Leopard shines the spotlight on xattrs

Posted by brian Sunday, November 04, 2007 11:41:00 GMT

When Tiger was released back in 2005, Spotlight search technology was all the rage. Several articles appeared showing off the technology and explaining the details. For most people, being able to easily find their files was all they cared about. Others thought it was too slow and immediately disabled it.

If you're a geek like me, you probably got excited when Amit Singh explained how to use the undocumented fsevents API to monitor spotlight events directly. However, although spotlight in Tiger monitors basic file activity, it ignored xattrs (extended attributes). This matters, because extended attributes have major potential to store arbitrary metadata on files. Ever wanted to be able to tag your files? Maybe you've used one of the existing Finder-comment hacks, or a more elegant solution like Tagbot. Perhaps you've experimented with spotmeta, a project started by Ben Summers that made extended attributes searchable through spotlight. In Tiger, this was difficult, since the fs_event system did not monitor changes to extended attributes. A quick look through the bsd kernel source code shows that this has changed in Leopard:

(from xnu/bsd/sys/fsevents.h)

// Event types that you can ask to listen for
#define FSE_INVALID             -1
#define FSE_CREATE_FILE          0
#define FSE_DELETE               1
#define FSE_STAT_CHANGED         2
#define FSE_RENAME               3
#define FSE_CONTENT_MODIFIED     4
#define FSE_EXCHANGE             5
#define FSE_FINDER_INFO_CHANGED  6
#define FSE_CREATE_DIR           7
#define FSE_CHOWN                8
#define FSE_XATTR_MODIFIED       9
#define FSE_XATTR_REMOVED       10

#define FSE_MAX_EVENTS          11
#define FSE_ALL_EVENTS         998

#define FSE_EVENTS_DROPPED     999

Leopard adds the FSE_XATTR_MODIFIED (9) and FSE_XATTR_REMOVED (10) events, making it possible to monitor changes to extended attributes. This might seem like no big deal. However, this opens the door to building custom metadata solutions and integrating them directly into the operating system. I haven't installed Leopard yet, so I'm not sure if Apple is utilizing this underlying technology for anything in Leopard. I checked the online Spotlight metadata attributes, and there is nothing obvious to suggest that Spotlight is making custom extended attributes easily searchable through the MDQuery API. Apple has a habit of adding features to the kernel in preparation for use in later versions of the OS (cough*autofs). This little gem of a feature could bring a project like spotmeta back to life, or inspire a new round of xattr-based metadata solutions. Stay tuned for more information on this topci after I have time to install Leopard.

(07-dec-2007 update: fixed a few typos)

You might need version control if

Posted by brian Wednesday, October 31, 2007 09:39:00 GMT

  1. You're working on a grant or paper with collaborators and your filenames look like this (no, I'm not making this up):

    endo07_gaz_D2edits_26oct_2pm_kih_26Oct_700pm_rick_27Oct.doc

  2. The filename would actually be longer, except that then it would exceed the 255 character limit, so you just make it more cryptic instead. Soon you end up with files named:

    e07gD2e26o14k26o19r27o.doc

Version control software is not "for programmers only". If you're working on a collaborative writing project, please, pretty please, stop pretending that good version control tools do not exist and learn how to use one of them. While you're at it, ditch word and use a real text editor that supports syntax highlighting and integrates with your version control system. Then you can write with markdown + LaTeX using Pandoc and save yourself and your collaborators from lots of headaches.

Recent Articles

  • ReadyNAS upgrade includes ssh access

    Posted by brian Thursday, August 23, 2007 23:22:00 GMT

    If anyone out there is actually checking this site for the latest info on readynas shell access, then know that this will probably be my last post about the topic. Infrant Netgear has finally released a beta version of RAIDiator v4. Highlights include:

    • RAIDiator 4 is now based...
  • Take back your readynas

    Posted by brian Tuesday, July 24, 2007 13:44:00 GMT

    A few people have asked if I’ve been able to compile a working kernel and run it on my readynas. I haven’t attempted this, but the lazy web has come through for all of us. Head over to 360 and learn how to compile a working kernel and...

  • ReadyNAS shell access redux

    Posted by brian Saturday, May 05, 2007 21:44:00 GMT

    When I wrote the original article on how to enable shell access to the readynas, I was motivated by the need to solve my backup problems. Given the unfulfilled promises from infrant regarding ssh availability, I was also frustrated, and wanted to share how easy it...

  • Infrant ReadyNAS software

    Posted by brian Thursday, March 22, 2007 19:32:00 GMT

    The first quarter of 2007 is almost over and Infrant has still not released any patches that enable ssh access to the readynas. I guess they were probably too busy putting out fires caused by Windows Vista. Those poor bastards.

    Judging from the responses to my cross-compiler post...

  • Building a compiler for the Infrant ReadyNAS

    Posted by brian Tuesday, January 16, 2007 12:17:00 GMT

    Having shell access is cool, but the real fun doesn't begin until you can build and run the software that you want on the ReadyNAS. After an embarrassingly long delay, here is the second installment of my series on Infrant ReadyNAS hacks. In this article, I'll show you how...

  • Infrant ReadyNAS shell access

    Posted by brian Thursday, November 23, 2006 00:12:00 GMT

    The Infrant ReadyNAS NV is a great backup server or media server. However, the one critical missing feature that will make any power-user break into a cold sweat is ssh shell/root access. My initial reaction was: Huh!? I’m buying this box to store my precious data and you...

  • Infrant ReadyNAS hacks

    Posted by brian Wednesday, November 22, 2006 23:37:00 GMT

    The Infrant ReadyNAS NV is an extremely capable network attached storage (NAS) device that packs some serious power into a tiny box. If you’re in the market for a RAID storage device or perhaps even a home media server, give it a look. You’ll probably be impressed.

    The...

  • Work at home with your SOCKS on

    Posted by brian Saturday, October 21, 2006 21:15:00 GMT

    Most scientific articles are published in journals that are not freely accessible to the general public. If you’re in academic science, biotech or big pharma, your respective institutions pay the big bucks to the publishers so that you can access journal content over the internet. However, what about when you...

  • Upgrade Complete

    Posted by brian Tuesday, October 17, 2006 21:45:00 GMT

    I just finished migrating my site to mephisto. There might be a few rough spots left to smooth out, but all of the old content that people were actually viewing should available at the same urls, although some things have new homes that should be reflected in the...

  • Life with Mephisto

    Posted by brian Wednesday, September 20, 2006 23:08:00 GMT

    No, I’m not talking about the demon. I’m not living in hell, yet. I’m talking about the hot, new blogging cms app that all the cool kids are using. I’ve finally upgraded this site to use some modern technology. If you’re one of the ~100 people who...

  • Pier Design Tutorial

    Posted by brian Thursday, May 25, 2006 13:55:00 GMT

    Introduction

    Lukas Renggli has created an amazing content management system called Pier. It's still in the alpha phase, but the functionality and flexibility make it a truly innovative content management solution. If you've played with wiki software in rails or php, try Pier and Seaside and...