1999-08-28 01:08:13 +00:00
|
|
|
/* $FreeBSD$ */
|
1998-02-18 09:28:47 +00:00
|
|
|
/* $NetBSD: direntry.h,v 1.14 1997/11/17 15:36:32 ws Exp $ */
|
1994-09-19 15:41:57 +00:00
|
|
|
|
|
|
|
/*-
|
1998-02-18 09:28:47 +00:00
|
|
|
* Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
|
|
|
|
* Copyright (C) 1994, 1995, 1997 TooLs GmbH.
|
1994-09-19 15:41:57 +00:00
|
|
|
* All rights reserved.
|
|
|
|
* Original code by Paul Popelka (paulp@uts.amdahl.com) (see below).
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by TooLs GmbH.
|
|
|
|
* 4. The name of TooLs GmbH may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
|
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
|
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
|
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
2005-01-06 18:10:42 +00:00
|
|
|
/*-
|
1994-09-19 15:41:57 +00:00
|
|
|
* Written by Paul Popelka (paulp@uts.amdahl.com)
|
1995-05-30 08:16:23 +00:00
|
|
|
*
|
1994-09-19 15:41:57 +00:00
|
|
|
* You can do anything you want with this software, just don't say you wrote
|
|
|
|
* it, and don't remove this notice.
|
1995-05-30 08:16:23 +00:00
|
|
|
*
|
1994-09-19 15:41:57 +00:00
|
|
|
* This software is provided "as is".
|
1995-05-30 08:16:23 +00:00
|
|
|
*
|
1994-09-19 15:41:57 +00:00
|
|
|
* The author supplies this software to be publicly redistributed on the
|
|
|
|
* understanding that the author is not responsible for the correct
|
|
|
|
* functioning of this software in any circumstances and is not liable for
|
|
|
|
* any damages caused by this software.
|
1995-05-30 08:16:23 +00:00
|
|
|
*
|
1994-09-19 15:41:57 +00:00
|
|
|
* October 1992
|
|
|
|
*/
|
2010-02-13 12:41:07 +00:00
|
|
|
#ifndef _FS_MSDOSFS_DIRENTRY_H_
|
|
|
|
#define _FS_MSDOSFS_DIRENTRY_H_
|
1994-09-19 15:41:57 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Structure of a dos directory entry.
|
|
|
|
*/
|
|
|
|
struct direntry {
|
2010-02-13 12:41:07 +00:00
|
|
|
u_int8_t deName[11]; /* filename, blank filled */
|
1998-02-18 09:28:47 +00:00
|
|
|
#define SLOT_EMPTY 0x00 /* slot has never been used */
|
|
|
|
#define SLOT_E5 0x05 /* the real value is 0xe5 */
|
|
|
|
#define SLOT_DELETED 0xe5 /* file in this slot deleted */
|
|
|
|
u_int8_t deAttributes; /* file attributes */
|
|
|
|
#define ATTR_NORMAL 0x00 /* normal file */
|
|
|
|
#define ATTR_READONLY 0x01 /* file is readonly */
|
|
|
|
#define ATTR_HIDDEN 0x02 /* file is hidden */
|
|
|
|
#define ATTR_SYSTEM 0x04 /* file is a system file */
|
|
|
|
#define ATTR_VOLUME 0x08 /* entry is a volume label */
|
|
|
|
#define ATTR_DIRECTORY 0x10 /* entry is a directory name */
|
|
|
|
#define ATTR_ARCHIVE 0x20 /* file is new or modified */
|
1998-11-21 00:20:24 +00:00
|
|
|
u_int8_t deLowerCase; /* NT VFAT lower case flags */
|
|
|
|
#define LCASE_BASE 0x08 /* filename base in lower case */
|
|
|
|
#define LCASE_EXT 0x10 /* filename extension in lower case */
|
1998-02-18 09:28:47 +00:00
|
|
|
u_int8_t deCHundredth; /* hundredth of seconds in CTime */
|
|
|
|
u_int8_t deCTime[2]; /* create time */
|
|
|
|
u_int8_t deCDate[2]; /* create date */
|
|
|
|
u_int8_t deADate[2]; /* access date */
|
|
|
|
u_int8_t deHighClust[2]; /* high bytes of cluster number */
|
|
|
|
u_int8_t deMTime[2]; /* last update time */
|
|
|
|
u_int8_t deMDate[2]; /* last update date */
|
|
|
|
u_int8_t deStartCluster[2]; /* starting cluster of file */
|
|
|
|
u_int8_t deFileSize[4]; /* size of file in bytes */
|
1994-09-19 15:41:57 +00:00
|
|
|
};
|
|
|
|
|
1998-02-18 09:28:47 +00:00
|
|
|
/*
|
|
|
|
* Structure of a Win95 long name directory entry
|
|
|
|
*/
|
|
|
|
struct winentry {
|
|
|
|
u_int8_t weCnt;
|
|
|
|
#define WIN_LAST 0x40
|
|
|
|
#define WIN_CNT 0x3f
|
|
|
|
u_int8_t wePart1[10];
|
|
|
|
u_int8_t weAttributes;
|
|
|
|
#define ATTR_WIN95 0x0f
|
|
|
|
u_int8_t weReserved1;
|
|
|
|
u_int8_t weChksum;
|
|
|
|
u_int8_t wePart2[12];
|
|
|
|
u_int16_t weReserved2;
|
|
|
|
u_int8_t wePart3[4];
|
|
|
|
};
|
|
|
|
#define WIN_CHARS 13 /* Number of chars per winentry */
|
|
|
|
|
2003-09-26 20:26:25 +00:00
|
|
|
/*
|
2003-09-27 01:18:27 +00:00
|
|
|
* Maximum number of winentries for a filename.
|
2003-09-26 20:26:25 +00:00
|
|
|
*/
|
2003-09-27 01:18:27 +00:00
|
|
|
#define WIN_MAXSUBENTRIES 20
|
2003-09-26 20:26:25 +00:00
|
|
|
|
1998-02-18 09:28:47 +00:00
|
|
|
/*
|
|
|
|
* Maximum filename length in Win95
|
|
|
|
* Note: Must be < sizeof(dirent.d_name)
|
|
|
|
*/
|
|
|
|
#define WIN_MAXLEN 255
|
|
|
|
|
1994-09-19 15:41:57 +00:00
|
|
|
/*
|
|
|
|
* This is the format of the contents of the deTime field in the direntry
|
|
|
|
* structure.
|
|
|
|
* We don't use bitfields because we don't know how compilers for
|
|
|
|
* arbitrary machines will lay them out.
|
|
|
|
*/
|
|
|
|
#define DT_2SECONDS_MASK 0x1F /* seconds divided by 2 */
|
|
|
|
#define DT_2SECONDS_SHIFT 0
|
|
|
|
#define DT_MINUTES_MASK 0x7E0 /* minutes */
|
|
|
|
#define DT_MINUTES_SHIFT 5
|
|
|
|
#define DT_HOURS_MASK 0xF800 /* hours */
|
|
|
|
#define DT_HOURS_SHIFT 11
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is the format of the contents of the deDate field in the direntry
|
|
|
|
* structure.
|
|
|
|
*/
|
|
|
|
#define DD_DAY_MASK 0x1F /* day of month */
|
|
|
|
#define DD_DAY_SHIFT 0
|
|
|
|
#define DD_MONTH_MASK 0x1E0 /* month */
|
|
|
|
#define DD_MONTH_SHIFT 5
|
|
|
|
#define DD_YEAR_MASK 0xFE00 /* year - 1980 */
|
|
|
|
#define DD_YEAR_SHIFT 9
|
|
|
|
|
1999-12-29 05:07:58 +00:00
|
|
|
#ifdef _KERNEL
|
2007-08-31 22:29:55 +00:00
|
|
|
struct mbnambuf {
|
|
|
|
size_t nb_len;
|
|
|
|
int nb_last_id;
|
|
|
|
char nb_buf[WIN_MAXLEN + 1];
|
|
|
|
};
|
|
|
|
|
1998-02-18 09:28:47 +00:00
|
|
|
struct dirent;
|
2003-09-27 01:18:27 +00:00
|
|
|
struct msdosfsmount;
|
|
|
|
|
2007-08-31 22:29:55 +00:00
|
|
|
char *mbnambuf_flush(struct mbnambuf *nbp, struct dirent *dp);
|
|
|
|
void mbnambuf_init(struct mbnambuf *nbp);
|
|
|
|
void mbnambuf_write(struct mbnambuf *nbp, char *name, int id);
|
2003-09-27 01:18:27 +00:00
|
|
|
int dos2unixfn(u_char dn[11], u_char *un, int lower,
|
|
|
|
struct msdosfsmount *pmp);
|
2004-02-19 09:56:58 +00:00
|
|
|
int unix2dosfn(const u_char *un, u_char dn[12], size_t unlen, u_int gen,
|
2003-09-27 01:18:27 +00:00
|
|
|
struct msdosfsmount *pmp);
|
2004-02-19 09:56:58 +00:00
|
|
|
int unix2winfn(const u_char *un, size_t unlen, struct winentry *wep, int cnt,
|
2003-09-27 01:18:27 +00:00
|
|
|
int chksum, struct msdosfsmount *pmp);
|
2007-08-31 22:29:55 +00:00
|
|
|
int winChkName(struct mbnambuf *nbp, const u_char *un, size_t unlen,
|
|
|
|
int chksum, struct msdosfsmount *pmp);
|
|
|
|
int win2unixfn(struct mbnambuf *nbp, struct winentry *wep, int chksum,
|
2003-09-27 01:18:27 +00:00
|
|
|
struct msdosfsmount *pmp);
|
2010-02-13 12:41:07 +00:00
|
|
|
u_int8_t winChksum(u_int8_t *name);
|
2004-02-19 09:56:58 +00:00
|
|
|
int winSlotCnt(const u_char *un, size_t unlen, struct msdosfsmount *pmp);
|
|
|
|
size_t winLenFixup(const u_char *un, size_t unlen);
|
1999-12-29 05:07:58 +00:00
|
|
|
#endif /* _KERNEL */
|
2010-02-13 12:41:07 +00:00
|
|
|
#endif /* !_FS_MSDOSFS_DIRENTRY_H_ */
|