From 8f5ad7ef175851a18b35a10707742ff3b3382c7d Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sat, 23 Aug 2014 23:08:59 -0500 Subject: Promote blockdev to other. --- toys/other/blockdev.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++ toys/pending/blockdev.c | 70 ------------------------------------------------- 2 files changed, 70 insertions(+), 70 deletions(-) create mode 100644 toys/other/blockdev.c delete mode 100644 toys/pending/blockdev.c (limited to 'toys') diff --git a/toys/other/blockdev.c b/toys/other/blockdev.c new file mode 100644 index 00000000..79b4d6f9 --- /dev/null +++ b/toys/other/blockdev.c @@ -0,0 +1,70 @@ +/* blockdev.c -show/set blockdev information. + * + * Copyright 2014 Sameer Prakash Pradhan + * + * No Standard. + +USE_BLOCKDEV(NEWTOY(blockdev, "<1>1(setro)(setrw)(getro)(getss)(getbsz)(setbsz)#<0(getsz)(getsize)(getsize64)(flushbufs)(rereadpt)",TOYFLAG_USR|TOYFLAG_BIN)) + +config BLOCKDEV + bool "blockdev" + default y + help + usage: blockdev --OPTION... BLOCKDEV... + + Call ioctl(s) on each listed block device + + OPTIONs: + --setro Set read only + --setrw Set read write + --getro Get read only + --getss Get sector size + --getbsz Get block size + --setbsz BYTES Set block size + --getsz Get device size in 512-byte sectors + --getsize Get device size in sectors (deprecated) + --getsize64 Get device size in bytes + --flushbufs Flush buffers + --rereadpt Reread partition table +*/ + +#define FOR_blockdev +#include "toys.h" +#include + +GLOBALS( + long bsz; +) + +void blockdev_main(void) +{ + int cmds[] = {BLKRRPART, BLKFLSBUF, BLKGETSIZE64, BLKGETSIZE, BLKGETSIZE64, + BLKBSZSET, BLKBSZGET, BLKSSZGET, BLKROGET, BLKROSET, BLKROSET}; + char **ss; + long long val = 0; + + if (!toys.optflags) { + toys.exithelp = 1; + error_exit("need --option"); + } + + for (ss = toys.optargs; *ss; ss++) { + int fd = xopen(*ss, O_RDONLY), i; + + // Command line order discarded so perform multiple operations in flag order + for (i = 0; i < 32; i++) { + long flag = toys.optflags & (1<> 9: val); + } + xclose(fd); + } +} diff --git a/toys/pending/blockdev.c b/toys/pending/blockdev.c deleted file mode 100644 index 58318f55..00000000 --- a/toys/pending/blockdev.c +++ /dev/null @@ -1,70 +0,0 @@ -/* blockdev.c -show/set blockdev information. - * - * Copyright 2014 Sameer Prakash Pradhan - * - * No Standard. - -USE_BLOCKDEV(NEWTOY(blockdev, "<1>1(setro)(setrw)(getro)(getss)(getbsz)(setbsz)#<0(getsz)(getsize)(getsize64)(flushbufs)(rereadpt)",TOYFLAG_USR|TOYFLAG_BIN)) - -config BLOCKDEV - bool "blockdev" - default n - help - usage: blockdev --OPTION... BLOCKDEV... - - Call ioctl(s) on each listed block device - - OPTIONs: - --setro Set read only - --setrw Set read write - --getro Get read only - --getss Get sector size - --getbsz Get block size - --setbsz BYTES Set block size - --getsz Get device size in 512-byte sectors - --getsize Get device size in sectors (deprecated) - --getsize64 Get device size in bytes - --flushbufs Flush buffers - --rereadpt Reread partition table -*/ - -#define FOR_blockdev -#include "toys.h" -#include - -GLOBALS( - long bsz; -) - -void blockdev_main(void) -{ - int cmds[] = {BLKRRPART, BLKFLSBUF, BLKGETSIZE64, BLKGETSIZE, BLKGETSIZE64, - BLKBSZSET, BLKBSZGET, BLKSSZGET, BLKROGET, BLKROSET, BLKROSET}; - char **ss; - long long val = 0; - - if (!toys.optflags) { - toys.exithelp = 1; - error_exit("need --option"); - } - - for (ss = toys.optargs; *ss; ss++) { - int fd = xopen(*ss, O_RDONLY), i; - - // Command line order discarded so perform multiple operations in flag order - for (i = 0; i < 32; i++) { - long flag = toys.optflags & (1<> 9: val); - } - xclose(fd); - } -} -- cgit v1.2.3