or Connect
AppleInsider › Forums › General › Genius Bar › Making a disk image that opens a Finder window on mount.
New Posts  All Forums:Forum Nav:

Making a disk image that opens a Finder window on mount.

post #1 of 5
Thread Starter 
Anyone know how to make a .dmg image file in OS X that automatically opens the volume when you mount it? Apple's MacOS X update images do this, but I can't figure out how they do it for the life of me.

In OS 9 it was straightforward since the window formatting was preserved on the image, but not so in OS X. I even tried making an image with open window on OS 9 and bringing it over to X with no success.
post #2 of 5
I don't think that is possible in OSX.
post #3 of 5
Thread Starter 
I figured it out. It involves modifying the HFS+ volume header bits.

It most definitely cannot be done with conventional OS X tools.
post #4 of 5
care to share?
I'm having deja-vu and amnesia at the same time. I think I've forgotten this before.
Reply
I'm having deja-vu and amnesia at the same time. I think I've forgotten this before.
Reply
post #5 of 5
Thread Starter 
Sure thing!

Here's the code:
[code]

/*
* Copyright (c) 2001 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* <a href="http://www.apple.com/publicsource" target="_blank">http://www.apple.com/publicsource</a> and read it before using this file.
*
* This Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*
* Shantonu Sen &lt;ssen@apple.com&gt;
* openUp.c - program to set the "first-open-window" field of a volume
*
* Get the directory ID for the first argument, and set it as word 2
* of the Finder Info fields for the volume it lives on
*
* cc -o openUp openUp.c
* Usage: openUp /Volumes/Foo/OpenMe/
*
*/

#include &lt;stdio.h&gt;
#include &lt;unistd.h&gt;
#include &lt;sys/attr.h&gt;
#include &lt;sys/stat.h&gt;
#include &lt;sys/mount.h&gt;

struct directoryinfo {
unsigned long length;
u_int32_t dirid;
};

struct volumeinfo {
unsigned long length;
u_int32_t finderinfo[8];
};


int main(int argc, char *argv[]) {

char *path = NULL;
struct attrlist alist;
struct directoryinfo dirinfo;
struct volumeinfo volinfo;
struct statfs sfs;

path = argv[1];

bzero(&alist, sizeof(alist));
alist.bitmapcount = 5;
alist.commonattr = ATTR_CMN_OBJID;

getattrlist(path, &alist, &dirinfo, sizeof(dirinfo), 0);

printf("directory id: %lu\
", dirinfo.dirid);

statfs(path, &sfs);

printf("mountpoint: %s\
", sfs.f_mntonname);

alist.commonattr = ATTR_CMN_FNDRINFO;
alist.volattr = ATTR_VOL_INFO;

getattrlist(sfs.f_mntonname, &alist, &volinfo, sizeof(volinfo), 0);
volinfo.finderinfo[2] = dirinfo.dirid;
setattrlist(sfs.f_mntonname, &alist, volinfo.finderinfo,
sizeof(volinfo.finderinfo), 0);

}</pre><hr></blockquote>
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Genius Bar
AppleInsider › Forums › General › Genius Bar › Making a disk image that opens a Finder window on mount.