Home Forums OS X Server and Client Discussion Questions and Answers mdls and md server in single user mode won’t work

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #363968
    klktrk
    Participant

    I’m not able to get mdls to work in single user mode, even after running /usr/libexec/register_mach_bootstrap_servers on /etc/mach_init.d (which does contain the mds.plist to start up the md server).

    running mdls will either hang (need CTRL-C to break out of it), or will return an error along the lines of “cannot find ./foo/bar/file.ext”

    When I do a ps -ax after the bootstrap, I see that there is no md server in the process list.

    Anyone have any clues on how to get this going?

    Background: I’m trying to cobble together a way to ascertain if a file is a Mac OS X alias file. Darwin sees it as a regular file, and of course bash has no built-in file test for Mac OS X style aliases, like -L for symbolic link, etc. I need a way, in bash, to find out if certain files are aliases or not, and wrote something that worked for me, using mdls and looking for the kMDItemContentType string and testing to see if it was “com.apple.alias-file”. But when I tried to run the script in single user mode (which is where I need it), no joy.

    Anyone out there with some insight? Is it possible to just call /System/Library/Frameworks/CoreServices.framework/Frameworks/Metadata.framework/Versions/A/Support/mds
    directly, without messing things up?

    Thanks.

    #363988
    klktrk
    Participant

    I got some helpful hints from a user on Mac Ars, and thought I’d share them. He recommended using the file utility, and looking into the file’s resource fork.

    Basically, an alias has two defining characteristics that can be tested in bash:
    1) It has a zero file size (all info is stored in the resource fork).
    2) using the file util agains the rsrc fork of the file will yield the response: ms-windows icon resource (weird).

    So, the code I cobbled together with his help:

    testfile=somefile
    # first, test for 0 file size
    if [ ! -s $testfile ]; then
    r=`file $testfile/rsrc | awk ‘/ms-windows icon resource/ { print $2 “.” $3 “.” $4 }’`;
    if [ “$r” = “ms-windows.icon.resource” ];then
    echo “it’s an alias”;
    fi
    fi

    This seems to be working.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Comments are closed