1 /* 2 ** make_desktop: create "Desktop DB" and "Desktop DF" files. 3 ** 4 ** These are set up to prevent the Mac "rebuilding the desktop" 5 ** when the CD is inserted ??? 6 ** 7 ** I don't know if these files should be populated, but I've just 8 ** created these files in their initial states: 9 ** 10 ** Desktop DB: Initial size == volume's clump size 11 ** first block contents found by using od ... 12 ** rest of file seems to be padding 13 ** No resource fork 14 ** 15 ** Desktop DF: Empty 16 ** 17 ** If the files already exist, then set correct type/creator/flags 18 ** 19 ** James Pearson 11/8/97 20 ** Adapted from mkhfs routines for mkhybrid 21 */ 22 23 #ifdef APPLE_HYB 24 25 #include <string.h> 26 #include "hfs.h" 27 28 #define DB "Desktop DB" 29 #define DBFC "DMGR" 30 #define DBT "BTFL" 31 32 #define DF "Desktop DF" 33 #define DFT "DTFL" 34 35 /* from "data.h" - libhfs routines */ 36 void d_putw(unsigned char *, short); 37 void d_putl(unsigned char *, long); 38 39 extern hce_mem *hce; /* libhfs/mkisofs extras */ 40 41 int 42 make_desktop(hfsvol *vol, int end) 43 /* hfsvol *vol; /* Mac volume */ 44 { 45 hfsfile *hfp; /* Mac file */ 46 hfsdirent ent; /* Mac finderinfo */ 47 unsigned short clps; /* clump size */ 48 unsigned short blks; /* blocks in a clump */ 49 unsigned char *blk; /* user data */ 50 int i; 51 52 /* set up default directory entries - not all these fields 53 are needed, but we'll set them up anyway ... */ 54 ent.rsize = 0; /* resource size == 0 */ 55 strcpy(ent.creator, DBFC); /* creator */ 56 strcpy(ent.type, DBT); /* type */ 57 ent.crdate = ent.mddate = time(0); /* date is now */ 58 ent.fdflags = HFS_FNDR_ISINVISIBLE; /* invisible files */ 59 60 /* clear the DB file */ 61 blk = hce->hfs_ce + hce->hfs_ce_size*HFS_BLOCKSZ; 62 blks = hce->hfs_dt_size; 63 clps = blks*HFS_BLOCKSZ; 64 65 memset(blk, 0, clps); 66 67 /* create "Desktop DB" (if it doesn't exist) */ 68 if(hfs_create(vol, DB, ent.type, ent.creator) == 0) 69 { 70 /* DB file size from hce_mem info */ 71 /* set up "Desktop DB" data - following found by od'ing 72 the "Desktop DB" file */ 73 d_putw(blk+8, 0x100); 74 d_putw(blk+10, 0x3); 75 76 d_putw(blk+32, 0x200); 77 d_putw(blk+34, 0x25); 78 79 d_putl(blk+36, blks); 80 d_putl(blk+40, blks - 1); 81 82 d_putw(blk+48, clps); 83 d_putw(blk+50, 0xff); 84 85 d_putw(blk+120, 0x20a); 86 d_putw(blk+122, 0x100); 87 88 d_putw(blk+248, 0x8000); 89 90 d_putl(blk+504, 0x1f800f8); 91 d_putl(blk+508, 0x78000e); 92 93 /* entries for "Desktop DB" */ 94 ent.dsize = clps; /* size = clump size */ 95 96 /* open file */ 97 if((hfp = hfs_open(vol, DB)) == 0) 98 perr(hfs_error); 99 100 /* "write" file */ 101 write_fork(hfp, clps); 102 103 /* set DB file attributes */ 104 if (hfs_fsetattr(hfp, &ent) < 0) 105 perr(hfs_error); 106 107 /* find the real start of the file */ 108 end += hce->hfs_ce_size; 109 110 /* close DB file */ 111 if (hfs_close(hfp, end, 0) < 0) 112 perr(hfs_error); 113 } 114 else 115 { 116 /* if it already exists, then make sure it has the correct 117 type/creator and flags */ 118 if(hfs_setattr(vol, DB, &ent) < 0) 119 perr(hfs_error); 120 } 121 122 /* setup "Desktop DF" file as an empty file */ 123 strcpy(ent.type, DFT); /* type */ 124 ent.dsize = 0; /* empty */ 125 126 /* create DF file (if it doesn't exist) - no need to open it */ 127 hfs_create(vol, DF, ent.type, ent.creator); 128 129 /* set DB file attributes */ 130 if (hfs_setattr(vol, DF, &ent) < 0) 131 perr(hfs_error); 132 return 0; 133 } 134 #endif /* APPLE_HYB */ 135