198dc8da5SEd Maste /* $NetBSD: direntry.h,v 1.14 1997/11/17 15:36:32 ws Exp $ */ 298dc8da5SEd Maste 398dc8da5SEd Maste /*- 498dc8da5SEd Maste * SPDX-License-Identifier: BSD-4-Clause 598dc8da5SEd Maste * 698dc8da5SEd Maste * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. 798dc8da5SEd Maste * Copyright (C) 1994, 1995, 1997 TooLs GmbH. 898dc8da5SEd Maste * All rights reserved. 998dc8da5SEd Maste * Original code by Paul Popelka (paulp@uts.amdahl.com) (see below). 1098dc8da5SEd Maste * 1198dc8da5SEd Maste * Redistribution and use in source and binary forms, with or without 1298dc8da5SEd Maste * modification, are permitted provided that the following conditions 1398dc8da5SEd Maste * are met: 1498dc8da5SEd Maste * 1. Redistributions of source code must retain the above copyright 1598dc8da5SEd Maste * notice, this list of conditions and the following disclaimer. 1698dc8da5SEd Maste * 2. Redistributions in binary form must reproduce the above copyright 1798dc8da5SEd Maste * notice, this list of conditions and the following disclaimer in the 1898dc8da5SEd Maste * documentation and/or other materials provided with the distribution. 1998dc8da5SEd Maste * 3. All advertising materials mentioning features or use of this software 2098dc8da5SEd Maste * must display the following acknowledgement: 2198dc8da5SEd Maste * This product includes software developed by TooLs GmbH. 2298dc8da5SEd Maste * 4. The name of TooLs GmbH may not be used to endorse or promote products 2398dc8da5SEd Maste * derived from this software without specific prior written permission. 2498dc8da5SEd Maste * 2598dc8da5SEd Maste * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR 2698dc8da5SEd Maste * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 2798dc8da5SEd Maste * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2898dc8da5SEd Maste * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2998dc8da5SEd Maste * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 3098dc8da5SEd Maste * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 3198dc8da5SEd Maste * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 3298dc8da5SEd Maste * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 3398dc8da5SEd Maste * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 3498dc8da5SEd Maste * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3598dc8da5SEd Maste */ 3698dc8da5SEd Maste /*- 3798dc8da5SEd Maste * Written by Paul Popelka (paulp@uts.amdahl.com) 3898dc8da5SEd Maste * 3998dc8da5SEd Maste * You can do anything you want with this software, just don't say you wrote 4098dc8da5SEd Maste * it, and don't remove this notice. 4198dc8da5SEd Maste * 4298dc8da5SEd Maste * This software is provided "as is". 4398dc8da5SEd Maste * 4498dc8da5SEd Maste * The author supplies this software to be publicly redistributed on the 4598dc8da5SEd Maste * understanding that the author is not responsible for the correct 4698dc8da5SEd Maste * functioning of this software in any circumstances and is not liable for 4798dc8da5SEd Maste * any damages caused by this software. 4898dc8da5SEd Maste * 4998dc8da5SEd Maste * October 1992 5098dc8da5SEd Maste */ 5198dc8da5SEd Maste #ifndef _FS_MSDOSFS_DIRENTRY_H_ 5298dc8da5SEd Maste #define _FS_MSDOSFS_DIRENTRY_H_ 5398dc8da5SEd Maste 5498dc8da5SEd Maste /* 5598dc8da5SEd Maste * Structure of a dos directory entry. 5698dc8da5SEd Maste */ 5798dc8da5SEd Maste struct direntry { 5898dc8da5SEd Maste uint8_t deName[11]; /* filename, blank filled */ 5998dc8da5SEd Maste #define SLOT_EMPTY 0x00 /* slot has never been used */ 6098dc8da5SEd Maste #define SLOT_E5 0x05 /* the real value is 0xe5 */ 6198dc8da5SEd Maste #define SLOT_DELETED 0xe5 /* file in this slot deleted */ 6298dc8da5SEd Maste uint8_t deAttributes; /* file attributes */ 6398dc8da5SEd Maste #define ATTR_NORMAL 0x00 /* normal file */ 6498dc8da5SEd Maste #define ATTR_READONLY 0x01 /* file is readonly */ 6598dc8da5SEd Maste #define ATTR_HIDDEN 0x02 /* file is hidden */ 6698dc8da5SEd Maste #define ATTR_SYSTEM 0x04 /* file is a system file */ 6798dc8da5SEd Maste #define ATTR_VOLUME 0x08 /* entry is a volume label */ 6898dc8da5SEd Maste #define ATTR_DIRECTORY 0x10 /* entry is a directory name */ 6998dc8da5SEd Maste #define ATTR_ARCHIVE 0x20 /* file is new or modified */ 7098dc8da5SEd Maste uint8_t deLowerCase; /* NT VFAT lower case flags */ 7198dc8da5SEd Maste #define LCASE_BASE 0x08 /* filename base in lower case */ 7298dc8da5SEd Maste #define LCASE_EXT 0x10 /* filename extension in lower case */ 7398dc8da5SEd Maste uint8_t deCHundredth; /* hundredth of seconds in CTime */ 7498dc8da5SEd Maste uint8_t deCTime[2]; /* create time */ 7598dc8da5SEd Maste uint8_t deCDate[2]; /* create date */ 7698dc8da5SEd Maste uint8_t deADate[2]; /* access date */ 7798dc8da5SEd Maste uint8_t deHighClust[2]; /* high bytes of cluster number */ 7898dc8da5SEd Maste uint8_t deMTime[2]; /* last update time */ 7998dc8da5SEd Maste uint8_t deMDate[2]; /* last update date */ 8098dc8da5SEd Maste uint8_t deStartCluster[2]; /* starting cluster of file */ 8198dc8da5SEd Maste uint8_t deFileSize[4]; /* size of file in bytes */ 8298dc8da5SEd Maste }; 8398dc8da5SEd Maste 8498dc8da5SEd Maste /* 8598dc8da5SEd Maste * Structure of a Win95 long name directory entry 8698dc8da5SEd Maste */ 8798dc8da5SEd Maste struct winentry { 8898dc8da5SEd Maste uint8_t weCnt; 8998dc8da5SEd Maste #define WIN_LAST 0x40 9098dc8da5SEd Maste #define WIN_CNT 0x3f 9198dc8da5SEd Maste uint8_t wePart1[10]; 9298dc8da5SEd Maste uint8_t weAttributes; 9398dc8da5SEd Maste #define ATTR_WIN95 0x0f 9498dc8da5SEd Maste uint8_t weReserved1; 9598dc8da5SEd Maste uint8_t weChksum; 9698dc8da5SEd Maste uint8_t wePart2[12]; 9798dc8da5SEd Maste uint16_t weReserved2; 9898dc8da5SEd Maste uint8_t wePart3[4]; 9998dc8da5SEd Maste }; 10098dc8da5SEd Maste #define WIN_CHARS 13 /* Number of chars per winentry */ 10198dc8da5SEd Maste 10298dc8da5SEd Maste /* 10398dc8da5SEd Maste * Maximum number of winentries for a filename. 10498dc8da5SEd Maste */ 10598dc8da5SEd Maste #define WIN_MAXSUBENTRIES 20 10698dc8da5SEd Maste 10798dc8da5SEd Maste /* 10898dc8da5SEd Maste * Maximum filename length in Win95 10998dc8da5SEd Maste * Note: Must be < sizeof(dirent.d_name) 11098dc8da5SEd Maste */ 11198dc8da5SEd Maste #define WIN_MAXLEN 255 11298dc8da5SEd Maste 11398dc8da5SEd Maste /* 11498dc8da5SEd Maste * This is the format of the contents of the deTime field in the direntry 11598dc8da5SEd Maste * structure. 11698dc8da5SEd Maste * We don't use bitfields because we don't know how compilers for 11798dc8da5SEd Maste * arbitrary machines will lay them out. 11898dc8da5SEd Maste */ 11998dc8da5SEd Maste #define DT_2SECONDS_MASK 0x1F /* seconds divided by 2 */ 12098dc8da5SEd Maste #define DT_2SECONDS_SHIFT 0 12198dc8da5SEd Maste #define DT_MINUTES_MASK 0x7E0 /* minutes */ 12298dc8da5SEd Maste #define DT_MINUTES_SHIFT 5 12398dc8da5SEd Maste #define DT_HOURS_MASK 0xF800 /* hours */ 12498dc8da5SEd Maste #define DT_HOURS_SHIFT 11 12598dc8da5SEd Maste 12698dc8da5SEd Maste /* 12798dc8da5SEd Maste * This is the format of the contents of the deDate field in the direntry 12898dc8da5SEd Maste * structure. 12998dc8da5SEd Maste */ 13098dc8da5SEd Maste #define DD_DAY_MASK 0x1F /* day of month */ 13198dc8da5SEd Maste #define DD_DAY_SHIFT 0 13298dc8da5SEd Maste #define DD_MONTH_MASK 0x1E0 /* month */ 13398dc8da5SEd Maste #define DD_MONTH_SHIFT 5 13498dc8da5SEd Maste #define DD_YEAR_MASK 0xFE00 /* year - 1980 */ 13598dc8da5SEd Maste #define DD_YEAR_SHIFT 9 13698dc8da5SEd Maste 13798dc8da5SEd Maste int unix2dosfn(const u_char *un, u_char dn[12], size_t unlen, u_int gen); 13898dc8da5SEd Maste int unix2winfn(const u_char *un, size_t unlen, struct winentry *wep, int cnt, 13998dc8da5SEd Maste int chksum); 140*2037e988SEd Maste int winChkName(const u_char *un, size_t unlen, struct winentry *wep, 141*2037e988SEd Maste int chksum); 142*2037e988SEd Maste uint8_t winChksum(uint8_t *name); 143*2037e988SEd Maste int winSlotCnt(const u_char *un, size_t unlen); 14498dc8da5SEd Maste 14598dc8da5SEd Maste #endif /* !_FS_MSDOSFS_DIRENTRY_H_ */ 146