Thursday, June 28, 2012

Update: Removing those darn .DS_Store and .AppleDouble directories from shared network storage

Seems at 0200 in the morning I was not accurate in my description.  I apologize.


This one is a short one. 


I searched long and hard for this one and found a partial fix.  The environment variables of old (Leopard and Tiger) do not work to stop the creation of these files. I found out the hard way. :-)


.DS_Store

Here is the command to stop the creation of .DS_Store Directories that pollute your network storage resources. For For Mac OS X Lion you need to use:
defaults write com.apple.desktopservices DSDontWriteNetworkStores true
Now you must Logoff or Restart.


.AppleDouble

To stop the creation of .AppleDouble folders you need to edit your AFP service configuration.  There is usually a "No AppleDouble" or "Enable AppleDouble" configuration setting that needs to be set true (For the NO option) or set to false (For the Enable Option).


Note: In FreeNAS 8.0.4 it seems that the .AppleDouble directories are created anyway regardless of setting.  But at least they seem to be empty and can be removed (rm -r /path/).




The Who, What, and When

The .AppleDouble Directories are used by Mac OS X to store Extended Attributes (exattr) for files residing on filesystems that are not formatted HFS+.  They are most commonly seen when moving a flash drive from your Mac to your Windows Machine.


The .DS_Store Directories store Finder Information.  Such as in "Get File Information" you can access a "Comments" field.  If you provide information on the file i the comment it is stored and Finder Information.  If this directory is missing on remote storage, other Mac users would not be able to see the comment you created.


Why get rid of them?

On network storage you can have the same share presented over AFP (Apple Filing Protocol) and CIFS (Common Internet File System).  Windows users that connect over CIFS can see the extra Apple directories.  The files often copy the name of the original file and prefix it with "._".  Windows users can mistakenly access these files and think their data is corrupt.


Hope this helps, :-)


This is the day the Lord has made. We will rejoice and be glad in it.
  --Psalm 118:24, NLT

Saturday, June 9, 2012

Interesting Mac OS X Configuration Tips

Why


Yes you can google and find many more results like the following:
MacLife.com -8 Finder Terminal Hacks
Mac OS X Tips - Terminal Commands For Hidden Settings
But these are the ones I use almost all the time when working on Mac Systems.  So I thought I would compile them here as there are only a few.



Tips


Show all files in Finder

The following allows you to show all files in a directory from the GUI.  I am a full on Terminal Fan, but some times it's just faster to do it the easy way.
Show All Files
sudo defaults write com.apple.Finder AppleShowAllFiles YES
Hide Hidden Files
defaults write com.apple.Finder AppleShowAllFiles NO

Add Quit to Finder

Trust me on this one, one day you will need to quit the Finder.
Can Quit Finder
sudo defaults write com.apple.finder QuitMenuItem 1
Can Not Quit Finder
sudo defaults write com.apple.finder QuitMenuItem 0
Restart the finder by using Option+Right Click (Or Two Finger on Touch Pad Click) on the Finder Icon. Click Relaunch.

Show full path in Finder title bar

It makes moving from the Finder GUI to the Terminal so much easier.
Path in Finder Title
defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES
Remove Path from Finder Title
defaults write com.apple.finder _FXShowPosixPathInTitle -bool NO
Restart the finder by using Option+Right Click (Or Two Finger on Touch Pad Click) on the Finder Icon. Click Relaunch.

Verbose Boot

This one give you more of a Linux Style Kernel boot so you can see the steps that OS X's Kernel is taking.
You can hold Command+V during boot. 

Or
Set your kernel to always boot Verbosely by doing the following in a terminal.
sudo nvram boot-args="-v"

You can also
sudo nano /Library/Preferences/SystemConfiguration/com.apple.Boot.plist
Now add -v between <string> and </string>.
Save Changes.

Mac OS X Safe Mode

Hold the Shift key while booting.  I have messed up kernel flags so bad in the past that Single User mode (Hold Command+S during boot) would not even boot.  This mode would using default kernel settings.

Mac OS X Startup Manager

Hold the Option key (fitting no?) during boot to load the Startup Manager.  This will allow you to chose a Startup Disk, Flash Drive, Firewire Drive or CD to boot from.  Handy if you forgot to use the Startup Disk utility before rebooting.



“Pride leads to disgrace, but with humility comes wisdom.”
Proverbs 11:2

Friday, June 8, 2012

Aptana Studio 3 and AFP (Apple Shares)

(The JavaVM -Dosgi.locking=none trick, from Eclipse)


Problem:


I installed Aptana Studio 3 on my MacBook.  I use Aptana because I am partial to the slimed down Eclipse environment it offers.  Majority of my code and scripts are Python, Java, and XHTML so it makes sense not to use the entire Eclipse suite.  However I came across the strangest error when I pointed Aptana's workspace to my AFP share on my NAS.



Many failed attempts to diagnose why Aptana saw the share as "read-only" had occurred when looking in the logs.  So, I went Geek on it.  I tried using the command line argument -data [path] when launching Aptana.  This forces Aptana to use the value provided (replace [path] with your intended path) as the workspace directory.  

With a Mac this is not as simple as running Aptana.app -data [path].  In very high level terms I will explain why.  The [name].app items in your Applications folder are actually Directories.  These hold all the vital contents and resources required to launch you Mac Application.  When you click (launch or execute) the directory, it will proceed to launch [name].app/Contents/MacOS/[name]
In the case of Aptana we can list the directory like so:
ls /Applications/Aptana\ Studio\ 3/AptanaStudio3.app/Contents/MacOS/
-rwxr-xr-x  1  70368 May 30 02:13 AptanaStudio3
-rw-r--r--  1  458 May 30 02:13 AptanaStudio3.ini

So now we can test the argument in a terminal window. 
/Applications/Aptana\ Studio\ 3/AptanaStudio3.app/Contents/MacOS/AptanaStudio3 -data [path]

It is more than likely that your AFP share still will not work, you will probably see one of two errors.
  1. The folder "[path]" is read-only.
  2. Locking is not possible in the directory "[path]". A common reason is that the Runtime Environment does not support file locking for that location. Please choose a different location , or disable file locking passing "-Dosgi.locking=none" as a VM argument.

This all means that Aptana's underlying JavaVM can't perform a file lock on the target AFP share.  To disable file locking you need to add two parameters to your command.
 -vmargs
 -Dosgi.locking=none