summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak2007-11-07 21:25:48 +0100
committerKarel Zak2007-11-07 21:25:48 +0100
commit8505ff35cfc77f5f38aa0357c313aca99f0bda92 (patch)
tree592daa58e49ce8ef320021ae122912ad320132db
parentmount: cleanup KERNEL_VERSION, remove my_dev_t.h (diff)
downloadkernel-qcow2-util-linux-8505ff35cfc77f5f38aa0357c313aca99f0bda92.tar.gz
kernel-qcow2-util-linux-8505ff35cfc77f5f38aa0357c313aca99f0bda92.tar.xz
kernel-qcow2-util-linux-8505ff35cfc77f5f38aa0357c313aca99f0bda92.zip
elvtune: use get_linux_version()
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--disk-utils/Makefile.am1
-rw-r--r--disk-utils/elvtune.c27
-rw-r--r--include/blkdev.h1
3 files changed, 6 insertions, 23 deletions
diff --git a/disk-utils/Makefile.am b/disk-utils/Makefile.am
index 9ee985741..397d8efb4 100644
--- a/disk-utils/Makefile.am
+++ b/disk-utils/Makefile.am
@@ -15,6 +15,7 @@ usrbinexec_PROGRAMS = fdformat isosize
if BUILD_ELVTUNE
sbin_PROGRAMS += elvtune
man_MANS += elvtune.8
+elvtune_SOURCES = elvtune.c ../lib/linux_version.c
endif
if HAVE_RAW
diff --git a/disk-utils/elvtune.c b/disk-utils/elvtune.c
index dc264658f..fc7550ba6 100644
--- a/disk-utils/elvtune.c
+++ b/disk-utils/elvtune.c
@@ -30,6 +30,8 @@
#include <sys/ioctl.h>
#include <sys/utsname.h>
#include "nls.h"
+#include "blkdev.h"
+#include "linux_version.h"
/* this has to match with the kernel structure */
/* current version for ac19 and 2.2.16 */
@@ -40,10 +42,6 @@ typedef struct blkelv_ioctl_arg_s {
int max_bomb_segments;
} blkelv_ioctl_arg_t;
-/* ioctls introduced in 2.2.16, removed in 2.5.58 */
-#define BLKELVGET _IOR(0x12,106,size_t)
-#define BLKELVSET _IOW(0x12,107,size_t)
-
static void
usage(void) {
fprintf(stderr, "elvtune (%s)\n", PACKAGE_STRING);
@@ -61,23 +59,6 @@ version(void) {
fprintf(stderr, "elvtune (%s)\n", PACKAGE_STRING);
}
-#define MAKE_VERSION(p,q,r) (65536*(p) + 256*(q) + (r))
-
-static int
-linux_version_code(void) {
- struct utsname my_utsname;
- int p, q, r;
-
- if (uname(&my_utsname) == 0) {
- p = atoi(strtok(my_utsname.release, "."));
- q = atoi(strtok(NULL, "."));
- r = atoi(strtok(NULL, "."));
- return MAKE_VERSION(p,q,r);
- }
- return 0;
-}
-
-
int
main(int argc, char * argv[]) {
int read_value = 0xbeefbeef, write_value = 0xbeefbeef, bomb_value = 0xbeefbeef;
@@ -123,7 +104,7 @@ main(int argc, char * argv[]) {
if (optind >= argc)
fprintf(stderr, "missing blockdevice, use -h for help\n"), exit(1);
-
+
while (optind < argc) {
devname = argv[optind++];
@@ -141,7 +122,7 @@ main(int argc, char * argv[]) {
int errsv = errno;
perror("ioctl get");
if ((errsv == EINVAL || errsv == ENOTTY) &&
- linux_version_code() >= MAKE_VERSION(2,5,58)) {
+ get_linux_version() >= KERNEL_VERSION(2,5,58)) {
fprintf(stderr,
"\nelvtune is only useful on older "
"kernels;\nfor 2.6 use IO scheduler "
diff --git a/include/blkdev.h b/include/blkdev.h
index 8065acc1e..1f0fe674e 100644
--- a/include/blkdev.h
+++ b/include/blkdev.h
@@ -21,6 +21,7 @@
#define BLKSECTGET _IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
#define BLKSSZGET _IO(0x12,104)/* get block device sector size */
+/* ioctls introduced in 2.2.16, removed in 2.5.58 */
#define BLKELVGET _IOR(0x12,106,size_t) /* elevator get */
#define BLKELVSET _IOW(0x12,107,size_t) /* elevator set */