summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorattilio <attilio@FreeBSD.org>2013-03-02 14:54:33 +0000
committerattilio <attilio@FreeBSD.org>2013-03-02 14:54:33 +0000
commit4b0353fc07e5e0a054a50bb98e473e42ae9c961d (patch)
tree6d6389eceffac7546d097a5136a4531f6971cabd
parent063bdc75f87d3604c970760a9806706da5e9d4ec (diff)
downloadFreeBSD-src-4b0353fc07e5e0a054a50bb98e473e42ae9c961d.zip
FreeBSD-src-4b0353fc07e5e0a054a50bb98e473e42ae9c961d.tar.gz
Garbage collect HPFS bits which are now already completely disconnected
from the tree since few months (please note that the userland bits were already disconnected since a long time, thus there is no need to update the OLD* entries). This is not targeted for MFC.
-rw-r--r--sbin/mount_hpfs/Makefile14
-rw-r--r--sbin/mount_hpfs/mount_hpfs.8100
-rw-r--r--sbin/mount_hpfs/mount_hpfs.c244
-rw-r--r--sys/fs/hpfs/hpfs.h387
-rw-r--r--sys/fs/hpfs/hpfs_alsubr.c907
-rw-r--r--sys/fs/hpfs/hpfs_ioctl.h43
-rw-r--r--sys/fs/hpfs/hpfs_lookup.c213
-rw-r--r--sys/fs/hpfs/hpfs_subr.c869
-rw-r--r--sys/fs/hpfs/hpfs_subr.h89
-rw-r--r--sys/fs/hpfs/hpfs_vfsops.c545
-rw-r--r--sys/fs/hpfs/hpfs_vnops.c1264
-rw-r--r--sys/fs/hpfs/hpfsmount.h39
-rw-r--r--sys/modules/hpfs/Makefile10
13 files changed, 0 insertions, 4724 deletions
diff --git a/sbin/mount_hpfs/Makefile b/sbin/mount_hpfs/Makefile
deleted file mode 100644
index 9e65b8e..0000000
--- a/sbin/mount_hpfs/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-#
-# $FreeBSD$
-#
-
-PROG= mount_hpfs
-SRCS= mount_hpfs.c getmntopts.c
-MAN= mount_hpfs.8
-
-MOUNT= ${.CURDIR}/../mount
-CFLAGS+= -I${MOUNT} -DHPFS
-
-.PATH: ${MOUNT}
-
-.include <bsd.prog.mk>
diff --git a/sbin/mount_hpfs/mount_hpfs.8 b/sbin/mount_hpfs/mount_hpfs.8
deleted file mode 100644
index 81e3ea3..0000000
--- a/sbin/mount_hpfs/mount_hpfs.8
+++ /dev/null
@@ -1,100 +0,0 @@
-.\"
-.\" Copyright (c) 1993,1994 Christopher G. Demetriou
-.\" Copyright (c) 1999 Semen Ustimenko <semenu@FreeBSD.org>
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgment:
-.\" This product includes software developed by Christopher G. Demetriou.
-.\" 3. The name of the author may not be used to endorse or promote products
-.\" derived from this software without specific prior written permission
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd May 20, 1999
-.Dt MOUNT_HPFS 8
-.Os
-.Sh NAME
-.Nm mount_hpfs
-.Nd mount an HPFS file system
-.Sh SYNOPSIS
-.Nm
-.Op Fl o Ar options
-.Op Fl u Ar uid
-.Op Fl g Ar gid
-.Op Fl m Ar mask
-.Pa special
-.Pa node
-.Sh DESCRIPTION
-The
-.Nm
-utility attaches the HPFS file system residing on the device
-.Pa special
-to the global file system namespace at the location
-indicated by
-.Pa node .
-This command is normally executed by
-.Xr mount 8
-at boot time, but can be used by any user to mount an
-HPFS file system on any directory that they own (provided,
-of course, that they have appropriate access to the device that
-contains the file system).
-.Pp
-The options are as follows:
-.Bl -tag -width Ds
-.It Fl u Ar uid
-Set the owner of the files in the file system to
-.Ar uid .
-The default owner is the owner of the directory
-on which the file system is being mounted.
-.It Fl g Ar gid
-Set the group of the files in the file system to
-.Ar gid .
-The default group is the group of the directory
-on which the file system is being mounted.
-.It Fl m Ar mask
-Specify the maximum file permissions for files
-in the file system.
-.El
-.Sh EXAMPLES
-To mount an hpfs volume located in /dev/wd1s1:
-.Bd -literal -offset indent
-# mount_hpfs /dev/wd1s1 /mnt
-.Ed
-.Sh WRITING
-There is limited writing ability and it is not well-tested.
-It is strongly recommended to mount readonly!
-.Sh SEE ALSO
-.Xr mount 2 ,
-.Xr unmount 2 ,
-.Xr fstab 5 ,
-.Xr mount 8
-.Sh HISTORY
-The
-.Nm
-utility first appeared in
-.Fx 3.0 .
-.Sh AUTHORS
-HPFS kernel implementation,
-.Nm
-and manual were written by
-.An Semen Ustimenko Aq semenu@FreeBSD.org .
diff --git a/sbin/mount_hpfs/mount_hpfs.c b/sbin/mount_hpfs/mount_hpfs.c
deleted file mode 100644
index 0106377..0000000
--- a/sbin/mount_hpfs/mount_hpfs.c
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * Copyright (c) 1994 Christopher G. Demetriou
- * Copyright (c) 1999 Semen Ustimenko (semenu@FreeBSD.org)
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Christopher G. Demetriou.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <sys/cdefs.h>
-#include <sys/param.h>
-#include <sys/mount.h>
-#include <sys/stat.h>
-#include <fs/hpfs/hpfsmount.h>
-#include <ctype.h>
-#include <err.h>
-#include <grp.h>
-#include <pwd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sysexits.h>
-#include <unistd.h>
-
-#include "mntopts.h"
-
-static struct mntopt mopts[] = {
- MOPT_STDOPTS,
- MOPT_END
-};
-
-static gid_t a_gid(char *);
-static uid_t a_uid(char *);
-static mode_t a_mask(char *);
-static void usage(void) __dead2;
-static void load_u2wtable(struct hpfs_args *, char *);
-
-int
-main(int argc, char *argv[])
-{
- struct hpfs_args args;
- struct stat sb;
- int c, mntflags, set_gid, set_uid, set_mask;
- int forcerw = 0;
- char *dev, *dir, ndir[MAXPATHLEN];
-
- mntflags = set_gid = set_uid = set_mask = 0;
- (void)memset(&args, '\0', sizeof(args));
-
- while ((c = getopt(argc, argv, "u:g:m:o:c:W:F")) != -1) {
- switch (c) {
- case 'F':
- forcerw=1;
- break;
- case 'u':
- args.uid = a_uid(optarg);
- set_uid = 1;
- break;
- case 'g':
- args.gid = a_gid(optarg);
- set_gid = 1;
- break;
- case 'm':
- args.mode = a_mask(optarg);
- set_mask = 1;
- break;
- case 'o':
- getmntopts(optarg, mopts, &mntflags, 0);
- break;
- case 'W':
- load_u2wtable(&args, optarg);
- args.flags |= HPFSMNT_TABLES;
- break;
- case '?':
- default:
- usage();
- break;
- }
- }
-
- if (optind + 2 != argc)
- usage();
-
- if (!(mntflags & MNT_RDONLY) && !forcerw) {
- warnx("Write support is BETA, you need -F flag to enable RW mount!");
- exit (111);
- }
-
- dev = argv[optind];
- dir = argv[optind + 1];
- if (dir[0] != '/') {
- warnx("\"%s\" is a relative path", dir);
- if (getcwd(ndir, sizeof(ndir)) == NULL)
- err(EX_OSERR, "getcwd");
- strncat(ndir, "/", sizeof(ndir) - strlen(ndir) - 1);
- strncat(ndir, dir, sizeof(ndir) - strlen(ndir) - 1);
- dir = ndir;
- warnx("using \"%s\" instead", dir);
- }
-
- args.fspec = dev;
- args.export.ex_root = 65534; /* unchecked anyway on DOS fs */
- if (mntflags & MNT_RDONLY)
- args.export.ex_flags = MNT_EXRDONLY;
- else
- args.export.ex_flags = 0;
-
- if (!set_gid || !set_uid || !set_mask) {
- if (stat(dir, &sb) == -1)
- err(EX_OSERR, "stat %s", dir);
-
- if (!set_uid)
- args.uid = sb.st_uid;
- if (!set_gid)
- args.gid = sb.st_gid;
- if (!set_mask)
- args.mode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
- }
-
- if (mount("hpfs", dir, mntflags, &args) < 0)
- err(EX_OSERR, "%s", dev);
-
- exit (0);
-}
-
-gid_t
-a_gid(char *s)
-{
- struct group *gr;
- char *gname;
- gid_t gid;
-
- if ((gr = getgrnam(s)) != NULL)
- gid = gr->gr_gid;
- else {
- for (gname = s; *s && isdigit(*s); ++s);
- if (!*s)
- gid = atoi(gname);
- else
- errx(EX_NOUSER, "unknown group id: %s", gname);
- }
- return (gid);
-}
-
-uid_t
-a_uid(char *s)
-{
- struct passwd *pw;
- char *uname;
- uid_t uid;
-
- if ((pw = getpwnam(s)) != NULL)
- uid = pw->pw_uid;
- else {
- for (uname = s; *s && isdigit(*s); ++s);
- if (!*s)
- uid = atoi(uname);
- else
- errx(EX_NOUSER, "unknown user id: %s", uname);
- }
- return (uid);
-}
-
-mode_t
-a_mask(char *s)
-{
- int done, rv=0;
- char *ep;
-
- done = 0;
- if (*s >= '0' && *s <= '7') {
- done = 1;
- rv = strtol(optarg, &ep, 8);
- }
- if (!done || rv < 0 || *ep)
- errx(EX_USAGE, "invalid file mode: %s", s);
- return (rv);
-}
-
-void
-usage(void)
-{
- fprintf(stderr, "usage: mount_hpfs [-u user] [-g group] [-m mask] bdev dir\n");
- exit(EX_USAGE);
-}
-
-void
-load_u2wtable (struct hpfs_args *pargs, char *name)
-{
- FILE *f;
- int i, code;
- char buf[128];
- char *fn;
-
- if (*name == '/')
- fn = name;
- else {
- snprintf(buf, sizeof(buf), "/usr/libdata/msdosfs/%s", name);
- buf[127] = '\0';
- fn = buf;
- }
- if ((f = fopen(fn, "r")) == NULL)
- err(EX_NOINPUT, "%s", fn);
- for (i = 0; i < 128; i++) {
- if (fscanf(f, "%i", &code) != 1)
- errx(EX_DATAERR, "u2w: missing item number %d", i);
- /* pargs->u2w[i] = code; */
- }
- for (i = 0; i < 128; i++) {
- if (fscanf(f, "%i", &code) != 1)
- errx(EX_DATAERR, "d2u: missing item number %d", i);
- pargs->d2u[i] = code;
- }
- for (i = 0; i < 128; i++) {
- if (fscanf(f, "%i", &code) != 1)
- errx(EX_DATAERR, "u2d: missing item number %d", i);
- pargs->u2d[i] = code;
- }
- fclose(f);
-}
diff --git a/sys/fs/hpfs/hpfs.h b/sys/fs/hpfs/hpfs.h
deleted file mode 100644
index fba0c45..0000000
--- a/sys/fs/hpfs/hpfs.h
+++ /dev/null
@@ -1,387 +0,0 @@
-/*-
- * Copyright (c) 1998, 1999 Semen Ustimenko (semenu@FreeBSD.org)
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-/*#define HPFS_DEBUG 10*/
-typedef u_int32_t lsn_t; /* Logical Sector Number */
-typedef struct {
- lsn_t lsn1;
- lsn_t lsn2;
-} rsp_t; /* Redundant Sector Pointer */
-typedef struct {
- u_int32_t cnt;
- lsn_t lsn;
-} sptr_t; /* Storage Pointer */
-
-#define SUBLOCK 0x10
-#define SUSIZE DEV_BSIZE
-#define SPBLOCK 0x11
-#define SPSIZE DEV_BSIZE
-#define BMSIZE (4 * DEV_BSIZE)
-#define HPFS_MAXFILENAME 255
-
-#define SU_MAGIC ((u_int64_t)0xFA53E9C5F995E849)
-struct sublock {
- u_int64_t su_magic;
- u_int8_t su_hpfsver;
- u_int8_t su_fnctver;
- u_int16_t unused;
- lsn_t su_rootfno; /* Root Fnode */
- u_int32_t su_btotal; /* Total blocks */
- u_int32_t su_badbtotal; /* Bad Sectors total */
- rsp_t su_bitmap;
- rsp_t su_badbl;
- u_long su_chkdskdate;
- u_long su_dskoptdate;
- u_int32_t su_dbbsz; /* Sectors in DirBlock Band */
- lsn_t su_dbbstart;
- lsn_t su_dbbend;
- lsn_t su_dbbbitmap;
- char su_volname[0x20];
- lsn_t su_uidt; /* Ptr to User ID Table (8 sect) */
-};
-
-#define SP_MAGIC ((u_int64_t)0xFA5229C5F9911849)
-#define SP_DIRTY 0x0001
-#define SP_SPDBINUSE 0x0002
-#define SP_HFINUSE 0x0004
-#define SP_BADSECT 0x0008
-#define SP_BADBMBL 0x0010
-#define SP_FASTFRMT 0x0020
-#define SP_OLDHPFS 0x0080
-#define SP_IDASD 0x0100
-#define SP_RDASD 0x0200
-#define SP_DASD 0x0400
-#define SP_MMACTIVE 0x0800
-#define SP_DCEACLS 0x1000
-#define SP_DSADDIRTY 0x2000
-struct spblock {
- u_int64_t sp_magic;
- u_int16_t sp_flag;
- u_int8_t sp_mmcontf;
- u_int8_t unused;
- lsn_t sp_hf; /* HotFix list */
- u_int32_t sp_hfinuse; /* HotFixes in use */
- u_int32_t sp_hfavail; /* HotFixes available */
- u_int32_t sp_spdbavail; /* Spare DirBlocks available */
- u_int32_t sp_spdbmax; /* Spare DirBlocks maximum */
- lsn_t sp_cpi;
- u_int32_t sp_cpinum;
- u_int32_t sp_suchecksum;
- u_int32_t sp_spchecksum;
- u_int8_t reserved[0x3C];
- lsn_t sp_spdb[0x65];
-};
-
-#define DE_SPECIAL 0x0001
-#define DE_ACL 0x0002
-#define DE_DOWN 0x0004
-#define DE_END 0x0008
-#define DE_EALIST 0x0010
-#define DE_EPERM 0x0020
-#define DE_EXPLACL 0x0040
-#define DE_NEEDEA 0x0080
-#define DE_RONLY 0x0100
-#define DE_HIDDEN 0x0200
-#define DE_SYSTEM 0x0400
-#define DE_VOLLABEL 0x0800
-#define DE_DIR 0x1000
-#define DE_ARCHIV 0x2000
-#define DE_DOWNLSN(dep) (*(lsn_t *)((caddr_t)(dep) + (dep)->de_reclen - sizeof(lsn_t)))
-#define DE_NEXTDE(dep) ((struct hpfsdirent *)((caddr_t)(dep) + (dep)->de_reclen))
-typedef struct hpfsdirent {
- u_int16_t de_reclen;
- u_int16_t de_flag;
- lsn_t de_fnode;
- u_long de_mtime;
- u_int32_t de_size;
- u_long de_atime;
- u_long de_ctime;
- u_int32_t de_ealen;
- u_int8_t de_flexflag;
- u_int8_t de_cpid;
- u_int8_t de_namelen;
- char de_name[1];
-/* ... de_flex; */
-/* lsn_t de_down; */
-} hpfsdirent_t;
-
-#define D_BSIZE (DEV_BSIZE*4)
-#define D_MAGIC 0x77E40AAE
-#define D_DIRENT(dbp) ((hpfsdirent_t *)((caddr_t)dbp + sizeof(dirblk_t)))
-#define D_DE(dbp, deoff) ((hpfsdirent_t *)((caddr_t)dbp + sizeof(dirblk_t) + (deoff)))
-typedef struct dirblk {
- u_int32_t d_magic;
- u_int32_t d_freeoff; /* Offset of first free byte */
- u_int32_t d_chcnt; /* Change count */
- lsn_t d_parent;
- lsn_t d_self;
-} dirblk_t;
-
-/*
- * Allocation Block (ALBLK)
- */
-#define AB_HBOFFEO 0x01
-#define AB_FNPARENT 0x20
-#define AB_SUGGBSCH 0x40
-#define AB_NODES 0x80
-#define AB_ALLEAF(abp) ((alleaf_t *)((caddr_t)(abp) + sizeof(alblk_t)))
-#define AB_ALNODE(abp) ((alnode_t *)((caddr_t)(abp) + sizeof(alblk_t)))
-#define AB_FREEALP(abp) ((alleaf_t *)((caddr_t)(abp) + (abp)->ab_freeoff))
-#define AB_FREEANP(abp) ((alnode_t *)((caddr_t)(abp) + (abp)->ab_freeoff))
-#define AB_LASTALP(abp) (AB_ALLEAF(abp) + (abp)->ab_busycnt - 1)
-#define AB_LASTANP(abp) (AB_ALNODE(abp) + (abp)->ab_busycnt - 1)
-#define AB_ADDNREC(abp, sz, n) { \
- (abp)->ab_busycnt += (n); \
- (abp)->ab_freecnt -= (n); \
- (abp)->ab_freeoff += (n) * (sz); \
-}
-#define AB_RMNREC(abp, sz, n) { \
- (abp)->ab_busycnt -= (n); \
- (abp)->ab_freecnt += (n); \
- (abp)->ab_freeoff -= (n) * (sz);\
-}
-#define AB_ADDAL(abp) AB_ADDNREC(abp,sizeof(alleaf_t), 1)
-#define AB_ADDAN(abp) AB_ADDNREC(abp,sizeof(alnode_t), 1)
-#define AB_RMAL(abp) AB_RMNREC(abp,sizeof(alleaf_t), 1)
-#define AB_RMAN(abp) AB_RMNREC(abp,sizeof(alnode_t), 1)
-typedef struct alblk {
- u_int8_t ab_flag;
- u_int8_t ab_res[3];
- u_int8_t ab_freecnt;
- u_int8_t ab_busycnt;
- u_int16_t ab_freeoff;
-} alblk_t;
-
-/*
- * FNode
- */
-#define FNODESIZE DEV_BSIZE
-#define FN_MAGIC 0xF7E40AAE
-struct fnode {
- u_int32_t fn_magic;
- u_int64_t fn_readhist;
- u_int8_t fn_namelen;
- char fn_name[0xF]; /* First 15 symbols or less */
- lsn_t fn_parent;
- sptr_t fn_extacl;
- u_int16_t fn_acllen;
- u_int8_t fn_extaclflag;
- u_int8_t fn_histbitcount;
- sptr_t fn_extea;
- u_int16_t fn_ealen; /* Len of EAs in Fnode */
- u_int8_t fn_exteaflag; /* EAs in exteas */
- u_int8_t fn_flag;
- alblk_t fn_ab;
- u_int8_t fn_abd[0x60];
- u_int32_t fn_size;
- u_int32_t fn_reqea;
- u_int8_t fn_uid[0x10];
- u_int16_t fn_intoff;
- u_int8_t fn_1dasdthr;
- u_int8_t fn_dasdthr;
- u_int32_t fn_dasdlim;
- u_int32_t fn_dasdusage;
- u_int8_t fn_int[0x13c];
-};
-
-#define EA_NAME(eap) ((char *)(((caddr_t)(eap)) + sizeof(struct ea)))
-struct ea {
- u_int8_t ea_type; /* 0 - plain val */
- /* 1 - sptr to val */
- /* 3 - lsn point to AlSec, cont. val */
- u_int8_t ea_namelen;
- u_int16_t ea_vallen;
- /*u_int8_t ea_name[]; */
- /*u_int8_t ea_val[]; */
-};
-
-/*
- * Allocation Block Data (ALNODE)
- *
- * NOTE: AlNodes are used when there are too many fragments
- * to represent the data in the AlBlk
- */
-#define AN_SET(anp,nextoff,lsn) { \
- (anp)->an_nextoff = (nextoff); \
- (anp)->an_lsn = (lsn); \
-}
-typedef struct alnode {
- u_int32_t an_nextoff; /* next node offset in blocks */
- lsn_t an_lsn; /* position of AlSec structure */
-} alnode_t;
-
-/*
- * Allocaion Block Data (ALLEAF)
- *
- * NOTE: Leaves are used to point at contiguous block of data
- * (a fragment or an "extent");
- */
-#define AL_SET(alp,off,len,lsn) { \
- (alp)->al_off = (off); \
- (alp)->al_len = (len); \
- (alp)->al_lsn = (lsn); \
-}
-typedef struct alleaf {
- u_int32_t al_off; /* offset in blocks */
- u_int32_t al_len; /* len in blocks */
- lsn_t al_lsn; /* phys position */
-} alleaf_t;
-
-/*
- * Allocation Sector
- *
- * NOTE: AlSecs are not initialized before use, so they ussually
- * look full of junk. Use the AlBlk tto validate the data.
- */
-#define AS_MAGIC 0x37E40AAE
-typedef struct alsec {
- u_int32_t as_magic;
- lsn_t as_self;
- lsn_t as_parent;
- alblk_t as_ab;
- u_int8_t as_abd[0x1E0];
-} alsec_t;
-
-/*
- * Code Page structures
- */
-struct cpdblk {
- u_int16_t b_country; /* Country code */
- u_int16_t b_cpid; /* CP ID */
- u_int16_t b_dbcscnt; /* Count of DBCS ranges in CP */
- char b_upcase[0x80]; /* Case conversion table */
- u_int16_t b_dbcsrange; /* Start/End DBCS range pairs */
-
-};
-
-#define CPD_MAGIC ((u_int32_t)0x894521F7)
-struct cpdsec {
- u_int32_t d_magic;
- u_int16_t d_cpcnt; /* CP Data count */
- u_int16_t d_cpfirst; /* Index of first CP Data */
- u_int32_t d_checksum[3]; /* CP Data checksumms */
- u_int16_t d_offset[3]; /* Offsets of CP Data blocks */
- struct cpdblk d_cpdblk[3]; /* Array of CP Data Blocks */
-};
-
-struct cpiblk {
- u_int16_t b_country; /* Country code */
- u_int16_t b_cpid; /* CP ID */
- u_int32_t b_checksum;
- lsn_t b_cpdsec; /* Pointer to CP Data Sector */
- u_int16_t b_vcpid; /* Volume spec. CP ID */
- u_int16_t b_dbcscnt; /* Count of DBCS ranges in CP */
-};
-
-#define CPI_MAGIC ((u_int32_t)0x494521F7)
-struct cpisec {
- u_int32_t s_magic;
- u_int32_t s_cpicnt; /* Count of CPI's in this sector */
- u_int32_t s_cpifirst; /* Index of first CPI in this sector */
- lsn_t s_next; /* Pointer to next CPI Sector */
- struct cpiblk s_cpi[0x1F]; /* Array of CPI blocks */
-};
-
-struct hpfsmount {
- struct sublock hpm_su;
- struct spblock hpm_sp;
- struct mount * hpm_mp;
- struct vnode * hpm_devvp; /* XXX: lose this, it's in hpfsmount */
- struct g_consumer *hpm_cp;
- struct bufobj *hpm_bo;
- struct cdev *hpm_dev;
- uid_t hpm_uid;
- gid_t hpm_gid;
- mode_t hpm_mode;
-
- lsn_t * hpm_bmind;
- struct cpdblk * hpm_cpdblk; /* Array of CP Data Blocks */
- u_char hpm_u2d[0x80]; /* Unix to DOS Table*/
- u_char hpm_d2u[0x80]; /* DOS to Unix Table*/
-
- u_long hpm_bavail; /* Blocks available */
- u_long hpm_dbnum; /* Data Band number */
- u_int8_t * hpm_bitmap;
-};
-
-#define H_PARVALID 0x0002 /* parent info is valid */
-#define H_CHANGE 0x0004 /* node date was changed */
-#define H_PARCHANGE 0x0008 /* parent node date was changed */
-#define H_INVAL 0x0010 /* Invalid node */
-struct hpfsnode {
- struct mtx h_interlock;
-
- struct hpfsmount *h_hpmp;
- struct fnode h_fn;
- struct vnode * h_vp;
- struct vnode * h_devvp; /* XXX: remove, hpfsmount has it */
- struct cdev *h_dev;
- lsn_t h_no;
- uid_t h_uid;
- gid_t h_gid;
- mode_t h_mode;
- u_int32_t h_flag;
-
- /* parent dir information */
- u_long h_mtime;
- u_long h_atime;
- u_long h_ctime;
- char h_name[HPFS_MAXFILENAME+1]; /* Used to speedup dirent */
- int h_namelen; /* lookup */
-};
-
-/* This overlays the fid structure (see <sys/mount.h>) */
-struct hpfid {
- u_int16_t hpfid_len; /* Length of structure. */
- u_int16_t hpfid_pad; /* Force 32-bit alignment. */
- lsn_t hpfid_ino; /* File number (ino). */
- int32_t hpfid_gen; /* Generation number. */
-};
-
-#if defined(HPFS_DEBUG)
-#define dprintf(a) printf a
-#if HPFS_DEBUG > 1
-#define ddprintf(a) printf a
-#else
-#define ddprintf(a)
-#endif
-#else
-#define dprintf(a)
-#define ddprintf(a)
-#endif
-
-#if __FreeBSD_version >= 300000
-MALLOC_DECLARE(M_HPFSMNT);
-MALLOC_DECLARE(M_HPFSNO);
-#endif
-#define VFSTOHPFS(mp) ((struct hpfsmount *)((mp)->mnt_data))
-#define VTOHP(v) ((struct hpfsnode *)((v)->v_data))
-#define HPTOV(h) ((struct vnode *)((h)->h_vp))
-#define FID(f) (*((lsn_t *)(f)->fid_data))
-
-extern struct vop_vector hpfs_vnodeops;
diff --git a/sys/fs/hpfs/hpfs_alsubr.c b/sys/fs/hpfs/hpfs_alsubr.c
deleted file mode 100644
index 226865f..0000000
--- a/sys/fs/hpfs/hpfs_alsubr.c
+++ /dev/null
@@ -1,907 +0,0 @@
-/*-
- * Copyright (c) 1998, 1999 Semen Ustimenko (semenu@FreeBSD.org)
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/proc.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <sys/namei.h>
-#include <sys/malloc.h>
-#include <sys/bio.h>
-#include <sys/buf.h>
-
-#include <fs/hpfs/hpfs.h>
-#include <fs/hpfs/hpfs_subr.h>
-
-#define AE_DONE 0 /* Nothing to change */
-#define AE_SPLIT 2 /* Split was done, ranp is valid */
-
-int hpfs_addextentr (struct hpfsmount *, lsn_t, alleaf_t *,
- alnode_t *, u_long *);
-int hpfs_allocalsec (struct hpfsmount *, lsn_t, struct buf **);
-int hpfs_alblk2alsec (struct hpfsmount *, alblk_t *, alsec_t **,
- struct buf **);
-int hpfs_splitalsec (struct hpfsmount *, alsec_t *, alsec_t **,
- struct buf **);
-int hpfs_concatalsec (struct hpfsmount *, alsec_t *, alsec_t *,
- alnode_t *);
-
-/*
- * Map file offset to disk offset. hpfsnode have to be locked.
- */
-int
-hpfs_hpbmap(hp, bn, bnp, runp)
- struct hpfsnode *hp;
- daddr_t bn;
- daddr_t *bnp;
- int *runp;
-{
- struct buf *bp;
- alblk_t * abp;
- alleaf_t *alp;
- alnode_t *anp;
- int error, i;
-
- dprintf(("hpfs_hpbmap(0x%x, 0x%x): ",hp->h_no, bn));
-
- bp = NULL;
- abp = &hp->h_fn.fn_ab;
- alp = (alleaf_t *)&hp->h_fn.fn_abd;
- anp = (alnode_t *)&hp->h_fn.fn_abd;
-
-dive:
- if (abp->ab_flag & AB_NODES) {
- for (i=0; i<abp->ab_busycnt; i++, anp++) {
- dprintf(("[0x%x,0x%x] ",anp->an_nextoff,anp->an_lsn));
- if (bn < anp->an_nextoff) {
- alsec_t *asp;
-
- dprintf(("< found | "));
-
- if (bp)
- brelse(bp);
- error = bread(hp->h_devvp, anp->an_lsn,
- DEV_BSIZE, NOCRED, &bp);
- if (error) {
- printf("hpfs_hpbmap: bread error\n");
- brelse(bp);
- return (error);
- }
-
- asp = (alsec_t *) bp->b_data;
- if (asp->as_magic != AS_MAGIC) {
- brelse(bp);
- printf("hpfs_hpbmap: "
- "MAGIC DOESN'T MATCH");
- return (EINVAL);
- }
-
- abp = &asp->as_ab;
- alp = (alleaf_t *)&asp->as_abd;
- anp = (alnode_t *)&asp->as_abd;
-
- goto dive;
- }
- }
- } else {
- for (i=0; i<abp->ab_busycnt; i++, alp++) {
- dprintf(("[0x%x,0x%x,0x%x] ",
- alp->al_off,alp->al_len,alp->al_lsn));
-
- if ((bn >= alp->al_off) &&
- (!alp->al_len || (bn < alp->al_off + alp->al_len))) {
- dprintf(("found, "));
-
- *bnp = bn - alp->al_off + alp->al_lsn;
-
- dprintf((" 0x%x ", *bnp));
-
- if (runp != NULL) {
- if (alp->al_len)
- *runp = alp->al_off - 1 +
- alp->al_len - bn;
- else
- *runp = 3; /* XXX */
-
- dprintf((" 0x%x cont", *runp));
- }
-
- if (bp)
- brelse(bp);
-
- dprintf(("\n"));
- return (0);
- }
- }
- }
-
- dprintf(("END, notfound\n"));
- if (bp)
- brelse(bp);
-
- dprintf(("hpfs_hpbmap: offset too big\n"));
-
- return (EFBIG);
-}
-
-/*
- * Find place and preinitialize AlSec structure
- * AlBlk is initialized to contain AlLeafs.
- */
-int
-hpfs_allocalsec (
- struct hpfsmount *hpmp,
- lsn_t parlsn,
- struct buf **bpp)
-{
- alsec_t * asp;
- struct buf * bp;
- lsn_t lsn;
- int error;
-
- *bpp = NULL;
-
- error = hpfs_bmfblookup(hpmp, &lsn);
- if (error) {
- printf("hpfs_allocalsec: CAN'T ALLOC SPACE FOR AlSec\n");
- return (error);
- }
-
- error = hpfs_bmmarkbusy(hpmp, lsn, 1);
- if (error)
- return (error);
-
- bp = getblk(hpmp->hpm_devvp, lsn, DEV_BSIZE, 0, 0, 0);
- clrbuf(bp);
-
- /* Fill AlSec info */
- asp = (alsec_t *) bp->b_data;
- asp->as_magic = AS_MAGIC;
- asp->as_self = lsn;
- asp->as_parent = parlsn;
-
- /* Fill AlBlk */
- asp->as_ab.ab_flag = 0;
- asp->as_ab.ab_busycnt = 0;
- asp->as_ab.ab_freecnt = 0x28;
- asp->as_ab.ab_freeoff = sizeof(alblk_t);
-
- *bpp = bp;
-
- return (0);
-}
-
-/*
- * Split AlSec structure into new allocated:
- * allocate new AlSec; then move second half of asp's entries in
- * into it; set proper flags.
- *
- * IF AlSec CONTAINS AlNodes, THEN YOU ALMOST EVERYTIME HAVE TO
- * FIX LAST AlNode in OLD AlSec (NEXTOFF TO BE 0xFFFFFFFF).
- * TOGETHER WITH FIXING ALL CHILDREN'S AlSecs (THEY HAVE GOT NEW PARENT).
- */
-int
-hpfs_splitalsec (
- struct hpfsmount *hpmp,
- alsec_t *asp,
- alsec_t **naspp,
- struct buf **nbpp)
-{
- alsec_t *nasp;
- struct buf *nbp;
- alblk_t *abp;
- alblk_t *nabp;
- int error, n1, n2, sz;
-
- error = hpfs_allocalsec(hpmp, asp->as_parent, &nbp);
- if (error)
- return (error);
-
- nasp = (alsec_t *)nbp->b_data;
- nabp = &nasp->as_ab;
- abp = &asp->as_ab;
-
- n1 = (abp->ab_busycnt + 1) / 2;
- n2 = (abp->ab_busycnt - n1);
- sz = (abp->ab_flag & AB_NODES) ? sizeof(alnode_t) : sizeof(alleaf_t);
-
- bcopy((caddr_t)abp + sizeof(alblk_t) + n1 * sz,
- (caddr_t)nabp + sizeof(alblk_t), n2 * sz);
-
- nabp->ab_flag = abp->ab_flag;
- nabp->ab_busycnt = n2;
- nabp->ab_freecnt = (0x1e0 / sz - n2);
- nabp->ab_freeoff += n2 * sz;
-
- abp->ab_busycnt -= n1;
- abp->ab_freecnt += n1;
- abp->ab_freeoff -= n1 * sz;
-
- *naspp = nasp;
- *nbpp = nbp;
-
- return (0);
-}
-
-/*
- * Try to concatenate two AlSec's
- *
- * Moves all entries from AlSec corresponding (as1p, aanp[1]) into
- * corresponding aanp[0] one. If not enought space, then return ENOSPC.
- *
- * WARNING! YOU HAVE TO FIX aanp VALUES YOURSELF LATER:
- * aanp[0].an_nextoff = aanp[1].an_nextoff;
- */
-int
-hpfs_concatalsec (
- struct hpfsmount *hpmp,
- alsec_t *as0p,
- alsec_t *as1p,
- alnode_t *aanp)
-{
- alblk_t *ab0p;
- alblk_t *ab1p;
- int sz;
-
- dprintf(("hpfs_concatalsec: AlSecs at 0x%x and 0x%x \n",
- as0p->as_self,as1p->as_self));
-
- ab0p = &as0p->as_ab;
- ab1p = &as1p->as_ab;
- sz = (ab0p->ab_flag & AB_NODES) ? sizeof(alnode_t) : sizeof(alleaf_t);
-
- if (ab0p->ab_freecnt > ab1p->ab_busycnt) {
- /*
- * Concatenate AlSecs
- */
- if (ab0p->ab_flag & AB_NODES)
- AB_LASTANP(ab0p)->an_nextoff = aanp[0].an_nextoff;
-
- bcopy (AB_ALNODE(ab1p), AB_FREEANP(ab0p),
- ab1p->ab_busycnt * sz);
-
- AB_ADDNREC(ab0p, sz, ab1p->ab_busycnt);
-
- return (0);
- } else {
- /* Not enought space to concatenate */
- return (ENOSPC);
- }
-}
-
-/*
- * Transform AlBlk structure into new allocated
- * AlSec.
- *
- * DOESN'T SET AlSec'S PARENT LSN.
- */
-int
-hpfs_alblk2alsec (
- struct hpfsmount *hpmp,
- alblk_t *abp,
- alsec_t **naspp,
- struct buf **nbpp)
-{
- alsec_t *nasp;
- alblk_t *nabp;
- struct buf *nbp;
- int error, sz;
-
- error = hpfs_allocalsec(hpmp, 0, &nbp);
- if (error)
- return (error);
-
- nasp = (alsec_t *)nbp->b_data;
- nabp = &nasp->as_ab;
-
- sz = (abp->ab_flag & AB_NODES) ? sizeof(alnode_t) : sizeof(alleaf_t);
-
- bcopy (abp, nabp, sizeof(alblk_t) + sz * abp->ab_busycnt);
-
- nabp->ab_freecnt = 0x1e0 / sz - nabp->ab_busycnt;
-
- *naspp = nasp;
- *nbpp = nbp;
-
- return (0);
-}
-
-/*
- * Allocate len blocks and concatenate them to file.
- * If we hadn't found contignous run of len blocks, concatenate
- * as much as we can, and return.
- *
- */
-int
-hpfs_addextent (
- struct hpfsmount *hpmp,
- struct hpfsnode *hp,
- u_long len)
-{
- alblk_t *rabp;
- alnode_t ranp[2];
- alleaf_t al;
- int error;
- u_long pf;
-
- /*
- * We don't know for now start lsn of block
- */
- al.al_lsn = ~0;
- al.al_len = len;
- al.al_off = (hp->h_fn.fn_size + DEV_BSIZE - 1) >> DEV_BSHIFT;
-
- rabp = &hp->h_fn.fn_ab;
-
- /* Init AlBlk if this is first extent */
- if (al.al_off == 0) {
- lsn_t nlsn;
- u_long nlen;
-
- dprintf(("hpfs_addextent: init AlBlk in root\n"));
-
- rabp->ab_busycnt = 0;
- rabp->ab_freecnt = 0x8;
- rabp->ab_freeoff = sizeof(alblk_t);
- rabp->ab_flag = 0;
-
- error = hpfs_bmlookup (hpmp, 0, hp->h_no + 1, al.al_len, &nlsn, &nlen);
- if (error)
- return (error);
-
- error = hpfs_bmmarkbusy(hpmp, nlsn, nlen);
- if (error)
- return (error);
-
- dprintf(("hpfs_addextent: new: 0x%x 0x%lx, ", nlsn, nlen));
-
- AL_SET(AB_FREEALP(rabp), al.al_off, nlen, nlsn);
- AB_ADDAL(rabp);
-
- al.al_off += nlen;
- al.al_len -= nlen;
- }
-
-retry:
- dprintf(("hpfs_addextent: AlBlk: [0x%x, 0x%x, 0x%x] need: 0x%x\n",
- rabp->ab_freecnt, rabp->ab_busycnt, rabp->ab_flag, al.al_len));
-
- while ((al.al_len) && (rabp->ab_freecnt > 0)) {
- if (rabp->ab_flag & AB_NODES) {
- alnode_t *anp;
- /*
- * This is level containing AlNodes, so try to
- * insert recursively into last entry.
- */
- anp = AB_LASTANP(rabp);
- dprintf(("hpfs_addextent: AlNode: [0x%x,0x%x] \n",
- anp->an_nextoff,anp->an_lsn));
-
- /*
- * Try to insert...
- */
- error = hpfs_addextentr (hpmp, anp->an_lsn, &al, ranp, &pf);
- if (error) {
- printf("hpfs_addextent: FAILED %d\n",error);
- return (error);
- }
-
- switch (pf) {
- case AE_SPLIT:
- dprintf(("hpfs_addextent: successful (split)\n"));
- /*
- * Then hpfs_addextentr has split tree below, now
- * we need to fix this level. Particulary:
- * fix last AlNode and add another one.
- */
-
- bcopy(ranp, AB_LASTANP(rabp), sizeof(alnode_t) * 2);
- AB_ADDAN(rabp);
- break;
-
- default:
- case AE_DONE:
- dprintf(("hpfs_addextent: successful\n"));
- break;
- }
- } else {
- alleaf_t *alp;
-
- alp = AB_LASTALP(rabp);
- dprintf(("hpfs_addextent: AlLeaf: [0x%x,0x%x,0x%x] \n",
- alp->al_off,alp->al_len,alp->al_lsn));
-
- /* Check if we trying to add in right place */
- if (alp->al_off + alp->al_len == al.al_off) {
- lsn_t nlsn;
- u_long nlen;
-
- /*
- * Search bitmap for block begining from
- * alp->al_lsn + alp->al_len and long of ralp->al_len
- */
- error = hpfs_bmlookup (hpmp, 0,
- alp->al_lsn + alp->al_len, al.al_len, &nlsn, &nlen);
- if (error)
- return (error);
-
- error = hpfs_bmmarkbusy(hpmp, nlsn, nlen);
- if (error)
- return (error);
-
- dprintf(("hpfs_addextent: new: 0x%x 0x%lx, ", nlsn, nlen));
-
- if (alp->al_lsn + alp->al_len == nlsn) {
- dprintf(("extended existed leaf\n"));
-
- alp->al_len += nlen;
- } else {
- dprintf(("created new leaf\n"));
- AL_SET(AB_FREEALP(rabp), al.al_off, nlen, nlsn);
- AB_ADDAL(rabp);
- }
- al.al_off += nlen;
- al.al_len -= nlen;
- } else {
- printf("hpfs_addextent: INTERNAL INCONSISTENCE\n");
- return (EINVAL);
- }
- }
- }
-
- /*
- * Move AlBlk contain to new AlSec (it will fit more
- * entries) if overflowed (no more free entries).
- */
- if (rabp->ab_freecnt <= 0) {
- struct buf *nbp;
- alsec_t * nrasp;
-
- dprintf(("hpfs_addextent: overflow, convt\n"));
-
- /*
- * Convert AlBlk to new AlSec, it will set
- * AB_FNPARENT also.
- */
- rabp->ab_flag |= AB_FNPARENT;
- error = hpfs_alblk2alsec (hpmp, rabp, &nrasp, &nbp);
- if (error) {
- printf("hpfs_addextent: CAN'T CONVT\n");
- return (error);
- }
- nrasp->as_parent = hp->h_no;
-
- /*
- * Scan all childrens (if exist), set new parent and
- * clean their AB_FNPARENT flag.
- */
- if (rabp->ab_flag & AB_NODES) {
- int i;
- alsec_t * asp;
- alnode_t * anp;
- struct buf * bp;
-
- anp = AB_ALNODE(rabp);
- for (i=0; i<rabp->ab_busycnt; i++) {
- error = hpfs_breadalsec(hpmp, anp->an_lsn, &bp);
- if (error)
- return (error);
-
- asp = (alsec_t *)bp->b_data;
- asp->as_ab.ab_flag &= ~AB_FNPARENT;
- asp->as_parent = nrasp->as_self;
-
- bdwrite(bp);
- anp ++;
- }
- }
-
- /* Convert AlBlk to contain AlNodes */
- rabp->ab_flag = AB_NODES;
- rabp->ab_busycnt = 0;
- rabp->ab_freecnt = 0xC;
- rabp->ab_freeoff = sizeof(alblk_t);
-
- /* Add AlNode for new allocated AlSec */
- AN_SET(AB_FREEANP(rabp), ~0, nrasp->as_self);
- AB_ADDAN(rabp);
-
- bdwrite(nbp);
- }
-
- if (al.al_len) {
- dprintf(("hpfs_addextent: root retry\n"));
- goto retry;
- }
-
- return (0);
-}
-
-/*
- * Descent down to the end of tree, then search for
- * ralp->len contignous run begining from last run's end and
- * concatenate new block! If we can't find one, then...
- */
-int
-hpfs_addextentr (
- struct hpfsmount *hpmp, /* Mix info */
- lsn_t rlsn, /* LSN containing AlSec */
- alleaf_t *ralp, /* AlLeaf to insert */
- alnode_t *ranp, /* New AlNodes' values */
- u_long *resp) /* Mix returning info */
-{
- struct buf *rbp;
- alsec_t *rasp;
- alblk_t *rabp;
- alleaf_t *alp;
- alnode_t *anp;
- int error;
- u_long pf;
- u_long wb;
-
- *resp = 0;
-
- dprintf(("hpfs_addextentr: AlSec at 0x%x\n", rlsn));
-
- error = hpfs_breadalsec(hpmp, rlsn, &rbp);
- if (error)
- return (error);
-
- rasp = (alsec_t *)rbp->b_data;
- rabp = &rasp->as_ab;
- wb = 0;
-
- dprintf(("hpfs_addextentr: AlBlk: [0x%x, 0x%x, 0x%x]\n",
- rabp->ab_freecnt, rabp->ab_busycnt, rabp->ab_flag));
-
- while ((ralp->al_len) && (rabp->ab_freecnt > 0)) {
- if (rabp->ab_flag & AB_NODES) {
- /*
- * This is level containing AlNodes, so try to
- * insert recursively into last entry.
- */
- anp = AB_LASTANP(rabp);
- dprintf(("hpfs_addextentr: AlNode: [0x%x,0x%x] \n",
- anp->an_nextoff,anp->an_lsn));
-
- /*
- * Try to insert...
- */
- error = hpfs_addextentr (hpmp, anp->an_lsn, ralp, ranp, &pf);
- if (error) {
- printf("hpfs_addextentr: FAILED %d\n",error);
- goto fail;
- }
-
- switch (pf) {
- case AE_SPLIT:
- dprintf(("hpfs_addextentr: successful (split)\n"));
- /*
- * Then hpfs_addextentr has split tree below, now
- * we need to fix this level. Particulary:
- * fix last AlNode and add another one.
- */
- bcopy(ranp, AB_LASTANP(rabp), sizeof(alnode_t) * 2);
- AB_ADDAN(rabp);
- wb = 1;
- break;
-
- default:
- case AE_DONE:
- dprintf(("hpfs_addextentr: successful\n"));
- break;
- }
- } else {
- alp = AB_LASTALP(rabp);
- dprintf(("hpfs_addextentr: AlLeaf: [0x%x,0x%x,0x%x] \n",
- alp->al_off,alp->al_len,alp->al_lsn));
-
- /* Check if we trying to add in right place */
- if (alp->al_off + alp->al_len == ralp->al_off) {
- lsn_t nlsn;
- u_long nlen;
- /*
- * Search bitmap for block begining from
- * alp->al_lsn + alp->al_len and long of ralp->al_len
- */
- error = hpfs_bmlookup (hpmp, 0,
- alp->al_lsn + alp->al_len, ralp->al_len, &nlsn, &nlen);
- if (error)
- goto fail;
-
- error = hpfs_bmmarkbusy(hpmp, nlsn, nlen);
- if (error)
- goto fail;
-
- dprintf(("hpfs_addextentr: new: 0x%x 0x%lx, ", nlsn, nlen));
-
- /*
- * If ending of existed entry fits the
- * begining of the extent being added,
- * then we add concatenate two extents.
- */
- if (alp->al_lsn + alp->al_len == nlsn) {
- dprintf(("concat\n"));
- alp->al_len += nlen;
- } else {
- dprintf(("created new leaf\n"));
- AL_SET(AB_FREEALP(rabp), ralp->al_off, nlen, nlsn);
- AB_ADDAL(rabp);
- }
-
- ralp->al_len -= nlen;
- ralp->al_off += nlen;
- } else {
- printf("hpfs_addextentr: INTERNAL INCONSISTENCE\n");
- error = (EINVAL);
- goto fail;
- }
- }
- }
-
- /*
- * Split AlBlk if overflowed.
- */
- if (rabp->ab_freecnt <= 0) {
- struct buf *nbp;
- alsec_t * nrasp;
-
- dprintf(("hpfs_addextentr: overflow, split\n"));
-
- error = hpfs_splitalsec (hpmp, rasp, &nrasp, &nbp);
- if (error) {
- printf("hpfs_addextent: CAN'T SPLIT\n");
- goto fail;
- }
-
- if (rabp->ab_flag & AB_NODES) {
- int i;
- alsec_t * asp;
- alnode_t * anp;
- struct buf * bp;
-
- ranp[0].an_nextoff =
- AB_LASTANP(&rasp->as_ab)->an_nextoff;
-
- /* We need to set left subtree's last entry
- * offset to 0xFFFFFFFF for OS/2 to be able
- * to read our files. It treats absence of
- * 0xFFFFFFFF as error.
- */
- AB_LASTANP(&rasp->as_ab)->an_nextoff = ~0;
-
- /* We need to fix new allocated AlSec's
- * children, becouse their parent has changed.
- */
- anp = AB_ALNODE(&nrasp->as_ab);
- for (i=0; i<nrasp->as_ab.ab_busycnt; i++) {
- error = hpfs_breadalsec(hpmp, anp->an_lsn, &bp);
- if (error) {
- brelse(nbp);
- goto fail;
- }
-
- asp = (alsec_t *)bp->b_data;
- asp->as_parent = nrasp->as_self;
-
- bdwrite(bp);
- anp ++;
- }
- } else {
- ranp[0].an_nextoff =
- AB_ALLEAF(&nrasp->as_ab)->al_off;
- }
-
- ranp[0].an_lsn = rasp->as_self;
- ranp[1].an_nextoff = ~0;
- ranp[1].an_lsn = nrasp->as_self;
-
- bdwrite(nbp);
-
- *resp = AE_SPLIT;
- wb = 1;
- }
-
- if (wb)
- bdwrite (rbp);
- else
- brelse(rbp);
-
- return (0);
-
-fail:
- brelse(rbp);
-
- return (error);
-}
-
-/*
- * Recursive routine walking down the b-tree and deallocating all
- * extents above bn. Returns *resp != 0 if alblk was totally
- * deallocated and may be freed. Tries to keep b-tree.
- *
- * (XXXX) NOTE! THIS ROUTINE WILL NEVER DECREMENT DEPTH OF
- * THE TREE.
- */
-int
-hpfs_truncatealblk (
- struct hpfsmount *hpmp,
- alblk_t *abp,
- lsn_t bn,
- int *resp)
-{
- int error;
- alleaf_t *alp;
- alnode_t *anp;
- alsec_t *asp;
- struct buf *bp;
-
- dprintf(("hpfs_truncatealblk: AlBlk: [0x%x,0x%x, 0x%x]\n",
- abp->ab_freecnt, abp->ab_busycnt, abp->ab_flag));
-
- if (abp->ab_flag & AB_NODES) {
- /*
- * Scan array of AlNodes backward,
- * diving in recursion if needed
- */
- anp = AB_LASTANP(abp);
-
- while (abp->ab_busycnt && (bn <= anp->an_nextoff)) {
- dprintf(("hpfs_truncatealblk: AlNode: [0x%x,0x%x] \n",
- anp->an_nextoff,anp->an_lsn));
-
- error = hpfs_breadalsec(hpmp, anp->an_lsn, &bp);
- if (error)
- return (error);
-
- asp = (alsec_t *)bp->b_data;
-
- error = hpfs_truncatealblk (hpmp,
- &asp->as_ab, bn, resp);
- if (error) {
- brelse(bp);
- return (error);
- }
-
- if (*resp) {
- brelse (bp);
-
- error = hpfs_bmmarkfree(hpmp,
- anp->an_lsn, 1);
- if (error)
- return (error);
-
- AB_RMAN(abp);
- anp --;
- } else {
- /*
- * We have deallocated some entries, some space
- * migth been freed, then try to concat two
- * last AlSec.
- */
- anp->an_nextoff = ~0;
- if (abp->ab_busycnt >= 2) {
- alsec_t *as0p;
- struct buf *b0p;
-
- error = hpfs_breadalsec(hpmp,
- (anp-1)->an_lsn, &b0p);
- if (error)
- return (error);
-
- as0p = (alsec_t *)b0p->b_data;
- error = hpfs_concatalsec(hpmp,
- as0p, asp, anp - 1);
- if (error == ENOSPC) {
- /* Not enought space */
- brelse (b0p);
- bdwrite (bp);
- } else if (error == 0) {
- /* All OK */
- (anp-1)->an_nextoff = anp->an_nextoff;
-
- bdwrite (b0p);
- brelse (bp);
-
- error = hpfs_bmmarkfree(hpmp,
- anp->an_lsn, 1);
- if (error)
- return (error);
-
- AB_RMAN(abp);
- } else {
- /* True error */
- brelse (b0p);
- brelse (bp);
- return (error);
- }
- } else {
- /* Nowhere to concatenate */
- bdwrite (bp);
- }
-
- /* There can not be any more entries
- * over greater bn, becouse last AlSec
- * wasn't freed totally. So go out.
- */
- break;
- }
- }
-
- if (abp->ab_busycnt == 0)
- *resp = 1;
- else
- *resp = 0;
- } else {
- /*
- * Scan array of AlLeafs backward,
- * free all above bn.
- */
- alp = AB_LASTALP(abp);
-
- while (abp->ab_busycnt && (bn < alp->al_off + alp->al_len)){
- dprintf(("hpfs_truncatealblk: AlLeaf: [0x%x,0x%x,0x%x] \n",
- alp->al_off,alp->al_len,alp->al_lsn));
-
- if (bn <= alp->al_off) {
- error = hpfs_bmmarkfree(hpmp, alp->al_lsn,
- alp->al_len);
- if (error)
- return (error);
-
- AB_RMAL(abp);
- alp --;
- } else if ((bn > alp->al_off) &&
- (bn < alp->al_off + alp->al_len)){
- error = hpfs_bmmarkfree(hpmp,
- alp->al_lsn + bn - alp->al_off,
- alp->al_len - bn + alp->al_off);
- if (error)
- return (error);
-
- alp->al_len = bn - alp->al_off;
-
- break;
- } else
- break;
- }
- }
-
- /* Signal parent deallocation, if need */
- if (abp->ab_busycnt == 0)
- *resp = 1;
- else
- *resp = 0;
-
- return (0);
-}
diff --git a/sys/fs/hpfs/hpfs_ioctl.h b/sys/fs/hpfs/hpfs_ioctl.h
deleted file mode 100644
index 7f60729..0000000
--- a/sys/fs/hpfs/hpfs_ioctl.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*-
- * Copyright (c) 1998, 1999 Semen Ustimenko (semenu@FreeBSD.org)
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#ifndef _HPFS_IOCTL_H_
-#define _HPFS_IOCTL_H_
-#include <sys/ioccom.h>
-
-struct hpfs_rdea {
- u_long ea_no;
- u_long ea_sz;
- void * ea_data;
-};
-
-#define HPFSIOCGEANUM _IOR('H', 0, u_long) /* Get EA number */
-#define HPFSIOCGEASZ _IOWR('H', 1, u_long) /* Get EA size */
-#define HPFSIOCRDEA _IOWR('H', 2, struct hpfs_rdea) /* Read EA */
-
-#endif
diff --git a/sys/fs/hpfs/hpfs_lookup.c b/sys/fs/hpfs/hpfs_lookup.c
deleted file mode 100644
index 88542cb..0000000
--- a/sys/fs/hpfs/hpfs_lookup.c
+++ /dev/null
@@ -1,213 +0,0 @@
-/*-
- * Copyright (c) 1998, 1999 Semen Ustimenko (semenu@FreeBSD.org)
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/proc.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <sys/namei.h>
-#include <sys/malloc.h>
-#include <sys/bio.h>
-#include <sys/buf.h>
-
-#include <fs/hpfs/hpfs.h>
-#include <fs/hpfs/hpfsmount.h>
-#include <fs/hpfs/hpfs_subr.h>
-
-int hpfs_removedirent (struct hpfsmount *, lsn_t, char *, int, int *);
-
-/*
- * This routine traverse the b+ tree representing directory
- * looking for file named 'name'. Returns buf struct and hpfsdirent
- * pointer. Calling routine is supposed to brelse buffer.
- * name is supposed in Unix encodeing.
- */
-int
-hpfs_genlookupbyname (
- struct hpfsnode *dhp,
- char *name,
- int namelen,
- struct buf **bpp,
- struct hpfsdirent **depp)
-{
- struct hpfsmount *hpmp = dhp->h_hpmp;
- struct buf *bp;
- struct dirblk *dp;
- struct hpfsdirent *dep;
- lsn_t lsn;
- int error, res;
-
- dprintf(("hpfs_genlookupbyname(0x%x, %s (%d)): \n",
- dhp->h_no, name, namelen));
-
- lsn = ((alleaf_t *)dhp->h_fn.fn_abd)->al_lsn;
-dive:
- error = hpfs_breaddirblk (hpmp, lsn, &bp);
- if (error)
- return (error);
-
- dp = (struct dirblk *) bp->b_data;
- dep = D_DIRENT(dp);
-
- while(!(dep->de_flag & DE_END)) {
- dprintf(("no: 0x%x, size: %d, name: %2d:%.*s, flag: 0x%x\n",
- dep->de_fnode, dep->de_size, dep->de_namelen,
- dep->de_namelen, dep->de_name, dep->de_flag));
-
- res = hpfs_cmpfname(hpmp, name, namelen,
- dep->de_name, dep->de_namelen, dep->de_cpid);
- if (res == 0) {
- *bpp = bp;
- *depp = dep;
- return (0);
- } else if (res < 0)
- break;
-
- dep = (hpfsdirent_t *)(((caddr_t)dep) + dep->de_reclen);
- }
-
- if (dep->de_flag & DE_DOWN) {
- lsn = DE_DOWNLSN(dep);
- brelse(bp);
- goto dive;
- }
-
- brelse(bp);
-
- return (ENOENT);
-}
-
-int
-hpfs_makefnode (
- struct vnode * dvp,
- struct vnode ** vpp,
- struct componentname *cnp,
- struct vattr *vap)
-{
-#ifdef HPFS_DEBUG
- register struct hpfsnode *dhp = VTOHP(dvp);
- dprintf(("hpfs_makefnode(0x%x, %s, %ld): \n",
- dhp->h_no, cnp->cn_nameptr, cnp->cn_namelen));
-#endif
-
- return (EOPNOTSUPP);
-}
-
-int
-hpfs_removedirent (
- struct hpfsmount *hpmp,
- lsn_t lsn,
- char *name,
- int namelen,
- int *retp)
-{
-#if 0
- struct buf *bp;
- dirblk_t *dbp;
- struct hpfsdirent *dep;
- int deoff;
- int error, ret;
-
- dprintf(("hpfs_removedirent(0x%x, %.*s, %d): \n",
- lsn, namelen, name, namelen));
-
- error = hpfs_breaddirblk (hpmp, lsn, &bp);
- if (error)
- return (error);
-
- dbp = (dirblk_t *) bp->b_data;
- deoff = sizeof(dirblk_t);
- dep = DB_DIRENT(dbp);
-
- while(!(dep->de_flag & DE_END)) {
- dprintf(("no: 0x%x, size: %d, name: %2d:%.*s, flag: 0x%x\n",
- dep->de_fnode, dep->de_size, dep->de_namelen,
- dep->de_namelen, dep->de_name, dep->de_flag));
-
- res = hpfs_cmpfname(hpmp, name, namelen,
- dep->de_name, dep->de_namelen, dep->de_cpid);
- if (res == 0) {
- if (dep->de_flag & DE_DOWN) {
- /*XXXXXX*/
- } else {
- /* XXX we can copy less */
- bcopy (DE_NEXTDE(dep), dep, DB_BSIZE - deoff - dep->de_reclen);
- dbp->d_freeoff -= dep->de_reclen;
- *retp = 0;
- }
- bdwrite (bp);
- return (0);
- } else if (res < 0)
- break;
-
- deoff += dep->de_reclen;
- dep = DB_NEXTDE(dep);
- }
-
- if (dep->de_flag & DE_DOWN) {
- error = hpfs_removede (hpmp, DE_DOWNLSN(dep), name, namelen, &ret);
- if (error) {
- brelse (bp);
- return (error);
- }
- if (ret == 0) {
- if (deoff > sizeof (dirblk_t)) {
- } else if (deoff + dep->de_reclen < dbp->db_freeoff) {
- }
- }
- } else {
- error = ENOENT;
- }
-
- brelse (bp);
- return (error);
-#endif
- return (EOPNOTSUPP);
-}
-
-int
-hpfs_removefnode (
- struct vnode * dvp,
- struct vnode * vp,
- struct componentname *cnp)
-{
-#ifdef HPFS_DEBUG
- register struct hpfsnode *dhp = VTOHP(dvp);
- register struct hpfsnode *hp = VTOHP(vp);
- dprintf(("hpfs_removefnode(0x%x, 0x%x, %s, %ld): \n",
- dhp->h_no, hp->h_no, cnp->cn_nameptr, cnp->cn_namelen));
-#endif
-
-
- return (EOPNOTSUPP);
-}
diff --git a/sys/fs/hpfs/hpfs_subr.c b/sys/fs/hpfs/hpfs_subr.c
deleted file mode 100644
index c7fe94f..0000000
--- a/sys/fs/hpfs/hpfs_subr.c
+++ /dev/null
@@ -1,869 +0,0 @@
-/*-
- * Copyright (c) 1998, 1999 Semen Ustimenko (semenu@FreeBSD.org)
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/proc.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <sys/namei.h>
-#include <sys/malloc.h>
-#include <sys/bio.h>
-#include <sys/buf.h>
-
-#include <fs/hpfs/hpfs.h>
-#include <fs/hpfs/hpfsmount.h>
-#include <fs/hpfs/hpfs_subr.h>
-
-u_long
-hpfs_checksum(
- u_int8_t *object,
- int size)
-{
- register int i;
- u_long csum=0L;
- for (i=0; i < size; i++) {
- csum += (u_long) *object++;
- csum = (csum << 7) + (csum >> (25));
- }
- return (csum);
-}
-
-void
-hpfs_bmdeinit(
- struct hpfsmount *hpmp)
-{
- struct buf *bp;
- int i;
-
- dprintf(("hpmp_bmdeinit: "));
-
- if (!(hpmp->hpm_mp->mnt_flag & MNT_RDONLY)) {
- /*
- * Write down BitMap.
- */
- for (i=0; i<hpmp->hpm_dbnum; i++) {
- dprintf(("[%d: 0x%x] ", i, hpmp->hpm_bmind[i]));
-
- bp = getblk(hpmp->hpm_devvp, hpmp->hpm_bmind[i],
- BMSIZE, 0, 0, 0);
- clrbuf(bp);
-
- bcopy(hpmp->hpm_bitmap + BMSIZE * i, bp->b_data,
- BMSIZE);
-
- bwrite(bp);
- }
- }
-
- free(hpmp->hpm_bitmap,M_HPFSMNT);
- free(hpmp->hpm_bmind,M_HPFSMNT);
-
- dprintf(("\n"));
-}
-
-/*
- * Initialize BitMap management, includes calculation of
- * available blocks number.
- */
-int
-hpfs_bminit(
- struct hpfsmount *hpmp)
-{
- struct buf *bp;
- int error, i, k;
- u_long dbavail;
-
- dprintf(("hpfs_bminit: "));
-
- hpmp->hpm_dbnum = (hpmp->hpm_su.su_btotal + 0x3FFF) / 0x4000;
-
- dprintf(("0x%lx data bands, ", hpmp->hpm_dbnum));
-
- hpmp->hpm_bmind = malloc(hpmp->hpm_dbnum * sizeof(lsn_t),
- M_HPFSMNT, M_WAITOK);
-
- hpmp->hpm_bitmap = malloc(hpmp->hpm_dbnum * BMSIZE,
- M_HPFSMNT, M_WAITOK);
-
- error = bread(hpmp->hpm_devvp, hpmp->hpm_su.su_bitmap.lsn1,
- ((hpmp->hpm_dbnum + 0x7F) & ~(0x7F)) << 2, NOCRED, &bp);
- if (error) {
- brelse(bp);
- free(hpmp->hpm_bitmap, M_HPFSMNT);
- free(hpmp->hpm_bmind, M_HPFSMNT);
- dprintf((" error %d\n", error));
- return (error);
- }
- bcopy(bp->b_data, hpmp->hpm_bmind, hpmp->hpm_dbnum * sizeof(lsn_t));
-
- brelse(bp);
-
- /*
- * Read in all BitMap
- */
- for (i=0; i<hpmp->hpm_dbnum; i++) {
- dprintf(("[%d: 0x%x] ", i, hpmp->hpm_bmind[i]));
-
- error = bread(hpmp->hpm_devvp, hpmp->hpm_bmind[i],
- BMSIZE, NOCRED, &bp);
- if (error) {
- brelse(bp);
- free(hpmp->hpm_bitmap, M_HPFSMNT);
- free(hpmp->hpm_bmind, M_HPFSMNT);
- dprintf((" error %d\n", error));
- return (error);
- }
- bcopy(bp->b_data, hpmp->hpm_bitmap + BMSIZE * i, BMSIZE);
-
- brelse(bp);
- }
-
- /*
- * Look througth BitMap and count free bits
- */
- dbavail = 0;
- for (i=0; i < hpmp->hpm_su.su_btotal >> 5; i++) {
- register u_int32_t mask;
- for (k=0, mask=1; k < 32; k++, mask<<=1)
- if(((u_int32_t *)hpmp->hpm_bitmap)[i] & mask)
- dbavail ++;
-
- }
- hpmp->hpm_bavail = dbavail;
-
- return (0);
-}
-
-int
-hpfs_cmpfname (
- struct hpfsmount *hpmp,
- char * uname,
- int ulen,
- char * dname,
- int dlen,
- u_int16_t cp)
-{
- register int i, res;
-
- for (i = 0; i < ulen && i < dlen; i++) {
- res = hpfs_toupper(hpmp, hpfs_u2d(hpmp, uname[i]), cp) -
- hpfs_toupper(hpmp, dname[i], cp);
- if (res)
- return res;
- }
- return (ulen - dlen);
-}
-
-int
-hpfs_cpstrnnicmp (
- struct hpfsmount *hpmp,
- char * str1,
- int str1len,
- u_int16_t str1cp,
- char * str2,
- int str2len,
- u_int16_t str2cp)
-{
- int i, res;
-
- for (i = 0; i < str1len && i < str2len; i++) {
- res = (int)hpfs_toupper(hpmp, ((u_char *)str1)[i], str1cp) -
- (int)hpfs_toupper(hpmp, ((u_char *)str2)[i], str2cp);
- if (res)
- return res;
- }
- return (str1len - str2len);
-}
-
-
-int
-hpfs_cpload (
- struct hpfsmount *hpmp,
- struct cpiblk *cpibp,
- struct cpdblk *cpdbp)
-{
- struct buf *bp;
- struct cpdsec * cpdsp;
- int error, i;
-
- error = bread(hpmp->hpm_devvp, cpibp->b_cpdsec, DEV_BSIZE, NOCRED, &bp);
- if (error) {
- brelse(bp);
- return (error);
- }
-
- cpdsp = (struct cpdsec *)bp->b_data;
-
- for (i=cpdsp->d_cpfirst; i<cpdsp->d_cpcnt; i++) {
- if (cpdsp->d_cpdblk[i].b_cpid == cpibp->b_cpid) {
- bcopy(cpdsp->d_cpdblk + i, cpdbp,
- sizeof(struct cpdblk));
-
- brelse(bp);
-
- return (0);
- }
- }
-
- brelse(bp);
-
- return (ENOENT);
-}
-
-
-/*
- * Initialize Code Page information management.
- * Load all copdepages in memory.
- */
-int
-hpfs_cpinit (
- struct mount *mp,
- struct hpfsmount *hpmp)
-{
- struct buf *bp;
- int error, i;
- lsn_t lsn;
- int cpicnt;
- struct cpisec * cpisp;
- struct cpiblk * cpibp;
- struct cpdblk * cpdbp;
-
- dprintf(("hpfs_cpinit: \n"));
-
- error = vfs_copyopt(mp->mnt_optnew, "d2u", hpmp->hpm_d2u,
- sizeof hpmp->hpm_d2u);
- if (error == ENOENT)
- for (i=0x0; i<0x80;i++)
- hpmp->hpm_d2u[i] = i + 0x80;
- else if (error)
- return (error);
-
- error = vfs_copyopt(mp->mnt_optnew, "u2d", hpmp->hpm_u2d,
- sizeof hpmp->hpm_u2d);
- if (error == ENOENT)
- for (i=0x0; i<0x80;i++)
- hpmp->hpm_u2d[i] = i + 0x80;
- else if (error)
- return (error);
-
- cpicnt = hpmp->hpm_sp.sp_cpinum;
-
- hpmp->hpm_cpdblk = malloc(cpicnt * sizeof(struct cpdblk),
- M_HPFSMNT, M_WAITOK);
-
- cpdbp = hpmp->hpm_cpdblk;
- lsn = hpmp->hpm_sp.sp_cpi;
-
- while (cpicnt > 0) {
- error = bread(hpmp->hpm_devvp, lsn, DEV_BSIZE, NOCRED, &bp);
- if (error) {
- brelse(bp);
- return (error);
- }
-
- cpisp = (struct cpisec *)bp->b_data;
-
- cpibp = cpisp->s_cpi;
- for (i=0; i<cpisp->s_cpicnt; i++, cpicnt --, cpdbp++, cpibp++) {
- dprintf(("hpfs_cpinit: Country: %d, CP: %d (%d)\n",
- cpibp->b_country, cpibp->b_cpid,
- cpibp->b_vcpid));
-
- error = hpfs_cpload(hpmp, cpibp, cpdbp);
- if (error) {
- brelse(bp);
- return (error);
- }
- }
- lsn = cpisp->s_next;
- brelse(bp);
- }
-
- return (0);
-}
-
-int
-hpfs_cpdeinit (
- struct hpfsmount *hpmp)
-{
- dprintf(("hpmp_cpdeinit: "));
- free(hpmp->hpm_cpdblk,M_HPFSMNT);
- return (0);
-}
-
-/*
- * Lookup for a run of blocks.
- */
-int
-hpfs_bmlookup (
- struct hpfsmount *hpmp,
- u_long flags, /* 1 means we want right len blocks in run, not less */
- lsn_t lsn, /* We want near this one */
- u_long len, /* We want such long */
- lsn_t *lsnp, /* We got here */
- u_long *lenp) /* We got this long */
-{
- u_int32_t * bitmap;
- register u_int32_t mask;
- int i,k;
- int cband, vcband;
- u_int bandsz;
- int count;
-
- dprintf(("hpfs_bmlookup: lsn: 0x%x, len 0x%lx | Step1\n", lsn, len));
-
- if (lsn > hpmp->hpm_su.su_btotal) {
- printf("hpfs_bmlookup: OUT OF VOLUME\n");
- return ENOSPC;
- }
- if (len > hpmp->hpm_bavail) {
- printf("hpfs_bmlookup: OUT OF SPACE\n");
- return ENOSPC;
- }
- i = lsn >> 5;
- k = lsn & 0x1F;
- mask = 1 << k;
- bitmap = (u_int32_t *)hpmp->hpm_bitmap + i;
-
- if (*bitmap & mask) {
- *lsnp = lsn;
- *lenp = 0;
- for (; k < 32; k++, mask<<=1) {
- if (*bitmap & mask)
- (*lenp) ++;
- else {
- if (flags & 1)
- goto step2;
- else
- return (0);
- }
-
- if (*lenp == len)
- return (0);
- }
-
- bitmap++;
- i++;
- for (; i < hpmp->hpm_su.su_btotal >> 5; i++, bitmap++) {
- for (k=0, mask=1; k < 32; k++, mask<<=1) {
- if (*bitmap & mask)
- (*lenp) ++;
- else {
- if (flags & 1)
- goto step2;
- else
- return (0);
- }
-
- if (*lenp == len)
- return (0);
- }
- }
- return (0);
- }
-
-step2:
- /*
- * Lookup all bands begining from cband, lookup for first block
- */
- cband = (lsn >> 14);
- dprintf(("hpfs_bmlookup: Step2: band 0x%x (0x%lx)\n",
- cband, hpmp->hpm_dbnum));
- for (vcband = 0; vcband < hpmp->hpm_dbnum; vcband ++, cband++) {
- cband = cband % hpmp->hpm_dbnum;
- bandsz = min (hpmp->hpm_su.su_btotal - (cband << 14), 0x4000);
- dprintf(("hpfs_bmlookup: band: %d, sz: 0x%x\n", cband, bandsz));
-
- bitmap = (u_int32_t *)hpmp->hpm_bitmap + (cband << 9);
- *lsnp = cband << 14;
- *lenp = 0;
- count = 0;
- for (i=0; i < bandsz >> 5; i++, bitmap++) {
- for (k=0, mask=1; k < 32; k++, mask<<=1) {
- if (*bitmap & mask) {
- if (count) {
- (*lenp) ++;
- } else {
- count = 1;
- *lsnp = (cband << 14) + (i << 5) + k;
- *lenp = 1;
- }
- } else {
- if ((*lenp) && !(flags & 1)) {
- return (0);
- } else {
- count = 0;
- }
- }
-
- if (*lenp == len)
- return (0);
- }
- }
- if (cband == hpmp->hpm_dbnum - 1) {
- if ((*lenp) && !(flags & 1)) {
- return (0);
- } else {
- count = 0;
- }
- }
- }
-
- return (ENOSPC);
-}
-
-/*
- * Lookup a single free block. XXX Need locking on BitMap operations
- * VERY STUPID ROUTINE!!!
- */
-int
-hpfs_bmfblookup (
- struct hpfsmount *hpmp,
- lsn_t *lp)
-{
- u_int32_t * bitmap;
- int i,k;
-
- dprintf(("hpfs_bmfblookup: "));
-
- bitmap = (u_int32_t *)hpmp->hpm_bitmap;
- for (i=0; i < hpmp->hpm_su.su_btotal >> 5; i++, bitmap++) {
- k = ffs(*bitmap);
- if (k) {
- *lp = (i << 5) + k - 1;
- dprintf((" found: 0x%x\n",*lp));
- return (0);
- }
- }
-
- return (ENOSPC);
-}
-
-/*
- * Mark contignous block of blocks.
- */
-int
-hpfs_bmmark (
- struct hpfsmount *hpmp,
- lsn_t bn,
- u_long bl,
- int state)
-{
- u_int32_t * bitmap;
- int i, didprint = 0;
-
- dprintf(("hpfs_bmmark(0x%x, 0x%lx, %d): \n",bn,bl, state));
-
- if ((bn > hpmp->hpm_su.su_btotal) || (bn+bl > hpmp->hpm_su.su_btotal)) {
- printf("hpfs_bmmark: MARKING OUT OF VOLUME\n");
- return 0;
- }
- bitmap = (u_int32_t *)hpmp->hpm_bitmap;
- bitmap += bn >> 5;
-
- while (bl > 0) {
- for (i = bn & 0x1F; (i < 0x20) && (bl > 0) ; i++, bl--) {
- if (state) {
- if ( *bitmap & (1 << i)) {
- if (!didprint) {
- printf("hpfs_bmmark: ALREADY FREE\n");
- didprint = 1;
- }
- } else
- hpmp->hpm_bavail++;
-
- *bitmap |= (1 << i);
- } else {
- if ((~(*bitmap)) & (1 << i)) {
- if (!didprint) {
- printf("hpfs_bmmark: ALREADY BUSY\n");
- didprint = 1;
- }
- } else
- hpmp->hpm_bavail--;
-
- *bitmap &= ~(1 << i);
- }
- }
- bn = 0;
- bitmap++;
- }
-
- return (0);
-}
-
-
-int
-hpfs_validateparent (
- struct hpfsnode *hp)
-{
- struct hpfsnode *dhp;
- struct vnode *dvp;
- struct hpfsmount *hpmp = hp->h_hpmp;
- struct buf *bp;
- struct dirblk *dp;
- struct hpfsdirent *dep;
- lsn_t lsn, olsn;
- int level, error;
-
- dprintf(("hpfs_validatetimes(0x%x): [parent: 0x%x] ",
- hp->h_no, hp->h_fn.fn_parent));
-
- if (hp->h_no == hp->h_fn.fn_parent) {
- dhp = hp;
- } else {
- error = VFS_VGET(hpmp->hpm_mp, hp->h_fn.fn_parent,
- LK_EXCLUSIVE, &dvp);
- if (error)
- return (error);
- dhp = VTOHP(dvp);
- }
-
- lsn = ((alleaf_t *)dhp->h_fn.fn_abd)->al_lsn;
-
- olsn = 0;
- level = 1;
- bp = NULL;
-
-dive:
- dprintf(("[dive 0x%x] ", lsn));
- if (bp != NULL)
- brelse(bp);
- error = bread(dhp->h_devvp, lsn, D_BSIZE, NOCRED, &bp);
- if (error)
- goto failed;
-
- dp = (struct dirblk *) bp->b_data;
- if (dp->d_magic != D_MAGIC) {
- printf("hpfs_validatetimes: magic doesn't match\n");
- error = EINVAL;
- goto failed;
- }
-
- dep = D_DIRENT(dp);
-
- if (olsn) {
- dprintf(("[restore 0x%x] ", olsn));
-
- while(!(dep->de_flag & DE_END) ) {
- if((dep->de_flag & DE_DOWN) &&
- (olsn == DE_DOWNLSN(dep)))
- break;
- dep = (hpfsdirent_t *)((caddr_t)dep + dep->de_reclen);
- }
-
- if((dep->de_flag & DE_DOWN) && (olsn == DE_DOWNLSN(dep))) {
- if (dep->de_flag & DE_END)
- goto blockdone;
-
- if (hp->h_no == dep->de_fnode) {
- dprintf(("[found] "));
- goto readdone;
- }
-
- dep = (hpfsdirent_t *)((caddr_t)dep + dep->de_reclen);
- } else {
- printf("hpfs_validatetimes: ERROR! oLSN not found\n");
- error = EINVAL;
- goto failed;
- }
- }
-
- olsn = 0;
-
- while(!(dep->de_flag & DE_END)) {
- if(dep->de_flag & DE_DOWN) {
- lsn = DE_DOWNLSN(dep);
- level++;
- goto dive;
- }
-
- if (hp->h_no == dep->de_fnode) {
- dprintf(("[found] "));
- goto readdone;
- }
-
- dep = (hpfsdirent_t *)((caddr_t)dep + dep->de_reclen);
- }
-
- if(dep->de_flag & DE_DOWN) {
- dprintf(("[enddive] "));
- lsn = DE_DOWNLSN(dep);
- level++;
- goto dive;
- }
-
-blockdone:
- dprintf(("[EOB] "));
- olsn = lsn;
- lsn = dp->d_parent;
- level--;
- dprintf(("[level %d] ", level));
- if (level > 0)
- goto dive; /* undive really */
-
- goto failed;
-
-readdone:
- bcopy(dep->de_name,hp->h_name,dep->de_namelen);
- hp->h_name[dep->de_namelen] = '\0';
- hp->h_namelen = dep->de_namelen;
- hp->h_ctime = dep->de_ctime;
- hp->h_atime = dep->de_atime;
- hp->h_mtime = dep->de_mtime;
- hp->h_flag |= H_PARVALID;
-
- dprintf(("[readdone]"));
-
-failed:
- dprintf(("\n"));
- if (bp != NULL)
- brelse(bp);
- if (hp != dhp)
- vput(dvp);
-
- return (error);
-}
-
-struct timespec
-hpfstimetounix (
- u_long hptime)
-{
- struct timespec t;
-
- t.tv_nsec = 0;
- t.tv_sec = hptime;
-
- return t;
-}
-
-/*
- * Write down changes done to parent dir, these are only times for now.
- * hpfsnode have to be locked.
- */
-int
-hpfs_updateparent (
- struct hpfsnode *hp)
-{
- struct hpfsnode *dhp;
- struct vnode *dvp;
- struct hpfsdirent *dep;
- struct buf * bp;
- int error;
-
- dprintf(("hpfs_updateparent(0x%x): \n", hp->h_no));
-
- if (!(hp->h_flag & H_PARCHANGE))
- return (0);
-
- if (!(hp->h_flag & H_PARVALID)) {
- error = hpfs_validateparent (hp);
- if (error)
- return (error);
- }
-
- if (hp->h_no == hp->h_fn.fn_parent) {
- dhp = hp;
- } else {
- error = VFS_VGET(hp->h_hpmp->hpm_mp, hp->h_fn.fn_parent,
- LK_EXCLUSIVE, &dvp);
- if (error)
- return (error);
- dhp = VTOHP(dvp);
- }
-
- error = hpfs_genlookupbyname (dhp, hp->h_name, hp->h_namelen,
- &bp, &dep);
- if (error) {
- goto failed;
- }
-
- dep->de_atime = hp->h_atime;
- dep->de_mtime = hp->h_mtime;
- dep->de_size = hp->h_fn.fn_size;
-
- bdwrite (bp);
-
- hp->h_flag &= ~H_PARCHANGE;
-
- error = 0;
-failed:
- if (hp != dhp)
- vput(dvp);
-
- return (0);
-}
-
-/*
- * Write down on disk changes done to fnode. hpfsnode have to be locked.
- */
-int
-hpfs_update (
- struct hpfsnode *hp)
-{
- struct buf * bp;
-
- dprintf(("hpfs_update(0x%x): \n", hp->h_no));
-
- if (!(hp->h_flag & H_CHANGE))
- return (0);
-
- bp = getblk(hp->h_devvp, hp->h_no, FNODESIZE, 0, 0, 0);
- clrbuf(bp);
-
- bcopy (&hp->h_fn, bp->b_data, sizeof(struct fnode));
- bdwrite (bp);
-
- hp->h_flag &= ~H_CHANGE;
-
- if (hp->h_flag & H_PARCHANGE)
- return (hpfs_updateparent(hp));
-
- return (0);
-}
-
-/*
- * Truncate file to specifed size. hpfsnode have to be locked.
- */
-int
-hpfs_truncate (
- struct hpfsnode *hp,
- u_long size)
-{
- struct hpfsmount *hpmp = hp->h_hpmp;
- lsn_t newblen, oldblen;
- int error, pf;
-
- dprintf(("hpfs_truncate(0x%x, 0x%x -> 0x%lx): ",
- hp->h_no, hp->h_fn.fn_size, size));
-
- newblen = (size + DEV_BSIZE - 1) >> DEV_BSHIFT;
- oldblen = (hp->h_fn.fn_size + DEV_BSIZE - 1) >> DEV_BSHIFT;
-
- dprintf(("blen: 0x%x -> 0x%x\n", oldblen, newblen));
-
- error = hpfs_truncatealblk (hpmp, &hp->h_fn.fn_ab, newblen, &pf);
- if (error)
- return (error);
- if (pf) {
- hp->h_fn.fn_ab.ab_flag = 0;
- hp->h_fn.fn_ab.ab_freecnt = 0x8;
- hp->h_fn.fn_ab.ab_busycnt = 0x0;
- hp->h_fn.fn_ab.ab_freeoff = sizeof(alblk_t);
- }
-
- hp->h_fn.fn_size = size;
-
- hp->h_flag |= (H_CHANGE | H_PARCHANGE);
-
- dprintf(("hpfs_truncate: successful\n"));
-
- return (0);
-}
-
-/*
- * Enlarge file to specifed size. hpfsnode have to be locked.
- */
-int
-hpfs_extend (
- struct hpfsnode *hp,
- u_long size)
-{
- struct hpfsmount *hpmp = hp->h_hpmp;
- lsn_t newblen, oldblen;
- int error;
-
- dprintf(("hpfs_extend(0x%x, 0x%x -> 0x%lx): ",
- hp->h_no, hp->h_fn.fn_size, size));
-
- if (hpmp->hpm_bavail < 0x10)
- return (ENOSPC);
-
- newblen = (size + DEV_BSIZE - 1) >> DEV_BSHIFT;
- oldblen = (hp->h_fn.fn_size + DEV_BSIZE - 1) >> DEV_BSHIFT;
-
- dprintf(("blen: 0x%x -> 0x%x\n", oldblen, newblen));
-
- error = hpfs_addextent(hpmp, hp, newblen - oldblen);
- if (error) {
- printf("hpfs_extend: FAILED TO ADD EXTENT %d\n", error);
- return (error);
- }
-
- hp->h_fn.fn_size = size;
-
- hp->h_flag |= (H_CHANGE | H_PARCHANGE);
-
- dprintf(("hpfs_extend: successful\n"));
-
- return (0);
-}
-
-/*
- * Read AlSec structure, and check if magic is valid.
- * You don't need to brelse buf on error.
- */
-int
-hpfs_breadstruct (
- struct hpfsmount *hpmp,
- lsn_t lsn,
- u_int len,
- u_int32_t magic,
- struct buf **bpp)
-{
- struct buf *bp;
- u_int32_t *mp;
- int error;
-
- dprintf(("hpfs_breadstruct: reading at 0x%x\n", lsn));
-
- *bpp = NULL;
-
- error = bread(hpmp->hpm_devvp, lsn, len, NOCRED, &bp);
- if (error) {
- brelse(bp);
- return (error);
- }
- mp = (u_int32_t *) bp->b_data;
- if (*mp != magic) {
- brelse(bp);
- printf("hpfs_breadstruct: MAGIC DOESN'T MATCH (0x%08x != 0x%08x)\n",
- *mp, magic);
- return (EINVAL);
- }
-
- *bpp = bp;
-
- return (0);
-}
-
diff --git a/sys/fs/hpfs/hpfs_subr.h b/sys/fs/hpfs/hpfs_subr.h
deleted file mode 100644
index e8a24b4..0000000
--- a/sys/fs/hpfs/hpfs_subr.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/*-
- * Copyright (c) 1998, 1999 Semen Ustimenko (semenu@FreeBSD.org)
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#define hpfs_bmmarkfree(hpmp, bn,bl) hpfs_bmmark(hpmp, bn, bl, 1)
-#define hpfs_bmmarkbusy(hpmp, bn,bl) hpfs_bmmark(hpmp, bn, bl, 0)
-
-u_long hpfs_checksum (u_int8_t *, int);
-
-int hpfs_bminit (struct hpfsmount *);
-void hpfs_bmdeinit (struct hpfsmount *);
-int hpfs_bmfblookup (struct hpfsmount *, lsn_t *);
-int hpfs_bmmark (struct hpfsmount *, lsn_t, u_long, int);
-int hpfs_bmlookup (struct hpfsmount *, u_long, lsn_t, u_long,
- lsn_t *, u_long *);
-
-struct hpfs_args;
-int hpfs_cpinit (struct mount *, struct hpfsmount *);
-int hpfs_cpdeinit (struct hpfsmount *);
-int hpfs_cpload (struct hpfsmount *, struct cpiblk *,
- struct cpdblk *);
-int hpfs_cpstrnnicmp (struct hpfsmount *, char *, int, u_int16_t,
- char *, int, u_int16_t);
-int hpfs_cmpfname (struct hpfsmount *, char *, int,
- char *, int, u_int16_t);
-
-/* XXX Need unsigned conversion? */
-#define hpfs_u2d(hpmp, c) ((((u_char)(c))&0x80)?(hpmp->hpm_u2d[((u_char)(c))&0x7F]):((u_char)(c)))
-#define hpfs_d2u(hpmp, c) ((((u_char)(c))&0x80)?(hpmp->hpm_d2u[((u_char)(c))&0x7F]):((u_char)(c)))
-#define hpfs_toupper(hpmp, c, cp) ((((u_char)(c))&0x80) ? ((u_char)((hpmp)->hpm_cpdblk[(cp)].b_upcase[((u_char)(c))&0x7F])) : ((((u_char)(c)) >= 'a' && ((u_char)(c)) <='z')?(((u_char)(c))-'a'+'A'):((u_char)(c))))
-
-
-int hpfs_truncate (struct hpfsnode *, u_long);
-int hpfs_extend (struct hpfsnode *, u_long);
-
-int hpfs_updateparent (struct hpfsnode *);
-int hpfs_update (struct hpfsnode *);
-
-int hpfs_validateparent (struct hpfsnode *);
-struct timespec hpfstimetounix (u_long);
-int hpfs_genlookupbyname (struct hpfsnode *, char *, int,
- struct buf **, struct hpfsdirent **);
-
-int hpfs_makefnode (struct vnode *, struct vnode **,
- struct componentname *, struct vattr *);
-int hpfs_removefnode (struct vnode *, struct vnode *,
- struct componentname *);
-
-int hpfs_breadstruct (struct hpfsmount *, lsn_t, u_int, u_int32_t,
- struct buf **);
-#define hpfs_breadalsec(hpmp, lsn, bpp) \
- hpfs_breadstruct(hpmp, lsn, DEV_BSIZE, AS_MAGIC, bpp)
-#define hpfs_breaddirblk(hpmp, lsn, bpp) \
- hpfs_breadstruct(hpmp, lsn, D_BSIZE, D_MAGIC, bpp)
-
-#if 0
-#define hpfs_hplock(hp, p) \
- lockmgr(&(hp)->h_intlock, LK_EXCLUSIVE, (p))
-#define hpfs_hpunlock(hp, p) \
- lockmgr(&(hp)->h_intlock, LK_RELEASE, (p))
-#endif
-
-int hpfs_hpbmap (struct hpfsnode *, daddr_t, daddr_t *, int *);
-int hpfs_truncatealblk (struct hpfsmount *, alblk_t *, lsn_t,int *);
-int hpfs_addextent (struct hpfsmount *, struct hpfsnode *, u_long);
diff --git a/sys/fs/hpfs/hpfs_vfsops.c b/sys/fs/hpfs/hpfs_vfsops.c
deleted file mode 100644
index edc37b2..0000000
--- a/sys/fs/hpfs/hpfs_vfsops.c
+++ /dev/null
@@ -1,545 +0,0 @@
-/*-
- * Copyright (c) 1998, 1999 Semen Ustimenko (semenu@FreeBSD.org)
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/namei.h>
-#include <sys/conf.h>
-#include <sys/proc.h>
-#include <sys/kernel.h>
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <sys/bio.h>
-#include <sys/buf.h>
-#include <sys/fcntl.h>
-#include <sys/malloc.h>
-
-#include <geom/geom.h>
-#include <geom/geom_vfs.h>
-
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <vm/vm_page.h>
-#include <vm/vm_object.h>
-#include <vm/vm_extern.h>
-
-#include <fs/hpfs/hpfs.h>
-#include <fs/hpfs/hpfsmount.h>
-#include <fs/hpfs/hpfs_subr.h>
-
-MALLOC_DEFINE(M_HPFSMNT, "hpfs_mount", "HPFS mount structure");
-MALLOC_DEFINE(M_HPFSNO, "hpfs_node", "HPFS node structure");
-
-struct sockaddr;
-
-static int hpfs_mountfs(register struct vnode *, struct mount *,
- struct thread *);
-
-static vfs_fhtovp_t hpfs_fhtovp;
-static vfs_vget_t hpfs_vget;
-static vfs_cmount_t hpfs_cmount;
-static vfs_mount_t hpfs_mount;
-static vfs_root_t hpfs_root;
-static vfs_statfs_t hpfs_statfs;
-static vfs_unmount_t hpfs_unmount;
-
-static int
-hpfs_cmount (
- struct mntarg *ma,
- void *data,
- uint64_t flags)
-{
- struct hpfs_args args;
- struct export_args exp;
- int error;
-
- error = copyin(data, (caddr_t)&args, sizeof (struct hpfs_args));
- if (error)
- return (error);
- vfs_oexport_conv(&args.export, &exp);
-
- ma = mount_argsu(ma, "from", args.fspec, MAXPATHLEN);
- ma = mount_arg(ma, "export", &exp, sizeof(exp));
- ma = mount_argf(ma, "uid", "%d", args.uid);
- ma = mount_argf(ma, "gid", "%d", args.gid);
- ma = mount_argf(ma, "mode", "%d", args.mode);
- if (args.flags & HPFSMNT_TABLES) {
- ma = mount_arg(ma, "d2u", args.d2u, sizeof args.d2u);
- ma = mount_arg(ma, "u2d", args.u2d, sizeof args.u2d);
- }
-
- error = kernel_mount(ma, flags);
-
- return (error);
-}
-
-static const char *hpfs_opts[] = {
- "from", "export", "uid", "gid", "mode", "d2u", "u2d", NULL
-};
-
-static int
-hpfs_mount (struct mount *mp)
-{
- int err = 0, error;
- struct vnode *devvp;
- struct thread *td;
- struct nameidata ndp;
- struct export_args export;
- char *from;
-
- td = curthread;
- dprintf(("hpfs_omount():\n"));
- /*
- ***
- * Mounting non-root filesystem or updating a filesystem
- ***
- */
- if (vfs_filteropt(mp->mnt_optnew, hpfs_opts))
- return (EINVAL);
-
- from = vfs_getopts(mp->mnt_optnew, "from", &error);
- if (error)
- return (error);
-
- /*
- * If updating, check whether changing from read-only to
- * read/write; if there is no device name, that's all we do.
- */
- if (mp->mnt_flag & MNT_UPDATE) {
- dprintf(("hpfs_omount: MNT_UPDATE: "));
-
- if (from == NULL) {
- error = vfs_copyopt(mp->mnt_optnew, "export",
- &export, sizeof export);
- if (error)
- return (error);
- dprintf(("export 0x%x\n",args.export.ex_flags));
- err = vfs_export(mp, &export);
- if (err) {
- printf("hpfs_omount: vfs_export failed %d\n",
- err);
- }
- goto success;
- } else {
- dprintf(("name [FAILED]\n"));
- err = EINVAL;
- goto success;
- }
- dprintf(("\n"));
- }
-
- /*
- * Not an update, or updating the name: look up the name
- * and verify that it refers to a sensible block device.
- */
- NDINIT(&ndp, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE, from, td);
- err = namei(&ndp);
- if (err) {
- /* can't get devvp!*/
- goto error_1;
- }
-
- devvp = ndp.ni_vp;
-
- if (!vn_isdisk(devvp, &err)) {
- vput(devvp);
- return (err);
- }
-
- /*
- ********************
- * NEW MOUNT
- ********************
- */
-
- /*
- * Since this is a new mount, we want the names for
- * the device and the mount point copied in. If an
- * error occurs, the mountpoint is discarded by the
- * upper level code. Note that vfs_omount() handles
- * copying the mountpoint f_mntonname for us, so we
- * don't have to do it here unless we want to set it
- * to something other than "path" for some rason.
- */
- /* Save "mounted from" info for mount point (NULL pad)*/
- vfs_mountedfrom(mp, from);
-
- err = hpfs_mountfs(devvp, mp, td);
- if (err) {
- vrele(devvp);
- goto error_1;
- }
-
- goto success;
-
-error_1: /* no state to back out*/
- /* XXX: Missing NDFREE(&ndp, ...) */
-
-success:
- return( err);
-}
-
-/*
- * Common code for mount and mountroot
- */
-int
-hpfs_mountfs(devvp, mp, td)
- register struct vnode *devvp;
- struct mount *mp;
- struct thread *td;
-{
- int error, ronly, v;
- struct sublock *sup;
- struct spblock *spp;
- struct hpfsmount *hpmp;
- struct buf *bp = NULL;
- struct vnode *vp;
- struct cdev *dev = devvp->v_rdev;
- struct g_consumer *cp;
- struct bufobj *bo;
-
- if (mp->mnt_flag & MNT_ROOTFS)
- return (EOPNOTSUPP);
- dprintf(("hpfs_mountfs():\n"));
- ronly = (mp->mnt_flag & MNT_RDONLY) != 0;
- /* XXX: use VOP_ACCESS to check FS perms */
- DROP_GIANT();
- g_topology_lock();
- error = g_vfs_open(devvp, &cp, "hpfs", ronly ? 0 : 1);
- g_topology_unlock();
- PICKUP_GIANT();
- VOP_UNLOCK(devvp, 0);
- if (error)
- return (error);
-
- bo = &devvp->v_bufobj;
- bo->bo_private = cp;
- bo->bo_ops = g_vfs_bufops;
-
- /*
- * Do actual mount
- */
- hpmp = malloc(sizeof(struct hpfsmount), M_HPFSMNT, M_WAITOK | M_ZERO);
-
- hpmp->hpm_cp = cp;
- hpmp->hpm_bo = bo;
-
- /* Read in SuperBlock */
- error = bread(devvp, SUBLOCK, SUSIZE, NOCRED, &bp);
- if (error)
- goto failed;
- bcopy(bp->b_data, &hpmp->hpm_su, sizeof(struct sublock));
- brelse(bp); bp = NULL;
-
- /* Read in SpareBlock */
- error = bread(devvp, SPBLOCK, SPSIZE, NOCRED, &bp);
- if (error)
- goto failed;
- bcopy(bp->b_data, &hpmp->hpm_sp, sizeof(struct spblock));
- brelse(bp); bp = NULL;
-
- sup = &hpmp->hpm_su;
- spp = &hpmp->hpm_sp;
-
- /* Check magic */
- if (sup->su_magic != SU_MAGIC) {
- printf("hpfs_mountfs: SuperBlock MAGIC DOESN'T MATCH\n");
- error = EINVAL;
- goto failed;
- }
- if (spp->sp_magic != SP_MAGIC) {
- printf("hpfs_mountfs: SpareBlock MAGIC DOESN'T MATCH\n");
- error = EINVAL;
- goto failed;
- }
-
- mp->mnt_data = hpmp;
- hpmp->hpm_devvp = devvp;
- hpmp->hpm_dev = devvp->v_rdev;
- hpmp->hpm_mp = mp;
- if (vfs_scanopt(mp->mnt_optnew, "uid", "%d", &v) == 1)
- hpmp->hpm_uid = v;
- if (vfs_scanopt(mp->mnt_optnew, "gid", "%d", &v) == 1)
- hpmp->hpm_gid = v;
- if (vfs_scanopt(mp->mnt_optnew, "mode", "%d", &v) == 1)
- hpmp->hpm_mode = v;
-
- error = hpfs_bminit(hpmp);
- if (error)
- goto failed;
-
- error = hpfs_cpinit(mp, hpmp);
- if (error) {
- hpfs_bmdeinit(hpmp);
- goto failed;
- }
-
- error = hpfs_root(mp, LK_EXCLUSIVE, &vp);
- if (error) {
- hpfs_cpdeinit(hpmp);
- hpfs_bmdeinit(hpmp);
- goto failed;
- }
-
- vput(vp);
-
- mp->mnt_stat.f_fsid.val[0] = (long)dev2udev(dev);
- mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum;
- mp->mnt_maxsymlinklen = 0;
- MNT_ILOCK(mp);
- mp->mnt_flag |= MNT_LOCAL;
- MNT_IUNLOCK(mp);
- return (0);
-
-failed:
- if (bp)
- brelse (bp);
- mp->mnt_data = NULL;
- DROP_GIANT();
- g_topology_lock();
- g_vfs_close(cp);
- g_topology_unlock();
- PICKUP_GIANT();
- return (error);
-}
-
-static int
-hpfs_unmount(
- struct mount *mp,
- int mntflags)
-{
- int error, flags;
- register struct hpfsmount *hpmp = VFSTOHPFS(mp);
-
- dprintf(("hpfs_unmount():\n"));
-
- flags = 0;
- if(mntflags & MNT_FORCE)
- flags |= FORCECLOSE;
-
- dprintf(("hpfs_unmount: vflushing...\n"));
-
- error = vflush(mp, 0, flags, curthread);
- if (error) {
- printf("hpfs_unmount: vflush failed: %d\n",error);
- return (error);
- }
-
- vinvalbuf(hpmp->hpm_devvp, V_SAVE, 0, 0);
- DROP_GIANT();
- g_topology_lock();
- g_vfs_close(hpmp->hpm_cp);
- g_topology_unlock();
- PICKUP_GIANT();
- vrele(hpmp->hpm_devvp);
-
- dprintf(("hpfs_umount: freeing memory...\n"));
- hpfs_cpdeinit(hpmp);
- hpfs_bmdeinit(hpmp);
- mp->mnt_data = NULL;
- MNT_ILOCK(mp);
- mp->mnt_flag &= ~MNT_LOCAL;
- MNT_IUNLOCK(mp);
- free(hpmp, M_HPFSMNT);
-
- return (0);
-}
-
-static int
-hpfs_root(
- struct mount *mp,
- int flags,
- struct vnode **vpp)
-{
- int error = 0;
- struct hpfsmount *hpmp = VFSTOHPFS(mp);
-
- dprintf(("hpfs_root():\n"));
- error = VFS_VGET(mp, (ino_t)hpmp->hpm_su.su_rootfno, LK_EXCLUSIVE, vpp);
- if(error) {
- printf("hpfs_root: VFS_VGET failed: %d\n",error);
- return (error);
- }
-
- return (error);
-}
-
-static int
-hpfs_statfs(
- struct mount *mp,
- struct statfs *sbp)
-{
- struct hpfsmount *hpmp = VFSTOHPFS(mp);
-
- dprintf(("hpfs_statfs(): HPFS%d.%d\n",
- hpmp->hpm_su.su_hpfsver, hpmp->hpm_su.su_fnctver));
-
- sbp->f_type = mp->mnt_vfc->vfc_typenum;
- sbp->f_bsize = DEV_BSIZE;
- sbp->f_iosize = DEV_BSIZE;
- sbp->f_blocks = hpmp->hpm_su.su_btotal;
- sbp->f_bfree = sbp->f_bavail = hpmp->hpm_bavail;
- sbp->f_ffree = 0;
- sbp->f_files = 0;
- sbp->f_flags = mp->mnt_flag;
-
- return (0);
-}
-
-/*ARGSUSED*/
-static int
-hpfs_fhtovp(
- struct mount *mp,
- struct fid *fhp,
- int flags,
- struct vnode **vpp)
-{
- struct vnode *nvp;
- struct hpfid *hpfhp = (struct hpfid *)fhp;
- int error;
-
- if ((error = VFS_VGET(mp, hpfhp->hpfid_ino, LK_EXCLUSIVE, &nvp)) != 0) {
- *vpp = NULLVP;
- return (error);
- }
- /* XXX as unlink/rmdir/mkdir/creat are not currently possible
- * with HPFS, we don't need to check anything else for now */
- *vpp = nvp;
-
- return (0);
-}
-
-static int
-hpfs_vget(
- struct mount *mp,
- ino_t ino,
- int flags,
- struct vnode **vpp)
-{
- struct hpfsmount *hpmp = VFSTOHPFS(mp);
- struct vnode *vp;
- struct hpfsnode *hp;
- struct buf *bp;
- int error;
-
- dprintf(("hpfs_vget(0x%x): ",ino));
-
- error = vfs_hash_get(mp, ino, flags, curthread, vpp, NULL, NULL);
- if (error || *vpp != NULL)
- return (error);
-
- *vpp = NULL;
- hp = NULL;
- vp = NULL;
-
- /*
- * We have to lock node creation for a while,
- * but then we have to call getnewvnode(),
- * this may cause hpfs_reclaim() to be called,
- * this may need to VOP_VGET() parent dir for
- * update reasons, and if parent is not in
- * hash, we have to lock node creation...
- * To solve this, we MALLOC, getnewvnode and init while
- * not locked (probability of node appearence
- * at that time is little, and anyway - we'll
- * check for it).
- */
- hp = malloc(sizeof(struct hpfsnode),
- M_HPFSNO, M_WAITOK);
-
- error = getnewvnode("hpfs", mp, &hpfs_vnodeops, &vp);
- if (error) {
- printf("hpfs_vget: can't get new vnode\n");
- free(hp, M_HPFSNO);
- return (error);
- }
-
- dprintf(("prenew "));
-
- vp->v_data = hp;
-
- if (ino == (ino_t)hpmp->hpm_su.su_rootfno)
- vp->v_vflag |= VV_ROOT;
-
-
- mtx_init(&hp->h_interlock, "hpfsnode interlock", NULL, MTX_DEF);
-
- hp->h_flag = H_INVAL;
- hp->h_vp = vp;
- hp->h_hpmp = hpmp;
- hp->h_no = ino;
- hp->h_dev = hpmp->hpm_dev;
- hp->h_uid = hpmp->hpm_uid;
- hp->h_gid = hpmp->hpm_uid;
- hp->h_mode = hpmp->hpm_mode;
- hp->h_devvp = hpmp->hpm_devvp;
-
- lockmgr(vp->v_vnlock, LK_EXCLUSIVE, NULL);
- error = insmntque(vp, mp);
- if (error != 0) {
- free(hp, M_HPFSNO);
- return (error);
- }
- error = vfs_hash_insert(vp, ino, flags, curthread, vpp, NULL, NULL);
- if (error || *vpp != NULL)
- return (error);
-
- error = bread(hpmp->hpm_devvp, ino, FNODESIZE, NOCRED, &bp);
- if (error) {
- printf("hpfs_vget: can't read ino %ju\n", (uintmax_t)ino);
- vput(vp);
- return (error);
- }
- bcopy(bp->b_data, &hp->h_fn, sizeof(struct fnode));
- brelse(bp);
-
- if (hp->h_fn.fn_magic != FN_MAGIC) {
- printf("hpfs_vget: MAGIC DOESN'T MATCH\n");
- vput(vp);
- return (EINVAL);
- }
-
- vp->v_type = hp->h_fn.fn_flag ? VDIR:VREG;
- hp->h_flag &= ~H_INVAL;
-
- *vpp = vp;
-
- return (0);
-}
-
-static struct vfsops hpfs_vfsops = {
- .vfs_fhtovp = hpfs_fhtovp,
- .vfs_cmount = hpfs_cmount,
- .vfs_mount = hpfs_mount,
- .vfs_root = hpfs_root,
- .vfs_statfs = hpfs_statfs,
- .vfs_unmount = hpfs_unmount,
- .vfs_vget = hpfs_vget,
-};
-VFS_SET(hpfs_vfsops, hpfs, 0);
diff --git a/sys/fs/hpfs/hpfs_vnops.c b/sys/fs/hpfs/hpfs_vnops.c
deleted file mode 100644
index 9abe77c..0000000
--- a/sys/fs/hpfs/hpfs_vnops.c
+++ /dev/null
@@ -1,1264 +0,0 @@
-/*-
- * Copyright (c) 1998, 1999 Semen Ustimenko (semenu@FreeBSD.org)
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/proc.h>
-#include <sys/conf.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <sys/namei.h>
-#include <sys/malloc.h>
-#include <sys/bio.h>
-#include <sys/buf.h>
-#include <sys/dirent.h>
-
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <vm/vm_page.h>
-#include <vm/vm_object.h>
-#include <vm/vm_pager.h>
-#include <vm/vnode_pager.h>
-#include <vm/vm_extern.h>
-
-#include <sys/unistd.h> /* for pathconf(2) constants */
-
-#include <fs/hpfs/hpfs.h>
-#include <fs/hpfs/hpfsmount.h>
-#include <fs/hpfs/hpfs_subr.h>
-#include <fs/hpfs/hpfs_ioctl.h>
-
-static int hpfs_de_uiomove(struct hpfsmount *, struct hpfsdirent *,
- struct uio *);
-static vop_ioctl_t hpfs_ioctl;
-static vop_read_t hpfs_read;
-static vop_write_t hpfs_write;
-static vop_getattr_t hpfs_getattr;
-static vop_setattr_t hpfs_setattr;
-static vop_inactive_t hpfs_inactive;
-static vop_print_t hpfs_print;
-static vop_reclaim_t hpfs_reclaim;
-static vop_strategy_t hpfs_strategy;
-static vop_access_t hpfs_access;
-static vop_open_t hpfs_open;
-static vop_close_t hpfs_close;
-static vop_readdir_t hpfs_readdir;
-static vop_cachedlookup_t hpfs_lookup;
-static vop_create_t hpfs_create;
-static vop_remove_t hpfs_remove;
-static vop_bmap_t hpfs_bmap;
-static vop_fsync_t hpfs_fsync;
-static vop_pathconf_t hpfs_pathconf;
-static vop_vptofh_t hpfs_vptofh;
-
-static int
-hpfs_fsync(ap)
- struct vop_fsync_args /* {
- struct vnode *a_vp;
- struct ucred *a_cred;
- int a_waitfor;
- struct thread *a_td;
- } */ *ap;
-{
- /*
- * Flush our dirty buffers.
- */
- vop_stdfsync(ap);
-
- /*
- * Write out the on-disc version of the vnode.
- */
- return hpfs_update(VTOHP(ap->a_vp));
-}
-
-static int
-hpfs_ioctl (
- struct vop_ioctl_args /* {
- struct vnode *a_vp;
- u_long a_command;
- caddr_t a_data;
- int a_fflag;
- struct ucred *a_cred;
- struct thread *a_td;
- } */ *ap)
-{
- register struct vnode *vp = ap->a_vp;
- register struct hpfsnode *hp = VTOHP(vp);
- int error;
-
- printf("hpfs_ioctl(0x%x, 0x%lx, 0x%p, 0x%x): ",
- hp->h_no, ap->a_command, ap->a_data, ap->a_fflag);
-
- switch (ap->a_command) {
- case HPFSIOCGEANUM: {
- u_long eanum;
- u_long passed;
- struct ea *eap;
-
- eanum = 0;
-
- if (hp->h_fn.fn_ealen > 0) {
- eap = (struct ea *)&(hp->h_fn.fn_int);
- passed = 0;
-
- while (passed < hp->h_fn.fn_ealen) {
-
- printf("EAname: %s\n", EA_NAME(eap));
-
- eanum++;
- passed += sizeof(struct ea) +
- eap->ea_namelen + 1 + eap->ea_vallen;
- eap = (struct ea *)((caddr_t)hp->h_fn.fn_int +
- passed);
- }
- error = 0;
- } else {
- error = ENOENT;
- }
-
- printf("%lu eas\n", eanum);
-
- *(u_long *)ap->a_data = eanum;
-
- break;
- }
- case HPFSIOCGEASZ: {
- u_long eanum;
- u_long passed;
- struct ea *eap;
-
- printf("EA%ld\n", *(u_long *)ap->a_data);
-
- eanum = 0;
- if (hp->h_fn.fn_ealen > 0) {
- eap = (struct ea *)&(hp->h_fn.fn_int);
- passed = 0;
-
- error = ENOENT;
- while (passed < hp->h_fn.fn_ealen) {
- printf("EAname: %s\n", EA_NAME(eap));
-
- if (eanum == *(u_long *)ap->a_data) {
- *(u_long *)ap->a_data =
- eap->ea_namelen + 1 +
- eap->ea_vallen;
-
- error = 0;
- break;
- }
-
- eanum++;
- passed += sizeof(struct ea) +
- eap->ea_namelen + 1 + eap->ea_vallen;
- eap = (struct ea *)((caddr_t)hp->h_fn.fn_int +
- passed);
- }
- } else {
- error = ENOENT;
- }
-
- break;
- }
- case HPFSIOCRDEA: {
- u_long eanum;
- u_long passed;
- struct hpfs_rdea *rdeap;
- struct ea *eap;
-
- rdeap = (struct hpfs_rdea *)ap->a_data;
- printf("EA%ld\n", rdeap->ea_no);
-
- eanum = 0;
- if (hp->h_fn.fn_ealen > 0) {
- eap = (struct ea *)&(hp->h_fn.fn_int);
- passed = 0;
-
- error = ENOENT;
- while (passed < hp->h_fn.fn_ealen) {
- printf("EAname: %s\n", EA_NAME(eap));
-
- if (eanum == rdeap->ea_no) {
- rdeap->ea_sz = eap->ea_namelen + 1 +
- eap->ea_vallen;
- copyout(EA_NAME(eap),rdeap->ea_data,
- rdeap->ea_sz);
- error = 0;
- break;
- }
-
- eanum++;
- passed += sizeof(struct ea) +
- eap->ea_namelen + 1 + eap->ea_vallen;
- eap = (struct ea *)((caddr_t)hp->h_fn.fn_int +
- passed);
- }
- } else {
- error = ENOENT;
- }
-
- break;
- }
- default:
- error = ENOTTY;
- break;
- }
- return (error);
-}
-
-/*
- * Map file offset to disk offset.
- */
-int
-hpfs_bmap(ap)
- struct vop_bmap_args /* {
- struct vnode *a_vp;
- daddr_t a_bn;
- struct bufobj **a_bop;
- daddr_t *a_bnp;
- int *a_runp;
- int *a_runb;
- } */ *ap;
-{
- register struct hpfsnode *hp = VTOHP(ap->a_vp);
- daddr_t blkno;
- int error;
-
- if (ap->a_bop != NULL)
- *ap->a_bop = &hp->h_devvp->v_bufobj;
- if (ap->a_runb != NULL)
- *ap->a_runb = 0;
- if (ap->a_bnp == NULL)
- return (0);
-
- dprintf(("hpfs_bmap(0x%x, 0x%x): ",hp->h_no, ap->a_bn));
-
- error = hpfs_hpbmap (hp, ap->a_bn, &blkno, ap->a_runp);
- *ap->a_bnp = blkno;
-
- return (error);
-}
-
-static int
-hpfs_read(ap)
- struct vop_read_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- int a_ioflag;
- struct ucred *a_cred;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
- register struct hpfsnode *hp = VTOHP(vp);
- struct uio *uio = ap->a_uio;
- struct buf *bp;
- u_int xfersz, toread;
- u_int off;
- daddr_t lbn, bn;
- int resid;
- int runl;
- int error = 0;
-
- resid = min (uio->uio_resid, hp->h_fn.fn_size - uio->uio_offset);
-
- dprintf(("hpfs_read(0x%x, off: %d resid: %d, segflg: %d): [resid: 0x%x]\n",hp->h_no,(u_int32_t)uio->uio_offset,uio->uio_resid,uio->uio_segflg, resid));
-
- while (resid) {
- lbn = uio->uio_offset >> DEV_BSHIFT;
- off = uio->uio_offset & (DEV_BSIZE - 1);
- dprintf(("hpfs_read: resid: 0x%x lbn: 0x%x off: 0x%x\n",
- uio->uio_resid, lbn, off));
- error = hpfs_hpbmap(hp, lbn, &bn, &runl);
- if (error)
- return (error);
-
- toread = min(off + resid, min(DFLTPHYS, (runl+1)*DEV_BSIZE));
- xfersz = (toread + DEV_BSIZE - 1) & ~(DEV_BSIZE - 1);
- dprintf(("hpfs_read: bn: 0x%x (0x%x) toread: 0x%x (0x%x)\n",
- bn, runl, toread, xfersz));
-
- if (toread == 0)
- break;
-
- error = bread(hp->h_devvp, bn, xfersz, NOCRED, &bp);
- if (error) {
- brelse(bp);
- break;
- }
-
- error = uiomove(bp->b_data + off, toread - off, uio);
- if(error) {
- brelse(bp);
- break;
- }
- brelse(bp);
- resid -= toread;
- }
- dprintf(("hpfs_read: successful\n"));
- return (error);
-}
-
-static int
-hpfs_write(ap)
- struct vop_write_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- int a_ioflag;
- struct ucred *a_cred;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
- register struct hpfsnode *hp = VTOHP(vp);
- struct uio *uio = ap->a_uio;
- struct buf *bp;
- u_int xfersz, towrite;
- u_int off;
- daddr_t lbn, bn;
- int runl;
- int error = 0;
-
- dprintf(("hpfs_write(0x%x, off: %d resid: %d, segflg: %d):\n",hp->h_no,(u_int32_t)uio->uio_offset,uio->uio_resid,uio->uio_segflg));
-
- if (ap->a_ioflag & IO_APPEND) {
- dprintf(("hpfs_write: APPEND mode\n"));
- uio->uio_offset = hp->h_fn.fn_size;
- }
- if (uio->uio_offset + uio->uio_resid > hp->h_fn.fn_size) {
- error = hpfs_extend (hp, uio->uio_offset + uio->uio_resid);
- if (error) {
- printf("hpfs_write: hpfs_extend FAILED %d\n", error);
- return (error);
- }
- }
-
- while (uio->uio_resid) {
- lbn = uio->uio_offset >> DEV_BSHIFT;
- off = uio->uio_offset & (DEV_BSIZE - 1);
- dprintf(("hpfs_write: resid: 0x%x lbn: 0x%x off: 0x%x\n",
- uio->uio_resid, lbn, off));
- error = hpfs_hpbmap(hp, lbn, &bn, &runl);
- if (error)
- return (error);
-
- towrite = min(off + uio->uio_resid, min(DFLTPHYS, (runl+1)*DEV_BSIZE));
- xfersz = (towrite + DEV_BSIZE - 1) & ~(DEV_BSIZE - 1);
- dprintf(("hpfs_write: bn: 0x%x (0x%x) towrite: 0x%x (0x%x)\n",
- bn, runl, towrite, xfersz));
-
- if ((off == 0) && (towrite == xfersz)) {
- bp = getblk(hp->h_devvp, bn, xfersz, 0, 0, 0);
- clrbuf(bp);
- } else {
- error = bread(hp->h_devvp, bn, xfersz, NOCRED, &bp);
- if (error) {
- brelse(bp);
- return (error);
- }
- }
-
- error = uiomove(bp->b_data + off, towrite - off, uio);
- if(error) {
- brelse(bp);
- return (error);
- }
-
- if (ap->a_ioflag & IO_SYNC)
- bwrite(bp);
- else
- bawrite(bp);
- }
-
- dprintf(("hpfs_write: successful\n"));
- return (0);
-}
-
-/*
- * XXXXX do we need hpfsnode locking inside?
- */
-static int
-hpfs_getattr(ap)
- struct vop_getattr_args /* {
- struct vnode *a_vp;
- struct vattr *a_vap;
- struct ucred *a_cred;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
- register struct hpfsnode *hp = VTOHP(vp);
- register struct vattr *vap = ap->a_vap;
- int error;
-
- dprintf(("hpfs_getattr(0x%x):\n", hp->h_no));
-
- vap->va_fsid = dev2udev(hp->h_dev);
- vap->va_fileid = hp->h_no;
- vap->va_mode = hp->h_mode;
- vap->va_nlink = 1;
- vap->va_uid = hp->h_uid;
- vap->va_gid = hp->h_gid;
- vap->va_rdev = NODEV;
- vap->va_size = hp->h_fn.fn_size;
- vap->va_bytes = ((hp->h_fn.fn_size + DEV_BSIZE-1) & ~(DEV_BSIZE-1)) +
- DEV_BSIZE;
-
- if (!(hp->h_flag & H_PARVALID)) {
- error = hpfs_validateparent(hp);
- if (error)
- return (error);
- }
- vap->va_atime = hpfstimetounix(hp->h_atime);
- vap->va_mtime = hpfstimetounix(hp->h_mtime);
- vap->va_ctime = hpfstimetounix(hp->h_ctime);
-
- vap->va_flags = 0;
- vap->va_gen = 0;
- vap->va_blocksize = DEV_BSIZE;
- vap->va_type = vp->v_type;
- vap->va_filerev = 0;
-
- return (0);
-}
-
-/*
- * XXXXX do we need hpfsnode locking inside?
- */
-static int
-hpfs_setattr(ap)
- struct vop_setattr_args /* {
- struct vnode *a_vp;
- struct vattr *a_vap;
- struct ucred *a_cred;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
- struct hpfsnode *hp = VTOHP(vp);
- struct vattr *vap = ap->a_vap;
- struct ucred *cred = ap->a_cred;
- struct thread *td = curthread;
- int error;
-
- dprintf(("hpfs_setattr(0x%x):\n", hp->h_no));
-
- /*
- * Check for unsettable attributes.
- */
- if ((vap->va_type != VNON) || (vap->va_nlink != VNOVAL) ||
- (vap->va_fsid != VNOVAL) || (vap->va_fileid != VNOVAL) ||
- (vap->va_blocksize != VNOVAL) || (vap->va_rdev != VNOVAL) ||
- (vap->va_bytes != VNOVAL) || (vap->va_gen != VNOVAL)) {
- dprintf(("hpfs_setattr: changing nonsettable attr\n"));
- return (EINVAL);
- }
-
- /* Can't change flags XXX Could be implemented */
- if (vap->va_flags != VNOVAL) {
- printf("hpfs_setattr: FLAGS CANNOT BE SET\n");
- return (EINVAL);
- }
-
- /* Can't change uid/gid XXX Could be implemented */
- if (vap->va_uid != (uid_t)VNOVAL || vap->va_gid != (gid_t)VNOVAL) {
- printf("hpfs_setattr: UID/GID CANNOT BE SET\n");
- return (EINVAL);
- }
-
- /* Can't change mode XXX Could be implemented */
- if (vap->va_mode != (mode_t)VNOVAL) {
- printf("hpfs_setattr: MODE CANNOT BE SET\n");
- return (EINVAL);
- }
-
- /* Update times */
- if (vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL) {
- if (vp->v_mount->mnt_flag & MNT_RDONLY)
- return (EROFS);
- if (vap->va_vaflags & VA_UTIMES_NULL) {
- error = VOP_ACCESS(vp, VADMIN, cred, td);
- if (error)
- error = VOP_ACCESS(vp, VWRITE, cred, td);
- } else
- error = VOP_ACCESS(vp, VADMIN, cred, td);
- if (vap->va_atime.tv_sec != VNOVAL)
- hp->h_atime = vap->va_atime.tv_sec;
- if (vap->va_mtime.tv_sec != VNOVAL)
- hp->h_mtime = vap->va_mtime.tv_sec;
-
- hp->h_flag |= H_PARCHANGE;
- }
-
- if (vap->va_size != VNOVAL) {
- switch (vp->v_type) {
- case VDIR:
- return (EISDIR);
- case VREG:
- if (vp->v_mount->mnt_flag & MNT_RDONLY)
- return (EROFS);
- break;
- default:
- printf("hpfs_setattr: WRONG v_type\n");
- return (EINVAL);
- }
-
- if (vap->va_size < hp->h_fn.fn_size) {
- error = vtruncbuf(vp, cred, vap->va_size, DEV_BSIZE);
- if (error)
- return (error);
- error = hpfs_truncate(hp, vap->va_size);
- if (error)
- return (error);
-
- } else if (vap->va_size > hp->h_fn.fn_size) {
- vnode_pager_setsize(vp, vap->va_size);
- error = hpfs_extend(hp, vap->va_size);
- if (error)
- return (error);
- }
- }
-
- return (0);
-}
-
-/*
- * Last reference to a node. If necessary, write or delete it.
- */
-int
-hpfs_inactive(ap)
- struct vop_inactive_args /* {
- struct vnode *a_vp;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
- register struct hpfsnode *hp = VTOHP(vp);
- int error;
-
- dprintf(("hpfs_inactive(0x%x): \n", hp->h_no));
-
- if (hp->h_flag & H_CHANGE) {
- dprintf(("hpfs_inactive: node changed, update\n"));
- error = hpfs_update (hp);
- if (error)
- return (error);
- }
-
- if (hp->h_flag & H_PARCHANGE) {
- dprintf(("hpfs_inactive: parent node changed, update\n"));
- error = hpfs_updateparent (hp);
- if (error)
- return (error);
- }
-
- if (hp->h_flag & H_INVAL) {
- vrecycle(vp);
- return (0);
- }
-
- return (0);
-}
-
-/*
- * Reclaim an inode so that it can be used for other purposes.
- */
-int
-hpfs_reclaim(ap)
- struct vop_reclaim_args /* {
- struct vnode *a_vp;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
- register struct hpfsnode *hp = VTOHP(vp);
-
- dprintf(("hpfs_reclaim(0x%x0): \n", hp->h_no));
-
- /*
- * Destroy the vm object and flush associated pages.
- */
- vnode_destroy_vobject(vp);
-
- vfs_hash_remove(vp);
-
- mtx_destroy(&hp->h_interlock);
-
- vp->v_data = NULL;
-
- free(hp, M_HPFSNO);
-
- return (0);
-}
-
-static int
-hpfs_print(ap)
- struct vop_print_args /* {
- struct vnode *a_vp;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
- register struct hpfsnode *hp = VTOHP(vp);
-
- printf("\tino 0x%x\n", hp->h_no);
- return (0);
-}
-
-/*
- * Calculate the logical to physical mapping if not done already,
- * then call the device strategy routine.
- *
- * In order to be able to swap to a file, the hpfs_hpbmap operation may not
- * deadlock on memory. See hpfs_bmap() for details. XXXXXXX (not impl)
- */
-int
-hpfs_strategy(ap)
- struct vop_strategy_args /* {
- struct buf *a_bp;
- } */ *ap;
-{
- register struct buf *bp = ap->a_bp;
- register struct vnode *vp = ap->a_vp;
- register struct hpfsnode *hp = VTOHP(ap->a_vp);
- daddr_t blkno;
- struct bufobj *bo;
- int error;
-
- dprintf(("hpfs_strategy(): \n"));
-
- if (vp->v_type == VBLK || vp->v_type == VCHR)
- panic("hpfs_strategy: spec");
- if (bp->b_blkno == bp->b_lblkno) {
- error = hpfs_hpbmap (hp, bp->b_lblkno, &blkno, NULL);
- bp->b_blkno = blkno;
- if (error) {
- printf("hpfs_strategy: hpfs_bpbmap FAILED %d\n", error);
- bp->b_error = error;
- bp->b_ioflags |= BIO_ERROR;
- bufdone(bp);
- return (0);
- }
- if ((long)bp->b_blkno == -1)
- vfs_bio_clrbuf(bp);
- }
- if ((long)bp->b_blkno == -1) {
- bufdone(bp);
- return (0);
- }
- bp->b_iooffset = dbtob(bp->b_blkno);
- bo = hp->h_hpmp->hpm_bo;
- BO_STRATEGY(bo, bp);
- return (0);
-}
-
-/*
- * XXXXX do we need hpfsnode locking inside?
- */
-int
-hpfs_access(ap)
- struct vop_access_args /* {
- struct vnode *a_vp;
- accmode_t a_accmode;
- struct ucred *a_cred;
- struct thread *a_td;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
- struct hpfsnode *hp = VTOHP(vp);
- accmode_t accmode = ap->a_accmode;
-
- dprintf(("hpfs_access(0x%x):\n", hp->h_no));
-
- /*
- * Disallow write attempts on read-only filesystems;
- * unless the file is a socket, fifo, or a block or
- * character device resident on the filesystem.
- */
- if (accmode & VWRITE) {
- switch ((int)vp->v_type) {
- case VDIR:
- case VLNK:
- case VREG:
- if (vp->v_mount->mnt_flag & MNT_RDONLY)
- return (EROFS);
- break;
- }
- }
-
- return (vaccess(vp->v_type, hp->h_mode, hp->h_uid, hp->h_gid,
- ap->a_accmode, ap->a_cred, NULL));
-}
-
-/*
- * Open called.
- *
- * Nothing to do.
- */
-/* ARGSUSED */
-static int
-hpfs_open(ap)
- struct vop_open_args /* {
- struct vnode *a_vp;
- int a_mode;
- struct ucred *a_cred;
- struct thread *a_td;
- } */ *ap;
-{
-#ifdef HPFS_DEBUG
- register struct vnode *vp = ap->a_vp;
- register struct hpfsnode *hp = VTOHP(vp);
-
- printf("hpfs_open(0x%x):\n",hp->h_no);
-#endif
-
- /*
- * Files marked append-only must be opened for appending.
- */
-
- return (0);
-}
-
-/*
- * Close called.
- *
- * Update the times on the inode.
- */
-/* ARGSUSED */
-static int
-hpfs_close(ap)
- struct vop_close_args /* {
- struct vnode *a_vp;
- int a_fflag;
- struct ucred *a_cred;
- struct thread *a_td;
- } */ *ap;
-{
-#ifdef HPFS_DEBUG
- register struct vnode *vp = ap->a_vp;
- register struct hpfsnode *hp = VTOHP(vp);
-
- printf("hpfs_close: %d\n",hp->h_no);
-#endif
-
- return (0);
-}
-
-static int
-hpfs_de_uiomove (
- struct hpfsmount *hpmp,
- struct hpfsdirent *dep,
- struct uio *uio)
-{
- struct dirent cde;
- int i, error;
-
- dprintf(("[no: 0x%x, size: %d, name: %2d:%.*s, flag: 0x%x] ",
- dep->de_fnode, dep->de_size, dep->de_namelen,
- dep->de_namelen, dep->de_name, dep->de_flag));
-
- /*strncpy(cde.d_name, dep->de_name, dep->de_namelen);*/
- for (i=0; i<dep->de_namelen; i++)
- cde.d_name[i] = hpfs_d2u(hpmp, dep->de_name[i]);
-
- cde.d_name[dep->de_namelen] = '\0';
- cde.d_namlen = dep->de_namelen;
- cde.d_fileno = dep->de_fnode;
- cde.d_type = (dep->de_flag & DE_DIR) ? DT_DIR : DT_REG;
- cde.d_reclen = sizeof(struct dirent);
-
- error = uiomove((char *)&cde, sizeof(struct dirent), uio);
- if (error)
- return (error);
-
- dprintf(("[0x%x] ", uio->uio_resid));
- return (error);
-}
-
-
-static struct dirent hpfs_de_dot = {
- .d_fileno = 0,
- .d_reclen = sizeof(struct dirent),
- .d_type = DT_DIR,
- .d_namlen = 1,
- .d_name = "."
-};
-static struct dirent hpfs_de_dotdot = {
- .d_fileno = 0,
- .d_reclen = sizeof(struct dirent),
- .d_type = DT_DIR,
- .d_namlen = 2,
- .d_name = ".."
-};
-
-int
-hpfs_readdir(ap)
- struct vop_readdir_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- struct ucred *a_cred;
- int *a_ncookies;
- u_int **cookies;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
- register struct hpfsnode *hp = VTOHP(vp);
- struct hpfsmount *hpmp = hp->h_hpmp;
- struct uio *uio = ap->a_uio;
- int ncookies = 0, i, num, cnum;
- int error = 0;
- off_t off;
- struct buf *bp;
- struct dirblk *dp;
- struct hpfsdirent *dep;
- lsn_t olsn;
- lsn_t lsn;
- int level;
-
- dprintf(("hpfs_readdir(0x%x, 0x%x, 0x%x): ",hp->h_no,(u_int32_t)uio->uio_offset,uio->uio_resid));
-
- off = uio->uio_offset;
-
- if( uio->uio_offset < sizeof(struct dirent) ) {
- dprintf((". faked, "));
- hpfs_de_dot.d_fileno = hp->h_no;
- error = uiomove((char *)&hpfs_de_dot,sizeof(struct dirent),uio);
- if(error) {
- return (error);
- }
-
- ncookies ++;
- }
-
- if( uio->uio_offset < 2 * sizeof(struct dirent) ) {
- dprintf((".. faked, "));
- hpfs_de_dotdot.d_fileno = hp->h_fn.fn_parent;
-
- error = uiomove((char *)&hpfs_de_dotdot, sizeof(struct dirent),
- uio);
- if(error) {
- return (error);
- }
-
- ncookies ++;
- }
-
- num = uio->uio_offset / sizeof(struct dirent) - 2;
- cnum = 0;
-
- lsn = ((alleaf_t *)hp->h_fn.fn_abd)->al_lsn;
-
- olsn = 0;
- level = 1;
-
-dive:
- dprintf(("[dive 0x%x] ", lsn));
- error = bread(hp->h_devvp, lsn, D_BSIZE, NOCRED, &bp);
- if (error) {
- brelse(bp);
- return (error);
- }
-
- dp = (struct dirblk *) bp->b_data;
- if (dp->d_magic != D_MAGIC) {
- printf("hpfs_readdir: MAGIC DOESN'T MATCH\n");
- brelse(bp);
- return (EINVAL);
- }
-
- dep = D_DIRENT(dp);
-
- if (olsn) {
- dprintf(("[restore 0x%x] ", olsn));
-
- while(!(dep->de_flag & DE_END) ) {
- if((dep->de_flag & DE_DOWN) &&
- (olsn == DE_DOWNLSN(dep)))
- break;
- dep = (hpfsdirent_t *)((caddr_t)dep + dep->de_reclen);
- }
-
- if((dep->de_flag & DE_DOWN) && (olsn == DE_DOWNLSN(dep))) {
- if (dep->de_flag & DE_END)
- goto blockdone;
-
- if (!(dep->de_flag & DE_SPECIAL)) {
- if (num <= cnum) {
- if (uio->uio_resid < sizeof(struct dirent)) {
- brelse(bp);
- dprintf(("[resid] "));
- goto readdone;
- }
-
- error = hpfs_de_uiomove(hpmp, dep, uio);
- if (error) {
- brelse (bp);
- return (error);
- }
- ncookies++;
-
- if (uio->uio_resid < sizeof(struct dirent)) {
- brelse(bp);
- dprintf(("[resid] "));
- goto readdone;
- }
- }
- cnum++;
- }
-
- dep = (hpfsdirent_t *)((caddr_t)dep + dep->de_reclen);
- } else {
- printf("hpfs_readdir: ERROR! oLSN not found\n");
- brelse(bp);
- return (EINVAL);
- }
- }
-
- olsn = 0;
-
- while(!(dep->de_flag & DE_END)) {
- if(dep->de_flag & DE_DOWN) {
- lsn = DE_DOWNLSN(dep);
- brelse(bp);
- level++;
- goto dive;
- }
-
- if (!(dep->de_flag & DE_SPECIAL)) {
- if (num <= cnum) {
- if (uio->uio_resid < sizeof(struct dirent)) {
- brelse(bp);
- dprintf(("[resid] "));
- goto readdone;
- }
-
- error = hpfs_de_uiomove(hpmp, dep, uio);
- if (error) {
- brelse (bp);
- return (error);
- }
- ncookies++;
-
- if (uio->uio_resid < sizeof(struct dirent)) {
- brelse(bp);
- dprintf(("[resid] "));
- goto readdone;
- }
- }
- cnum++;
- }
-
- dep = (hpfsdirent_t *)((caddr_t)dep + dep->de_reclen);
- }
-
- if(dep->de_flag & DE_DOWN) {
- dprintf(("[enddive] "));
- lsn = DE_DOWNLSN(dep);
- brelse(bp);
- level++;
- goto dive;
- }
-
-blockdone:
- dprintf(("[EOB] "));
- olsn = lsn;
- lsn = dp->d_parent;
- brelse(bp);
- level--;
-
- dprintf(("[level %d] ", level));
-
- if (level > 0)
- goto dive; /* undive really */
-
- if (ap->a_eofflag) {
- dprintf(("[EOF] "));
- *ap->a_eofflag = 1;
- }
-
-readdone:
- dprintf(("[readdone]\n"));
- if (!error && ap->a_ncookies != NULL) {
- struct dirent* dpStart;
- struct dirent* dp;
- u_long *cookies;
- u_long *cookiep;
-
- dprintf(("%d cookies, ",ncookies));
- if (uio->uio_segflg != UIO_SYSSPACE || uio->uio_iovcnt != 1)
- panic("hpfs_readdir: unexpected uio from NFS server");
- dpStart = (struct dirent *)
- ((caddr_t)uio->uio_iov->iov_base -
- (uio->uio_offset - off));
- cookies = malloc(ncookies * sizeof(u_long),
- M_TEMP, M_WAITOK);
- for (dp = dpStart, cookiep = cookies, i=0;
- i < ncookies;
- dp = (struct dirent *)((caddr_t) dp + dp->d_reclen), i++) {
- off += dp->d_reclen;
- *cookiep++ = (u_int) off;
- }
- *ap->a_ncookies = ncookies;
- *ap->a_cookies = cookies;
- }
-
- return (0);
-}
-
-int
-hpfs_lookup(ap)
- struct vop_cachedlookup_args /* {
- struct vnode *a_dvp;
- struct vnode **a_vpp;
- struct componentname *a_cnp;
- } */ *ap;
-{
- register struct vnode *dvp = ap->a_dvp;
- register struct hpfsnode *dhp = VTOHP(dvp);
- struct hpfsmount *hpmp = dhp->h_hpmp;
- struct componentname *cnp = ap->a_cnp;
- struct ucred *cred = cnp->cn_cred;
- int error;
- int nameiop = cnp->cn_nameiop;
- int flags = cnp->cn_flags;
- dprintf(("hpfs_lookup(0x%x, %s, %ld):\n",
- dhp->h_no, cnp->cn_nameptr, cnp->cn_namelen));
-
- if (nameiop != CREATE && nameiop != DELETE && nameiop != LOOKUP) {
- printf("hpfs_lookup: LOOKUP, DELETE and CREATE are only supported\n");
- return (EOPNOTSUPP);
- }
-
- error = VOP_ACCESS(dvp, VEXEC, cred, cnp->cn_thread);
- if(error)
- return (error);
-
- if( (cnp->cn_namelen == 1) &&
- !strncmp(cnp->cn_nameptr,".",1) ) {
- dprintf(("hpfs_lookup(0x%x,...): . faked\n",dhp->h_no));
-
- VREF(dvp);
- *ap->a_vpp = dvp;
-
- return (0);
- } else if( (cnp->cn_namelen == 2) &&
- !strncmp(cnp->cn_nameptr,"..",2) && (flags & ISDOTDOT) ) {
- dprintf(("hpfs_lookup(0x%x,...): .. faked (0x%x)\n",
- dhp->h_no, dhp->h_fn.fn_parent));
-
- if (VFS_VGET(hpmp->hpm_mp, dhp->h_fn.fn_parent,
- LK_NOWAIT | LK_EXCLUSIVE, ap->a_vpp)) {
- VOP_UNLOCK(dvp,0);
- error = VFS_VGET(hpmp->hpm_mp,
- dhp->h_fn.fn_parent, LK_EXCLUSIVE, ap->a_vpp);
- vn_lock(dvp, LK_EXCLUSIVE|LK_RETRY);
- if (error)
- return(error);
- }
- return (0);
- } else {
- struct buf *bp;
- struct hpfsdirent *dep;
- struct hpfsnode *hp;
-
- error = hpfs_genlookupbyname(dhp,
- cnp->cn_nameptr, cnp->cn_namelen, &bp, &dep);
- if (error) {
- if ((error == ENOENT) && (flags & ISLASTCN) &&
- (nameiop == CREATE || nameiop == RENAME)) {
- cnp->cn_flags |= SAVENAME;
- return (EJUSTRETURN);
- }
-
- return (error);
- }
-
- dprintf(("hpfs_lookup: fnode: 0x%x, CPID: 0x%x\n",
- dep->de_fnode, dep->de_cpid));
-
- if (nameiop == DELETE && (flags & ISLASTCN)) {
- error = VOP_ACCESS(dvp, VWRITE, cred, cnp->cn_thread);
- if (error) {
- brelse(bp);
- return (error);
- }
- }
-
- if (dhp->h_no == dep->de_fnode) {
- brelse(bp);
- VREF(dvp);
- *ap->a_vpp = dvp;
- return (0);
- }
-
- error = VFS_VGET(hpmp->hpm_mp, dep->de_fnode, LK_EXCLUSIVE,
- ap->a_vpp);
- if (error) {
- printf("hpfs_lookup: VFS_VGET FAILED %d\n", error);
- brelse(bp);
- return(error);
- }
-
- hp = VTOHP(*ap->a_vpp);
-
- hp->h_mtime = dep->de_mtime;
- hp->h_ctime = dep->de_ctime;
- hp->h_atime = dep->de_atime;
- bcopy(dep->de_name, hp->h_name, dep->de_namelen);
- hp->h_name[dep->de_namelen] = '\0';
- hp->h_namelen = dep->de_namelen;
- hp->h_flag |= H_PARVALID;
-
- brelse(bp);
-
- if ((flags & MAKEENTRY) &&
- (!(flags & ISLASTCN) ||
- (nameiop != DELETE && nameiop != CREATE)))
- cache_enter(dvp, *ap->a_vpp, cnp);
- }
- return (error);
-}
-
-int
-hpfs_remove(ap)
- struct vop_remove_args /* {
- struct vnode *a_dvp;
- struct vnode *a_vp;
- struct componentname *a_cnp;
- } */ *ap;
-{
- int error;
-
- dprintf(("hpfs_remove(0x%x, %s, %ld): \n", VTOHP(ap->a_vp)->h_no,
- ap->a_cnp->cn_nameptr, ap->a_cnp->cn_namelen));
-
- if (ap->a_vp->v_type == VDIR)
- return (EPERM);
-
- error = hpfs_removefnode (ap->a_dvp, ap->a_vp, ap->a_cnp);
- return (error);
-}
-
-int
-hpfs_create(ap)
- struct vop_create_args /* {
- struct vnode *a_dvp;
- struct vnode **a_vpp;
- struct componentname *a_cnp;
- struct vattr *a_vap;
- } */ *ap;
-{
- int error;
-
- dprintf(("hpfs_create(0x%x, %s, %ld): \n", VTOHP(ap->a_dvp)->h_no,
- ap->a_cnp->cn_nameptr, ap->a_cnp->cn_namelen));
-
- if (!(ap->a_cnp->cn_flags & HASBUF))
- panic ("hpfs_create: no name\n");
-
- error = hpfs_makefnode (ap->a_dvp, ap->a_vpp, ap->a_cnp, ap->a_vap);
-
- return (error);
-}
-
-/*
- * Return POSIX pathconf information applicable to NTFS filesystem
- */
-int
-hpfs_pathconf(ap)
- struct vop_pathconf_args /* {
- struct vnode *a_vp;
- int a_name;
- register_t *a_retval;
- } */ *ap;
-{
- switch (ap->a_name) {
- case _PC_LINK_MAX:
- *ap->a_retval = 1;
- return (0);
- case _PC_NAME_MAX:
- *ap->a_retval = HPFS_MAXFILENAME;
- return (0);
- case _PC_PATH_MAX:
- *ap->a_retval = PATH_MAX;
- return (0);
- case _PC_CHOWN_RESTRICTED:
- *ap->a_retval = 1;
- return (0);
- case _PC_NO_TRUNC:
- *ap->a_retval = 0;
- return (0);
- default:
- return (EINVAL);
- }
- /* NOTREACHED */
-}
-
-int
-hpfs_vptofh(ap)
- struct vop_vptofh_args /* {
- struct vnode *a_vp;
- struct fid *a_fhp;
- } */ *ap;
-{
- register struct hpfsnode *hpp;
- register struct hpfid *hpfhp;
-
- hpp = VTOHP(ap->a_vp);
- hpfhp = (struct hpfid *)ap->a_fhp;
- hpfhp->hpfid_len = sizeof(struct hpfid);
- hpfhp->hpfid_ino = hpp->h_no;
- /* hpfhp->hpfid_gen = hpp->h_gen; */
- return (0);
-}
-
-
-/*
- * Global vfs data structures
- */
-struct vop_vector hpfs_vnodeops = {
- .vop_default = &default_vnodeops,
-
- .vop_access = hpfs_access,
- .vop_bmap = hpfs_bmap,
- .vop_cachedlookup = hpfs_lookup,
- .vop_close = hpfs_close,
- .vop_create = hpfs_create,
- .vop_fsync = hpfs_fsync,
- .vop_getattr = hpfs_getattr,
- .vop_inactive = hpfs_inactive,
- .vop_ioctl = hpfs_ioctl,
- .vop_lookup = vfs_cache_lookup,
- .vop_open = hpfs_open,
- .vop_pathconf = hpfs_pathconf,
- .vop_print = hpfs_print,
- .vop_read = hpfs_read,
- .vop_readdir = hpfs_readdir,
- .vop_reclaim = hpfs_reclaim,
- .vop_remove = hpfs_remove,
- .vop_setattr = hpfs_setattr,
- .vop_strategy = hpfs_strategy,
- .vop_write = hpfs_write,
- .vop_vptofh = hpfs_vptofh,
-};
diff --git a/sys/fs/hpfs/hpfsmount.h b/sys/fs/hpfs/hpfsmount.h
deleted file mode 100644
index 5ca42b3..0000000
--- a/sys/fs/hpfs/hpfsmount.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*-
- * Copyright (c) 1998, 1999 Semen Ustimenko (semenu@FreeBSD.org)
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#define HPFSMNT_TABLES 0x0001
-struct hpfs_args {
- char *fspec; /* block special device to mount */
- struct oexport_args export; /* network export information */
- uid_t uid; /* uid that owns hpfs files */
- gid_t gid; /* gid that owns hpfs files */
- mode_t mode; /* mask to be applied for hpfs perms */
- u_long flags; /* additional flags */
- u_char d2u[0x80];
- u_char u2d[0x80];
-};
diff --git a/sys/modules/hpfs/Makefile b/sys/modules/hpfs/Makefile
deleted file mode 100644
index 750fda0..0000000
--- a/sys/modules/hpfs/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
-# $FreeBSD$
-
-.PATH: ${.CURDIR}/../../fs/hpfs
-
-KMOD= hpfs
-SRCS= vnode_if.h \
- hpfs_vfsops.c hpfs_vnops.c hpfs_subr.c hpfs_lookup.c \
- hpfs_alsubr.c
-
-.include <bsd.kmod.mk>
OpenPOWER on IntegriCloud