ADC Home > Reference Library > Technical Q&As > Legacy Documents > Mac OS 9 & Earlier >

Legacy Documentclose button

Important: This document is part of the Legacy section of the ADC Reference Library. This information should not be used for new development.

Current information on this Reference Library topic can be found here:

Finding the VM Backing Store

Q I'm writing a backup program and I'd like to find the VM Storage file, so as to avoid backing it up. How do I do this?

A The best way of finding the current VM Storage file is to use a previously undocumented Gestalt selector:
enum {
    gestaltVMBackingStoreFileRefNum = 'vmbs'
};

The result of this selector is an file reference number to the active "VM Storage" file. You can convert that reference number to an FSSpec by calling PBGetFCBInfoSync, as shown below:

OSErr FindVMStorage(FSSpec *fss) {
    OSErr err;
    long gestaltResult;
    FCBPBRec fcbPB;
    Str255 theName;

    err = Gestalt(gestaltVMBackingStoreFileRefNum, &gestaltResult);
    if (err == noErr) {
        fcbPB.ioNamePtr = theName;
        fcbPB.ioVRefNum = 0;
        fcbPB.ioRefNum = gestaltResult;
        fcbPB.ioFCBIndx = 0;
        err = PBGetFCBInfoSync(&fcbPB);
        if (err == noErr) {
            err = FSMakeFSSpec(fcbPB.ioFCBVRefNum,
                    fcbPB.ioFCBParID, theName, fss);
        }
    }
    return err;
}

[Mar 30 2001]


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.