Since I switched to using Macintosh predominately, I’ve tried a few different programs for editing text. I auditioned some of the available Macintosh native applications. The built in text editor, “TextEdit” is surprisingly useable, although it no longer offers much specific programming support. XCode has a capable editor, with IDE features for Macintosh application development, but it’s too slow and large to be more generally useful. The power editor on Macintosh always used to be “BBEdit” , but it’s expensive, and seemed complicated and old-fashioned. TextMate is very interesting, an attempt to bring together UNIX editing concepts with the OS X application frameworks, and I was nearly tempted to switch to it full time, but I eventually decided to stick with the editor I know best, GNU emacs .
It turns out that that’s not as straightforward a decision as it might seem. There’s a variety of different emacs implementations on offer. Apple ship a version of emacs 21 in /usr/bin , but it’s purely a terminal based application that has to run in an emulator window. This works well enough, but has restricted font rendering, and your editor session isn’t an application instance at the top level, being subprocess of the terminal application. You could compile a GUI emacs using the Apple X11 server, which improves the font handling, but still would be a sub-application process, and would introduce the usual klunky X11 clipboard integration . There are also a few ‘native’ Emacs application ports. Andrew Choi has ported both GNU Emacs and XEmacs to the Macintosh OS X carbon APIs, and there is something called “Emacs.app” which is an update of the NeXT Emacs port to a more modern emacs base.
I seem to have settled on using the Carbon emacs port, in a new variant that uses the ATSUI text rendering framework rather than QuickDraw . This seems to fix some of the very ugly font rendering behaviour I used to sometimes see with Carbon emacs. I suspect I am probably rather oversensitive to font rendering accuracy. I think this new engine is only available in the CVS tree for emacs, but this is quite simple to install on a Mac using MacPorts .
sudo port install emacs-devel +atsui
A remaining niggle is the use of emacs in server mode. Emacs is rather a heavyweight application, taking some seconds to load, and it carries a lot of state. Ideally you want to perform all of your editing in a single emacs session, rather than starting a new editor anew each time. Emacs has a client/server mode to allow you to do just this. Simply add
(server-start)
to your .emacs file to start the server, and use the emacsclient program as your editing tool. This contacts the running server and creates a new buffer for the invoked editing context. Setting your environment variables for EDITOR and VISUAL means that shell commands will use the emacs server as your default editor.
The niggle is that you then have to switch window context to edit. And as autoraise and raise-window do not seem to have any effect on Carbon Emacs, you have to manually find the emacs window for the server that is waiting for your edits, probably buried under a pile of windows. I’ve managed to go some way to fixing this problem with an unholy marriage of elisp and AppleScript.
The AppleScript
Tell application "Emacs" to activate
will raise the running emacs frame and switch focus to it. There is a command line program provided with OS X, osascript that can run AppleScript programs from script files, or run one-liners via the -e argument. It is therefore possible to add some elisp to the emacs initialisation scripts to automatically run the AppleScript snippet.
(defun my-server-visit-hook()
(interactive)
(shell-command
"osascript -e 'tell application
\"Emacs\" to activate'"))
(add-hook 'server-visit-hook 'my-server-visit-hook)
Every time a server buffer is created, this hook will be called, and emacs will raise itself to the front of the window stack, steal focus and prompt for input, which seems to be mostly what I’d want. I have yet to devise a manner of returning to the calling window context after editing, which will probably be a less trivial hack.
Apple have been providing the ability to securely encrypt your home directory for the last few versions of OS X. The cute name they have for this is FileVault . It’s largely a transparent business, and perhaps useful to have if your data might be found lying around somewhere, so I tend to enable it for portables.
It’s not entirely invisible. During use, your home directory changes to a spiffy modified icon. Logging in, and working with very large files seems to be slightly slower, and it prompts you to reclaim space on logout, which can take quite a while if you’ve recently re-organised a lot of data. And there’s a few more obscure differences that might show up. I was recently bitten by one of these, and perhaps it’s a testament to how seamlessly FileVault is slotted into the system in that it took me a little while to figure out what was going on.
I’d been playing around with some toy code for some co-operating daemons, and I was tweaking a section that might open some files read-write, to check that they would work with minimal access permissions. On a mac I tend to do all my development work inside my home directory, much like I do everything else. So I changed the ownership of my exectuable to a dummy user, enabled the set-user-id bit, locked down my data file’s permissions, and ran the tests. I wasn’t particularly suprised when it failed with access errors. First pass, my code, bound to be wrong.
I double checked the permissions and ownership, files owner only, process owned by the right uid, setuid bit on. I read the man pages for chmod and chown again. Still no joy. I fished out a copy of APUE and wrote the simplest possible test case. It still wouldn’t work. Whatever sequence of library or system calls I tried, the effective user id of the subsequent process was always me.
After a while I figured it out. When you enable FileVault for a user account, your home directory has a binary file called yourloginname .sparseimage within it. This is your FileVault home directory, in the form of a sparse encrypted disk image. When you login to your account, this image file is transparently mounted under $HOME, using the OS X disk image framework. When you logout, it’s unmounted again. You can manually mount it from a shell using the hdiutil tool like this
hdiutil -stdinpass -mountpoint /Users/foo /Users/foo/foo.sparseimage
You’ll get a prompt for the image password, which will be the same as the UNIX account password. You need to type the null at the end of the password, which you can do with C-@ , before you hit return. If you type mount you’ll see the disk image listed in the mount list. You will also notice the default options for disk image attachments is to mount them with the nosuid attribute. This causes OS X to silently disregard any set-user-id attributes of files within the filesystem. This makes a lot of sense as a security measure, and is commnly used for filesystems on removable media. You don’t want foreign filesystems introducing set-user-id binaries into your local filesystem on an ad-hoc basis as they are mounted.
Your own securely encrypted home directory doesn’t really represent a similar security risk, especially if you’re already the main administration account for your mac, and so the precaution seems less useful here. I wondered if it was a deliberate policy decision, or a side effect of the disk image framework. I’m not sure if you can mount disk images without nosuid at all.
When manually mounting filesystems, nosuid is an optional property supplied to the mount command. It seems like it ought to be possible therefore to mount disk images without the nosuid attribute being passed through to mount , but I haven’t yet managed to find a way to influence the mount options passed from hdiutil . Nor have I found where the magical FileVault attach happens, or if there is any way to influence it’s settings. In practice, it doesn’t really matter much, as set-user-id binaries have a very limited use, and probably shouldn’t be encouraged to proliferate.
A week later, I phoned back as suggested. I used the number from the apple store shipment tracking form, as before. I did as I had been told, and read out my incident number to the representative who answered This time, the Apple Store support chap pointed out I was dialling the wrong number for technical support, before offering to transfer me to the right department.
Immediate connect. A reasurring Irish accent enunciating an Applecare support menu. I select ‘other’. Less than five minutes on hold. Nice jazz at a reasonable volume, rather than distorted techno-metal. A friendly, intelligible voice takes the call, takes my case number, and then puts me on wait for another couple of minutes while he digs out the details.
He returns to confirm everything I’d managed to deduce from the UPS number. An order had been created with UPS, and they’d been credited, but no shipment collection had ever been made. He’s checked with the dispatch team, and the battery order is there, ready to go. He’ll chase it up with UPS, and anticipates it should be delivered to me within a couple of days. I explain about the useless tracking number on my battery program confirmation email, and he tells me that these are from an entirely separate order numbering systems to the store, you need to phone technical support. I grumble a bit about the wait time, he’s very apologetic.
This is the Apple support I’m used to. Ok, someone screwed up, but they’re on to it, and it didn’t take more than ten minutes of my time to let them know. Why so different from last week’s call center hell ? My best guess is that it has to be the valid incident case number. Presumably, if you hand out Applecare credentials or a case number early in the chain you get fast-tracked to a higher tier of support. A further conclusion to draw; for Apple laptops, which in my experience are more likely to feature technical problems than their desktop machines, Applecare should probably be considered a mandatory part of the purchase cost.
There’s a small, persistent chorus of dissent that echoes around the net, a companion to the peculiar cult of Apple worship that purchasing a Macintosh computer seems to bring out in some consumers. “Apple computers are all very nice”, it goes ” but they’re overpriced, and tend to be unreliable” . I’m not really sure how much truth there is to it, but like anything repeated more than three times on slashdot , it’s approached the state of a received wisdom amongst that particular strain of technophiliac. Nerds love dogma.
It’s not a very significantly-sized sample, but I have owned/managed six modern Macintosh systems, and my strike rate for hardware problems is exactly 50%. Perhaps interestingly, it’s been entirely limited to the notebooks. I’m not sure if this spells anything significant itself. I can certainly see how portable computers might undergo more stress as part of their normal wear and tear. One trend I am getting a little tired of is what seems to me to be the plummeting standards of product support at Apple.
My powerbook, the same one that originally started me thinking about questionable standards of support , is one of the lucky models that was sold with a battery that’s subject to a recent safety recall . There’s been a lot of this happening recently, to various brands of laptop . From what I’ve read, it’s all down to contamination in the cells, a flaw at the factory manufacturing the base cells that go into Lithium-Ion batteries. This contaminant means the batteries can get too hot in operation, and when hot, potentially catch fire or explode. The cells in question were produced by Sony for assembly into laptop battery packs for various other computer brands. In fact, Apple seemed to be making a point of this, highlighting the fact that the batteries were made by Sony, and mentioning in a subsequent press release that Sony would be picking up the tab for the free replacement program Apple have set up to handle the recall.
So I typed in my serial numbers into the web form, and sure enough my battery was a dud. I was advised to stop using it immediately, and wait for a free replacement. This might take from four to six weeks to ship. This means my portable won’t be very portable for a month or so, which is irritating. On the other hand, I’m going to get a factory new battery, which will probably have a larger charge capacity than my worn in one. Also I didn’t catch fire or explode. Overall, a net positive I think, with some minor inconvenience.
Nine weeks later, there’s been absolutely no sign of this replacement battery. I’ve been getting progressively more twitchy about this after the minimal four-week period passed. I’ve got a confirmation email about the transaction with a tracking number, which fails to work in their online order tracking system. I don’t ever seem to have much luck with Apple store shipments. This one is now well overdue, and I realise I’m going to have to give them a call to try and chase it up. I’m reluctant, remembering how terrible the last session was, but I’m getting increasingly suspicious that something’s gone wrong with the process, and I’ve had a functionally restricted computer for the past two months now.
So I make the call to the support number offered on the useless web tracking form. The robot reads out a menu, with an option for tracking orders or shipments. I press the indicated number. A robot tells me to use the web tracking form, and hangs up on me. Irritated, I redial, and this time wait and choose the ‘Other enquiries’ option. Five minutes or so on hold and I get picked up. Heavy accented English once again, perhaps an off-shore call centre. I explain I’m trying to track a battery replacement for a powerbook G4. I’m asked if I have a reference number. I give him the tracking number I was originally sent by the email robot. There’s a short pause while he does his thing with the number. He asks ‘Is this a battery replacement?’, sounding a little suprised. Declining to point out that I’ve already explained that it is, I agree. He’ll have to transfer me to another department.
Forty-five minutes on hold. Forty-five minutes of obnoxious pop music, too loud for the phone, distorting. So loud I have to hold the receiver a few inches away from my face. Every couple of minutes the volume drops and a voice starts speaking, so I’m compelled to listen closely once more in case it’s a pickup. It’s a robot, telling me a representative will be answering as soon as possible. And then the music blasts in again, deafening. These call queues are a horrible variant on the traditional bus-stop dilemma. Hang up after twenty minutes? What if the mean queue time is twenty-five, and I’m only a few minutes from an answer? I have to make the call, it’s my only realistic avenue of support. What if the next time it’s a forty minute average wait ? Better to stay on the line.
At the end of this ordeal, I’m answered by a female, again an accent, sounds off-shore. She explains helpfully that I’m through to iPod support, asks about the nature of my problem. I’m so stunned I have to ask her to repeat this. She confirms it’s iPod support. I manage to say something about having been put through to the wrong department by the previous operative, but I’m almost lost for words. I think my mood must be detectable from my voice, because she volunteers to see what she can do, referencing other departments. I hand over my details, including all the serial numbers, and the useless tracking number. I’m put on hold for another ten minutes while she looks things up. Thankfully this time it’s just quiet elevator muzak. Not often you find yourself grateful for bland piped music.
She returns with a UPS tracking reference. It doesn’t elucidate any detail other than the information that it was billed and shipped on the 20th of September, with a destination of Bristol, UK. This seems likely to be mine. She tells me that she will escalate this incident, gives me a ticket number, and tells me to call back in a week if it hasn’t fixed itself.
Overall I find this to be a fairly shocking standard of product support. I’m a moderately competent computer user, I wouldn’t bother to trouble the support line for usage or software problems, or anything self inflicted. In all cases I’m calling because I’ve purchased an expensive piece of consumer electronics that has proven to be mechanically faulty as supplied. I can accept that accidents and mistakes can occur, but I’m not sure it makes economic sense to keep purchasing products from a source that seems to guarantee I’ll be spending months waiting for inevitable faults to be corrected (taking into account the previous hardware fault, this powerbook will now have had fifteen-plus weeks of outage/reduced functionality), and spending multiple hours chasing up the state of these orders and repairs.
Another interesting data point is that the first two support incidents I ever reported to Apple were handled magnificently, super friendly support lines, and whizzy next day turnaround on replacements and repairs. Whereas currently, the root of the trouble I’m getting is entirely down to customer service, which although it’s polite, and ultimately helpful, is too unresponsive, and close to incompetent. I’ve got two working theories as to what has changed.
At the time they were impressing me with customer service, I had valid Applecare for one of the Macintoshes in the house. Perhaps you get a better tier of support if you’re a registered Applecare customer. Unfortunately the only way I can test this hypothesis is by buying another Macintosh, and buying some Applecare, and waiting for a fault, or faking one for test purposes. This plan is both expensive, and perhaps morally dubious.
Either way, I’m slightly ticked off. I think Apple products are good value for what they offer. I’m a big fan of the software. In particular, I think the modern Mac OS represents the least irritating computer environment I’ve worked in yet. I appreciate that sounds like faint praise, but I think it’s quite a measure of acheivement. I’ve been working with software and computers long enough now, that I appreciate that most of the skill in system design is centered in, for want of a better term, the process of suck-removal . I really appreciate that all the NeXT technologies and principles still have a viable platform, almost twenty years after their inception.
The trouble I have is that commiting oneself to using Macintosh means a commitment to a single supplier. Nobody likes feeling like they’re being peddled a lower quality deal because of a vendor-contrived platform lock-in. The increasingly fashionable anti-Windows grumbling, that Apple are cheeky enough to allude to in their current television advertising , is rooted in a similar sentiment, borne of a peculiar, voluntary form of modern serfdom; indenture to an unsatisfactory software platform in return for maintaining compatability with the status quo. There would be a certain kind of irony in Apple managing to parallel this antagonism by fixing the software, but in turn locking you to a hardware promise they’re not capable of delivering. I wonder how I’ll be feeling about this after the suggested week’s wait.
Quicksilver is one of the very best things you can do with your Mac . I adore it. To describe simply, it superimposes a keyboard interface over the Macintosh interface in a very natural way, directly appealing to any keyboard junkie.
Most quicksilver operations involve navigating a hierarchy of lists, precisely the sort of thing that would be a frustrating exercise in imprecision with a mouse. Navigating them by typing is a breeze. Incremental search, next and previous item, forwards, backwards. Until recently, I had thought that the directional commands were restricted to the arrow keys, which was unfortunate as I dislike reaching for the arrow keys on most keyboards. C-n and C-p work for next and previous as they tend to in many Cocoa applications, but for forward and back I was still using the left and right arrows in the inverse ‘T’.
No more. I recently discovered that ‘/’ and ‘?’ were bound to these commands, much closer to the home row. Further reading led me to discover how to customise these bindings. Like most things Quicksilver, this is barely documented. Creating a property list file at
~/Library/Application Support/Quicksilver/KeyBindings.qskeys
with contents like this
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>QSSearchObjectView</key> <dict> <key>^f</key> <string>moveRight:</string> <key>^b</key> <string>moveLeft:</string> </dict> </dict> </plist>
Will allow C-f to move forward into a list, and C-b to move back up, which is more in line with how my fingers expect applications to work. The master definition file can be found in the application bundle
Quicksilver.app/Contents/Frameworks/QSInterface.framework/Versions/A/Resources/DefaultBindings.qskeys
and should give some ideas about things that you can set. Scanning through the default actions that are bound is an education too. I’m not even sure what half of the entries represent yet.
echo -e "\033[40;1;33m"
you can send control characters to an xterm to set the foreground and background colours of the text. Then, redrawing the screen via ‘clear’ will leave you with a terminal window that has bold yellow text on a black background.
echo -e "\033[42;1;31m"
would give you bold red text on bright green. Easy to spot at any size, and it works in Apple Terminal too!
The breakdown of how this works is as follows. The -e argument to echo means that it will use its own escape sequences to interpret non-printing characters. \033 is the octal code for ESC. The string recipe is actually ESC then [ which intiates the sequence, followed by a list of numeric attribute codes separated by semicolons and then the charcter m. The following table lists some of the ANSI display attribute codes codes that are useful.| Attribute | Description |
|---|---|
| 1 | Bold |
| 2 | Normal (not bold) |
| 4 | Underline |
| 5 | Blink |
| 7 | Inverse video |
| 8 | Invisible |
| 30 | Foreground black |
| 31 | Foreground red |
| 32 | Foreground green |
| 33 | Foreground yellow |
| 34 | Foreground blue |
| 35 | Foreground magenta |
| 36 | Foreground cyan |
| 37 | Foreground white |
| 40 | Background black |
| 41 | Background red |
| 42 | Background green |
| 43 | Background yellow |
| 44 | Background blue |
| 45 | Background magenta |
| 46 | Background cyan |
| 47 | Background white |
echo -e "\033[32;47m" ; clear
would change your colors scheme to green text on a white background, for example. The drawbacks are obvious. The numbers are hard to remember, and the string is tricky to type. This calls for a gross hack ! I define three butt-ugly functions in my bash profile that simplify this process greatly. They’re listed below.
function _fg {
case $1 in
y)
FG="1;33"
;;
g)
FG="1;32"
;;
r)
FG="1;31"
;;
p)
FG="1;35"
;;
W|w)
FG="1;37"
;;
b)
FG="1;34"
;;
B)
FG="1;30"
;;
esac
}
function _bg {
case $1 in
y)
BG="43"
;;
g)
BG="42"
;;
r)
BG="41"
;;
p)
BG="45"
;;
W|w)
BG="47"
;;
b)
BG="44"
;;
B)
BG="40"
;;
esac
}
function xtc
{
FB=$1
F=$( echo | cut -c1 )
B=$( echo | cut -c2 )
_fg $F
_bg $B
CMD="\033[${BG};${FG}m"
echo -e $CMD && clear
}
The way this works is I get a short mnemonic comand xtc to use for changing the terminal color. I define the colors as single letter constants, in separate helper functions for both foreground and background colours. Then I can just use type xtc rb to instantly refresh the terminal I am using to be bold red on blue. I can then use this as a memory-aid, by assigning distinct colours to different terminals as I use them. This makes them easy to pick out when shrunk. A kludge, but a handy one to have about
All mail clients suck. I say this often.
I’m fairly welded to the Mac OS X mail client. It’s free, comes with the computer, and does a reasonable job of supporting the sort of email standards that you need to be able to post to nerd mail lists without getting shouted off stage.
It’s got a nice interface, albeit one which Apple keep shunting about radically with each new OS release; particularly so in the case of the 10.4 update where they gave it a strange new skin and widget set unlike anything else in their oft-lauded UI guidlines, and broke the IMAP support so badly I had to rebuild my entire mail server just to keep using it. I suppose this is indicative of just how attached I am to the application. Or some weird software-user abusive relationship cycle I’m psychologically locked into. It’s a habit.
Some of this is down to the integration. Seeing as the authors own the hardware and the OS platform, they can link the mail client into their bundled software in much the same way that Microsoft get shouted at for attempting to do. This is undeniably handy, the system-wide address-book, sync services, messaging and calendaring all co-operate with each other with pleasant synergy.
Some of the attraction is familiarity. I’ve been using ‘Mail.app’ for a long time. Years. If I were more pretentious, I could try and act as if my NeXT dabbling entitled me to claim it was decades. Like most network-centric people, email is quite fundamental to my computer-life, and upheavals there might have a wide domino effect. I’m resistant to change.
Mostly though, I think the attraction is down to functionality. It just has some hands-down-unbeatable features, that other clients don’t manage to match. Ranging from the obvious ( lovely mac fonts and text input system ), to the subtle ( I’ve configured color coding quotations at indent level in progressively paler shades of blue so that the older citations gradually fade towards white ), to the magnificent ( only quoting the currently highlighted text in a reply, every mail client should have this feature ).
Not only all that, but I keep unearthing new useful features, which is what has prompted me to write. In the past month, I’ve stumbled across two excellent capabilities that have refreshed my enthusiasm for this workhorse software. I’ve no idea how long they’ve been present.
Reading this back it occurs to me that I recently found a blog seemingly dedicated to Apple Mail tips . Some or all of these suggestions may well have come at me from this source. It’s interesting reading.
The site has been effectively offline since the start of December, due to hardware trouble. Seeing as I barely manage to update it monthly, I’m sure this service interruption was only irritating to me. The trickle of users who hit it from googling for dalmatian photos would not have been able to discern the problem, you’ll be glad to hear. It was a hardware problem of the offline variety.
My powerbook developed a fault with its motherboard, ‘logic board’ in Apple-speak. The fangly new scrolly-touchpad which I was foolishly and boastfully proud of when it arrived has a temperature sensor associated with it. I know this because it was this particular sensor that failed. Sporadically, the laptop would shutdown fast. I ignored it the first one or two times, they were probably months apart. By the next escalation, it would immediately drop to sleep in a half hour. The logs showed that it was shutting down in response to an ‘emergency thermal overtemp’ condition. I wondered if it mightn’t be getting sufficient airflow in its customary position on the desk. The case wasn’t hot, or even warm to the touch.Pretty soon these clusters of outages were coming twice-weekly or more. Still no unexpected heat. Judicious googling using the log messages turned up a small gaggle of mac users with similar symptoms on forums and blogs. All with similar powerbook models to mine - 15″ aluminium case, USB ‘two-finger scroll’ touchpad. A few of them suggested that they’d isolated the problem to the trackpad thermal sensor using monitoring software. I downloaded some software called ‘Temperature Monitor.app’. It didn’t take long to confirm. The powerbook started having one of its power-off tantrums soon enough, and the logs produced by the monitoring software indicated that the trackpad sensor was recording temperature fluctuations between -70 and +270 degrees Celsius, within the space of a couple of minutes. In itself amusing, but by now the computer had degenerated further and become unusable, making it harder for me to appreciate the funny side.
At this point I shall note that since ’switching’, I’ve bought three models of Apple laptop, all of which have suffered some kind of spontaneous component failure. Perhaps all the talk about Apple product reliability has some foundations after all? I’m enough of a crap statistician to realise that three subjects isn’t really a useful sample population. The failures do represent a rather disappointing coincidence. Over the same time period I’ve made home for three desktop Apple models, all of which have performed without trouble, which doesn’t help really signify that much of a trend. Anecdotal evidence, especially any gleaned from web discussions, I think is largely worthless. I did find this informal survey which generally suggests an even distribution. It is mildly interesting that all my three problems are specifically marked in red as significantly prone to fail on the model by component chart (iBook G3 800 logic board, Titanium powerbook G4 800 Optical drive and Aluminium 15″ powerbook trackpad). If only I was this successful at picking lottery numbers! I might win ten pounds.
One positive thing had emerged from my run of unlucky laptops. Apple customer support had been wonderful. Although the titanium had been covered by AppleCare, the iBook was out of warranty; in both cases after a pleasant phone call to an unquestioningly helpful support line, they arranged to courier the laptops back to the mothership and returned them back after 24 hours in a working state. This time I was less impressed. My powerbook was not covered by AppleCare, but was only 8 months old, I genereally prefer to wait a while before purchase, to try and spread the cost. It took a fair bit of grubbing around the Apple website to find an appropriate looking telephone support contact. I dialled it, and worked my way through the automated menu system towards the ‘Help, my computer is borked’ options.
After waiting on hold for the usual half hour or so of canned music and messages, I was put through to a heavily accented man, who, whilst being unfailingly polite, and ultimately quite helpful, still managed to live up to every unfortunate offshore-call-centre cliché going; I was repeating everything he said back to him for confirmation, and repeating most of my own answers similarly until we were confident about agreement, several times we resorted to spelling things phonetically. All of this over a premium rate call I was paying for, of course. After running through his scripted heuristics, pre-charging my credit card for a support incident, and him explaining to me where to find the hardware diagnostics disc (It’s the same DVD as the software restore these days - who knew?), he was able to confirm what I already knew, my powerbook had a hardware fault with it’s trackpad, and that this would entail a logic board replacement, which was covered by standard warranty.
I was surprised to hear that there’d be no magic courier this time. Instead I needed to take it to my local service centre. In Belfast . It took several attempts at spelling and pronunciation to discern this was what he was saying. I live in Bristol . Belfast, Ireland might not be quite within a separate country, but it is about as close as you can get to that without leaving the UK. There’s a different island involved. Ten minutes of explaining why this was bad and I got a second suggestion out of him. Western Computer , a fairly local Apple shop I don’t tend to frequent. Apparently I would have to phone them myself and arrange a repair.
I don’t particularly want to use this space to complain about Western. I don’t like the shop particularly, I find the staff aloof, and indolent, and I get an impression of long-entrenched smug mac-user superiority from the whole place that I’m entirely ready to believe is a product of my own imagination. They have weird opening hours policies that preclude weekends. Whatever the reason, I tend to prefer to spread my shekels on other soil. Still, they were pleasant enough on the (promptly answered) phone, although they did ominously explain that they were rather backlogged with repairs, invited me in to see what my options were
When I arrived they were friendly enough, although not particularly enthusiastic. I went through the whole story with the support technician chap, and he looked my serial number and confirmed that it would be a warranty repair job, probably a motherboard replacement, and that they’d only charge me for the examination if their own investigation proved there to be no fault. They couldn’t examine it then and there, there was a queue system. Oh, and there was a minimum four week wait for a repair of this time, what with it being Christmas, and something to do with iPods I didn’t quite follow. I could perhaps try going to the Cardiff Apple Centre as an alternative. Again, with the other country treatment. Admittedly Wales is fairly close, but still a few hours travel there and back. Probably not a huge saving over a flight to Belfast. I didn’t seem to have many options. I asked the chap if they had a lot of broken powerbooks in. He said, no, they were really reliable. Perhaps that’s why they didn’t have many repair staff handy.
In the end it took six weeks. While they didn’t seem to be terrifically proactive about it, I can’t really call too much fault on Western’s part. The few times I chased them they replied to my calls and were happy to discuss the details of the job. I can understand that they had a backlog of work, or had to wait a longer time on parts from Apple (my powerbook is a custom web build), or shut the store completely for two weeks over Christmas, to a certain extent - I find it harder to understand why Apple are referring faulty products to a dealer with such rudimentary servicing facilities.
As I work from home, and live off my mac, managing for a month or so without a computer really wasn’t an option for me. I spent a couple of hours trying to cobble together a replacement linux computer from spare parts, but I couldn’t manage to get anything capable of driving my super-sci-fi TFT display satisfactorily. It was obvious that I was going to have to spend some money on a new computer. Attending a local LUG meeting, and sketching out my problems to a friend elicited the suggestion that I should just buy a mac mini to be getting on with - a drop in replacement that could tide me over, and ideally would hold its value for resale better than a generic pc box over the same period. This proved to be excellent advice. I picked up a mini from John Lewis, and have to say that they are excellent little machines. If you’re reading this and have been wondering about getting one, I’d say do it now. It was slower than I was used to, particularly the little disk, but overall a more capable Macintosh than I’d have thought possible for the price. Still, I’m either out of pocket over what should have been a guaranteed repair job, albeit with another, admittedly very nice, computer I don’t really need.
Luckily enough I have an effective, automated backup system (what’s your excuse? Data loss is inevitable, and common), so all in all it was only a day or so in total to swap the two systems in and out.
Lessons learnt
Given recent hardware trends, Apple are becoming decreasingly different from standard ‘name’ PC vendors. The sole points of deviation within this whole experience and what I’d expect from someone like Dell is now really just down to the cost, and the software. Lucky for Apple, I really like the software. At this point in time, I feel like I’m paying a significant premium for a license to use it. I wonder if it will still seem a good deal in twelve months time when I’m pricing up my next laptop against a marketload of almost identical intel-based systems running Free Unix.
Please allow me to introduce memberd!
Mac OS X is a funny kind of Unix as was its father NEXTSTEP. And it’s a still a family trend. Maybe it’s the final glimmering remnants of its once-trendy microkernel heritage, maybe it’s an attitude influenced by all the ‘networks of directory services are better than forests of flat files’ thinking behind NetInfo and Open Directory, it doesn’t really matter why. There’s a host of system daemons running away on the Macintosh of today, some quite unfamiliar to users more used to the more traditional Unixes (or Unix-alike) operating systems. Collections of daemons managing system services aren’t anything new of course, but many of these have unfamiliar names. They replicate entire UNIX subsystems with unfamiliar, perhaps unexpected solutions. It’s just like Unix yet still unlike Unix.
Some of them date all the way back to antique NeXT releases. Like lookupd , which looks things up in directories. You might be more familiar with it in it’s guise as ‘every now and then my computer stops resolving certain addresses’ , necessitating a quick ‘ sudo lookupd -flushcache ‘ (one word, single dash, minimally intuitive). Others like configd are newer, (introduced in the transition to Mac OS, responsible for maintaing different ’states’ of machine configurations such as the network ‘locations’ feature), or the excitingly named, but ultimately rather prosaic blued (responsible for the rather wonderful mac bluetooth implementation, but on first encountering it running I wondered if it was providing all the blue in the Aqua GUI). And then there’s the bang-up-to-the-minute, hipper than hip new Tiger-only ones. Chief amongst them the slicing, dicing, init/cron/xinetd replacement and more that is launchd .
All of these have man pages to investigate, some of them are quite configurable, and can be fun to experiment with - especially launchd. I’m not sure how long memberd has been around for, but it was new to me today, when I stumbled across it.
As I keep a loosely organised collection of jumble-sale-quality Unix boxes, I place value in keeping my login account numeric uids synchronised across various systems I use. It obeys the principle of least surprise and is useful when network file sharing, especially via NFS. I also appreciate the access control features UNIX groups can offer to multiple users. I don’t care enough about either to actually invest in some enterprise-class networked directory service, nor am I enough of a wannabe systems administrator to aspire to wrestling such a monster into seving my will. So I generally shell in ad-hoc and adjust such things on a host by host, account by account sort of basis, as the situation demands. On OS X this can mean interacting with NetInfo, but that’s okay, I’m weird enough to quite like NetInfo, I’ve known it a while.
So today I was fiddling with some group permissions, and I actually ended up making a couple of groups entirely redundant. So I removed them from NI completely. After I was done I noticed from running id , that I was still a member of a couple of them. More oddly, the system could still identify them by name. So I panicked, assuming I’d deleted a set of NetInfo keys that were in entirely the wrong dictionary. On inspecting the damage it all looked fine. Then I realised that group membership changes were one of those things that are fixed in your environment, cached by the login shell. So I logged in and out. Still no good, the phantom groups persisted. Mental alarm bells were ringing at this point, so I started doing some digging. Walking through the list of running processes and poking at man pages led me to find memberd.
It starts up at system boot and keeps running. It has a fine man page. It seems to be how OS X 10.4 resolves user group membership. More pertinently, it maintains a cache of such information. This cache can be flushed when stale by running
memberd -r
from a root shell. And that fixed my all my troubles. Well, it got rid of the sticky invalid groups anyway.
NFS is a good protocol to use for sharing filesystems between UNIX-like computer systems. Mac OS X 10.x will happily serve and mount network filesystems using the NFS protocol out of the box. If you are working from the shell, you can just mount nfs exports, using the mount command in the usual manner, and assuming your NFS is appropriately configured for permissions, it should Just Work. Assuming a mount point of an empty folder in your home directory called mountpoint, you can issue a command like
mount server:/path/to/share ~/mountpoint
and you’ll get your network directory mounted there just like you were using any old UNIX system.
There are problems with using this straightforward approach though, it confuses the Finder. If you are using a mountpoint somewhere within the Finder’s idea of the visible filesystem, it will probably notice this new curio fairly sharply. Your mountpoint directory will probably be re-rendered with a network alias icon rather than a folder, and if you have the Finder sidebar preference to ’show connected servers’ enabled, you’ll probably get a network icon in there representing the nfs mount, complete with little ‘eject me’ widget, just like a removable media filesystem. You can’t eject it with this widget though, you need to unmount it from the shell, using the usual umount command.
When you do this you’ll probably find that you still have a ‘connected server’ sidebar item, replete with non functional eject widget. Clicking on it tends to throw you into the ‘Computer’ Finder view, occasionally you might get a grumble from the Finder about the volume being removed. Usually not though. You might be able to drag the null ‘volume’ to poof or to the trash, you might not. Even if you manage this it sometimes pops back up again a few seconds later, still quite useless. Force Quit -> Restart Finder usually sorts this, but again not always. Sometimes it seems to need a reboot. This entire state of affairs is most unsatisfactory. It’s probably better to keep mountpoints for shell sessions, or scripts somewhere the Finder won’t look for them, like under /usr/local or /mnt . This isn’t any use if you want to be able to use this filesystem from any GUI applications.
A better approach to ad hoc network mounts is to use the Finder to control the mounting. Using the ‘connect to server’ option in the ‘Go’ menu, or the shortcut command-k , and the odd looking URL
nfs://server/path/to/share/
This gets you a network icon for a new volume in the sidebar, again replete with eject button. This time around though the icon works, you can eject it using it’s control or drag it to trash to unmount. The Finder has created a mount for you under /Volumes/ with a unique mount point name that has been generated from the remote hostname. You can use this mount as you’d expect from shell sessions. What’s even better, the Finder will react more appropriately to shell level changes, closing open views and removing the volume icon if you unmount it, informing you that it’s in use if you try to eject it. The mount is interruptible and the Finder will time out and ask to disconnect in the event of networking problems. For transient network shares, the Finder’s connect to server feature looks like the way to go.
With network shared volumes, it’s common to want some persistent shares, for situations like common project folders, networked personal directories or backup volumes. On UNIX like systems you might add entries to the system fstab table, and have them mounted at boot time via the startup scripts. You could do something similar in Mac OS X, or you could use login scripts to mount shares using the previously discussed approaches. There is a third interesting way to use NFS shares in Mac OS X, you can use the system automounter.
The automounter is a system daemon that is launched at boot time, via SystemStarter. It’s job is to manage network filesystem mounts on-demand. Assuming that the line
AUTOMOUNT=-YES-
is present in /etc/hostconfig , the NFS service in /System/Library/StartupItems/NFS/ spawns several instances of the automounter during the boot process to handle different kinds of network filesystems. The one that is used to manage dynamic NFS mounts is called like this
automount -m /automount/Servers -fstab -mnt /private/Network/Servers -m /automount/static -static -mnt /private/var/automount
This invocation is responsible for creating two ‘filesystems’ which appear can be seen as
automount -fstab [PID]
and
automount -static [PID]
in the output of df . The automounter will create special symbolic links within these filesystems that represent network filesystems, mounting them transparently as they are accessed and then automatically unmounting them after a certain amount of idle time. The ‘magic’ used to differentiate these symbolic links from normal links, is simply that they have the ’sticky bit’ set.
The -m argument supplied to the automounter is used to specify the ‘map’, which is a list of nfs exports and mount options and locations. The invocations above make use of the ’special’ map types -static and -dynamic which generate map information from system fstab data.
OS X, of course doesn’t actually store it’s fstab data in a traditional /etc/fstab flat file by default. Like many other system configuration variables, this data uses the NeXT-inherited NetInfo directory service. A dictionary called ‘mounts’ is used to hold this filesystem information, it contains a dictionary for each mount point with the following structure, shown below in nidump ‘raw’ format. The keys mostly correspond to the fields found in a more traditional fstab file entry.
{
"name" = ( "mounts" );
CHILDREN = (
{
"dir" = ( "/mnt/some/local/mountpoint" );
"dump_freq" = ( "0" );
"name" = ( "server:/path/to/share" );
"opts" = ( "net", "-P", "-i", "-s", "rw" );
"passno" = ( "0" );
"vfstype" = ( "nfs" );
}
)
}
By default, the /mounts dictionary won’t exist on a fresh OS X client. There are a few ways you can manipulate NetInfo to create this data, using the NetInfo Manager GUI application in /Applications/Utilities/ or using the command line utilities niutil or niload . “niload” is the best way to approach this task I think, as it has a very nifty shortcut feature - it ’speaks’ traditional flat file format for a number of dictionaries, and will convert input from a normal UNIX flat file format for many dictionaries such as aliases, fstab, group, hosts, passwd, and quite a few others.
Using the command
niload fstab . < foo.txt
you can load the contents of the file foo.txt into the local netinfo database, and assuming that foo.txt contains fstab formatted information, it will populate the mounts dictionary for you with the correct keys. You will need admin privileges to write to the NetInfo database, just use sudo . The example dictionary above would correspond to foo.txt being a flat file with the following content.
server:/path/to/share /mnt/some/local/mountpoint nfs net,-P,-i,-s,rw 0 0
After loading it , the command
nidump -r /mounts /
should demonstrate the raw dictionary form from above. The various client options are the usual things, and can be found from the mount_nfs man page. The net option is a special option for the automounter. This causes the local mount point field to be ignored, the symlink will appear within the automount -fstab filesystem using a generated path of the form server/path/to/share .
The default automount -fstab filesystem configuration maps to /automount/Servers as noted above. OS X has a symbolic link set up /Network/Servers/ that points to this location, and using the net option for your mount will cause your network volumes to be mounted, neatly and transparently on demand within the Finder’s Network hierarchy, and subsequently unmounted automatically after an idle period. The example above would correspond to a Finder location of /Network/Servers/server/path/to/share/
Mounts defined without the net option would create the symbolic link using the local mountpoint path argument, which would point to a similarly named “trigger” link in the location defined by the -static automount filesystem.
Once you’ve configured all of this, a quick SIGHUP to the automounter processes, should set all this up to work for your next login. I usually reboot the system at this point, however, just to be double sure it’s all caught.