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