Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Add mount -o extattr option to enable extended attributs (co...
details: https://anonhg.NetBSD.org/src/rev/35343db340e8
branches: trunk
changeset: 766158:35343db340e8
user: manu <manu%NetBSD.org@localhost>
date: Fri Jun 17 14:23:50 2011 +0000
description:
Add mount -o extattr option to enable extended attributs (corrently only
for UFS1).
Remove kernel option for EA backing store autocreation and do it by
default. Add a sysctl so that autocreated attriutr size can be modified.
diffstat:
include/mntopts.h | 3 +-
lib/libc/sys/mount.2 | 5 +++-
sbin/mount/mount.8 | 5 +++-
sbin/mount_ffs/mount_ffs.c | 5 ++-
share/man/man4/options.4 | 4 ++-
sys/kern/vfs_syscalls.c | 36 ++++++++++++++++++++++++++---
sys/sys/extattr.h | 6 ++++-
sys/sys/fstypes.h | 12 +++++----
sys/sys/statvfs.h | 3 +-
sys/ufs/ffs/ffs_extern.h | 5 ++-
sys/ufs/ffs/ffs_vfsops.c | 35 ++++++++++++++++------------
sys/ufs/ufs/extattr.h | 6 ++--
sys/ufs/ufs/ufs_extattr.c | 21 +++--------------
usr.sbin/extattrctl/extattrctl.8 | 48 +++++++++++++++++++++------------------
14 files changed, 118 insertions(+), 76 deletions(-)
diffs (truncated from 587 to 300 lines):
diff -r 03934ee02b3e -r 35343db340e8 include/mntopts.h
--- a/include/mntopts.h Fri Jun 17 09:50:52 2011 +0000
+++ b/include/mntopts.h Fri Jun 17 14:23:50 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mntopts.h,v 1.13 2009/01/12 18:14:20 pooka Exp $ */
+/* $NetBSD: mntopts.h,v 1.14 2011/06/17 14:23:50 manu Exp $ */
/*-
* Copyright (c) 1994
@@ -57,6 +57,7 @@
#define MOPT_SOFTDEP { "softdep", 0, MNT_SOFTDEP, 0 }
#define MOPT_LOG { "log", 0, MNT_LOG, 0 }
#define MOPT_IGNORE { "hidden", 0, MNT_IGNORE, 0 }
+#define MOPT_EXTATTR { "extattr", 0, MNT_EXTATTR, 0 }
/* Control flags. */
#define MOPT_FORCE { "force", 0, MNT_FORCE, 0 }
diff -r 03934ee02b3e -r 35343db340e8 lib/libc/sys/mount.2
--- a/lib/libc/sys/mount.2 Fri Jun 17 09:50:52 2011 +0000
+++ b/lib/libc/sys/mount.2 Fri Jun 17 14:23:50 2011 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: mount.2,v 1.45 2010/05/31 12:16:20 njoly Exp $
+.\" $NetBSD: mount.2,v 1.46 2011/06/17 14:23:50 manu Exp $
.\"
.\" Copyright (c) 1980, 1989, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -119,6 +119,9 @@
filesystem, creating a record of meta-data writes to be
performed, allowing the actual writes to be deferred.
This improves performance in most cases.
+.It MNT_EXTATTR
+Enable extended attributes, if the filesystem supports them and do not enable
+them by default. Currently this is only the case for UFS1.
.El
.Pp
The
diff -r 03934ee02b3e -r 35343db340e8 sbin/mount/mount.8
--- a/sbin/mount/mount.8 Fri Jun 17 09:50:52 2011 +0000
+++ b/sbin/mount/mount.8 Fri Jun 17 14:23:50 2011 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: mount.8,v 1.70 2010/11/21 18:33:08 pooka Exp $
+.\" $NetBSD: mount.8,v 1.71 2011/06/17 14:23:51 manu Exp $
.\"
.\" Copyright (c) 1980, 1989, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -190,6 +190,9 @@
Clear
.Cm async
mode.
+.It Cm extattr
+Enable extended attributes, if the filesystem supports them and do not enable
+them by default. Currently this is only the case for UFS1.
.It Cm force
The same as
.Fl f ;
diff -r 03934ee02b3e -r 35343db340e8 sbin/mount_ffs/mount_ffs.c
--- a/sbin/mount_ffs/mount_ffs.c Fri Jun 17 09:50:52 2011 +0000
+++ b/sbin/mount_ffs/mount_ffs.c Fri Jun 17 14:23:50 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mount_ffs.c,v 1.25 2008/08/05 20:57:45 pooka Exp $ */
+/* $NetBSD: mount_ffs.c,v 1.26 2011/06/17 14:23:51 manu Exp $ */
/*-
* Copyright (c) 1993, 1994
@@ -39,7 +39,7 @@
#if 0
static char sccsid[] = "@(#)mount_ufs.c 8.4 (Berkeley) 4/26/95";
#else
-__RCSID("$NetBSD: mount_ffs.c,v 1.25 2008/08/05 20:57:45 pooka Exp $");
+__RCSID("$NetBSD: mount_ffs.c,v 1.26 2011/06/17 14:23:51 manu Exp $");
#endif
#endif /* not lint */
@@ -74,6 +74,7 @@
MOPT_SOFTDEP,
MOPT_LOG,
MOPT_GETARGS,
+ MOPT_EXTATTR,
MOPT_NULL,
};
diff -r 03934ee02b3e -r 35343db340e8 share/man/man4/options.4
--- a/share/man/man4/options.4 Fri Jun 17 09:50:52 2011 +0000
+++ b/share/man/man4/options.4 Fri Jun 17 14:23:50 2011 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: options.4,v 1.406 2011/06/07 20:23:14 wiz Exp $
+.\" $NetBSD: options.4,v 1.407 2011/06/17 14:23:51 manu Exp $
.\"
.\" Copyright (c) 1996
.\" Perry E. Metzger. All rights reserved.
@@ -959,6 +959,8 @@
support in FFS file systems.
Maybe useful for install media kernels, small memory systems and
embedded systems which don't require the snapshot support.
+.It Cd options UFS_EXTATTR
+Enable extended attribute support for UFS1 filesystems.
.It Cd options WAPBL
Enable
.Dq Write Ahead Physical Block Logging file system journaling .
diff -r 03934ee02b3e -r 35343db340e8 sys/kern/vfs_syscalls.c
--- a/sys/kern/vfs_syscalls.c Fri Jun 17 09:50:52 2011 +0000
+++ b/sys/kern/vfs_syscalls.c Fri Jun 17 14:23:50 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_syscalls.c,v 1.429 2011/06/12 03:35:57 rmind Exp $ */
+/* $NetBSD: vfs_syscalls.c,v 1.430 2011/06/17 14:23:51 manu Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.429 2011/06/12 03:35:57 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.430 2011/06/17 14:23:51 manu Exp $");
#ifdef _KERNEL_OPT
#include "opt_fileassoc.h"
@@ -97,6 +97,7 @@
#ifdef FILEASSOC
#include <sys/fileassoc.h>
#endif /* FILEASSOC */
+#include <sys/extattr.h>
#include <sys/verified_exec.h>
#include <sys/kauth.h>
#include <sys/atomic.h>
@@ -232,12 +233,12 @@
~(MNT_NOSUID | MNT_NOEXEC | MNT_NODEV |
MNT_SYNCHRONOUS | MNT_UNION | MNT_ASYNC | MNT_NOCOREDUMP |
MNT_NOATIME | MNT_NODEVMTIME | MNT_SYMPERM | MNT_SOFTDEP |
- MNT_LOG);
+ MNT_LOG | MNT_EXTATTR);
mp->mnt_flag |= flags &
(MNT_NOSUID | MNT_NOEXEC | MNT_NODEV |
MNT_SYNCHRONOUS | MNT_UNION | MNT_ASYNC | MNT_NOCOREDUMP |
MNT_NOATIME | MNT_NODEVMTIME | MNT_SYMPERM | MNT_SOFTDEP |
- MNT_LOG | MNT_IGNORE);
+ MNT_LOG | MNT_EXTATTR | MNT_IGNORE);
error = VFS_MOUNT(mp, path, data, data_len);
@@ -275,6 +276,25 @@
mutex_exit(&mp->mnt_updating);
vfs_unbusy(mp, false, NULL);
+ if ((error == 0) && !(saved_flags & MNT_EXTATTR) &&
+ (flags & MNT_EXTATTR)) {
+ if (VFS_EXTATTRCTL(vp->v_mount, EXTATTR_CMD_START,
+ NULL, 0, NULL) != 0) {
+ printf("%s: failed to start extattr, error = %d",
+ vp->v_mount->mnt_stat.f_mntonname, error);
+ mp->mnt_flag &= ~MNT_EXTATTR;
+ }
+ }
+
+ if ((error == 0) && (saved_flags & MNT_EXTATTR) &&
+ !(flags & MNT_EXTATTR)) {
+ if (VFS_EXTATTRCTL(vp->v_mount, EXTATTR_CMD_STOP,
+ NULL, 0, NULL) != 0) {
+ printf("%s: failed to stop extattr, error = %d",
+ vp->v_mount->mnt_stat.f_mntonname, error);
+ mp->mnt_flag |= MNT_RDONLY;
+ }
+ }
out:
return (error);
}
@@ -448,6 +468,14 @@
error = mount_domount(l, &vp, vfsops, path, flags, data_buf,
&data_len);
vfsopsrele = false;
+
+ if ((error == 0) && (flags & MNT_EXTATTR)) {
+ if (VFS_EXTATTRCTL(vp->v_mount, EXTATTR_CMD_START,
+ NULL, 0, NULL) != 0)
+ printf("%s: failed to start extattr",
+ vp->v_mount->mnt_stat.f_mntonname);
+ /* XXX remove flag */
+ }
}
done:
diff -r 03934ee02b3e -r 35343db340e8 sys/sys/extattr.h
--- a/sys/sys/extattr.h Fri Jun 17 09:50:52 2011 +0000
+++ b/sys/sys/extattr.h Fri Jun 17 14:23:50 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: extattr.h,v 1.4 2006/05/14 21:38:18 elad Exp $ */
+/* $NetBSD: extattr.h,v 1.5 2011/06/17 14:23:51 manu Exp $ */
/*-
* Copyright (c) 1999-2001 Robert N. M. Watson
@@ -46,6 +46,10 @@
#define EXTATTR_NAMESPACE_SYSTEM 0x00000002
#define EXTATTR_NAMESPACE_SYSTEM_STRING "system"
+/* for sys_extattrctl */
+#define EXTATTR_CMD_START 0x00000001
+#define EXTATTR_CMD_STOP 0x00000002
+
#ifdef _KERNEL
#include <sys/syslimits.h>
diff -r 03934ee02b3e -r 35343db340e8 sys/sys/fstypes.h
--- a/sys/sys/fstypes.h Fri Jun 17 09:50:52 2011 +0000
+++ b/sys/sys/fstypes.h Fri Jun 17 14:23:50 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fstypes.h,v 1.28 2011/01/13 07:25:50 pooka Exp $ */
+/* $NetBSD: fstypes.h,v 1.29 2011/06/17 14:23:51 manu Exp $ */
/*
* Copyright (c) 1989, 1991, 1993
@@ -86,7 +86,6 @@
#define __MNT_UNUSED1 0x00020000
#define __MNT_UNUSED2 0x00200000
#define __MNT_UNUSED3 0x00800000
-#define __MNT_UNUSED4 0x01000000
#define MNT_RDONLY 0x00000001 /* read only filesystem */
#define MNT_SYNCHRONOUS 0x00000002 /* file system written synchronously */
@@ -97,6 +96,7 @@
#define MNT_ASYNC 0x00000040 /* file system written asynchronously */
#define MNT_NOCOREDUMP 0x00008000 /* don't write core dumps to this FS */
#define MNT_IGNORE 0x00100000 /* don't show entry in df */
+#define MNT_EXTATTR 0x01000000 /* enable extended attributes */
#define MNT_LOG 0x02000000 /* Use logging */
#define MNT_NOATIME 0x04000000 /* Never update access times in fs */
#define MNT_SYMPERM 0x20000000 /* recognize symlink permission */
@@ -117,7 +117,8 @@
{ MNT_SYMPERM, 0, "symperm" }, \
{ MNT_NODEVMTIME, 0, "nodevmtime" }, \
{ MNT_SOFTDEP, 0, "soft dependencies" }, \
- { MNT_LOG, 0, "log" },
+ { MNT_LOG, 0, "log" }, \
+ { MNT_EXTATTR, 0, "extattr" },
/*
* exported mount flags.
@@ -178,7 +179,8 @@
MNT_LOCAL | \
MNT_QUOTA | \
MNT_ROOTFS | \
- MNT_LOG)
+ MNT_LOG | \
+ MNT_EXTATTR)
/*
* External filesystem control flags.
@@ -227,7 +229,7 @@
"\34MNT_EXNORESPORT" \
"\33MNT_NOATIME" \
"\32MNT_LOG" \
- "\31MNT_UNUSED" \
+ "\31MNT_EXTATTR" \
"\30MNT_UNUSED" \
"\27MNT_GETARGS" \
"\26MNT_UNUSED" \
diff -r 03934ee02b3e -r 35343db340e8 sys/sys/statvfs.h
--- a/sys/sys/statvfs.h Fri Jun 17 09:50:52 2011 +0000
+++ b/sys/sys/statvfs.h Fri Jun 17 14:23:50 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: statvfs.h,v 1.15 2008/07/31 05:38:06 simonb Exp $ */
+/* $NetBSD: statvfs.h,v 1.16 2011/06/17 14:23:51 manu Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -119,6 +119,7 @@
#define ST_NODEVMTIME MNT_NODEVMTIME
#define ST_SOFTDEP MNT_SOFTDEP
#define ST_LOG MNT_LOG
+#define ST_EXTATTR MNT_EXTATTR
#define ST_EXRDONLY MNT_EXRDONLY
#define ST_EXPORTED MNT_EXPORTED
diff -r 03934ee02b3e -r 35343db340e8 sys/ufs/ffs/ffs_extern.h
--- a/sys/ufs/ffs/ffs_extern.h Fri Jun 17 09:50:52 2011 +0000
+++ b/sys/ufs/ffs/ffs_extern.h Fri Jun 17 14:23:50 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ffs_extern.h,v 1.77 2011/04/27 07:24:52 hannken Exp $ */
+/* $NetBSD: ffs_extern.h,v 1.78 2011/06/17 14:23:52 manu Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -42,7 +42,8 @@
#define FFS_REALLOCBLKS 3 /* block reallocation enabled */
#define FFS_ASYNCFREE 4 /* asynchronous block freeing enabled */
#define FFS_LOG_CHANGEOPT 5 /* log optimalization strategy change */
-#define FFS_MAXID 6 /* number of valid ffs ids */
+#define FFS_EXTATTR_AUTOCREATE 6 /* size for backing file autocreation */
+#define FFS_MAXID 7 /* number of valid ffs ids */
struct buf;
struct fid;
diff -r 03934ee02b3e -r 35343db340e8 sys/ufs/ffs/ffs_vfsops.c
--- a/sys/ufs/ffs/ffs_vfsops.c Fri Jun 17 09:50:52 2011 +0000
+++ b/sys/ufs/ffs/ffs_vfsops.c Fri Jun 17 14:23:50 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ffs_vfsops.c,v 1.267 2011/06/12 03:36:00 rmind Exp $ */
+/* $NetBSD: ffs_vfsops.c,v 1.268 2011/06/17 14:23:52 manu Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
Home |
Main Index |
Thread Index |
Old Index