Remove spaces/tabs from ends of lines.

This commit is contained in:
Neil Brown 2007-12-14 20:13:43 +11:00
parent 08e43379e5
commit aba69144fd
23 changed files with 118 additions and 123 deletions

View File

@ -230,7 +230,7 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
free(super); free(super);
super = NULL; super = NULL;
} }
dfd = dev_open(devname, O_RDONLY|O_EXCL); dfd = dev_open(devname, O_RDONLY|O_EXCL);
if (dfd < 0) { if (dfd < 0) {
if ((inargv && verbose >= 0) || verbose > 0) if ((inargv && verbose >= 0) || verbose > 0)
@ -918,7 +918,7 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
fprintf(stderr, Name ": no uptodate device for slot %d of %s\n", fprintf(stderr, Name ": no uptodate device for slot %d of %s\n",
i, mddev); i, mddev);
} }
if (runstop == 1 || if (runstop == 1 ||
(runstop <= 0 && (runstop <= 0 &&
( enough(info.array.level, info.array.raid_disks, ( enough(info.array.level, info.array.raid_disks,
@ -1026,7 +1026,7 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
fprintf(stderr, Name ": Cannot start array: %s\n", fprintf(stderr, Name ": Cannot start array: %s\n",
strerror(errno)); strerror(errno));
} }
} }
if (must_close) close(mdfd); if (must_close) close(mdfd);
return 0; return 0;

View File

@ -114,7 +114,7 @@ int Build(char *mddev, int mdfd, int chunk, int level, int layout,
vers = md_get_version(mdfd); vers = md_get_version(mdfd);
/* looks Ok, go for it */ /* looks Ok, go for it */
if (vers >= 9000) { if (vers >= 9000) {
mdu_array_info_t array; mdu_array_info_t array;
@ -170,7 +170,7 @@ int Build(char *mddev, int mdfd, int chunk, int level, int layout,
} }
fd = open(dv->devname, O_RDONLY|O_EXCL); fd = open(dv->devname, O_RDONLY|O_EXCL);
if (fd < 0) { if (fd < 0) {
fprintf(stderr, Name ": Cannot open %s: %s\n", fprintf(stderr, Name ": Cannot open %s: %s\n",
dv->devname, strerror(errno)); dv->devname, strerror(errno));
goto abort; goto abort;
} }
@ -232,7 +232,7 @@ int Build(char *mddev, int mdfd, int chunk, int level, int layout,
bitmap_file); bitmap_file);
return 1; return 1;
} }
} }
if (bitmap_fd >= 0) { if (bitmap_fd >= 0) {
if (ioctl(mdfd, SET_BITMAP_FILE, bitmap_fd) < 0) { if (ioctl(mdfd, SET_BITMAP_FILE, bitmap_fd) < 0) {
fprintf(stderr, Name ": Cannot set bitmap file for %s: %s\n", fprintf(stderr, Name ": Cannot set bitmap file for %s: %s\n",
@ -273,5 +273,4 @@ int Build(char *mddev, int mdfd, int chunk, int level, int layout,
else else
ioctl(mdfd, STOP_MD, 0); ioctl(mdfd, STOP_MD, 0);
return 1; return 1;
} }

View File

@ -298,7 +298,7 @@ int Create(struct supertype *st, char *mddev, int mdfd,
if (level > 0 || level == LEVEL_MULTIPATH || level == LEVEL_FAULTY) { if (level > 0 || level == LEVEL_MULTIPATH || level == LEVEL_FAULTY) {
/* size is meaningful */ /* size is meaningful */
if (minsize > 0x100000000ULL && st->ss->major == 0) { if (minsize > 0x100000000ULL && st->ss->major == 0) {
fprintf(stderr, Name ": devices too large for RAID level %d\n", level); fprintf(stderr, Name ": devices too large for RAID level %d\n", level);
return 1; return 1;
} }
size = minsize; size = minsize;
@ -348,7 +348,7 @@ int Create(struct supertype *st, char *mddev, int mdfd,
Name ": This level does not support missing devices\n"); Name ": This level does not support missing devices\n");
return 1; return 1;
} }
/* Ok, lets try some ioctls */ /* Ok, lets try some ioctls */
array.level = level; array.level = level;
@ -467,7 +467,7 @@ int Create(struct supertype *st, char *mddev, int mdfd,
inf.major_version = st->ss->major; inf.major_version = st->ss->major;
inf.minor_version = st->minor_version; inf.minor_version = st->minor_version;
rv = ioctl(mdfd, SET_ARRAY_INFO, &inf); rv = ioctl(mdfd, SET_ARRAY_INFO, &inf);
} else } else
rv = ioctl(mdfd, SET_ARRAY_INFO, NULL); rv = ioctl(mdfd, SET_ARRAY_INFO, NULL);
if (rv) { if (rv) {
fprintf(stderr, Name ": SET_ARRAY_INFO failed for %s: %s\n", fprintf(stderr, Name ": SET_ARRAY_INFO failed for %s: %s\n",

View File

@ -233,7 +233,7 @@ int Detail(char *dev, int brief, int export, int test, char *homehost)
break; break;
default: break; default: break;
} }
if (e && e->percent >= 0) { if (e && e->percent >= 0) {
printf(" Re%s Status : %d%% complete\n", printf(" Re%s Status : %d%% complete\n",
(super && info.reshape_active)? "shape":"build", (super && info.reshape_active)? "shape":"build",
@ -301,7 +301,7 @@ This is pretty boring
} }
if (disk.major == 0 && disk.minor == 0) if (disk.major == 0 && disk.minor == 0)
continue; continue;
if (disk.raid_disk >= 0 && disk.raid_disk < array.raid_disks) if (disk.raid_disk >= 0 && disk.raid_disk < array.raid_disks)
disks[disk.raid_disk] = disk; disks[disk.raid_disk] = disk;
else if (next < max_disks) else if (next < max_disks)
disks[next++] = disk; disks[next++] = disk;
@ -319,13 +319,13 @@ This is pretty boring
if (!brief) { if (!brief) {
if (d == array.raid_disks) printf("\n"); if (d == array.raid_disks) printf("\n");
if (disk.raid_disk < 0) if (disk.raid_disk < 0)
printf(" %5d %5d %5d - ", printf(" %5d %5d %5d - ",
disk.number, disk.major, disk.minor); disk.number, disk.major, disk.minor);
else else
printf(" %5d %5d %5d %5d ", printf(" %5d %5d %5d %5d ",
disk.number, disk.major, disk.minor, disk.raid_disk); disk.number, disk.major, disk.minor, disk.raid_disk);
if (disk.state & (1<<MD_DISK_FAULTY)) { if (disk.state & (1<<MD_DISK_FAULTY)) {
printf(" faulty"); printf(" faulty");
if (disk.raid_disk < array.raid_disks && if (disk.raid_disk < array.raid_disks &&
disk.raid_disk >= 0) disk.raid_disk >= 0)
failed++; failed++;

View File

@ -55,7 +55,7 @@ int Examine(mddev_dev_t devlist, int brief, int scan,
* If (brief) gather devices for same array and just print a mdadm.conf line including devices= * If (brief) gather devices for same array and just print a mdadm.conf line including devices=
* if devlist==NULL, use conf_get_devs() * if devlist==NULL, use conf_get_devs()
*/ */
int fd; int fd;
void *super = NULL; void *super = NULL;
int rv = 0; int rv = 0;
int err = 0; int err = 0;

8
Grow.c
View File

@ -52,7 +52,7 @@ int Grow_Add_device(char *devname, int fd, char *newdev)
int nfd, fd2; int nfd, fd2;
int d, nd; int d, nd;
struct supertype *st = NULL; struct supertype *st = NULL;
if (ioctl(fd, GET_ARRAY_INFO, &info.array) < 0) { if (ioctl(fd, GET_ARRAY_INFO, &info.array) < 0) {
fprintf(stderr, Name ": cannot get array info for %s\n", devname); fprintf(stderr, Name ": cannot get array info for %s\n", devname);
@ -115,7 +115,7 @@ int Grow_Add_device(char *devname, int fd, char *newdev)
/* Ok, looks good. Lets update the superblock and write it out to /* Ok, looks good. Lets update the superblock and write it out to
* newdev. * newdev.
*/ */
info.disk.number = d; info.disk.number = d;
info.disk.major = major(stb.st_rdev); info.disk.major = major(stb.st_rdev);
info.disk.minor = minor(stb.st_rdev); info.disk.minor = minor(stb.st_rdev);
@ -179,7 +179,7 @@ int Grow_Add_device(char *devname, int fd, char *newdev)
st->ss->update_super(&info, super, "linear-grow-update", dv, st->ss->update_super(&info, super, "linear-grow-update", dv,
0, 0, NULL); 0, 0, NULL);
if (st->ss->store_super(st, fd2, super)) { if (st->ss->store_super(st, fd2, super)) {
fprintf(stderr, Name ": Cannot store new superblock on %s\n", dv); fprintf(stderr, Name ": Cannot store new superblock on %s\n", dv);
close(fd2); close(fd2);
@ -816,7 +816,7 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file,
break; break;
sleep(1); sleep(1);
} }
/* invalidate superblocks */ /* invalidate superblocks */
memset(&bsb, 0, sizeof(bsb)); memset(&bsb, 0, sizeof(bsb));
for (i=odisks; i<d ; i++) { for (i=odisks; i<d ; i++) {

2
Kill.c
View File

@ -44,7 +44,7 @@ int Kill(char *dev, int force, int quiet)
void *super; void *super;
int fd, rv = 0; int fd, rv = 0;
struct supertype *st; struct supertype *st;
fd = open(dev, O_RDWR|O_EXCL); fd = open(dev, O_RDWR|O_EXCL);
if (fd < 0) { if (fd < 0) {
if (!quiet) if (!quiet)

View File

@ -45,7 +45,7 @@ int Manage_ro(char *devname, int fd, int readonly)
* *
*/ */
mdu_array_info_t array; mdu_array_info_t array;
if (md_get_version(fd) < 9000) { if (md_get_version(fd) < 9000) {
fprintf(stderr, Name ": need md driver version 0.90.0 or later\n"); fprintf(stderr, Name ": need md driver version 0.90.0 or later\n");
return 1; return 1;
@ -55,7 +55,7 @@ int Manage_ro(char *devname, int fd, int readonly)
devname); devname);
return 1; return 1;
} }
if (readonly>0) { if (readonly>0) {
if (ioctl(fd, STOP_ARRAY_RO, NULL)) { if (ioctl(fd, STOP_ARRAY_RO, NULL)) {
fprintf(stderr, Name ": failed to set readonly for %s: %s\n", fprintf(stderr, Name ": failed to set readonly for %s: %s\n",
@ -69,7 +69,7 @@ int Manage_ro(char *devname, int fd, int readonly)
return 1; return 1;
} }
} }
return 0; return 0;
} }
#ifndef MDASSEMBLE #ifndef MDASSEMBLE
@ -88,7 +88,7 @@ int Manage_runstop(char *devname, int fd, int runstop, int quiet)
return 1; return 1;
} }
} }
if (md_get_version(fd) < 9000) { if (md_get_version(fd) < 9000) {
fprintf(stderr, Name ": need md driver version 0.90.0 or later\n"); fprintf(stderr, Name ": need md driver version 0.90.0 or later\n");
return 1; return 1;
@ -342,7 +342,7 @@ int Manage_subdevs(char *devname, int fd,
} }
/* need to find a sample superblock to copy, and /* need to find a sample superblock to copy, and
* a spare slot to use * a spare slot to use
*/ */
for (j=0; j<st->max_devs; j++) { for (j=0; j<st->max_devs; j++) {
char *dev; char *dev;
@ -507,7 +507,7 @@ int Manage_subdevs(char *devname, int fd,
} }
} }
return 0; return 0;
} }
int autodetect(void) int autodetect(void)

View File

@ -38,7 +38,7 @@
static void alert(char *event, char *dev, char *disc, char *mailaddr, char *mailfrom, static void alert(char *event, char *dev, char *disc, char *mailaddr, char *mailfrom,
char *cmd, int dosyslog); char *cmd, int dosyslog);
static char *percentalerts[] = { static char *percentalerts[] = {
"RebuildStarted", "RebuildStarted",
"Rebuild20", "Rebuild20",
"Rebuild40", "Rebuild40",
@ -291,11 +291,11 @@ int Monitor(mddev_dev_t devlist,
alert("DegradedArray", dev, NULL, mailaddr, mailfrom, alert_cmd, dosyslog); alert("DegradedArray", dev, NULL, mailaddr, mailfrom, alert_cmd, dosyslog);
if (st->utime == 0 && /* new array */ if (st->utime == 0 && /* new array */
st->expected_spares > 0 && st->expected_spares > 0 &&
array.spare_disks < st->expected_spares) array.spare_disks < st->expected_spares)
alert("SparesMissing", dev, NULL, mailaddr, mailfrom, alert_cmd, dosyslog); alert("SparesMissing", dev, NULL, mailaddr, mailfrom, alert_cmd, dosyslog);
if (mse && if (mse &&
st->percent == -1 && st->percent == -1 &&
mse->percent >= 0) mse->percent >= 0)
alert("RebuildStarted", dev, NULL, mailaddr, mailfrom, alert_cmd, dosyslog); alert("RebuildStarted", dev, NULL, mailaddr, mailfrom, alert_cmd, dosyslog);
if (mse && if (mse &&
@ -401,7 +401,7 @@ int Monitor(mddev_dev_t devlist,
/* now check if there are any new devices found in mdstat */ /* now check if there are any new devices found in mdstat */
if (scan) { if (scan) {
struct mdstat_ent *mse; struct mdstat_ent *mse;
for (mse=mdstat; mse; mse=mse->next) for (mse=mdstat; mse; mse=mse->next)
if (mse->devnum != INT_MAX && if (mse->devnum != INT_MAX &&
(strcmp(mse->level, "raid0")!=0 && (strcmp(mse->level, "raid0")!=0 &&
strcmp(mse->level, "linear")!=0) strcmp(mse->level, "linear")!=0)
@ -467,7 +467,7 @@ int Monitor(mddev_dev_t devlist,
} }
} }
if (dev > 0) { if (dev > 0) {
if (ioctl(fd2, HOT_REMOVE_DISK, if (ioctl(fd2, HOT_REMOVE_DISK,
(unsigned long)dev) == 0) { (unsigned long)dev) == 0) {
if (ioctl(fd1, HOT_ADD_DISK, if (ioctl(fd1, HOT_ADD_DISK,
(unsigned long)dev) == 0) { (unsigned long)dev) == 0) {
@ -504,7 +504,7 @@ static void alert(char *event, char *dev, char *disc, char *mailaddr, char *mail
if (!cmd && !mailaddr) { if (!cmd && !mailaddr) {
time_t now = time(0); time_t now = time(0);
printf("%1.15s: %s on %s %s\n", ctime(&now)+4, event, dev, disc?disc:"unknown device"); printf("%1.15s: %s on %s %s\n", ctime(&now)+4, event, dev, disc?disc:"unknown device");
} }
if (cmd) { if (cmd) {
@ -520,8 +520,8 @@ static void alert(char *event, char *dev, char *disc, char *mailaddr, char *mail
exit(2); exit(2);
} }
} }
if (mailaddr && if (mailaddr &&
(strncmp(event, "Fail", 4)==0 || (strncmp(event, "Fail", 4)==0 ||
strncmp(event, "Test", 4)==0 || strncmp(event, "Test", 4)==0 ||
strncmp(event, "Spares", 6)==0 || strncmp(event, "Spares", 6)==0 ||
strncmp(event, "Degrade", 7)==0)) { strncmp(event, "Degrade", 7)==0)) {

13
Query.c
View File

@ -34,7 +34,7 @@
int Query(char *dev) int Query(char *dev)
{ {
/* Give a brief description of the device, /* Give a brief description of the device,
* whether it is an md device and whether it has * whether it is an md device and whether it has
* a superblock * a superblock
*/ */
int fd = open(dev, O_RDONLY, 0); int fd = open(dev, O_RDONLY, 0);
@ -62,7 +62,7 @@ int Query(char *dev)
if (ioctl(fd, GET_ARRAY_INFO, &array)<0) if (ioctl(fd, GET_ARRAY_INFO, &array)<0)
ioctlerr = errno; ioctlerr = errno;
else ioctlerr = 0; else ioctlerr = 0;
fstat(fd, &stb); fstat(fd, &stb);
if (vers>=9000 && !ioctlerr) { if (vers>=9000 && !ioctlerr) {
@ -70,7 +70,7 @@ int Query(char *dev)
larray_size = 0; larray_size = 0;
} }
if (vers < 0) if (vers < 0)
printf("%s: is not an md array\n", dev); printf("%s: is not an md array\n", dev);
else if (vers < 9000) else if (vers < 9000)
printf("%s: is an md device, but kernel cannot provide details\n", dev); printf("%s: is an md device, but kernel cannot provide details\n", dev);
@ -91,7 +91,7 @@ int Query(char *dev)
if (st) { if (st) {
superror = st->ss->load_super(st, fd, &super, dev); superror = st->ss->load_super(st, fd, &super, dev);
superrno = errno; superrno = errno;
} else } else
superror = -1; superror = -1;
close(fd); close(fd);
if (superror == 0) { if (superror == 0) {
@ -102,7 +102,7 @@ int Query(char *dev)
disc.number = info.disk.number; disc.number = info.disk.number;
activity = "undetected"; activity = "undetected";
if (mddev && (fd = open(mddev, O_RDONLY))>=0) { if (mddev && (fd = open(mddev, O_RDONLY))>=0) {
if (md_get_version(fd) >= 9000 && if (md_get_version(fd) >= 9000 &&
ioctl(fd, GET_ARRAY_INFO, &array)>= 0) { ioctl(fd, GET_ARRAY_INFO, &array)>= 0) {
if (ioctl(fd, GET_DISK_INFO, &disc) >= 0 && if (ioctl(fd, GET_DISK_INFO, &disc) >= 0 &&
makedev((unsigned)disc.major,(unsigned)disc.minor) == stb.st_rdev) makedev((unsigned)disc.major,(unsigned)disc.minor) == stb.st_rdev)
@ -117,7 +117,7 @@ int Query(char *dev)
mddev = "array"; mddev = "array";
} }
printf("%s: device %d in %d device %s %s %s. Use mdadm --examine for more detail.\n", printf("%s: device %d in %d device %s %s %s. Use mdadm --examine for more detail.\n",
dev, dev,
info.disk.number, info.array.raid_disks, info.disk.number, info.array.raid_disks,
activity, activity,
map_num(pers, info.array.level), map_num(pers, info.array.level),
@ -128,4 +128,3 @@ int Query(char *dev)
return 0; return 0;
} }

View File

@ -110,7 +110,7 @@ struct option long_options[] = {
/* synonyms */ /* synonyms */
{"monitor", 0, 0, 'F'}, {"monitor", 0, 0, 'F'},
/* after those will normally come the name of the md device */ /* after those will normally come the name of the md device */
{"help", 0, 0, 'h'}, {"help", 0, 0, 'h'},
{"help-options",0,0,'h'}, {"help-options",0,0,'h'},

View File

@ -152,7 +152,7 @@ bitmap_info_t *bitmap_fd_read(int fd, int brief)
skip = sizeof(info->sb); skip = sizeof(info->sb);
sb_le_to_cpu(&info->sb); /* convert superblock to CPU byte ordering */ sb_le_to_cpu(&info->sb); /* convert superblock to CPU byte ordering */
if (brief || info->sb.sync_size == 0) if (brief || info->sb.sync_size == 0)
goto out; goto out;
@ -219,7 +219,7 @@ bitmap_info_t *bitmap_file_read(char *filename, int brief, struct supertype **st
if (!st) { if (!st) {
/* just look at device... */ /* just look at device... */
lseek(fd, 0, 0); lseek(fd, 0, 0);
} else { } else {
st->ss->locate_bitmap(st, fd, NULL); st->ss->locate_bitmap(st, fd, NULL);
} }
ioctl(fd, BLKFLSBUF, 0); /* make sure we read current data */ ioctl(fd, BLKFLSBUF, 0); /* make sure we read current data */
@ -398,7 +398,7 @@ int CreateBitmap(char *filename, int force, char uuid[16],
} }
bytes -= sizeof(block); bytes -= sizeof(block);
} }
rv = 0; rv = 0;
fflush(fp); fflush(fp);
/* make the file be the right size (well, to the nearest byte) */ /* make the file be the right size (well, to the nearest byte) */

View File

@ -162,7 +162,7 @@ typedef struct bitmap_super_s {
* (1) This event counter is updated before the eventcounter in the md superblock * (1) This event counter is updated before the eventcounter in the md superblock
* When a bitmap is loaded, it is only accepted if this event counter is equal * When a bitmap is loaded, it is only accepted if this event counter is equal
* to, or one greater than, the event counter in the superblock. * to, or one greater than, the event counter in the superblock.
* (2) This event counter is updated when the other one is *if*and*only*if* the * (2) This event counter is updated when the other one is *if*and*only*if* the
* array is not degraded. As bits are not cleared when the array is degraded, * array is not degraded. As bits are not cleared when the array is degraded,
* this represents the last time that any bits were cleared. * this represents the last time that any bits were cleared.
* If a device is being added that has an event count with this value or * If a device is being added that has an event count with this value or
@ -187,7 +187,7 @@ struct bitmap_page {
unsigned int hijacked; unsigned int hijacked;
/* /*
* count of dirty bits on the page * count of dirty bits on the page
*/ */
int count; int count;
}; };

View File

@ -100,7 +100,7 @@ int match_keyword(char *word)
{ {
int len = strlen(word); int len = strlen(word);
int n; int n;
if (len < 3) return -1; if (len < 3) return -1;
for (n=0; keywords[n]; n++) { for (n=0; keywords[n]; n++) {
if (strncasecmp(word, keywords[n], len)==0) if (strncasecmp(word, keywords[n], len)==0)
@ -173,7 +173,7 @@ char *conf_word(FILE *file, int allow_key)
} }
return word; return word;
} }
/* /*
* conf_line reads one logical line from the conffile. * conf_line reads one logical line from the conffile.
* It skips comments and continues until it finds a line that starts * It skips comments and continues until it finds a line that starts
@ -237,7 +237,7 @@ mddev_dev_t load_partitions(void)
if (buf[0] != ' ') if (buf[0] != ' ')
continue; continue;
major = strtoul(buf, &mp, 10); major = strtoul(buf, &mp, 10);
if (mp == buf || *mp != ' ') if (mp == buf || *mp != ' ')
continue; continue;
minor = strtoul(mp, NULL, 10); minor = strtoul(mp, NULL, 10);
@ -379,7 +379,7 @@ static void createline(char *line)
} }
} }
void devline(char *line) void devline(char *line)
{ {
char *w; char *w;
struct conf_dev *cd; struct conf_dev *cd;
@ -494,7 +494,7 @@ void arrayline(char *line)
} else if (strncasecmp(w, "metadata=", 9) == 0) { } else if (strncasecmp(w, "metadata=", 9) == 0) {
/* style of metadata on the devices. */ /* style of metadata on the devices. */
int i; int i;
for(i=0; superlist[i] && !mis.st; i++) for(i=0; superlist[i] && !mis.st; i++)
mis.st = superlist[i]->match_metadata_desc(w+9); mis.st = superlist[i]->match_metadata_desc(w+9);
@ -657,7 +657,7 @@ void load_conffile(void)
} }
free_line(line); free_line(line);
} }
fclose(f); fclose(f);
/* printf("got file\n"); */ /* printf("got file\n"); */
@ -717,7 +717,7 @@ mddev_dev_t conf_get_devs()
free(t->devname); free(t->devname);
free(t); free(t);
} }
load_conffile(); load_conffile();
if (cdevlist == NULL) if (cdevlist == NULL)

10
md_p.h
View File

@ -1,15 +1,15 @@
/* /*
md_p.h : physical layout of Linux RAID devices md_p.h : physical layout of Linux RAID devices
Copyright (C) 1996-98 Ingo Molnar, Gadi Oxman Copyright (C) 1996-98 Ingo Molnar, Gadi Oxman
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option) the Free Software Foundation; either version 2, or (at your option)
any later version. any later version.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
(for example /usr/src/linux/COPYING); if not, write to the Free (for example /usr/src/linux/COPYING); if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef _MD_P_H #ifndef _MD_P_H
@ -80,7 +80,7 @@
#define MD_DISK_REMOVED 3 /* disk is in sync with the raid set */ #define MD_DISK_REMOVED 3 /* disk is in sync with the raid set */
#define MD_DISK_WRITEMOSTLY 9 /* disk is "write-mostly" is RAID1 config. #define MD_DISK_WRITEMOSTLY 9 /* disk is "write-mostly" is RAID1 config.
* read requests will only be sent here in * read requests will only be sent here in
* dire need * dire need
*/ */
@ -190,5 +190,5 @@ static inline __u64 md_event(mdp_super_t *sb) {
return (ev<<32)| sb->events_lo; return (ev<<32)| sb->events_lo;
} }
#endif #endif

8
md_u.h
View File

@ -1,15 +1,15 @@
/* /*
md_u.h : user <=> kernel API between Linux raidtools and RAID drivers md_u.h : user <=> kernel API between Linux raidtools and RAID drivers
Copyright (C) 1998 Ingo Molnar Copyright (C) 1998 Ingo Molnar
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option) the Free Software Foundation; either version 2, or (at your option)
any later version. any later version.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
(for example /usr/src/linux/COPYING); if not, write to the Free (for example /usr/src/linux/COPYING); if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef _MD_U_H #ifndef _MD_U_H
@ -119,5 +119,5 @@ typedef struct mdu_param_s
int max_fault; /* unused for now */ int max_fault; /* unused for now */
} mdu_param_t; } mdu_param_t;
#endif #endif

28
mdadm.c
View File

@ -26,7 +26,7 @@
* Sydney, 2052 * Sydney, 2052
* Australia * Australia
* *
* Additions for bitmap and write-behind RAID options, Copyright (C) 2003-2004, * Additions for bitmap and write-behind RAID options, Copyright (C) 2003-2004,
* Paul Clements, SteelEye Technology, Inc. * Paul Clements, SteelEye Technology, Inc.
*/ */
@ -133,7 +133,7 @@ int main(int argc, char *argv[])
/* firstly, some mode-independant options */ /* firstly, some mode-independant options */
switch(opt) { switch(opt) {
case 'h': case 'h':
if (option_index > 0 && if (option_index > 0 &&
strcmp(long_options[option_index].name, "help-options")==0) strcmp(long_options[option_index].name, "help-options")==0)
print_help = 2; print_help = 2;
else else
@ -174,7 +174,7 @@ int main(int argc, char *argv[])
} }
/* second, figure out the mode. /* second, figure out the mode.
* Some options force the mode. Others * Some options force the mode. Others
* set the mode if it isn't already * set the mode if it isn't already
*/ */
switch(opt) { switch(opt) {
@ -232,7 +232,7 @@ int main(int argc, char *argv[])
mode = newmode; mode = newmode;
} else { } else {
/* special case of -c --help */ /* special case of -c --help */
if (opt == 'c' && if (opt == 'c' &&
( strncmp(optarg, "--h", 3)==0 || ( strncmp(optarg, "--h", 3)==0 ||
strncmp(optarg, "-h", 2)==0)) { strncmp(optarg, "-h", 2)==0)) {
fputs(Help_config, stdout); fputs(Help_config, stdout);
@ -255,7 +255,7 @@ int main(int argc, char *argv[])
dv->next = NULL; dv->next = NULL;
*devlistend = dv; *devlistend = dv;
devlistend = &dv->next; devlistend = &dv->next;
devs_found++; devs_found++;
continue; continue;
} }
@ -307,7 +307,7 @@ int main(int argc, char *argv[])
dv->next = NULL; dv->next = NULL;
*devlistend = dv; *devlistend = dv;
devlistend = &dv->next; devlistend = &dv->next;
devs_found++; devs_found++;
continue; continue;
} }
@ -342,7 +342,7 @@ int main(int argc, char *argv[])
fprintf(stderr, Name ": metadata information already given\n"); fprintf(stderr, Name ": metadata information already given\n");
exit(2); exit(2);
} }
for(i=0; !ss && superlist[i]; i++) for(i=0; !ss && superlist[i]; i++)
ss = superlist[i]->match_metadata_desc(optarg); ss = superlist[i]->match_metadata_desc(optarg);
if (!ss) { if (!ss) {
@ -451,7 +451,7 @@ int main(int argc, char *argv[])
case -5: /* Faulty case -5: /* Faulty
* modeNNN * modeNNN
*/ */
{ {
int ln = strcspn(optarg, "0123456789"); int ln = strcspn(optarg, "0123456789");
char *m = strdup(optarg); char *m = strdup(optarg);
@ -584,7 +584,7 @@ int main(int argc, char *argv[])
exit(2); exit(2);
} }
update = optarg; update = optarg;
if (strcmp(update, "sparc2.2")==0) if (strcmp(update, "sparc2.2")==0)
continue; continue;
if (strcmp(update, "super-minor") == 0) if (strcmp(update, "super-minor") == 0)
continue; continue;
@ -605,7 +605,7 @@ int main(int argc, char *argv[])
fprintf(stderr, Name ": must not set metadata type with --update=byteorder.\n"); fprintf(stderr, Name ": must not set metadata type with --update=byteorder.\n");
exit(2); exit(2);
} }
for(i=0; !ss && superlist[i]; i++) for(i=0; !ss && superlist[i]; i++)
ss = superlist[i]->match_metadata_desc("0.swap"); ss = superlist[i]->match_metadata_desc("0.swap");
if (!ss) { if (!ss) {
fprintf(stderr, Name ": INTERNAL ERROR cannot find 0.swap\n"); fprintf(stderr, Name ": INTERNAL ERROR cannot find 0.swap\n");
@ -941,7 +941,7 @@ int main(int argc, char *argv[])
exit(2); exit(2);
} }
if ((int)ident.super_minor == -2 && autof) { if ((int)ident.super_minor == -2 && autof) {
fprintf(stderr, Name ": --super-minor=dev is incompatible with --auto\n"); fprintf(stderr, Name ": --super-minor=dev is incompatible with --auto\n");
exit(2); exit(2);
} }
if (mode == MANAGE || mode == GROW) if (mode == MANAGE || mode == GROW)
@ -1010,7 +1010,7 @@ int main(int argc, char *argv[])
devlist->devname); devlist->devname);
rv |= 1; rv |= 1;
} else { } else {
mdfd = open_mddev(devlist->devname, mdfd = open_mddev(devlist->devname,
array_ident->autof ? array_ident->autof : autof); array_ident->autof ? array_ident->autof : autof);
if (mdfd < 0) if (mdfd < 0)
rv |= 1; rv |= 1;
@ -1042,7 +1042,7 @@ int main(int argc, char *argv[])
rv |= 1; rv |= 1;
continue; continue;
} }
mdfd = open_mddev(dv->devname, mdfd = open_mddev(dv->devname,
array_ident->autof ?array_ident->autof : autof); array_ident->autof ?array_ident->autof : autof);
if (mdfd < 0) { if (mdfd < 0) {
rv |= 1; rv |= 1;
@ -1310,7 +1310,7 @@ int main(int argc, char *argv[])
case GROW: case GROW:
if (devs_found > 1) { if (devs_found > 1) {
/* must be '-a'. */ /* must be '-a'. */
if (size >= 0 || raiddisks) { if (size >= 0 || raiddisks) {
fprintf(stderr, Name ": --size, --raiddisks, and --add are exclusing in --grow mode\n"); fprintf(stderr, Name ": --size, --raiddisks, and --add are exclusing in --grow mode\n");

View File

@ -195,7 +195,7 @@ enum special_options {
#define UnSet (0xfffe) #define UnSet (0xfffe)
typedef struct mddev_ident_s { typedef struct mddev_ident_s {
char *devname; char *devname;
int uuid_set; int uuid_set;
int uuid[4]; int uuid[4];
char name[33]; char name[33];

View File

@ -193,7 +193,7 @@ int open_mddev(char *dev, int autof)
* If the device name is in a 'standard' format, * If the device name is in a 'standard' format,
* intuit the minor from that, else * intuit the minor from that, else
* easiest to read /proc/mdstat, and hunt through for * easiest to read /proc/mdstat, and hunt through for
* an unused number * an unused number
*/ */
if (num < 0) { if (num < 0) {
/* need to pick an unused number */ /* need to pick an unused number */

View File

@ -161,7 +161,7 @@ struct mdstat_ent *mdstat_read(int hold, int start)
ent->dev = strdup(line); ent->dev = strdup(line);
ent->devnum = devnum; ent->devnum = devnum;
for (w=dl_next(line); w!= line ; w=dl_next(w)) { for (w=dl_next(line); w!= line ; w=dl_next(w)) {
int l = strlen(w); int l = strlen(w);
char *eq; char *eq;
@ -209,7 +209,7 @@ struct mdstat_ent *mdstat_read(int hold, int start)
strncmp(w, "resync", 4)==0) { strncmp(w, "resync", 4)==0) {
ent->resync = 1; ent->resync = 1;
} else if (ent->percent == -1 && } else if (ent->percent == -1 &&
w[0] >= '0' && w[0] >= '0' &&
w[0] <= '9' && w[0] <= '9' &&
w[l-1] == '%') { w[l-1] == '%') {
ent->percent = atoi(w); ent->percent = atoi(w);

View File

@ -52,7 +52,7 @@ raid5_extend(unsigned long len, int chunksize, int layout, int n, int m, int rfd
unsigned int blocksperchunk= chunksize/4096; unsigned int blocksperchunk= chunksize/4096;
unsigned long b; unsigned long b;
for (b=0; b<blocks; b++) { for (b=0; b<blocks; b++) {
unsigned long stripe = b / blocksperchunk; unsigned long stripe = b / blocksperchunk;
unsigned int offset = b - (stripe*blocksperchunk); unsigned int offset = b - (stripe*blocksperchunk);

View File

@ -38,7 +38,7 @@
* - initialising a new superblock * - initialising a new superblock
* - printing the superblock for --examine * - printing the superblock for --examine
* - printing part of the superblock for --detail * - printing part of the superblock for --detail
* .. other stuff * .. other stuff
*/ */
@ -56,7 +56,7 @@ static unsigned long calc_sb0_csum(mdp_super_t *super)
void super0_swap_endian(struct mdp_superblock_s *sb) void super0_swap_endian(struct mdp_superblock_s *sb)
{ {
/* as super0 superblocks are host-endian, it is sometimes /* as super0 superblocks are host-endian, it is sometimes
* useful to be able to swap the endianness * useful to be able to swap the endianness
* as (almost) everything is u32's we byte-swap every 4byte * as (almost) everything is u32's we byte-swap every 4byte
* number. * number.
* We then also have to swap the events_hi and events_lo * We then also have to swap the events_hi and events_lo
@ -403,14 +403,14 @@ static int update_super0(struct mdinfo *info, void *sbv, char *update,
if (strcmp(update, "summaries") == 0) { if (strcmp(update, "summaries") == 0) {
int i; int i;
/* set nr_disks, active_disks, working_disks, /* set nr_disks, active_disks, working_disks,
* failed_disks, spare_disks based on disks[] * failed_disks, spare_disks based on disks[]
* array in superblock. * array in superblock.
* Also make sure extra slots aren't 'failed' * Also make sure extra slots aren't 'failed'
*/ */
sb->nr_disks = sb->active_disks = sb->nr_disks = sb->active_disks =
sb->working_disks = sb->failed_disks = sb->working_disks = sb->failed_disks =
sb->spare_disks = 0; sb->spare_disks = 0;
for (i=0; i < MD_SB_DISKS ; i++) for (i=0; i < MD_SB_DISKS ; i++)
if (sb->disks[i].major || if (sb->disks[i].major ||
sb->disks[i].minor) { sb->disks[i].minor) {
int state = sb->disks[i].state; int state = sb->disks[i].state;
@ -727,7 +727,7 @@ static int load_super0(struct supertype *st, int fd, void **sbp, char *devname)
mdp_super_t *super; mdp_super_t *super;
int uuid[4]; int uuid[4];
struct bitmap_super_s *bsb; struct bitmap_super_s *bsb;
if (!get_dev_size(fd, devname, &dsize)) if (!get_dev_size(fd, devname, &dsize))
return 1; return 1;
@ -910,7 +910,7 @@ int write_bitmap0(struct supertype *st, int fd, void *sbv)
unsigned long long dsize; unsigned long long dsize;
unsigned long long offset; unsigned long long offset;
mdp_super_t *sb = sbv; mdp_super_t *sb = sbv;
int rv = 0; int rv = 0;
int towrite, n; int towrite, n;
@ -938,7 +938,7 @@ int write_bitmap0(struct supertype *st, int fd, void *sbv)
memset(buf, 0xff, sizeof(buf)); memset(buf, 0xff, sizeof(buf));
while (towrite > 0) { while (towrite > 0) {
n = towrite; n = towrite;
if (n > sizeof(buf)) if (n > sizeof(buf))
n = sizeof(buf); n = sizeof(buf);
n = write(fd, buf, n); n = write(fd, buf, n);
if (n > 0) if (n > 0)

59
util.c
View File

@ -73,33 +73,32 @@ struct blkpg_partition {
*/ */
int parse_uuid(char *str, int uuid[4]) int parse_uuid(char *str, int uuid[4])
{ {
int hit = 0; /* number of Hex digIT */ int hit = 0; /* number of Hex digIT */
int i; int i;
char c; char c;
for (i=0; i<4; i++) uuid[i]=0; for (i=0; i<4; i++) uuid[i]=0;
while ((c= *str++)) { while ((c= *str++)) {
int n; int n;
if (c>='0' && c<='9') if (c>='0' && c<='9')
n = c-'0'; n = c-'0';
else if (c>='a' && c <= 'f') else if (c>='a' && c <= 'f')
n = 10 + c - 'a'; n = 10 + c - 'a';
else if (c>='A' && c <= 'F') else if (c>='A' && c <= 'F')
n = 10 + c - 'A'; n = 10 + c - 'A';
else if (strchr(":. -", c)) else if (strchr(":. -", c))
continue; continue;
else return 0; else return 0;
if (hit<32) { if (hit<32) {
uuid[hit/8] <<= 4; uuid[hit/8] <<= 4;
uuid[hit/8] += n; uuid[hit/8] += n;
}
hit++;
} }
hit++; if (hit == 32)
} return 1;
if (hit == 32) return 0;
return 1;
return 0;
} }
@ -132,7 +131,6 @@ int md_get_version(int fd)
return -1; return -1;
} }
int get_linux_version() int get_linux_version()
{ {
struct utsname name; struct utsname name;
@ -224,7 +222,7 @@ int same_uuid(int a[4], int b[4], int swapuuid)
if (swapuuid) { if (swapuuid) {
/* parse uuids are hostendian. /* parse uuids are hostendian.
* uuid's from some superblocks are big-ending * uuid's from some superblocks are big-ending
* if there is a difference, we need to swap.. * if there is a difference, we need to swap..
*/ */
unsigned char *ac = (unsigned char *)a; unsigned char *ac = (unsigned char *)a;
unsigned char *bc = (unsigned char *)b; unsigned char *bc = (unsigned char *)b;
@ -318,7 +316,7 @@ int check_reiser(int fd, char *name)
fprintf(stderr, Name ": %s appears to contain a reiserfs file system\n",name); fprintf(stderr, Name ": %s appears to contain a reiserfs file system\n",name);
size = sb[0]|(sb[1]|(sb[2]|sb[3]<<8)<<8)<<8; size = sb[0]|(sb[1]|(sb[2]|sb[3]<<8)<<8)<<8;
fprintf(stderr, " size = %luK\n", size*4); fprintf(stderr, " size = %luK\n", size*4);
return 1; return 1;
} }
@ -391,7 +389,7 @@ int is_standard(char *dev, int *nump)
{ {
/* tests if dev is a "standard" md dev name. /* tests if dev is a "standard" md dev name.
* i.e if the last component is "/dNN" or "/mdNN", * i.e if the last component is "/dNN" or "/mdNN",
* where NN is a string of digits * where NN is a string of digits
*/ */
char *d = strrchr(dev, '/'); char *d = strrchr(dev, '/');
int type=0; int type=0;
@ -546,7 +544,7 @@ unsigned long calc_csum(void *super, int bytes)
newcsum+= superc[i]; newcsum+= superc[i];
csum = (newcsum& 0xffffffff) + (newcsum>>32); csum = (newcsum& 0xffffffff) + (newcsum>>32);
#ifdef __alpha__ #ifdef __alpha__
/* The in-kernel checksum calculation is always 16bit on /* The in-kernel checksum calculation is always 16bit on
* the alpha, though it is 32 bit on i386... * the alpha, though it is 32 bit on i386...
* I wonder what it is elsewhere... (it uses and API in * I wonder what it is elsewhere... (it uses and API in
* a way that it shouldn't). * a way that it shouldn't).
@ -592,7 +590,6 @@ char *human_size(long long bytes)
char *human_size_brief(long long bytes) char *human_size_brief(long long bytes)
{ {
static char buf[30]; static char buf[30];
if (bytes < 5000*1024) if (bytes < 5000*1024)
snprintf(buf, sizeof(buf), "%ld.%02ldKiB", snprintf(buf, sizeof(buf), "%ld.%02ldKiB",
@ -753,7 +750,7 @@ struct supertype *guess_super(int fd)
struct supertype *st; struct supertype *st;
unsigned long besttime = 0; unsigned long besttime = 0;
int bestsuper = -1; int bestsuper = -1;
void *sbp = NULL; void *sbp = NULL;
int i; int i;