summaryrefslogtreecommitdiffstats
path: root/misc-utils/findmnt.c
diff options
context:
space:
mode:
authorKarel Zak2014-02-21 12:27:58 +0100
committerKarel Zak2014-02-21 12:27:58 +0100
commit2b6759df0c24a16ad5ddb855f0b453dd086a3747 (patch)
treef3017e233df5c9ca5dd9e94eee393559c65abba5 /misc-utils/findmnt.c
parentmkfs: mark this wrapper as DEPRECATED (diff)
downloadkernel-qcow2-util-linux-2b6759df0c24a16ad5ddb855f0b453dd086a3747.tar.gz
kernel-qcow2-util-linux-2b6759df0c24a16ad5ddb855f0b453dd086a3747.tar.xz
kernel-qcow2-util-linux-2b6759df0c24a16ad5ddb855f0b453dd086a3747.zip
findmnt: add --bytes to print sizes in bytes
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'misc-utils/findmnt.c')
-rw-r--r--misc-utils/findmnt.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/misc-utils/findmnt.c b/misc-utils/findmnt.c
index 988cd7397..dc1cbb745 100644
--- a/misc-utils/findmnt.c
+++ b/misc-utils/findmnt.c
@@ -59,7 +59,8 @@ enum {
FL_POLL = (1 << 9),
FL_DF = (1 << 10),
FL_ALL = (1 << 11),
- FL_UNIQ = (1 << 12)
+ FL_UNIQ = (1 << 12),
+ FL_BYTES = (1 << 13)
};
/* column IDs */
@@ -478,8 +479,14 @@ static char *get_vfs_attr(struct libmnt_fs *fs, int sizetype)
return sizestr;
}
- return vfs_attr == 0 ? xstrdup("0") :
- size_to_human_string(SIZE_SUFFIX_1LETTER, vfs_attr);
+ if (!vfs_attr)
+ sizestr = xstrdup("0");
+ else if (flags & FL_BYTES)
+ xasprintf(&sizestr, "%ju", vfs_attr);
+ else
+ sizestr = size_to_human_string(SIZE_SUFFIX_1LETTER, vfs_attr);
+
+ return sizestr;
}
/* reads FS data from libmount
@@ -1124,6 +1131,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out)
fputs(_(" -A, --all disable all built-in filters, print all filesystems\n"), out);
fputs(_(" -a, --ascii use ASCII chars for tree formatting\n"), out);
+ fputs(_(" -b, --bytes print sizes in bytes rather than in human readable format\n"), out);
fputs(_(" -c, --canonicalize canonicalize printed paths\n"), out);
fputs(_(" -D, --df imitate the output of df(1)\n"), out);
fputs(_(" -d, --direction <word> direction of search, 'forward' or 'backward'\n"), out);
@@ -1176,6 +1184,7 @@ int main(int argc, char *argv[])
static const struct option longopts[] = {
{ "all", 0, 0, 'A' },
{ "ascii", 0, 0, 'a' },
+ { "bytes", 0, 0, 'b' },
{ "canonicalize", 0, 0, 'c' },
{ "direction", 1, 0, 'd' },
{ "df", 0, 0, 'D' },
@@ -1227,7 +1236,7 @@ int main(int argc, char *argv[])
tt_flags |= TT_FL_TREE;
while ((c = getopt_long(argc, argv,
- "AacDd:ehifF:o:O:p::PklmnN:rst:uvRS:T:Uw:V",
+ "AabcDd:ehifF:o:O:p::PklmnN:rst:uvRS:T:Uw:V",
longopts, NULL)) != -1) {
err_exclusive_options(c, longopts, excl, excl_st);
@@ -1239,6 +1248,9 @@ int main(int argc, char *argv[])
case 'a':
tt_flags |= TT_FL_ASCII;
break;
+ case 'b':
+ flags |= FL_BYTES;
+ break;
case 'c':
flags |= FL_CANONICALIZE;
break;