From 538349c592323ed78385ebdce73ddd29823d040e Mon Sep 17 00:00:00 2001 From: szaka Date: Sun, 12 Nov 2006 21:29:12 +0000 Subject: [PATCH] ntfs_device_unix_io_open: check for block device early on --- libntfs-3g/unix_io.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libntfs-3g/unix_io.c b/libntfs-3g/unix_io.c index b8c3fa07..bf46825d 100644 --- a/libntfs-3g/unix_io.c +++ b/libntfs-3g/unix_io.c @@ -87,6 +87,13 @@ static int ntfs_device_unix_io_open(struct ntfs_device *dev, int flags) errno = EBUSY; return -1; } + if (stat(dev->d_name, &sbuf)) { + ntfs_log_perror("Failed to access '%s'", dev->d_name); + return -1; + } + if (S_ISBLK(sbuf.st_mode)) + NDevSetBlock(dev); + dev->d_private = ntfs_malloc(sizeof(int)); if (!dev->d_private) return -1; @@ -121,9 +128,6 @@ static int ntfs_device_unix_io_open(struct ntfs_device *dev, int flags) "close %s", dev->d_name); goto err_out; } - /* Determine if device is a block device or not, ignoring errors. */ - if (!fstat(DEV_FD(dev), &sbuf) && S_ISBLK(sbuf.st_mode)) - NDevSetBlock(dev); /* Set our open flag. */ NDevSetOpen(dev); return 0;