xref: /openbsd-src/gnu/usr.sbin/mkhybrid/src/libhfs_iso/hfs.h (revision f0d9efc08bdf8f314c206a5c81ebc300245394f8)
1*f0d9efc0Sbeck /*
2*f0d9efc0Sbeck  * hfsutils - tools for reading and writing Macintosh HFS volumes
3*f0d9efc0Sbeck  * Copyright (C) 1996, 1997 Robert Leslie
4*f0d9efc0Sbeck  *
5*f0d9efc0Sbeck  * This program is free software; you can redistribute it and/or modify
6*f0d9efc0Sbeck  * it under the terms of the GNU General Public License as published by
7*f0d9efc0Sbeck  * the Free Software Foundation; either version 2 of the License, or
8*f0d9efc0Sbeck  * (at your option) any later version.
9*f0d9efc0Sbeck  *
10*f0d9efc0Sbeck  * This program is distributed in the hope that it will be useful,
11*f0d9efc0Sbeck  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12*f0d9efc0Sbeck  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13*f0d9efc0Sbeck  * GNU General Public License for more details.
14*f0d9efc0Sbeck  *
15*f0d9efc0Sbeck  * You should have received a copy of the GNU General Public License
16*f0d9efc0Sbeck  * along with this program; if not, write to the Free Software
17*f0d9efc0Sbeck  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18*f0d9efc0Sbeck  */
19*f0d9efc0Sbeck 
20*f0d9efc0Sbeck # include <time.h>
21*f0d9efc0Sbeck 
22*f0d9efc0Sbeck #ifdef APPLE_HYB
23*f0d9efc0Sbeck #include "hybrid.h"
24*f0d9efc0Sbeck 
25*f0d9efc0Sbeck /* don't need device locking for mkhybrid */
26*f0d9efc0Sbeck #ifndef NODEVLOCKS
27*f0d9efc0Sbeck #define NODEVLOCKS
28*f0d9efc0Sbeck #endif /* NODEVLOCKS */
29*f0d9efc0Sbeck 
30*f0d9efc0Sbeck #endif /* APPLE_HYB */
31*f0d9efc0Sbeck 
32*f0d9efc0Sbeck # define HFS_BLOCKSZ	512
33*f0d9efc0Sbeck # define HFS_MAX_FLEN	31
34*f0d9efc0Sbeck # define HFS_MAX_VLEN	27
35*f0d9efc0Sbeck 
36*f0d9efc0Sbeck typedef struct _hfsvol_  hfsvol;
37*f0d9efc0Sbeck typedef struct _hfsfile_ hfsfile;
38*f0d9efc0Sbeck typedef struct _hfsdir_  hfsdir;
39*f0d9efc0Sbeck 
40*f0d9efc0Sbeck typedef struct {
41*f0d9efc0Sbeck   char name[HFS_MAX_VLEN + 1];	/* name of volume */
42*f0d9efc0Sbeck   int flags;			/* volume flags */
43*f0d9efc0Sbeck   unsigned long totbytes;	/* total bytes on volume */
44*f0d9efc0Sbeck   unsigned long freebytes;	/* free bytes on volume */
45*f0d9efc0Sbeck   time_t crdate;		/* volume creation date */
46*f0d9efc0Sbeck   time_t mddate;		/* last volume modification date */
47*f0d9efc0Sbeck } hfsvolent;
48*f0d9efc0Sbeck 
49*f0d9efc0Sbeck typedef struct {
50*f0d9efc0Sbeck   char name[HFS_MAX_FLEN + 1];	/* catalog name */
51*f0d9efc0Sbeck   int flags;			/* bit flags */
52*f0d9efc0Sbeck   long cnid;			/* catalog node id (CNID) */
53*f0d9efc0Sbeck   long parid;			/* CNID of parent directory */
54*f0d9efc0Sbeck   time_t crdate;		/* date of creation */
55*f0d9efc0Sbeck   time_t mddate;		/* date of last modification */
56*f0d9efc0Sbeck   unsigned long dsize;		/* size of data fork */
57*f0d9efc0Sbeck   unsigned long rsize;		/* size of resource fork */
58*f0d9efc0Sbeck   char type[5];			/* file type code (plus null) */
59*f0d9efc0Sbeck   char creator[5];		/* file creator code (plus null) */
60*f0d9efc0Sbeck   short fdflags;		/* Macintosh Finder flags */
61*f0d9efc0Sbeck } hfsdirent;
62*f0d9efc0Sbeck 
63*f0d9efc0Sbeck # define HFS_ISDIR		0x01
64*f0d9efc0Sbeck # define HFS_ISLOCKED		0x02
65*f0d9efc0Sbeck 
66*f0d9efc0Sbeck # define HFS_CNID_ROOTPAR	1
67*f0d9efc0Sbeck # define HFS_CNID_ROOTDIR	2
68*f0d9efc0Sbeck # define HFS_CNID_EXT		3
69*f0d9efc0Sbeck # define HFS_CNID_CAT		4
70*f0d9efc0Sbeck # define HFS_CNID_BADALLOC	5
71*f0d9efc0Sbeck 
72*f0d9efc0Sbeck # define HFS_FNDR_ISONDESK		(1 <<  0)
73*f0d9efc0Sbeck # define HFS_FNDR_COLOR			0x0e
74*f0d9efc0Sbeck # define HFS_FNDR_COLORRESERVED		(1 <<  4)
75*f0d9efc0Sbeck # define HFS_FNDR_REQUIRESSWITCHLAUNCH	(1 <<  5)
76*f0d9efc0Sbeck # define HFS_FNDR_ISSHARED		(1 <<  6)
77*f0d9efc0Sbeck # define HFS_FNDR_HASNOINITS		(1 <<  7)
78*f0d9efc0Sbeck # define HFS_FNDR_HASBEENINITED		(1 <<  8)
79*f0d9efc0Sbeck # define HFS_FNDR_RESERVED		(1 <<  9)
80*f0d9efc0Sbeck # define HFS_FNDR_HASCUSTOMICON		(1 << 10)
81*f0d9efc0Sbeck # define HFS_FNDR_ISSTATIONERY		(1 << 11)
82*f0d9efc0Sbeck # define HFS_FNDR_NAMELOCKED		(1 << 12)
83*f0d9efc0Sbeck # define HFS_FNDR_HASBUNDLE		(1 << 13)
84*f0d9efc0Sbeck # define HFS_FNDR_ISINVISIBLE		(1 << 14)
85*f0d9efc0Sbeck # define HFS_FNDR_ISALIAS		(1 << 15)
86*f0d9efc0Sbeck 
87*f0d9efc0Sbeck extern char *hfs_error;
88*f0d9efc0Sbeck extern unsigned char hfs_charorder[];
89*f0d9efc0Sbeck 
90*f0d9efc0Sbeck #ifdef APPLE_HYB
91*f0d9efc0Sbeck hfsvol *hfs_mount(hce_mem *, int, int);
92*f0d9efc0Sbeck #else
93*f0d9efc0Sbeck hfsvol *hfs_mount(char *, int, int);
94*f0d9efc0Sbeck #endif /* APPLE_HYB */
95*f0d9efc0Sbeck 
96*f0d9efc0Sbeck int hfs_flush(hfsvol *);
97*f0d9efc0Sbeck void hfs_flushall(void);
98*f0d9efc0Sbeck #ifdef APPLE_HYB
99*f0d9efc0Sbeck int hfs_umount(hfsvol *, long);
100*f0d9efc0Sbeck #else
101*f0d9efc0Sbeck int hfs_umount(hfsvol *);
102*f0d9efc0Sbeck #endif /* APPLE_HYB */
103*f0d9efc0Sbeck void hfs_umountall(void);
104*f0d9efc0Sbeck hfsvol *hfs_getvol(char *);
105*f0d9efc0Sbeck void hfs_setvol(hfsvol *);
106*f0d9efc0Sbeck 
107*f0d9efc0Sbeck int hfs_vstat(hfsvol *, hfsvolent *);
108*f0d9efc0Sbeck #ifdef APPLE_HYB
109*f0d9efc0Sbeck int hfs_format(hce_mem *, int, char *);
110*f0d9efc0Sbeck #else
111*f0d9efc0Sbeck int hfs_format(char *, int, char *);
112*f0d9efc0Sbeck #endif /* APPLE_HYB */
113*f0d9efc0Sbeck 
114*f0d9efc0Sbeck int hfs_chdir(hfsvol *, char *);
115*f0d9efc0Sbeck long hfs_getcwd(hfsvol *);
116*f0d9efc0Sbeck int hfs_setcwd(hfsvol *, long);
117*f0d9efc0Sbeck int hfs_dirinfo(hfsvol *, long *, char *);
118*f0d9efc0Sbeck 
119*f0d9efc0Sbeck hfsdir *hfs_opendir(hfsvol *, char *);
120*f0d9efc0Sbeck int hfs_readdir(hfsdir *, hfsdirent *);
121*f0d9efc0Sbeck int hfs_closedir(hfsdir *);
122*f0d9efc0Sbeck 
123*f0d9efc0Sbeck hfsfile *hfs_open(hfsvol *, char *);
124*f0d9efc0Sbeck int hfs_setfork(hfsfile *, int);
125*f0d9efc0Sbeck int hfs_getfork(hfsfile *);
126*f0d9efc0Sbeck long hfs_read(hfsfile *, void *, unsigned long);
127*f0d9efc0Sbeck long hfs_write(hfsfile *, void *, unsigned long);
128*f0d9efc0Sbeck int hfs_truncate(hfsfile *, unsigned long);
129*f0d9efc0Sbeck long hfs_lseek(hfsfile *, long, int);
130*f0d9efc0Sbeck #ifdef APPLE_HYB
131*f0d9efc0Sbeck int hfs_close(hfsfile *, long, long);
132*f0d9efc0Sbeck #else
133*f0d9efc0Sbeck int hfs_close(hfsfile *);
134*f0d9efc0Sbeck #endif /* APPLE_HYB */
135*f0d9efc0Sbeck 
136*f0d9efc0Sbeck int hfs_stat(hfsvol *, char *, hfsdirent *);
137*f0d9efc0Sbeck int hfs_fstat(hfsfile *, hfsdirent *);
138*f0d9efc0Sbeck int hfs_setattr(hfsvol *, char *, hfsdirent *);
139*f0d9efc0Sbeck int hfs_fsetattr(hfsfile *, hfsdirent *);
140*f0d9efc0Sbeck 
141*f0d9efc0Sbeck int hfs_mkdir(hfsvol *, char *);
142*f0d9efc0Sbeck int hfs_rmdir(hfsvol *, char *);
143*f0d9efc0Sbeck 
144*f0d9efc0Sbeck int hfs_create(hfsvol *, char *, char *, char *);
145*f0d9efc0Sbeck int hfs_delete(hfsvol *, char *);
146*f0d9efc0Sbeck 
147*f0d9efc0Sbeck int hfs_rename(hfsvol *, char *, char *);
148*f0d9efc0Sbeck 
149*f0d9efc0Sbeck #ifdef APPLE_HYB
150*f0d9efc0Sbeck unsigned short hfs_get_drAllocPtr(hfsfile *);
151*f0d9efc0Sbeck int hfs_set_drAllocPtr(hfsfile *, unsigned short, int size);
152*f0d9efc0Sbeck #endif /* APPLE_HYB */
153