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.
edge.strict_endians
yura 2006-11-25 17:37:37 +00:00
parent 4b7868ddc2
commit 8df298aec2
5 changed files with 17 additions and 13 deletions

View File

@ -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.

View File

@ -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;
/**

View File

@ -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. */

View File

@ -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

View File

@ -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;