xref: /illumos-gate/usr/src/uts/common/sys/fs/pc_dir.h (revision f127cb91)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
55b024a5bSbatschul  * Common Development and Distribution License (the "License").
65b024a5bSbatschul  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
224a37d755Sksn  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
235b024a5bSbatschul  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_SYS_FS_PC_DIR_H
277c478bd9Sstevel@tonic-gate #define	_SYS_FS_PC_DIR_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #include <sys/dirent.h>
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
347c478bd9Sstevel@tonic-gate extern "C" {
357c478bd9Sstevel@tonic-gate #endif
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #define	PCFNAMESIZE	8
387c478bd9Sstevel@tonic-gate #define	PCFEXTSIZE	3
397c478bd9Sstevel@tonic-gate #define	PCMAXPATHLEN	MAXPATHLEN
407c478bd9Sstevel@tonic-gate #define	PCMAXNAMLEN	255
414a37d755Sksn #define	PCMAXNAM_UTF16	(256 * sizeof (uint16_t))	/* for UTF-16 */
427c478bd9Sstevel@tonic-gate #define	PCLFNCHUNKSIZE	13
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate struct pctime {
457c478bd9Sstevel@tonic-gate 	ushort_t pct_time;		/* hh:mm:ss (little endian) */
467c478bd9Sstevel@tonic-gate 	ushort_t pct_date;		/* yy:mm:dd (little endian) */
477c478bd9Sstevel@tonic-gate };
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate /*
507c478bd9Sstevel@tonic-gate  * Shifts and masks for time and date fields, in host byte order.
517c478bd9Sstevel@tonic-gate  */
527c478bd9Sstevel@tonic-gate #define	SECSHIFT	0
537c478bd9Sstevel@tonic-gate #define	SECMASK		0x1F
547c478bd9Sstevel@tonic-gate #define	MINSHIFT	5
557c478bd9Sstevel@tonic-gate #define	MINMASK		0x3F
567c478bd9Sstevel@tonic-gate #define	HOURSHIFT	11
577c478bd9Sstevel@tonic-gate #define	HOURMASK	0x1F
587c478bd9Sstevel@tonic-gate 
597c478bd9Sstevel@tonic-gate #define	DAYSHIFT	0
607c478bd9Sstevel@tonic-gate #define	DAYMASK		0x1F
617c478bd9Sstevel@tonic-gate #define	MONSHIFT	5
627c478bd9Sstevel@tonic-gate #define	MONMASK		0x0F
637c478bd9Sstevel@tonic-gate #define	YEARSHIFT	9
647c478bd9Sstevel@tonic-gate #define	YEARMASK	0x7F
657c478bd9Sstevel@tonic-gate 
667c478bd9Sstevel@tonic-gate struct pcdir {
677c478bd9Sstevel@tonic-gate 	char pcd_filename[PCFNAMESIZE];	/* file name */
687c478bd9Sstevel@tonic-gate 	char pcd_ext[PCFEXTSIZE];	/* file extension */
697c478bd9Sstevel@tonic-gate 	uchar_t	pcd_attr;		/* file attributes */
707c478bd9Sstevel@tonic-gate 	uchar_t	pcd_ntattr;		/* reserved for NT attributes */
717c478bd9Sstevel@tonic-gate 	uchar_t	pcd_crtime_msec;	/* milliseconds after the minute */
727c478bd9Sstevel@tonic-gate 	struct pctime pcd_crtime;	/* creation time/date */
737c478bd9Sstevel@tonic-gate 	ushort_t pcd_ladate;		/* last-access date */
747c478bd9Sstevel@tonic-gate 	union {
757c478bd9Sstevel@tonic-gate 		uint16_t pcd_eattr;	/* OS/2 extended attribute */
767c478bd9Sstevel@tonic-gate 		pc_cluster16_t pcd_scluster_hi;
777c478bd9Sstevel@tonic-gate 	} un;
787c478bd9Sstevel@tonic-gate 	struct pctime pcd_mtime;	/* last modified time/date */
797c478bd9Sstevel@tonic-gate 	pc_cluster16_t pcd_scluster_lo;	/* starting cluster (little endian) */
807c478bd9Sstevel@tonic-gate 	uint_t	pcd_size;		/* file size (little endian) */
817c478bd9Sstevel@tonic-gate };
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
847c478bd9Sstevel@tonic-gate }
857c478bd9Sstevel@tonic-gate #endif
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate #include <sys/fs/pc_node.h>
887c478bd9Sstevel@tonic-gate 
897c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
907c478bd9Sstevel@tonic-gate extern "C" {
917c478bd9Sstevel@tonic-gate #endif
927c478bd9Sstevel@tonic-gate 
937c478bd9Sstevel@tonic-gate /*
947c478bd9Sstevel@tonic-gate  * Long filename support (introduced by Windows 95) is an interesting
957c478bd9Sstevel@tonic-gate  * exercise in compatibility. Basically, it is now no longer the case
967c478bd9Sstevel@tonic-gate  * that an entry in a directory (as described by the 'pcdir' structure above)
977c478bd9Sstevel@tonic-gate  * contains the entire name of a file. Now, a directory entry can consist of
987c478bd9Sstevel@tonic-gate  * a long filename component (a series of 'pcdir'-like structures) followed
997c478bd9Sstevel@tonic-gate  * by a short filename (the old form). Each long filename component is
1007c478bd9Sstevel@tonic-gate  * identified by having it's Read-Only, Hidden, System, and Volume Label
1017c478bd9Sstevel@tonic-gate  * attributes set.  Each can store 13 Unicode characters (16-bits, of
1027c478bd9Sstevel@tonic-gate  * which we only look at the lower 8 for now), broken into (gak) three
1037c478bd9Sstevel@tonic-gate  * sections of the entry (since that's the way the available bits fall out).
1047c478bd9Sstevel@tonic-gate  * In addition, each long filename entry has a sequence number (starting
1057c478bd9Sstevel@tonic-gate  * from 1). The first entry has bit 7 (0x40) set in the sequence number, and
1067c478bd9Sstevel@tonic-gate  * has the maximum value in the sequence. This may seem a bit backwards, and
1077c478bd9Sstevel@tonic-gate  * it gets worse: the first entry stores the last component of
1087c478bd9Sstevel@tonic-gate  * the name. So the directory entry for a file named
1097c478bd9Sstevel@tonic-gate  * "This is a very long filename indeed" might look like this:
1107c478bd9Sstevel@tonic-gate  *
1117c478bd9Sstevel@tonic-gate  * Offset  Sequence      Component         Attributes    Cluster    Size
1127c478bd9Sstevel@tonic-gate  *    0      0x43       "me indeed"          RSHV           0         0
1137c478bd9Sstevel@tonic-gate  *   32      0x02       "y long filena"      RSHV           0         0
1147c478bd9Sstevel@tonic-gate  *   64      0x01       "This is a ver"      RSHV           0         0
1157c478bd9Sstevel@tonic-gate  *   96      ----       "THISIS~1.TXT"       <whatever>  2122       110
1167c478bd9Sstevel@tonic-gate  *
1177c478bd9Sstevel@tonic-gate  * The last entry is for the short filename, which stores actual information
1187c478bd9Sstevel@tonic-gate  * about the file (like type, permissions, cluster, and size). The short name
1197c478bd9Sstevel@tonic-gate  * is also used by non-long-filename aware applications (like Windows 3.X and
1207c478bd9Sstevel@tonic-gate  * DOS). This name is generated by Windows 95 (and now Solaris) from the
1217c478bd9Sstevel@tonic-gate  * long name, and must (of course) be unique within the directory.
1227c478bd9Sstevel@tonic-gate  * Solaris continues to this entry to actually identify the file and its
1237c478bd9Sstevel@tonic-gate  * attributes (filenames only really matter when names are used, like at
1247c478bd9Sstevel@tonic-gate  * lookup/readdir/remove/create/rename time - for general access to the file
1257c478bd9Sstevel@tonic-gate  * they aren't used).
1267c478bd9Sstevel@tonic-gate  *
1277c478bd9Sstevel@tonic-gate  * Long filenames can also be broken by applications that don't
1287c478bd9Sstevel@tonic-gate  * understand them (for example, a Solaris 2.5.1 user could rename
1297c478bd9Sstevel@tonic-gate  * "THISIS~1.TXT" to "test.exe"). This can be detected because each long
1307c478bd9Sstevel@tonic-gate  * filename component has a checksum which is based on the short filename.
1317c478bd9Sstevel@tonic-gate  * After reading the long filename entry, if the checksum doesn't match the
1327c478bd9Sstevel@tonic-gate  * short name that follows, we simply ignore it and use the short name.
1337c478bd9Sstevel@tonic-gate  *
1347c478bd9Sstevel@tonic-gate  * One subtle thing - though long file names are case-sensitive,
1357c478bd9Sstevel@tonic-gate  * searches for them are not.
1367c478bd9Sstevel@tonic-gate  *
1377c478bd9Sstevel@tonic-gate  * Another _very_ subtle thing. The number of characters in the
1387c478bd9Sstevel@tonic-gate  * last long filename chunk (the first entry, with the 0x40 bit set) is
1397c478bd9Sstevel@tonic-gate  * either all the characters (if there is no null, '\0'), or all the
1407c478bd9Sstevel@tonic-gate  * characters up to the null. _However_, if the remaining characters are
1417c478bd9Sstevel@tonic-gate  * null, Norton Disk Doctor and Microsoft ScanDisk will claim
1427c478bd9Sstevel@tonic-gate  * that the filename entry is damaged. The remaining bytes must actually
1437c478bd9Sstevel@tonic-gate  * contain 0xff (discovered with Disk Doctor).
1447c478bd9Sstevel@tonic-gate  *
1457c478bd9Sstevel@tonic-gate  * Some information about long filename support can be found in the
1467c478bd9Sstevel@tonic-gate  * book "Inside Windows 95" by Adrian King.
1477c478bd9Sstevel@tonic-gate  */
1487c478bd9Sstevel@tonic-gate 
1497c478bd9Sstevel@tonic-gate /*
1507c478bd9Sstevel@tonic-gate  * The number of bytes in each section of the name in a long filename
1517c478bd9Sstevel@tonic-gate  * entry. This is _bytes_, not characters: each character is actually
1527c478bd9Sstevel@tonic-gate  * 16 bits.
1537c478bd9Sstevel@tonic-gate  */
1547c478bd9Sstevel@tonic-gate #define	PCLF_FIRSTNAMESIZE	10
1557c478bd9Sstevel@tonic-gate #define	PCLF_SECONDNAMESIZE	12
1567c478bd9Sstevel@tonic-gate #define	PCLF_THIRDNAMESIZE	4
1577c478bd9Sstevel@tonic-gate 
1587c478bd9Sstevel@tonic-gate /*
1597c478bd9Sstevel@tonic-gate  * A long filename entry. It must match the 'pcdir' structure in size,
1607c478bd9Sstevel@tonic-gate  * and pcdl_attr must overlap pcd_attr.
1617c478bd9Sstevel@tonic-gate  */
1627c478bd9Sstevel@tonic-gate struct pcdir_lfn {
1637c478bd9Sstevel@tonic-gate 	uchar_t pcdl_ordinal;	/* lfn order. First is 01, next 02, */
1647c478bd9Sstevel@tonic-gate 				/* last has bit 7 (0x40) set */
1657c478bd9Sstevel@tonic-gate 	uchar_t pcdl_firstfilename[PCLF_FIRSTNAMESIZE];
1667c478bd9Sstevel@tonic-gate 	uchar_t pcdl_attr;
1677c478bd9Sstevel@tonic-gate 	uchar_t pcdl_type;	/* type - always contains 0 for an LFN entry */
1687c478bd9Sstevel@tonic-gate 	uchar_t pcdl_checksum;	/* checksum to validate the LFN entry - */
1697c478bd9Sstevel@tonic-gate 				/* based on the short name */
1707c478bd9Sstevel@tonic-gate 	uchar_t pcdl_secondfilename[PCLF_SECONDNAMESIZE];
1717c478bd9Sstevel@tonic-gate 	pc_cluster16_t pcd_scluster;	/* (not used, always 0) */
1727c478bd9Sstevel@tonic-gate 	uchar_t pcdl_thirdfilename[PCLF_THIRDNAMESIZE];
1737c478bd9Sstevel@tonic-gate };
1747c478bd9Sstevel@tonic-gate 
175*f127cb91Sfrankho /*
176*f127cb91Sfrankho  * FAT LFN entries are consecutively numbered downwards, and the last
177*f127cb91Sfrankho  * entry of a LFN chain will have the 0x40 'termination' marker logically
178*f127cb91Sfrankho  * or'ed in. The entry immediately preceeding the short name has number 1,
179*f127cb91Sfrankho  * consecutively increasing. Since the filename length limit on FAT is
180*f127cb91Sfrankho  * 255 unicode characters and every LFN entry contributes 13 characters,
181*f127cb91Sfrankho  * the maximum sequence number is 255/13 + 1 == 20.
182*f127cb91Sfrankho  */
1837c478bd9Sstevel@tonic-gate #define	PCDL_IS_LAST_LFN(x) ((x->pcdl_ordinal) & 0x40)
1847c478bd9Sstevel@tonic-gate #define	PCDL_LFN_BITS (PCA_RDONLY | PCA_HIDDEN | PCA_SYSTEM | PCA_LABEL)
185*f127cb91Sfrankho #define	PCDL_LFN_MASK (PCDL_LFN_BITS | PCA_DIR | PCA_ARCH)
186*f127cb91Sfrankho #define	PCDL_LFN_VALID_ORD(x)						\
187*f127cb91Sfrankho 	(((((struct pcdir_lfn *)(x))->pcdl_ordinal & ~0x40) > 0) &&	\
188*f127cb91Sfrankho 	((((struct pcdir_lfn *)(x))->pcdl_ordinal & ~0x40) <= 20))
189*f127cb91Sfrankho #define	PCDL_IS_LFN(x)							\
190*f127cb91Sfrankho 	(enable_long_filenames &&					\
191*f127cb91Sfrankho 	(((x)->pcd_attr & PCDL_LFN_MASK) == PCDL_LFN_BITS) &&		\
192*f127cb91Sfrankho 	PCDL_LFN_VALID_ORD((x)))
1937c478bd9Sstevel@tonic-gate 
1947c478bd9Sstevel@tonic-gate /*
1957c478bd9Sstevel@tonic-gate  * The first char of the file name has special meaning as follows:
1967c478bd9Sstevel@tonic-gate  */
1977c478bd9Sstevel@tonic-gate #define	PCD_UNUSED	((char)0x00)	/* entry has never been used */
1987c478bd9Sstevel@tonic-gate #define	PCD_ERASED	((char)0xE5)	/* entry was erased */
1997c478bd9Sstevel@tonic-gate 
2007c478bd9Sstevel@tonic-gate /*
2017c478bd9Sstevel@tonic-gate  * File attributes.
2027c478bd9Sstevel@tonic-gate  */
2037c478bd9Sstevel@tonic-gate #define	PCA_RDONLY	0x01	/* file is read only */
2047c478bd9Sstevel@tonic-gate #define	PCA_HIDDEN	0x02	/* file is hidden */
2057c478bd9Sstevel@tonic-gate #define	PCA_SYSTEM	0x04	/* system file */
2067c478bd9Sstevel@tonic-gate #define	PCA_LABEL	0x08	/* entry contains the volume label */
2077c478bd9Sstevel@tonic-gate #define	PCA_DIR		0x10	/* subdirectory */
2087c478bd9Sstevel@tonic-gate #define	PCA_ARCH	0x20	/* file has been modified since last backup */
2097c478bd9Sstevel@tonic-gate 
2107c478bd9Sstevel@tonic-gate /*
2117c478bd9Sstevel@tonic-gate  * Avoid hidden files unless the private variable is set.
2127c478bd9Sstevel@tonic-gate  * Always avoid the label.
2137c478bd9Sstevel@tonic-gate  */
2147c478bd9Sstevel@tonic-gate #define	PCA_IS_HIDDEN(fsp, attr) \
2157c478bd9Sstevel@tonic-gate 	((((attr) & PCA_LABEL) == PCA_LABEL) || \
2167c478bd9Sstevel@tonic-gate 	((((fsp)->pcfs_flags & PCFS_HIDDEN) == 0) && \
2177c478bd9Sstevel@tonic-gate 	    ((attr) & (PCA_HIDDEN | PCA_SYSTEM))))
2187c478bd9Sstevel@tonic-gate 
2197c478bd9Sstevel@tonic-gate #define	PC_NAME_IS_DOT(namep) \
2207c478bd9Sstevel@tonic-gate 	(((namep)[0] == '.') && ((namep)[1] == '\0'))
2217c478bd9Sstevel@tonic-gate #define	PC_NAME_IS_DOTDOT(namep) \
2227c478bd9Sstevel@tonic-gate 	(((namep)[0] == '.') && ((namep)[1] == '.') && ((namep)[2] == '\0'))
2237c478bd9Sstevel@tonic-gate #define	PC_SHORTNAME_IS_DOT(namep) \
2247c478bd9Sstevel@tonic-gate 	(((namep)[0] == '.') && ((namep)[1] == ' '))
2257c478bd9Sstevel@tonic-gate #define	PC_SHORTNAME_IS_DOTDOT(namep) \
2267c478bd9Sstevel@tonic-gate 	(((namep)[0] == '.') && ((namep)[1] == '.') && ((namep)[2] == ' '))
2277c478bd9Sstevel@tonic-gate /*
2287c478bd9Sstevel@tonic-gate  * slot structure is used by the directory search routine to return
2297c478bd9Sstevel@tonic-gate  * the results of the search.  If the search is successful sl_blkno and
2307c478bd9Sstevel@tonic-gate  * sl_offset reflect the disk address of the entry and sl_ep points to
2317c478bd9Sstevel@tonic-gate  * the actual entry data in buffer sl_bp. sl_flags is set to whether the
2327c478bd9Sstevel@tonic-gate  * entry is dot or dotdot. If the search is unsuccessful sl_blkno and
2337c478bd9Sstevel@tonic-gate  * sl_offset points to an empty directory slot if there are any. Otherwise
2347c478bd9Sstevel@tonic-gate  * it is set to -1.
2357c478bd9Sstevel@tonic-gate  */
2365b024a5bSbatschul struct pcslot {
2377c478bd9Sstevel@tonic-gate 	enum {SL_NONE, SL_FOUND, SL_EXTEND} sl_status;	/* slot status */
2387c478bd9Sstevel@tonic-gate 	daddr_t		sl_blkno;	/* disk block number which has entry */
2397c478bd9Sstevel@tonic-gate 	int		sl_offset;	/* offset of entry within block */
2407c478bd9Sstevel@tonic-gate 	struct buf	*sl_bp;		/* buffer containing entry data */
2417c478bd9Sstevel@tonic-gate 	struct pcdir	*sl_ep;		/* pointer to entry data */
2427c478bd9Sstevel@tonic-gate 	int		sl_flags;	/* flags (see below) */
2437c478bd9Sstevel@tonic-gate };
2447c478bd9Sstevel@tonic-gate #define	SL_DOT		1	/* entry point to self */
2457c478bd9Sstevel@tonic-gate #define	SL_DOTDOT	2	/* entry points to parent */
2467c478bd9Sstevel@tonic-gate 
2477c478bd9Sstevel@tonic-gate /*
2487c478bd9Sstevel@tonic-gate  * A pcfs directory entry. Directory entries are actually variable
2497c478bd9Sstevel@tonic-gate  * length, but this is the maximum size.
2507c478bd9Sstevel@tonic-gate  *
2517c478bd9Sstevel@tonic-gate  * This _must_ match a dirent64 structure in format.
2524a37d755Sksn  * d_name is 512 bytes long to accomodate 256 UTF-16 characters.
2537c478bd9Sstevel@tonic-gate  */
2547c478bd9Sstevel@tonic-gate struct pc_dirent {
2557c478bd9Sstevel@tonic-gate 	ino64_t		d_ino;		/* "inode number" of entry */
2567c478bd9Sstevel@tonic-gate 	off64_t		d_off;		/* offset of disk directory entry */
2577c478bd9Sstevel@tonic-gate 	unsigned short	d_reclen;	/* length of this record */
2584a37d755Sksn 	char		d_name[PCMAXNAM_UTF16];
2597c478bd9Sstevel@tonic-gate };
2607c478bd9Sstevel@tonic-gate 
261264a6e74Sfrankho /*
262264a6e74Sfrankho  * Check FAT 8.3 filename characters for validity.
263264a6e74Sfrankho  * Lacking a kernel iconv, codepage support for short filenames
264264a6e74Sfrankho  * is not provided.
265264a6e74Sfrankho  * Short names must be uppercase ASCII (no support for MSDOS
266264a6e74Sfrankho  * codepages right now, sorry) and may not contain any of
267264a6e74Sfrankho  * *+=|\[];:",<>.?/ which are explicitly forbidden by the
268264a6e74Sfrankho  * FAT specifications.
269264a6e74Sfrankho  */
2709bd42341Sfrankho #define	pc_invalchar(c)						\
2719bd42341Sfrankho 	(((c) >= 'a' && (c) <= 'z') ||				\
2729bd42341Sfrankho 	(c) == '"' || (c) == '*' || (c) == '+' || (c) == ',' || \
2739bd42341Sfrankho 	(c) == '.' || (c) == '/' || (c) == ':' || (c) == ';' || \
2749bd42341Sfrankho 	(c) == '<' || (c) == '=' || (c) == '>' || (c) == '?' || \
2759bd42341Sfrankho 	(c) == '[' || (c) == '|' || (c) == ']' || (c) == '\\')
2769bd42341Sfrankho 
2779bd42341Sfrankho #define	pc_validchar(c)	(((c) >= ' ' && !((c) & ~0177)) && !pc_invalchar(c))
278264a6e74Sfrankho 
279264a6e74Sfrankho 
2807c478bd9Sstevel@tonic-gate #ifdef _KERNEL
2817c478bd9Sstevel@tonic-gate 
2827c478bd9Sstevel@tonic-gate /*
283264a6e74Sfrankho  * macros for converting ASCII to/from upper or lower case.
2847c478bd9Sstevel@tonic-gate  * users may give and get names in lower case, but they are stored on the
285264a6e74Sfrankho  * disk in upper case to be PCDOS compatible.
286264a6e74Sfrankho  * These would better come from some shared source in <sys/...> but
287264a6e74Sfrankho  * there is no such place yet.
2887c478bd9Sstevel@tonic-gate  */
2897c478bd9Sstevel@tonic-gate #define	toupper(C)	(((C) >= 'a' && (C) <= 'z') ? (C) - 'a' + 'A' : (C))
2907c478bd9Sstevel@tonic-gate #define	tolower(C)	(((C) >= 'A' && (C) <= 'Z') ? (C) - 'A' + 'a' : (C))
2917c478bd9Sstevel@tonic-gate 
292264a6e74Sfrankho extern int pc_tvtopct(timestruc_t *, struct pctime *);	/* timeval to pctime */
293264a6e74Sfrankho extern void pc_pcttotv(struct pctime *, int64_t *);	/* pctime to timeval */
2947c478bd9Sstevel@tonic-gate extern int pc_valid_lfn_char(char);		/* valid long filename ch */
2957c478bd9Sstevel@tonic-gate 
2967c478bd9Sstevel@tonic-gate extern int pc_read_long_fn(struct vnode *, struct uio *,
2977c478bd9Sstevel@tonic-gate     struct pc_dirent *, struct pcdir **, offset_t *, struct buf **);
2987c478bd9Sstevel@tonic-gate extern int pc_read_short_fn(struct vnode *, struct uio *,
2997c478bd9Sstevel@tonic-gate     struct pc_dirent *, struct pcdir **, offset_t *, struct buf **);
3007c478bd9Sstevel@tonic-gate extern int pc_match_long_fn(struct pcnode *, char *, struct pcdir **,
3015b024a5bSbatschul     struct pcslot *, offset_t *);
3027c478bd9Sstevel@tonic-gate extern int pc_match_short_fn(struct pcnode *, char *,
3035b024a5bSbatschul     struct pcdir **, struct pcslot *, offset_t *);
3047c478bd9Sstevel@tonic-gate extern uchar_t pc_checksum_long_fn(char *, char *);
3057c478bd9Sstevel@tonic-gate extern void set_long_fn_chunk(struct pcdir_lfn *, char *, int);
3064a37d755Sksn extern int pc_valid_long_fn(char *, int);
3077c478bd9Sstevel@tonic-gate extern int pc_extract_long_fn(struct pcnode *, char *,
3087c478bd9Sstevel@tonic-gate     struct pcdir **, offset_t *offset, struct buf **);
3097c478bd9Sstevel@tonic-gate extern int pc_fname_ext_to_name(char *, char *, char *, int);
3107c478bd9Sstevel@tonic-gate 
3117c478bd9Sstevel@tonic-gate extern pc_cluster32_t pc_getstartcluster(struct pcfs *, struct pcdir *);
3127c478bd9Sstevel@tonic-gate extern void pc_setstartcluster(struct pcfs *, struct pcdir *, pc_cluster32_t);
3137c478bd9Sstevel@tonic-gate 
3147c478bd9Sstevel@tonic-gate /*
3157c478bd9Sstevel@tonic-gate  * Private tunables
3167c478bd9Sstevel@tonic-gate  */
3177c478bd9Sstevel@tonic-gate 
3187c478bd9Sstevel@tonic-gate /*
3197c478bd9Sstevel@tonic-gate  * Use long filenames (Windows 95). Disabling this causes pcfs
3207c478bd9Sstevel@tonic-gate  * to not recognize long filenames at all, which may cause it to
3217c478bd9Sstevel@tonic-gate  * break associations between the short and long names. This is likely
3227c478bd9Sstevel@tonic-gate  * to leave unused long filename entries  in directories (which may make
3237c478bd9Sstevel@tonic-gate  * apparently empty directories unremovable), and would require a fsck_pcfs
3247c478bd9Sstevel@tonic-gate  * to find and fix (or a Windows utility like Norton Disk Doctor or
3257c478bd9Sstevel@tonic-gate  * Microsoft ScanDisk).
3267c478bd9Sstevel@tonic-gate  */
3277c478bd9Sstevel@tonic-gate extern int enable_long_filenames;	/* default: on */
3287c478bd9Sstevel@tonic-gate 
3297c478bd9Sstevel@tonic-gate #endif
3307c478bd9Sstevel@tonic-gate 
3317c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
3327c478bd9Sstevel@tonic-gate }
3337c478bd9Sstevel@tonic-gate #endif
3347c478bd9Sstevel@tonic-gate 
3357c478bd9Sstevel@tonic-gate #endif	/* _SYS_FS_PC_DIR_H */
336