Re: [PATCH 08/12] mkfs.bfs: fix block device open race

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

 



On Sat, Oct 31, 2015 at 07:21:20PM +0000, Sami Kerola wrote:
> This fix makes mkfs.bfs also to detect if block device is busy, and warn if
> the device is misaligned.
> 
> Signed-off-by: Sami Kerola <kerolasa@xxxxxx>
> ---
>  disk-utils/mkfs.bfs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/disk-utils/mkfs.bfs.c b/disk-utils/mkfs.bfs.c
> index 7057194..139130e 100644
> --- a/disk-utils/mkfs.bfs.c
> +++ b/disk-utils/mkfs.bfs.c
> @@ -187,7 +187,7 @@ int main(int argc, char **argv)
>  	if (!S_ISBLK(statbuf.st_mode))
>  		errx(EXIT_FAILURE, _("%s is not a block special device"), device);
>  
> -	fd = open(device, O_RDWR | O_EXCL);
> +	fd = open_blkdev_or_file(device, O_RDWR);

 It seems code assumes block devices only, why we need _or_file()
 here? It would be enough to check statbuf and fstat(fd) for inode
 number if you want to avoid races.

    Karel

-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux