RPi-Distro / repo

Issue tracking for the archive.raspberrypi.org repo
37 stars 1 forks source link

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

Open longhighway opened 1 year ago

longhighway commented 1 year ago

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 commented 1 year ago

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)?