Determining the Culprits

By: Scott Doenges - Revised: 2006-05-30 devin

Introduction

If your app won't work after setting custom permissions (the app will either crash, refuse to open, or behave erratically after opening), you need to determine which files/folders are to blame.

Trial and Error

1. Grant write access to suspect files and folders one by one, to narrow down which ones are causing the problem.

2. Run "sudo fs_usage -w" while opening the app. Alternately, run "sudo fs_usage -w > ~/Desktop/errorlog" which will save the fs_usage results into a file on your desktop.

fs_usage presents an ongoing display of system call usage information pertaining to file system activity. By default this includes all system processes. Run this command and open your app, wait for the error to occur, then stop fs__usage with ^C. Now slog through the results and look for suspicious files (see image below). This may require a lot of slogging (10,000+ lines, depending on how long you leave it running), and you will probably need to set your Terminal window to have unlimited scrollback:

Sample fs_usage Output in Terminal

3. Run "ktrace -cp <pid>" while opening the app:

ktrace enables kernel trace logging for the specified processes. Kernel trace data is logged to the file ktrace.out. The kernel operations that are traced include system calls, name translations, signal processing, and I/O. As with fs_usage, run this as you open your app, then look through the results for files that your app was trying to access. (Note that ktrace and fs_usage are quite useful for this purpose, but it takes time and patience to look through the voluminous results. Most of the time, the answer to your problem lies somewhere in the results of fs_usage or ktrace).