summaryrefslogtreecommitdiffstats
path: root/disk-utils
diff options
context:
space:
mode:
authorKarel Zak2006-12-07 00:25:44 +0100
committerKarel Zak2006-12-07 00:25:44 +0100
commit66ee8158b69525e12060ef558cb5d77feadab1dc (patch)
tree08b30f2d07df9213f5647bc6f60b5090a263ef43 /disk-utils
parentImported from util-linux-2.10m tarball. (diff)
downloadkernel-qcow2-util-linux-66ee8158b69525e12060ef558cb5d77feadab1dc.tar.gz
kernel-qcow2-util-linux-66ee8158b69525e12060ef558cb5d77feadab1dc.tar.xz
kernel-qcow2-util-linux-66ee8158b69525e12060ef558cb5d77feadab1dc.zip
Imported from util-linux-2.10s tarball.
Diffstat (limited to 'disk-utils')
-rw-r--r--disk-utils/Makefile11
-rw-r--r--disk-utils/blockdev.855
-rw-r--r--disk-utils/elvtune.c19
-rw-r--r--disk-utils/fdformat.c6
-rw-r--r--disk-utils/isosize.829
-rw-r--r--disk-utils/isosize.c218
-rw-r--r--disk-utils/mkfs.bfs.c61
-rw-r--r--disk-utils/mkfs.minix.83
-rw-r--r--disk-utils/mkfs.minix.c10
-rw-r--r--disk-utils/mkswap.c9
-rw-r--r--disk-utils/raw.c1
-rw-r--r--disk-utils/setfdprm.c40
12 files changed, 391 insertions, 71 deletions
diff --git a/disk-utils/Makefile b/disk-utils/Makefile
index ab9237c88..af15ee410 100644
--- a/disk-utils/Makefile
+++ b/disk-utils/Makefile
@@ -8,16 +8,17 @@ include ../MCONFIG
# Where to put man pages?
-MAN8= fdformat.8 mkfs.8 mkswap.8 elvtune.8 fsck.minix.8 mkfs.minix.8 mkfs.bfs.8
+MAN8= blockdev.8 fdformat.8 isosize.8 mkfs.8 mkswap.8 elvtune.8 \
+ fsck.minix.8 mkfs.minix.8 mkfs.bfs.8
# Where to put binaries?
# See the "install" rule for the links. . .
-SBIN= mkfs mkswap blockdev elvtune fsck.minix mkfs.minix mkfs.bfs
+SBIN= mkfs mkswap blockdev elvtune fsck.minix mkfs.minix mkfs.bfs
-USRBIN= fdformat
+USRBIN= fdformat isosize
-ETC= fdprm
+ETC= fdprm
ifneq "$(HAVE_FDUTILS)" "yes"
USRBIN:=$(USRBIN) setfdprm
@@ -47,4 +48,4 @@ endif
.PHONY: clean
clean:
- -rm -f *.o *~ core $(SBIN) $(USRBIN)
+ -rm -f *.o *~ core $(SBIN) $(USRBIN) raw
diff --git a/disk-utils/blockdev.8 b/disk-utils/blockdev.8
new file mode 100644
index 000000000..bde64265f
--- /dev/null
+++ b/disk-utils/blockdev.8
@@ -0,0 +1,55 @@
+.\" -*- nroff -*-
+.\" Copyright 1998 Andries E. Brouwer (aeb@cwi.nl)
+.\"
+.\" May be distributed under the GNU General Public License
+.TH BLOCKDEV 8 "May 2000" ""
+.SH NAME
+blockdev \- call block device ioctls from the command line
+.SH SYNOPSIS
+.B blockdev
+.RI [ options ]
+.I commands devices
+.SH DESCRIPTION
+The utility
+.B blockdev
+allows one to call block device ioctls from the command line.
+.SH OPTIONS
+.TP
+.B \-V
+Print version and exit.
+.TP
+.B \-q
+Be quiet.
+.TP
+.B \-v
+Be verbose.
+.SH COMMANDS
+.TP
+.B \--setro
+Set read-only.
+.TP
+.B \--setrw
+Set read-write.
+.TP
+.B \--getro
+Get read-only. Print 1 if the device is read-only, 0 otherwise.
+.TP
+.B \--getss
+Print sectorsize in bytes - usually 512.
+.TP
+.B \--getsize
+Print device capacity (in 512-byte sectors).
+.TP
+.BI \--setra " N"
+Set readahead to
+.I N
+512-byte sectors.
+.TP
+.B \--getra
+Print readahead (in 512-byte sectors).
+.TP
+.B \--flushbufs
+Flush buffers.
+.TP
+.B \--rereadpt
+Reread partition table.
diff --git a/disk-utils/elvtune.c b/disk-utils/elvtune.c
index 00640fede..75ab57c0e 100644
--- a/disk-utils/elvtune.c
+++ b/disk-utils/elvtune.c
@@ -26,28 +26,33 @@
#include <sys/ioctl.h>
#include <unistd.h>
#include <stdlib.h>
-
-#define BLKELVGET _IO(0x12,106)/* elevator get */
-#define BLKELVSET _IO(0x12,107)/* elevator set */
+#include "nls.h"
/* this has to match with the kernel structure */
+/* current version for ac19 and 2.2.16 */
typedef struct blkelv_ioctl_arg_s {
- void * queue_ID;
+ int queue_ID;
int read_latency;
int write_latency;
int max_bomb_segments;
} blkelv_ioctl_arg_t;
+#define BLKELVGET _IOR(0x12,106,sizeof(blkelv_ioctl_arg_t))
+#define BLKELVSET _IOW(0x12,107,sizeof(blkelv_ioctl_arg_t))
+
static void
usage(void) {
- fprintf(stderr, "usage:\n\telvtune [-r r_lat] [-w w_lat] [-b b_lat] /dev/blkdev1 [/dev/blkdev2...]\n");
+ fprintf(stderr, "elvtune (%s)\n", util_linux_version);
+ fprintf(stderr, _("usage:\n"));
+ fprintf(stderr, "\telvtune [-r r_lat] [-w w_lat] [-b b_lat]"
+ " /dev/blkdev1 [/dev/blkdev2...]\n");
fprintf(stderr, "\telvtune -h\n");
fprintf(stderr, "\telvtune -v\n");
}
static void
version(void) {
- fprintf(stderr, "elvtune: version 1.0\n");
+ fprintf(stderr, "elvtune (%s)\n", util_linux_version);
}
int
@@ -128,7 +133,7 @@ main(int argc, char * argv[]) {
}
}
- printf("\n%s elevator ID %p\n", devname, elevator.queue_ID);
+ printf("\n%s elevator ID\t\t%d\n", devname, elevator.queue_ID);
printf("\tread_latency:\t\t%d\n", elevator.read_latency);
printf("\twrite_latency:\t\t%d\n", elevator.write_latency);
printf("\tmax_bomb_segments:\t%d\n\n", elevator.max_bomb_segments);
diff --git a/disk-utils/fdformat.c b/disk-utils/fdformat.c
index 0251e3440..b4aec0076 100644
--- a/disk-utils/fdformat.c
+++ b/disk-utils/fdformat.c
@@ -1,4 +1,4 @@
-/* fdformat.c - Low-level formats a floppy disk. */
+/* fdformat.c - Low-level formats a floppy disk - Werner Almesberger */
/* 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@misiek.eu.org>
* - added Native Language Support
@@ -135,11 +135,11 @@ int main(int argc,char **argv)
exit(1);
}
if (access(argv[1],W_OK) < 0) PERROR(argv[1]);
- if ((ctrl = open(argv[1],3)) < 0) PERROR(argv[1]);
+ if ((ctrl = open(argv[1],O_WRONLY)) < 0) PERROR(argv[1]);
if (ioctl(ctrl,FDGETPRM,(long) &param) < 0)
PERROR(_("Could not determine current format type"));
printf(_("%s-sided, %d tracks, %d sec/track. Total capacity %d kB.\n"),
- param.head ? _("Double") : _("Single"),
+ (param.head == 2) ? _("Double") : _("Single"),
param.track, param.sect,param.size >> 1);
format_disk(argv[1]);
if (verify) verify_disk(argv[1]);
diff --git a/disk-utils/isosize.8 b/disk-utils/isosize.8
new file mode 100644
index 000000000..47ab71fc5
--- /dev/null
+++ b/disk-utils/isosize.8
@@ -0,0 +1,29 @@
+.TH ISOSIZE "8" "December 2000" "sg3_utils-0.91" SG_UTILS
+.SH NAME
+isosize \- outputs the length of a iso9660 file system
+.SH SYNOPSIS
+.B isosize
+[\fI-x\fR] [\fI-d <num>\fR] \fI<iso9660_image_file>\fR...
+.SH DESCRIPTION
+.\" Add any additional description here
+.PP
+This command outputs the length of an iso9660 file system that
+is contained in given file. That file may be a normal file or
+a block device (e.g. /dev/hdd or /dev/sr0). In the absence of
+any switches (or errors) it will output the size of the iso9660
+file system in bytes. This can now be a large number (> > 4 GB).
+.TP
+-x
+output in humanly readable form the block count and the block
+size. Output uses the term "sectors" for "blocks".
+.TP
+-d <num>
+only has affect when "-x" is not given. The number output (if no errors)
+is the iso9660 file size in bytes divided by <num>. So if <num> is
+the block size then the output number will be the block count.
+.PP
+The size of the file (or block device) holding a iso9660 file
+system can be marginally larger than the actual size of the
+iso9660 file system. One reason for this is that cd writers
+are allowed to add "run out" sectors at the end of a iso9660
+image.
diff --git a/disk-utils/isosize.c b/disk-utils/isosize.c
new file mode 100644
index 000000000..bff45d923
--- /dev/null
+++ b/disk-utils/isosize.c
@@ -0,0 +1,218 @@
+/*
+ * isosize.c - Andries Brouwer, 000608
+ *
+ * use header info to find size of iso9660 file system
+ * output a number - useful in scripts
+ *
+ * Synopsis:
+ * isosize [-x] [-d <num>] <filename>
+ * where "-x" gives length in sectors and sector size while
+ * without this argument the size is given in bytes
+ * without "-x" gives length in bytes unless "-d <num>" is
+ * given. In the latter case the length in bytes divided
+ * by <num> is given
+ *
+ * Version 2.03 2000/12/21
+ * - add "-d <num>" option and use long long to fix things > 2 GB
+ * Version 2.02 2000/10/11
+ * - error messages on IO failures [D. Gilbert]
+ *
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <getopt.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+
+#include "nls.h"
+
+#define ISODCL(from, to) (to - from + 1)
+
+int xflag;
+
+static int
+isonum_721 (unsigned char * p) {
+ return ((p[0] & 0xff)
+ | ((p[1] & 0xff) << 8));
+}
+
+static int
+isonum_722 (unsigned char * p) {
+ return ((p[1] & 0xff)
+ | ((p[0] & 0xff) << 8));
+}
+
+static int
+isonum_723 (unsigned char * p) {
+ int le = isonum_721 (p);
+ int be = isonum_722 (p+2);
+ if (xflag && le != be)
+ /* translation is useless */
+ fprintf(stderr, "723error: le=%d be=%d\n", le, be);
+ return (le);
+}
+
+static int
+isonum_731 (unsigned char * p) {
+ return ((p[0] & 0xff)
+ | ((p[1] & 0xff) << 8)
+ | ((p[2] & 0xff) << 16)
+ | ((p[3] & 0xff) << 24));
+}
+
+static int
+isonum_732 (unsigned char * p) {
+ return ((p[3] & 0xff)
+ | ((p[2] & 0xff) << 8)
+ | ((p[1] & 0xff) << 16)
+ | ((p[0] & 0xff) << 24));
+}
+
+
+static int
+isonum_733 (unsigned char * p) {
+ int le = isonum_731 (p);
+ int be = isonum_732 (p+4);
+ if (xflag && le != be)
+ /* translation is useless */
+ fprintf(stderr, "733error: le=%d be=%d\n", le, be);
+ return (le);
+}
+
+struct iso_primary_descriptor {
+ unsigned char type [ISODCL ( 1, 1)]; /* 711 */
+ unsigned char id [ISODCL ( 2, 6)];
+ unsigned char version [ISODCL ( 7, 7)]; /* 711 */
+ unsigned char unused1 [ISODCL ( 8, 8)];
+ unsigned char system_id [ISODCL ( 9, 40)]; /* auchars */
+ unsigned char volume_id [ISODCL ( 41, 72)]; /* duchars */
+ unsigned char unused2 [ISODCL ( 73, 80)];
+ unsigned char volume_space_size [ISODCL ( 81, 88)]; /* 733 */
+ unsigned char unused3 [ISODCL ( 89, 120)];
+ unsigned char volume_set_size [ISODCL (121, 124)]; /* 723 */
+ unsigned char volume_sequence_number [ISODCL (125, 128)]; /* 723 */
+ unsigned char logical_block_size [ISODCL (129, 132)]; /* 723 */
+ unsigned char path_table_size [ISODCL (133, 140)]; /* 733 */
+ unsigned char type_l_path_table [ISODCL (141, 144)]; /* 731 */
+ unsigned char opt_type_l_path_table [ISODCL (145, 148)]; /* 731 */
+ unsigned char type_m_path_table [ISODCL (149, 152)]; /* 732 */
+ unsigned char opt_type_m_path_table [ISODCL (153, 156)]; /* 732 */
+ unsigned char root_directory_record [ISODCL (157, 190)]; /* 9.1 */
+ unsigned char volume_set_id [ISODCL (191, 318)]; /* duchars */
+ unsigned char publisher_id [ISODCL (319, 446)]; /* achars */
+ unsigned char preparer_id [ISODCL (447, 574)]; /* achars */
+ unsigned char application_id [ISODCL (575, 702)]; /* achars */
+ unsigned char copyright_file_id [ISODCL (703, 739)]; /* 7.5 dchars */
+ unsigned char abstract_file_id [ISODCL (740, 776)]; /* 7.5 dchars */
+ unsigned char bibliographic_file_id [ISODCL (777, 813)]; /* 7.5 dchars */
+ unsigned char creation_date [ISODCL (814, 830)]; /* 8.4.26.1 */
+ unsigned char modification_date [ISODCL (831, 847)]; /* 8.4.26.1 */
+ unsigned char expiration_date [ISODCL (848, 864)]; /* 8.4.26.1 */
+ unsigned char effective_date [ISODCL (865, 881)]; /* 8.4.26.1 */
+ unsigned char file_structure_version [ISODCL (882, 882)]; /* 711 */
+ unsigned char unused4 [ISODCL (883, 883)];
+ unsigned char application_data [ISODCL (884, 1395)];
+ unsigned char unused5 [ISODCL (1396, 2048)];
+};
+
+const char *progname;
+int divisor = 0;
+
+static void
+isosize(char *filenamep) {
+ int fd, nsecs, ssize;
+ struct iso_primary_descriptor ipd;
+
+ if ((fd = open(filenamep, O_RDONLY)) < 0) {
+ perror(filenamep);
+ fprintf(stderr, _("%s: failed to open: %s\n"),
+ progname, filenamep);
+ exit(1);
+ }
+ if (lseek(fd, 16 << 11, 0) == (off_t)-1) {
+ perror("lseek");
+ fprintf(stderr, _("%s: seek error on %s\n"),
+ progname, filenamep);
+ exit(1);
+ }
+ if (read(fd, &ipd, sizeof(ipd)) < 0) {
+ perror("read");
+ fprintf(stderr, _("%s: read error on %s\n"),
+ progname, filenamep);
+ exit(1);
+ }
+
+ nsecs = isonum_733(ipd.volume_space_size);
+ ssize = isonum_723(ipd.logical_block_size); /* nowadays always 2048 */
+
+ if (xflag) {
+ printf (_("sector count: %d, sector size: %d\n"),
+ nsecs, ssize);
+ } else {
+ long long product = nsecs;
+
+ if (divisor == 0)
+ printf ("%lld\n", product * ssize);
+ else if (divisor == ssize)
+ printf ("%d\n", nsecs);
+ else
+ printf ("%lld\n", (product * ssize) / divisor);
+ }
+}
+
+int
+main(int argc, char * argv[]) {
+ int j, ct;
+ char *p;
+
+ progname = argv[0];
+ if ((p = strrchr(progname, '/')) != NULL)
+ progname = p+1;
+
+ setlocale(LC_ALL, "");
+ bindtextdomain(PACKAGE, LOCALEDIR);
+ textdomain(PACKAGE);
+
+ if (argc >= 2 &&
+ (!strcmp(argv[1], "-V") || !strcmp(argv[1], "--version"))) {
+ printf(_("%s from %s\n"), progname, util_linux_version);
+ exit(0);
+ }
+
+ for (;;) {
+ int opt;
+
+ opt = getopt(argc, argv, "xd:");
+ if (opt < 0)
+ break;
+ switch (opt) {
+ case 'd':
+ divisor = atoi(optarg);
+ break;
+ case 'x':
+ xflag = 1;
+ break;
+ default:
+ fprintf(stderr,
+ _("%s: option parse error\n"), progname);
+ exit(1);
+ }
+ }
+
+ ct = argc - optind;
+
+ if (ct <= 0) {
+ fprintf(stderr, _("Usage: %s [-x] [-d <num>] iso9660-image\n"),
+ progname);
+ exit(1);
+ }
+
+ for (j = optind; j < argc; j++) {
+ if (ct > 1)
+ printf("%s: ", argv[j]);
+ isosize(argv[j]);
+ }
+
+ return 0;
+}
diff --git a/disk-utils/mkfs.bfs.c b/disk-utils/mkfs.bfs.c
index a8f557837..b27fd2eb6 100644
--- a/disk-utils/mkfs.bfs.c
+++ b/disk-utils/mkfs.bfs.c
@@ -15,14 +15,13 @@
#include <errno.h>
#include <string.h>
#include <time.h>
+#include "nls.h"
/* cannot include <linux/fs.h> */
#ifndef BLKGETSIZE
#define BLKGETSIZE _IO(0x12,96) /* return device size */
#endif
-#include "../defines.h" /* for util_linux_version */
-
#define BFS_ROOT_INO 2
#define BFS_NAMELEN 14
#define BFS_BLOCKSIZE 512
@@ -85,9 +84,9 @@ fatal(char *s, ...) {
static void
usage(void) {
- fprintf(stderr,
+ fprintf(stderr, _(
"Usage: %s [-v] [-N nr-of-inodes] [-V volume-name]\n"
- " [-F fsname] device [block-count]\n",
+ " [-F fsname] device [block-count]\n"),
progname);
exit(1);
}
@@ -117,7 +116,7 @@ main(int argc, char *argv[]) {
if (argc == 2 &&
(!strcmp(argv[1], "-V") || !strcmp(argv[1], "--version"))) {
- printf("%s from %s\n", progname, util_linux_version);
+ printf(_("%s from %s\n"), progname, util_linux_version);
exit(0);
}
@@ -133,14 +132,14 @@ main(int argc, char *argv[]) {
case 'V':
len = strlen(optarg);
if (len <= 0 || len > 6)
- fatal("volume name too long");
+ fatal(_("volume name too long"));
volume = strdup(optarg);
break;
case 'F':
len = strlen(optarg);
if (len <= 0 || len > 6)
- fatal("fsname name too long");
+ fatal(_("fsname name too long"));
fsname = strdup(optarg);
break;
@@ -165,16 +164,16 @@ main(int argc, char *argv[]) {
if (stat(device, &statbuf) == -1) {
perror(device);
- fatal("cannot stat device %s", device);
+ fatal(_("cannot stat device %s"), device);
}
if (!S_ISBLK(statbuf.st_mode))
- fatal("%s is not a block special device", device);
+ fatal(_("%s is not a block special device"), device);
fd = open(device, O_RDWR);
if (fd == -1) {
perror(device);
- fatal("cannot open %s", device);
+ fatal(_("cannot open %s"), device);
}
if (optind == argc-1)
@@ -185,12 +184,12 @@ main(int argc, char *argv[]) {
if (ioctl(fd, BLKGETSIZE, &total_blocks) == -1) {
if (!user_specified_total_blocks) {
perror("BLKGETSIZE");
- fatal("cannot get size of %s", device);
+ fatal(_("cannot get size of %s"), device);
}
total_blocks = user_specified_total_blocks;
} else if (user_specified_total_blocks) {
if (user_specified_total_blocks > total_blocks)
- fatal("blocks argument too large, max is %d",
+ fatal(_("blocks argument too large, max is %lu"),
total_blocks);
total_blocks = user_specified_total_blocks;
}
@@ -205,7 +204,7 @@ main(int argc, char *argv[]) {
} else {
/* believe the user */
if (inodes > 512)
- fatal("too many inodes - max is 512");
+ fatal(_("too many inodes - max is 512"));
}
ino_bytes = inodes * sizeof(struct bfsi);
@@ -214,7 +213,7 @@ main(int argc, char *argv[]) {
/* mimic the behaviour of SCO's mkfs - maybe this limit is needed */
if (data_blocks < 32)
- fatal("not enough space, need at least %d blocks",
+ fatal(_("not enough space, need at least %lu blocks"),
ino_blocks + 33);
memset(&sb, 0, sizeof(sb));
@@ -226,19 +225,23 @@ main(int argc, char *argv[]) {
memcpy(sb.s_volume, volume, 6);
if (verbose) {
- fprintf(stderr, "Device: %s\n", device);
- fprintf(stderr, "Volume: <%-6s>\n", volume);
- fprintf(stderr, "FSname: <%-6s>\n", fsname);
- fprintf(stderr, "BlockSize: %d\n", BFS_BLOCKSIZE);
- fprintf(stderr, "Inodes: %d (in %ld block%s)\n",
- inodes, ino_blocks, (ino_blocks==1) ? "" : "s");
- fprintf(stderr, "Blocks: %ld\n", total_blocks);
- fprintf(stderr, "Inode end: %d, Data end: %d\n",
+ fprintf(stderr, _("Device: %s\n"), device);
+ fprintf(stderr, _("Volume: <%-6s>\n"), volume);
+ fprintf(stderr, _("FSname: <%-6s>\n"), fsname);
+ fprintf(stderr, _("BlockSize: %d\n"), BFS_BLOCKSIZE);
+ if (ino_blocks==1)
+ fprintf(stderr, _("Inodes: %d (in 1 block)\n"),
+ inodes);
+ else
+ fprintf(stderr, _("Inodes: %d (in %ld blocks)\n"),
+ inodes, ino_blocks);
+ fprintf(stderr, _("Blocks: %ld\n"), total_blocks);
+ fprintf(stderr, _("Inode end: %d, Data end: %d\n"),
sb.s_start-1, sb.s_end);
}
if (write(fd, &sb, sizeof(sb)) != sizeof(sb))
- fatal("error writing superblock");
+ fatal(_("error writing superblock"));
memset(&ri, 0, sizeof(ri));
ri.i_ino = BFS_ROOT_INO;
@@ -258,29 +261,29 @@ main(int argc, char *argv[]) {
ri.i_ctime = now;
if (write(fd, &ri, sizeof(ri)) != sizeof(ri))
- fatal("error writing root inode");
+ fatal(_("error writing root inode"));
memset(&ri, 0, sizeof(ri));
for (i=1; i<inodes; i++)
if (write(fd, &ri, sizeof(ri)) != sizeof(ri))
- fatal("error writing inode");
+ fatal(_("error writing inode"));
if (lseek(fd, (1 + ino_blocks)*BFS_BLOCKSIZE, SEEK_SET) == -1)
- fatal("seek error");
+ fatal(_("seek error"));
memset(&de, 0, sizeof(de));
de.d_ino = BFS_ROOT_INO;
memcpy(de.d_name, ".", 1);
if (write(fd, &de, sizeof(de)) != sizeof(de))
- fatal("error writing . entry");
+ fatal(_("error writing . entry"));
memcpy(de.d_name, "..", 2);
if (write(fd, &de, sizeof(de)) != sizeof(de))
- fatal("error writing .. entry");
+ fatal(_("error writing .. entry"));
if (close(fd) == -1) {
perror(device);
- fatal("error closing %s", device);
+ fatal(_("error closing %s"), device);
}
return 0;
diff --git a/disk-utils/mkfs.minix.8 b/disk-utils/mkfs.minix.8
index 2325805a2..689c26399 100644
--- a/disk-utils/mkfs.minix.8
+++ b/disk-utils/mkfs.minix.8
@@ -46,7 +46,8 @@ are found, the count is printed.
.BI \-n " namelength"
Specify the maximum length of filenames.
Currently, the only allowable values are 14 and 30.
-The default is 30.
+The default is 30. Note that kernels older than 0.99p7
+only accept namelength 14.
.TP
.BI \-i " inodecount"
Specify the number of inodes for the filesystem.
diff --git a/disk-utils/mkfs.minix.c b/disk-utils/mkfs.minix.c
index 4eb9aa4b9..4c2afbb28 100644
--- a/disk-utils/mkfs.minix.c
+++ b/disk-utils/mkfs.minix.c
@@ -32,8 +32,8 @@
* 03.01.94 - Added support for file system valid flag.
* (Dr. Wettstein, greg%wind.uucp@plains.nodak.edu)
*
- * 30.10.94 - added support for v2 filesystem
- * (Andreas Schwab, schwab@issan.informatik.uni-dortmund.de)
+ * 30.10.94 - Added support for v2 filesystem
+ * (Andreas Schwab, schwab@issan.informatik.uni-dortmund.de)
*
* 09.11.94 - Added test to prevent overwrite of mounted fs adapted
* from Theodore Ts'o's (tytso@athena.mit.edu) mke2fs
@@ -538,8 +538,8 @@ do_check(char * buffer, int try, unsigned int current_block) {
/* Seek to the correct loc. */
if (lseek(DEV, current_block * BLOCK_SIZE, SEEK_SET) !=
- current_block * BLOCK_SIZE ) {
- die(_("seek failed during testing of blocks"));
+ current_block * BLOCK_SIZE ) {
+ die(_("seek failed during testing of blocks"));
}
@@ -653,7 +653,7 @@ main(int argc, char ** argv) {
case 'c':
check=1; break;
case 'i':
- req_nr_inodes = (unsigned long) atol(optarg);
+ req_nr_inodes = (unsigned long) atol(optarg);
break;
case 'l':
listfile = optarg; break;
diff --git a/disk-utils/mkswap.c b/disk-utils/mkswap.c
index 960500013..6bd96d904 100644
--- a/disk-utils/mkswap.c
+++ b/disk-utils/mkswap.c
@@ -39,9 +39,14 @@
#include <sys/ioctl.h> /* for _IO */
#include <sys/utsname.h>
#include <sys/stat.h>
+#include "nls.h"
+
+#ifdef HAVE_asm_page_h
#include <asm/page.h> /* for PAGE_SIZE and PAGE_SHIFT */
/* we also get PAGE_SIZE via getpagesize() */
-#include "nls.h"
+/* recent glibc systems also define this in <sys/user.h> */
+#endif
+
#ifndef _IO
/* pre-1.3.45 */
@@ -609,7 +614,9 @@ the -f option to force it.\n"),
* A subsequent swapon() will fail if the signature
* is not actually on disk. (This is a kernel bug.)
*/
+#ifdef HAVE_fsync
if (fsync(DEV))
die(_("fsync failed"));
+#endif
return 0;
}
diff --git a/disk-utils/raw.c b/disk-utils/raw.c
index 54e1008cb..4fc5e2470 100644
--- a/disk-utils/raw.c
+++ b/disk-utils/raw.c
@@ -161,6 +161,7 @@ int main(int argc, char *argv[])
break;
default:
+ block_major = block_minor = 0; /* just to keep gcc happy */
usage(1);
}
diff --git a/disk-utils/setfdprm.c b/disk-utils/setfdprm.c
index 73b3b7174..958f98c16 100644
--- a/disk-utils/setfdprm.c
+++ b/disk-utils/setfdprm.c
@@ -20,28 +20,29 @@
#define MAXLINE 200
-static int convert(char *arg)
-{
+static int
+convert(char *arg) {
long result;
char *end;
result = strtol(arg,&end,0);
- if (!*end) return (int) result;
+ if (!*end)
+ return (int) result;
fprintf(stderr,_("Invalid number: %s\n"),arg);
exit(1);
}
-
-static void cmd_without_param(int cmd,int fd)
-{
- if (ioctl(fd,cmd,NULL) >= 0) exit(0);
+static void
+cmd_without_param(int cmd,int fd) {
+ if (ioctl(fd,cmd,NULL) >= 0)
+ exit(0);
perror("ioctl");
exit(1);
}
-
-static void set_params(int cmd,int fd,char **params)
-{
+/* set given fd parameters */
+static void
+set_params(int cmd,int fd,char **params) {
struct floppy_struct ft;
ft.size = convert(params[0]);
@@ -59,9 +60,9 @@ static void set_params(int cmd,int fd,char **params)
exit(1);
}
-
-static void find_params(int cmd,int fd,char *name)
-{
+/* find parameter set in file, and use it */
+static void
+find_params(int cmd,int fd,char *name) {
FILE *file;
char line[MAXLINE+2],this[MAXLINE+2],param[9][MAXLINE+2];
char *params[9],*start;
@@ -91,9 +92,8 @@ static void find_params(int cmd,int fd,char *name)
exit(1);
}
-
-static void usage(char *name)
-{
+static void
+usage(char *name) {
char *this;
if ((this = strrchr(name,'/')) != NULL) name = this+1;
@@ -109,8 +109,7 @@ gap rate spec1 fmt_gap\n"),name);
}
int
-main(int argc, char **argv)
-{
+main(int argc, char **argv) {
int fd;
unsigned int cmd;
char *progname, *p;
@@ -129,7 +128,8 @@ main(int argc, char **argv)
exit(0);
}
- if (argc < 3) usage(progname);
+ if (argc < 2)
+ usage(progname);
cmd = FDSETPRM;
if (*argv[1] == '-') {
switch (argv[1][1]) {
@@ -156,7 +156,7 @@ main(int argc, char **argv)
argc--;
argv++;
}
- if ((fd = open(argv[1],3)) < 0) { /* 3 == no access at all */
+ if ((fd = open(argv[1],3)) < 0) { /* O_WRONLY needed in a few kernels */
perror(argv[1]);
exit(1);
}