return 0;
}
+int sysfs_get_str(struct mdinfo *sra, struct mdinfo *dev,
+ char *name, char *buf, int buf_len)
+{
+ char fname[50];
+ int n;
+ int fd;
+
+ sprintf(fname, "/sys/block/%s/md/%s/%s",
+ sra->sys_name, dev?dev->sys_name:"", name);
+ fd = open(fname, O_RDONLY);
+ if (fd < 0)
+ return -1;
+ n = read(fd, buf, buf_len);
+ close(fd);
+ if (n <= 0)
+ return -1;
+ buf[n] = 0;
+ return 0;
+}
+
int sysfs_set_safemode(struct mdinfo *sra, unsigned long ms)
{
unsigned long sec;
rv |= sysfs_set_num(info, NULL, "chunk_size", info->array.chunk_size);
rv |= sysfs_set_num(info, NULL, "layout", info->array.layout);
rv |= sysfs_set_num(info, NULL, "component_size", info->component_size/2);
+ if (info->custom_array_size) {
+ int rc;
+
+ rc = sysfs_set_num(info, NULL, "array_size",
+ info->custom_array_size/2);
+ if (rc && errno == ENOENT) {
+ fprintf(stderr, Name ": This kernel does not "
+ "have the md/array_size attribute, "
+ "the array may be larger than expected\n");
+ rc = 0;
+ }
+ rv |= rc;
+ }
+
if (info->array.level > 0)
rv |= sysfs_set_num(info, NULL, "resync_start", info->resync_start);
return rv;