* Fix bug with updating atime on read-only volumes. (Thanks to Szaka and Anton)
* Add MS_NOATIME to ntfs_mount. (By Yuval's request)edge.strict_endians
							parent
							
								
									56c8393be0
								
							
						
					
					
						commit
						e58a468d0c
					
				| 
						 | 
				
			
			@ -88,6 +88,7 @@ xx/xx/2005 - 1.12.2-WIP
 | 
			
		|||
	  stayed at approximately same level.  (Yura)
 | 
			
		||||
	- Automatically update access and change time in ntfs_attr_p{read,write}
 | 
			
		||||
	  and ntfs_attr_truncate.  (Yura)
 | 
			
		||||
	- Add support of MS_NOATIME flag to ntfs_mount().  (Yura)
 | 
			
		||||
 | 
			
		||||
10/10/2005 - 1.12.1 - Minor fix to location of mount.ntfs-fuse and mkfs.ntfs.
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -82,6 +82,7 @@ typedef enum {
 | 
			
		|||
	NV_ReadOnly,		/* 1: Volume is read-only. */
 | 
			
		||||
	NV_CaseSensitive,	/* 1: Volume is mounted case-sensitive. */
 | 
			
		||||
	NV_LogFileEmpty,	/* 1: $logFile journal is empty. */
 | 
			
		||||
	NV_NoATime,		/* 1: Do not update access time. */
 | 
			
		||||
} ntfs_volume_state_bits;
 | 
			
		||||
 | 
			
		||||
#define  test_nvol_flag(nv, flag)	 test_bit(NV_##flag, (nv)->state)
 | 
			
		||||
| 
						 | 
				
			
			@ -100,11 +101,15 @@ typedef enum {
 | 
			
		|||
#define NVolSetLogFileEmpty(nv)		  set_nvol_flag(nv, LogFileEmpty)
 | 
			
		||||
#define NVolClearLogFileEmpty(nv)	clear_nvol_flag(nv, LogFileEmpty)
 | 
			
		||||
 | 
			
		||||
#define NVolNoATime(nv)			 test_nvol_flag(nv, NoATime)
 | 
			
		||||
#define NVolSetNoATime(nv)		  set_nvol_flag(nv, NoATime)
 | 
			
		||||
#define NVolClearNoATime(nv)		clear_nvol_flag(nv, NoATime)
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * NTFS version 1.1 and 1.2 are used by Windows NT4.
 | 
			
		||||
 * NTFS version 2.x is used by Windows 2000 Beta
 | 
			
		||||
 * NTFS version 3.0 is used by Windows 2000.
 | 
			
		||||
 * NTFS version 3.1 is used by Windows XP, Windows Server 2003 and Longhorn.
 | 
			
		||||
 * NTFS version 3.1 is used by Windows XP, 2003 and Vista.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#define NTFS_V1_1(major, minor) ((major) == 1 && (minor) == 1)
 | 
			
		||||
| 
						 | 
				
			
			@ -200,13 +205,13 @@ struct _ntfs_volume {
 | 
			
		|||
extern ntfs_volume *ntfs_volume_alloc(void);
 | 
			
		||||
 | 
			
		||||
extern ntfs_volume *ntfs_volume_startup(struct ntfs_device *dev,
 | 
			
		||||
		unsigned long rwflag);
 | 
			
		||||
		unsigned long flags);
 | 
			
		||||
 | 
			
		||||
extern ntfs_volume *ntfs_device_mount(struct ntfs_device *dev,
 | 
			
		||||
		unsigned long rwflag);
 | 
			
		||||
		unsigned long flags);
 | 
			
		||||
extern int ntfs_device_umount(ntfs_volume *vol, const BOOL force);
 | 
			
		||||
 | 
			
		||||
extern ntfs_volume *ntfs_mount(const char *name, unsigned long rwflag);
 | 
			
		||||
extern ntfs_volume *ntfs_mount(const char *name, unsigned long flags);
 | 
			
		||||
extern int ntfs_umount(ntfs_volume *vol, const BOOL force);
 | 
			
		||||
 | 
			
		||||
extern int ntfs_version_is_supported(ntfs_volume *vol);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -770,8 +770,10 @@ s64 ntfs_attr_pread(ntfs_attr *na, const s64 pos, s64 count, void *b)
 | 
			
		|||
		errno = EACCES;
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	vol = na->ni->vol;
 | 
			
		||||
	/* Update access time if accessing unnamed data attribute. */
 | 
			
		||||
	if (na->type == AT_DATA && na->name == AT_UNNAMED) {
 | 
			
		||||
	if (!NVolReadOnly(vol) && !NVolNoATime(vol) && na->type == AT_DATA &&
 | 
			
		||||
			na->name == AT_UNNAMED) {
 | 
			
		||||
		na->ni->last_access_time = time(NULL);
 | 
			
		||||
		NInoFileNameSetDirty(na->ni);
 | 
			
		||||
		NInoSetDirty(na->ni);
 | 
			
		||||
| 
						 | 
				
			
			@ -784,7 +786,6 @@ s64 ntfs_attr_pread(ntfs_attr *na, const s64 pos, s64 count, void *b)
 | 
			
		|||
			return 0;
 | 
			
		||||
		count = na->data_size - pos;
 | 
			
		||||
	}
 | 
			
		||||
	vol = na->ni->vol;
 | 
			
		||||
	/* If it is a resident attribute, get the value from the mft record. */
 | 
			
		||||
	if (!NAttrNonResident(na)) {
 | 
			
		||||
		ntfs_attr_search_ctx *ctx;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -384,7 +384,7 @@ error_exit:
 | 
			
		|||
/**
 | 
			
		||||
 * ntfs_volume_startup - allocate and setup an ntfs volume
 | 
			
		||||
 * @dev:	device to open
 | 
			
		||||
 * @rwflag:	optional mount flags
 | 
			
		||||
 * @flags:	optional mount flags
 | 
			
		||||
 *
 | 
			
		||||
 * Load, verify, and parse bootsector; load and setup $MFT and $MFTMirr. After
 | 
			
		||||
 * calling this function, the volume is setup sufficiently to call all read
 | 
			
		||||
| 
						 | 
				
			
			@ -393,7 +393,7 @@ error_exit:
 | 
			
		|||
 * Return the allocated volume structure on success and NULL on error with
 | 
			
		||||
 * errno set to the error code.
 | 
			
		||||
 */
 | 
			
		||||
ntfs_volume *ntfs_volume_startup(struct ntfs_device *dev, unsigned long rwflag)
 | 
			
		||||
ntfs_volume *ntfs_volume_startup(struct ntfs_device *dev, unsigned long flags)
 | 
			
		||||
{
 | 
			
		||||
	LCN mft_zone_size, mft_lcn;
 | 
			
		||||
	s64 br;
 | 
			
		||||
| 
						 | 
				
			
			@ -429,8 +429,10 @@ ntfs_volume *ntfs_volume_startup(struct ntfs_device *dev, unsigned long rwflag)
 | 
			
		|||
	}
 | 
			
		||||
	ntfs_upcase_table_build(vol->upcase,
 | 
			
		||||
			vol->upcase_len * sizeof(ntfschar));
 | 
			
		||||
	if ((rwflag & MS_RDONLY) == MS_RDONLY)
 | 
			
		||||
	if (flags & MS_RDONLY)
 | 
			
		||||
		NVolSetReadOnly(vol);
 | 
			
		||||
	if (flags & MS_NOATIME)
 | 
			
		||||
		NVolSetNoATime(vol);
 | 
			
		||||
	ntfs_log_debug("Reading bootsector... ");
 | 
			
		||||
	if (dev->d_ops->open(dev, NVolReadOnly(vol) ? O_RDONLY: O_RDWR)) {
 | 
			
		||||
		ntfs_log_debug(FAILED);
 | 
			
		||||
| 
						 | 
				
			
			@ -730,15 +732,16 @@ out:
 | 
			
		|||
/**
 | 
			
		||||
 * ntfs_device_mount - open ntfs volume
 | 
			
		||||
 * @dev:	device to open
 | 
			
		||||
 * @rwflag:	optional mount flags
 | 
			
		||||
 * @flags:	optional mount flags
 | 
			
		||||
 *
 | 
			
		||||
 * This function mounts an ntfs volume. @dev should describe the device which
 | 
			
		||||
 * to mount as the ntfs volume.
 | 
			
		||||
 *
 | 
			
		||||
 * @rwflags is an optional second parameter. The same flags are used as for
 | 
			
		||||
 * the mount system call (man 2 mount). Currently only the following flag
 | 
			
		||||
 * is implemented:
 | 
			
		||||
 * @flags is an optional second parameter. The same flags are used as for
 | 
			
		||||
 * the mount system call (man 2 mount). Currently only the following flags
 | 
			
		||||
 * are implemented:
 | 
			
		||||
 *	MS_RDONLY	- mount volume read-only
 | 
			
		||||
 *	MS_NOATIME	- do not update access time
 | 
			
		||||
 *
 | 
			
		||||
 * The function opens the device @dev and verifies that it contains a valid
 | 
			
		||||
 * bootsector. Then, it allocates an ntfs_volume structure and initializes
 | 
			
		||||
| 
						 | 
				
			
			@ -749,7 +752,7 @@ out:
 | 
			
		|||
 * Return the allocated volume structure on success and NULL on error with
 | 
			
		||||
 * errno set to the error code.
 | 
			
		||||
 */
 | 
			
		||||
ntfs_volume *ntfs_device_mount(struct ntfs_device *dev, unsigned long rwflag)
 | 
			
		||||
ntfs_volume *ntfs_device_mount(struct ntfs_device *dev, unsigned long flags)
 | 
			
		||||
{
 | 
			
		||||
	s64 l;
 | 
			
		||||
#ifndef NTFS_DISABLE_DEBUG_LOGGING
 | 
			
		||||
| 
						 | 
				
			
			@ -767,7 +770,7 @@ ntfs_volume *ntfs_device_mount(struct ntfs_device *dev, unsigned long rwflag)
 | 
			
		|||
	int i, j, eo;
 | 
			
		||||
	u32 u;
 | 
			
		||||
 | 
			
		||||
	vol = ntfs_volume_startup(dev, rwflag);
 | 
			
		||||
	vol = ntfs_volume_startup(dev, flags);
 | 
			
		||||
	if (!vol) {
 | 
			
		||||
		ntfs_log_perror("Failed to startup volume");
 | 
			
		||||
		return NULL;
 | 
			
		||||
| 
						 | 
				
			
			@ -1101,7 +1104,7 @@ ntfs_volume *ntfs_device_mount(struct ntfs_device *dev, unsigned long rwflag)
 | 
			
		|||
	 * Check for dirty logfile and hibernated Windows.
 | 
			
		||||
	 * We care only about read-write mounts.
 | 
			
		||||
	 */
 | 
			
		||||
	if (!(rwflag & MS_RDONLY)) {
 | 
			
		||||
	if (!(flags & MS_RDONLY)) {
 | 
			
		||||
		if (ntfs_volume_check_logfile(vol) < 0)
 | 
			
		||||
			goto error_exit;
 | 
			
		||||
		if (ntfs_volume_check_hiberfile(vol) < 0)
 | 
			
		||||
| 
						 | 
				
			
			@ -1125,15 +1128,16 @@ error_exit:
 | 
			
		|||
/**
 | 
			
		||||
 * ntfs_mount - open ntfs volume
 | 
			
		||||
 * @name:	name of device/file to open
 | 
			
		||||
 * @rwflag:	optional mount flags
 | 
			
		||||
 * @flags:	optional mount flags
 | 
			
		||||
 *
 | 
			
		||||
 * This function mounts an ntfs volume. @name should contain the name of the
 | 
			
		||||
 * device/file to mount as the ntfs volume.
 | 
			
		||||
 *
 | 
			
		||||
 * @rwflags is an optional second parameter. The same flags are used as for
 | 
			
		||||
 * the mount system call (man 2 mount). Currently only the following flag
 | 
			
		||||
 * is implemented:
 | 
			
		||||
 * @flags is an optional second parameter. The same flags are used as for
 | 
			
		||||
 * the mount system call (man 2 mount). Currently only the following flags
 | 
			
		||||
 * are implemented:
 | 
			
		||||
 *	MS_RDONLY	- mount volume read-only
 | 
			
		||||
 *	MS_NOATIME	- do not update access time
 | 
			
		||||
 *
 | 
			
		||||
 * 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
 | 
			
		||||
| 
						 | 
				
			
			@ -1148,7 +1152,7 @@ error_exit:
 | 
			
		|||
 * soon as the function returns.
 | 
			
		||||
 */
 | 
			
		||||
ntfs_volume *ntfs_mount(const char *name __attribute__((unused)),
 | 
			
		||||
		unsigned long rwflag __attribute__((unused)))
 | 
			
		||||
		unsigned long flags __attribute__((unused)))
 | 
			
		||||
{
 | 
			
		||||
#ifndef NO_NTFS_DEVICE_DEFAULT_IO_OPS
 | 
			
		||||
	struct ntfs_device *dev;
 | 
			
		||||
| 
						 | 
				
			
			@ -1159,7 +1163,7 @@ ntfs_volume *ntfs_mount(const char *name __attribute__((unused)),
 | 
			
		|||
	if (!dev)
 | 
			
		||||
		return NULL;
 | 
			
		||||
	/* Call ntfs_device_mount() to do the actual mount. */
 | 
			
		||||
	vol = ntfs_device_mount(dev, rwflag);
 | 
			
		||||
	vol = ntfs_device_mount(dev, flags);
 | 
			
		||||
	if (!vol) {
 | 
			
		||||
		int eo = errno;
 | 
			
		||||
		ntfs_device_free(dev);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue