![basebuilder@powerel.org](/assets/img/avatar_default.png)
36 changed files with 1200 additions and 477 deletions
@ -0,0 +1,128 @@ |
|||||||
|
From c8dc4235614292020f82a031545d66c000b455f9 Mon Sep 17 00:00:00 2001 |
||||||
|
From: "Darrick J. Wong" <darrick.wong@oracle.com> |
||||||
|
Date: Wed, 25 Jan 2017 20:02:43 -0600 |
||||||
|
Subject: [PATCH] xfs_db: fix the 'source' command when passed as a -c option |
||||||
|
|
||||||
|
The 'source' command is supposed to read commands out of a file and |
||||||
|
execute them. This works great when done from an interactive command |
||||||
|
line, but it doesn't work at all when invoked from the command line |
||||||
|
because we never actually do anything with the opened file. |
||||||
|
|
||||||
|
So don't load stdin into the input stack when we're only executing |
||||||
|
command line options, and use that to decide if source_f is executing |
||||||
|
from the command line so that we can actually run the input loop. We'll |
||||||
|
use this for the per-field fuzzing xfstests. |
||||||
|
|
||||||
|
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> |
||||||
|
Reviewed-by: Eric Sandeen <sandeen@redhat.com> |
||||||
|
Signed-off-by: Eric Sandeen <sandeen@sandeen.net> |
||||||
|
--- |
||||||
|
db/init.c | 2 +- |
||||||
|
db/input.c | 43 +++++++++++++++++++++++++++++++++---------- |
||||||
|
2 files changed, 34 insertions(+), 11 deletions(-) |
||||||
|
|
||||||
|
Index: xfsprogs-4.5.0/db/init.c |
||||||
|
=================================================================== |
||||||
|
--- xfsprogs-4.5.0.orig/db/init.c |
||||||
|
+++ xfsprogs-4.5.0/db/init.c |
||||||
|
@@ -192,7 +192,6 @@ main( |
||||||
|
char **v; |
||||||
|
int start_iocur_sp; |
||||||
|
|
||||||
|
- pushfile(stdin); |
||||||
|
init(argc, argv); |
||||||
|
start_iocur_sp = iocur_sp; |
||||||
|
|
||||||
|
@@ -207,6 +206,7 @@ main( |
||||||
|
goto close_devices; |
||||||
|
} |
||||||
|
|
||||||
|
+ pushfile(stdin); |
||||||
|
while (!done) { |
||||||
|
if ((input = fetchline()) == NULL) |
||||||
|
break; |
||||||
|
Index: xfsprogs-4.5.0/db/input.c |
||||||
|
=================================================================== |
||||||
|
--- xfsprogs-4.5.0.orig/db/input.c |
||||||
|
+++ xfsprogs-4.5.0/db/input.c |
||||||
|
@@ -156,7 +156,7 @@ fetchline_internal(void) |
||||||
|
|
||||||
|
rval = NULL; |
||||||
|
for (rlen = iscont = 0; ; ) { |
||||||
|
- if (inputstacksize == 1) { |
||||||
|
+ if (curinput == stdin) { |
||||||
|
if (iscont) |
||||||
|
dbprintf("... "); |
||||||
|
else |
||||||
|
@@ -181,18 +181,24 @@ fetchline_internal(void) |
||||||
|
} |
||||||
|
if (ferror(curinput) || feof(curinput) || |
||||||
|
(len = strlen(buf)) == 0) { |
||||||
|
- popfile(); |
||||||
|
- if (curinput == NULL) { |
||||||
|
+ /* |
||||||
|
+ * No more input at this inputstack level; pop |
||||||
|
+ * our fd off and return so that a lower |
||||||
|
+ * level fetchline can handle us. If this was |
||||||
|
+ * an interactive session, print a newline |
||||||
|
+ * because ^D doesn't emit one. |
||||||
|
+ */ |
||||||
|
+ if (curinput == stdin) |
||||||
|
dbprintf("\n"); |
||||||
|
- return NULL; |
||||||
|
- } |
||||||
|
+ |
||||||
|
+ popfile(); |
||||||
|
iscont = 0; |
||||||
|
rlen = 0; |
||||||
|
if (rval) { |
||||||
|
xfree(rval); |
||||||
|
rval = NULL; |
||||||
|
} |
||||||
|
- continue; |
||||||
|
+ return NULL; |
||||||
|
} |
||||||
|
if (inputstacksize == 1) |
||||||
|
logprintf("%s", buf); |
||||||
|
@@ -225,7 +231,9 @@ fetchline(void) |
||||||
|
|
||||||
|
if (inputstacksize == 1) { |
||||||
|
line = readline(get_prompt()); |
||||||
|
- if (line && *line) { |
||||||
|
+ if (!line) |
||||||
|
+ dbprintf("\n"); |
||||||
|
+ else if (line && *line) { |
||||||
|
add_history(line); |
||||||
|
logprintf("%s", line); |
||||||
|
} |
||||||
|
@@ -314,12 +322,27 @@ source_f( |
||||||
|
char **argv) |
||||||
|
{ |
||||||
|
FILE *f; |
||||||
|
+ int c, done = 0; |
||||||
|
+ char *input; |
||||||
|
+ char **v; |
||||||
|
|
||||||
|
f = fopen(argv[1], "r"); |
||||||
|
- if (f == NULL) |
||||||
|
+ if (f == NULL) { |
||||||
|
dbprintf(_("can't open %s\n"), argv[0]); |
||||||
|
- else |
||||||
|
- pushfile(f); |
||||||
|
+ return 0; |
||||||
|
+ } |
||||||
|
+ |
||||||
|
+ /* Run the sourced commands now. */ |
||||||
|
+ pushfile(f); |
||||||
|
+ while (!done) { |
||||||
|
+ if ((input = fetchline_internal()) == NULL) |
||||||
|
+ break; |
||||||
|
+ v = breakline(input, &c); |
||||||
|
+ if (c) |
||||||
|
+ done = command(c, v); |
||||||
|
+ doneline(input, v); |
||||||
|
+ } |
||||||
|
+ |
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
@ -0,0 +1,55 @@ |
|||||||
|
From 921c30674e9bc719e7c2747deb6deb04be2adb4b Mon Sep 17 00:00:00 2001 |
||||||
|
From: "Darrick J. Wong" <darrick.wong@oracle.com> |
||||||
|
Date: Thu, 9 Nov 2017 11:35:22 -0600 |
||||||
|
Subject: [PATCH] db: increase metadump's default overly long extent discard |
||||||
|
threshold |
||||||
|
|
||||||
|
Back in 88b8e1d6d7 ("Make xfs_metadump more robust against bad data"), |
||||||
|
metadump grew the ability to ignore a directory extent if it was longer |
||||||
|
than 20 blocks. Presumably this was to protect metadump from dumping |
||||||
|
absurdly long extents resulting from bmbt corruption, but it's certainly |
||||||
|
possible to create a directory with an extent longer than 20 blocks. |
||||||
|
Hilariously, the discards happen with no warning unless the caller |
||||||
|
explicitly set -w. |
||||||
|
|
||||||
|
This was raised to 1000 blocks in 7431d134fe8 ("Increase default maximum |
||||||
|
extent size for xfs_metadump when copying..."), but it's still possible |
||||||
|
to create a directory with an extent longer than 1000 blocks. |
||||||
|
|
||||||
|
Increase the threshold to MAXEXTLEN blocks because it's totally valid |
||||||
|
for the filesystem to create extents up to that length. |
||||||
|
|
||||||
|
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> |
||||||
|
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com> |
||||||
|
Signed-off-by: Eric Sandeen <sandeen@sandeen.net> |
||||||
|
--- |
||||||
|
db/metadump.c | 2 +- |
||||||
|
man/man8/xfs_metadump.8 | 2 +- |
||||||
|
2 files changed, 2 insertions(+), 2 deletions(-) |
||||||
|
|
||||||
|
Index: xfsprogs-4.5.0/db/metadump.c |
||||||
|
=================================================================== |
||||||
|
--- xfsprogs-4.5.0.orig/db/metadump.c |
||||||
|
+++ xfsprogs-4.5.0/db/metadump.c |
||||||
|
@@ -32,7 +32,7 @@ |
||||||
|
#include "field.h" |
||||||
|
#include "dir2.h" |
||||||
|
|
||||||
|
-#define DEFAULT_MAX_EXT_SIZE 1000 |
||||||
|
+#define DEFAULT_MAX_EXT_SIZE MAXEXTLEN |
||||||
|
|
||||||
|
/* |
||||||
|
* It's possible that multiple files in a directory (or attributes |
||||||
|
Index: xfsprogs-4.5.0/man/man8/xfs_metadump.8 |
||||||
|
=================================================================== |
||||||
|
--- xfsprogs-4.5.0.orig/man/man8/xfs_metadump.8 |
||||||
|
+++ xfsprogs-4.5.0/man/man8/xfs_metadump.8 |
||||||
|
@@ -114,7 +114,7 @@ copied. |
||||||
|
.B \-m |
||||||
|
Set the maximum size of an allowed metadata extent. Extremely large metadata |
||||||
|
extents are likely to be corrupt, and will be skipped if they exceed |
||||||
|
-this value. The default size is 1000 blocks. |
||||||
|
+this value. The default size is 2097151 blocks. |
||||||
|
.TP |
||||||
|
.B \-o |
||||||
|
Disables obfuscation of file names and extended attributes. |
@ -0,0 +1,35 @@ |
|||||||
|
From d0ca5d8a3875a423b522ee9767cbeb3d47bed420 Mon Sep 17 00:00:00 2001 |
||||||
|
From: Eric Sandeen <sandeen@redhat.com> |
||||||
|
Date: Thu, 25 Jan 2018 13:55:01 -0600 |
||||||
|
Subject: [PATCH] xfs_copy: accept CRC version of ABTB_MAGIC in ASSERT |
||||||
|
|
||||||
|
Not sure how this was missed for so long, but to handle CRC |
||||||
|
filesystems, this ASSERT on block magic must accept CRC magic |
||||||
|
as well. |
||||||
|
|
||||||
|
Reported-by: Radek Burkat <radek@pinkbike.com> |
||||||
|
Signed-off-by: Eric Sandeen <sandeen@redhat.com> |
||||||
|
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> |
||||||
|
Reviewed-by: Bill O'Donnell <billodo@redhat.com> |
||||||
|
Signed-off-by: Eric Sandeen <sandeen@sandeen.net> |
||||||
|
--- |
||||||
|
copy/xfs_copy.c | 3 ++- |
||||||
|
1 file changed, 2 insertions(+), 1 deletion(-) |
||||||
|
|
||||||
|
diff --git a/copy/xfs_copy.c b/copy/xfs_copy.c |
||||||
|
index fb37375..16ee4d9 100644 |
||||||
|
--- a/copy/xfs_copy.c |
||||||
|
+++ b/copy/xfs_copy.c |
||||||
|
@@ -1140,7 +1140,8 @@ main(int argc, char **argv) |
||||||
|
((char *) btree_buf.data + |
||||||
|
pos - btree_buf.position); |
||||||
|
|
||||||
|
- ASSERT(be32_to_cpu(block->bb_magic) == XFS_ABTB_MAGIC); |
||||||
|
+ ASSERT(be32_to_cpu(block->bb_magic) == XFS_ABTB_MAGIC || |
||||||
|
+ be32_to_cpu(block->bb_magic) == XFS_ABTB_CRC_MAGIC); |
||||||
|
} |
||||||
|
|
||||||
|
/* |
||||||
|
-- |
||||||
|
2.9.5 |
||||||
|
|
@ -0,0 +1,37 @@ |
|||||||
|
From 945e47e2fcc5d1cec693122286da06d8ab829c52 Mon Sep 17 00:00:00 2001 |
||||||
|
From: "Darrick J. Wong" <darrick.wong@oracle.com> |
||||||
|
Date: Thu, 4 Jan 2018 13:58:29 -0600 |
||||||
|
Subject: [PATCH] xfs_db: fix crash when field list selector string has |
||||||
|
trailing slash |
||||||
|
|
||||||
|
If I run the following command: |
||||||
|
|
||||||
|
xfs_db /dev/sdf -x -c 'agf 0' -c 'addr refcntroot' -c 'addr ptrs[1]\' |
||||||
|
|
||||||
|
it errors out with "bad character in field \" and |
||||||
|
then ftok_free crashes on an invalid free() because picking up the |
||||||
|
previous token (the closing bracket) xrealloc'd the token array to be 5 |
||||||
|
elements long but never set the last element's tok pointer. |
||||||
|
Consequently the ftok_free tries to free whatever garbage pointer is in |
||||||
|
that last element and kaboom. |
||||||
|
|
||||||
|
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> |
||||||
|
Reviewed-by: Eric Sandeen <sandeen@sandeen.net> |
||||||
|
[sandeen: slightly clarify commit log] |
||||||
|
Signed-off-by: Eric Sandeen <sandeen@sandeen.net> |
||||||
|
--- |
||||||
|
db/flist.c | 1 + |
||||||
|
1 file changed, 1 insertion(+) |
||||||
|
|
||||||
|
Index: xfsprogs-4.5.0/db/flist.c |
||||||
|
=================================================================== |
||||||
|
--- xfsprogs-4.5.0.orig/db/flist.c |
||||||
|
+++ xfsprogs-4.5.0/db/flist.c |
||||||
|
@@ -400,6 +400,7 @@ flist_split( |
||||||
|
strncpy(a, s, l); |
||||||
|
a[l] = '\0'; |
||||||
|
v = xrealloc(v, (nv + 2) * sizeof(*v)); |
||||||
|
+ v[nv + 1].tok = NULL; |
||||||
|
v[nv].tok = a; |
||||||
|
v[nv].tokty = t; |
||||||
|
nv++; |
@ -0,0 +1,97 @@ |
|||||||
|
From 50663dc149619aef23bcb43e6fdf48bc60487374 Mon Sep 17 00:00:00 2001 |
||||||
|
From: "Darrick J. Wong" <darrick.wong@oracle.com> |
||||||
|
Date: Thu, 25 Jan 2018 13:55:01 -0600 |
||||||
|
Subject: [PATCH] xfsprogs: update dead urls |
||||||
|
|
||||||
|
Since oss.sgi.com is dead and xfs.org is slowly migrating to |
||||||
|
xfs.wiki.kernel.org, update all the documentation links to point to the |
||||||
|
current landing pads. |
||||||
|
|
||||||
|
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> |
||||||
|
Reviewed-by: Eric Sandeen <sandeen@redhat.com> |
||||||
|
Signed-off-by: Eric Sandeen <sandeen@sandeen.net> |
||||||
|
--- |
||||||
|
README | 2 +- |
||||||
|
debian/control | 6 +++--- |
||||||
|
debian/copyright | 2 +- |
||||||
|
debian/watch | 2 +- |
||||||
|
4 files changed, 6 insertions(+), 6 deletions(-) |
||||||
|
|
||||||
|
Index: xfsprogs-4.5.0/README |
||||||
|
=================================================================== |
||||||
|
--- xfsprogs-4.5.0.orig/README |
||||||
|
+++ xfsprogs-4.5.0/README |
||||||
|
@@ -9,4 +9,4 @@ and references to other XFS manual pages |
||||||
|
|
||||||
|
For more information and details on how to contribute to the |
||||||
|
XFS project see the web pages at: |
||||||
|
- http://oss.sgi.com/projects/xfs/ |
||||||
|
+ https://xfs.wiki.kernel.org/ |
||||||
|
Index: xfsprogs-4.5.0/debian/control |
||||||
|
=================================================================== |
||||||
|
--- xfsprogs-4.5.0.orig/debian/control |
||||||
|
+++ xfsprogs-4.5.0/debian/control |
||||||
|
@@ -24,7 +24,7 @@ Description: Utilities for managing the |
||||||
|
Btrees (directories, extents, free space) to aid both performance |
||||||
|
and scalability. |
||||||
|
. |
||||||
|
- Refer to the documentation at http://oss.sgi.com/projects/xfs/ |
||||||
|
+ Refer to the documentation at https://xfs.wiki.kernel.org/ |
||||||
|
for complete details. |
||||||
|
|
||||||
|
Package: xfslibs-dev |
||||||
|
Index: xfsprogs-4.5.0/debian/copyright |
||||||
|
=================================================================== |
||||||
|
--- xfsprogs-4.5.0.orig/debian/copyright |
||||||
|
+++ xfsprogs-4.5.0/debian/copyright |
||||||
|
@@ -1,7 +1,7 @@ |
||||||
|
This package was debianized by Nathan Scott nathans@debian.org on |
||||||
|
Sun, 19 Nov 2000 07:37:09 -0500. |
||||||
|
|
||||||
|
-It can be downloaded from ftp://oss.sgi.com/projects/xfs/download/ |
||||||
|
+It can be downloaded from https://www.kernel.org/pub/linux/utils/fs/xfs/xfsprogs/ |
||||||
|
|
||||||
|
Copyright: |
||||||
|
|
||||||
|
Index: xfsprogs-4.5.0/debian/watch |
||||||
|
=================================================================== |
||||||
|
--- xfsprogs-4.5.0.orig/debian/watch |
||||||
|
+++ xfsprogs-4.5.0/debian/watch |
||||||
|
@@ -1,3 +1,3 @@ |
||||||
|
version=3 |
||||||
|
opts=uversionmangle=s/(\d)[_\.\-\+]?((RC|rc|pre|dev|beta|alpha)\d*)$/$1~$2/ \ |
||||||
|
-ftp://oss.sgi.com/projects/xfs/cmd_tars/xfsprogs-(.+)\.tar\.gz |
||||||
|
+https://www.kernel.org/pub/linux/utils/fs/xfs/xfsprogs/xfsprogs-(.+)\.tar\.xz |
||||||
|
Index: xfsprogs-4.5.0/libxfs/util.c |
||||||
|
=================================================================== |
||||||
|
--- xfsprogs-4.5.0.orig/libxfs/util.c |
||||||
|
+++ xfsprogs-4.5.0/libxfs/util.c |
||||||
|
@@ -690,7 +690,7 @@ libxfs_fs_repair_cmn_err(int level, xfs_ |
||||||
|
fprintf(stderr, " This is a bug.\n"); |
||||||
|
fprintf(stderr, "%s version %s\n", progname, VERSION); |
||||||
|
fprintf(stderr, "Please capture the filesystem metadata with " |
||||||
|
- "xfs_metadump and\nreport it to xfs@oss.sgi.com.\n"); |
||||||
|
+ "xfs_metadump and\nreport it to linux-xfs@vger.kernel.org.\n"); |
||||||
|
va_end(ap); |
||||||
|
} |
||||||
|
|
||||||
|
Index: xfsprogs-4.5.0/man/man8/xfs_mdrestore.8 |
||||||
|
=================================================================== |
||||||
|
--- xfsprogs-4.5.0.orig/man/man8/xfs_mdrestore.8 |
||||||
|
+++ xfsprogs-4.5.0/man/man8/xfs_mdrestore.8 |
||||||
|
@@ -51,4 +51,4 @@ returns an exit code of 0 if all the met |
||||||
|
.BR xfs (5) |
||||||
|
.SH BUGS |
||||||
|
Email bug reports to |
||||||
|
-.BR xfs@oss.sgi.com . |
||||||
|
+.BR linux-xfs@vger.kernel.org . |
||||||
|
Index: xfsprogs-4.5.0/man/man8/xfs_metadump.8 |
||||||
|
=================================================================== |
||||||
|
--- xfsprogs-4.5.0.orig/man/man8/xfs_metadump.8 |
||||||
|
+++ xfsprogs-4.5.0/man/man8/xfs_metadump.8 |
||||||
|
@@ -154,4 +154,4 @@ command. |
||||||
|
.BR xfs (5) |
||||||
|
.SH BUGS |
||||||
|
Email bug reports to |
||||||
|
-.BR xfs@oss.sgi.com . |
||||||
|
+.BR linux-xfs@vger.kernel.org . |
@ -0,0 +1,194 @@ |
|||||||
|
From cfa10b0f972005b38ed294bca66cebf2f65298ec Mon Sep 17 00:00:00 2001 |
||||||
|
From: Eric Sandeen <sandeen@redhat.com> |
||||||
|
Date: Thu, 24 May 2018 14:48:33 -0500 |
||||||
|
Subject: [PATCH] xfs_io: add label command |
||||||
|
|
||||||
|
This adds an online get/set/clear label command to xfs_io. |
||||||
|
|
||||||
|
Signed-off-by: Eric Sandeen <sandeen@redhat.com> |
||||||
|
Reviewed-by: Dave Chinner <dchinner@redhat.com> |
||||||
|
Signed-off-by: Eric Sandeen <sandeen@sandeen.net> |
||||||
|
--- |
||||||
|
io/Makefile | 6 +-- |
||||||
|
io/init.c | 1 + |
||||||
|
io/io.h | 1 + |
||||||
|
io/label.c | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||||||
|
man/man8/xfs_io.8 | 13 +++++++ |
||||||
|
5 files changed, 126 insertions(+), 3 deletions(-) |
||||||
|
create mode 100644 io/label.c |
||||||
|
|
||||||
|
Index: xfsprogs-4.5.0/io/Makefile |
||||||
|
=================================================================== |
||||||
|
--- xfsprogs-4.5.0.orig/io/Makefile |
||||||
|
+++ xfsprogs-4.5.0/io/Makefile |
||||||
|
@@ -9,7 +9,7 @@ LTCOMMAND = xfs_io |
||||||
|
LSRCFILES = xfs_bmap.sh xfs_freeze.sh xfs_mkfile.sh |
||||||
|
HFILES = init.h io.h |
||||||
|
CFILES = init.c \ |
||||||
|
- attr.c bmap.c file.c freeze.c fsync.c getrusage.c imap.c link.c \ |
||||||
|
+ attr.c bmap.c file.c freeze.c fsync.c getrusage.c imap.c label.c link.c \ |
||||||
|
mmap.c open.c parent.c pread.c prealloc.c pwrite.c seek.c shutdown.c \ |
||||||
|
sync.c truncate.c reflink.c |
||||||
|
|
||||||
|
Index: xfsprogs-4.5.0/io/init.c |
||||||
|
=================================================================== |
||||||
|
--- xfsprogs-4.5.0.orig/io/init.c |
||||||
|
+++ xfsprogs-4.5.0/io/init.c |
||||||
|
@@ -65,6 +65,7 @@ init_commands(void) |
||||||
|
help_init(); |
||||||
|
imap_init(); |
||||||
|
inject_init(); |
||||||
|
+ label_init(); |
||||||
|
seek_init(); |
||||||
|
madvise_init(); |
||||||
|
mincore_init(); |
||||||
|
Index: xfsprogs-4.5.0/io/io.h |
||||||
|
=================================================================== |
||||||
|
--- xfsprogs-4.5.0.orig/io/io.h |
||||||
|
+++ xfsprogs-4.5.0/io/io.h |
||||||
|
@@ -102,6 +102,7 @@ extern void getrusage_init(void); |
||||||
|
extern void help_init(void); |
||||||
|
extern void imap_init(void); |
||||||
|
extern void inject_init(void); |
||||||
|
+extern void label_init(void); |
||||||
|
extern void mmap_init(void); |
||||||
|
extern void open_init(void); |
||||||
|
extern void parent_init(void); |
||||||
|
Index: xfsprogs-4.5.0/io/label.c |
||||||
|
=================================================================== |
||||||
|
--- /dev/null |
||||||
|
+++ xfsprogs-4.5.0/io/label.c |
||||||
|
@@ -0,0 +1,108 @@ |
||||||
|
+/* |
||||||
|
+ * Copyright (c) 2018 Red Hat, Inc. |
||||||
|
+ * All Rights Reserved. |
||||||
|
+ * |
||||||
|
+ * This program is free software; you can redistribute it and/or |
||||||
|
+ * modify it under the terms of the GNU General Public License as |
||||||
|
+ * published by the Free Software Foundation. |
||||||
|
+ * |
||||||
|
+ * This program is distributed in the hope that it would be useful, |
||||||
|
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
+ * GNU General Public License for more details. |
||||||
|
+ * |
||||||
|
+ * You should have received a copy of the GNU General Public License |
||||||
|
+ * along with this program; if not, write the Free Software Foundation, |
||||||
|
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
||||||
|
+ */ |
||||||
|
+ |
||||||
|
+#include <sys/ioctl.h> |
||||||
|
+#include <sys/mount.h> |
||||||
|
+#include "platform_defs.h" |
||||||
|
+#include "libxfs.h" |
||||||
|
+#include "path.h" |
||||||
|
+#include "command.h" |
||||||
|
+#include "init.h" |
||||||
|
+#include "io.h" |
||||||
|
+ |
||||||
|
+#ifndef FS_IOC_GETFSLABEL |
||||||
|
+/* Max chars for the interface; fs limits may differ */ |
||||||
|
+#define FSLABEL_MAX 256 |
||||||
|
+#define FS_IOC_GETFSLABEL _IOR(0x94, 49, char[FSLABEL_MAX]) |
||||||
|
+#define FS_IOC_SETFSLABEL _IOW(0x94, 50, char[FSLABEL_MAX]) |
||||||
|
+#endif |
||||||
|
+ |
||||||
|
+static cmdinfo_t label_cmd; |
||||||
|
+ |
||||||
|
+static void |
||||||
|
+label_help(void) |
||||||
|
+{ |
||||||
|
+ printf(_( |
||||||
|
+"\n" |
||||||
|
+" Manipulate or query the filesystem label while mounted.\n" |
||||||
|
+"\n" |
||||||
|
+" With no arguments, displays the current filesystem label.\n" |
||||||
|
+" -s newlabel -- set the filesystem label to newlabel\n" |
||||||
|
+" -c -- clear the filesystem label (sets to NULL string)\n" |
||||||
|
+"\n")); |
||||||
|
+} |
||||||
|
+ |
||||||
|
+static int |
||||||
|
+label_f( |
||||||
|
+ int argc, |
||||||
|
+ char **argv) |
||||||
|
+{ |
||||||
|
+ int c; |
||||||
|
+ int error; |
||||||
|
+ char label[FSLABEL_MAX]; |
||||||
|
+ |
||||||
|
+ if (argc == 1) { |
||||||
|
+ memset(label, 0, sizeof(label)); |
||||||
|
+ error = ioctl(file->fd, FS_IOC_GETFSLABEL, &label); |
||||||
|
+ goto out; |
||||||
|
+ } |
||||||
|
+ |
||||||
|
+ while ((c = getopt(argc, argv, "cs:")) != EOF) { |
||||||
|
+ switch (c) { |
||||||
|
+ case 'c': |
||||||
|
+ label[0] = '\0'; |
||||||
|
+ break; |
||||||
|
+ case 's': |
||||||
|
+ strncpy(label, optarg, sizeof(label)); |
||||||
|
+ break; |
||||||
|
+ default: |
||||||
|
+ return command_usage(&label_cmd); |
||||||
|
+ } |
||||||
|
+ } |
||||||
|
+ |
||||||
|
+ /* Check for trailing arguments */ |
||||||
|
+ if (argc != optind) |
||||||
|
+ return command_usage(&label_cmd); |
||||||
|
+ |
||||||
|
+ error = ioctl(file->fd, FS_IOC_SETFSLABEL, label); |
||||||
|
+out: |
||||||
|
+ if (error) { |
||||||
|
+ perror("label"); |
||||||
|
+ exitcode = 1; |
||||||
|
+ } else { |
||||||
|
+ printf("label = \"%s\"\n", label); |
||||||
|
+ } |
||||||
|
+ |
||||||
|
+ return 0; |
||||||
|
+} |
||||||
|
+ |
||||||
|
+void |
||||||
|
+label_init(void) |
||||||
|
+{ |
||||||
|
+ label_cmd.name = "label"; |
||||||
|
+ label_cmd.cfunc = label_f; |
||||||
|
+ label_cmd.argmin = 0; |
||||||
|
+ label_cmd.argmax = 3; |
||||||
|
+ label_cmd.args = _("[-s label|-c]"); |
||||||
|
+ label_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK; |
||||||
|
+ label_cmd.oneline = |
||||||
|
+ _("query, set, or clear the filesystem label while mounted"); |
||||||
|
+ label_cmd.help = label_help; |
||||||
|
+ |
||||||
|
+ add_command(&label_cmd); |
||||||
|
+} |
||||||
|
Index: xfsprogs-4.5.0/man/man8/xfs_io.8 |
||||||
|
=================================================================== |
||||||
|
--- xfsprogs-4.5.0.orig/man/man8/xfs_io.8 |
||||||
|
+++ xfsprogs-4.5.0/man/man8/xfs_io.8 |
||||||
|
@@ -812,7 +812,19 @@ verbose output will be printed. |
||||||
|
.IP |
||||||
|
.B [NOTE: Not currently operational on Linux.] |
||||||
|
.PD |
||||||
|
- |
||||||
|
+.TP |
||||||
|
+.BI "label" " " "[ -c | -s " label " ] " |
||||||
|
+On filesystems that support online label manipulation, get, set, or clear the |
||||||
|
+filesystem label. With no options, print the current filesystem label. The |
||||||
|
+.B \-c |
||||||
|
+option clears the filesystem label by setting it to the null string. The |
||||||
|
+.BI "\-s " label |
||||||
|
+option sets the filesystem label to |
||||||
|
+.IR label . |
||||||
|
+If the label is longer than the filesystem will accept, |
||||||
|
+.B xfs_io |
||||||
|
+will print an error message. XFS filesystem labels can be at most 12 |
||||||
|
+characters long. |
||||||
|
.SH SEE ALSO |
||||||
|
.BR mkfs.xfs (8), |
||||||
|
.BR xfsctl (3), |
@ -0,0 +1,64 @@ |
|||||||
|
From 98c4a01c21b99b13d8aaa406ab15b7424ee5ef9f Mon Sep 17 00:00:00 2001 |
||||||
|
From: Eric Sandeen <sandeen@redhat.com> |
||||||
|
Date: Wed, 23 May 2018 16:30:49 -0500 |
||||||
|
Subject: [PATCH] xfsprogs: be careful about what we stat in |
||||||
|
platform_check_mount |
||||||
|
|
||||||
|
After we lost ustat(2) in commit 4e7a824, we ended up with a slightly |
||||||
|
bonkers method to determine if our target block device was mounted: |
||||||
|
it goes through every entry returned by getmntent and stats the dir |
||||||
|
to see if its underlying device matches ours. |
||||||
|
|
||||||
|
Unfortunately that dir might be a hung nfs server and sadness ensues. |
||||||
|
|
||||||
|
So just do a really simple sanity check before we try to stat the |
||||||
|
mountpoint: does its device start with a / ? If not, skip it. |
||||||
|
|
||||||
|
Fixes: 4e7a824 ("libxfs/linux.c: Replace use of ustat by stat") |
||||||
|
Signed-off-by: Eric Sandeen <sandeen@redhat.com> |
||||||
|
Reviewed-by: Allison Henderson <allison.henderson@oracle.com> |
||||||
|
Signed-off-by: Eric Sandeen <sandeen@sandeen.net> |
||||||
|
--- |
||||||
|
libfrog/linux.c | 10 ++++++++++ |
||||||
|
1 file changed, 10 insertions(+) |
||||||
|
|
||||||
|
Index: xfsprogs-4.5.0/libxfs/linux.c |
||||||
|
=================================================================== |
||||||
|
--- xfsprogs-4.5.0.orig/libxfs/linux.c |
||||||
|
+++ xfsprogs-4.5.0/libxfs/linux.c |
||||||
|
@@ -68,7 +68,17 @@ platform_check_ismounted(char *name, cha |
||||||
|
progname, name); |
||||||
|
return 1; |
||||||
|
} |
||||||
|
+ /* |
||||||
|
+ * This whole business is to work out if our block device is mounted |
||||||
|
+ * after we lost ustat(2), see: |
||||||
|
+ * 4e7a824 libxfs/linux.c: Replace use of ustat by stat |
||||||
|
+ * We don't really want to stat every single mounted directory, |
||||||
|
+ * as that may include tmpfs, cgroups, procfs or - worst - hung nfs |
||||||
|
+ * servers. So first, a simple check: does the "dev" start with "/" ? |
||||||
|
+ */ |
||||||
|
while ((mnt = getmntent(f)) != NULL) { |
||||||
|
+ if (mnt->mnt_fsname[0] != '/') |
||||||
|
+ continue; |
||||||
|
if (stat64(mnt->mnt_dir, &mst) < 0) |
||||||
|
continue; |
||||||
|
if (mst.st_dev != s->st_rdev) |
||||||
|
@@ -99,7 +109,17 @@ platform_check_iswritable(char *name, ch |
||||||
|
"mounted filesystem\n"), progname, name); |
||||||
|
return fatal; |
||||||
|
} |
||||||
|
+ /* |
||||||
|
+ * This whole business is to work out if our block device is mounted |
||||||
|
+ * after we lost ustat(2), see: |
||||||
|
+ * 4e7a824 libxfs/linux.c: Replace use of ustat by stat |
||||||
|
+ * We don't really want to stat every single mounted directory, |
||||||
|
+ * as that may include tmpfs, cgroups, procfs or - worst - hung nfs |
||||||
|
+ * servers. So first, a simple check: does the "dev" start with "/" ? |
||||||
|
+ */ |
||||||
|
while ((mnt = getmntent(f)) != NULL) { |
||||||
|
+ if (mnt->mnt_fsname[0] != '/') |
||||||
|
+ continue; |
||||||
|
if (stat64(mnt->mnt_fsname, &mst) < 0) |
||||||
|
continue; |
||||||
|
if ((mst.st_mode & S_IFMT) != S_IFBLK) |
@ -0,0 +1,51 @@ |
|||||||
|
xfs_repair: Fix root inode's parent when it's bogus for sf directory |
||||||
|
|
||||||
|
Currently when root inode is in short-form and its parent ino |
||||||
|
has an invalid value, process_sf_dir2() ends up not fixing it, |
||||||
|
because if verify_inum() fails we never get to the next case which |
||||||
|
would fix the root inode's parent pointer. |
||||||
|
|
||||||
|
This behavior triggers the following assert on process_dir2(): |
||||||
|
|
||||||
|
ASSERT((ino != mp->m_sb.sb_rootino && ino != *parent) || |
||||||
|
(ino == mp->m_sb.sb_rootino && |
||||||
|
(ino == *parent || need_root_dotdot == 1))); |
||||||
|
|
||||||
|
This patch fixes this behavior by making sure we always properly |
||||||
|
handle rootino parent pointer in process_sf_dir2() |
||||||
|
|
||||||
|
Signed-off-by: Marco Benatto <mbenatto@redhat.com> |
||||||
|
Reviewed-by: Eric Sandeen <sandeen@redhat.com> |
||||||
|
|
||||||
|
--- |
||||||
|
|
||||||
|
Note: reviewed but not yet merged upstream |
||||||
|
|
||||||
|
repair/dir2.c | 4 +++- |
||||||
|
1 file changed, 3 insertions(+), 1 deletion(-) |
||||||
|
|
||||||
|
diff --git a/repair/dir2.c b/repair/dir2.c |
||||||
|
index e162d2b..225f926 100644 |
||||||
|
--- a/repair/dir2.c |
||||||
|
+++ b/repair/dir2.c |
||||||
|
@@ -495,8 +495,10 @@ _("corrected entry offsets in directory %" PRIu64 "\n"), |
||||||
|
|
||||||
|
/* |
||||||
|
* if parent entry is bogus, null it out. we'll fix it later . |
||||||
|
+ * If the validation fails for the root inode we fix it in |
||||||
|
+ * the next else case. |
||||||
|
*/ |
||||||
|
- if (verify_inum(mp, *parent)) { |
||||||
|
+ if (verify_inum(mp, *parent) && ino != mp->m_sb.sb_rootino) { |
||||||
|
|
||||||
|
do_warn( |
||||||
|
_("bogus .. inode number (%" PRIu64 ") in directory inode %" PRIu64 ", "), |
||||||
|
-- |
||||||
|
2.9.5 |
||||||
|
|
||||||
|
-- |
||||||
|
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in |
||||||
|
the body of a message to majordomo@vger.kernel.org |
||||||
|
More majordomo info at http://vger.kernel.org/majordomo-info.html |
||||||
|
|
||||||
|
|
@ -0,0 +1,24 @@ |
|||||||
|
/* This file is here to prevent a file conflict on multiarch systems. A |
||||||
|
* conflict will occur because platform_defs.h has arch-specific definitions. |
||||||
|
* |
||||||
|
* DO NOT INCLUDE THE NEW FILE DIRECTLY -- ALWAYS INCLUDE THIS ONE INSTEAD. */ |
||||||
|
|
||||||
|
#if defined(__i386__) |
||||||
|
#include "platform_defs-i386.h" |
||||||
|
#elif defined(__x86_64__) |
||||||
|
#include "platform_defs-x86_64.h" |
||||||
|
#elif defined(__powerpc64__) |
||||||
|
#include "platform_defs-ppc64.h" |
||||||
|
#elif defined(__powerpc__) |
||||||
|
#include "platform_defs-ppc.h" |
||||||
|
#elif defined(__s390x__) |
||||||
|
#include "platform_defs-s390x.h" |
||||||
|
#elif defined(__s390__) |
||||||
|
#include "platform_defs-s390.h" |
||||||
|
#elif defined(__sparc__) && defined(__arch64__) |
||||||
|
#include "platform_defs-sparc64.h" |
||||||
|
#elif defined(__sparc__) |
||||||
|
#include "platform_defs-sparc.h" |
||||||
|
#else |
||||||
|
#error "This xfsprogs-devel package does not work your architecture?" |
||||||
|
#endif |
Loading…
Reference in new issue