diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2007-06-01 05:37:15 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2007-06-01 05:37:15 +0000 |
commit | ec42e67e3ece7b764cc447806ce367beb91df444 (patch) | |
tree | a64b0f9ee3677762cbc5f1d7556548fbcd0b725c | |
parent | 38941110e226cedb7c40f10d71f5f62cb24aa3c1 (diff) |
remove crufty adosfs. everytime we try to change a vfs layer interface,
adosfs has the issue and in an entirely different way. noone uses this
code so this is hte best way to handle the problem
diff from pedro who went to sleep but we need to move ahead; ok thib
-rw-r--r-- | sbin/Makefile | 4 | ||||
-rw-r--r-- | sbin/mount/mount.8 | 5 | ||||
-rw-r--r-- | sbin/mount/mount.c | 13 | ||||
-rw-r--r-- | sbin/mount_ados/Makefile | 11 | ||||
-rw-r--r-- | sbin/mount_ados/mount_ados.8 | 124 | ||||
-rw-r--r-- | sbin/mount_ados/mount_ados.c | 194 | ||||
-rw-r--r-- | sbin/mountd/mountd.c | 5 | ||||
-rw-r--r-- | share/man/man4/options.4 | 13 | ||||
-rw-r--r-- | share/man/man5/fstab.5 | 8 | ||||
-rw-r--r-- | share/man/man9/malloc.9 | 10 | ||||
-rw-r--r-- | sys/adosfs/adlookup.c | 277 | ||||
-rw-r--r-- | sys/adosfs/adosfs.h | 152 | ||||
-rw-r--r-- | sys/adosfs/adutil.c | 249 | ||||
-rw-r--r-- | sys/adosfs/advfsops.c | 758 | ||||
-rw-r--r-- | sys/adosfs/advnops.c | 1077 | ||||
-rw-r--r-- | sys/conf/files | 6 | ||||
-rw-r--r-- | sys/kern/Make.tags.inc | 5 | ||||
-rw-r--r-- | sys/kern/Makefile | 5 | ||||
-rw-r--r-- | sys/kern/vfs_conf.c | 15 | ||||
-rw-r--r-- | sys/sys/malloc.h | 16 | ||||
-rw-r--r-- | sys/sys/mount.h | 16 |
21 files changed, 25 insertions, 2938 deletions
diff --git a/sbin/Makefile b/sbin/Makefile index f207c62757c..17d41bc5dc8 100644 --- a/sbin/Makefile +++ b/sbin/Makefile @@ -1,10 +1,10 @@ -# $OpenBSD: Makefile,v 1.83 2007/05/26 21:39:45 grunk Exp $ +# $OpenBSD: Makefile,v 1.84 2007/06/01 05:37:14 deraadt Exp $ SUBDIR= atactl badsect bioctl brconfig ccdconfig clri dhclient \ disklabel dmesg dump dumpfs fdisk fsck fsck_ext2fs fsck_ffs \ fsck_msdos fsdb fsirand growfs ifconfig init iopctl ipsecctl \ isakmpd kbd lmccontrol mknod modload modunload mount \ - mount_ados mount_cd9660 mount_ext2fs mount_ffs mount_msdos \ + mount_cd9660 mount_ext2fs mount_ffs mount_msdos \ mount_nfs mount_ntfs mount_portal mount_procfs mount_udf \ mount_vnd mount_xfs mountd ncheck_ffs newfs newfs_msdos \ nfsd nmeaattach nologin pdisk pfctl pflogd ping ping6 quotacheck \ diff --git a/sbin/mount/mount.8 b/sbin/mount/mount.8 index b870c0c94c0..53146950a1a 100644 --- a/sbin/mount/mount.8 +++ b/sbin/mount/mount.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: mount.8,v 1.61 2007/05/31 19:19:45 jmc Exp $ +.\" $OpenBSD: mount.8,v 1.62 2007/06/01 05:37:14 deraadt Exp $ .\" $NetBSD: mount.8,v 1.11 1995/07/12 06:23:21 cgd Exp $ .\" .\" Copyright (c) 1980, 1989, 1991, 1993 @@ -30,7 +30,7 @@ .\" .\" @(#)mount.8 8.7 (Berkeley) 3/27/94 .\" -.Dd $Mdocdate: May 31 2007 $ +.Dd $Mdocdate: June 1 2007 $ .Dt MOUNT 8 .Os .Sh NAME @@ -360,7 +360,6 @@ with option .Xr mount 2 , .Xr fstab 5 , .Xr disklabel 8 , -.Xr mount_ados 8 , .Xr mount_cd9660 8 , .Xr mount_ext2fs 8 , .Xr mount_ffs 8 , diff --git a/sbin/mount/mount.c b/sbin/mount/mount.c index 77b95f4f6aa..a64b98b50b6 100644 --- a/sbin/mount/mount.c +++ b/sbin/mount/mount.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mount.c,v 1.44 2006/12/15 03:04:24 krw Exp $ */ +/* $OpenBSD: mount.c,v 1.45 2007/06/01 05:37:14 deraadt Exp $ */ /* $NetBSD: mount.c,v 1.24 1995/11/18 03:34:29 cgd Exp $ */ /* @@ -40,7 +40,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)mount.c 8.19 (Berkeley) 4/19/94"; #else -static char rcsid[] = "$OpenBSD: mount.c,v 1.44 2006/12/15 03:04:24 krw Exp $"; +static char rcsid[] = "$OpenBSD: mount.c,v 1.45 2007/06/01 05:37:14 deraadt Exp $"; #endif #endif /* not lint */ @@ -560,15 +560,6 @@ prmount(struct statfs *sf) header = getbsize(&headerlen, &blocksize); (void)printf("%s%s=%lu %s", !f++ ? " (" : ", ", "size", sf->mount_info.mfs_args.size / blocksize, header); - } else if (strcmp(sf->f_fstypename, MOUNT_ADOSFS) == 0) { - struct adosfs_args *adosfs_args = &sf->mount_info.adosfs_args; - - if (verbose || adosfs_args->uid || adosfs_args->gid) - (void)printf("%s%s=%u, %s=%u", !f++ ? " (" : ", ", - "uid", adosfs_args->uid, "gid", adosfs_args->gid); - if (verbose || adosfs_args->mask != 0755) - (void)printf("%s%s=0%o", !f++ ? " (" : ", ", - "mask", adosfs_args->mask); } else if (strcmp(sf->f_fstypename, MOUNT_MSDOS) == 0) { struct msdosfs_args *msdosfs_args = &sf->mount_info.msdosfs_args; diff --git a/sbin/mount_ados/Makefile b/sbin/mount_ados/Makefile index a185a6a77e4..e69de29bb2d 100644 --- a/sbin/mount_ados/Makefile +++ b/sbin/mount_ados/Makefile @@ -1,11 +0,0 @@ -# $OpenBSD: Makefile,v 1.3 1997/09/21 11:37:06 deraadt Exp $ - -PROG= mount_ados -SRCS= mount_ados.c getmntopts.c -MAN= mount_ados.8 - -MOUNT= ${.CURDIR}/../mount -CFLAGS+= -I${MOUNT} -.PATH: ${MOUNT} - -.include <bsd.prog.mk> diff --git a/sbin/mount_ados/mount_ados.8 b/sbin/mount_ados/mount_ados.8 index 3f505625a52..e69de29bb2d 100644 --- a/sbin/mount_ados/mount_ados.8 +++ b/sbin/mount_ados/mount_ados.8 @@ -1,124 +0,0 @@ -.\" $OpenBSD: mount_ados.8,v 1.13 2007/05/31 19:19:45 jmc Exp $ -.\" $NetBSD: mount_ados.8,v 1.3 1995/03/18 14:57:09 cgd Exp $ -.\" -.\" Copyright (c) 1993,1994 Christopher G. Demetriou -.\" 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. -.\" 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. -.\" -.Dd $Mdocdate: May 31 2007 $ -.Dt MOUNT_ADOS 8 -.Os -.Sh NAME -.Nm mount_ados -.Nd mount an AmigaDOS file system -.Sh SYNOPSIS -.Nm mount_ados -.Op Fl g Ar gid -.Op Fl m Ar mask -.Op Fl o Ar options -.Op Fl u Ar uid -.Ar special -.Ar node -.Sh DESCRIPTION -The -.Nm -command attaches the AmigaDOS filesystem residing on -the device -.Ar special -to the global filesystem namespace at the location -indicated by -.Ar node . -This command is invoked by -.Xr mount 8 -when using the syntax -.Bd -ragged -offset 4n -.Nm mount Op options --t ados -.Ar special Ar node -.Ed -.Pp -The -.Ar special -device must correspond to a partition registered in the -.Xr disklabel 5 . -.Pp -.Xr mount 8 -is normally run at boot time, but can be used by any user to mount an -AmigaDOS 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 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. -(For example, a mask of -.Li 755 -specifies that, by default, the owner should have -read, write, and execute permissions for files, but -others should only have read and execute permissions. -See -.Xr chmod 1 -for more information about octal file modes.) -Only the nine low-order bits of -.Ar mask -are used. -The default mask is taken from the -directory on which the file system is being mounted. -.It Fl o Ar options -Use the specified mount -.Ar options , -as described in -.Xr mount 8 . -.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. -.El -.Sh SEE ALSO -.Xr mount 2 , -.Xr disklabel 5 , -.Xr fstab 5 , -.Xr disklabel 8 , -.Xr mount 8 , -.Xr umount 8 -.Sh HISTORY -The -.Nm -utility first appeared in -.Nx 0.9 b. -.Sh CAVEATS -The -.Li ados -filesystem currently supports the Amiga fast file system. diff --git a/sbin/mount_ados/mount_ados.c b/sbin/mount_ados/mount_ados.c index 04ddef6924c..e69de29bb2d 100644 --- a/sbin/mount_ados/mount_ados.c +++ b/sbin/mount_ados/mount_ados.c @@ -1,194 +0,0 @@ -/* $OpenBSD: mount_ados.c,v 1.15 2007/03/20 03:45:54 tedu Exp $ */ -/* $NetBSD: mount_ados.c,v 1.5 1996/04/13 01:30:59 jtc Exp $ */ - -/* - * Copyright (c) 1994 Christopher G. Demetriou - * 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. - */ - -#ifndef lint -static char rcsid[] = "$OpenBSD: mount_ados.c,v 1.15 2007/03/20 03:45:54 tedu Exp $"; -#endif /* not lint */ - -#include <sys/cdefs.h> -#include <sys/param.h> -#include <sys/mount.h> -#include <sys/stat.h> -#include <ctype.h> -#include <err.h> -#include <errno.h> -#include <grp.h> -#include <pwd.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -#include "mntopts.h" - -const struct mntopt mopts[] = { - MOPT_STDOPTS, - { NULL } -}; - -gid_t a_gid(char *); -uid_t a_uid(char *); -mode_t a_mask(char *); -void usage(void); - -int -main(int argc, char *argv[]) -{ - struct adosfs_args args; - struct stat sb; - int c, mntflags, set_gid, set_uid, set_mask; - char *dev, dir[MAXPATHLEN]; - - mntflags = set_gid = set_uid = set_mask = 0; - (void)memset(&args, '\0', sizeof(args)); - - while ((c = getopt(argc, argv, "u:g:m:o:")) != -1) { - switch (c) { - 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.mask = a_mask(optarg); - set_mask = 1; - break; - case 'o': - getmntopts(optarg, mopts, &mntflags); - break; - case '?': - default: - usage(); - break; - } - } - - if (optind + 2 != argc) - usage(); - - dev = argv[optind]; - if (realpath(argv[optind + 1], dir) == NULL) - err(1, "realpath %s", argv[optind + 1]); - - args.fspec = dev; - args.export_info.ex_root = -2; /* unchecked anyway on DOS fs */ - if (mntflags & MNT_RDONLY) - args.export_info.ex_flags = MNT_EXRDONLY; - else - args.export_info.ex_flags = 0; - if (!set_gid || !set_uid || !set_mask) { - if (stat(dir, &sb) == -1) - err(1, "stat %s", dir); - - if (!set_uid) - args.uid = sb.st_uid; - if (!set_gid) - args.gid = sb.st_gid; - if (!set_mask) - args.mask = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO); - } - - if (mount(MOUNT_ADOSFS, dir, mntflags, &args) < 0) { - if (errno == EOPNOTSUPP) - errx(1, "%s: Filesystem not supported by kernel", dir); - else - err(1, "%s", dir); - } - 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; isdigit(*s); ++s); - if (!*s) - gid = atoi(gname); - else - errx(1, "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; isdigit(*s); ++s); - if (!*s) - uid = atoi(uname); - else - errx(1, "unknown user id: %s", uname); - } - return (uid); -} - -mode_t -a_mask(char *s) -{ - int done, rv; - char *ep; - - done = 0; - if (*s >= '0' && *s <= '7') { - done = 1; - rv = strtol(optarg, &ep, 8); - } - if (!done || rv < 0 || *ep) - errx(1, "invalid file mode: %s", s); - return (rv); -} - -void -usage(void) -{ - - fprintf(stderr, - "usage: mount_ados [-g gid] [-m mask] [-o options] [-u uid] special node\n"); - exit(1); -} diff --git a/sbin/mountd/mountd.c b/sbin/mountd/mountd.c index 383a0683f3c..01513c0d93a 100644 --- a/sbin/mountd/mountd.c +++ b/sbin/mountd/mountd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mountd.c,v 1.67 2006/05/29 16:49:42 avsm Exp $ */ +/* $OpenBSD: mountd.c,v 1.68 2007/06/01 05:37:14 deraadt Exp $ */ /* $NetBSD: mountd.c,v 1.31 1996/02/18 11:57:53 fvdl Exp $ */ /* @@ -710,7 +710,6 @@ get_exportlist(void) struct iso_args ia; struct mfs_args ma; struct msdosfs_args da; - struct adosfs_args aa; } targs; struct fsarray { int exflags; @@ -758,7 +757,6 @@ get_exportlist(void) !strncmp(fsp->f_fstypename, MOUNT_FFS, MFSNAMELEN) || !strncmp(fsp->f_fstypename, MOUNT_EXT2FS, MFSNAMELEN) || !strncmp(fsp->f_fstypename, MOUNT_MSDOS, MFSNAMELEN) || - !strncmp(fsp->f_fstypename, MOUNT_ADOSFS, MFSNAMELEN) || !strncmp(fsp->f_fstypename, MOUNT_CD9660, MFSNAMELEN)) { fstbl[i].exflags = MNT_DELEXPORT; fstbl[i].mntonname = fsp->f_mntonname; @@ -1583,7 +1581,6 @@ do_mount(struct exportlist *ep, struct grouplist *grp, int exflags, struct iso_args ia; struct mfs_args ma; struct msdosfs_args da; - struct adosfs_args aa; } args; char savedc = '\0'; u_int32_t **addrp; diff --git a/share/man/man4/options.4 b/share/man/man4/options.4 index 51371a866c3..bbe9bbd8226 100644 --- a/share/man/man4/options.4 +++ b/share/man/man4/options.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: options.4,v 1.181 2007/05/31 19:19:51 jmc Exp $ +.\" $OpenBSD: options.4,v 1.182 2007/06/01 05:37:14 deraadt Exp $ .\" $NetBSD: options.4,v 1.21 1997/06/25 03:13:00 thorpej Exp $ .\" .\" Copyright (c) 1998 Theo de Raadt @@ -34,7 +34,7 @@ .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .\" -.Dd $Mdocdate: May 31 2007 $ +.Dd $Mdocdate: June 1 2007 $ .Dt OPTIONS 4 .Os .Sh NAME @@ -337,15 +337,6 @@ Most machines need this if they are not running diskless. .It Cd option FFS2 Includes code implementing the enhanced Fast File System .Em ( FFS2 ) . -.It Cd option ADOSFS -Includes code implementing the AmigaDOS Fast File System -.Em ( ADOSFS ) . -Note that the Professional and Smart File Systems are -.Em not -supported. -See -.Xr mount_ados 8 -for details. .It Cd option EXT2FS Includes code implementing the Second Extended File System .Em ( EXT2FS ) . diff --git a/share/man/man5/fstab.5 b/share/man/man5/fstab.5 index 71768d415fd..3cc0e703eaf 100644 --- a/share/man/man5/fstab.5 +++ b/share/man/man5/fstab.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: fstab.5,v 1.39 2007/05/31 19:19:58 jmc Exp $ +.\" $OpenBSD: fstab.5,v 1.40 2007/06/01 05:37:14 deraadt Exp $ .\" $NetBSD: fstab.5,v 1.5.2.1 1995/11/16 20:11:11 pk Exp $ .\" .\" Copyright (c) 1980, 1989, 1991, 1993 @@ -30,7 +30,7 @@ .\" .\" @(#)fstab.5 8.1 (Berkeley) 6/5/93 .\" -.Dd $Mdocdate: May 31 2007 $ +.Dd $Mdocdate: June 1 2007 $ .Dt FSTAB 5 .Os .Sh NAME @@ -99,10 +99,6 @@ describes the type of the filesystem. The system currently supports the following types of filesystems: .Pp .Bl -tag -width indent -offset indent -compact -.It adosfs -An -.Tn AmigaDOS -filesystem. .It cd9660 An ISO 9660 CD-ROM filesystem. .It ext2fs diff --git a/share/man/man9/malloc.9 b/share/man/man9/malloc.9 index 79b33e65e14..bab48af8b31 100644 --- a/share/man/man9/malloc.9 +++ b/share/man/man9/malloc.9 @@ -1,4 +1,4 @@ -.\" $OpenBSD: malloc.9,v 1.38 2007/05/31 19:20:00 jmc Exp $ +.\" $OpenBSD: malloc.9,v 1.39 2007/06/01 05:37:14 deraadt Exp $ .\" $NetBSD: malloc.9,v 1.2 1996/10/30 05:29:54 lukem Exp $ .\" .\" Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: May 31 2007 $ +.Dd $Mdocdate: June 1 2007 $ .Dt MALLOC 9 .Os .Sh NAME @@ -220,12 +220,6 @@ Allocated tty structures. Argument lists & other mem used by exec. .It Dv M_MISCFSMNT Misc. FS mount structures. -.It Dv M_ADOSFSMNT -ADOSFS mount structures. -.It Dv M_ANODE -ADOSFS anode structures and tables. -.It Dv M_ADOSFSBITMAP -ADOSFS bitmap. .It Dv M_PFKEY Pfkey data. .It Dv M_TDB diff --git a/sys/adosfs/adlookup.c b/sys/adosfs/adlookup.c index 7ffc7f392f6..e69de29bb2d 100644 --- a/sys/adosfs/adlookup.c +++ b/sys/adosfs/adlookup.c @@ -1,277 +0,0 @@ -/* $OpenBSD: adlookup.c,v 1.14 2003/04/01 12:18:43 art Exp $ */ -/* $NetBSD: adlookup.c,v 1.17 1996/10/25 23:13:58 cgd Exp $ */ - -/* - * Copyright (c) 1994 Christian E. Hopps - * Copyright (c) 1996 Matthias Scheler - * 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 Christian E. Hopps. - * 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. - */ -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/vnode.h> -#include <sys/namei.h> -#include <sys/mount.h> -#include <sys/time.h> -#include <sys/queue.h> -#include <adosfs/adosfs.h> - -#ifdef ADOSFS_EXACTMATCH -#define strmatch(s1, l1, s2, l2, i) \ - ((l1) == (l2) && bcmp((s1), (s2), (l1)) == 0) -#else -#define strmatch(s1, l1, s2, l2, i) \ - ((l1) == (l2) && adoscaseequ((s1), (s2), (l1), (i))) -#endif - -/* - * adosfs lookup. enters with: - * pvp (parent vnode) referenced and locked. - * exit with: - * target vp referenced and locked. - * unlock pvp unless LOCKPARENT and at end of search. - * special cases: - * pvp == vp, just ref pvp, pvp already holds a ref and lock from - * caller, this will not occur with RENAME or CREATE. - * LOOKUP always unlocks parent if last element. (not now!?!?) - */ -int -adosfs_lookup(v) - void *v; -{ - struct vop_lookup_args /* { - struct vnode *a_dvp; - struct vnode **a_vpp; - struct componentname *a_cnp; - } */ *sp = v; - int nameiop, last, lockp, wantp, flags, error, nocache, i; - struct componentname *cnp; - struct vnode **vpp; /* place to store result */ - struct anode *ap; /* anode to find */ - struct vnode *vdp; /* vnode of search dir */ - struct anode *adp; /* anode of search dir */ - struct ucred *ucp; /* lookup credentials */ - struct proc *p; - u_int32_t plen, hval; - daddr_t bn; - char *pelt; - -#ifdef ADOSFS_DIAGNOSTIC - advopprint(sp); -#endif - cnp = sp->a_cnp; - vdp = sp->a_dvp; - adp = VTOA(vdp); - vpp = sp->a_vpp; - *vpp = NULL; - ucp = cnp->cn_cred; - nameiop = cnp->cn_nameiop; - cnp->cn_flags &= ~PDIRUNLOCK; - flags = cnp->cn_flags; - last = flags & ISLASTCN; - lockp = flags & LOCKPARENT; - wantp = flags & (LOCKPARENT | WANTPARENT); - pelt = cnp->cn_nameptr; - plen = cnp->cn_namelen; - p = cnp->cn_proc; - nocache = 0; - - /* - * check that: - * pvp is a dir, and that the user has rights to access - */ - if (vdp->v_type != VDIR) - return (ENOTDIR); - if ((error = VOP_ACCESS(vdp, VEXEC, ucp, cnp->cn_proc)) != 0) - return (error); - if ((flags & ISLASTCN) && (vdp->v_mount->mnt_flag & MNT_RDONLY) && - (cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME)) - return (EROFS); - - /* - * Before tediously performing a linear scan of the directory, - * check the name cache to see if the directory/name pair - * we are looking for is known already. - */ - if ((error = cache_lookup(vdp, vpp, cnp)) >= 0) - return (error); - - /* - * fake a '.' - */ - if (plen == 1 && pelt[0] == '.') { - /* see special cases in prologue. */ - *vpp = vdp; - goto found; - } - /* - * fake a ".." - */ - if (flags & ISDOTDOT) { - if (vdp->v_type == VDIR && (vdp->v_flag & VROOT)) - panic("adosfs .. attempted lookup through root"); - /* - * cannot get `..' while `vdp' is locked - * e.g. procA holds lock on `..' and waits for `vdp' - * we wait for `..' and hold lock on `vdp'. deadlock. - * because `vdp' may have been achieved through symlink - * fancy detection code that decreases the race - * window size is not reasonably possible. - * - * basically unlock the parent, try and lock the child (..) - * if that fails relock the parent (ignoring error) and - * fail. Otherwise we have the child (..) if this is the - * last and the caller requested LOCKPARENT, attempt to - * relock the parent. If that fails unlock the child (..) - * and fail. Otherwise we have succeeded. - * - */ - VOP_UNLOCK(vdp, 0, p); /* race */ - cnp->cn_flags |= PDIRUNLOCK; - if ((error = VFS_VGET(vdp->v_mount, ABLKTOINO(adp->pblock), - vpp)) != 0) { - if (vn_lock(vdp, LK_EXCLUSIVE | LK_RETRY, p) == 0) - cnp->cn_flags &= ~PDIRUNLOCK; - } else if (last && lockp) { - if ((error = vn_lock(vdp, LK_EXCLUSIVE | LK_RETRY, p))) - vput(*vpp); - else - cnp->cn_flags &= ~PDIRUNLOCK; - } - if (error) { - *vpp = NULL; - return (error); - } - goto found_lockdone; - } - - /* - * hash the name and grab the first block in chain - * then walk the chain. if chain has not been fully - * walked before, track the count in `tabi' - */ - hval = adoshash(pelt, plen, adp->ntabent, IS_INTER(adp->amp)); - bn = adp->tab[hval]; - i = min(adp->tabi[hval], 0); - while (bn != 0) { - if ((error = VFS_VGET(vdp->v_mount, ABLKTOINO(bn), vpp)) != - 0) { -#ifdef ADOSFS_DIAGNOSTIC - printf("[aget] %d)", error); -#endif - /* XXX check to unlock parent possibly? */ - return(error); - } - ap = VTOA(*vpp); - if (i <= 0) { - if (--i < adp->tabi[hval]) - adp->tabi[hval] = i; - /* - * last header in chain lock count down by - * negating it to positive - */ - if (ap->hashf == 0) { -#ifdef DEBUG - if (i != adp->tabi[hval]) - panic("adlookup: wrong chain count"); -#endif - adp->tabi[hval] = -adp->tabi[hval]; - } - } - if (strmatch(pelt, plen, ap->name, strlen(ap->name), - IS_INTER(adp->amp))) - goto found; - bn = ap->hashf; - vput(*vpp); - } - *vpp = NULL; - /* - * not found - */ - if ((nameiop == CREATE || nameiop == RENAME) && last) { - if ((error = VOP_ACCESS(vdp, VWRITE, ucp, cnp->cn_proc)) != 0) - { -#ifdef ADOSFS_DIAGNOSTIC - printf("[VOP_ACCESS] %d)", error); -#endif - return (error); - } - if (lockp == 0) { - VOP_UNLOCK(vdp, 0, p); - cnp->cn_flags |= PDIRUNLOCK; - } - cnp->cn_nameiop |= SAVENAME; -#ifdef ADOSFS_DIAGNOSTIC - printf("EJUSTRETURN)"); -#endif - return(EJUSTRETURN); - } - if ((cnp->cn_flags & MAKEENTRY) && nameiop != CREATE) - cache_enter(vdp, NULL, cnp); -#ifdef ADOSFS_DIAGNOSTIC - printf("ENOENT)"); -#endif - return(ENOENT); - -found: - if (nameiop == DELETE && last) { - if ((error = VOP_ACCESS(vdp, VWRITE, ucp, cnp->cn_proc)) != 0) - { - if (vdp != *vpp) - vput(*vpp); - *vpp = NULL; - return (error); - } - nocache = 1; - } - if (nameiop == RENAME && wantp && last) { - if (vdp == *vpp) - return(EISDIR); - if ((error = VOP_ACCESS(vdp, VWRITE, ucp, cnp->cn_proc)) != 0) - { - vput(*vpp); - *vpp = NULL; - return (error); - } - cnp->cn_flags |= SAVENAME; - nocache = 1; - } - if (vdp == *vpp) - VREF(vdp); - else if (lockp == 0 || last == 0) { - VOP_UNLOCK(vdp, 0, p); - cnp->cn_flags |= PDIRUNLOCK; - } -found_lockdone: - if ((cnp->cn_flags & MAKEENTRY) && nocache == 0) - cache_enter(vdp, *vpp, cnp); - -#ifdef ADOSFS_DIAGNOSTIC - printf("0)\n"); -#endif - return(0); -} diff --git a/sys/adosfs/adosfs.h b/sys/adosfs/adosfs.h index 843c39e6b02..e69de29bb2d 100644 --- a/sys/adosfs/adosfs.h +++ b/sys/adosfs/adosfs.h @@ -1,152 +0,0 @@ -/* $OpenBSD: adosfs.h,v 1.12 2003/11/13 17:23:57 drahn Exp $ */ -/* $NetBSD: adosfs.h,v 1.12 1996/10/08 22:18:02 thorpej Exp $ */ - -/* - * Copyright (c) 1994 Christian E. Hopps - * Copyright (c) 1996 Matthias Scheler - * 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 Christian E. Hopps. - * 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. - */ - -/* - * Amigados datestamp. (from 1/1/1978 00:00:00 local) - */ -struct datestamp { - u_int32_t days; - u_int32_t mins; - u_int32_t ticks; /* 20000 * (ticks % 50) = useconds */ - /* ticks / 50 = seconds */ -}; - -enum anode_type { AROOT, ADIR, AFILE, ALDIR, ALFILE, ASLINK }; - -/* - * similar to inode's, we use to represent: - * the root dir, reg dirs, reg files and extension blocks - * note the ``tab'' is a hash table for r/d, and a data block - * table for f/e. it is always ANODETABSZ(ap) bytes in size. - */ -struct anode { - LIST_ENTRY(anode) link; - enum anode_type type; - char name[31]; /* (r/d/f) name for object */ - struct datestamp mtimev; /* (r) volume modified */ - struct datestamp created; /* (r) volume created */ - struct datestamp mtime; /* (r/d/f) last modified */ - struct adosfsmount *amp; /* owner file system */ - struct vnode *vp; /* owner vnode */ - struct lockf *a_lockf; /* byte level lock list */ - struct lock a_lock; /* anode lock */ - u_int32_t fsize; /* (f) size of file in bytes */ - daddr_t block; /* block num */ - daddr_t pblock; /* (d/f/e) parent block */ - daddr_t hashf; /* (d/f) hash forward */ - daddr_t extb; /* (f/e) extension block number */ - daddr_t linkto; /* (hd/hf) hdr this link points at */ - daddr_t linknext; /* (d/f/hd/hf) next chain link/head */ - daddr_t lastlindblk; /* (f/hf) last logical indirect blk */ - daddr_t lastindblk; /* (f/hf) last indirect block read */ - daddr_t *tab; /* (r/d) hash table */ - int *tabi; /* (r/d) table info */ - int ntabent; /* (r/d) number of entries in table */ - int nwords; /* size of blocks in 32-bit words */ - int adprot; /* (d/f) amigados protection bits */ - uid_t uid; /* (d/f) uid of directory/file */ - gid_t gid; /* (d/f) gid of directory/file */ - char *slinkto; /* name of file or dir */ -}; -#define VTOA(vp) ((struct anode *)(vp)->v_data) -#define ATOV(ap) ((ap)->vp) -#define ANODETABENT(ap) ((ap)->nwords - 56) -#define ANODENDATBLKENT(ap) ((ap)->nwords - 56) -#define ABLKTOINO(bn) ((ino_t)(bn)) -#define AINOTOBLK(bn) ((daddr_t)(bn)) -/* - * mount data - */ -#define ANODEHASHSZ (512) - -struct adosfsmount { - LIST_HEAD(anodechain, anode) anodetab[ANODEHASHSZ]; - struct mount *mp; /* owner mount */ - u_int32_t dostype; /* type of volume */ - daddr_t rootb; /* root block number */ - int secsperblk; /* sectors per block */ - int bsize; /* size of blocks */ - int nwords; /* size of blocks in long words */ - int dbsize; /* data bytes per block */ - uid_t uid; /* uid of mounting user */ - gid_t gid; /* gid of mounting user */ - mode_t mask; /* mode mask */ - struct vnode *devvp; /* blk device mounted on */ - struct vnode *rootvp; /* out root vnode */ - struct netexport export; - u_int32_t *bitmap; /* allocation bitmap */ - u_int32_t numblks; /* number of usable blocks */ - u_int32_t freeblks; /* number of free blocks */ -}; -#define VFSTOADOSFS(mp) ((struct adosfsmount *)(mp)->mnt_data) - -#define IS_FFS(amp) ((amp)->dostype & 1) -#define IS_INTER(amp) (((amp)->dostype & 7) > 1) - -/* - * AmigaDOS block stuff. - */ -#define BBOFF (0) - -#define BPT_SHORT ((u_int32_t)2) -#define BPT_DATA ((u_int32_t)8) -#define BPT_LIST ((u_int32_t)16) - -#define BST_RDIR ((u_int32_t)1) -#define BST_UDIR ((u_int32_t)2) -#define BST_SLINK ((u_int32_t)3) -#define BST_LDIR ((u_int32_t)4) -#define BST_FILE ((u_int32_t)-3) -#define BST_LFILE ((u_int32_t)-4) - -#define OFS_DATA_OFFSET (24) - -/* - * utility protos - */ -#define adoswordn(bp,wn) betoh32(*((u_int32_t *)(bp)->b_data + (wn))) - -u_int32_t adoscksum(struct buf *, int); -int adoscaseequ(const char *, const char *, int, int); -int adoshash(const char *, int, int, int); -int adunixprot(int); -int adosfs_getblktype(struct adosfsmount *, struct buf *); - -struct vnode *adosfs_ahashget(struct mount *, ino_t); -int adosfs_ainshash(struct adosfsmount *, struct anode *); -void adosfs_aremhash(struct anode *); - -int adosfs_lookup(void *); - -extern int (**adosfs_vnodeop_p)(void *); diff --git a/sys/adosfs/adutil.c b/sys/adosfs/adutil.c index b9f0cb48a0a..e69de29bb2d 100644 --- a/sys/adosfs/adutil.c +++ b/sys/adosfs/adutil.c @@ -1,249 +0,0 @@ -/* $OpenBSD: adutil.c,v 1.17 2007/05/28 22:17:21 pyr Exp $ */ -/* $NetBSD: adutil.c,v 1.15 1996/10/13 02:52:07 christos Exp $ */ - -/* - * Copyright (c) 1994 Christian E. Hopps - * Copyright (c) 1996 Matthias Scheler - * 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 Christian E. Hopps. - * 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. - */ -#include <sys/param.h> -#include <sys/vnode.h> -#include <sys/mount.h> -#include <sys/proc.h> -#include <sys/systm.h> -#include <sys/malloc.h> -#include <sys/lock.h> -#include <sys/time.h> -#include <sys/queue.h> -#include <sys/buf.h> - -#include <machine/endian.h> - -#include <adosfs/adosfs.h> - -/* - * look for anode in the mount's hash table, return locked. - */ -#define AHASH(an) ((an) & (ANODEHASHSZ - 1)) - -static __inline char CapitalChar(char, int); - -struct vnode * -adosfs_ahashget(mp, an) - struct mount *mp; - ino_t an; -{ - struct anodechain *hp; - struct anode *ap; - struct proc *p = curproc; /* XXX */ - struct vnode *vp; - - hp = &VFSTOADOSFS(mp)->anodetab[AHASH(an)]; - - for (;;) { - LIST_FOREACH(ap, hp, link) { - if (ABLKTOINO(ap->block) == an) { - vp = ATOV(ap); - if (!vget(vp, LK_EXCLUSIVE, p)) - return (vp); - break; - } - } - if (ap == NULL) - return (NULL); - } - /* NOTREACHED */ -} - -/* - * insert in hash table and lock - */ -int -adosfs_ainshash(amp, ap) - struct adosfsmount *amp; - struct anode *ap; -{ - struct anodechain *hp; - struct anode *aq; - - /* lock the inode, then put it on the appropriate hash list */ - lockmgr(&ap->a_lock, LK_EXCLUSIVE, NULL); - - hp = &->anodetab[AHASH(ap->block)]; - - LIST_FOREACH(aq, hp, link) { - if (aq->block == ap->block) { - lockmgr(&ap->a_lock, LK_RELEASE, NULL); - return (EEXIST); - } - } - - LIST_INSERT_HEAD(hp, ap, link); - return (0); -} - -void -adosfs_aremhash(ap) - struct anode *ap; -{ - - if (ap->link.le_prev != NULL) - LIST_REMOVE(ap, link); -} - -int -adosfs_getblktype(amp, bp) - struct adosfsmount *amp; - struct buf *bp; -{ - if (adoscksum(bp, amp->nwords)) { -#ifdef DIAGNOSTIC - printf("adosfs: aget: cksum of blk %d failed\n", - bp->b_blkno / amp->secsperblk); -#endif - return (-1); - } - - /* - * check primary block type - */ - if (adoswordn(bp, 0) != BPT_SHORT) { -#ifdef DIAGNOSTIC - printf("adosfs: aget: bad primary type blk %d\n", - bp->b_blkno / amp->secsperblk); -#endif - return (-1); - } - - switch (adoswordn(bp, amp->nwords - 1)) { - case BST_RDIR: /* root block */ - return (AROOT); - case BST_LDIR: /* hard link to dir */ - return (ALDIR); - case BST_UDIR: /* user dir */ - return (ADIR); - case BST_LFILE: /* hard link to file */ - return (ALFILE); - case BST_FILE: /* file header */ - return (AFILE); - case BST_SLINK: /* soft link */ - return (ASLINK); - } - return (-1); -} - -int -adunixprot(adprot) - int adprot; -{ - if (adprot & 0xc000ee00) { - adprot = (adprot & 0xee0e) >> 1; - return (((adprot & 0x7) << 6) | - ((adprot & 0x700) >> 5) | - ((adprot & 0x7000) >> 12)); - } - else { - adprot = (adprot >> 1) & 0x7; - return((adprot << 6) | (adprot << 3) | adprot); - } -} - -static __inline char -CapitalChar(ch, inter) - char ch; - int inter; -{ - if ((ch >= 'a' && ch <= 'z') || - (inter && ch >= '\xe0' && ch <= '\xfe' && ch != '\xf7')) - return(ch - ('a' - 'A')); - return(ch); -} - -u_int32_t -adoscksum(bp, n) - struct buf *bp; - int n; -{ - u_int32_t sum, *lp; - - lp = (u_int32_t *)bp->b_data; - sum = 0; - - while (n--) - sum += betoh32(*lp++); - return(sum); -} - -int -adoscaseequ(name1, name2, len, inter) - const char *name1, *name2; - int len, inter; -{ - while (len-- > 0) - if (CapitalChar(*name1++, inter) != - CapitalChar(*name2++, inter)) - return 0; - - return 1; -} - -int -adoshash(nam, namlen, nelt, inter) - const char *nam; - int namlen, nelt, inter; -{ - int val; - - val = namlen; - while (namlen--) - val = ((val * 13) + (u_char)CapitalChar(*nam++, inter)) & - 0x7ff; - return(val % nelt); -} - -#ifdef notyet -/* - * datestamp is local time, tv is to be UTC - */ -int -dstotv(dsp, tvp) - struct datestamp *dsp; - struct timeval *tvp; -{ -} - -/* - * tv is UTC, datestamp is to be local time - */ -int -tvtods(tvp, dsp) - struct timeval *tvp; - struct datestamp *dsp; -{ -} -#endif diff --git a/sys/adosfs/advfsops.c b/sys/adosfs/advfsops.c index 3653ccafc8d..e69de29bb2d 100644 --- a/sys/adosfs/advfsops.c +++ b/sys/adosfs/advfsops.c @@ -1,758 +0,0 @@ -/* $OpenBSD: advfsops.c,v 1.26 2007/05/29 06:28:16 otto Exp $ */ -/* $NetBSD: advfsops.c,v 1.24 1996/12/22 10:10:12 cgd Exp $ */ - -/* - * Copyright (c) 1994 Christian E. Hopps - * Copyright (c) 1996 Matthias Scheler - * 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 Christian E. Hopps. - * 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. - */ -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/vnode.h> -#include <sys/mount.h> -#include <sys/proc.h> -#include <sys/time.h> -#include <sys/malloc.h> -#include <sys/disklabel.h> -#include <sys/fcntl.h> -#include <sys/namei.h> -#include <sys/ioctl.h> -#include <sys/queue.h> -#include <sys/buf.h> - -#include <machine/endian.h> - -#include <miscfs/specfs/specdev.h> /* XXX */ -#include <adosfs/adosfs.h> - -int adosfs_init(struct vfsconf *); -int adosfs_mount(struct mount *, const char *, void *, struct nameidata *, - struct proc *); -int adosfs_start(struct mount *, int, struct proc *); -int adosfs_unmount(struct mount *, int, struct proc *); -int adosfs_root(struct mount *, struct vnode **); -int adosfs_quotactl(struct mount *, int, uid_t, caddr_t, struct proc *); -int adosfs_statfs(struct mount *, struct statfs *, struct proc *); -int adosfs_sync(struct mount *, int, struct ucred *, struct proc *); -int adosfs_vget(struct mount *, ino_t, struct vnode **); -int adosfs_fhtovp(struct mount *, struct fid *, struct vnode **); - -int adosfs_vptofh(struct vnode *, struct fid *); - -int adosfs_mountfs(struct vnode *, struct mount *, struct proc *); -int adosfs_loadbitmap(struct adosfsmount *); - -int -adosfs_mount(mp, path, data, ndp, p) - struct mount *mp; - const char *path; - void *data; - struct nameidata *ndp; - struct proc *p; -{ - struct vnode *devvp; - struct adosfs_args args; - struct adosfsmount *amp; - size_t size; - int error; - mode_t accessmode; - - error = copyin(data, &args, sizeof(struct adosfs_args)); - if (error) - return(error); - -#if 0 - if (mp->mnt_flag & MNT_UPDATE) - return (EOPNOTSUPP); -#endif - if ((mp->mnt_flag & MNT_RDONLY) == 0) - return (EROFS); - /* - * 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) { - amp = VFSTOADOSFS(mp); - if (args.fspec == 0) - return (vfs_export(mp, &->export, - &args.export_info)); - } - /* - * 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, UIO_USERSPACE, args.fspec, p); - if ((error = namei(ndp)) != 0) - return (error); - devvp = ndp->ni_vp; - - if (devvp->v_type != VBLK) { - vrele(devvp); - return (ENOTBLK); - } - if (major(devvp->v_rdev) >= nblkdev) { - vrele(devvp); - return (ENXIO); - } - /* - * If mount by non-root, then verify that user has necessary - * permissions on the device. - */ - if (p->p_ucred->cr_uid != 0) { - accessmode = VREAD; - if ((mp->mnt_flag & MNT_RDONLY) == 0) - accessmode |= VWRITE; - vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_ACCESS(devvp, accessmode, p->p_ucred, p); - if (error) { - vput(devvp); - return (error); - } - VOP_UNLOCK(devvp, 0, p); - } -/* MNT_UPDATE? */ - if ((error = adosfs_mountfs(devvp, mp, p)) != 0) { - vrele(devvp); - return (error); - } - amp = VFSTOADOSFS(mp); - amp->uid = args.uid; - amp->gid = args.gid; - amp->mask = args.mask; - (void)copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size); - bzero(mp->mnt_stat.f_mntonname + size, MNAMELEN - size); - (void)copyinstr(args.fspec, mp->mnt_stat.f_mntfromname, MNAMELEN - 1, - &size); - bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); - bcopy(&args, &mp->mnt_stat.mount_info.adosfs_args, sizeof(args)); - return (0); -} - -int -adosfs_mountfs(devvp, mp, p) - struct vnode *devvp; - struct mount *mp; - struct proc *p; -{ - struct disklabel dl; - struct partition *parp; - struct adosfsmount *amp; - struct buf *bp; - struct vnode *rvp; - int error, part, i; - - part = DISKPART(devvp->v_rdev); - amp = NULL; - - /* - * Disallow multiple mounts of the same device. - * Disallow mounting of a device that is currently in use - * (except for root, which might share swap device for miniroot). - * Flush out any old buffers remaining from a previous use. - */ - if ((error = vfs_mountedon(devvp)) != 0) - return (error); - if (vcount(devvp) > 1 && devvp != rootvp) - return (EBUSY); - if ((error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0)) != 0) - return (error); - - /* - * open blkdev and read root block - */ - if ((error = VOP_OPEN(devvp, FREAD, NOCRED, p)) != 0) - return (error); - error = VOP_IOCTL(devvp, DIOCGDINFO,(caddr_t)&dl, FREAD, NOCRED, p); - if (error) - goto fail; - - parp = &dl.d_partitions[part]; - amp = malloc(sizeof(struct adosfsmount), M_ADOSFSMNT, M_WAITOK); - bzero((char *)amp, sizeof(struct adosfsmount)); - amp->mp = mp; - if (dl.d_type == DTYPE_FLOPPY) { - amp->bsize = dl.d_secsize; - amp->secsperblk = 1; - } - else { - amp->bsize = DISKLABELV1_FFS_BSIZE(parp->fragblock); - amp->secsperblk = DISKLABELV1_FFS_FRAG(parp->p_fragblock); - } - amp->rootb = (parp->p_size / amp->secsperblk - 1 + parp->p_cpg) >> 1; - amp->numblks = parp->p_size / amp->secsperblk - parp->p_cpg; - - bp = NULL; - if ((error = bread(devvp, (daddr_t)BBOFF, - amp->bsize, NOCRED, &bp)) != 0) - goto fail; - - amp->dostype = adoswordn(bp, 0); - brelse(bp); - - if (amp->dostype < 0x444f5300 || amp->dostype > 0x444f5305) { - error = EINVAL; - goto fail; - } - - amp->nwords = amp->bsize >> 2; - amp->dbsize = amp->bsize - (IS_FFS(amp) ? 0 : OFS_DATA_OFFSET); - amp->devvp = devvp; - - mp->mnt_data = (qaddr_t)amp; - mp->mnt_stat.f_fsid.val[0] = (int32_t)devvp->v_rdev; - mp->mnt_stat.f_fsid.val[1] = makefstype(MOUNT_ADOSFS); - mp->mnt_flag |= MNT_LOCAL; - devvp->v_specmountpoint = mp; - - /* - * init anode table. - */ - for (i = 0; i < ANODEHASHSZ; i++) - LIST_INIT(&->anodetab[i]); - - /* - * get the root anode, if not a valid fs this will fail. - */ - if ((error = VFS_ROOT(mp, &rvp)) != 0) - goto fail; - /* allocate and load bitmap, set free space */ - amp->bitmap = malloc(((amp->numblks + 31) / 32) * sizeof(*amp->bitmap), - M_ADOSFSBITMAP, M_WAITOK); - adosfs_loadbitmap(amp); - if (mp->mnt_flag & MNT_RDONLY && amp->bitmap) { - /* - * Don't need the bitmap any more if it's read-only. - */ - free(amp->bitmap, M_ADOSFSBITMAP); - amp->bitmap = NULL; - } - vput(rvp); - - return(0); - -fail: - (void) VOP_CLOSE(devvp, FREAD, NOCRED, p); - if (amp && amp->bitmap) - free(amp->bitmap, M_ADOSFSBITMAP); - if (amp) - free(amp, M_ADOSFSMNT); - return (error); -} - -int -adosfs_start(mp, flags, p) - struct mount *mp; - int flags; - struct proc *p; -{ - - return (0); -} - -int -adosfs_unmount(mp, mntflags, p) - struct mount *mp; - int mntflags; - struct proc *p; -{ - struct adosfsmount *amp; - int error, flags; - - flags = 0; - if (mntflags & MNT_FORCE) - flags |= FORCECLOSE; - if ((error = vflush(mp, NULLVP, flags)) != 0) - return (error); - amp = VFSTOADOSFS(mp); - amp->devvp->v_specmountpoint = NULL; - error = VOP_CLOSE(amp->devvp, FREAD, NOCRED, p); - vrele(amp->devvp); - if (amp->bitmap) - free(amp->bitmap, M_ADOSFSBITMAP); - free(amp, M_ADOSFSMNT); - mp->mnt_data = (qaddr_t)0; - mp->mnt_flag &= ~MNT_LOCAL; - return (error); -} - -int -adosfs_root(mp, vpp) - struct mount *mp; - struct vnode **vpp; -{ - struct vnode *nvp; - int error; - - if ((error = VFS_VGET(mp, ABLKTOINO(VFSTOADOSFS(mp)->rootb), &nvp)) != - 0) - return (error); - /* XXX verify it's a root block? */ - *vpp = nvp; - return (0); -} - -int -adosfs_statfs(mp, sbp, p) - struct mount *mp; - struct statfs *sbp; - struct proc *p; -{ - struct adosfsmount *amp; - - amp = VFSTOADOSFS(mp); - sbp->f_bsize = amp->bsize; - sbp->f_iosize = amp->dbsize; - sbp->f_blocks = amp->numblks; - sbp->f_bfree = amp->freeblks; - sbp->f_bavail = amp->freeblks; - sbp->f_files = 0; /* who knows */ - sbp->f_ffree = 0; /* " " */ - if (sbp != &mp->mnt_stat) { - bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN); - bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN); - bcopy(&mp->mnt_stat.mount_info.adosfs_args, - &sbp->mount_info.adosfs_args, sizeof(struct adosfs_args)); - } - strncpy(sbp->f_fstypename, mp->mnt_vfc->vfc_name, MFSNAMELEN); - return (0); -} - -/* - * lookup an anode, check mount's hash table if not found, create - * return locked and referenced al la vget(vp, 1); - */ -int -adosfs_vget(mp, an, vpp) - struct mount *mp; - ino_t an; - struct vnode **vpp; -{ - struct adosfsmount *amp; - struct vnode *vp; - struct anode *ap; - struct buf *bp; - char *nam, *tmp; - int namlen, error; - - error = 0; - amp = VFSTOADOSFS(mp); - bp = NULL; - - /* - * check hash table. we are done if found - */ - retry: - if ((*vpp = adosfs_ahashget(mp, an)) != NULL) - return (0); - - error = getnewvnode(VT_ADOSFS, mp, adosfs_vnodeop_p, &vp); - if (error) - return (error); - - /* - * setup, insert in hash, and lock before io. - */ - vp->v_data = ap = malloc(sizeof(struct anode), M_ANODE, M_WAITOK); - bzero(ap, sizeof(struct anode)); - lockinit(&ap->a_lock, PINOD, "anode", 0, 0); - ap->vp = vp; - ap->amp = amp; - ap->block = AINOTOBLK(an); - ap->nwords = amp->nwords; - error = adosfs_ainshash(amp, ap); - - if (error) { - vrele (vp); - - if (error == EEXIST) - goto retry; - - return (error); - } - - if ((error = bread(amp->devvp, an * amp->secsperblk, amp->bsize, - NOCRED, &bp)) != 0) { - vput(vp); - return (error); - } - - /* - * get type and fill rest in based on that. - */ - switch (ap->type = adosfs_getblktype(amp, bp)) { - case AROOT: - vp->v_type = VDIR; - vp->v_flag |= VROOT; - ap->mtimev.days = adoswordn(bp, ap->nwords - 10); - ap->mtimev.mins = adoswordn(bp, ap->nwords - 9); - ap->mtimev.ticks = adoswordn(bp, ap->nwords - 8); - ap->created.days = adoswordn(bp, ap->nwords - 7); - ap->created.mins = adoswordn(bp, ap->nwords - 6); - ap->created.ticks = adoswordn(bp, ap->nwords - 5); - break; - case ALDIR: - case ADIR: - vp->v_type = VDIR; - break; - case ALFILE: - case AFILE: - vp->v_type = VREG; - ap->fsize = adoswordn(bp, ap->nwords - 47); - break; - case ASLINK: /* XXX soft link */ - vp->v_type = VLNK; - /* - * convert from BCPL string and - * from: "part:dir/file" to: "/part/dir/file" - */ - nam = bp->b_data + (6 * sizeof(u_int32_t)); - namlen = strlen(nam); - tmp = nam; - while (*tmp && *tmp != ':') - tmp++; - if (*tmp == 0) { - ap->slinkto = malloc(namlen + 1, M_ANODE, M_WAITOK); - bcopy(nam, ap->slinkto, namlen); - } else if (*nam == ':') { - ap->slinkto = malloc(namlen + 1, M_ANODE, M_WAITOK); - bcopy(nam, ap->slinkto, namlen); - ap->slinkto[0] = '/'; - } else { - ap->slinkto = malloc(namlen + 2, M_ANODE, M_WAITOK); - ap->slinkto[0] = '/'; - bcopy(nam, &ap->slinkto[1], namlen); - ap->slinkto[tmp - nam + 1] = '/'; - namlen++; - } - ap->slinkto[namlen] = 0; - ap->fsize = namlen; - break; - default: - brelse(bp); - vput(vp); - return (EINVAL); - } - - /* - * Get appropriate data from this block; hard link needs - * to get other data from the "real" block. - */ - - /* - * copy in name (from original block) - */ - nam = bp->b_data + (ap->nwords - 20) * sizeof(u_int32_t); - namlen = *(u_char *)nam++; - if (namlen > 30) { -#ifdef DIAGNOSTIC - printf("adosfs: aget: name length too long blk %d\n", an); -#endif - brelse(bp); - vput(vp); - return (EINVAL); - } - bcopy(nam, ap->name, namlen); - ap->name[namlen] = 0; - - /* - * if dir alloc hash table and copy it in - */ - if (vp->v_type == VDIR) { - int i; - - ap->ntabent = ANODETABENT(ap); - ap->tab = malloc(ap->ntabent * (sizeof(daddr_t) + sizeof(int)), - M_ANODE, M_WAITOK); - ap->tabi = (int *)&ap->tab[ap->ntabent]; - bzero(ap->tabi, ANODETABENT(ap) * sizeof(int)); - for (i = 0; i < ap->ntabent; i++) - ap->tab[i] = (daddr_t)adoswordn(bp, i + 6); - } - - /* - * misc. - */ - ap->pblock = (daddr_t)adoswordn(bp, ap->nwords - 3); - ap->hashf = (daddr_t)adoswordn(bp, ap->nwords - 4); - ap->linknext = (daddr_t)adoswordn(bp, ap->nwords - 10); - ap->linkto = (daddr_t)adoswordn(bp, ap->nwords - 11); - - /* - * setup last indirect block cache. - */ - ap->lastlindblk = 0; - if (ap->type == AFILE) { - ap->lastindblk = ap->block; - if (adoswordn(bp, ap->nwords - 10)) - ap->linkto = ap->block; - } else if (ap->type == ALFILE) { - ap->lastindblk = ap->linkto; - brelse(bp); - bp = NULL; - error = bread(amp->devvp, ap->linkto * amp->secsperblk, - amp->bsize, NOCRED, &bp); - ap->fsize = adoswordn(bp, ap->nwords - 47); - /* - * Should ap->block be set to the real file header block? - */ - ap->block = ap->linkto; - } - - if (ap->type == AROOT) { - ap->adprot = 15; - ap->uid = amp->uid; - ap->gid = amp->gid; - } else { - ap->adprot = adoswordn(bp, ap->nwords - 48) ^ 15; - /* - * Get uid/gid from extensions in file header - * (really need to know if this is a muFS partition) - */ - ap->uid = (adoswordn(bp, ap->nwords - 49) >> 16) & 0xffff; - ap->gid = adoswordn(bp, ap->nwords - 49) & 0xffff; - if (ap->uid || ap->gid) { - if (ap->uid == 0xffff) - ap->uid = 0; - if (ap->gid == 0xffff) - ap->gid = 0; - ap->adprot |= 0x40000000; /* Kludge */ - } - else { - /* - * uid & gid extension don't exist, - * so use the mount-point uid/gid - */ - ap->uid = amp->uid; - ap->gid = amp->gid; - } - } - ap->mtime.days = adoswordn(bp, ap->nwords - 23); - ap->mtime.mins = adoswordn(bp, ap->nwords - 22); - ap->mtime.ticks = adoswordn(bp, ap->nwords - 21); - - *vpp = vp; /* return vp */ - brelse(bp); /* release buffer */ - return (0); -} - -/* - * Load the bitmap into memory, and count the number of available - * blocks. - * The bitmap will be released if the filesystem is read-only; it's - * only needed to find the free space. - */ -int -adosfs_loadbitmap(amp) - struct adosfsmount *amp; -{ - struct buf *bp, *mapbp; - u_int32_t bits; - daddr_t bn; - int blkix, endix, mapix, bmsize, n; - int error; - - bp = mapbp = NULL; - bn = amp->rootb; - if ((error = bread(amp->devvp, bn * amp->secsperblk, amp->bsize, - NOCRED, &bp)) != 0) - return (error); - blkix = amp->nwords - 49; - endix = amp->nwords - 24; - mapix = 0; - bmsize = (amp->numblks + 31) / 32; - while (mapix < bmsize) { - if (adoswordn(bp, blkix) == 0) - break; - if (mapbp != NULL) - brelse(mapbp); - if ((error = bread(amp->devvp, - adoswordn(bp, blkix) * amp->secsperblk, amp->bsize, - NOCRED, &mapbp)) != 0) - break; - if (adoscksum(mapbp, amp->nwords)) { -#ifdef DIAGNOSTIC - printf("adosfs: loadbitmap - cksum of blk %d failed\n", - adoswordn(bp, blkix)); -#endif - /* XXX Force read-only? Set free space 0? */ - break; - } - n = 1; - while (n < amp->nwords && mapix < bmsize) { - amp->bitmap[mapix++] = bits = adoswordn(mapbp, n); - ++n; - if (mapix == bmsize && amp->numblks & 31) - bits &= ~(0xffffffff << (amp->numblks & 31)); - while (bits) { - if (bits & 1) - ++amp->freeblks; - bits >>= 1; - } - } - ++blkix; - if (mapix < bmsize && blkix == endix) { - bn = (daddr_t)adoswordn(bp, blkix); - brelse(bp); - if ((error = bread(amp->devvp, bn * amp->secsperblk, - amp->bsize, NOCRED, &bp)) != 0) - break; - /* - * Why is there no checksum on these blocks? - */ - blkix = 0; - endix = amp->nwords - 1; - } - } - if (bp) - brelse(bp); - if (mapbp) - brelse(mapbp); - return (error); -} - - -/* - * File handle to vnode - * - * Have to be really careful about stale file handles: - * - check that the inode number is in range - * - call iget() to get the locked inode - * - check for an unallocated inode (i_mode == 0) - * - check that the generation number matches - */ - -/* - * This is using the same layout as struct fid from mount.h for the first two - * fields. - */ -struct ifid { - u_short ifid_len; - u_short ifid_pad; - ino_t ifid_ino; - daddr_t ifid_start; -}; - -int -adosfs_fhtovp(mp, fhp, vpp) - struct mount *mp; - struct fid *fhp; - struct vnode **vpp; -{ - struct ifid *ifhp = (struct ifid *)fhp; -#if 0 - struct anode *ap; -#endif - struct vnode *nvp; - int error; - -#ifdef ADOSFS_DIAGNOSTIC - printf("adfhtovp(%x, %x, %x)\n", mp, fhp, vpp); -#endif - - if ((error = VFS_VGET(mp, ifhp->ifid_ino, &nvp)) != 0) { - *vpp = NULLVP; - return (error); - } -#if 0 - ap = VTOA(nvp); - if (ap->inode.iso_mode == 0) { - vput(nvp); - *vpp = NULLVP; - return (ESTALE); - } -#endif - *vpp = nvp; - return(0); -} - -int -adosfs_vptofh(vp, fhp) - struct vnode *vp; - struct fid *fhp; -{ - struct anode *ap = VTOA(vp); - struct ifid *ifhp; - - ifhp = (struct ifid *)fhp; - ifhp->ifid_len = sizeof(struct ifid); - - ifhp->ifid_ino = ABLKTOINO(ap->block); - ifhp->ifid_start = ap->block; - -#ifdef ADOSFS_DIAGNOSTIC - printf("advptofh(%x, %x)\n", vp, fhp); -#endif - return(0); -} - -int -adosfs_quotactl(mp, cmds, uid, arg, p) - struct mount *mp; - int cmds; - uid_t uid; - caddr_t arg; - struct proc *p; -{ - return(EOPNOTSUPP); -} - -int -adosfs_sync(mp, waitfor, uc, p) - struct mount *mp; - int waitfor; - struct ucred *uc; - struct proc *p; -{ -#ifdef ADOSFS_DIAGNOSTIC - printf("ad_sync(%x, %x)\n", mp, waitfor); -#endif - return(0); -} - -int -adosfs_init(struct vfsconf *vfsp) -{ - return (0); -} - -/* - * vfs generic function call table - */ -const struct vfsops adosfs_vfsops = { - adosfs_mount, - adosfs_start, - adosfs_unmount, - adosfs_root, - adosfs_quotactl, - adosfs_statfs, - adosfs_sync, - adosfs_vget, - adosfs_fhtovp, - adosfs_vptofh, - adosfs_init, -}; diff --git a/sys/adosfs/advnops.c b/sys/adosfs/advnops.c index 3156c16b9df..e69de29bb2d 100644 --- a/sys/adosfs/advnops.c +++ b/sys/adosfs/advnops.c @@ -1,1077 +0,0 @@ -/* $OpenBSD: advnops.c,v 1.35 2007/04/11 16:08:50 thib Exp $ */ -/* $NetBSD: advnops.c,v 1.32 1996/10/13 02:52:09 christos Exp $ */ - -/* - * Copyright (c) 1994 Christian E. Hopps - * Copyright (c) 1996 Matthias Scheler - * 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 Christian E. Hopps. - * 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. - */ -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/vnode.h> -#include <sys/lockf.h> -#include <sys/mount.h> -#include <sys/time.h> -#include <sys/queue.h> -#include <sys/namei.h> -#include <sys/buf.h> -#include <sys/dirent.h> -#include <sys/malloc.h> -#include <sys/stat.h> -#include <sys/unistd.h> -#include <sys/poll.h> -#include <sys/proc.h> - -#include <machine/endian.h> - -#include <miscfs/specfs/specdev.h> -#include <adosfs/adosfs.h> - -int adosfs_advlock(void *); -int adosfs_open(void *); -int adosfs_getattr(void *); -int adosfs_read(void *); -int adosfs_write(void *); -int adosfs_ioctl(void *); -int adosfs_poll(void *); -int adosfs_strategy(void *); -int adosfs_link(void *); -int adosfs_symlink(void *); -int adosfs_lock(void *); -int adosfs_unlock(void *); -int adosfs_bmap(void *); -int adosfs_print(void *); -int adosfs_readdir(void *); -int adosfs_access(void *); -int adosfs_readlink(void *); -int adosfs_inactive(void *); -int adosfs_islocked(void *); -int adosfs_reclaim(void *); -int adosfs_pathconf(void *); -int adnullop(void *); -int adenotsup(void *); - -#define adosfs_close adnullop -#define adosfs_fsync adnullop -#define adosfs_bwrite adenotsup -#define adosfs_create adenotsup -#define adosfs_mkdir adenotsup -#define adosfs_mknod adenotsup -#define adosfs_remove adenotsup -#define adosfs_rename adenotsup -#define adosfs_rmdir adenotsup -#define adosfs_setattr adenotsup - -struct vnodeopv_entry_desc adosfs_vnodeop_entries[] = { - { &vop_default_desc, vn_default_error }, - { &vop_lookup_desc, adosfs_lookup }, /* lookup */ - { &vop_create_desc, adosfs_create }, /* create */ - { &vop_mknod_desc, adosfs_mknod }, /* mknod */ - { &vop_open_desc, adosfs_open }, /* open */ - { &vop_close_desc, adosfs_close }, /* close */ - { &vop_access_desc, adosfs_access }, /* access */ - { &vop_getattr_desc, adosfs_getattr }, /* getattr */ - { &vop_setattr_desc, adosfs_setattr }, /* setattr */ - { &vop_read_desc, adosfs_read }, /* read */ - { &vop_write_desc, adosfs_write }, /* write */ - { &vop_ioctl_desc, adosfs_ioctl }, /* ioctl */ - { &vop_poll_desc, adosfs_poll }, /* poll */ - { &vop_fsync_desc, adosfs_fsync }, /* fsync */ - { &vop_remove_desc, adosfs_remove }, /* remove */ - { &vop_link_desc, adosfs_link }, /* link */ - { &vop_rename_desc, adosfs_rename }, /* rename */ - { &vop_mkdir_desc, adosfs_mkdir }, /* mkdir */ - { &vop_rmdir_desc, adosfs_rmdir }, /* rmdir */ - { &vop_symlink_desc, adosfs_symlink }, /* symlink */ - { &vop_readdir_desc, adosfs_readdir }, /* readdir */ - { &vop_readlink_desc, adosfs_readlink }, /* readlink */ - { &vop_abortop_desc, vop_generic_abortop }, /* abortop */ - { &vop_inactive_desc, adosfs_inactive }, /* inactive */ - { &vop_reclaim_desc, adosfs_reclaim }, /* reclaim */ - { &vop_lock_desc, adosfs_lock }, /* lock */ - { &vop_unlock_desc, adosfs_unlock }, /* unlock */ - { &vop_bmap_desc, adosfs_bmap }, /* bmap */ - { &vop_strategy_desc, adosfs_strategy }, /* strategy */ - { &vop_print_desc, adosfs_print }, /* print */ - { &vop_islocked_desc, adosfs_islocked }, /* islocked */ - { &vop_pathconf_desc, adosfs_pathconf }, /* pathconf */ - { &vop_advlock_desc, adosfs_advlock }, /* advlock */ - { &vop_bwrite_desc, adosfs_bwrite }, /* bwrite */ - { (struct vnodeop_desc*)NULL, (int(*)(void *))NULL } -}; - -int (**adosfs_vnodeop_p)(void *); - -struct vnodeopv_desc adosfs_vnodeop_opv_desc = - { &adosfs_vnodeop_p, adosfs_vnodeop_entries }; - -int -adosfs_open(v) - void *v; -{ -#ifdef ADOSFS_DIAGNOSTIC - struct vop_open_args /* { - struct vnode *a_vp; - int a_mode; - struct ucred *a_cred; - struct proc *a_p; - } */ *sp = v; - advopprint(sp); - printf(" 0)"); -#endif - return(0); -} - -int -adosfs_getattr(v) - void *v; -{ - struct vop_getattr_args /* { - struct vnode *a_vp; - struct vattr *a_vap; - struct ucred *a_cred; - struct proc *a_p; - } */ *sp = v; - struct vattr *vap; - struct adosfsmount *amp; - struct anode *ap; - u_int32_t fblks; - -#ifdef ADOSFS_DIAGNOSTIC - advopprint(sp); -#endif - vap = sp->a_vap; - ap = VTOA(sp->a_vp); - amp = ap->amp; - vattr_null(vap); - vap->va_uid = ap->uid; - vap->va_gid = ap->gid; - vap->va_fsid = sp->a_vp->v_mount->mnt_stat.f_fsid.val[0]; - vap->va_atime.tv_sec = vap->va_mtime.tv_sec = vap->va_ctime.tv_sec = - ap->mtime.days * 24 * 60 * 60 + ap->mtime.mins * 60 + - ap->mtime.ticks / 50 + (8 * 365 + 2) * 24 * 60 * 60; - vap->va_atime.tv_nsec = vap->va_mtime.tv_nsec = vap->va_ctime.tv_nsec = 0; - vap->va_gen = 0; - vap->va_flags = 0; - vap->va_rdev = NODEV; - vap->va_fileid = (long)ap->block; - vap->va_type = sp->a_vp->v_type; - vap->va_mode = amp->mask & adunixprot(ap->adprot); - if (sp->a_vp->v_type == VDIR) { - vap->va_nlink = 1; /* XXX bogus, oh well */ - vap->va_bytes = amp->bsize; - vap->va_size = amp->bsize; - } else { - /* - * XXX actually we can track this if we were to walk the list - * of links if it exists. - * XXX for now, just set nlink to 2 if this is a hard link - * to a file, or a file with a hard link. - */ - vap->va_nlink = 1 + (ap->linkto != 0); - /* - * round up to nearest blocks add number of file list - * blocks needed and multiply by number of bytes per block. - */ - fblks = howmany(ap->fsize, amp->dbsize); - fblks += howmany(fblks, ANODENDATBLKENT(ap)); - vap->va_bytes = fblks * amp->dbsize; - vap->va_size = (off_t)ap->fsize; - - vap->va_blocksize = amp->dbsize; - } -#ifdef ADOSFS_DIAGNOSTIC - printf(" 0)"); -#endif - return(0); -} -/* - * are things locked??? they need to be to avoid this being - * deleted or changed (data block pointer blocks moving about.) - */ -int -adosfs_read(v) - void *v; -{ - struct vop_read_args /* { - struct vnode *a_vp; - struct uio *a_uio; - int a_ioflag; - struct ucred *a_cred; - } */ *sp = v; - struct adosfsmount *amp; - struct anode *ap; - struct uio *uio; - struct buf *bp; - daddr_t lbn; - int size, error, n, on; - u_int32_t off; - int64_t diff; - -#ifdef ADOSFS_DIAGNOSTIC - advopprint(sp); -#endif - error = 0; - uio = sp->a_uio; - ap = VTOA(sp->a_vp); - amp = ap->amp; - /* - * Return EOF for character devices, EIO for others - */ - if (sp->a_vp->v_type != VREG) { - error = EIO; - goto reterr; - } - if (uio->uio_resid == 0) - goto reterr; - if (uio->uio_offset < 0 || uio->uio_offset > UINT_MAX) { /* XXX */ - error = EINVAL; - goto reterr; - } - off = (u_int32_t)uio->uio_offset; - - /* - * to expensive to let general algorithm figure out that - * we are beyond the file. Do it now. - */ - if (off >= ap->fsize) - goto reterr; - - /* - * taken from ufs_read() - */ - do { - /* - * we are only supporting ADosFFS currently - * (which have data blocks without headers) - */ - size = amp->dbsize; - lbn = off / size; - on = off % size; - n = min((u_int32_t)(size - on), uio->uio_resid); - diff = ap->fsize - off; - /* - * check for EOF - */ - if (diff <= 0) - return(0); - if (diff < n) - n = (int)diff; - /* - * read ahead could possibly be worth something - * but not much as ados makes little attempt to - * make things contiguous - */ - error = bread(sp->a_vp, lbn * amp->secsperblk, amp->bsize, - NOCRED, &bp); - - if (!IS_FFS(amp)) { - if (bp->b_resid > 0) - error = EIO; /* OFS needs the complete block */ - else if (adoswordn(bp, 0) != BPT_DATA) { -#ifdef DIAGNOSTIC - printf("adosfs: bad primary type blk %d\n", - bp->b_blkno / amp->secsperblk); -#endif - error=EINVAL; - } - else if (adoscksum(bp, ap->nwords)) { -#ifdef DIAGNOSTIC - printf("adosfs: blk %u failed cksum.\n", - bp->b_blkno / amp->secsperblk); -#endif - error=EINVAL; - } - } - - if (error) { - brelse(bp); - goto reterr; - } -#ifdef ADOSFS_DIAGNOSTIC - printf(" %u+%u-%u+%u", lbn, on, lbn, n); -#endif - n = min(n, size - bp->b_resid); /* XXX check types */ - error = uiomove(bp->b_data + on + amp->bsize - - amp->dbsize, n, uio); - brelse(bp); - off = (u_int32_t)uio->uio_offset; - } while (error == 0 && uio->uio_resid > 0 && n != 0); -reterr: -#ifdef ADOSFS_DIAGNOSTIC - printf(" %d)", error); -#endif - return(error); -} - -int -adosfs_write(v) - void *v; -{ -#ifdef ADOSFS_DIAGNOSTIC - struct vop_write_args /* { - struct vnode *a_vp; - struct uio *a_uio; - int a_ioflag; - struct ucred *a_cred; - } */ *sp = v; - advopprint(sp); - printf(" EOPNOTSUPP)"); -#endif - return(EOPNOTSUPP); -} - -/* - * Device ioctl operation. - */ -/* ARGSUSED */ -int -adosfs_ioctl(v) - void *v; -{ -#ifdef ADOSFS_DIAGNOSTIC - struct vop_ioctl_args /* { - struct vnode *a_vp; - u_long a_command; - caddr_t a_data; - int a_fflag; - struct ucred *a_cred; - struct proc *a_p; - } */ *sp = v; - advopprint(sp); - printf(" ENOTTY)"); -#endif - return(ENOTTY); -} - -/* ARGSUSED */ -int -adosfs_poll(v) - void *v; -{ - struct vop_poll_args /* { - struct vnode *a_vp; - int a_events; - struct proc *a_p; - } */ *ap = v; -#ifdef ADOSFS_DIAGNOSTIC - /* - * sure there's something to read... - */ - advopprint(sp); - printf(" %d", - ap->a_events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)); -#endif - return(ap->a_events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)); -} - -/* - * Just call the device strategy routine - */ -int -adosfs_strategy(v) - void *v; -{ - struct vop_strategy_args /* { - struct buf *a_bp; - } */ *sp = v; - struct buf *bp; - struct anode *ap; - struct vnode *vp; - int error; - int s; - -#ifdef ADOSFS_DIAGNOSTIC - advopprint(sp); -#endif - error = 0; - bp = sp->a_bp; - if (bp->b_vp == NULL) { - bp->b_flags |= B_ERROR; - s = splbio(); - biodone(bp); - splx(s); - error = EIO; - goto reterr; - } - vp = bp->b_vp; - ap = VTOA(vp); - if (bp->b_blkno == bp->b_lblkno) { - error = VOP_BMAP(vp, bp->b_lblkno, NULL, &bp->b_blkno, NULL); - if (error) { - bp->b_flags |= B_ERROR; - s = splbio(); - biodone(bp); - splx(s); - goto reterr; - } - } -#if 0 - if (bp->b_blkno == UINT_MAX) { /* XXX huh? (was (long)... == -1 */ - biodone(bp); - error = 0; - goto reterr; - } -#endif - vp = ap->amp->devvp; - bp->b_dev = vp->v_rdev; - VOCALL(vp->v_op, VOFFSET(vop_strategy), sp); -reterr: -#ifdef ADOSFS_DIAGNOSTIC - printf(" %d)", error); -#endif - return(error); -} - -int -adosfs_link(v) - void *v; -{ - struct vop_link_args /* { - struct vnode *a_dvp; - struct vnode *a_vp; - struct componentname *a_cnp; - } */ *ap = v; - - VOP_ABORTOP(ap->a_dvp, ap->a_cnp); - vput(ap->a_dvp); - return (EROFS); -} - -int -adosfs_symlink(v) - void *v; -{ - struct vop_symlink_args /* { - struct vnode *a_dvp; - struct vnode **a_vpp; - struct componentname *a_cnp; - struct vattr *a_vap; - char *a_target; - } */ *ap = v; - - VOP_ABORTOP(ap->a_dvp, ap->a_cnp); - vput(ap->a_dvp); - return (EROFS); -} - -/* - * lock the anode - */ -int -adosfs_lock(v) - void *v; -{ - struct vop_lock_args /* { - struct vnode *a_vp; - int a_flags; - struct proc *a_p; - } */ *ap = v; - struct vnode *vp = ap->a_vp; - int rv; - -#ifdef ADOSFS_DIAGNOSTIC - advopprint(ap); -#endif - - rv = lockmgr(&VTOA(vp)->a_lock, ap->a_flags, NULL); - -#ifdef ADOSFS_DIAGNOSTIC - printf(" %d)", rv); -#endif - return (rv); -} - -/* - * unlock an anode - */ -int -adosfs_unlock(v) - void *v; -{ - struct vop_unlock_args /* { - struct vnode *a_vp; - } */ *ap = v; - struct vnode *vp = ap->a_vp; - int rv; - -#ifdef ADOSFS_DIAGNOSTIC - advopprint(ap); -#endif - - rv = lockmgr(&VTOA(vp)->a_lock, ap->a_flags | LK_RELEASE, NULL); - -#ifdef ADOSFS_DIAGNOSTIC - printf(" %d)", rv); -#endif - return (rv); -} - -/* - * Wait until the vnode has finished changing state. - */ -int -adosfs_bmap(v) - void *v; -{ - struct vop_bmap_args /* { - struct vnode *a_vp; - daddr_t a_bn; - struct vnode **a_vpp; - daddr_t *a_bnp; - int *a_runp; - } */ *sp = v; - struct anode *ap; - struct buf *flbp; - daddr_t *bnp, bn, nb, flblk, fcnt; - int error, flblkoff; - -#ifdef ADOSFS_DIAGNOSTIC - advopprint(sp); -#endif - ap = VTOA(sp->a_vp); - bn = sp->a_bn / ap->amp->secsperblk; - bnp = sp->a_bnp; - error = 0; - - if (sp->a_vpp != NULL) - *sp->a_vpp = ap->amp->devvp; - if (bnp == NULL) - goto reterr; - if (bn < 0) { - error = EFBIG; - goto reterr; - } - if (sp->a_vp->v_type != VREG) { - error = EINVAL; - goto reterr; - } - - /* - * walk the chain of file list blocks until we find - * the one that will yield the block pointer we need. - */ - if (ap->type == AFILE) - nb = ap->block; /* pointer to ourself */ - else if (ap->type == ALFILE) - nb = ap->linkto; /* pointer to real file */ - else { - error = EINVAL; - goto reterr; - } - - flblk = bn / ANODENDATBLKENT(ap); - flbp = NULL; - - /* - * check last indirect block cache - */ - if (flblk < ap->lastlindblk) - fcnt = 0; - else { - flblk -= ap->lastlindblk; - fcnt = ap->lastlindblk; - nb = ap->lastindblk; - } - while (1) { - if (flbp) - brelse(flbp); - if (nb == 0) { -#ifdef DIAGNOSTIC - printf("adosfs: bad file list chain.\n"); -#endif - error = EINVAL; - goto reterr; - } - error = bread(ap->amp->devvp, nb * ap->amp->secsperblk, - ap->amp->bsize, NOCRED, &flbp); - if (error) - goto reterr; - if (adoscksum(flbp, ap->nwords)) { -#ifdef DIAGNOSTIC - printf("adosfs: blk %u failed cksum.\n", nb); -#endif - brelse(flbp); - error = EINVAL; - goto reterr; - } - /* - * update last indirect block cache - */ - ap->lastlindblk = fcnt++; - ap->lastindblk = nb; - - nb = (daddr_t)adoswordn(flbp, ap->nwords - 2); - if (flblk == 0) - break; - flblk--; - } - /* - * calculate offset of block number in table. The table starts - * at nwords - 51 and goes to offset 6 or less if indicated by the - * valid table entries stored at offset ADBI_NBLKTABENT. - */ - flblkoff = bn % ANODENDATBLKENT(ap); - if (flblkoff < adoswordn(flbp, 2 /* ADBI_NBLKTABENT */)) { - flblkoff = (ap->nwords - 51) - flblkoff; - *bnp = adoswordn(flbp, flblkoff) * ap->amp->secsperblk; - } else { -#ifdef DIAGNOSTIC - printf("flblk offset %d too large in lblk %u blk %u\n", - flblkoff, bn / ap->amp->secsperblk, flbp->b_blkno); -#endif - error = EINVAL; - } - brelse(flbp); -reterr: -#ifdef ADOSFS_DIAGNOSTIC - if (error == 0 && bnp) - printf(" %u => %u", bn, *bnp); - printf(" %d)", error); -#endif - return(error); -} - -/* - * Print out the contents of an adosfs vnode. - */ -/* ARGSUSED */ -int -adosfs_print(v) - void *v; -{ -#ifdef DIAGNOSTIC - struct vop_print_args /* { - struct vnode *a_vp; - } */ *ap = v; - struct anode *anp = VTOA(ap->a_vp); -#endif - - /* XXX Fill in more info here. */ - printf("tag VT_ADOSFS\n"); -#ifdef DIAGNOSTIC - lockmgr_printinfo(&anp->a_lock); -#endif - return(0); -} - -int -adosfs_advlock(v) - void *v; -{ - struct vop_advlock_args /* { - struct vnode *a_vp; - caddr_t a_id; - int a_op; - struct flock *a_fl; - int a_flags; - } */ *ap = v; - register struct anode *anp = VTOA(ap->a_vp); - - return (lf_advlock(&anp->a_lockf, anp->fsize, ap->a_id, ap->a_op, - ap->a_fl, ap->a_flags)); -} - -/* This is laid out like a standard dirent, except that it is shorter. */ -struct adirent { - u_int32_t fileno; - u_int16_t reclen; - u_int8_t type; - u_int8_t namlen; - char name[32]; /* maxlen of 30 plus 2 NUL's */ -}; - -/* XXX look over the off_t usage below wrt type safety */ -int -adosfs_readdir(v) - void *v; -{ - struct vop_readdir_args /* { - struct vnode *a_vp; - struct uio *a_uio; - struct ucred *a_cred; - int *a_eofflag; - u_long **a_cookies; - int *a_ncookies; - } */ *sp = v; - int error, useri, chainc, hashi, scanned, uavail; - struct adirent ad, *adp; - struct anode *pap, *ap; - struct adosfsmount *amp; - struct vnode *vp; - struct uio *uio; - daddr_t nextbn; - off_t uoff; - -#ifdef ADOSFS_DIAGNOSTIC - advopprint(sp); -#endif - if (sp->a_vp->v_type != VDIR) { - error = ENOTDIR; - goto reterr; - } - uio = sp->a_uio; - uoff = uio->uio_offset; - if (uoff < 0) { - error = EINVAL; - goto reterr; - } - - pap = VTOA(sp->a_vp); - amp = pap->amp; - adp = &ad; - error = nextbn = hashi = chainc = scanned = 0; - uavail = uio->uio_resid / sizeof(ad); - useri = uoff / sizeof(ad); - - /* - * if no slots available or offset requested is not on a slot boundary - */ - if (uavail < 1 || uoff % sizeof(ad)) { - error = EINVAL; - goto reterr; - } - - while (uavail && (sp->a_cookies == NULL || sp->a_ncookies > 0)) { - if (hashi == pap->ntabent) { - *sp->a_eofflag = 1; - break; - } - if (pap->tab[hashi] == 0) { - hashi++; - continue; - } - if (nextbn == 0) - nextbn = pap->tab[hashi]; - - /* - * first determine if we can skip this chain - */ - if (chainc == 0) { - int skip; - - skip = useri - scanned; - if (pap->tabi[hashi] > 0 && pap->tabi[hashi] <= skip) { - scanned += pap->tabi[hashi]; - hashi++; - nextbn = 0; - continue; - } - } - - /* - * now [continue to] walk the chain - */ - ap = NULL; - do { - error = VFS_VGET(amp->mp, ABLKTOINO(nextbn), &vp); - if (error) - goto reterr; - ap = VTOA(vp); - scanned++; - chainc++; - nextbn = ap->hashf; - - /* - * check for end of chain. - */ - if (nextbn == 0) { - pap->tabi[hashi] = chainc; - hashi++; - chainc = 0; - } else if (pap->tabi[hashi] <= 0 && - -chainc < pap->tabi[hashi]) - pap->tabi[hashi] = -chainc; - - if (useri >= scanned) { - vput(vp); - ap = NULL; - } - } while (ap == NULL && nextbn != 0); - - /* - * we left the loop but without a result so do main over. - */ - if (ap == NULL) - continue; - /* - * Fill in dirent record - */ - bzero(adp, sizeof(struct adirent)); - adp->fileno = (u_int32_t)ap->block; - /* - * this deserves an function in kern/vfs_subr.c - */ - switch (ATOV(ap)->v_type) { - case VREG: - adp->type = DT_REG; - break; - case VDIR: - adp->type = DT_DIR; - break; - case VLNK: - adp->type = DT_LNK; - break; - default: - adp->type = DT_UNKNOWN; - break; - } - adp->reclen = sizeof(struct adirent); - adp->namlen = strlen(ap->name); - bcopy(ap->name, adp->name, adp->namlen); - vput(vp); - - error = uiomove((caddr_t)adp, sizeof(struct adirent), uio); - if (error) - break; -#ifdef FIXME_TO_HAVE_COOKIES - if (sp->a_cookies) { - *sp->a_cookies++ = (u_long)uoff; - sp->a_ncookies--; - } -#endif - uoff += sizeof(struct adirent); - useri++; - uavail--; - } -#if doesnt_uiomove_handle_this - uio->uio_offset = uoff; -#endif -reterr: -#ifdef ADOSFS_DIAGNOSTIC - printf(" %d)", error); -#endif - return(error); -} - - -int -adosfs_access(v) - void *v; -{ - struct vop_access_args /* { - struct vnode *a_vp; - int a_mode; - struct ucred *a_cred; - struct proc *a_p; - } */ *sp = v; - struct anode *ap; - int error; - -#ifdef ADOSFS_DIAGNOSTIC - advopprint(sp); -#endif - - ap = VTOA(sp->a_vp); -#ifdef DIAGNOSTIC - if (!VOP_ISLOCKED(sp->a_vp)) { - vprint("adosfs_access: not locked", sp->a_vp); - panic("adosfs_access: not locked"); - } -#endif -#ifdef QUOTA -#endif - error = vaccess(adunixprot(ap->adprot) & ap->amp->mask, ap->uid, - ap->gid, sp->a_mode, sp->a_cred); -#ifdef ADOSFS_DIAGNOSTIC - printf(" %d)", error); -#endif - return(error); -} - -/*ARGSUSED*/ -int -adosfs_readlink(v) - void *v; -{ - struct vop_readlink_args /* { - struct vnode *a_vp; - struct uio *a_uio; - struct ucred *a_cred; - } */ *sp = v; - struct anode *ap; - int error; - -#ifdef ADOSFS_DIAGNOSTIC - advopprint(sp); -#endif - ap = VTOA(sp->a_vp); - error = uiomove(ap->slinkto, strlen(ap->slinkto), sp->a_uio); -#ifdef ADOSFS_DIAGNOSTIC - printf(" %d)", error); -#endif - return (error); -} - -/*ARGSUSED*/ -int -adosfs_inactive(v) - void *v; -{ - struct vop_inactive_args /* { - struct vnode *a_vp; - } */ *sp = v; -#ifdef ADOSFS_DIAGNOSTIC - advopprint(sp); -#endif - - VOP_UNLOCK(sp->a_vp, 0, sp->a_p); - - if (sp->a_vp->v_usecount == 0 /* && check for file gone? */) - vrecycle(sp->a_vp, sp->a_p); - -#ifdef ADOSFS_DIAGNOSTIC - printf(" 0)"); -#endif - return(0); -} - -int -adosfs_islocked(v) - void *v; -{ - struct vop_islocked_args /* { - struct vnode *a_vp; - } */ *ap = v; - int locked; - -#ifdef ADOSFS_DIAGNOSTIC - advopprint(ap); -#endif - - locked = lockstatus(&VTOA(ap->a_vp)->a_lock); - -#ifdef ADOSFS_DIAGNOSTIC - printf(" %d)", locked); -#endif - return(locked); -} - -/* - * the kernel wants its vnode back. - * no lock needed we are being called from vclean() - */ -int -adosfs_reclaim(v) - void *v; -{ - struct vop_reclaim_args /* { - struct vnode *a_vp; - } */ *sp = v; - struct vnode *vp; - struct anode *ap; - -#ifdef ADOSFS_DIAGNOSTIC - printf("(reclaim 0)"); -#endif - vp = sp->a_vp; - ap = VTOA(vp); - - adosfs_aremhash(ap); - - cache_purge(vp); - if (vp->v_type == VDIR && ap->tab) - free(ap->tab, M_ANODE); - else if (vp->v_type == VLNK && ap->slinkto) - free(ap->slinkto, M_ANODE); - free(ap, M_ANODE); - vp->v_data = NULL; - return(0); -} - - -/* - * POSIX pathconf info, grabbed from kern/u fs, probably need to - * investigate exactly what each return type means as they are probably - * not valid currently - */ -int -adosfs_pathconf(v) - void *v; -{ - struct vop_pathconf_args /* { - struct vnode *a_vp; - int a_name; - register_t *a_retval; - } */ *ap = v; - - switch (ap->a_name) { - case _PC_CHOWN_RESTRICTED: - *ap->a_retval = 1; - return (0); - case _PC_LINK_MAX: - *ap->a_retval = LINK_MAX; - return (0); - case _PC_MAX_CANON: - *ap->a_retval = MAX_CANON; - return (0); - case _PC_MAX_INPUT: - *ap->a_retval = MAX_INPUT; - return (0); - case _PC_NAME_MAX: - *ap->a_retval = 30; - return (0); - case _PC_NO_TRUNC: - *ap->a_retval = 0; - return (0); - case _PC_PATH_MAX: - *ap->a_retval = PATH_MAX; - return (0); - case _PC_PIPE_BUF: - *ap->a_retval = PIPE_BUF; - return (0); - case _PC_VDISABLE: - *ap->a_retval = _POSIX_VDISABLE; - return (0); - default: - return (EINVAL); - } - /* NOTREACHED */ -} - -int -adenotsup(sp) - void *sp; -{ -#ifdef ADOSFS_DIAGNOSTIC - advopprint(sp); - printf(" EOPNOTSUPP)"); -#endif - return(EOPNOTSUPP); -} - -int -adnullop(sp) - void *sp; -{ -#ifdef ADOSFS_DIAGNOSTIC - advopprint(sp); - printf(" NULL)"); -#endif - return(0); -} diff --git a/sys/conf/files b/sys/conf/files index c80941aae85..8d81fd03b97 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1,4 +1,4 @@ -# $OpenBSD: files,v 1.405 2007/06/01 02:46:11 uwe Exp $ +# $OpenBSD: files,v 1.406 2007/06/01 05:37:14 deraadt Exp $ # $NetBSD: files,v 1.87 1996/05/19 17:17:50 jonathan Exp $ # @(#)files.newconf 7.5 (Berkeley) 5/10/93 @@ -493,10 +493,6 @@ file net/if_pppoe.c pppoe needs-flag # XXX machine-independent SCSI files should live somewhere here, maybe # kernel sources -file adosfs/adlookup.c adosfs -file adosfs/adutil.c adosfs -file adosfs/advfsops.c adosfs -file adosfs/advnops.c adosfs file altq/altq_subr.c altq file altq/altq_red.c altq file altq/altq_cbq.c altq diff --git a/sys/kern/Make.tags.inc b/sys/kern/Make.tags.inc index 92739a337c9..1370d67d99e 100644 --- a/sys/kern/Make.tags.inc +++ b/sys/kern/Make.tags.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Make.tags.inc,v 1.9 2005/07/14 02:09:46 uwe Exp $ +# $OpenBSD: Make.tags.inc,v 1.10 2007/06/01 05:37:14 deraadt Exp $ # Common files for "make tags". # Included by the Makefile for each architecture. @@ -7,8 +7,7 @@ # there is a struct tag with the same name (eg., vmmeter). The real # solution would probably be for ctags to generate "struct vmmeter" tags. -COMM= $S/adosfs/*.[ch] \ - $S/altq/*.[ch] \ +COMM= $S/altq/*.[ch] \ $S/compat/*/*.[ch] \ $S/conf/*.[ch] \ $S/crypto/*.[ch] \ diff --git a/sys/kern/Makefile b/sys/kern/Makefile index 0f154229408..e54f67e2fec 100644 --- a/sys/kern/Makefile +++ b/sys/kern/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.16 2006/05/09 21:17:13 miod Exp $ +# $OpenBSD: Makefile,v 1.17 2007/06/01 05:37:14 deraadt Exp $ # Makefile for kernel tags files, init_sysent, etc. @@ -28,8 +28,7 @@ SYSTAGS=/var/db/sys_tags SYSDIR=/sys # Directories in which to place tags links (other than machine-dependent) -DGEN= adosfs \ - compat compat/common compat/freebsd compat/hpux compat/ibcs2 \ +DGEN= compat compat/common compat/freebsd compat/hpux compat/ibcs2 \ compat/linux compat/osf1 compat/sunos compat/svr4 compat/ultrix \ conf \ ddb \ diff --git a/sys/kern/vfs_conf.c b/sys/kern/vfs_conf.c index 49ef87809e5..2c011d3ee9a 100644 --- a/sys/kern/vfs_conf.c +++ b/sys/kern/vfs_conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_conf.c,v 1.32 2007/05/08 20:26:19 deraadt Exp $ */ +/* $OpenBSD: vfs_conf.c,v 1.33 2007/06/01 05:37:14 deraadt Exp $ */ /* $NetBSD: vfs_conf.c,v 1.21.4.1 1995/11/01 00:06:26 jtc Exp $ */ /* @@ -103,10 +103,6 @@ extern const struct vfsops procfs_vfsops; extern const struct vfsops cd9660_vfsops; #endif -#ifdef ADOSFS -extern const struct vfsops adosfs_vfsops; -#endif - #ifdef EXT2FS extern const struct vfsops ext2fs_vfsops; #endif @@ -151,11 +147,6 @@ static struct vfsconf vfsconflist[] = { { &msdosfs_vfsops, MOUNT_MSDOS, 4, 0, MNT_LOCAL, NULL, NULL }, #endif - /* AmigaDOS Filesystem */ -#ifdef ADOSFS - { &adosfs_vfsops, MOUNT_ADOSFS, 16, 0, MNT_LOCAL, NULL, NULL }, -#endif - /* Sun-compatible Network Filesystem */ #ifdef NFSCLIENT { &nfs_vfsops, MOUNT_NFS, 2, 0, 0, nfs_mountroot, NULL }, @@ -219,7 +210,6 @@ extern struct vnodeopv_desc cd9660_vnodeop_opv_desc; extern struct vnodeopv_desc cd9660_specop_opv_desc; extern struct vnodeopv_desc cd9660_fifoop_opv_desc; extern struct vnodeopv_desc msdosfs_vnodeop_opv_desc; -extern struct vnodeopv_desc adosfs_vnodeop_opv_desc; extern struct vnodeopv_desc ext2fs_vnodeop_opv_desc; extern struct vnodeopv_desc ext2fs_specop_opv_desc; extern struct vnodeopv_desc ext2fs_fifoop_opv_desc; @@ -267,9 +257,6 @@ struct vnodeopv_desc *vfs_opv_descs[] = { #ifdef MSDOSFS &msdosfs_vnodeop_opv_desc, #endif -#ifdef ADOSFS - &adosfs_vnodeop_opv_desc, -#endif #ifdef EXT2FS &ext2fs_vnodeop_opv_desc, &ext2fs_specop_opv_desc, diff --git a/sys/sys/malloc.h b/sys/sys/malloc.h index 1363016982b..7ed5c1cad4f 100644 --- a/sys/sys/malloc.h +++ b/sys/sys/malloc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: malloc.h,v 1.83 2006/09/30 14:31:28 mickey Exp $ */ +/* $OpenBSD: malloc.h,v 1.84 2007/06/01 05:37:14 deraadt Exp $ */ /* $NetBSD: malloc.h,v 1.39 1998/07/12 19:52:01 augustss Exp $ */ /* @@ -117,13 +117,7 @@ #define M_TTYS 62 /* allocated tty structures */ #define M_EXEC 63 /* argument lists & other mem used by exec */ #define M_MISCFSMNT 64 /* miscfs mount structures */ -/* 65 - free */ -#define M_ADOSFSMNT 66 /* adosfs mount structures */ -/* 67 - free */ -#define M_ANODE 68 /* adosfs anode structures and tables. */ -/* 69-70 - free */ -#define M_ADOSFSBITMAP 71 /* adosfs bitmap */ -/* 72-73 - free */ +/* 65-73 - free */ #define M_PFKEY 74 /* pfkey data */ #define M_TDB 75 /* Transforms database */ #define M_XDATA 76 /* IPsec data */ @@ -251,12 +245,12 @@ "exec", /* 63 M_EXEC */ \ "miscfs mount", /* 64 M_MISCFSMNT */ \ NULL, \ - "adosfs mount", /* 66 M_ADOSFSMNT */ \ NULL, \ - "adosfs anode", /* 68 M_ANODE */ \ NULL, \ NULL, \ - "adosfs bitmap", /* 71 M_ADOSFSBITMAP */ \ + NULL, \ + NULL, \ + NULL, \ NULL, \ NULL, \ "pfkey data", /* 74 M_PFKEY */ \ diff --git a/sys/sys/mount.h b/sys/sys/mount.h index 402fd4682f3..c838a545f51 100644 --- a/sys/sys/mount.h +++ b/sys/sys/mount.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mount.h,v 1.80 2007/05/26 20:26:51 pedro Exp $ */ +/* $OpenBSD: mount.h,v 1.81 2007/06/01 05:37:14 deraadt Exp $ */ /* $NetBSD: mount.h,v 1.48 1996/02/18 11:55:47 fvdl Exp $ */ /* @@ -225,18 +225,6 @@ struct msdosfs_args { #define MSDOSFSMNT_ALLOWDIRX 0x10 /* dir is mode +x if r */ /* - * Arguments to mount amigados filesystems. - */ -struct adosfs_args { - char *fspec; /* blocks special holding the fs to mount */ - struct export_args export_info; - /* network export information */ - uid_t uid; /* uid that owns adosfs files */ - gid_t gid; /* gid that owns adosfs files */ - mode_t mask; /* mask to be applied for adosfs perms */ -}; - -/* * Arguments to mount ntfs filesystems */ struct ntfs_args { @@ -290,7 +278,6 @@ union mount_info { struct iso_args iso_args; struct procfs_args procfs_args; struct msdosfs_args msdosfs_args; - struct adosfs_args adosfs_args; struct ntfs_args ntfs_args; char __align[160]; /* 64-bit alignment and room to grow */ }; @@ -350,7 +337,6 @@ struct ostatfs { #define MOUNT_PROCFS "procfs" /* /proc Filesystem */ #define MOUNT_AFS "afs" /* Andrew Filesystem */ #define MOUNT_CD9660 "cd9660" /* ISO9660 (aka CDROM) Filesystem */ -#define MOUNT_ADOSFS "adosfs" /* AmigaDOS Filesystem */ #define MOUNT_EXT2FS "ext2fs" /* Second Extended Filesystem */ #define MOUNT_NCPFS "ncpfs" /* NetWare Network File System */ #define MOUNT_XFS "xfs" /* xfs */ |