:: Re: [DNG] slashes in FAT file names
Αρχική Σελίδα
Delete this message
Reply to this message
Συντάκτης: Didier Kryn
Ημερομηνία:  
Προς: dng
Αντικείμενο: Re: [DNG] slashes in FAT file names
Le 23/12/2018 à 18:16, karl@??? a écrit :
> Didier:
> ...
>>   2) there isn't a function in the C library which permits to change
>> the name of a file (or open it), except by giving its whole pathname.
>> Eg. it's not possible to open it from its directory entry.
> ...
>
> man openat
> man renameat
>
> int openat(int dirfd, const char *pathname, int flags);



    The file isn't refered by its directory entry, but by a file
descriptor allowing to read the directory, and the relative pathname
(which contains slashes). The slashes will be interpreted as a directory
tree which doesnexist.

If it was possible to refer to the file by the /struct dirent/
associated to each file in the directory, obtained by readdir(dirfd),
then it would solve the problem, but the only thing in /struct dirent/
which can be used to refer to the file is d_filename, which is its
relative pathname.

           struct dirent {
               ino_t          d_ino;       /* Inode number */
               off_t          d_off;       /* Not an offset; see below */
               unsigned short d_reclen;    /* Length of this record */
               unsigned char  d_type;      /* Type of file; not supported
                                              by all filesystem types */
               char           d_name[256]; /* Null-terminated filename */
           };

            Didier