direntry.h revision 1.1.2.2 1 1.1.2.2 thorpej /* $NetBSD: direntry.h,v 1.1.2.2 2002/12/29 19:55:58 thorpej Exp $ */
2 1.1.2.2 thorpej
3 1.1.2.2 thorpej /*-
4 1.1.2.2 thorpej * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
5 1.1.2.2 thorpej * Copyright (C) 1994, 1995, 1997 TooLs GmbH.
6 1.1.2.2 thorpej * All rights reserved.
7 1.1.2.2 thorpej * Original code by Paul Popelka (paulp (at) uts.amdahl.com) (see below).
8 1.1.2.2 thorpej *
9 1.1.2.2 thorpej * Redistribution and use in source and binary forms, with or without
10 1.1.2.2 thorpej * modification, are permitted provided that the following conditions
11 1.1.2.2 thorpej * are met:
12 1.1.2.2 thorpej * 1. Redistributions of source code must retain the above copyright
13 1.1.2.2 thorpej * notice, this list of conditions and the following disclaimer.
14 1.1.2.2 thorpej * 2. Redistributions in binary form must reproduce the above copyright
15 1.1.2.2 thorpej * notice, this list of conditions and the following disclaimer in the
16 1.1.2.2 thorpej * documentation and/or other materials provided with the distribution.
17 1.1.2.2 thorpej * 3. All advertising materials mentioning features or use of this software
18 1.1.2.2 thorpej * must display the following acknowledgement:
19 1.1.2.2 thorpej * This product includes software developed by TooLs GmbH.
20 1.1.2.2 thorpej * 4. The name of TooLs GmbH may not be used to endorse or promote products
21 1.1.2.2 thorpej * derived from this software without specific prior written permission.
22 1.1.2.2 thorpej *
23 1.1.2.2 thorpej * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
24 1.1.2.2 thorpej * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 1.1.2.2 thorpej * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 1.1.2.2 thorpej * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 1.1.2.2 thorpej * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 1.1.2.2 thorpej * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
29 1.1.2.2 thorpej * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30 1.1.2.2 thorpej * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
31 1.1.2.2 thorpej * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
32 1.1.2.2 thorpej * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 1.1.2.2 thorpej */
34 1.1.2.2 thorpej /*
35 1.1.2.2 thorpej * Written by Paul Popelka (paulp (at) uts.amdahl.com)
36 1.1.2.2 thorpej *
37 1.1.2.2 thorpej * You can do anything you want with this software, just don't say you wrote
38 1.1.2.2 thorpej * it, and don't remove this notice.
39 1.1.2.2 thorpej *
40 1.1.2.2 thorpej * This software is provided "as is".
41 1.1.2.2 thorpej *
42 1.1.2.2 thorpej * The author supplies this software to be publicly redistributed on the
43 1.1.2.2 thorpej * understanding that the author is not responsible for the correct
44 1.1.2.2 thorpej * functioning of this software in any circumstances and is not liable for
45 1.1.2.2 thorpej * any damages caused by this software.
46 1.1.2.2 thorpej *
47 1.1.2.2 thorpej * October 1992
48 1.1.2.2 thorpej */
49 1.1.2.2 thorpej
50 1.1.2.2 thorpej /*
51 1.1.2.2 thorpej * Structure of a dos directory entry.
52 1.1.2.2 thorpej */
53 1.1.2.2 thorpej struct direntry {
54 1.1.2.2 thorpej u_int8_t deName[8]; /* filename, blank filled */
55 1.1.2.2 thorpej #define SLOT_EMPTY 0x00 /* slot has never been used */
56 1.1.2.2 thorpej #define SLOT_E5 0x05 /* the real value is 0xe5 */
57 1.1.2.2 thorpej #define SLOT_DELETED 0xe5 /* file in this slot deleted */
58 1.1.2.2 thorpej u_int8_t deExtension[3]; /* extension, blank filled */
59 1.1.2.2 thorpej u_int8_t deAttributes; /* file attributes */
60 1.1.2.2 thorpej #define ATTR_NORMAL 0x00 /* normal file */
61 1.1.2.2 thorpej #define ATTR_READONLY 0x01 /* file is readonly */
62 1.1.2.2 thorpej #define ATTR_HIDDEN 0x02 /* file is hidden */
63 1.1.2.2 thorpej #define ATTR_SYSTEM 0x04 /* file is a system file */
64 1.1.2.2 thorpej #define ATTR_VOLUME 0x08 /* entry is a volume label */
65 1.1.2.2 thorpej #define ATTR_DIRECTORY 0x10 /* entry is a directory name */
66 1.1.2.2 thorpej #define ATTR_ARCHIVE 0x20 /* file is new or modified */
67 1.1.2.2 thorpej u_int8_t deReserved; /* reserved */
68 1.1.2.2 thorpej u_int8_t deCHundredth; /* hundredth of seconds in CTime */
69 1.1.2.2 thorpej u_int8_t deCTime[2]; /* create time */
70 1.1.2.2 thorpej u_int8_t deCDate[2]; /* create date */
71 1.1.2.2 thorpej u_int8_t deADate[2]; /* access date */
72 1.1.2.2 thorpej u_int8_t deHighClust[2]; /* high bytes of cluster number */
73 1.1.2.2 thorpej u_int8_t deMTime[2]; /* last update time */
74 1.1.2.2 thorpej u_int8_t deMDate[2]; /* last update date */
75 1.1.2.2 thorpej u_int8_t deStartCluster[2]; /* starting cluster of file */
76 1.1.2.2 thorpej u_int8_t deFileSize[4]; /* size of file in bytes */
77 1.1.2.2 thorpej };
78 1.1.2.2 thorpej
79 1.1.2.2 thorpej /*
80 1.1.2.2 thorpej * Structure of a Win95 long name directory entry
81 1.1.2.2 thorpej */
82 1.1.2.2 thorpej struct winentry {
83 1.1.2.2 thorpej u_int8_t weCnt;
84 1.1.2.2 thorpej #define WIN_LAST 0x40
85 1.1.2.2 thorpej #define WIN_CNT 0x3f
86 1.1.2.2 thorpej u_int8_t wePart1[10];
87 1.1.2.2 thorpej u_int8_t weAttributes;
88 1.1.2.2 thorpej #define ATTR_WIN95 0x0f
89 1.1.2.2 thorpej u_int8_t weReserved1;
90 1.1.2.2 thorpej u_int8_t weChksum;
91 1.1.2.2 thorpej u_int8_t wePart2[12];
92 1.1.2.2 thorpej u_int16_t weReserved2;
93 1.1.2.2 thorpej u_int8_t wePart3[4];
94 1.1.2.2 thorpej };
95 1.1.2.2 thorpej #define WIN_CHARS 13 /* Number of chars per winentry */
96 1.1.2.2 thorpej
97 1.1.2.2 thorpej /*
98 1.1.2.2 thorpej * This is the format of the contents of the deTime field in the direntry
99 1.1.2.2 thorpej * structure.
100 1.1.2.2 thorpej * We don't use bitfields because we don't know how compilers for
101 1.1.2.2 thorpej * arbitrary machines will lay them out.
102 1.1.2.2 thorpej */
103 1.1.2.2 thorpej #define DT_2SECONDS_MASK 0x1F /* seconds divided by 2 */
104 1.1.2.2 thorpej #define DT_2SECONDS_SHIFT 0
105 1.1.2.2 thorpej #define DT_MINUTES_MASK 0x7E0 /* minutes */
106 1.1.2.2 thorpej #define DT_MINUTES_SHIFT 5
107 1.1.2.2 thorpej #define DT_HOURS_MASK 0xF800 /* hours */
108 1.1.2.2 thorpej #define DT_HOURS_SHIFT 11
109 1.1.2.2 thorpej
110 1.1.2.2 thorpej /*
111 1.1.2.2 thorpej * This is the format of the contents of the deDate field in the direntry
112 1.1.2.2 thorpej * structure.
113 1.1.2.2 thorpej */
114 1.1.2.2 thorpej #define DD_DAY_MASK 0x1F /* day of month */
115 1.1.2.2 thorpej #define DD_DAY_SHIFT 0
116 1.1.2.2 thorpej #define DD_MONTH_MASK 0x1E0 /* month */
117 1.1.2.2 thorpej #define DD_MONTH_SHIFT 5
118 1.1.2.2 thorpej #define DD_YEAR_MASK 0xFE00 /* year - 1980 */
119 1.1.2.2 thorpej #define DD_YEAR_SHIFT 9
120 1.1.2.2 thorpej
121 1.1.2.2 thorpej #ifdef _KERNEL
122 1.1.2.2 thorpej void unix2dostime __P((struct timespec *tsp, u_int16_t *ddp,
123 1.1.2.2 thorpej u_int16_t *dtp, u_int8_t *dhp));
124 1.1.2.2 thorpej void dos2unixtime __P((u_int dd, u_int dt, u_int dh, struct timespec *tsp));
125 1.1.2.2 thorpej int dos2unixfn __P((u_char dn[11], u_char *un, int lower));
126 1.1.2.2 thorpej int unix2dosfn __P((const u_char *un, u_char dn[12], int unlen,
127 1.1.2.2 thorpej u_int gen));
128 1.1.2.2 thorpej int unix2winfn __P((const u_char *un, int unlen, struct winentry *wep,
129 1.1.2.2 thorpej int cnt, int chksum));
130 1.1.2.2 thorpej int winChkName __P((const u_char *un, int unlen, struct winentry *wep,
131 1.1.2.2 thorpej int chksum));
132 1.1.2.2 thorpej int win2unixfn __P((struct winentry *wep, struct dirent *dp, int chksum));
133 1.1.2.2 thorpej u_int8_t winChksum __P((u_int8_t *name));
134 1.1.2.2 thorpej int winSlotCnt __P((const u_char *un, int unlen));
135 1.1.2.2 thorpej #endif /* _KERNEL */
136