home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / unix / bsd / 9003 < prev    next >
Encoding:
Internet Message Format  |  1992-11-17  |  37.2 KB

  1. Xref: sparky comp.unix.bsd:9003 alt.sources:2539
  2. Path: sparky!uunet!charon.amdahl.com!amdahl!paulp
  3. From: paulp@uts.amdahl.com (Paul Popelka)
  4. Newsgroups: comp.unix.bsd,alt.sources
  5. Subject: [386bsd] mountable DOS filesystem code, Part 1/5
  6. Message-ID: <ba3w03h7bbR300@amdahl.uts.amdahl.com>
  7. Date: 17 Nov 92 17:25:12 GMT
  8. Followup-To: comp.unix.bsd
  9. Organization: Amdahl Corporation, Sunnyvale CA
  10. Lines: 1069
  11.  
  12.  
  13. # This is a shell archive.  Save it in a file, remove anything before
  14. # this line, and then unpack it by entering "sh file".  Note, it may
  15. # create directories; files and directories will be owned by you and
  16. # have default permissions.
  17. #
  18. # This archive contains:
  19. #
  20. #    /sys/pcfs
  21. #    /sys/pcfs/INSTALL
  22. #    /sys/pcfs/README
  23. #    /sys/pcfs/pcfs.8
  24. #    /sys/pcfs/pcfs.cdiff
  25. #    /sys/pcfs/fat.h
  26. #    /sys/pcfs/direntry.h
  27. #    /sys/pcfs/denode.h
  28. #    /sys/pcfs/bpb.h
  29. #    /sys/pcfs/bootsect.h
  30. #    /sys/pcfs/pcfsmount.h
  31. #    /usr/src/sbin/mount_pcfs
  32. #    /usr/src/sbin/mount_pcfs/mount_pcfs.c
  33. #    /usr/src/sbin/mount_pcfs/Makefile
  34. #
  35. echo c - /sys/pcfs
  36. mkdir /sys/pcfs > /dev/null 2>&1
  37. echo x - /sys/pcfs/INSTALL
  38. sed 's/^X//' >/sys/pcfs/INSTALL << 'END-of-/sys/pcfs/INSTALL'
  39. XThis note describes the installation of the pcfs filesystem into
  40. Xa 386bsd 0.1 system.
  41. X
  42. XFirst unshar the shar files.  They are made with absolute pathnames.
  43. XThey do not overwrite anything that is part of a standard system.
  44. XThey deposit files into the /usr/src/sbin/mount_pcfs and /sys/pcfs
  45. Xdirectories.
  46. X
  47. XIn the /sys/pcfs directory is a context diff file pcfs.cdiff.  It
  48. Xcontains context diffs to the following files:
  49. X    /sys/sys/vnode.h
  50. X    /sys/sys/mount.h
  51. X    /sys/sys/malloc.h
  52. X    /sys/conf/files
  53. X    /sys/kern/vfs_conf.c
  54. X
  55. XApply them with the following command:
  56. X    patch -p <pcfs.cdiff
  57. X
  58. XNext go to the /usr/src/sbin/mount_pcfs directory and build and install
  59. Xthe mount_pcfs command:
  60. X    cd /usr/src/sbin/mount_pcfs
  61. X    make install
  62. X
  63. XTo configure pcfs into your kernel goto to your configuration file
  64. Xin the /sys/i386/conf directory and add the following statement:
  65. X    options PCFS
  66. X
  67. XThen run the config command.
  68. X    config WHATEVER_YOU_CALL_IT
  69. X
  70. XThen goto the your kernel build directory in /sys/compile/WHATEVER_YOU_CALL_IT
  71. Xand do a "make depend" and then do a make.
  72. X    make depend
  73. X    make
  74. X
  75. XThen copy the kernel into the root directory and reboot your system.
  76. X    cp 386bsd /
  77. X
  78. XTo mount a pcfs filesystem:
  79. X    mount -t pcfs /dev/fd0a /mnt
  80. X
  81. XTo unmount a pcfs filesystem:
  82. X    umount /mnt
  83. END-of-/sys/pcfs/INSTALL
  84. echo x - /sys/pcfs/README
  85. sed 's/^X//' >/sys/pcfs/README << 'END-of-/sys/pcfs/README'
  86. XThis is version 0.0 of the code to allow mountable DOS filesystems
  87. Xunder 386bsd 0.1.  It is refered as pcfs from now on.  No, this is
  88. Xnot related to sun's pcfs, although they essentially do the same
  89. Xthing.
  90. X
  91. XThis package has been installed on a 386bsd 0.1 system that has NOT
  92. Xhad the patchkit installed.
  93. X
  94. XUnshar each of the following 4 shar files.  They create files in
  95. X/sys/pcfs and /usr/src/sbin/mount_pcfs.  They do not overwrite any
  96. Xexisting files.  Once you have them unshared read the /sys/pcfs/INSTALL
  97. Xfile to find out how to install it and mount pc filesystems.  Then look
  98. Xat the /sys/pcfs/pcfs.8 file for a list of the filesystem's quirks.
  99. X
  100. XIf you have problems send me some email and I'll see what I can do.
  101. XIf you add things please send me the mods and I will try to incorporate
  102. Xthem for the next release.
  103. X
  104. XHave fun,
  105. XPaul
  106. Xpaulp@sde.uts.amdahl.com
  107. END-of-/sys/pcfs/README
  108. echo x - /sys/pcfs/pcfs.8
  109. sed 's/^X//' >/sys/pcfs/pcfs.8 << 'END-of-/sys/pcfs/pcfs.8'
  110. XPCFS quirks file
  111. X
  112. XPCFS filesystems on floppy disks only are supported in this release.
  113. XAnd, only high density floppy disks are supported.  This is because
  114. Xthe floppy disk driver only supports high density disks.  PCFS
  115. Xfilesystems on hard disks are not supported yet.  This is because
  116. Xadditions to the disk drivers to make them better utilize dos
  117. Xpartition information are required.
  118. X
  119. XCreated files use only the user permissions bits.  And of these
  120. Xonly the write bit is meaningful.  DOS files always have the
  121. Xexecute and read bits on.
  122. X
  123. XPCFS does not turn on or off the DOS archive attribute bit.
  124. X
  125. XThe timestamp on dos files is updated when ever the file is modified.
  126. XThere is no inode time or create time stamp.
  127. X
  128. XThe timestamp placed on a dos file does not have corrections for
  129. Xdaylight savings time included.  It does have the correction for
  130. Xtimezone though.
  131. X
  132. XUnix times before 1980 will have their year set to 1980 in dos file
  133. Xtimestamps.  This is because dos's idea of time starts in 1980.
  134. X
  135. XPCFS filesystems do not support sparse files.  Any attempt to seek
  136. Xpast the end of a file results in the blocks being allocated and
  137. Xcleared.
  138. X
  139. XWhen read() is used to examine pcfs directories you will get dos
  140. Xdirectory contents.  Note that the root directory does not contain
  141. Xa "." or ".." entry.  Only the readdir() system call simulates these
  142. Xentries in the root directory of a dos filesystem.  readdir() returns
  143. Xdirectory entries as described in getdirentries(2).
  144. X
  145. XUsing read() and write() to manipulate the contents of dos directories
  146. Xis unwise on an active dos filesystem since a more up to date copy of
  147. Xtheir contents may reside in data structures in the kernel.  It is
  148. Xprobably safe to examine the filename field of dos directory entries.
  149. XThe filesystem code keeps this up to date at all times.
  150. X
  151. XThe cluster allocation algorithm is very simplistic.  It starts at
  152. Xcluster 2 and searchs until the last cluster of the filesystem and
  153. Xtakes the first available cluster.
  154. X
  155. XThe fsync() system call does not work on file descriptors open on
  156. Xdirectories.  This isn't a terrible thing since very few programs
  157. Xopen directories for writing.
  158. X
  159. XThe pcfs filesystem truncates filenames quietly.  If a filename has
  160. Xmore than 8 characters before the 1st period only the 1st eigth are
  161. Xused.  It only uses the 1st three characters after the period if
  162. Xthey exist.  The filenames "abc" and "abc." are the same to pcfs.
  163. XFilenames that begin with a "." are considered to be dos filenames
  164. Xwith an extension only and so are limited to 3 characters after the
  165. Xleading ".".  For example ".imlost" would be seen as ".iml" by pcfs.
  166. XPCFS folds filenames to upper case before writing them to disk or
  167. Xlooking up filenames, and folds them to lower case when reading them
  168. Xfrom disk for presentation to the user (for example by readdir()).
  169. X
  170. XDirectory entries for the DOS filesystem label are quietly ignored.
  171. X
  172. XThis is probably going to be a problem.  This implementation expects
  173. Xthe length of the root directory to be a multiple of the size of
  174. Xa cluster.  If this is not true a warning message is printed when
  175. Xthe filesystem is mounted.
  176. X
  177. XPCFS supports DOS filesystems with 12 bit or 16 bit FATs.  It supports
  178. Xboth regular and huge filesystems ( > 32 megabytes).  It supports
  179. Xboth version 3.3 and 5.0 BPB's.  Don't know about version 4.x and
  180. Xless than 3.3.  It has not been tested with 16 bit fats or huge
  181. Xfilesystems. This is because the hard disk drivers need to support
  182. Xdos partitions to do these things. 
  183. X
  184. XPCFS does not support symbolic links or hard links.  It does not
  185. Xsupport quotas.  How could it, pcfs files have no owners.  PCFS
  186. Xfiles have a simulated owner and group of 0.  PCFS does not support
  187. Xfile locking.  Though it may in the future.  PCFS filesystems are
  188. Xnot remote mountable, but they will be in the future.
  189. X
  190. XThis is the first release and as such has performance problems.
  191. XReading large files is very slow because the read ahead code in pcfs_read()
  192. Xdoesn't read far enough ahead for filesystems with small blocksizes.
  193. XPerformance and dos hard disk paritions are the next areas to be
  194. Xworked on.  Unless someone else does it.
  195. X
  196. X
  197. XOperational Details
  198. X-------------------
  199. X
  200. XTo mount a pcfs filesystem:
  201. X    mount -t pcfs /dev/fd0a /mnt
  202. X
  203. XTo unmount a pcfs filesystem:
  204. X    umount /mnt
  205. X
  206. XIf you want to be sure the fat is ALWAYS up to date, mount the
  207. Xfilesystem with the synchronous option:
  208. X    mount -t pcfs -o synchronous /dev/fd0a /mnt
  209. XThis reasults in very slow file write performance because it turns
  210. Xoff write behind of fst disk blocks.
  211. X
  212. X
  213. XConfiguring PCFS into your kernel
  214. X---------------------------------
  215. X
  216. XAdd the following statements to your configuration file in /sys/i386/conf/BLOT.
  217. XOr whatever you call your config file.
  218. X
  219. X    options PCFS
  220. X
  221. XThen do a "config BLOT" in /sys/i386/conf.
  222. X
  223. XThen do a "make depend" in /sys/compile/BLOT.
  224. X
  225. XAnd then do a "make" in /sys/compile/BLOT.
  226. X
  227. XCopy the kernel to / and boot your system.
  228. X
  229. XPCFS consumes approximately 24000 bytes of kernel code space and
  230. Xapproximately 4000 bytes of bss.
  231. X
  232. XPCFS has some debug printf's that can be turned on by defining PCFSDEBUG.
  233. XIt produces lots of output.  If you use it be sure to kill syslogd before
  234. Xusing a PCFS filesystem with debug.
  235. END-of-/sys/pcfs/pcfs.8
  236. echo x - /sys/pcfs/pcfs.cdiff
  237. sed 's/^X//' >/sys/pcfs/pcfs.cdiff << 'END-of-/sys/pcfs/pcfs.cdiff'
  238. X*** /sys/sys/vnode.h    Tue Dec 24 14:24:19 1991
  239. X--- /sys/sys/NEWvnode.h    Thu Oct 22 21:44:42 1992
  240. X***************
  241. X*** 53,59 ****
  242. X   * These are for the benefit of external programs only (e.g., pstat)
  243. X   * and should NEVER be inspected inside the kernel.
  244. X   */
  245. X! enum vtagtype    { VT_NON, VT_UFS, VT_NFS, VT_MFS };
  246. X  
  247. X  /*
  248. X   * This defines the maximum size of the private data area
  249. X--- 53,59 ----
  250. X   * These are for the benefit of external programs only (e.g., pstat)
  251. X   * and should NEVER be inspected inside the kernel.
  252. X   */
  253. X! enum vtagtype    { VT_NON, VT_UFS, VT_NFS, VT_MFS, VT_PCFS };
  254. X  
  255. X  /*
  256. X   * This defines the maximum size of the private data area
  257. X*** /sys/sys/mount.h    Sun May 24 18:36:01 1992
  258. X--- /sys/sys/NEWmount.h    Thu Oct 22 21:45:47 1992
  259. X***************
  260. X*** 76,82 ****
  261. X  #define    MOUNT_UFS    1        /* UNIX "Fast" Filesystem */
  262. X  #define    MOUNT_NFS    2        /* Network Filesystem */
  263. X  #define    MOUNT_MFS    3        /* Memory Filesystem */
  264. X! #define    MOUNT_MSDOS    4        /* MSDOS Filesystem */
  265. X  #define MOUNT_ISOFS    5        /* iso9660 cdrom */
  266. X  #define    MOUNT_MAXTYPE    5
  267. X  
  268. X--- 76,82 ----
  269. X  #define    MOUNT_UFS    1        /* UNIX "Fast" Filesystem */
  270. X  #define    MOUNT_NFS    2        /* Network Filesystem */
  271. X  #define    MOUNT_MFS    3        /* Memory Filesystem */
  272. X! #define    MOUNT_PCFS    4        /* MSDOS Filesystem */
  273. X  #define MOUNT_ISOFS    5        /* iso9660 cdrom */
  274. X  #define    MOUNT_MAXTYPE    5
  275. X  
  276. X***************
  277. X*** 260,265 ****
  278. X--- 260,276 ----
  279. X  #define    NFSMNT_COMPRESS    0x0800    /* Compress nfs rpc xdr */
  280. X  #define    NFSMNT_LOCKBITS    (NFSMNT_SCKLOCK | NFSMNT_WANTSCK)
  281. X  #endif NFS
  282. X+ 
  283. X+ #ifdef PCFS
  284. X+ /*
  285. X+  *  Arguments to mount MSDOS filesystems.
  286. X+  */
  287. X+ struct pcfs_args {
  288. X+     char *fspec;        /* blocks special holding the fs to mount */
  289. X+     int exflags;        /* mount flags                */
  290. X+     uid_t exroot;        /* mapping for root uid            */
  291. X+ };
  292. X+ #endif /* PCFS */
  293. X  
  294. X  #ifdef KERNEL
  295. X  /*
  296. X*** /sys/sys/malloc.h    Tue Dec 24 14:24:17 1991
  297. X--- /sys/sys/NEWmalloc.h    Thu Oct 22 21:46:27 1992
  298. X***************
  299. X*** 91,97 ****
  300. X  #define    M_PROC        41    /* Proc structures */
  301. X  #define    M_SUBPROC    42    /* Proc sub-structures */
  302. X  #define    M_TEMP        49    /* misc temporary data buffers */
  303. X! #define    M_LAST        50
  304. X  
  305. X  #define INITKMEMNAMES { \
  306. X      "free",        /* 0 M_FREE */ \
  307. X--- 91,99 ----
  308. X  #define    M_PROC        41    /* Proc structures */
  309. X  #define    M_SUBPROC    42    /* Proc sub-structures */
  310. X  #define    M_TEMP        49    /* misc temporary data buffers */
  311. X! #define    M_PCFSMNT    50    /* PCFS mount structure */
  312. X! #define    M_PCFSFAT    51    /* PCFS fat table */
  313. X! #define    M_LAST        52
  314. X  
  315. X  #define INITKMEMNAMES { \
  316. X      "free",        /* 0 M_FREE */ \
  317. X***************
  318. X*** 139,144 ****
  319. X--- 141,148 ----
  320. X      "subproc",    /* 42 M_PROC */ \
  321. X      0, 0, 0, 0, 0, 0, \
  322. X      "temp",        /* 49 M_TEMP */ \
  323. X+     "PCFS mount",    /* 50 M_PCFSMNT */ \
  324. X+     "PCFS fat",    /* 51 M_PCFSFAT */ \
  325. X  }
  326. X  
  327. X  struct kmemstats {
  328. X*** /sys/conf/files    Mon May 25 12:26:27 1992
  329. X--- /sys/conf/NEWfiles    Thu Oct 22 21:48:05 1992
  330. X***************
  331. X*** 214,216 ****
  332. X--- 214,222 ----
  333. X  ddb/db_variables.c    optional ddb
  334. X  ddb/db_watch.c        optional ddb
  335. X  ddb/db_write_cmd.c    optional ddb
  336. X+ pcfs/pcfs_fat.c        optional pcfs
  337. X+ pcfs/pcfs_conv.c    optional pcfs
  338. X+ pcfs/pcfs_denode.c    optional pcfs
  339. X+ pcfs/pcfs_lookup.c    optional pcfs
  340. X+ pcfs/pcfs_vfsops.c    optional pcfs
  341. X+ pcfs/pcfs_vnops.c    optional pcfs
  342. X*** /sys/kern/vfs_conf.c    Mon May 25 02:43:56 1992
  343. X--- /sys/kern/NEWvfs_conf.c    Thu Oct 22 21:48:58 1992
  344. X***************
  345. X*** 63,68 ****
  346. X--- 63,72 ----
  347. X  extern    struct vfsops mfs_vfsops;
  348. X  #endif
  349. X  
  350. X+ #ifdef PCFS
  351. X+ extern    struct vfsops pcfs_vfsops;
  352. X+ #endif
  353. X+ 
  354. X  #ifdef ISOFS
  355. X  extern    struct vfsops isofs_vfsops;
  356. X  #endif
  357. X***************
  358. X*** 80,86 ****
  359. X  #else
  360. X      (struct vfsops *)0,
  361. X  #endif
  362. X!     (struct vfsops *)0,    /* 4 = MOUNT_MSDOS */
  363. X  #ifdef ISOFS
  364. X      &isofs_vfsops,        /* 5 = MOUNT_ISOFS */
  365. X  #else
  366. X--- 84,94 ----
  367. X  #else
  368. X      (struct vfsops *)0,
  369. X  #endif
  370. X! #ifdef PCFS
  371. X!     &pcfs_vfsops,        /* 4 = MOUNT_PCFS */
  372. X! #else
  373. X!     (struct vfsops *)0,
  374. X! #endif
  375. X  #ifdef ISOFS
  376. X      &isofs_vfsops,        /* 5 = MOUNT_ISOFS */
  377. X  #else
  378. END-of-/sys/pcfs/pcfs.cdiff
  379. echo x - /sys/pcfs/fat.h
  380. sed 's/^X//' >/sys/pcfs/fat.h << 'END-of-/sys/pcfs/fat.h'
  381. X/*
  382. X *  Some useful cluster numbers.
  383. X */
  384. X#define    PCFSROOT    0    /* cluster 0 means the root dir        */
  385. X#define    CLUST_FREE    0    /* cluster 0 also means a free cluster    */
  386. X#define    PCFSFREE    CLUST_FREE
  387. X#define    CLUST_FIRST    2    /* first legal cluster number        */
  388. X#define    CLUST_RSRVS    0xfff0    /* start of reserved cluster range    */
  389. X#define    CLUST_RSRVE    0xfff6    /* end of reserved cluster range    */
  390. X#define    CLUST_BAD    0xfff7    /* a cluster with a defect        */
  391. X#define    CLUST_EOFS    0xfff8    /* start of eof cluster range        */
  392. X#define    CLUST_EOFE    0xffff    /* end of eof cluster range        */
  393. X
  394. X#define    FAT12_MASK    0x0fff    /* mask for 12 bit cluster numbers    */
  395. X#define    FAT16_MASK    0xffff    /* mask for 16 bit cluster numbers    */
  396. X
  397. X/*
  398. X *  Return true if filesystem uses 12 bit fats.
  399. X *  Microsoft Programmer's Reference says if the
  400. X *  maximum cluster number in a filesystem is greater
  401. X *  than 4086 then we've got a 16 bit fat filesystem.
  402. X */
  403. X#define    FAT12(pmp)    (pmp->pm_maxcluster <= 4086)
  404. X#define    FAT16(pmp)    (pmp->pm_maxcluster >  4086)
  405. X
  406. X#define    PCFSEOF(cn)    (((cn) & 0xfff8) == 0xfff8)
  407. X
  408. X/*
  409. X *  These are the values for the function argument to
  410. X *  the function fatentry().
  411. X */
  412. X#define    FAT_GET        0x0001        /* get a fat entry        */
  413. X#define    FAT_SET        0x0002        /* set a fat entry        */
  414. X#define    FAT_GET_AND_SET    (FAT_GET | FAT_SET)
  415. X
  416. X/*
  417. X *  This union is useful for manipulating entries
  418. X *  in 12 bit fats.
  419. X */
  420. Xunion fattwiddle {
  421. X    unsigned short word;
  422. X    unsigned char  byte[2];
  423. X};
  424. X
  425. X#if defined(KERNEL)
  426. Xint pcbmap __P((struct denode *dep,
  427. X        unsigned long findcn,
  428. X        daddr_t *bnp,
  429. X        unsigned long *cnp));
  430. Xint clusterfree __P((struct pcfsmount *pmp, unsigned long cn));
  431. Xint clusteralloc __P((struct pcfsmount *pmp, unsigned long *retcluster,
  432. X    unsigned long fillwith));
  433. Xint fatentry __P((int function, struct pcfsmount *pmp,
  434. X    unsigned long cluster,
  435. X    unsigned long *oldcontents,
  436. X    unsigned long newcontents));
  437. Xint freeclusterchain __P((struct pcfsmount *pmp, unsigned long startchain));
  438. X#endif /* defined(KERNEL) */
  439. END-of-/sys/pcfs/fat.h
  440. echo x - /sys/pcfs/direntry.h
  441. sed 's/^X//' >/sys/pcfs/direntry.h << 'END-of-/sys/pcfs/direntry.h'
  442. X/*
  443. X *  Structure of a dos directory entry.
  444. X */
  445. Xstruct direntry {
  446. X    unsigned char deName[8];    /* filename, blank filled    */
  447. X#define    SLOT_EMPTY    0x00        /* slot has never been used    */
  448. X#define    SLOT_E5        0x05        /* the real value is 0xe5    */
  449. X#define    SLOT_DELETED    0xe5        /* file in this slot deleted    */
  450. X    unsigned char deExtension[3];    /* extension, blank filled    */
  451. X    unsigned char deAttributes;    /* file attributes        */
  452. X#define    ATTR_NORMAL    0x00        /* normal file            */
  453. X#define    ATTR_READONLY    0x01        /* file is readonly        */
  454. X#define    ATTR_HIDDEN    0x02        /* file is hidden        */
  455. X#define    ATTR_SYSTEM    0x04        /* file is a system file    */
  456. X#define    ATTR_VOLUME    0x08        /* entry is a volume label    */
  457. X#define    ATTR_DIRECTORY    0x10        /* entry is a directory name    */
  458. X#define    ATTR_ARCHIVE    0x20        /* file is new or modified    */
  459. X    char deReserved[10];        /* reserved            */
  460. X    unsigned short deTime;        /* create/last update time    */
  461. X    unsigned short deDate;        /* create/last update date    */
  462. X    unsigned short deStartCluster;    /* starting cluster of file    */
  463. X    unsigned long deFileSize;    /* size of file in bytes    */
  464. X};
  465. X
  466. X/*
  467. X *  This is the format of the contents of the deTime
  468. X *  field in the direntry structure.
  469. X */
  470. Xstruct DOStime {
  471. X    unsigned short
  472. X            dt_2seconds:5,    /* seconds divided by 2        */
  473. X            dt_minutes:6,    /* minutes            */
  474. X            dt_hours:5;    /* hours            */
  475. X};
  476. X
  477. X/*
  478. X *  This is the format of the contents of the deDate
  479. X *  field in the direntry structure.
  480. X */
  481. Xstruct DOSdate {
  482. X    unsigned short
  483. X            dd_day:5,    /* day of month            */
  484. X            dd_month:4,    /* month            */
  485. X            dd_year:7;    /* years since 1980        */
  486. X};
  487. X
  488. Xunion dostime {
  489. X    struct DOStime dts;
  490. X    unsigned short dti;
  491. X};
  492. X
  493. Xunion dosdate {
  494. X    struct DOSdate dds;
  495. X    unsigned short ddi;
  496. X};
  497. X
  498. X/*
  499. X *  The following defines are used to rename fields in
  500. X *  the ufs_specific structure in the nameidata structure
  501. X *  in namei.h
  502. X */
  503. X#define    ni_pcfs        ni_ufs
  504. X#define    pcfs_count    ufs_count
  505. X#define    pcfs_offset    ufs_offset
  506. X#define    pcfs_cluster    ufs_ino
  507. X
  508. X#if defined(KERNEL)
  509. Xvoid unix2dostime __P((struct timeval *tvp,
  510. X            union dosdate *ddp,
  511. X            union dostime *dtp));
  512. Xvoid dos2unixtime __P((union dosdate *ddp,
  513. X            union dostime *dtp,
  514. X            struct timeval *tvp));
  515. Xint  dos2unixfn __P((unsigned char dn[11], unsigned char *un));
  516. Xvoid unix2dosfn __P((unsigned char *un, unsigned char dn[11], int unlen));
  517. X#endif /* defined(KERNEL) */
  518. END-of-/sys/pcfs/direntry.h
  519. echo x - /sys/pcfs/denode.h
  520. sed 's/^X//' >/sys/pcfs/denode.h << 'END-of-/sys/pcfs/denode.h'
  521. X/*
  522. X *  Written by Paul Popelka (paulp@uts.amdahl.com)
  523. X *
  524. X *  You can do anything you want with this software,
  525. X *    just don't say you wrote it,
  526. X *    and don't remove this notice.
  527. X *
  528. X *  This software is provided "as is".
  529. X *
  530. X *  The author supplies this software to be publicly
  531. X *  redistributed on the understanding that the author
  532. X *  is not responsible for the correct functioning of
  533. X *  this software in any circumstances and is not liable
  534. X *  for any damages caused by this software.
  535. X *
  536. X *  October 1992
  537. X */
  538. X/*
  539. X *  This is the pc filesystem specific portion of the
  540. X *  vnode structure.
  541. X *  To describe a file uniquely the de_dirclust, de_diroffset,
  542. X *  and de_de.deStartCluster fields are used.  de_dirclust
  543. X *  contains the cluster number of the directory cluster containing
  544. X *  the entry for a file or directory.  de_diroffset is the
  545. X *  index into the cluster for the entry describing a file
  546. X *  or directory.  de_de.deStartCluster is the number of the
  547. X *  first cluster of the file or directory.  Now to describe the
  548. X *  quirks of the pc filesystem.
  549. X *  - Clusters 0 and 1 are reserved.
  550. X *  - The first allocatable cluster is 2.
  551. X *  - The root directory is of fixed size and all blocks that
  552. X *    make it up are contiguous.
  553. X *  - Cluster 0 refers to the root directory when it is found
  554. X *    in the startcluster field of a directory entry that points
  555. X *    to another directory.
  556. X *  - Cluster 0 implies a 0 length file when found in the start
  557. X *    cluster field of a directory entry that points to a file.
  558. X *  - You can't use the cluster number 0 to derive
  559. X *    the address of the root directory.
  560. X *  - Multiple directory entries can point to a directory.
  561. X *    The entry in the parent directory points to a child
  562. X *    directory.  Any directories in the child directory contain
  563. X *    a ".." entry that points back to the child.  The child
  564. X *    directory itself contains a "." entry that points to
  565. X *    itself.
  566. X *  - The root directory does not contain a "." or ".." entry.
  567. X *  - Directory entries for directories are never changed once
  568. X *    they are created (except when removed).  The size stays
  569. X *    0, and the last modification time is never changed.  This
  570. X *    is because so many directory entries can point to the physical
  571. X *    clusters that make up a directory.  It would lead to an update
  572. X *    nightmare.
  573. X *  - The length field in a directory entry pointing to a directory
  574. X *    contains 0 (always).  The only way to find the end of a directory
  575. X *    is to follow the cluster chain until the "last cluster"
  576. X *    marker is found.
  577. X *  My extensions to make this house of cards work.  These apply
  578. X *  only to the in memory copy of the directory entry.
  579. X *  - A reference count for each denode will be kept since dos doesn't
  580. X *    keep such things.
  581. X */
  582. X
  583. X/*
  584. X *  The fat cache structure.
  585. X *  fc_fsrcn is the filesystem relative cluster number
  586. X *  that corresponds to the file relative cluster number
  587. X *  in this structure (fc_frcn).
  588. X */
  589. Xstruct fatcache {
  590. X    unsigned short fc_frcn;        /* file relative cluster number    */
  591. X    unsigned short fc_fsrcn;    /* filesystem relative cluster number */
  592. X};
  593. X
  594. X/*
  595. X *  The fat entry cache as it stands helps make extending
  596. X *  files a "quick" operation by avoiding having to scan
  597. X *  the fat to discover the last cluster of the file.
  598. X *  The cache also helps sequential reads by remembering
  599. X *  the last cluster read from the file.  This also prevents
  600. X *  us from having to rescan the fat to find the next cluster
  601. X *  to read.  This cache is probably pretty worthless if a
  602. X *  file is opened by multiple processes.
  603. X */
  604. X#define    FC_SIZE        2    /* number of entries in the cache    */
  605. X#define    FC_LASTMAP    0    /* entry the last call to pcbmap() resolved to */
  606. X#define    FC_LASTFC    1    /* entry for the last cluster in the file */
  607. X
  608. X#define    FCE_EMPTY    0xffff    /* doesn't represent an actual cluster # */
  609. X
  610. X/*
  611. X *  Set a slot in the fat cache.
  612. X */
  613. X#define    fc_setcache(dep, slot, frcn, fsrcn) \
  614. X    (dep)->de_fc[slot].fc_frcn = frcn; \
  615. X    (dep)->de_fc[slot].fc_fsrcn = fsrcn;
  616. X
  617. X/*
  618. X *  This is the in memory variant of a dos directory
  619. X *  entry.  It is usually contained within a vnode.
  620. X */
  621. Xstruct denode {
  622. X    struct denode *de_chain[2];    /* hash chain ptrs        */
  623. X    struct vnode *de_vnode;        /* addr of vnode we are part of    */
  624. X    struct vnode *de_devvp;        /* vnode of blk dev we live on    */
  625. X    u_long de_flag;            /* flag bits            */
  626. X    dev_t de_dev;            /* device where direntry lives    */
  627. X    u_long de_dirclust;        /* cluster of the directory file
  628. X                     *  containing this entry    */
  629. X    u_long de_diroffset;        /* ordinal of this entry in the
  630. X                     *  directory            */
  631. X    long de_refcnt;            /* reference count        */
  632. X    struct pcfsmount *de_pmp;    /* addr of our mount struct    */
  633. X    struct lockf *de_lockf;        /* byte level lock list        */
  634. X    long de_spare0;            /* current lock holder        */
  635. X    long de_spare1;            /* lock wanter            */
  636. X    struct direntry de_de;        /* the actual directory entry    */
  637. X    struct fatcache de_fc[FC_SIZE];    /* fat cache            */
  638. X};
  639. X
  640. X/*
  641. X *  Values for the de_flag field of the denode.
  642. X */
  643. X#define    DELOCKED    0x0001        /* directory entry is locked    */
  644. X#define    DEWANT        0x0002        /* someone wants this de    */
  645. X#define    DERENAME    0x0004        /* de is being renamed        */
  646. X#define    DEUPD        0x0008        /* file has been modified    */
  647. X#define    DESHLOCK    0x0010        /* file has shared lock        */
  648. X#define    DEEXLOCK    0x0020        /* file has exclusive lock    */
  649. X#define    DELWAIT        0x0040        /* someone waiting on file lock    */
  650. X#define    DEMOD        0x0080        /* denode wants to be written back
  651. X                     *  to disk            */
  652. X
  653. X/*
  654. X *  Shorthand macros used to reference fields in the direntry
  655. X *  contained in the denode structure.
  656. X */
  657. X#define    de_Name        de_de.deName
  658. X#define    de_Extension    de_de.deExtension
  659. X#define    de_Attributes    de_de.deAttributes
  660. X#define    de_Reserved    de_de.deReserved
  661. X#define    de_Time        de_de.deTime
  662. X#define    de_Date        de_de.deDate
  663. X#define    de_StartCluster    de_de.deStartCluster
  664. X#define    de_FileSize    de_de.deFileSize
  665. X#define    de_forw        de_chain[0]
  666. X#define    de_back        de_chain[1]
  667. X
  668. X#if defined(KERNEL)
  669. X
  670. X#define    VTODE(vp)    ((struct denode *)(vp)->v_data)
  671. X#define    DETOV(de)    ((de)->de_vnode)
  672. X
  673. X#define    DELOCK(de)    delock(de)
  674. X#define    DEUNLOCK(de)    deunlock(de)
  675. X
  676. X#define    DEUPDAT(dep, t, waitfor) \
  677. X    if (dep->de_flag & DEUPD) \
  678. X        (void) deupdat(dep, t, waitfor);
  679. X
  680. X#define    DETIMES(dep, t) \
  681. X    if (dep->de_flag & DEUPD) { \
  682. X        (dep)->de_flag |= DEMOD; \
  683. X        unix2dostime(t, (union dosdate *)&dep->de_Date, \
  684. X            (union dostime *)&dep->de_Time); \
  685. X        (dep)->de_flag &= ~DEUPD; \
  686. X    }
  687. X
  688. X/*
  689. X * Prototypes for PCFS vnode operations
  690. X */
  691. Xint pcfs_lookup __P((struct vnode *vp, struct nameidata *ndp, struct proc *p));
  692. Xint pcfs_create __P((struct nameidata *ndp, struct vattr *vap, struct proc *p));
  693. Xint pcfs_mknod __P((struct nameidata *ndp, struct vattr *vap, struct ucred *cred,
  694. X    struct proc *p));
  695. Xint pcfs_open __P((struct vnode *vp, int mode, struct ucred *cred,
  696. X    struct proc *p));
  697. Xint pcfs_close __P((struct vnode *vp, int fflag, struct ucred *cred,
  698. X    struct proc *p));
  699. Xint pcfs_access __P((struct vnode *vp, int mode, struct ucred *cred,
  700. X    struct proc *p));
  701. Xint pcfs_getattr __P((struct vnode *vp, struct vattr *vap, struct ucred *cred,
  702. X    struct proc *p));
  703. Xint pcfs_setattr __P((struct vnode *vp, struct vattr *vap, struct ucred *cred,
  704. X    struct proc *p));
  705. Xint pcfs_read __P((struct vnode *vp, struct uio *uio, int ioflag,
  706. X    struct ucred *cred));
  707. Xint pcfs_write __P((struct vnode *vp, struct uio *uio, int ioflag,
  708. X    struct ucred *cred));
  709. Xint pcfs_ioctl __P((struct vnode *vp, int command, caddr_t data, int fflag,
  710. X    struct ucred *cred, struct proc *p));
  711. Xint pcfs_select __P((struct vnode *vp, int which, int fflags, struct ucred *cred,
  712. X    struct proc *p));
  713. Xint pcfs_mmap __P((struct vnode *vp, int fflags, struct ucred *cred,
  714. X    struct proc *p));
  715. Xint pcfs_fsync __P((struct vnode *vp, int fflags, struct ucred *cred,
  716. X    int waitfor, struct proc *p));
  717. Xint pcfs_seek __P((struct vnode *vp, off_t oldoff, off_t newoff,
  718. X    struct ucred *cred));
  719. Xint pcfs_remove __P((struct nameidata *ndp, struct proc *p));
  720. Xint pcfs_link __P((struct vnode *vp, struct nameidata *ndp, struct proc *p));
  721. Xint pcfs_rename __P((struct nameidata *fndp, struct nameidata *tdnp,
  722. X    struct proc *p));
  723. Xint pcfs_mkdir __P((struct nameidata *ndp, struct vattr *vap, struct proc *p));
  724. Xint pcfs_rmdir __P((struct nameidata *ndp, struct proc *p));
  725. Xint pcfs_symlink __P((struct nameidata *ndp, struct vattr *vap, char *target,
  726. X    struct proc *p));
  727. Xint pcfs_readdir __P((struct vnode *vp, struct uio *uio, struct ucred *cred,
  728. X    int *eofflagp));
  729. Xint pcfs_readlink __P((struct vnode *vp, struct uio *uio, struct ucred *cred));
  730. Xint pcfs_abortop __P((struct nameidata *ndp));
  731. Xint pcfs_inactive __P((struct vnode *vp, struct proc *p));
  732. Xint pcfs_reclaim __P((struct vnode *vp));
  733. Xint pcfs_lock __P((struct vnode *vp));
  734. Xint pcfs_unlock __P((struct vnode *vp));
  735. Xint pcfs_bmap __P((struct vnode *vp, daddr_t bn, struct vnode **vpp,
  736. X    daddr_t *bnp));
  737. Xint pcfs_strategy __P((struct buf *bp));
  738. Xint pcfs_print __P((struct vnode *vp));
  739. Xint pcfs_islocked __P((struct vnode *vp));
  740. Xint pcfs_advlock __P((struct vnode *vp, caddr_t id, int op, struct flock *fl,
  741. X    int flags));
  742. X
  743. X/*
  744. X *  Internal service routine prototypes.
  745. X */
  746. Xint deget __P((struct pcfsmount *pmp, int isadir, unsigned long dirclust,
  747. X    unsigned long diroffset, unsigned long startclust,
  748. X    struct buf *bp, struct denode **depp));
  749. X#endif /* defined(KERNEL) */
  750. END-of-/sys/pcfs/denode.h
  751. echo x - /sys/pcfs/bpb.h
  752. sed 's/^X//' >/sys/pcfs/bpb.h << 'END-of-/sys/pcfs/bpb.h'
  753. X/*
  754. X *  BIOS Parameter Block (BPB) for DOS 3.3
  755. X */
  756. Xstruct bpb33 {
  757. X    u_short bpbBytesPerSec;    /* bytes per sector            */
  758. X    u_char bpbSecPerClust;    /* sectors per cluster            */
  759. X    u_short bpbResSectors;    /* number of reserved sectors        */
  760. X    u_char bpbFATs;        /* number of FATs            */
  761. X    u_short bpbRootDirEnts;    /* number of root directory entries    */
  762. X    u_short bpbSectors;    /* total number of sectors        */
  763. X    u_char bpbMedia;    /* media descriptor            */
  764. X    u_short bpbFATsecs;    /* number of sectors per FAT        */
  765. X    u_short bpbSecPerTrack;    /* sectors per track            */
  766. X    u_short bpbHeads;    /* number of heads            */
  767. X    u_short bpbHiddenSecs;    /* number of hidden sectors        */
  768. X};
  769. X
  770. X/*
  771. X *  BPB for DOS 5.0
  772. X *  The difference is bpbHiddenSecs is a short for DOS 3.3,
  773. X *  and bpbHugeSectors is not in the 3.3 bpb.
  774. X */
  775. Xstruct bpb50 {
  776. X    u_short bpbBytesPerSec;    /* bytes per sector            */
  777. X    u_char bpbSecPerClust;    /* sectors per cluster            */
  778. X    u_short bpbResSectors;    /* number of reserved sectors        */
  779. X    u_char bpbFATs;        /* number of FATs            */
  780. X    u_short bpbRootDirEnts;    /* number of root directory entries    */
  781. X    u_short bpbSectors;    /* total number of sectors        */
  782. X    u_char bpbMedia;    /* media descriptor            */
  783. X    u_short bpbFATsecs;    /* number of sectors per FAT        */
  784. X    u_short bpbSecPerTrack;    /* sectors per track            */
  785. X    u_short bpbHeads;    /* number of heads            */
  786. X    u_long bpbHiddenSecs;    /* number of hidden sectors        */
  787. X    u_long bpbHugeSectors;    /* number of sectrs if bpbSectors == 0    */
  788. X};
  789. X
  790. X/*
  791. X *  The following structures represent how the bpb's look
  792. X *  on disk.  shorts and longs are just character arrays
  793. X *  of the appropriate length.  This is because the compiler
  794. X *  forces shorts and longs to align on word or halfword
  795. X *  boundaries.
  796. X */
  797. X#define    getushort(x)    *((unsigned short *)(x))
  798. X#define    getulong(x)    *((unsigned long *)(x))
  799. X
  800. X/*
  801. X *  BIOS Parameter Block (BPB) for DOS 3.3
  802. X */
  803. Xstruct byte_bpb33 {
  804. X    char bpbBytesPerSec[2];    /* bytes per sector            */
  805. X    char bpbSecPerClust;    /* sectors per cluster            */
  806. X    char bpbResSectors[2];    /* number of reserved sectors        */
  807. X    char bpbFATs;        /* number of FATs            */
  808. X    char bpbRootDirEnts[2];    /* number of root directory entries    */
  809. X    char bpbSectors[2];    /* total number of sectors        */
  810. X    char bpbMedia;        /* media descriptor            */
  811. X    char bpbFATsecs[2];    /* number of sectors per FAT        */
  812. X    char bpbSecPerTrack[2];    /* sectors per track            */
  813. X    char bpbHeads[2];    /* number of heads            */
  814. X    char bpbHiddenSecs[2];    /* number of hidden sectors        */
  815. X};
  816. X
  817. X/*
  818. X *  BPB for DOS 5.0
  819. X *  The difference is bpbHiddenSecs is a short for DOS 3.3,
  820. X *  and bpbHugeSectors is not in the 3.3 bpb.
  821. X */
  822. Xstruct byte_bpb50 {
  823. X    char bpbBytesPerSec[2];    /* bytes per sector            */
  824. X    char bpbSecPerClust;    /* sectors per cluster            */
  825. X    char bpbResSectors[2];    /* number of reserved sectors        */
  826. X    char bpbFATs;        /* number of FATs            */
  827. X    char bpbRootDirEnts[2];    /* number of root directory entries    */
  828. X    char bpbSectors[2];    /* total number of sectors        */
  829. X    char bpbMedia;        /* media descriptor            */
  830. X    char bpbFATsecs[2];    /* number of sectors per FAT        */
  831. X    char bpbSecPerTrack[2];    /* sectors per track            */
  832. X    char bpbHeads[2];    /* number of heads            */
  833. X    char bpbHiddenSecs[4];    /* number of hidden sectors        */
  834. X    char bpbHugeSectors[4];    /* number of sectrs if bpbSectors == 0    */
  835. X};
  836. END-of-/sys/pcfs/bpb.h
  837. echo x - /sys/pcfs/bootsect.h
  838. sed 's/^X//' >/sys/pcfs/bootsect.h << 'END-of-/sys/pcfs/bootsect.h'
  839. X/*
  840. X *  Format of a boot sector.  This is the first sector
  841. X *  on a DOS floppy disk or the fist sector of a partition
  842. X *  on a hard disk.  But, it is not the first sector of
  843. X *  a partitioned hard disk.
  844. X */
  845. Xstruct bootsector33 {
  846. X    char bsJump[3];        /* jump instruction E9xxxx or EBxx90    */
  847. X    char bsOemName[8];    /* OEM name and version            */
  848. X    char bsBPB[19];        /* BIOS parameter block            */
  849. X    char bsDriveNumber;    /* drive number (0x80)            */
  850. X    char bsBootCode[474];    /* pad so structure is 512 bytes long    */
  851. X    unsigned short bsBootSectSig;
  852. X#define    BOOTSIG    0xaa55
  853. X};
  854. X
  855. Xstruct bootsector50 {
  856. X    char bsJump[3];        /* jump instruction E9xxxx or EBxx90    */
  857. X    char bsOemName[8];    /* OEM name and version            */
  858. X    char bsBPB[25];        /* BIOS parameter block            */
  859. X    char bsDriveNumber;    /* drive number (0x80)            */
  860. X    char bsReserved1;    /* reserved                */
  861. X    char bsBootSignature;    /* extended boot signature (0x29)    */
  862. X#define    EXBOOTSIG    0x29
  863. X    char bsVolumeID[4];    /* volume ID number            */
  864. X    char bsVolumeLabel[11];    /* volume label                */
  865. X    char bsFileSysType[8];    /* file system type (FAT12 or FAT16)    */
  866. X    char bsBootCode[448];    /* pad so structure is 512 bytes long    */
  867. X    unsigned short bsBootSectSig;
  868. X#define    BOOTSIG    0xaa55
  869. X};
  870. X
  871. Xunion bootsector {
  872. X    struct bootsector33 bs33;
  873. X    struct bootsector50 bs50;
  874. X};
  875. X
  876. X/*
  877. X *  Shorthand for fields in the bpb.
  878. X */
  879. X#define    bsBytesPerSec    bsBPB.bpbBytesPerSec
  880. X#define    bsSectPerClust    bsBPB.bpbSectPerClust
  881. X#define    bsResSectors    bsBPB.bpbResSectors
  882. X#define    bsFATS        bsBPB.bpbFATS
  883. X#define    bsRootDirEnts    bsBPB.bpbRootDirEnts
  884. X#define    bsSectors    bsBPB.bpbSectors
  885. X#define    bsMedia        bsBPB.bpbMedia
  886. X#define    bsFATsecs    bsBPB.bpbFATsecs
  887. X#define    bsSectPerTrack    bsBPB.bpbSectPerTrack
  888. X#define    bsHeads        bsBPB.bpbHeads
  889. X#define    bsHiddenSecs    bsBPB.bpbHiddenSecs
  890. X#define    bsHugeSectors    bsBPB.bpbHugeSectors
  891. END-of-/sys/pcfs/bootsect.h
  892. echo x - /sys/pcfs/pcfsmount.h
  893. sed 's/^X//' >/sys/pcfs/pcfsmount.h << 'END-of-/sys/pcfs/pcfsmount.h'
  894. X/*
  895. X *  Written by Paul Popelka (paulp@uts.amdahl.com)
  896. X *
  897. X *  You can do anything you want with this software,
  898. X *    just don't say you wrote it,
  899. X *    and don't remove this notice.
  900. X *
  901. X *  This software is provided "as is".
  902. X *
  903. X *  The author supplies this software to be publicly
  904. X *  redistributed on the understanding that the author
  905. X *  is not responsible for the correct functioning of
  906. X *  this software in any circumstances and is not liable
  907. X *  for any damages caused by this software.
  908. X *
  909. X *  October 1992
  910. X */
  911. X
  912. X/*
  913. X *  Layout of the mount control block for a msdos
  914. X *  file system.
  915. X */
  916. Xstruct pcfsmount {
  917. X    struct mount *pm_mountp;    /* vfs mount struct for this fs    */
  918. X    dev_t pm_dev;            /* block special device mounted    */
  919. X    struct vnode *pm_devvp;        /* vnode for block device mntd    */
  920. X    struct bpb50 pm_bpb;        /* BIOS parameter blk for this fs */
  921. X    long pm_fatblk;            /* block # of first FAT        */
  922. X    long pm_rootdirblk;        /* block # of root directory    */
  923. X    long pm_rootdirsize;        /* size in blocks (not clusters) */
  924. X    long pm_firstcluster;        /* block number of first cluster */
  925. X    long pm_nmbrofclusters;        /* # of clusters in filesystem    */
  926. X    long pm_maxcluster;        /* maximum cluster number    */
  927. X    long pm_freeclustercount;    /* number of free clusters    */
  928. X    long pm_lookhere;        /* start free cluster search here */
  929. X    long pm_bnshift;        /* shift file offset right this
  930. X                     *  amount to get a block number */
  931. X    long pm_brbomask;        /* and a file offset with this
  932. X                     *  mask to get block rel offset */
  933. X    long pm_cnshift;        /* shift file offset right this
  934. X                     *  amount to get a cluster number */
  935. X    long pm_crbomask;        /* and a file offset with this
  936. X                     *  mask to get cluster rel offset */
  937. X    long pm_bpcluster;        /* bytes per cluster        */
  938. X    long pm_depclust;        /* directory entries per cluster */
  939. X    long pm_fmod;            /* ~0 if fs is modified, this can
  940. X                     * rollover to 0        */
  941. X    char pm_ronly;            /* read only if non-zero    */
  942. X    char pm_waitonfat;        /* wait for writes of the fat to complt,
  943. X                     * when 0 use bdwrite, else use bwrite */
  944. X    unsigned char *pm_inusemap;    /* ptr to bitmap of in-use clusters */
  945. X};
  946. X/*
  947. X *  How to compute pm_cnshift and pm_crbomask.
  948. X *
  949. X *  pm_crbomask = (pm_SectPerClust * pm_BytesPerSect) - 1
  950. X *  if (bytesperclust == 0) return EBADBLKSZ;
  951. X *  bit = 1;
  952. X *  for (i = 0; i < 32; i++) {
  953. X *    if (bit & bytesperclust) {
  954. X *      if (bit ^ bytesperclust) return EBADBLKSZ;
  955. X *      pm_cnshift = i;
  956. X *      break;
  957. X *    }
  958. X *    bit <<= 1;
  959. X * }
  960. X */
  961. X
  962. X/*
  963. X *  Shorthand for fields in the bpb contained in
  964. X *  the pcfsmount structure.
  965. X */
  966. X#define    pm_BytesPerSec    pm_bpb.bpbBytesPerSec
  967. X#define    pm_SectPerClust    pm_bpb.bpbSecPerClust
  968. X#define    pm_ResSectors    pm_bpb.bpbResSectors
  969. X#define    pm_FATs        pm_bpb.bpbFATs
  970. X#define    pm_RootDirEnts    pm_bpb.bpbRootDirEnts
  971. X#define    pm_Sectors    pm_bpb.bpbSectors
  972. X#define    pm_Media    pm_bpb.bpbMedia
  973. X#define    pm_FATsecs    pm_bpb.bpbFATsecs
  974. X#define    pm_SecPerTrack    pm_bpb.bpbSecPerTrack
  975. X#define    pm_Heads    pm_bpb.bpbHeads
  976. X#define    pm_HiddenSects    pm_bpb.bpbHiddenSecs
  977. X#define    pm_HugeSectors    pm_bpb.bpbHugeSectors
  978. X
  979. X/*
  980. X *  Map a cluster number into a filesystem relative
  981. X *  block number.
  982. X */
  983. X#define    cntobn(pmp, cn) \
  984. X    ((((cn)-CLUST_FIRST) * (pmp)->pm_SectPerClust) + (pmp)->pm_firstcluster)
  985. X
  986. X/*
  987. X *  Map a filesystem relative block number back into
  988. X *  a cluster number.
  989. X */
  990. X#define    bntocn(pmp, bn) \
  991. X    ((((bn) - pmp->pm_firstcluster)/ (pmp)->pm_SectPerClust) + CLUST_FIRST)
  992. X
  993. X/*
  994. X * Prototypes for PCFS virtual filesystem operations
  995. X */
  996. Xint pcfs_mount __P((struct mount *mp, char *path, caddr_t data,
  997. X    struct nameidata *ndp, struct proc *p));
  998. Xint pcfs_start __P((struct mount *mp, int flags, struct proc *p));
  999. Xint pcfs_unmount __P((struct mount *mp, int mntflags, struct proc *p));
  1000. Xint pcfs_root __P((struct mount *mp, struct vnode **vpp));
  1001. Xint pcfs_quotactl __P((struct mount *mp, int cmds, int uid, /* should be uid_t */
  1002. X    caddr_t arg, struct proc *p));
  1003. Xint pcfs_statfs __P((struct mount *mp, struct statfs *sbp, struct proc *p));
  1004. Xint pcfs_sync __P((struct mount *mp, int waitfor));
  1005. Xint pcfs_fhtovp __P((struct mount *mp, struct fid *fhp, struct vnode **vpp));
  1006. Xint pcfs_vptofh __P((struct vnode *vp, struct fid *fhp));
  1007. Xint pcfs_init __P(());
  1008. END-of-/sys/pcfs/pcfsmount.h
  1009. echo c - /usr/src/sbin/mount_pcfs
  1010. mkdir /usr/src/sbin/mount_pcfs > /dev/null 2>&1
  1011. echo x - /usr/src/sbin/mount_pcfs/mount_pcfs.c
  1012. sed 's/^X//' >/usr/src/sbin/mount_pcfs/mount_pcfs.c << 'END-of-/usr/src/sbin/mount_pcfs/mount_pcfs.c'
  1013. X#include <stdio.h>
  1014. X#include <sys/types.h>
  1015. X#include <sys/mount.h>
  1016. X
  1017. Xchar *progname;
  1018. X
  1019. Xvoid
  1020. Xusage ()
  1021. X{
  1022. X    fprintf (stderr, "usage: %s bdev dir\n", progname);
  1023. X    exit (1);
  1024. X}
  1025. X        
  1026. Xint
  1027. Xmain (argc, argv)
  1028. Xint argc;
  1029. Xchar **argv;
  1030. X{
  1031. X    char *dev;
  1032. X    char *dir;
  1033. X    struct pcfs_args args;
  1034. X    int c;
  1035. X    extern char *optarg;
  1036. X    extern int optind;
  1037. X    int opts;
  1038. X
  1039. X    progname = argv[0];
  1040. X
  1041. X    opts = 0;
  1042. X
  1043. X    while ((c = getopt (argc, argv, "F:")) != EOF) {
  1044. X        switch (c) {
  1045. X        case 'F':
  1046. X            opts |= atoi (optarg);
  1047. X            break;
  1048. X        default:
  1049. X            usage ();
  1050. X        }
  1051. X    }
  1052. X
  1053. X    if (optind + 2 != argc)
  1054. X        usage ();
  1055. X
  1056. X    dev = argv[optind];
  1057. X    dir = argv[optind + 1];
  1058. X
  1059. X    args.fspec = dev;
  1060. X    args.exflags = 0;
  1061. X    args.exroot = 0;
  1062. X
  1063. X    if (mount (MOUNT_PCFS, dir, opts, &args) < 0) {
  1064. X        perror ("mount");
  1065. X        exit (1);
  1066. X    }
  1067. X
  1068. X    exit (0);
  1069. X}
  1070. END-of-/usr/src/sbin/mount_pcfs/mount_pcfs.c
  1071. echo x - /usr/src/sbin/mount_pcfs/Makefile
  1072. sed 's/^X//' >/usr/src/sbin/mount_pcfs/Makefile << 'END-of-/usr/src/sbin/mount_pcfs/Makefile'
  1073. XPROG = mount_pcfs
  1074. XCFLAGS += -DPCFS
  1075. XNOMAN = noman
  1076. X
  1077. X.include <bsd.prog.mk>
  1078. END-of-/usr/src/sbin/mount_pcfs/Makefile
  1079. exit
  1080.  
  1081.