Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

smb_fstat doesn't work for directories #79

Open
naxos opened this issue May 23, 2016 · 10 comments
Open

smb_fstat doesn't work for directories #79

naxos opened this issue May 23, 2016 · 10 comments
Labels

Comments

@naxos
Copy link

naxos commented May 23, 2016

On a directory, smb_fstat seems to always return NULL.

Current workaround:

smb_stat stat = smb_fstat(s, tid, path);
if (stat == NULL) {
    smb_stat_list stats = smb_find(s, tid, path);
    if (stats != NULL) {
        size_t n = smb_stat_list_count(stats);
        if (n == 1) {
            stat = smb_stat_list_at(stats, 0);
        }
    }
}

Unless of course, I misunderstood the api...

@jbkempf
Copy link
Contributor

jbkempf commented May 23, 2016

A quick look at the code confirms this.

@naxos
Copy link
Author

naxos commented May 23, 2016

Also, smb_stat_name(stat) on the result of smb_fstat returns the complete path (including the name of the share), while the same call on an item of a smb_stat_list only returns the actual name of the file or directory. I don't know, which behaviour is correct. I'd prefer the latter.

@jbkempf
Copy link
Contributor

jbkempf commented May 23, 2016

What does fstat give?

@naxos
Copy link
Author

naxos commented May 23, 2016

Not sure I understand your question. As mentioned above smb_fstat gives the complete path smb_stat_list just the name(s).

@naxos
Copy link
Author

naxos commented May 23, 2016

Ah, are you talking about the samba client?

@naxos
Copy link
Author

naxos commented May 23, 2016

If however, you are referring to the posix function, the file name or path doesn't seem to be part of the result:

struct stat {
    dev_t     st_dev;     /* ID of device containing file */
    ino_t     st_ino;     /* inode number */
    mode_t    st_mode;    /* protection */
    nlink_t   st_nlink;   /* number of hard links */
    uid_t     st_uid;     /* user ID of owner */
    gid_t     st_gid;     /* group ID of owner */
    dev_t     st_rdev;    /* device ID (if special file) */
    off_t     st_size;    /* total size, in bytes */
    blksize_t st_blksize; /* blocksize for file system I/O */
    blkcnt_t  st_blocks;  /* number of 512B blocks allocated */
    time_t    st_atime;   /* time of last access */
    time_t    st_mtime;   /* time of last modification */
    time_t    st_ctime;   /* time of last status change */
};

@naxos
Copy link
Author

naxos commented May 23, 2016

And this is from the samba smbclient:

stat file
This command depends on the server supporting the CIFS UNIX extensions and will fail if the server does not. The client requests the UNIX basic info level and prints out the same info that the Linux stat command would about the file. This includes the size, blocks used on disk, file type, permissions, inode number, number of links and finally the three timestamps (access, modify and change). If the file is a special file (symlink, character or block device, fifo or socket) then extra information may also be printed.

@jbkempf
Copy link
Contributor

jbkempf commented May 23, 2016

I'd say just the name of the file, then.

@naxos
Copy link
Author

naxos commented May 23, 2016

Thanks. BTW, on the command line stat just echoes what you key in, e.g. stat -f "%N" ../asdf/test.pdf would print ../asdf/test.pdf.

@jbkempf jbkempf added the bug label May 27, 2016
@tguillem
Copy link
Contributor

Using bin/dsm sample, I cannot reproduce your issue. smb_fstat is working for a directory and tell me that the file is indeed a directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants