Folder names with a trailing space show empty on SMB shares.

scott2500uk

Dabbler
Joined
Nov 17, 2014
Messages
37
Running TrueNAS-12.0-U7.

Over the holidays we migrated our fileserver to brand new hardware and made the switch from AFP to SMB file sharing. We are pretty much a 100% Apple Mac company. We migrated the data using ZFS send/recv to copy over datasets, from the new server we blew away all permissions and ACLs and implemented new ACLs, and propagated down. Set up the SMB shares with Apple style encodings enabled.

All well and no complaints from staff except a couple of folders showing as empty that were not empty before. Any attempts at altering or using the folder over SMB resulted in an error. Had a little panic thinking the migration hadn't been completed properly. Logged into the server over ssh and verified the problematic folders looked good with files there and ACLs set correctly.

Debugging the problem I first tried to rename the folder thinking there might be some weird character in the name. That's when I saw the folder name had a trailing space. Removing the trailing space from the folder name then fixed the issue and the folder was once again browseable over SMB.

Is this a bug, a known issue, or something that SMB doesn't support?
 

scott2500uk

Dabbler
Joined
Nov 17, 2014
Messages
37
Thanks I didn't know that.

If I run this on my datasets I can see 1000's of folders with trailing spaces.

Code:
find . -name '.zfs' -prune -o -name '* ' -type d


Does anyone know how to expand that command to rename those folders removing the trailing space?

Thanks
 

scott2500uk

Dabbler
Joined
Nov 17, 2014
Messages
37
Answered my own question with a help of a friend:

Code:
find . -name '.zfs' -prune -o -name '* ' -type d | perl -lne 'chomp; (my $new = $_) =~ s/ +$//; print "mv '"'"'$_'"'"' '"'"'$new'"'"'"' | sh


You can run the above code without | sh at the end to see what would be run as mv commands to sense check
 
Top