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

The stat(2) call doesn't detect directory on SMB share #323

Open
longhighway opened this issue Mar 24, 2023 · 1 comment
Open

The stat(2) call doesn't detect directory on SMB share #323

longhighway opened this issue Mar 24, 2023 · 1 comment

Comments

@longhighway
Copy link

The stat(2) call fails to show that a directory on an SMB share is a directory. It does behave correctly when given a directory on the Pi's SD card. The same call works correctly on the same share when run from an x86 Debian VM.

This program ("dir"):

#include <sys/stat.h>
#include <unistd.h>

int main(int argc, char *argv[]) {
    struct stat sbuf;

    stat(argv[1], &sbuf);

    if (S_ISDIR(sbuf.st_mode)) {
        printf("%s is a directory\n", argv[1]);
    }
}

Works when you give it a directory on the Pi’s drive:

> ./dir /tmp
/tmp is a directory

But it doesn’t work when you give it a directory on a SMB share (from MacOS) that’s mounted on the Pi:

> ./dir directory-on-smb
>

It also works with the same SMB share when you compile and run it on a x86 VM running Debian:

> ./dir directory-on-smb
directory-on-smb/ is a directory

Pi is a Raspberry Pi 3b+.
Virtual machine is a VMware VM running in VMware Workstation Player on a Windows 10 PC (x86).

OS on the Pi is Raspbian GNU/Linux 11 (bullseye).
OS on the VM is Debian GNU/Linux 11 (bullseye).
OS on the iMac that’s serving the CIFS share is MacOS 13.2.1

SMB client on the Pi is "smbclient/stable,now 2:4.13.13+dfsg-1~deb11u4 armhf”.
SMB client on the VM is "smbclient/stable,stable-security,now 2:4.13.13+dfsg-1~deb11u5 amd64”.

Compiler on the Pi is "gcc version 10.2.1 20210110 (Raspbian 10.2.1-6+rpi1)".
Compiler on the VM is "gcc version 10.2.1 20210110 (Debian 10.2.1-6)".

@XECDesign
Copy link
Member

XECDesign commented Mar 27, 2023

I'm not seeing this on my pi.

$ ./isdir samba
samba is a directory
$ ./isdir ./samba/software
./samba/software is a directory

What's the output of uname -a and mount (edit out any sensitive information)?

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

No branches or pull requests

2 participants