Responses to APR Patch

Posted by Brian on January 20, 2007

A few months ago I shared a patch for APR that enables Subversion on a Macintosh computer to access FSFS repositories hosted on a Windows file server by means of file:/// URLs.

This is useful where a real Subversion server (accessed by svn:// or http:// URLs) is not possible or practical. In my case, the policy at work is that our workstations are not to be used as servers and the IT department is not going to setup and maintain a Subversion server for infrequent use by a small number of people.

We found an acceptable solution by creating a few FSFS-backed repositories on a shared folder of one of the existing Windows file servers. This worked fine when accessing the repositories with Windows computers, but failed with Macintosh computers because of a bug and limitations of the Mac OS X SMB support. The patch that was developed solved the problem nicely for our small group of Subversion users.

Since we had good results with the patch, I decided to share it by posting on this web site and submitting it to the APR developers by means of a bug report (#40700). I also sent in a hint to, though I admit that it could have been worded more clearly.

I’ve received several responses on the patch, several thanking me for finding a usable work-around and others ridiculing any IT department that would not setup a proper Subversion server.

Patch Rejected

The patch I has submitted to the APR developers was rejected with this explanation from Joe Orton.

“don’t do that” is probably the best answer here. If fcntl locking won’t work over SMB then FSFS won’t work over SMB.

If write(,,0) fails then that sounds like a Darwin bug, there’s no excuse for that really; Subversion needn’t make such a call anyway so it could be worked around at in Subversion.

I certainly agree that write(,,0)` failing is a bug in Mac OS X. In fact, I submitted a bug report (#4647254) to Apple so their engineers would be aware of it and hopefully provide a fix in a future update. Until then, a work-around could be implemented within Subversion as the APR developer suggested to prevent such a call from happening.

The rejecting of the file locking patch is understandable since few other projects that use APR are as likely to be affected by the limitations of Mac OS X file locking support for SMB filesystems. However, FSFS not working over SMB since fcntl locking is not properly supported in Mac OS X does not have to be the case.

FSFS Should Work Over SMB on Mac OS X

One of the most important features of FSFS is that it is usable over network filesystems, and this should include SMB filesystems. Notice this quote from page 73 of the Subversion Book, which implies that not only should it be possible, but it is a viable option for those who can not run a ‘real’ server process.

If you need multiple computers to access the repository, you create an FSFS repository on the network share, not a Berkeley DB repository. Or better yet, set up a real server process (such as Apache or svnserve), store the repository on a local filesystem which the server can access, and make the repository available over a network.

It is likely that the IT department where I work will setup a real Subversion server as the usefulness of it becomes more apparent to them. When this happens, the need for FSFS to work over SMB will not diminish. The reason for this can be see in the Subversion book under the heading “What is Subversion?”.

Subversion … is a general system that can be used to manage any collection of files. For you, those files might be source code—for others, anything from grocery shopping lists to digital video mixdowns and beyond.

Mac OS X is designed to treat certain folders as opaque bundles, presenting them to the user as a single file. It is not far-fetched to think that a developer may embed a Subversion FSFS-backed repository in such a bundle to manage a set of files or other pieces of data. The end-users would rightly expect these to work anywhere they are presently accustomed to working with files, both on their local hard drive or Windows file server.

What Is Next?

Since the APR patch was rejected, I have begun to pursue other options to ensure that Subversion on Mac OS X will work with FSFS repositories over SMB filesystems.

  1. Rewrite the patch for Subversion instead of APR. Since the issue seems to primarily affect Subversion, perhaps the patch will be better suited there instead of in APR. All the code for the patch would be applied to the libsvn_subr/io.c file.
  2. Try to hack the smbfs implementation in Mac OS X. This is based on code for the SMB protocol and filesystem implementation for FreeBSD (1.1MB download). Solving the issues at this level will fix it for all products, not just Subversion or APR.

Until I make progress on either of these options, feel free to continue using the APR patch if you need Subversion to work with your particular situation. As always, your comments and suggestions are welcome.