diff options
author | Robert Watson <rwatson@FreeBSD.org> | 2000-09-12 04:40:34 +0000 |
---|---|---|
committer | Robert Watson <rwatson@FreeBSD.org> | 2000-09-12 04:40:34 +0000 |
commit | 1fec210a697d244902acf2a4c8991f8f07a0a62b (patch) | |
tree | 12b3145c0187cc048f7aa327c5b1e2c7bbc87c42 /usr.sbin/extattrctl | |
parent | 16eb772dd793b44daf2ae297311b3b3437767e2c (diff) | |
download | src-test-1fec210a697d244902acf2a4c8991f8f07a0a62b.tar.gz src-test-1fec210a697d244902acf2a4c8991f8f07a0a62b.zip |
o Add a ``-o'' argument to initattr, which causes extattrctl to overwrite
the existing attribute file rather than aborting with an error.
o Useful if you want to reset the state of attributes on the system without
allocating different disk blocks through deletion and recreation,
for example, if you're doing benchmarks of extended attribute code. :-)
Obtained from: TrustedBSD Project
Notes
Notes:
svn path=/head/; revision=65767
Diffstat (limited to 'usr.sbin/extattrctl')
-rw-r--r-- | usr.sbin/extattrctl/extattrctl.8 | 8 | ||||
-rw-r--r-- | usr.sbin/extattrctl/extattrctl.c | 16 |
2 files changed, 20 insertions, 4 deletions
diff --git a/usr.sbin/extattrctl/extattrctl.8 b/usr.sbin/extattrctl/extattrctl.8 index 60c6009aeb22a..52ad1349a64af 100644 --- a/usr.sbin/extattrctl/extattrctl.8 +++ b/usr.sbin/extattrctl/extattrctl.8 @@ -40,6 +40,7 @@ .Ar path .Nm extattrctl .Cm initattr +.Op Fl o .Op Fl p Ar path .Ar attrsize .Ar attrfile @@ -75,6 +76,7 @@ Stop extended attribute support on the file system named using Extended attribute support must previously have been started. .It Xo .Cm initattr +.Op Fl o .Op Fl p Ar path .Ar attrsize attrfile .Xc @@ -85,6 +87,12 @@ as well as the file where the attribute will be stored, using .Ar attrfile . .Pp The +.Fl o +argument may be used to indicate that it is alright to overwrite an +existing attribute backing file; otherwise, if the target file exists, +an error will be returned. +.Pp +The .Fl p Ar path argument may be used to preallocate space for all attributes rather than relying on sparse files to conserve space. diff --git a/usr.sbin/extattrctl/extattrctl.c b/usr.sbin/extattrctl/extattrctl.c index 7d34831f007c8..2d08926e18692 100644 --- a/usr.sbin/extattrctl/extattrctl.c +++ b/usr.sbin/extattrctl/extattrctl.c @@ -54,7 +54,7 @@ usage(void) "usage:\n" " extattrctl start [path]\n" " extattrctl stop [path]\n" - " extattrctl initattr [-p path] [attrsize] [attrfile]\n" + " extattrctl initattr [-o] [-p path] [attrsize] [attrfile]\n" " extattrctl enable [path] [attrname] [attrfile]\n" " extattrctl disable [path] [attrname]\n"); exit(-1); @@ -82,11 +82,14 @@ initattr(int argc, char *argv[]) char *fs_path = NULL; char *zero_buf = NULL; long loop, num_inodes; - int ch, i, error, chunksize; + int ch, i, error, chunksize, overwrite = 0, flags; optind = 0; - while ((ch = getopt(argc, argv, "p:r:w:")) != -1) + while ((ch = getopt(argc, argv, "op:r:w:")) != -1) switch (ch) { + case 'o': + overwrite = 1; + break; case 'p': fs_path = strdup(optarg); break; @@ -101,8 +104,13 @@ initattr(int argc, char *argv[]) if (argc != 2) usage(); + if (overwrite) + flags = O_CREAT | O_WRONLY; + else + flags = O_CREAT | O_EXCL | O_WRONLY; + error = 0; - if ((i = open(argv[1], O_CREAT | O_EXCL | O_WRONLY, 0600)) != -1) { + if ((i = open(argv[1], flags, 0600)) != -1) { uef.uef_magic = UFS_EXTATTR_MAGIC; uef.uef_version = UFS_EXTATTR_VERSION; uef.uef_size = atoi(argv[0]); |