From 09ec0c0a970d3542d818bb57e29bb76c489cc37c Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 22 Dec 2011 11:02:58 +0100 Subject: losetup: print info about one device Signed-off-by: Karel Zak --- sys-utils/losetup.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'sys-utils/losetup.c') diff --git a/sys-utils/losetup.c b/sys-utils/losetup.c index ab45dff1d..af4d1b098 100644 --- a/sys-utils/losetup.c +++ b/sys-utils/losetup.c @@ -32,6 +32,7 @@ enum { A_DELETE, /* delete given device(s) */ A_DELETE_ALL, /* delete all devices */ A_SHOW, /* list devices */ + A_SHOW_ONE, /* print info about one device */ A_FIND_FREE, /* find first unused */ A_SET_CAPACITY, /* set device capacity */ }; @@ -329,6 +330,13 @@ int main(int argc, char **argv) act = A_CREATE; file = argv[optind++]; } + if (!act && optind + 1 == argc) { + /* + * losetup + */ + act = A_SHOW_ONE; + loopcxt_set_device(&lc, argv[optind++]); + } if (!act) { /* * losetup @@ -421,6 +429,11 @@ int main(int argc, char **argv) case A_SHOW: res = show_all_loops(&lc, file, offset, flags); break; + case A_SHOW_ONE: + res = printf_loopdev(&lc); + if (res) + warn(_("%s"), loopcxt_get_device(&lc)); + break; case A_SET_CAPACITY: res = set_capacity(&lc); break; -- cgit v1.2.3-55-g7522