diff --git a/ChangeLog b/ChangeLog index fedec596..140e561e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -77,6 +77,9 @@ xx/xx/2006 - x.xx.x - . - ntfsmount: Umount volume in DESTROY. This is guarantees that all data would be synced before umount return for volumes mounted with blkdev option. (Yura) + - Introduce MNT_NTFS_NOT_EXCLUSIVE mount option that tells libntfs do + not open volume exclusively. Useful if libntfs user cares about this + himself, eg. FUSE with blkdev option. (Yura) 21/06/2006 - 1.13.1 - Various fixes. diff --git a/include/ntfs/volume.h b/include/ntfs/volume.h index ba8cf3e3..96ace852 100644 --- a/include/ntfs/volume.h +++ b/include/ntfs/volume.h @@ -59,6 +59,7 @@ typedef enum { NTFS_MNT_RDONLY = 1, NTFS_MNT_NOATIME = 2, NTFS_MNT_CASE_SENSITIVE = 4, + NTFS_MNT_NOT_EXCLUSIVE = 8, } ntfs_mount_flags; /** diff --git a/libntfs/unix_io.c b/libntfs/unix_io.c index 4080147d..048791e0 100644 --- a/libntfs/unix_io.c +++ b/libntfs/unix_io.c @@ -88,12 +88,6 @@ static int ntfs_device_unix_io_open(struct ntfs_device *dev, int flags) } if (!(dev->d_private = ntfs_malloc(sizeof(int)))) return -1; - /* - * Open the device/file obtaining the file descriptor for exclusive - * access (but only if mounting r/w). - */ - if ((flags & O_RDWR) == O_RDWR) - flags |= O_EXCL; *(int*)dev->d_private = open(dev->d_name, flags); if (*(int*)dev->d_private == -1) { err = errno; @@ -112,11 +106,12 @@ static int ntfs_device_unix_io_open(struct ntfs_device *dev, int flags) flk.l_start = flk.l_len = 0LL; if (fcntl(DEV_FD(dev), F_SETLK, &flk)) { err = errno; - ntfs_log_debug("ntfs_device_unix_io_open: Could not lock %s for %s\n", - dev->d_name, NDevReadOnly(dev) ? "reading" : "writing"); + ntfs_log_debug("ntfs_device_unix_io_open: Could not lock %s " + "for %s\n", dev->d_name, NDevReadOnly(dev) ? + "reading" : "writing"); if (close(DEV_FD(dev))) - ntfs_log_perror("ntfs_device_unix_io_open: Warning: Could not " - "close %s", dev->d_name); + ntfs_log_perror("ntfs_device_unix_io_open: Warning: " + "Could not close %s", dev->d_name); goto err_out; } /* Determine if device is a block device or not, ignoring errors. */ diff --git a/libntfs/volume.c b/libntfs/volume.c index 3417bdf6..3901853e 100644 --- a/libntfs/volume.c +++ b/libntfs/volume.c @@ -438,7 +438,9 @@ ntfs_volume *ntfs_volume_startup(struct ntfs_device *dev, if (flags & NTFS_MNT_CASE_SENSITIVE) NVolSetCaseSensitive(vol); ntfs_log_debug("Reading bootsector... "); - if (dev->d_ops->open(dev, NVolReadOnly(vol) ? O_RDONLY: O_RDWR)) { + if (dev->d_ops->open(dev, NVolReadOnly(vol) ? O_RDONLY : + ((flags & NTFS_MNT_NOT_EXCLUSIVE) ? O_RDWR : + (O_RDWR | O_EXCL)))) { ntfs_log_debug(FAILED); ntfs_log_perror("Error opening partition device"); goto error_exit; @@ -752,6 +754,7 @@ out: * NTFS_MNT_NOATIME - do not update access time * NTFS_MNT_CASE_SENSITIVE - treat filenames as case sensitive even if * they are not in POSIX namespace + * NTFS_MNT_NOT_EXCLUSIVE - (unix only) do not open volume exclusively * * The function opens the device @dev and verifies that it contains a valid * bootsector. Then, it allocates an ntfs_volume structure and initializes @@ -1150,6 +1153,7 @@ error_exit: * NTFS_MNT_NOATIME - do not update access time * NTFS_MNT_CASE_SENSITIVE - treat filenames as case sensitive even if * they are not in POSIX namespace + * NTFS_MNT_NOT_EXCLUSIVE - (unix only) do not open volume exclusively * * The function opens the device or file @name and verifies that it contains a * valid bootsector. Then, it allocates an ntfs_volume structure and initializes diff --git a/ntfsprogs/ntfsmount.c b/ntfsprogs/ntfsmount.c index 1a0e15fd..75c5500e 100644 --- a/ntfsprogs/ntfsmount.c +++ b/ntfsprogs/ntfsmount.c @@ -1418,8 +1418,9 @@ static int ntfs_fuse_mount(const char *device) ntfs_volume *vol; vol = utils_mount_volume(device, ((ctx->ro) ? NTFS_MNT_RDONLY : 0) | - ((ctx->noatime) ? NTFS_MNT_NOATIME : 0) /*| - NTFS_MNT_CASE_SENSITIVE*/, ctx->force); + ((ctx->noatime) ? NTFS_MNT_NOATIME : 0) | + NTFS_MNT_NOT_EXCLUSIVE /*| NTFS_MNT_CASE_SENSITIVE*/, + ctx->force); if (!vol) { ntfs_log_error("Mount failed.\n"); return -1;