diff options
author | Maciej Wereski <m.wereski@partner.samsung.com> | 2014-10-31 11:49:53 +0100 |
---|---|---|
committer | Maciej Wereski <m.wereski@partner.samsung.com> | 2014-10-31 11:49:53 +0100 |
commit | 68a73530284ce26d3b2467592107dedd8302eb31 (patch) | |
tree | 7a7d9d408049a15bdbfe196c829963d6dc9c7e77 /misc-utils | |
parent | eccec3e6550cee2e6dcd6aa613353de6992d1ac1 (diff) | |
download | util-linux-68a73530284ce26d3b2467592107dedd8302eb31.tar.gz util-linux-68a73530284ce26d3b2467592107dedd8302eb31.tar.bz2 util-linux-68a73530284ce26d3b2467592107dedd8302eb31.zip |
Imported Upstream version 2.24.2upstream/2.24.2
Diffstat (limited to 'misc-utils')
-rw-r--r-- | misc-utils/blkid.c | 14 | ||||
-rw-r--r-- | misc-utils/findmnt.c | 5 | ||||
-rw-r--r-- | misc-utils/getopt.1 | 2 | ||||
-rw-r--r-- | misc-utils/lsblk.c | 6 | ||||
-rw-r--r-- | misc-utils/wipefs.8 | 3 | ||||
-rw-r--r-- | misc-utils/wipefs.c | 41 |
6 files changed, 52 insertions, 19 deletions
diff --git a/misc-utils/blkid.c b/misc-utils/blkid.c index b032c85..b3eade5 100644 --- a/misc-utils/blkid.c +++ b/misc-utils/blkid.c @@ -104,8 +104,10 @@ static void usage(int error) /* * This function does "safe" printing. It will convert non-printable * ASCII characters using '^' and M- notation. + * + * If 'esc' is defined then escape all chars from esc by \. */ -static void safe_print(const char *cp, int len) +static void safe_print(const char *cp, int len, const char *esc) { unsigned char ch; @@ -122,7 +124,9 @@ static void safe_print(const char *cp, int len) if ((ch < 32) || (ch == 0x7f)) { fputc('^', stdout); ch ^= 0x40; /* ^@, ^A, ^B; ^? for DEL */ - } + + } else if (esc && strchr(esc, ch)) + fputc('\\', stdout); } fputc(ch, stdout); } @@ -302,7 +306,7 @@ static void print_value(int output, int num, const char *devname, printf("DEVNAME=%s\n", devname); fputs(name, stdout); fputs("=", stdout); - safe_print(value, valsz); + safe_print(value, valsz, NULL); fputs("\n", stdout); } else { @@ -310,7 +314,7 @@ static void print_value(int output, int num, const char *devname, printf("%s: ", devname); fputs(name, stdout); fputs("=\"", stdout); - safe_print(value, valsz); + safe_print(value, valsz, "\""); fputs("\" ", stdout); } } @@ -595,7 +599,7 @@ static int list_to_usage(const char *list, int *flag) return mask; err: *flag = 0; - fprintf(stderr, "unknown kerword in -u <list> argument: '%s'\n", + fprintf(stderr, "unknown keyword in -u <list> argument: '%s'\n", word ? word : list); exit(BLKID_EXIT_OTHER); } diff --git a/misc-utils/findmnt.c b/misc-utils/findmnt.c index 91cc935..f269246 100644 --- a/misc-utils/findmnt.c +++ b/misc-utils/findmnt.c @@ -821,8 +821,9 @@ static int tab_is_tree(struct libmnt_table *tb) if (!itr) return 0; - if (mnt_table_next_fs(tb, itr, &fs) == 0) - rc = mnt_fs_get_id(fs) > 0 && mnt_fs_get_parent_id(fs) > 0; + rc = (mnt_table_next_fs(tb, itr, &fs) == 0 && + mnt_fs_is_kernel(fs) && + mnt_fs_get_root(fs)); mnt_free_iter(itr); return rc; diff --git a/misc-utils/getopt.1 b/misc-utils/getopt.1 index 04fd34a..7fd8720 100644 --- a/misc-utils/getopt.1 +++ b/misc-utils/getopt.1 @@ -418,7 +418,7 @@ Example scripts for (ba)sh and (t)csh are provided with the distribution, and are optionally installed in .BR /usr/share/getopt/ or -.BR /usr/share/docs/ +.BR /usr/share/doc/ in the util-linux subdirectory. .SH ENVIRONMENT .IP POSIXLY_CORRECT diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c index 9f7f1b6..9b53be3 100644 --- a/misc-utils/lsblk.c +++ b/misc-utils/lsblk.c @@ -903,7 +903,7 @@ static void set_tt_data(struct blkdev_cxt *cxt, int col, int id, struct tt_line if (cxt->discard && p) tt_line_set_data(ln, col, p); else - tt_line_set_data(ln, col, "0"); + tt_line_set_data(ln, col, xstrdup("0")); break; case COL_DGRAN: if (lsblk->bytes) @@ -936,7 +936,7 @@ static void set_tt_data(struct blkdev_cxt *cxt, int col, int id, struct tt_line if (cxt->discard && p) tt_line_set_data(ln, col, p); else - tt_line_set_data(ln, col, "0"); + tt_line_set_data(ln, col, xstrdup("0")); break; case COL_WSAME: if (lsblk->bytes) @@ -948,7 +948,7 @@ static void set_tt_data(struct blkdev_cxt *cxt, int col, int id, struct tt_line "queue/write_same_max_bytes", &x) == 0) p = size_to_human_string(SIZE_SUFFIX_1LETTER, x); } - tt_line_set_data(ln, col, p ? p : "0"); + tt_line_set_data(ln, col, p ? p : xstrdup("0")); break; }; } diff --git a/misc-utils/wipefs.8 b/misc-utils/wipefs.8 index 331e96c..0f280b3 100644 --- a/misc-utils/wipefs.8 +++ b/misc-utils/wipefs.8 @@ -23,6 +23,9 @@ does not erase the filesystem itself nor any other data from the device. When used without options \fB-a\fR or \fB-o\fR, it lists all visible filesystems and the offsets of their basic signatures. +.B wipefs +calls BLKRRPART ioctl when erase partition table to inform kernel about the change. + Note that some filesystems or some partition tables store more magic strings on the devices. The .B wipefs diff --git a/misc-utils/wipefs.c b/misc-utils/wipefs.c index 8ac6c33..cd2fd98 100644 --- a/misc-utils/wipefs.c +++ b/misc-utils/wipefs.c @@ -40,21 +40,24 @@ #include "c.h" #include "closestream.h" #include "optutils.h" +#include "blkdev.h" struct wipe_desc { loff_t offset; /* magic string offset */ size_t len; /* length of magic string */ unsigned char *magic; /* magic string */ - int zap; /* zap this offset? */ char *usage; /* raid, filesystem, ... */ char *type; /* FS type */ char *label; /* FS label */ char *uuid; /* FS uuid */ - int on_disk; - struct wipe_desc *next; + + unsigned int zap : 1, + on_disk : 1, + is_parttable : 1; + }; enum { @@ -80,7 +83,7 @@ print_pretty(struct wipe_desc *wp, int line) printf("----------------------------------------------------------------\n"); } - printf("0x%-17jx %s [%s]", wp->offset, wp->type, wp->usage); + printf("0x%-17jx %s [%s]", wp->offset, wp->type, _(wp->usage)); if (wp->label && *wp->label) printf("\n%27s %s", "LABEL:", wp->label); @@ -149,7 +152,7 @@ add_offset(struct wipe_desc *wp0, loff_t offset, int zap) wp = xcalloc(1, sizeof(struct wipe_desc)); wp->offset = offset; wp->next = wp0; - wp->zap = zap; + wp->zap = zap ? 1 : 0; return wp; } @@ -172,7 +175,7 @@ get_desc_for_probe(struct wipe_desc *wp, blkid_probe pr) const char *off, *type, *mag, *p, *usage = NULL; size_t len; loff_t offset; - int rc; + int rc, ispt = 0; /* superblocks */ if (blkid_probe_lookup_value(pr, "TYPE", &type, NULL) == 0) { @@ -189,7 +192,8 @@ get_desc_for_probe(struct wipe_desc *wp, blkid_probe pr) rc = blkid_probe_lookup_value(pr, "PTMAGIC", &mag, &len); if (rc) return wp; - usage = "partition table"; + usage = N_("partition table"); + ispt = 1; } else return wp; @@ -207,6 +211,7 @@ get_desc_for_probe(struct wipe_desc *wp, blkid_probe pr) wp->type = xstrdup(type); wp->on_disk = 1; + wp->is_parttable = ispt ? 1 : 0; wp->magic = xmalloc(len); memcpy(wp->magic, mag, len); @@ -340,10 +345,24 @@ err: err(EXIT_FAILURE, _("%s: failed to create a signature backup"), fname); } +static void rereadpt(int fd, const char *devname) +{ +#ifdef BLKRRPART + struct stat st; + + if (fstat(fd, &st) || !S_ISBLK(st.st_mode)) + return; + + errno = 0; + ioctl(fd, BLKRRPART); + printf(_("%s: calling ioclt to re-read partition table: %m\n"), devname); +#endif +} + static struct wipe_desc * do_wipe(struct wipe_desc *wp, const char *devname, int flags) { - int mode = O_RDWR; + int mode = O_RDWR, reread = 0; blkid_probe pr; struct wipe_desc *w, *wp0; int zap = (flags & WP_FL_ALL) ? 1 : wp->zap; @@ -387,6 +406,8 @@ do_wipe(struct wipe_desc *wp, const char *devname, int flags) if (backup) do_backup(wp, backup); do_wipe_real(pr, devname, wp, flags); + if (wp->is_parttable) + reread = 1; } } @@ -396,6 +417,10 @@ do_wipe(struct wipe_desc *wp, const char *devname, int flags) } fsync(blkid_probe_get_fd(pr)); + + if (reread) + rereadpt(blkid_probe_get_fd(pr), devname); + close(blkid_probe_get_fd(pr)); blkid_free_probe(pr); free_wipe(wp0); |