Re: [PATCH] policy: NULL path isn't really acceptable - use the devname

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

 



On Thu, 19 Dec 2013 13:02:12 +0100 Lukasz Dorau <lukasz.dorau@xxxxxxxxx>
wrote:

> According to:
> 	commit b451aa4846c5ccca5447a6b6d45e5623b8c8e961
> 	Fix handling for "auto" line in mdadm.conf
> 
> a NULL path isn't really acceptable and the devname should be used instead.
> 
> Signed-off-by: Lukasz Dorau <lukasz.dorau@xxxxxxxxx>
> ---
>  policy.c |   35 +++++++++++++++++------------------
>  1 file changed, 17 insertions(+), 18 deletions(-)
> 
> diff --git a/policy.c b/policy.c
> index b4f3943..104695d 100644
> --- a/policy.c
> +++ b/policy.c
> @@ -200,26 +200,25 @@ static char *disk_path(struct mdinfo *disk)
>  	int rv;
>  
>  	by_path = opendir(symlink);
> -	if (!by_path)
> -		return NULL;
> -	prefix_len = strlen(symlink);
> -
> -	while ((ent = readdir(by_path)) != NULL) {
> -		if (ent->d_type != DT_LNK)
> -			continue;
> -		strncpy(symlink + prefix_len,
> -			ent->d_name,
> -			sizeof(symlink) - prefix_len);
> -		if (stat(symlink, &stb) < 0)
> -			continue;
> -		if ((stb.st_mode & S_IFMT) != S_IFBLK)
> -			continue;
> -		if (stb.st_rdev != makedev(disk->disk.major, disk->disk.minor))
> -			continue;
> +	if (by_path) {
> +		prefix_len = strlen(symlink);
> +		while ((ent = readdir(by_path)) != NULL) {
> +			if (ent->d_type != DT_LNK)
> +				continue;
> +			strncpy(symlink + prefix_len,
> +					ent->d_name,
> +					sizeof(symlink) - prefix_len);
> +			if (stat(symlink, &stb) < 0)
> +				continue;
> +			if ((stb.st_mode & S_IFMT) != S_IFBLK)
> +				continue;
> +			if (stb.st_rdev != makedev(disk->disk.major, disk->disk.minor))
> +				continue;
> +			closedir(by_path);
> +			return xstrdup(ent->d_name);
> +		}
>  		closedir(by_path);
> -		return xstrdup(ent->d_name);
>  	}
> -	closedir(by_path);
>  	/* A NULL path isn't really acceptable - use the devname.. */
>  	sprintf(symlink, "/sys/dev/block/%d:%d", disk->disk.major, disk->disk.minor);
>  	rv = readlink(symlink, nm, sizeof(nm)-1);


Applied, thanks.

NeilBrown

Attachment: signature.asc
Description: PGP signature


[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