Re: [mdadm PATCH] mdopen: call "modprobe md_mod" if it might be needed.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>>>>> "NeilBrown" == NeilBrown  <neilb@xxxxxxxx> writes:

NeilBrown> Creating an array by opening a block-device with major number of 9
NeilBrown> will transparently load the md module if needed.
NeilBrown> Creating an array by opening
NeilBrown>    /sys/module/md_mod/parameters/new_array
NeilBrown> and writing to it won't, it will just fail if md_mod isn't loaded.

NeilBrown> So when opening that file fails with ENOENT, run "modprobe md_mod" and
NeilBrown> try again.

NeilBrown> This fixes a bug whereby if you have "CREATE names=yes" in mdadm.conf,
NeilBrown> and the md modules isn't loaded, then creating or assembling an
NeilBrown> array will not honor the "names=yes" configuration.

NeilBrown> Signed-off-by: NeilBrown <neilb@xxxxxxxx>
NeilBrown> ---
NeilBrown>  mdopen.c | 4 ++++
NeilBrown>  1 file changed, 4 insertions(+)

NeilBrown> diff --git a/mdopen.c b/mdopen.c
NeilBrown> index 3c0052f2db23..dcdc6f23e6c1 100644
NeilBrown> --- a/mdopen.c
NeilBrown> +++ b/mdopen.c
NeilBrown> @@ -312,6 +312,10 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
NeilBrown>  		if (block_udev)
NeilBrown>  			udev_block(devnm);
NeilBrown>  		fd = open("/sys/module/md_mod/parameters/new_array", O_WRONLY);
NeilBrown> +		if (fd < 0 && errno == ENOENT) {
NeilBrown> +			system("modprobe md_mod");
NeilBrown> +			fd = open("/sys/module/md_mod/parameters/new_array", O_WRONLY);
NeilBrown> +		}
NeilBrown>  		if (fd >= 0) {
NeilBrown>  			n = write(fd, devnm, strlen(devnm));
NeilBrown>  			close(fd);
NeilBrown> -- 
NeilBrown> 2.14.0.rc0.dirty

I haven't looked, but shouldn't the path for modprobe be hardcoded
here to /sbin/modprobe?  Or the PATH sanitized so that random people
can't put something into the system PATH and cause problems? 

--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux