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

Re: Request for advise with struct stat, ACL, xattr, zlib (2nd try)



Petr Salinger a écrit :
>>  libisofs/builder.c:209: warning: passing
>>  argument 2 of 'aaip_cleanout_st_mode' from
>>  incompatible pointer type
>>
>> Is stat.st_mode not of type mode_t ?
>>
>> The line in question is:
>>
>>  aaip_cleanout_st_mode(a_text, &(info.st_mode), 4 | 16);
>>
>> Argument number two is a component of
>>  struct stat info;
>>
>> The function prototype is
>>  int aaip_cleanout_st_mode(char *acl_text, mode_t *st_mode, int flag);
>>
>> Can somebody please have a look into
>>  <sys/stat.h>
>> whether
>>  struct stat.st_mode
>> is of different size than mode_t ?
>> The warning appears on amd64 and on i386.
> 
> Unfortunately yes:
> 
> /* Structure describing file characteristics.  */
> struct stat
>    {
>      __dev_t st_dev;             /* Device containing the file.  */
>      __ino_t st_ino;             /* File serial number.  */
>      __uint32_t st_mode;         /* File mode.  */
>      __uint32_t st_nlink;        /* Link count.  */
>      __uid_t st_uid;             /* User ID of the file's owner.  */
>      __gid_t st_gid;             /* Group ID of the file's group.  */
>      __dev_t st_rdev;            /* Device number, if device.  */
>      struct timespec st_atim;            /* Time of last access.  */
>      struct timespec st_mtim;            /* Time of last modification.  */
>      struct timespec st_ctim;            /* Time of last status change.  */
>      __off_t st_size;            /* Size of file, in bytes.  */
>      __blkcnt_t st_blocks;       /* Number of 512-byte blocks allocated.  */
>      __blksize_t st_blksize;     /* Optimal block size for I/O.  */
>      __uint32_t st_flags;        /* User defined flags.  */
>      __uint32_t st_gen;          /* Generation number.  */
>      __quad_t __unused1[2];
>    };
> 
> 
> Similar problem might be with nlink_t (16 bit also). Both are mandated by POSIX
> http://www.opengroup.org/onlinepubs/9699919799/basedefs/sys_stat.h.html
> 
> IMO, we should fix our headers, but retain binary compatibility
> which on little endian should be doable by
> 
> -    __uint32_t st_mode;        /* File mode.  */
> -    __uint32_t st_nlink;       /* Link count.  */
> +    __mode_t st_mode;		/* File mode.  */
> +    __mode_t __pad_mode;	/* __mode_t is 16 bit, align to 32 bit to retain previous ABI */
> +    __nlink_t st_nlink;	/* Link count.  */
> +    __nlink_t __pad_nlink;	/* __nlink_t is 16 bit, align to 32 bit to retain previous ABI */
> 
> And the stat16_to_stat() should zero __pad_mode and __pad_nlink.
> 
> Aurelien, Cyril do you agree with this (eglibc) change ?
> 

That looks fine given that the kernel syscall is using 16 bits. For big
endian targets, given we have none of them, it should not be a problem,
they can use the same definition.

It's a pitty we have such an ABI, as after this change stat16 and stat
looks really similar (unless I have missed a difference), modulo the
padding.

-- 
Aurelien Jarno                          GPG: 1024D/F1BCDB73
aurelien@aurel32.net                 http://www.aurel32.net


Reply to: