summaryrefslogtreecommitdiffstats
path: root/disk-utils
diff options
context:
space:
mode:
authorKarel Zak2006-12-07 00:25:43 +0100
committerKarel Zak2006-12-07 00:25:43 +0100
commit22853e4a82c6ef7b336527529acb94b14a0b0fd8 (patch)
treeee28e4598c8c449d7e811711d8ce8eb17caecfb6 /disk-utils
parentImported from util-linux-2.10f tarball. (diff)
downloadkernel-qcow2-util-linux-22853e4a82c6ef7b336527529acb94b14a0b0fd8.tar.gz
kernel-qcow2-util-linux-22853e4a82c6ef7b336527529acb94b14a0b0fd8.tar.xz
kernel-qcow2-util-linux-22853e4a82c6ef7b336527529acb94b14a0b0fd8.zip
Imported from util-linux-2.10m tarball.
Diffstat (limited to 'disk-utils')
-rw-r--r--disk-utils/Makefile12
-rw-r--r--disk-utils/blockdev.c17
-rw-r--r--disk-utils/elvtune.873
-rw-r--r--disk-utils/elvtune.c143
-rw-r--r--disk-utils/fdformat.c5
-rw-r--r--disk-utils/fsck.minix.84
-rw-r--r--disk-utils/fsck.minix.c171
-rw-r--r--disk-utils/minix.h60
-rw-r--r--disk-utils/mkfs.bfs.c5
-rw-r--r--disk-utils/mkfs.minix.c108
-rw-r--r--disk-utils/mkswap.813
-rw-r--r--disk-utils/mkswap.c133
-rw-r--r--disk-utils/raw.88
-rw-r--r--disk-utils/raw.c28
14 files changed, 575 insertions, 205 deletions
diff --git a/disk-utils/Makefile b/disk-utils/Makefile
index 36f5e616f..ab9237c88 100644
--- a/disk-utils/Makefile
+++ b/disk-utils/Makefile
@@ -8,23 +8,17 @@ include ../MCONFIG
# Where to put man pages?
-MAN8= fdformat.8 mkfs.8 mkswap.8
+MAN8= fdformat.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
+SBIN= mkfs mkswap blockdev elvtune fsck.minix mkfs.minix mkfs.bfs
USRBIN= fdformat
ETC= fdprm
-ifneq "$(CPU)" "sparc"
-# fsck and mkfs will compile, but there is no kernel support on sparc
-MAN8:=$(MAN8) fsck.minix.8 mkfs.minix.8 mkfs.bfs.8
-SBIN:=$(SBIN) fsck.minix mkfs.minix mkfs.bfs
-endif
-
ifneq "$(HAVE_FDUTILS)" "yes"
USRBIN:=$(USRBIN) setfdprm
MAN8:=$(MAN8) setfdprm.8
@@ -39,7 +33,7 @@ endif
all: $(SBIN) $(USRBIN)
-fsck.minix.o mkfs.minix.o: bitops.h
+fsck.minix.o mkfs.minix.o: bitops.h minix.h
install: all
$(INSTALLDIR) $(SBINDIR) $(USRBINDIR) $(ETCDIR)
diff --git a/disk-utils/blockdev.c b/disk-utils/blockdev.c
index 7f1fd7bb8..af727f7da 100644
--- a/disk-utils/blockdev.c
+++ b/disk-utils/blockdev.c
@@ -11,9 +11,22 @@
#include <unistd.h>
#include <sys/ioctl.h>
-#include <linux/fs.h>
#include "nls.h"
+/* Since it is impossible to include <linux/fs.h>, let us
+ give the ioctls explicitly. */
+
+#ifndef BLKROSET
+#define BLKROSET _IO(0x12,93)
+#define BLKROGET _IO(0x12,94)
+#define BLKRRPART _IO(0x12,95)
+#define BLKGETSIZE _IO(0x12,96)
+#define BLKFLSBUF _IO(0x12,97)
+#define BLKRASET _IO(0x12,98)
+#define BLKRAGET _IO(0x12,99)
+#define BLKSSZGET _IO(0x12,104)
+#endif
+
const char *progname;
struct bdc {
@@ -76,7 +89,7 @@ usage(void) {
exit(1);
}
-int
+static int
find_cmd(char *s) {
int j;
diff --git a/disk-utils/elvtune.8 b/disk-utils/elvtune.8
new file mode 100644
index 000000000..21a0bbc0a
--- /dev/null
+++ b/disk-utils/elvtune.8
@@ -0,0 +1,73 @@
+.\" -*- nroff -*-
+.TH ELVTUNE 8 "14 March 2000" "Version 1.0"
+.SH NAME
+elvtune \- I/O elevator tuner
+.SH SYNOPSIS
+.B elvtune
+[
+.B \-r
+.I r_lat
+]
+[
+.B \-w
+.I w_lat
+]
+[
+.B \-b
+.I b_max
+]
+.B /dev/blkdev1
+[
+.B /dev/blkdev2 ...
+]
+
+.B elvtune
+.B -h
+
+.B elvtune
+.B -v
+.SH DESCRIPTION
+.B elvtune
+allows to tune the I/O elevator per blockdevice queue basis. The
+tuning can be safely done at runtime. Tuning the elevator means
+being able to change disk performance and interactiveness. In the
+output of elvtune the address of the queue tuned will be shown
+and it can be considered as a queue ID.
+For example multiple partitions in the same harddisk will
+share the same queue and so tuning one partition will be
+like tuning the whole HD.
+.SH OPTIONS
+.TP
+.BI -r \ r_lat
+set the max latency that the I/O scheduler will provide on
+each read.
+.TP
+.BI -w \ w_lat
+set the max latency that the I/O scheduler will provide on
+each write.
+.TP
+.BI -b \ b_max
+max coalescing factor allowed on writes when there are reads
+pending in the queue.
+.TP
+.BI -h
+help.
+.TP
+.BI -v
+version.
+.SH NOTE
+Actually the only fields tunable are those relative
+to the IO scheduler. It's not possible to select
+a one-way or two-way elevator yet.
+.PP
+For logical blockdevices like LVM the tuning has to
+be done on the
+.I physical
+devices. Tuning the queue of the LVM logical device
+is useless.
+.SH RETURN VALUE
+0 on success and 1 on failure.
+.SH HISTORY
+Ioctls for tuning elevator behaviour were added in Linux 2.3.99-pre1.
+.SH AUTHORS
+Andrea Arcangeli <andrea@suse.de> SuSE
diff --git a/disk-utils/elvtune.c b/disk-utils/elvtune.c
new file mode 100644
index 000000000..00640fede
--- /dev/null
+++ b/disk-utils/elvtune.c
@@ -0,0 +1,143 @@
+/*
+ * elvtune.c - I/O elevator tuner
+ *
+ * Copyright (C) 2000 Andrea Arcangeli <andrea@suse.de> SuSE
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * This file may be redistributed under the terms of the GNU General
+ * Public License, version 2.
+ */
+
+#include <getopt.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <sys/ioctl.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+#define BLKELVGET _IO(0x12,106)/* elevator get */
+#define BLKELVSET _IO(0x12,107)/* elevator set */
+
+/* this has to match with the kernel structure */
+typedef struct blkelv_ioctl_arg_s {
+ void * queue_ID;
+ int read_latency;
+ int write_latency;
+ int max_bomb_segments;
+} 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, "\telvtune -h\n");
+ fprintf(stderr, "\telvtune -v\n");
+}
+
+static void
+version(void) {
+ fprintf(stderr, "elvtune: version 1.0\n");
+}
+
+int
+main(int argc, char * argv[]) {
+ int read_value = 0xbeefbeef, write_value = 0xbeefbeef, bomb_value = 0xbeefbeef;
+ int read_set, write_set, bomb_set, set;
+ char * devname;
+ int fd;
+ blkelv_ioctl_arg_t elevator;
+
+ read_set = write_set = bomb_set = set = 0;
+
+ for (;;) {
+ int opt;
+
+ opt = getopt(argc, argv, "r:w:b:hv");
+ if (opt < 0)
+ break;
+ switch (opt) {
+ case 'r':
+ read_value = atoi(optarg);
+ read_set = set = 1;
+ break;
+ case 'w':
+ write_value = atoi(optarg);
+ write_set = set = 1;
+ break;
+ case 'b':
+ bomb_value = atoi(optarg);
+ bomb_set = set = 1;
+ break;
+
+ case 'h':
+ usage(), exit(0);
+ case 'v':
+ version(), exit(0);
+
+ case '?':
+ default:
+ case ':':
+ fprintf(stderr, "parse error\n");
+ exit(1);
+ }
+ }
+
+ if (optind >= argc)
+ fprintf(stderr, "missing blockdevice, use -h for help\n"), exit(1);
+
+ while (optind < argc) {
+ devname = argv[optind++];
+
+ fd = open(devname, O_RDONLY|O_NONBLOCK);
+ if (fd < 0) {
+ perror("open");
+ break;
+ }
+
+ if (ioctl(fd, BLKELVGET, &elevator) < 0) {
+ perror("ioctl get");
+ break;
+ }
+
+ if (set) {
+ if (read_set)
+ elevator.read_latency = read_value;
+ if (write_set)
+ elevator.write_latency = write_value;
+ if (bomb_set)
+ elevator.max_bomb_segments = bomb_value;
+
+ if (ioctl(fd, BLKELVSET, &elevator) < 0) {
+ perror("ioctl set");
+ break;
+ }
+ if (ioctl(fd, BLKELVGET, &elevator) < 0) {
+ perror("ioctl reget");
+ break;
+ }
+ }
+
+ printf("\n%s elevator ID %p\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);
+
+ if (close(fd) < 0) {
+ perror("close");
+ break;
+ }
+ }
+
+ return 0;
+}
diff --git a/disk-utils/fdformat.c b/disk-utils/fdformat.c
index 6c3ef5c91..0251e3440 100644
--- a/disk-utils/fdformat.c
+++ b/disk-utils/fdformat.c
@@ -15,9 +15,12 @@
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <linux/fd.h>
-#include <linux/fs.h>
+
#include "nls.h"
+/* cannot include <linux/fs.h> */
+#define MAJOR(a) ((a)>>8)
+
static int ctrl;
struct floppy_struct param;
diff --git a/disk-utils/fsck.minix.8 b/disk-utils/fsck.minix.8
index f0d853751..68979ced0 100644
--- a/disk-utils/fsck.minix.8
+++ b/disk-utils/fsck.minix.8
@@ -36,9 +36,7 @@ will print "FILE SYSTEM HAS CHANGED" and will
three times before exiting. Since Linux does not currently have raw
devices, there is
.I no
-need to reboot at this time (versus a system which
-.I does
-have raw devices).
+need to reboot at this time.
.SH WARNING
.B fsck.minix
should
diff --git a/disk-utils/fsck.minix.c b/disk-utils/fsck.minix.c
index 99a8ca853..1f040eb52 100644
--- a/disk-utils/fsck.minix.c
+++ b/disk-utils/fsck.minix.c
@@ -96,8 +96,7 @@
#include <mntent.h>
#include <sys/stat.h>
-#include <linux/fs.h>
-#include <linux/minix_fs.h>
+#include "minix.h"
#include "nls.h"
#ifdef MINIX2_SUPER_MAGIC2
@@ -169,8 +168,10 @@ static char *zone_map;
static unsigned char * inode_count = NULL;
static unsigned char * zone_count = NULL;
-void recursive_check(unsigned int ino);
-void recursive_check2(unsigned int ino);
+static void recursive_check(unsigned int ino);
+#ifdef HAVE_MINIX2
+static void recursive_check2(unsigned int ino);
+#endif
#include "bitops.h"
@@ -183,22 +184,23 @@ void recursive_check2(unsigned int ino);
#define mark_zone(x) (setbit(zone_map,(x)-FIRSTZONE+1),changed=1)
#define unmark_zone(x) (clrbit(zone_map,(x)-FIRSTZONE+1),changed=1)
-void leave(int) __attribute__ ((noreturn));
-void leave(int status)
-{
+static void
+leave(int status) {
if (termios_set)
tcsetattr(0, TCSANOW, &termios);
exit(status);
}
-void usage(void) {
+static void
+usage(void) {
fprintf(stderr,
_("Usage: %s [-larvsmf] /dev/name\n"),
program_name);
leave(16);
}
-void die(const char *str) {
+static void
+die(const char *str) {
fprintf(stderr, "%s: %s\n", program_name, str);
leave(8);
}
@@ -207,8 +209,8 @@ void die(const char *str) {
* This simply goes through the file-name data and prints out the
* current file.
*/
-void print_current_name(void)
-{
+static void
+print_current_name(void) {
int i=0;
while (i<name_depth)
@@ -217,8 +219,8 @@ void print_current_name(void)
printf ("/");
}
-int ask(const char * string, int def)
-{
+static int
+ask(const char * string, int def) {
int c;
if (!repair) {
@@ -264,8 +266,8 @@ int ask(const char * string, int def)
* mounted partition. Code adapted from e2fsck, Copyright (C) 1993,
* 1994 Theodore Ts'o. Also licensed under GPL.
*/
-static void check_mount(void)
-{
+static void
+check_mount(void) {
FILE * f;
struct mntent * mnt;
int cont;
@@ -309,8 +311,8 @@ static void check_mount(void)
* if an error was corrected, and returns the zone (0 for no zone
* or a bad zone-number).
*/
-int check_zone_nr(unsigned short * nr, int * corrected)
-{
+static int
+check_zone_nr(unsigned short * nr, int * corrected) {
if (!*nr)
return 0;
if (*nr < FIRSTZONE)
@@ -329,8 +331,8 @@ int check_zone_nr(unsigned short * nr, int * corrected)
}
#ifdef HAVE_MINIX2
-int check_zone_nr2 (unsigned int *nr, int *corrected)
-{
+static int
+check_zone_nr2 (unsigned int *nr, int *corrected) {
if (!*nr)
return 0;
if (*nr < FIRSTZONE)
@@ -352,8 +354,8 @@ int check_zone_nr2 (unsigned int *nr, int *corrected)
/*
* read-block reads block nr into the buffer at addr.
*/
-void read_block(unsigned int nr, char * addr)
-{
+static void
+read_block(unsigned int nr, char * addr) {
if (!nr) {
memset(addr,0,BLOCK_SIZE);
return;
@@ -376,8 +378,8 @@ void read_block(unsigned int nr, char * addr)
/*
* write_block writes block nr to disk.
*/
-void write_block(unsigned int nr, char * addr)
-{
+static void
+write_block(unsigned int nr, char * addr) {
if (!nr)
return;
if (nr < FIRSTZONE || nr >= ZONES) {
@@ -401,8 +403,8 @@ void write_block(unsigned int nr, char * addr)
* It sets 'changed' if the inode has needed changing, and re-writes
* any indirect blocks with errors.
*/
-int map_block(struct minix_inode * inode, unsigned int blknr)
-{
+static int
+map_block(struct minix_inode * inode, unsigned int blknr) {
unsigned short ind[BLOCK_SIZE>>1];
unsigned short dind[BLOCK_SIZE>>1];
int blk_chg, block, result;
@@ -436,8 +438,8 @@ int map_block(struct minix_inode * inode, unsigned int blknr)
}
#ifdef HAVE_MINIX2
-int map_block2 (struct minix2_inode *inode, unsigned int blknr)
-{
+static int
+map_block2 (struct minix2_inode *inode, unsigned int blknr) {
unsigned int ind[BLOCK_SIZE >> 2];
unsigned int dind[BLOCK_SIZE >> 2];
unsigned int tind[BLOCK_SIZE >> 2];
@@ -494,8 +496,8 @@ int map_block2 (struct minix2_inode *inode, unsigned int blknr)
}
#endif
-void write_super_block(void)
-{
+static void
+write_super_block(void) {
/*
* Set the state of the filesystem based on whether or not there
* are uncorrected errors. The filesystem valid flag is
@@ -515,8 +517,8 @@ void write_super_block(void)
return;
}
-void write_tables(void)
-{
+static void
+write_tables(void) {
write_super_block();
if (IMAPS*BLOCK_SIZE != write(IN,inode_map,IMAPS*BLOCK_SIZE))
@@ -527,8 +529,8 @@ void write_tables(void)
die(_("Unable to write inodes"));
}
-void get_dirsize (void)
-{
+static void
+get_dirsize (void) {
int block;
char blk[BLOCK_SIZE];
int size;
@@ -550,8 +552,8 @@ void get_dirsize (void)
/* use defaults */
}
-void read_superblock(void)
-{
+static void
+read_superblock(void) {
if (BLOCK_SIZE != lseek(IN, BLOCK_SIZE, SEEK_SET))
die(_("seek failed"));
if (BLOCK_SIZE != read(IN, super_block_buffer, BLOCK_SIZE))
@@ -584,8 +586,8 @@ void read_superblock(void)
die(_("bad s_zmap_blocks field in super-block"));
}
-void read_tables(void)
-{
+static void
+read_tables(void) {
inode_map = malloc(IMAPS * BLOCK_SIZE);
if (!inode_map)
die(_("Unable to allocate buffer for inode map"));
@@ -625,8 +627,8 @@ void read_tables(void)
}
}
-struct minix_inode * get_inode(unsigned int nr)
-{
+static struct minix_inode *
+get_inode(unsigned int nr) {
struct minix_inode * inode;
if (!nr || nr > INODES)
@@ -676,9 +678,8 @@ struct minix_inode * get_inode(unsigned int nr)
}
#ifdef HAVE_MINIX2
-struct minix2_inode *
-get_inode2 (unsigned int nr)
-{
+static struct minix2_inode *
+get_inode2 (unsigned int nr) {
struct minix2_inode *inode;
if (!nr || nr > INODES)
@@ -724,8 +725,8 @@ get_inode2 (unsigned int nr)
}
#endif
-void check_root(void)
-{
+static void
+check_root(void) {
struct minix_inode * inode = Inode + ROOT_INO;
if (!inode || !S_ISDIR(inode->i_mode))
@@ -733,8 +734,8 @@ void check_root(void)
}
#ifdef HAVE_MINIX2
-void check_root2 (void)
-{
+static void
+check_root2 (void) {
struct minix2_inode *inode = Inode2 + ROOT_INO;
if (!inode || !S_ISDIR (inode->i_mode))
@@ -742,8 +743,8 @@ void check_root2 (void)
}
#endif
-static int add_zone(unsigned short * znr, int * corrected)
-{
+static int
+add_zone(unsigned short * znr, int * corrected) {
int result;
int block;
@@ -776,8 +777,8 @@ static int add_zone(unsigned short * znr, int * corrected)
}
#ifdef HAVE_MINIX2
-static int add_zone2 (unsigned int *znr, int *corrected)
-{
+static int
+add_zone2 (unsigned int *znr, int *corrected) {
int result;
int block;
@@ -810,8 +811,8 @@ static int add_zone2 (unsigned int *znr, int *corrected)
}
#endif
-static void add_zone_ind(unsigned short * znr, int * corrected)
-{
+static void
+add_zone_ind(unsigned short * znr, int * corrected) {
static char blk[BLOCK_SIZE];
int i, chg_blk=0;
int block;
@@ -828,8 +829,7 @@ static void add_zone_ind(unsigned short * znr, int * corrected)
#ifdef HAVE_MINIX2
static void
-add_zone_ind2 (unsigned int *znr, int *corrected)
-{
+add_zone_ind2 (unsigned int *znr, int *corrected) {
static char blk[BLOCK_SIZE];
int i, chg_blk = 0;
int block;
@@ -845,8 +845,8 @@ add_zone_ind2 (unsigned int *znr, int *corrected)
}
#endif
-static void add_zone_dind(unsigned short * znr, int * corrected)
-{
+static void
+add_zone_dind(unsigned short * znr, int * corrected) {
static char blk[BLOCK_SIZE];
int i, blk_chg=0;
int block;
@@ -863,8 +863,7 @@ static void add_zone_dind(unsigned short * znr, int * corrected)
#ifdef HAVE_MINIX2
static void
-add_zone_dind2 (unsigned int *znr, int *corrected)
-{
+add_zone_dind2 (unsigned int *znr, int *corrected) {
static char blk[BLOCK_SIZE];
int i, blk_chg = 0;
int block;
@@ -880,8 +879,7 @@ add_zone_dind2 (unsigned int *znr, int *corrected)
}
static void
-add_zone_tind2 (unsigned int *znr, int *corrected)
-{
+add_zone_tind2 (unsigned int *znr, int *corrected) {
static char blk[BLOCK_SIZE];
int i, blk_chg = 0;
int block;
@@ -897,8 +895,8 @@ add_zone_tind2 (unsigned int *znr, int *corrected)
}
#endif
-void check_zones(unsigned int i)
-{
+static void
+check_zones(unsigned int i) {
struct minix_inode * inode;
if (!i || i > INODES)
@@ -916,9 +914,8 @@ void check_zones(unsigned int i)
}
#ifdef HAVE_MINIX2
-void
-check_zones2 (unsigned int i)
-{
+static void
+check_zones2 (unsigned int i) {
struct minix2_inode *inode;
if (!i || i > INODES)
@@ -937,8 +934,8 @@ check_zones2 (unsigned int i)
}
#endif
-void check_file(struct minix_inode * dir, unsigned int offset)
-{
+static void
+check_file(struct minix_inode * dir, unsigned int offset) {
static char blk[BLOCK_SIZE];
struct minix_inode * inode;
int ino;
@@ -1000,9 +997,8 @@ void check_file(struct minix_inode * dir, unsigned int offset)
}
#ifdef HAVE_MINIX2
-void
-check_file2 (struct minix2_inode *dir, unsigned int offset)
-{
+static void
+check_file2 (struct minix2_inode *dir, unsigned int offset) {
static char blk[BLOCK_SIZE];
struct minix2_inode *inode;
int ino;
@@ -1064,8 +1060,8 @@ check_file2 (struct minix2_inode *dir, unsigned int offset)
}
#endif
-void recursive_check(unsigned int ino)
-{
+static void
+recursive_check(unsigned int ino) {
struct minix_inode * dir;
unsigned int offset;
@@ -1082,9 +1078,8 @@ void recursive_check(unsigned int ino)
}
#ifdef HAVE_MINIX2
-void
-recursive_check2 (unsigned int ino)
-{
+static void
+recursive_check2 (unsigned int ino) {
struct minix2_inode *dir;
unsigned int offset;
@@ -1101,8 +1096,8 @@ recursive_check2 (unsigned int ino)
}
#endif
-int bad_zone(int i)
-{
+static int
+bad_zone(int i) {
char buffer[1024];
if (BLOCK_SIZE*i != lseek(IN, BLOCK_SIZE*i, SEEK_SET))
@@ -1110,8 +1105,8 @@ int bad_zone(int i)
return (BLOCK_SIZE != read(IN, buffer, BLOCK_SIZE));
}
-void check_counts(void)
-{
+static void
+check_counts(void) {
int i;
for (i=1 ; i <= INODES ; i++) {
@@ -1162,9 +1157,8 @@ void check_counts(void)
}
#ifdef HAVE_MINIX2
-void
-check_counts2 (void)
-{
+static void
+check_counts2 (void) {
int i;
for (i = 1; i <= INODES; i++) {
@@ -1214,8 +1208,8 @@ check_counts2 (void)
}
#endif
-void check(void)
-{
+static void
+check(void) {
memset(inode_count,0,(INODES + 1) * sizeof(*inode_count));
memset(zone_count,0,ZONES*sizeof(*zone_count));
check_zones(ROOT_INO);
@@ -1224,9 +1218,8 @@ void check(void)
}
#ifdef HAVE_MINIX2
-void
-check2 (void)
-{
+static void
+check2 (void) {
memset (inode_count, 0, (INODES + 1) * sizeof (*inode_count));
memset (zone_count, 0, ZONES * sizeof (*zone_count));
check_zones2 (ROOT_INO);
@@ -1235,8 +1228,8 @@ check2 (void)
}
#endif
-int main(int argc, char ** argv)
-{
+int
+main(int argc, char ** argv) {
struct termios tmp;
int count;
int retcode = 0;
diff --git a/disk-utils/minix.h b/disk-utils/minix.h
new file mode 100644
index 000000000..46f2af3c5
--- /dev/null
+++ b/disk-utils/minix.h
@@ -0,0 +1,60 @@
+#ifdef KERNEL_INCLUDES_ARE_CLEAN
+
+#include <linux/fs.h>
+#include <linux/minix_fs.h>
+
+#else
+
+typedef unsigned char u8;
+typedef unsigned short u16;
+typedef unsigned int u32;
+
+struct minix_inode {
+ u16 i_mode;
+ u16 i_uid;
+ u32 i_size;
+ u32 i_time;
+ u8 i_gid;
+ u8 i_nlinks;
+ u16 i_zone[9];
+};
+
+struct minix2_inode {
+ u16 i_mode;
+ u16 i_nlinks;
+ u16 i_uid;
+ u16 i_gid;
+ u32 i_size;
+ u32 i_atime;
+ u32 i_mtime;
+ u32 i_ctime;
+ u32 i_zone[10];
+};
+
+struct minix_super_block {
+ u16 s_ninodes;
+ u16 s_nzones;
+ u16 s_imap_blocks;
+ u16 s_zmap_blocks;
+ u16 s_firstdatazone;
+ u16 s_log_zone_size;
+ u32 s_max_size;
+ u16 s_magic;
+ u16 s_state;
+ u32 s_zones;
+};
+
+#define BLOCK_SIZE_BITS 10
+#define BLOCK_SIZE (1<<BLOCK_SIZE_BITS)
+
+#define NAME_MAX 255 /* # chars in a file name */
+
+#define MINIX_INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct minix_inode)))
+
+#define MINIX_VALID_FS 0x0001 /* Clean fs. */
+#define MINIX_ERROR_FS 0x0002 /* fs has errors. */
+
+#define MINIX_SUPER_MAGIC 0x137F /* original minix fs */
+#define MINIX_SUPER_MAGIC2 0x138F /* minix fs, 30 char names */
+
+#endif /* KERNEL_INCLUDES_ARE_CLEAN */
diff --git a/disk-utils/mkfs.bfs.c b/disk-utils/mkfs.bfs.c
index 93cf1e60a..a8f557837 100644
--- a/disk-utils/mkfs.bfs.c
+++ b/disk-utils/mkfs.bfs.c
@@ -16,7 +16,10 @@
#include <string.h>
#include <time.h>
-#include <linux/fs.h> /* for BLKGETSIZE */
+/* cannot include <linux/fs.h> */
+#ifndef BLKGETSIZE
+#define BLKGETSIZE _IO(0x12,96) /* return device size */
+#endif
#include "../defines.h" /* for util_linux_version */
diff --git a/disk-utils/mkfs.minix.c b/disk-utils/mkfs.minix.c
index 4887f05d1..4eb9aa4b9 100644
--- a/disk-utils/mkfs.minix.c
+++ b/disk-utils/mkfs.minix.c
@@ -72,11 +72,13 @@
#include <mntent.h>
#include <getopt.h>
-#include <linux/fs.h>
-#include <linux/minix_fs.h>
-
+#include "minix.h"
#include "nls.h"
+#ifndef BLKGETSIZE
+#define BLKGETSIZE _IO(0x12,96) /* return device size */
+#endif
+
#ifdef MINIX2_SUPER_MAGIC2
#define HAVE_MINIX2 1
#endif
@@ -85,10 +87,6 @@
#error "needs gcc for the bitop-__asm__'s"
#endif
-#ifndef __linux__
-#define volatile
-#endif
-
#define MINIX_ROOT_INO 1
#define MINIX_BAD_INO 2
@@ -162,24 +160,20 @@ static unsigned long req_nr_inodes = 0;
#define mark_zone(x) (setbit(zone_map,(x)-FIRSTZONE+1))
#define unmark_zone(x) (clrbit(zone_map,(x)-FIRSTZONE+1))
-/*
- * Volatile to let gcc know that this doesn't return. When trying
- * to compile this under minix, volatile gives a warning, as
- * exit() isn't defined as volatile under minix.
- */
-volatile void fatal_error(const char * fmt_string,int status)
-{
+static void
+fatal_error(const char * fmt_string,int status) {
fprintf(stderr,fmt_string,program_name,device_name);
exit(status);
}
-volatile void die(char *str) {
+static void
+die(char *str) {
fprintf(stderr, "%s: %s\n", program_name, str);
exit(8);
}
-volatile void usage()
-{
+static void
+usage(void) {
fprintf(stderr, "%s (%s)\n", program_name, util_linux_version);
fprintf(stderr,
_("Usage: %s [-c | -l filename] [-nXX] [-iXX] /dev/name [blocks]\n"),
@@ -192,8 +186,8 @@ volatile void usage()
* an already mounted partition. Code adapted from mke2fs, Copyright
* (C) 1994 Theodore Ts'o. Also licensed under GPL.
*/
-static void check_mount(void)
-{
+static void
+check_mount(void) {
FILE * f;
struct mntent * mnt;
@@ -209,8 +203,8 @@ static void check_mount(void)
die(_("%s is mounted; will not make a filesystem here!"));
}
-static long valid_offset (int fd, int offset)
-{
+static long
+valid_offset (int fd, int offset) {
char ch;
if (lseek (fd, offset, 0) < 0)
@@ -220,8 +214,8 @@ static long valid_offset (int fd, int offset)
return 1;
}
-static int count_blocks (int fd)
-{
+static int
+count_blocks (int fd) {
int high, low;
low = 0;
@@ -240,8 +234,8 @@ static int count_blocks (int fd)
return (low + 1);
}
-static int get_size(const char *file)
-{
+static int
+get_size(const char *file) {
int fd;
long size;
@@ -260,8 +254,8 @@ static int get_size(const char *file)
return size;
}
-void write_tables(void)
-{
+static void
+write_tables(void) {
/* Mark the super block valid. */
Super.s_state |= MINIX_VALID_FS;
Super.s_state &= ~MINIX_ERROR_FS;
@@ -283,16 +277,16 @@ void write_tables(void)
}
-void write_block(int blk, char * buffer)
-{
+static void
+write_block(int blk, char * buffer) {
if (blk*BLOCK_SIZE != lseek(DEV, blk*BLOCK_SIZE, SEEK_SET))
die(_("seek failed in write_block"));
if (BLOCK_SIZE != write(DEV, buffer, BLOCK_SIZE))
die(_("write failed in write_block"));
}
-int get_free_block(void)
-{
+static int
+get_free_block(void) {
int blk;
if (used_good_blocks+1 >= MAX_GOOD_BLOCKS)
@@ -310,16 +304,16 @@ int get_free_block(void)
return blk;
}
-void mark_good_blocks(void)
-{
+static void
+mark_good_blocks(void) {
int blk;
for (blk=0 ; blk < used_good_blocks ; blk++)
mark_zone(good_blocks_table[blk]);
}
-inline int next(int zone)
-{
+static inline int
+next(int zone) {
if (!zone)
zone = FIRSTZONE-1;
while (++zone < ZONES)
@@ -328,8 +322,8 @@ inline int next(int zone)
return 0;
}
-void make_bad_inode(void)
-{
+static void
+make_bad_inode(void) {
struct minix_inode * inode = &Inode[MINIX_BAD_INO];
int i,j,zone;
int ind=0,dind=0;
@@ -379,9 +373,8 @@ end_bad:
}
#ifdef HAVE_MINIX2
-void
-make_bad_inode2 (void)
-{
+static void
+make_bad_inode2 (void) {
struct minix2_inode *inode = &Inode2[MINIX_BAD_INO];
int i, j, zone;
int ind = 0, dind = 0;
@@ -430,8 +423,8 @@ make_bad_inode2 (void)
}
#endif
-void make_root_inode(void)
-{
+static void
+make_root_inode(void) {
struct minix_inode * inode = &Inode[MINIX_ROOT_INO];
mark_inode(MINIX_ROOT_INO);
@@ -453,9 +446,8 @@ void make_root_inode(void)
}
#ifdef HAVE_MINIX2
-void
-make_root_inode2 (void)
-{
+static void
+make_root_inode2 (void) {
struct minix2_inode *inode = &Inode2[MINIX_ROOT_INO];
mark_inode (MINIX_ROOT_INO);
@@ -477,8 +469,8 @@ make_root_inode2 (void)
}
#endif
-void setup_tables(void)
-{
+static void
+setup_tables(void) {
int i;
unsigned long inodes;
@@ -540,8 +532,8 @@ void setup_tables(void)
* Perform a test of a block; return the number of
* blocks readable/writeable.
*/
-long do_check(char * buffer, int try, unsigned int current_block)
-{
+static long
+do_check(char * buffer, int try, unsigned int current_block) {
long got;
/* Seek to the correct loc. */
@@ -563,8 +555,8 @@ long do_check(char * buffer, int try, unsigned int current_block)
static unsigned int currently_testing = 0;
-void alarm_intr(int alnum)
-{
+static void
+alarm_intr(int alnum) {
if (currently_testing >= ZONES)
return;
signal(SIGALRM,alarm_intr);
@@ -575,8 +567,8 @@ void alarm_intr(int alnum)
fflush(stdout);
}
-void check_blocks(void)
-{
+static void
+check_blocks(void) {
int try,got;
static char buffer[BLOCK_SIZE * TEST_BUFFER_BLOCKS];
@@ -606,10 +598,8 @@ void check_blocks(void)
printf(_("one bad block\n"));
}
-void get_list_blocks(filename)
-char *filename;
-
-{
+static void
+get_list_blocks(char *filename) {
FILE *listfile;
unsigned long blockno;
@@ -628,8 +618,8 @@ char *filename;
printf(_("one bad block\n"));
}
-int main(int argc, char ** argv)
-{
+int
+main(int argc, char ** argv) {
int i;
char * tmp;
struct stat statbuf;
diff --git a/disk-utils/mkswap.8 b/disk-utils/mkswap.8
index 368ef3b5c..4ee3627ab 100644
--- a/disk-utils/mkswap.8
+++ b/disk-utils/mkswap.8
@@ -97,7 +97,7 @@ able to look it up with "cat /proc/cpuinfo" (or you may not -
the contents of this file depend on architecture and kernel version).
To setup a swap file, it is necessary to create that file before
-running
+initializing it with
.B mkswap ,
e.g. using a command like
@@ -140,13 +140,12 @@ Create a new style swap area.
.LP
If no \-v option is given,
.B mkswap
-will default to old style if the size of the swap area does not
-exceed the maximum size of an old style swap area, and also if
-the current kernel is older than 2.1.117 (and also if PAGE_SIZE
-is less than 2048).
+will default to new style, but use old style if the current kernel
+is older than 2.1.117 (and also if PAGE_SIZE is less than 2048).
The new style header does not touch the first block, so may be
-preferable (also if the swap area is small), in case you have
-a boot loader or disk label there.
+preferable, in case you have a boot loader or disk label there.
+If you need to use both 2.0 and 2.2 kernels, use the \-v0 option
+when creating the swapspace.
.SH "SEE ALSO"
.BR fdisk (8),
diff --git a/disk-utils/mkswap.c b/disk-utils/mkswap.c
index 2803587b7..960500013 100644
--- a/disk-utils/mkswap.c
+++ b/disk-utils/mkswap.c
@@ -24,6 +24,7 @@
*
* Sparc fixes, jj@ultra.linux.cz (Jakub Jelinek), 981201 - mangled by aeb.
* V1_MAX_PAGES fixes, jj, 990325.
+ * sparc64 fixes, jj, 000219.
*
* 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@misiek.eu.org>
* - added Native Language Support
@@ -74,6 +75,57 @@ linux_version_code(void) {
return 0;
}
+#ifdef __sparc__
+# ifdef __arch64__
+# define is_sparc64() 1
+# define is_be64() 1
+# else /* sparc32 */
+static int
+is_sparc64(void) {
+ struct utsname un;
+ static int sparc64 = -1;
+
+ if (sparc64 != -1) return sparc64;
+ sparc64 = 0;
+
+ if (uname(&un) < 0) return 0;
+ if (! strcmp(un.machine, "sparc64")) {
+ sparc64 = 1;
+ return 1;
+ }
+ if (strcmp(un.machine, "sparc"))
+ return 0; /* Should not happen */
+
+#ifdef HAVE_personality
+ {
+ extern int personality(unsigned long);
+ int oldpers;
+#define PERS_LINUX 0x00000000
+#define PERS_LINUX_32BIT 0x00800000
+#define PERS_LINUX32 0x00000008
+
+ oldpers = personality(PERS_LINUX_32BIT);
+ if (oldpers != -1) {
+ if (personality(PERS_LINUX) != -1) {
+ uname(&un);
+ if (! strcmp(un.machine, "sparc64")) {
+ sparc64 = 1;
+ oldpers = PERS_LINUX32;
+ }
+ }
+ personality(oldpers);
+ }
+ }
+#endif
+
+ return sparc64;
+}
+# define is_be64() is_sparc64()
+# endif /* sparc32 */
+#else /* !sparc */
+# define is_be64() 0
+#endif
+
/*
* The definition of the union swap_header uses the constant PAGE_SIZE.
* Unfortunately, on some architectures this depends on the hardware model,
@@ -92,7 +144,7 @@ static int user_pagesize = 0;
static int kernel_pagesize; /* obtained via getpagesize(); */
static int defined_pagesize = 0; /* PAGE_SIZE, when that exists */
static int pagesize;
-static int *signature_page;
+static long *signature_page;
struct swap_header_v1 {
char bootbits[1024]; /* Space for disklabel etc. */
@@ -104,7 +156,7 @@ struct swap_header_v1 {
} *p;
static void
-init_signature_page() {
+init_signature_page(void) {
#ifdef PAGE_SIZE
defined_pagesize = PAGE_SIZE;
#endif
@@ -130,7 +182,7 @@ init_signature_page() {
fprintf(stderr, _("Assuming pages of size %d (not %d)\n"),
pagesize, defined_pagesize);
- signature_page = (int *) malloc(pagesize);
+ signature_page = (long *) malloc(pagesize);
memset(signature_page,0,pagesize);
p = (struct swap_header_v1 *) signature_page;
}
@@ -169,14 +221,14 @@ write_signature(char *sig) {
refuse a swap space if it is too large.
*/
/* patch from jj - why does this differ from the above? */
+/* 32bit kernels have a second limitation of 2GB, sparc64 is limited by
+ the size of virtual address space allocation for vmalloc */
#if defined(__alpha__)
#define V1_MAX_PAGES ((1 << 24) - 1)
#elif defined(__mips__)
#define V1_MAX_PAGES ((1 << 17) - 1)
-#elif defined(__sparc_v9__)
-#define V1_MAX_PAGES ((3 << 29) - 1)
#elif defined(__sparc__)
-#define V1_MAX_PAGES (pagesize == 8192 ? ((3 << 29) - 1) : ((1 << 18) - 1))
+#define V1_MAX_PAGES (is_sparc64() ? ((3 << 29) - 1) : ((1 << 18) - 1))
#else
#define V1_MAX_PAGES V1_OLD_MAX_PAGES
#endif
@@ -188,28 +240,68 @@ It is roughly 2GB on i386, PPC, m68k, ARM, 1GB on sparc, 512MB on mips,
#define MAX_BADPAGES ((pagesize-1024-128*sizeof(int)-10)/sizeof(int))
+/*
+ * One more point of lossage - Linux swapspace really is a mess.
+ * The definition of the bitmap used is architecture dependent,
+ * and requires one to know whether the machine is bigendian,
+ * and if so, whether it will use 32-bit or 64-bit units in
+ * test_bit().
+ * davem writes: "... is based upon an unsigned long type of
+ * the cpu and the native endianness".
+ * So, it seems we can write `unsigned long' below.
+ * However, sparc64 uses 64-bit units in the kernel, while
+ * mkswap may have been translated with 32-bit longs. Thus,
+ * we need an explicit test for version 0 swap on sparc64.
+ */
+
static void
-bit_set (unsigned int *addr, unsigned int nr) {
+bit_set (unsigned long *addr, unsigned int nr) {
unsigned int r, m;
- addr += nr / (8 * sizeof(int));
+ if(is_be64()) {
+ unsigned long long *bitmap = (unsigned long long *) addr;
+ unsigned long long bitnum = (unsigned long long) nr;
+ unsigned long long rl, ml;
+
+ bitmap += bitnum / (8 * sizeof(long long));
+ rl = *bitmap;
+ ml = 1ULL << (bitnum &
+ (8ULL * (unsigned long long)sizeof(long long) - 1ULL));
+ *bitmap = rl | ml;
+ return;
+ }
+
+ addr += nr / (8 * sizeof(unsigned long));
r = *addr;
- m = 1 << (nr & (8 * sizeof(int) - 1));
+ m = 1 << (nr & (8 * sizeof(unsigned long) - 1));
*addr = r | m;
}
static int
-bit_test_and_clear (unsigned int *addr, unsigned int nr) {
+bit_test_and_clear (unsigned long *addr, unsigned int nr) {
unsigned int r, m;
- addr += nr / (8 * sizeof(int));
+ if(is_be64()) {
+ unsigned long long *bitmap = (unsigned long long *) addr;
+ unsigned long long bitnum = (unsigned long long) nr;
+ unsigned long long rl, ml;
+
+ bitmap += bitnum / (8 * sizeof(long long));
+ rl = *bitmap;
+ ml = 1ULL << (bitnum &
+ (8ULL * (unsigned long long)sizeof(long long) - 1ULL));
+ *bitmap = rl & ~ml;
+ return ((rl & ml) != 0ULL);
+ }
+
+ addr += nr / (8 * sizeof(unsigned long));
r = *addr;
- m = 1 << (nr & (8 * sizeof(int) - 1));
+ m = 1 << (nr & (8 * sizeof(unsigned long) - 1));
*addr = r & ~m;
return (r & m) != 0;
}
-void
+static void
usage(void) {
fprintf(stderr,
_("Usage: %s [-c] [-v0|-v1] [-pPAGESZ] /dev/name [blocks]\n"),
@@ -217,19 +309,19 @@ usage(void) {
exit(1);
}
-void
+static void
die(const char *str) {
fprintf(stderr, "%s: %s\n", program_name, str);
exit(1);
}
-void
+static void
page_ok(int page) {
if (version==0)
bit_set(signature_page, page);
}
-void
+static void
page_bad(int page) {
if (version == 0)
bit_test_and_clear(signature_page, page);
@@ -241,7 +333,7 @@ page_bad(int page) {
badpages++;
}
-void
+static void
check_blocks(void) {
unsigned int current_page;
int do_seek = 1;
@@ -322,7 +414,7 @@ get_size(const char *file) {
return size;
}
-int
+static int
isnzdigit(char c) {
return (c >= '1' && c <= '9');
}
@@ -371,7 +463,7 @@ main(int argc, char ** argv) {
usage();
break;
case 'v':
- version = atoi(argv[0]+2);
+ version = atoi(argv[i]+2);
break;
default:
usage();
@@ -414,7 +506,8 @@ main(int argc, char ** argv) {
}
if (version == -1) {
- if (PAGES <= V0_MAX_PAGES)
+ /* use version 1 as default, if possible */
+ if (PAGES <= V0_MAX_PAGES && PAGES > V1_MAX_PAGES)
version = 0;
else if (linux_version_code() < MAKE_VERSION(2,1,117))
version = 0;
diff --git a/disk-utils/raw.8 b/disk-utils/raw.8
index cb8021668..4fd91facf 100644
--- a/disk-utils/raw.8
+++ b/disk-utils/raw.8
@@ -4,14 +4,14 @@
raw \- bind a Linux raw character device
.SH SYNOPSIS
.B raw
-.I /dev/raw<N> <major> <minor>
+.I /dev/raw/raw<N> <major> <minor>
.PP
.B raw
-.I /dev/raw<N> /dev/<blockdev>
+.I /dev/raw/raw<N> /dev/<blockdev>
.PP
.B raw
.B \-q
-.I /dev/raw<N>
+.I /dev/raw/raw<N>
.PP
.B raw
.B \-qa
@@ -25,7 +25,7 @@ module later).
.B raw
is used in two modes: it either sets raw device bindings, or it queries
existing bindings. When setting a raw device,
-.I /dev/raw<N>
+.I /dev/raw/raw<N>
is the device name of an existing raw device node in the filesystem.
The block device to which it is to be bound can be specified either in
terms of its
diff --git a/disk-utils/raw.c b/disk-utils/raw.c
index 5fb95348a..54e1008cb 100644
--- a/disk-utils/raw.c
+++ b/disk-utils/raw.c
@@ -1,12 +1,12 @@
/*
* raw.c: User mode tool to bind and query raw character devices.
*
- * Stephen Tweedie, 1999
+ * Stephen Tweedie, 1999, 2000
*
* This file may be redistributed under the terms of the GNU General
* Public License, version 2.
*
- * Copyright Red Hat Software, 1999
+ * Copyright Red Hat Software, 1999, 2000
*
*/
@@ -19,8 +19,16 @@
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/sysmacros.h>
-#include <sys/raw.h>
+#include <linux/raw.h>
+#include <linux/major.h>
+#ifdef OLD_RAW_DEVS
+#define RAWCTLDEV "/dev/raw"
+#define RAWDEVDIR "/dev/"
+#else
+#define RAWCTLDEV "/dev/rawctl"
+#define RAWDEVDIR "/dev/raw/"
+#endif
char * progname;
@@ -39,9 +47,9 @@ static void usage(int err)
{
fprintf(stderr,
"Usage:\n"
- " %s /dev/rawN <major> <minor>\n"
- " %s /dev/rawN /dev/<blockdev>\n"
- " %s -q /dev/rawN\n"
+ " %s " RAWDEVDIR "rawN <major> <minor>\n"
+ " %s " RAWDEVDIR "rawN /dev/<blockdev>\n"
+ " %s -q " RAWDEVDIR "rawN\n"
" %s -qa\n",
progname, progname, progname, progname);
exit(err);
@@ -164,10 +172,10 @@ int main(int argc, char *argv[])
void open_raw_ctl(void)
{
- master_fd = open("/dev/raw", O_RDWR, 0);
+ master_fd = open(RAWCTLDEV, O_RDWR, 0);
if (master_fd < 0) {
fprintf (stderr,
- "Cannot open master raw device '/dev/raw' (%s)\n",
+ "Cannot open master raw device '" RAWCTLDEV "' (%s)\n",
strerror(errno));
exit(2);
}
@@ -190,7 +198,7 @@ int query(int minor, int quiet)
}
if (quiet && !rq.block_major && !rq.block_minor)
return 0;
- printf ("/dev/raw%d: bound to major %d, minor %d\n",
+ printf (RAWDEVDIR "raw%d: bound to major %d, minor %d\n",
minor, (int) rq.block_major, (int) rq.block_minor);
return 0;
}
@@ -210,7 +218,7 @@ int bind(int minor, int block_major, int block_minor)
strerror(errno));
exit(3);
}
- printf ("/dev/raw%d: bound to major %d, minor %d\n",
+ printf (RAWDEVDIR "raw%d: bound to major %d, minor %d\n",
raw_minor, (int) rq.block_major, (int) rq.block_minor);
return 0;
}