direntry.h revision 21673
1/*	$FreeBSD: head/sys/fs/msdosfs/direntry.h 21673 1997-01-14 07:20:47Z jkh $ */
2/*	$NetBSD: direntry.h,v 1.7 1994/08/21 18:43:54 ws Exp $	*/
3
4/*-
5 * Copyright (C) 1994 Wolfgang Solfrank.
6 * Copyright (C) 1994 TooLs GmbH.
7 * All rights reserved.
8 * Original code by Paul Popelka (paulp@uts.amdahl.com) (see below).
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
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.
23 *
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.
34 */
35/*
36 * Written by Paul Popelka (paulp@uts.amdahl.com)
37 *
38 * You can do anything you want with this software, just don't say you wrote
39 * it, and don't remove this notice.
40 *
41 * This software is provided "as is".
42 *
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.
47 *
48 * October 1992
49 */
50
51/*
52 * Structure of a dos directory entry.
53 */
54struct direntry {
55	u_char deName[8];	/* filename, blank filled */
56#define	SLOT_EMPTY	0x00	/* slot has never been used */
57#define	SLOT_E5		0x05	/* the real value is 0xe5 */
58#define	SLOT_DELETED	0xe5	/* file in this slot deleted */
59	u_char deExtension[3];	/* extension, blank filled */
60	u_char deAttributes;	/* file attributes */
61#define	ATTR_NORMAL	0x00	/* normal file */
62#define	ATTR_READONLY	0x01	/* file is readonly */
63#define	ATTR_HIDDEN	0x02	/* file is hidden */
64#define	ATTR_SYSTEM	0x04	/* file is a system file */
65#define	ATTR_VOLUME	0x08	/* entry is a volume label */
66#define	ATTR_DIRECTORY	0x10	/* entry is a directory name */
67#define	ATTR_ARCHIVE	0x20	/* file is new or modified */
68	u_char deReserved[10];	/* reserved */
69	u_char deTime[2];	/* create/last update time */
70	u_char deDate[2];	/* create/last update date */
71	u_char deStartCluster[2]; /* starting cluster of file */
72	u_char deFileSize[4];	/* size of file in bytes */
73};
74
75/*
76 * This is the format of the contents of the deTime field in the direntry
77 * structure.
78 * We don't use bitfields because we don't know how compilers for
79 * arbitrary machines will lay them out.
80 */
81#define DT_2SECONDS_MASK	0x1F	/* seconds divided by 2 */
82#define DT_2SECONDS_SHIFT	0
83#define DT_MINUTES_MASK		0x7E0	/* minutes */
84#define DT_MINUTES_SHIFT	5
85#define DT_HOURS_MASK		0xF800	/* hours */
86#define DT_HOURS_SHIFT		11
87
88/*
89 * This is the format of the contents of the deDate field in the direntry
90 * structure.
91 */
92#define DD_DAY_MASK		0x1F	/* day of month */
93#define DD_DAY_SHIFT		0
94#define DD_MONTH_MASK		0x1E0	/* month */
95#define DD_MONTH_SHIFT		5
96#define DD_YEAR_MASK		0xFE00	/* year - 1980 */
97#define DD_YEAR_SHIFT		9
98
99#ifdef KERNEL
100void unix2dostime __P((struct timespec * tsp, u_short * ddp, u_short * dtp));
101void dos2unixtime __P((u_short dd, u_short dt, struct timespec * tsp));
102int dos2unixfn __P((u_char dn[11], u_char * un));
103void unix2dosfn __P((u_char * un, u_char dn[11], int unlen));
104#endif	/* KERNEL */
105