* including spares
* failed_disks is the number of disks marked failed
*
- * Ideally, the kernel would keep these (except raid_disks)
+ * Ideally, the kernel would keep these (except raid_disks)
* up-to-date as we ADD_NEW_DISK, but it doesn't (yet).
* So for now, we assume that all raid and spare
* devices will be given.
char short_options[]="-ABCDEFGIQhVXYWZ:vqbc:i:l:p:m:n:x:u:c:d:z:U:N:sarfRSow1tye:";
char short_bitmap_options[]=
- "-ABCDEFGIQhVXYWZ:vqb:c:i:l:p:m:n:x:u:c:d:z:U:N:sarfRSow1tye:";
+ "-ABCDEFGIQhVXYWZ:vqb:c:i:l:p:m:n:x:u:c:d:z:U:N:sarfRSow1tye:";
char short_bitmap_auto_options[]=
- "-ABCDEFGIQhVXYWZ:vqb:c:i:l:p:m:n:x:u:c:d:z:U:N:sa:rfRSow1tye:";
+ "-ABCDEFGIQhVXYWZ:vqb:c:i:l:p:m:n:x:u:c:d:z:U:N:sa:rfRSow1tye:";
struct option long_options[] = {
{"manage", 0, 0, ManageOpt},
struct conf_dev {
- struct conf_dev *next;
- char *name;
+ struct conf_dev *next;
+ char *name;
} *cdevlist = NULL;
struct mddev_dev *load_partitions(void)
int match_oneof(char *devices, char *devname)
{
- /* check if one of the comma separated patterns in devices
- * matches devname
- */
-
- while (devices && *devices) {
- char patn[1024];
- char *p = devices;
- devices = strchr(devices, ',');
- if (!devices)
- devices = p + strlen(p);
- if (devices-p < 1024) {
- strncpy(patn, p, devices-p);
- patn[devices-p] = 0;
- if (fnmatch(patn, devname, FNM_PATHNAME)==0)
- return 1;
+ /* check if one of the comma separated patterns in devices
+ * matches devname
+ */
+
+ while (devices && *devices) {
+ char patn[1024];
+ char *p = devices;
+ devices = strchr(devices, ',');
+ if (!devices)
+ devices = p + strlen(p);
+ if (devices-p < 1024) {
+ strncpy(patn, p, devices-p);
+ patn[devices-p] = 0;
+ if (fnmatch(patn, devname, FNM_PATHNAME)==0)
+ return 1;
+ }
+ if (*devices == ',')
+ devices++;
}
- if (*devices == ',')
- devices++;
- }
- return 0;
+ return 0;
}
int devname_matches(char *name, char *match)
* Put them in a simple linked listfor now.
*/
struct devmap {
- int major, minor;
- char *name;
- struct devmap *next;
+ int major, minor;
+ char *name;
+ struct devmap *next;
} *devlist = NULL;
int devlist_ready = 0;
}
if (check_env("IMSM_TEST_OROM")) {
dprintf("OROM CAP: %p, pid: %d pop: %d\n",
- &imsm_orom[hba_id], (int) getpid(), populated_orom[hba_id]);
+ &imsm_orom[hba_id], (int) getpid(), populated_orom[hba_id]);
return imsm_platform_test(hba_id, &populated_orom[hba_id], &imsm_orom[hba_id]);
}
/* return empty OROM capabilities in EFI test mode */
errno = 0;
var_data_len = strtoul(buf, NULL, 16);
if ((errno == ERANGE && (var_data_len == LONG_MAX))
- || (errno != 0 && var_data_len == 0))
+ || (errno != 0 && var_data_len == 0))
return 1;
/* get data */
/* find rule named rule_type and return its value */
char *find_rule(struct rule *rule, char *rule_type)
{
- while (rule) {
- if (rule->name == rule_type)
- return rule->value;
+ while (rule) {
+ if (rule->name == rule_type)
+ return rule->value;
- rule = rule->next;
- }
- return NULL;
+ rule = rule->next;
+ }
+ return NULL;
}
#define UDEV_RULE_FORMAT \
*/
int generate_entries(int fd)
{
- struct pol_rule *loop, *dup;
- char *loop_value, *dup_value;
- int duplicate;
-
- for (loop = config_rules; loop; loop = loop->next) {
- if (loop->type != rule_policy && loop->type != rule_part)
- continue;
- duplicate = 0;
-
- /* only policies with paths and with actions supporting
- * bare disks are considered */
- loop_value = find_rule(loop->rule, pol_act);
- if (!loop_value || map_act(loop_value) < act_spare_same_slot)
- continue;
- loop_value = find_rule(loop->rule, rule_path);
- if (!loop_value)
- continue;
- for (dup = config_rules; dup != loop; dup = dup->next) {
- if (dup->type != rule_policy && loop->type != rule_part)
- continue;
- dup_value = find_rule(dup->rule, pol_act);
- if (!dup_value || map_act(dup_value) < act_spare_same_slot)
- continue;
- dup_value = find_rule(dup->rule, rule_path);
- if (!dup_value)
- continue;
- if (strcmp(loop_value, dup_value) == 0) {
- duplicate = 1;
- break;
- }
- }
-
- /* not a dup or first occurrence */
- if (!duplicate)
- if (!write_rule(loop->rule, fd, loop->type == rule_part) )
- return 0;
- }
- return 1;
+ struct pol_rule *loop, *dup;
+ char *loop_value, *dup_value;
+ int duplicate;
+
+ for (loop = config_rules; loop; loop = loop->next) {
+ if (loop->type != rule_policy && loop->type != rule_part)
+ continue;
+ duplicate = 0;
+
+ /* only policies with paths and with actions supporting
+ * bare disks are considered */
+ loop_value = find_rule(loop->rule, pol_act);
+ if (!loop_value || map_act(loop_value) < act_spare_same_slot)
+ continue;
+ loop_value = find_rule(loop->rule, rule_path);
+ if (!loop_value)
+ continue;
+ for (dup = config_rules; dup != loop; dup = dup->next) {
+ if (dup->type != rule_policy && loop->type != rule_part)
+ continue;
+ dup_value = find_rule(dup->rule, pol_act);
+ if (!dup_value || map_act(dup_value) < act_spare_same_slot)
+ continue;
+ dup_value = find_rule(dup->rule, rule_path);
+ if (!dup_value)
+ continue;
+ if (strcmp(loop_value, dup_value) == 0) {
+ duplicate = 1;
+ break;
+ }
+ }
+
+ /* not a dup or first occurrence */
+ if (!duplicate)
+ if (!write_rule(loop->rule, fd, loop->type == rule_part) )
+ return 0;
+ }
+ return 1;
}
/* Write_rules routine creates dynamic udev rules used to handle
*/
int Write_rules(char *rule_name)
{
- int fd;
- char udev_rule_file[PATH_MAX];
-
- if (rule_name) {
- strncpy(udev_rule_file, rule_name, sizeof(udev_rule_file) - 6);
- udev_rule_file[sizeof(udev_rule_file) - 6] = '\0';
- strcat(udev_rule_file, ".temp");
- fd = creat(udev_rule_file,
- S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
- if (fd == -1)
- return 1;
- } else
- fd = 1;
-
- /* write static invocation */
- if (write(fd, udev_template_start,
- sizeof(udev_template_start) - 1)
- != (int)sizeof(udev_template_start)-1)
- goto abort;
-
- /* iterate, if none created or error occurred, remove file */
- if (generate_entries(fd) < 0)
- goto abort;
-
- fsync(fd);
- if (rule_name) {
- close(fd);
- rename(udev_rule_file, rule_name);
- }
- return 0;
+ int fd;
+ char udev_rule_file[PATH_MAX];
+
+ if (rule_name) {
+ strncpy(udev_rule_file, rule_name, sizeof(udev_rule_file) - 6);
+ udev_rule_file[sizeof(udev_rule_file) - 6] = '\0';
+ strcat(udev_rule_file, ".temp");
+ fd = creat(udev_rule_file,
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+ if (fd == -1)
+ return 1;
+ } else
+ fd = 1;
+
+ /* write static invocation */
+ if (write(fd, udev_template_start,
+ sizeof(udev_template_start) - 1)
+ != (int)sizeof(udev_template_start)-1)
+ goto abort;
+
+ /* iterate, if none created or error occurred, remove file */
+ if (generate_entries(fd) < 0)
+ goto abort;
+
+ fsync(fd);
+ if (rule_name) {
+ close(fd);
+ rename(udev_rule_file, rule_name);
+ }
+ return 0;
abort:
- if (rule_name) {
- close(fd);
- unlink(udev_rule_file);
- }
- return 1;
+ if (rule_name) {
+ close(fd);
+ unlink(udev_rule_file);
+ }
+ return 1;
}
}
#define container_of(ptr, type, member) ({ \
- const typeof( ((type *)0)->member ) *__mptr = (ptr); \
- (type *)( (char *)__mptr - offsetof(type,member) );})
+ const typeof( ((type *)0)->member ) *__mptr = (ptr); \
+ (type *)( (char *)__mptr - offsetof(type,member) );})
/*
* The state of each disk is stored in the global phys_disk structure
* in phys_disk.entries[n].state.
__u32 *p = (__u32 *) mpb;
__u32 sum = 0;
- while (end--) {
- sum += __le32_to_cpu(*p);
+ while (end--) {
+ sum += __le32_to_cpu(*p);
p++;
}
- return sum - __le32_to_cpu(mpb->check_sum);
+ return sum - __le32_to_cpu(mpb->check_sum);
}
static size_t sizeof_imsm_map(struct imsm_map *map)
struct intel_super *first = st->sb;
struct intel_super *sec = tst->sb;
- if (!first) {
- st->sb = tst->sb;
- tst->sb = NULL;
- return 0;
- }
+ if (!first) {
+ st->sb = tst->sb;
+ tst->sb = NULL;
+ return 0;
+ }
/* in platform dependent environment test if the disks
* use the same Intel hba
*/
return 0;
}
- /* capabilities of OROM tested - copied from validate_geometry_imsm_volume */
+ /* capabilities of OROM tested - copied from validate_geometry_imsm_volume */
if (!is_raid_level_supported(super->orom, level, raiddisks)) {
pr_vrb(": platform does not support raid%d with %d disk%s\n",
level, raiddisks, raiddisks > 1 ? "s" : "");
__u32 dev_number; /* permanent identifier of this device - not role in raid */
__u32 cnt_corrected_read; /* number of read errors that were corrected by re-writing */
__u8 device_uuid[16]; /* user-space setable, ignored by kernel */
- __u8 devflags; /* per-device flags. Only one defined...*/
+ __u8 devflags; /* per-device flags. Only one defined...*/
#define WriteMostly1 1 /* mask for writemostly flag in above */
/* bad block log. If there are any bad blocks the feature flag is set.
* if offset and size are non-zero, that space is reserved and available.
/* The argument structure */
struct blkpg_ioctl_arg {
- int op;
- int flags;
- int datalen;
- void *data;
+ int op;
+ int flags;
+ int datalen;
+ void *data;
};
/* The subfunctions (for the op field) */
int md_get_version(int fd)
{
- struct stat stb;
- mdu_version_t vers;
+ struct stat stb;
+ mdu_version_t vers;
- if (fstat(fd, &stb)<0)
- return -1;
- if ((S_IFMT&stb.st_mode) != S_IFBLK)
- return -1;
+ if (fstat(fd, &stb)<0)
+ return -1;
+ if ((S_IFMT&stb.st_mode) != S_IFBLK)
+ return -1;
- if (ioctl(fd, RAID_VERSION, &vers) == 0)
- return (vers.major*10000) + (vers.minor*100) + vers.patchlevel;
- if (errno == EACCES)
- return -1;
- if (major(stb.st_rdev) == MD_MAJOR)
- return (3600);
- return -1;
+ if (ioctl(fd, RAID_VERSION, &vers) == 0)
+ return (vers.major*10000) + (vers.minor*100) + vers.patchlevel;
+ if (errno == EACCES)
+ return -1;
+ if (major(stb.st_rdev) == MD_MAJOR)
+ return (3600);
+ return -1;
}
int get_linux_version()