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