Unable to `ls` a CIFS/SmbFS Mount

Posted by – January 3, 2007

Ever wonder why you could mount a CIFS/SmbFS share, but you get a nice little “permission denied” type of message when you try to ls the mount point? We ran into this exact issue at BitLeap. The cause of the issue wasn’t too hard to figure out. See, you have rights at the share level, but you do not have file system level rights.

Easy to fix, however since we do not administer the CIFS/SmbFS servers, we needed a way to detect this issue so that we could mark the mount as invalid and raise an error to the customer. We accomplished this by simply checking to see if the php function scandir returned an array that contained at least two items. This works great, since the array is empty when we do not have access to the directory, and will always return at least . and .. otherwise. I love when issues can be easily addressed.