1 /* $FreeBSD: src/sys/msdosfs/direntry.h,v 1.15 1999/12/29 04:54:52 peter Exp $ */
2 /* $NetBSD: direntry.h,v 1.14 1997/11/17 15:36:32 ws Exp $ */
5 * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
6 * Copyright (C) 1994, 1995, 1997 TooLs GmbH.
8 * Original code by Paul Popelka (paulp@uts.amdahl.com) (see below).
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by TooLs GmbH.
21 * 4. The name of TooLs GmbH may not be used to endorse or promote products
22 * derived from this software without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
25 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
30 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
32 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 * Written by Paul Popelka (paulp@uts.amdahl.com)
38 * You can do anything you want with this software, just don't say you wrote
39 * it, and don't remove this notice.
41 * This software is provided "as is".
43 * The author supplies this software to be publicly redistributed on the
44 * understanding that the author is not responsible for the correct
45 * functioning of this software in any circumstances and is not liable for
46 * any damages caused by this software.
51 #ifndef _VFS_MSDOSFS_DIRENTRY_H_
52 #define _VFS_MSDOSFS_DIRENTRY_H_
55 * Structure of a dos directory entry.
58 u_int8_t deName[11]; /* filename, blank filled */
59 #define SLOT_EMPTY 0x00 /* slot has never been used */
60 #define SLOT_E5 0x05 /* the real value is 0xe5 */
61 #define SLOT_DELETED 0xe5 /* file in this slot deleted */
62 u_int8_t deAttributes; /* file attributes */
63 #define ATTR_NORMAL 0x00 /* normal file */
64 #define ATTR_READONLY 0x01 /* file is readonly */
65 #define ATTR_HIDDEN 0x02 /* file is hidden */
66 #define ATTR_SYSTEM 0x04 /* file is a system file */
67 #define ATTR_VOLUME 0x08 /* entry is a volume label */
68 #define ATTR_DIRECTORY 0x10 /* entry is a directory name */
69 #define ATTR_ARCHIVE 0x20 /* file is new or modified */
70 u_int8_t deLowerCase; /* NT VFAT lower case flags */
71 #define LCASE_BASE 0x08 /* filename base in lower case */
72 #define LCASE_EXT 0x10 /* filename extension in lower case */
73 u_int8_t deCHundredth; /* hundredth of seconds in CTime */
74 u_int8_t deCTime[2]; /* create time */
75 u_int8_t deCDate[2]; /* create date */
76 u_int8_t deADate[2]; /* access date */
77 u_int8_t deHighClust[2]; /* high bytes of cluster number */
78 u_int8_t deMTime[2]; /* last update time */
79 u_int8_t deMDate[2]; /* last update date */
80 u_int8_t deStartCluster[2]; /* starting cluster of file */
81 u_int8_t deFileSize[4]; /* size of file in bytes */
85 * Structure of a Win95 long name directory entry
92 u_int8_t weAttributes;
93 #define ATTR_WIN95 0x0f
97 u_int16_t weReserved2;
100 #define WIN_CHARS 13 /* Number of chars per winentry */
103 * Maximum filename length in Win95
104 * Note: Must be < sizeof(dirent.d_name)
106 #define WIN_MAXLEN 255
109 * This is the format of the contents of the deTime field in the direntry
111 * We don't use bitfields because we don't know how compilers for
112 * arbitrary machines will lay them out.
114 #define DT_2SECONDS_MASK 0x1F /* seconds divided by 2 */
115 #define DT_2SECONDS_SHIFT 0
116 #define DT_MINUTES_MASK 0x7E0 /* minutes */
117 #define DT_MINUTES_SHIFT 5
118 #define DT_HOURS_MASK 0xF800 /* hours */
119 #define DT_HOURS_SHIFT 11
122 * This is the format of the contents of the deDate field in the direntry
125 #define DD_DAY_MASK 0x1F /* day of month */
126 #define DD_DAY_SHIFT 0
127 #define DD_MONTH_MASK 0x1E0 /* month */
128 #define DD_MONTH_SHIFT 5
129 #define DD_YEAR_MASK 0xFE00 /* year - 1980 */
130 #define DD_YEAR_SHIFT 9
136 char nb_buf[WIN_MAXLEN + 1];
141 char *mbnambuf_flush(struct mbnambuf *nbp, char *d_name, u_int16_t *d_namlen);
142 void mbnambuf_init(struct mbnambuf *nbp);
143 void mbnambuf_write(struct mbnambuf *nbp, char *name, int id);
144 void unix2dostime (struct timespec *tsp, u_int16_t *ddp,
145 u_int16_t *dtp, u_int8_t *dhp);
146 void dos2unixtime (u_int dd, u_int dt, u_int dh, struct timespec *tsp);
147 int dos2unixfn (u_char dn[11], u_char *un, int lower, struct msdosfsmount *pmp);
148 int unix2dosfn (const u_char *un, u_char dn[12], size_t unlen, u_int gen, struct msdosfsmount *pmp);
149 int unix2winfn (const u_char *un, size_t unlen, struct winentry *wep, int cnt, int chksum, struct msdosfsmount *pmp);
150 int winChkName(struct mbnambuf *nbp, const u_char *un, size_t unlen,
151 int chksum, struct msdosfsmount *pmp);
152 int win2unixfn(struct mbnambuf *nbp, struct winentry *wep, int chksum,
153 struct msdosfsmount *pmp);
154 u_int8_t winChksum (u_int8_t *name);
155 int winSlotCnt (const u_char *un, size_t unlen, struct msdosfsmount *pmp);
156 size_t winLenFixup (const u_char *un, size_t unlen);
159 #endif /* !_VFS_MSDOSFS_DIRENTRY_H_ */