2

I have a Raspberry Pi running Transmission. The main data partition is on a USB drive. The partition is formatted as HFS+ (hfsplus) in case I need to plug it into my Mac. The Mac connects to the data partition via Samba.

Transmission has a feature to run a script when the download completes. But this does not recognize that the download may still be seeding. Instead, I have a cron job running under my username "myuser". This job triggers a script which will check for a completed download, determine whether it is still seeding, and if not, process the download.

The cronjob was setup using crontab -e under myuser:

*/5 * * * * /media/Data/torrents/torrent-clean

The script will make a new directory if needed and move the file to that directory. Most of the script is involved in formatting the name of the new file and directory and accessing the torrent daemon. The pertinent lines are:

mkdir "${target}/${folder_title}"
mv "$the_video" "${target}/${folder_title}/${video_title}"

The whole script: http://pastebin.com/JqqRMRp8

The directory gets created by the script with user/group "myuser users" and the file gets created with "myuser myuser". (Why?)

drwxr-xr-x 1 myuser users 3 Nov 28 10:33 some.directory
-rw-rw-r-- 1 myuser myuser 48477071 Nov 28 10:06 some.file.ABC.mp4

When I access the new file from the Mac and try to change its name, strange things happen:

  • If I delete the uppercase "C" from the name, I succeed.
  • If I add a lowercase "c" back to the name, sometimes it accepts the lowercase "c" and sometimes it changes it back to an uppercase "C". (Why?)
  • If I change the uppercase "ABC" to a lowercase "abc", I get a permissions error. (Why?)

During the successful changing of the name, the permissions get changed:

-rw-rw-r-- 1 myuser myuser 48477071 Nov 28 10:06 some.file.ABC.mp4
-rwxrwxr-x 1 myuser myuser 48477071 Nov 28 10:06 some.file.ABC.mp4 (Why?)

Similar, but slightly different things happen when changing the name of the directory:

  • If I add the uppercase "A" to the name, I succeed.
  • If I change the uppercase "A" to uppercase "E", I succeed.
  • If I change the uppercase "E" to a lowercase "e", it accepts it, but changes it back to uppercase "E".
  • If I again change the uppercase "E" to a lowercase "e", I get a permissions error. (Why?)

During the successful changing of the name, the permissions get changed:

from: drwxr-xr-x 1 myuser users 3 Nov 28 10:33 some.directory
to: drwxrwsr-x 1 myuser users 3 Nov 28 10:33 some.directoryE  (Why?)

Some of this may be caused by SMB. The relevant parts of my smb.conf:

[Pi2_Data]
path = /media/Data
valid users = @users
force group = users
create mask = 0775
force create mode = 0775
security mask = 0775
force security mode = 0775
directory mask = 2775
force directory mode = 2775
directory security mask = 2775
force directory security mode = 2775
browseable = yes
writeable = yes
guest ok = no
read only = no

Thanks for any insight.

  • "The partition is formatted as HFS+ (hfsplus) in case I need to plug it into my Mac. The Mac connects to the data partition via Samba." if you are using Samba anyways, why HFS+? Also, why not FAT? BTW, show us your script/cronjob and what user executes it. – Braiam Nov 28 '14 at 16:22
  • 1. I'm using HFS+ in case the Rasp Pi craps out and I need to plug the drive into the Mac. FAT has an upper limit to file size. 2. The script is long. The specific lines are: mkdir "${target}/${folder_title}" mv "$the_video" "${target}/${folder_title}/${video_title}" 3. The cronjob was setup using crontab -e under myuser: */5 * * * * /media/Data/torrents/torrent-clean – rammjet Nov 28 '14 at 16:33
  • Edit your question to include the script. – Braiam Nov 28 '14 at 16:43
  • I've compromised. The script is included in a pastebin link. – rammjet Nov 28 '14 at 16:59
  • A stab in the dark here, but isn't HFS+ case-insensitive, which may explain the part of your question where you try to change an upper case letter to a lower. – garethTheRed Nov 29 '14 at 8:22
1

According to wikipedia (last paragraph):

HFS saves the case of a file that is created or renamed but is case-insensitive in operation.

In practise this often means you cannot rename a file while preserving the name. Running this via Samba (that probably expects a case-sensitive filesystem underneath, as those have been around for at least 30 years), can only enhance the problems.

If one requirement is that the disc must be directly pluggable into the Mac I would look to install OSXFuse on the Mac and format the drive with ext3.

1

I went in a different direction and solved my problem. Braiam's comment and Anthon's answer got me to thinking and researching Samba. That led me to discover that Linux has a service for AFP (Apple File Protocol) which is Apple file sharing. The Linux service is Netatalk.

Not only does it respect my file name changes, it also allows me to use other attributes of the Apple Finder.

I turned off Samba and installed Netatalk.

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install netatalk

Edit the config file

sudo service netatalk stop
sudo nano /etc/netatalk/AppleVolumes.default

On the bottom of the file, add your shares

# By default all users have access to their home directories.
~/  "Home Directory"
/media/Data  "Pi Data"

Restart netatalk

sudo service netatalk start

Connect the Mac to the shares.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.