2 * This file has been modified for the cdrkit suite.
4 * The behaviour and appearence of the program code below can differ to a major
5 * extent from the version distributed by the original author(s).
7 * For details, see Changelog file distributed with the cdrkit package. If you
8 * received this file from another source then ask the distributing person for
9 * a log of modifications.
13 /* @(#)desktop.c 1.6 04/03/04 joerg, Copyright 1997, 1998, 1999, 2000 James Pearson */
15 * Copyright (c) 1997, 1998, 1999, 2000 James Pearson
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2, or (at your option)
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program; see the file COPYING. If not, write to
29 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
33 * make_desktop: create "Desktop DB" and "Desktop DF" files.
35 * These are set up to prevent the Mac "rebuilding the desktop"
36 * when the CD is inserted ???
38 * I don't know if these files should be populated, but I've just
39 * created these files in their initial states:
41 * Desktop DB: Initial size == volume's clump size
42 * first block contents found by using od ...
43 * rest of file seems to be padding
48 * If the files already exist, then set correct type/creator/flags
50 * James Pearson 11/8/97
51 * Adapted from mkhfs routines for mkhybrid
57 #include "genisoimage.h"
59 #define DB "Desktop DB"
63 #define DF "Desktop DF"
67 * from "data.h" - libhfs routines
69 extern void d_putw(unsigned char *, short);
70 extern void d_putl(unsigned char *, long);
72 int make_desktop(hfsvol *vol, int end);
75 extern hce_mem *hce; /* libhfs/genisoimage extras */
78 make_desktop(hfsvol *vol, int end)
80 hfsfile *hfp; /* Mac file */
81 hfsdirent ent; /* Mac finderinfo */
82 unsigned long clps; /* clump size */
83 unsigned short blks; /* blocks in a clump */
84 unsigned char *blk; /* user data */
87 * set up default directory entries - not all these fields are needed,
88 * but we'll set them up anyway ...
89 * First do a memset because there was a report about randomly
90 * changing Desktop DB/DF entries...
92 memset(&ent, 0, sizeof (hfsdirent)); /* First clear all ... */
93 ent.u.file.rsize = 0; /* resource size == 0 */
94 strcpy(ent.u.file.creator, DBFC); /* creator */
95 strcpy(ent.u.file.type, DBT); /* type */
96 ent.crdate = ent.mddate = time(0); /* date is now */
97 ent.fdflags = HFS_FNDR_ISINVISIBLE; /* invisible files */
102 blk = hce->hfs_ce + hce->hfs_ce_size * HFS_BLOCKSZ;
103 blks = hce->hfs_dt_size;
104 clps = blks * HFS_BLOCKSZ;
106 memset(blk, 0, clps);
109 * create "Desktop DB" (if it doesn't exist)
111 if (hfs_create(vol, DB, ent.u.file.type, ent.u.file.creator) == 0) {
113 * DB file size from hce_mem info
114 * set up "Desktop DB" data - following found by od'ing the
117 d_putw(blk + 8, 0x100);
118 d_putw(blk + 10, 0x3);
120 d_putw(blk + 32, 0x200);
121 d_putw(blk + 34, 0x25);
123 d_putl(blk + 36, blks);
124 d_putl(blk + 40, blks - 1);
126 d_putl(blk + 46, clps);
127 d_putw(blk + 50, 0xff);
129 d_putw(blk + 120, 0x20a);
130 d_putw(blk + 122, 0x100);
132 d_putw(blk + 248, 0x8000);
134 d_putl(blk + 504, 0x1f800f8);
135 d_putl(blk + 508, 0x78000e);
137 /* entries for "Desktop DB" */
138 ent.u.file.dsize = clps; /* size = clump size */
141 if ((hfp = hfs_open(vol, DB)) == 0)
145 write_fork(hfp, clps);
147 /* set DB file attributes */
148 if (hfs_fsetattr(hfp, &ent) < 0)
151 /* find the real start of the file */
152 end += hce->hfs_ce_size;
155 if (hfs_close(hfp, end, 0) < 0)
159 * if it already exists, then make sure it has the correct
160 * type/creator and flags
162 if (hfs_setattr(vol, DB, &ent) < 0)
166 /* setup "Desktop DF" file as an empty file */
167 strcpy(ent.u.file.type, DFT); /* type */
168 ent.u.file.dsize = 0; /* empty */
170 /* create DF file (if it doesn't exist) - no need to open it */
171 hfs_create(vol, DF, ent.u.file.type, ent.u.file.creator);
173 /* set DB file attributes */
174 if (hfs_setattr(vol, DF, &ent) < 0)
180 #endif /* APPLE_HYB */