Re: [PATCH 09/15] tgt: os.h - bind() is picky about names

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



FUJITA Tomonori wrote:
> On Sun,  1 Mar 2009 18:51:53 +0200
> Boaz Harrosh <bharrosh@xxxxxxxxxxx> wrote:
> 
>> The BSD's bind does not like the Linux IPC names with zero
>> as first char and zeros padding at end. Separate implementations
>> in os.c.
>>
>> Note: On BSD, after exit a file is left in current directory
>>       with the pipe's name. The "up" script was modified to
>>       delete this file before and after the tgtd load.
>>       (File name is: TGT_IPC_ABSTRACT_NAMESPACE)
>>
>> Signed-off-by: Boaz Harrosh <bharrosh@xxxxxxxxxxx>
>> ---
>>  usr/bsd/os.c   |   14 ++++++++++++++
>>  usr/linux/os.c |   10 ++++++++++
>>  usr/mgmt.c     |    6 ++----
>>  usr/os.h       |    3 +++
>>  4 files changed, 29 insertions(+), 4 deletions(-)
> 
> Hmm, the following patch seems to work on both Linux and FreeBSD 7.1
> for me.
> 
> Yeah, I installed FreeBSD 7.1 to try to write the better patches.
> 
> 
> diff --git a/usr/mgmt.c b/usr/mgmt.c
> index 5351b2c..47c8820 100644
> --- a/usr/mgmt.c
> +++ b/usr/mgmt.c
> @@ -562,8 +562,7 @@ int ipc_init(void)
>  
>  	memset(&addr, 0, sizeof(addr));
>  	addr.sun_family = AF_LOCAL;
> -	memcpy((char *) &addr.sun_path + 1, TGT_IPC_NAMESPACE,
> -	       strlen(TGT_IPC_NAMESPACE));
> +	strncpy(addr.sun_path, TGT_IPC_NAMESPACE, sizeof(addr.sun_path));
>  
>  	err = bind(fd, (struct sockaddr *) &addr, sizeof(addr));
>  	if (err) {
> diff --git a/usr/tgtadm.c b/usr/tgtadm.c
> index 6280c99..71d7fc5 100644
> --- a/usr/tgtadm.c
> +++ b/usr/tgtadm.c
> @@ -182,8 +182,7 @@ static int ipc_mgmt_connect(int *fd)
>  
>  	memset(&addr, 0, sizeof(addr));
>  	addr.sun_family = AF_LOCAL;
> -	memcpy((char *) &addr.sun_path + 1, TGT_IPC_NAMESPACE,
> -	       strlen(TGT_IPC_NAMESPACE));
> +	strncpy(addr.sun_path, TGT_IPC_NAMESPACE, sizeof(addr.sun_path));
>  
>  	err = connect(*fd, (struct sockaddr *) &addr, sizeof(addr));
>  	if (err < 0)


Sure, thanks
  I did not want to change the Linux code, I have no experience
with IPC code, I thought it is important to have zero at first char,
otherwise why is it there?

Feel free to replace the patch with this one

Ack-by: Boaz Harrosh <bharrosh@xxxxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux SCSI]     [Linux RAID]     [Linux Clusters]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]

  Powered by Linux