Custom Volume Icon SSHFS

425 views
Skip to first unread message

Omar Hijab

unread,
Dec 27, 2015, 12:14:21 PM12/27/15
to OSXFUSE

I couldn't get the volicon to work, so I decided to learn how to set up a custom icon from scratch for an sshfs mounted volume following 


Well, it turns out what is in there doesn't apply to my OS X (Yosemite), maybe it did in a previous iteration. The following works for my setup which is OS X 10.10.5 SSHFS-mounting a Linux server folder. As part of the explanation, I'll include the minimal info regarding OS X resource forks etc, because it was useful to me while figuring this out, and I couldn't find a simple coherent explanation without reading developer-level material.


The GUI approach to attaching an icon to an OS X object is


a. copy an image file in icns format into the clipboard,

b. select the object

c. press Command-I (Get Info),

d. select the icon image at the top left corner of the Get Info pane and paste.


Below is an exposition of the alternative command-line approach to attaching an icon.


When applying the GUI approach, what happens in the background? Where does the Finder store this image for future recall? As opposed to OS X, in Unix, a file is a stream of bytes, an unstructured object. In OS X, a file is broke into a structure of "forks": data fork, resource fork, etc. The file data is what's in the data fork, while the resource fork contains additional data such as the icon image file, and a flag alerting Finder that the file has a custom icon.


How then does OS X deal with foreign file systems such as Unix or NTFS typically presented as network volumes? In other words, suppose you attach (using the GUI approach) an icon to the file ~/filename on a Unix volume that is mounted as a Samba share. Since the Unix volume cannot host resource forks, for consistency OS X creates the "dot-underscore" file ._filename in the same folder containing filename and places the resource fork data in there. For example, changing the icon for ~/public_html creates the file ~/._public_html.


Similarly, when you attach (using the GUI approach) an icon to a network volume, OS X creates the file ._. in the root folder of the volume (since . is Unix's self-dir and the root folder has no parent), and places the icon image file as the file .VolumeIcon.icns in the root folder of the volume. The file ._. contains only the custom icon flag and is small  and is universal, ie independent of the volume or the mount point. Actually, the network folder's root does have a parent, /Volumes, and it is more consistent with the previous paragraph to create ._* inside there, alongside the mount point. This is in fact what the CUSTOM_VOLUME_ICON URL above describes, and this may have been the way OS X did things 5 years ago, but is no longer so. 


Thus, if you've set up a remote folder to show up with a specific icon when mounted, to do so for another remote folder involves copying over the two files ._. and

.VolumeIcon.icns. To change the icon image, create a new icns file and copy it over to .VolumeIcon.icns. Then make Finder aware of the custom icon by restarting Finder. 


I incorporated these steps in a simple GUI front-end for sshfs, that Mac users who've never touched Terminal can use:


https://it.cst.temple.edu/~it/sshfs/

Sam Moffatt

unread,
Dec 27, 2015, 1:21:42 PM12/27/15
to osxfus...@googlegroups.com
Interesting read, one clarifying point on the "dot-underscore" files are actually called AppleDouble files. 

Another thing to note is that while many UNIX file systems don't support forks (data/resource or named), they generally have the concept of extended attributes. On Mac OS X these are implemented as named forks of a file. Solaris and NFSv4 behave similarly in supporting extended attributes as forks. Finally NTFS supports a similar concept though called it streams. 

Cheers,

Sam

--
Sam Moffatt

Note: I'm not at my desk, responses may be delayed. Apologies for the typos, smartphones aren't all that smart. 

--
You received this message because you are subscribed to the Google Groups "OSXFUSE" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osxfuse-grou...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages