Changes by: yura
Update of /cvs/linux-ntfs/ntfsprogs/libntfs
In directory delta357:/tmp/cvs-serv12327/libntfs
Modified Files:
dir.c gnome-vfs-method.c volume.c
Log Message:
* Rename MS_{RDONLY,NOATIME} to NTFS_MNT_{RDONLY,NOATIME}.
* Introduce NTFS_MNT_CASE_SENSITIVE.
Index: dir.c
===================================================================
RCS file: /cvs/linux-ntfs/ntfsprogs/libntfs/dir.c,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -p -r1.74 -r1.75
--- dir.c 1 Nov 2006 22:37:31 -0000 1.74
+++ dir.c 12 Nov 2006 22:46:50 -0000 1.75
@@ -126,10 +126,11 @@ u64 ntfs_inode_lookup_by_name(ntfs_inode
return -1;
/* Find the index root attribute in the mft record. */
- if (ntfs_attr_lookup(AT_INDEX_ROOT, NTFS_INDEX_I30, 4, CASE_SENSITIVE, 0, NULL,
- 0, ctx)) {
- ntfs_log_perror("Index root attribute missing in directory inode "
- "0x%llx", (unsigned long long)dir_ni->mft_no);
+ if (ntfs_attr_lookup(AT_INDEX_ROOT, NTFS_INDEX_I30, 4, CASE_SENSITIVE,
+ 0, NULL, 0, ctx)) {
+ ntfs_log_perror("Index root attribute missing in directory "
+ "inode 0x%llx", (unsigned long long)dir_ni->
+ mft_no);
goto put_err_out;
}
/* Get to the index root value. */
@@ -263,9 +264,9 @@ found_it:
/* Open the index allocation attribute. */
ia_na = ntfs_attr_open(dir_ni, AT_INDEX_ALLOCATION, NTFS_INDEX_I30, 4);
if (!ia_na) {
- ntfs_log_perror("Failed to open index allocation attribute. Directory "
- "inode 0x%llx is corrupt or driver bug",
- (unsigned long long)dir_ni->mft_no);
+ ntfs_log_perror("Failed to open index allocation attribute. "
+ "Directory inode 0x%llx is corrupt or driver "
+ "bug", (unsigned long long)dir_ni->mft_no);
goto put_err_out;
}
@@ -302,28 +303,30 @@ descend_into_child_node:
}
if (sle64_to_cpu(ia->index_block_vcn) != vcn) {
- ntfs_log_debug("Actual VCN (0x%llx) of index buffer is different "
- "from expected VCN (0x%llx).\n",
+ ntfs_log_debug("Actual VCN (0x%llx) of index buffer is "
+ "different from expected VCN (0x%llx).\n",
(long long)sle64_to_cpu(ia->index_block_vcn),
(long long)vcn);
errno = EIO;
goto close_err_out;
}
if (le32_to_cpu(ia->index.allocated_size) + 0x18 != index_block_size) {
- ntfs_log_debug("Index buffer (VCN 0x%llx) of directory inode 0x%llx "
- "has a size (%u) differing from the directory "
- "specified size (%u).\n", (long long)vcn,
- (unsigned long long)dir_ni->mft_no,
- (unsigned) le32_to_cpu(ia->index.allocated_size) + 0x18,
- (unsigned)index_block_size);
+ ntfs_log_debug("Index buffer (VCN 0x%llx) of directory inode "
+ "0x%llx has a size (%u) differing from the "
+ "directory specified size (%u).\n",
+ (long long)vcn, (unsigned long long)dir_ni->
+ mft_no, (unsigned)le32_to_cpu(ia->index.
+ allocated_size) + 0x18, (unsigned)
+ index_block_size);
errno = EIO;
goto close_err_out;
}
index_end = (u8*)&ia->index + le32_to_cpu(ia->index.index_length);
if (index_end > (u8*)ia + index_block_size) {
- ntfs_log_debug("Size of index buffer (VCN 0x%llx) of directory inode "
- "0x%llx exceeds maximum size.\n",
- (long long)vcn, (unsigned long long)dir_ni->mft_no);
+ ntfs_log_debug("Size of index buffer (VCN 0x%llx) of directory "
+ "inode 0x%llx exceeds maximum size.\n",
+ (long long)vcn, (unsigned long long)dir_ni->
+ mft_no);
errno = EIO;
goto close_err_out;
}
@@ -444,8 +447,9 @@ found_it2:
*/
if (ie->flags & INDEX_ENTRY_NODE) {
if ((ia->index.flags & NODE_MASK) == LEAF_NODE) {
- ntfs_log_debug("Index entry with child node found in a leaf "
- "node in directory inode 0x%llx.\n",
+ ntfs_log_debug("Index entry with child node found in a "
+ "leaf node in directory inode "
+ "0x%llx.\n",
(unsigned long long)dir_ni->mft_no);
errno = EIO;
goto close_err_out;
@@ -455,7 +459,8 @@ found_it2:
if (vcn >= 0)
goto descend_into_child_node;
ntfs_log_debug("Negative child node vcn in directory inode "
- "0x%llx.\n", (unsigned long long)dir_ni->mft_no);
+ "0x%llx.\n", (unsigned long long)dir_ni->
+ mft_no);
errno = EIO;
goto close_err_out;
}
@@ -700,8 +705,9 @@ static MFT_REF ntfs_mft_get_parent_ref(n
goto err_out;
}
if (ctx->attr->non_resident) {
- ntfs_log_debug("File name attribute must be resident. Corrupt inode "
- "0x%llx.\n", (unsigned long long)ni->mft_no);
+ ntfs_log_debug("File name attribute must be resident. "
+ "Corrupt inode 0x%llx.\n",
+ (unsigned long long)ni->mft_no);
goto io_err_out;
}
fn = (FILE_NAME_ATTR*)((u8*)ctx->attr +
@@ -824,10 +830,11 @@ int ntfs_readdir(ntfs_inode *dir_ni, s64
/* Get the offset into the index root attribute. */
ir_pos = (int)*pos;
/* Find the index root attribute in the mft record. */
- if (ntfs_attr_lookup(AT_INDEX_ROOT, NTFS_INDEX_I30, 4, CASE_SENSITIVE, 0, NULL,
- 0, ctx)) {
- ntfs_log_debug("Index root attribute missing in directory inode "
- "0x%llx.\n", (unsigned long long)dir_ni->mft_no);
+ if (ntfs_attr_lookup(AT_INDEX_ROOT, NTFS_INDEX_I30, 4, CASE_SENSITIVE,
+ 0, NULL, 0, ctx)) {
+ ntfs_log_debug("Index root attribute missing in directory "
+ "inode 0x%llx.\n", (unsigned long long)dir_ni->
+ mft_no);
goto dir_err_out;
}
/* Get to the index root value. */
@@ -868,7 +875,8 @@ int ntfs_readdir(ntfs_inode *dir_ni, s64
* or signals an error (both covered by the rc test).
*/
for (;; ie = (INDEX_ENTRY*)((u8*)ie + le16_to_cpu(ie->length))) {
- ntfs_log_debug("In index root, offset 0x%x.\n", (u8*)ie - (u8*)ir);
+ ntfs_log_debug("In index root, offset 0x%x.\n",
+ (u8*)ie - (u8*)ir);
/* Bounds checks. */
if ((u8*)ie < (u8*)ctx->mrec || (u8*)ie +
sizeof(INDEX_ENTRY_HEADER) > index_end ||
@@ -965,7 +973,8 @@ find_next_index_buffer:
if (br != bmp_buf_size) {
if (br != -1)
errno = EIO;
- ntfs_log_perror("Failed to read from index bitmap attribute");
+ ntfs_log_perror("Failed to read from index bitmap "
+ "attribute");
goto err_out;
}
}
@@ -985,18 +994,19 @@ find_next_index_buffer:
ia_start = ia_pos & ~(s64)(index_block_size - 1);
if (sle64_to_cpu(ia->index_block_vcn) != ia_start >>
index_vcn_size_bits) {
- ntfs_log_debug("Actual VCN (0x%llx) of index buffer is different "
- "from expected VCN (0x%llx) in inode 0x%llx.\n",
+ ntfs_log_debug("Actual VCN (0x%llx) of index buffer is "
+ "different from expected VCN (0x%llx) in "
+ "inode 0x%llx.\n",
(long long)sle64_to_cpu(ia->index_block_vcn),
(long long)ia_start >> index_vcn_size_bits,
(unsigned long long)dir_ni->mft_no);
goto dir_err_out;
}
if (le32_to_cpu(ia->index.allocated_size) + 0x18 != index_block_size) {
- ntfs_log_debug("Index buffer (VCN 0x%llx) of directory inode 0x%llx "
- "has a size (%u) differing from the directory "
- "specified size (%u).\n", (long long)ia_start >>
- index_vcn_size_bits,
+ ntfs_log_debug("Index buffer (VCN 0x%llx) of directory inode "
+ "0x%llx has a size (%u) differing from the "
+ "directory specified size (%u).\n",
+ (long long)ia_start >> index_vcn_size_bits,
(unsigned long long)dir_ni->mft_no,
(unsigned) le32_to_cpu(ia->index.allocated_size)
+ 0x18, (unsigned)index_block_size);
@@ -1004,8 +1014,8 @@ find_next_index_buffer:
}
index_end = (u8*)&ia->index + le32_to_cpu(ia->index.index_length);
if (index_end > (u8*)ia + index_block_size) {
- ntfs_log_debug("Size of index buffer (VCN 0x%llx) of directory inode "
- "0x%llx exceeds maximum size.\n",
+ ntfs_log_debug("Size of index buffer (VCN 0x%llx) of directory "
+ "inode 0x%llx exceeds maximum size.\n",
(long long)ia_start >> index_vcn_size_bits,
(unsigned long long)dir_ni->mft_no);
goto dir_err_out;
@@ -1026,8 +1036,9 @@ find_next_index_buffer:
sizeof(INDEX_ENTRY_HEADER) > index_end ||
(u8*)ie + le16_to_cpu(ie->key_length) >
index_end) {
- ntfs_log_debug("Index entry out of bounds in directory inode "
- "0x%llx.\n", (unsigned long long)dir_ni->mft_no);
+ ntfs_log_debug("Index entry out of bounds in directory "
+ "inode 0x%llx.\n", (unsigned long long)
+ dir_ni->mft_no);
goto dir_err_out;
}
/* The last entry cannot contain a name. */
@@ -1058,10 +1069,11 @@ done:
ntfs_attr_close(ia_na);
#ifdef DEBUG
if (!rc)
- ntfs_log_debug("EOD, *pos 0x%llx, returning 0.\n", (long long)*pos);
+ ntfs_log_debug("EOD, *pos 0x%llx, returning 0.\n",
+ (long long)*pos);
else
- ntfs_log_debug("filldir returned %i, *pos 0x%llx, returning 0.\n",
- rc, (long long)*pos);
+ ntfs_log_debug("filldir returned %i, *pos 0x%llx, "
+ "returning 0.\n", rc, (long long)*pos);
#endif
return 0;
dir_err_out:
@@ -1483,8 +1495,8 @@ int ntfs_delete(ntfs_inode *ni, ntfs_ino
* WIN32_AND_DOS namespace, then simply remove it from index and inode.
* If filename in DOS or in WIN32 namespace, then remove DOS name first,
* only then remove WIN32 name. Mark WIN32 name as POSIX name to prevent
- * chkdsk to complain about DOS name absentation, in case if DOS name
- * had been successfully deleted, but WIN32 name removing failed.
+ * chkdsk to complain about DOS name absence in case if DOS name had
+ * been successfully deleted, but WIN32 name remove failed.
*/
actx = ntfs_attr_get_search_ctx(ni, NULL);
if (!actx)
@@ -1530,10 +1542,11 @@ search:
}
if (errno) {
/*
- * If case sensitive search failed, then try once again
- * ignoring case.
+ * If case sensitive search failed and volume mounted case
+ * insensitive, then try once again ignoring case.
*/
- if (errno == ENOENT && case_sensitive_match) {
+ if (errno == ENOENT && !NVolCaseSensitive(ni->vol) &&
+ case_sensitive_match) {
case_sensitive_match = FALSE;
ntfs_attr_reinit_search_ctx(actx);
ntfs_log_trace("Restart search. Ignore case.");
@@ -1556,7 +1569,7 @@ search:
/*
* Do not allow non-empty directory deletion if hard links count
* is 1 (always) or 2 (in case if filename in DOS namespace,
- * because we delete it first in filen which have both WIN32 and
+ * because we delete it first in file which have both WIN32 and
* DOS names).
*/
if ((na->data_size != sizeof(INDEX_ROOT) + sizeof(
@@ -1598,7 +1611,7 @@ search:
/* Remove FILE_NAME from inode. */
if (ntfs_attr_record_rm(actx))
goto err_out;
- /* Decerement hard link count. */
+ /* Decrement hard link count. */
ni->mrec->link_count = cpu_to_le16(le16_to_cpu(
ni->mrec->link_count) - 1);
ntfs_inode_mark_dirty(ni);
@@ -1611,7 +1624,7 @@ search:
goto search;
} else
ntfs_log_trace("Deleted.\n");
- /* TODO: Update object id, quota and securiry indexes if required. */
+ /* TODO: Update object id, quota and security indexes if required. */
/*
* If hard link count is not equal to zero then we are done. In other
* case there are no reference to this inode left, so we should free all
@@ -1687,8 +1700,8 @@ err_out:
* @name: unicode name of the new link
* @name_len: length of the name in unicode characters
*
- * NOTE: At present we allow creating hardlinks to directories, we use them
- * in a temporary state during rename. But it's defenitely bad idea to have
+ * NOTE: At present we allow creating hard links to directories, we use them
+ * in a temporary state during rename. But it's definitely bad idea to have
* hard links to directories as a result of operation.
* FIXME: Create internal __ntfs_link that allows hard links to a directories
* and external ntfs_link that do not. Write ntfs_rename that uses __ntfs_link.
@@ -1705,7 +1718,7 @@ int ntfs_link(ntfs_inode *ni, ntfs_inode
if (!ni || !dir_ni || !name || !name_len ||
ni->mft_no == dir_ni->mft_no) {
err = EINVAL;
- ntfs_log_perror("ntfs_link wrong arguments");
+ ntfs_log_error("Invalid arguments.");
goto err_out;
}
/* Create FILE_NAME attribute. */
Index: gnome-vfs-method.c
===================================================================
RCS file: /cvs/linux-ntfs/ntfsprogs/libntfs/gnome-vfs-method.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -p -r1.8 -r1.9
--- gnome-vfs-method.c 3 Feb 2006 22:19:19 -0000 1.8
+++ gnome-vfs-method.c 12 Nov 2006 22:46:50 -0000 1.9
@@ -162,7 +162,8 @@ static GnomeVFSResult libntfs_gnomevfs_u
return GNOME_VFS_ERROR_INVALID_URI;
}
- if (!(volume = ntfs_mount(uri->parent->text, MS_RDONLY))) {
+ if (!(volume = ntfs_mount(uri->parent->text,
+ NTFS_MNT_RDONLY))) {
g_free(uri_parent_string);
return GNOME_VFS_ERROR_WRONG_FORMAT;
}
Index: volume.c
===================================================================
RCS file: /cvs/linux-ntfs/ntfsprogs/libntfs/volume.c,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -p -r1.74 -r1.75
--- volume.c 1 Nov 2006 13:30:40 -0000 1.74
+++ volume.c 12 Nov 2006 22:46:50 -0000 1.75
@@ -117,7 +117,7 @@ static void __ntfs_volume_release(ntfs_v
if (NDevDirty(dev))
dev->d_ops->sync(dev);
if (dev->d_ops->close(dev))
- ntfs_log_perror("Eeek! Failed to close the device. Error: ");
+ ntfs_log_perror("Failed to close the device. Error: ");
}
free(v->vol_name);
free(v->upcase);
@@ -399,7 +399,8 @@ 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 flags)
+ntfs_volume *ntfs_volume_startup(struct ntfs_device *dev,
+ ntfs_mount_flags flags)
{
LCN mft_zone_size, mft_lcn;
s64 br;
@@ -435,10 +436,12 @@ ntfs_volume *ntfs_volume_startup(struct
ntfs_upcase_table_build(vol->upcase,
vol->upcase_len * sizeof(ntfschar));
- if (flags & MS_RDONLY)
+ if (flags & NTFS_MNT_RDONLY)
NVolSetReadOnly(vol);
- if (flags & MS_NOATIME)
+ if (flags & NTFS_MNT_NOATIME)
NVolSetNoATime(vol);
+ 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)) {
ntfs_log_debug(FAILED);
@@ -746,11 +749,13 @@ out:
* This function mounts an ntfs volume. @dev should describe the device which
* to mount as the ntfs volume.
*
- * @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
+ * @flags is an optional second parameter. Some flags are similar to flags used
+ * as for the mount system call (man 2 mount). Currently the following flags
* are implemented:
- * MS_RDONLY - mount volume read-only
- * MS_NOATIME - do not update access time
+ * NTFS_MNT_RDONLY - mount volume read-only
+ * 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
*
* The function opens the device @dev and verifies that it contains a valid
* bootsector. Then, it allocates an ntfs_volume structure and initializes
@@ -761,7 +766,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 flags)
+ntfs_volume *ntfs_device_mount(struct ntfs_device *dev, ntfs_mount_flags flags)
{
s64 l;
#ifndef NTFS_DISABLE_DEBUG_LOGGING
@@ -936,8 +941,8 @@ ntfs_volume *ntfs_device_mount(struct nt
l = ntfs_attr_pread(na, 0, na->data_size, vol->upcase);
if (l != na->data_size) {
ntfs_log_debug(FAILED);
- ntfs_log_debug("Amount of data read does not correspond to expected "
- "length!\n");
+ ntfs_log_debug("Amount of data read does not correspond to "
+ "expected length!\n");
errno = EIO;
goto error_exit;
}
@@ -990,8 +995,8 @@ ntfs_volume *ntfs_device_mount(struct nt
le16_to_cpu(a->value_offset) + le32_to_cpu(
a->value_length) > le32_to_cpu(a->length)) {
ntfs_log_debug(FAILED);
- ntfs_log_debug("Error: Attribute $VOLUME_INFORMATION in $Volume is "
- "corrupt!\n");
+ ntfs_log_debug("Error: Attribute $VOLUME_INFORMATION in "
+ "$Volume is corrupt!\n");
errno = EIO;
goto error_exit;
}
@@ -1009,9 +1014,10 @@ ntfs_volume *ntfs_device_mount(struct nt
ctx)) {
if (errno != ENOENT) {
ntfs_log_debug(FAILED);
- ntfs_log_debug("Error: Lookup of $VOLUME_NAME attribute in "
- "$Volume failed. This probably means "
- "something is corrupt. Run chkdsk.\n");
+ ntfs_log_debug("Error: Lookup of $VOLUME_NAME "
+ "attribute in $Volume failed. "
+ "This probably means something is "
+ "corrupt. Run chkdsk.\n");
goto error_exit;
}
/*
@@ -1044,8 +1050,8 @@ ntfs_volume *ntfs_device_mount(struct nt
*/
vol->vol_name = NULL;
if (ntfs_ucstombs(vname, u, &vol->vol_name, 0) == -1) {
- ntfs_log_perror("Error: Volume name could not be converted "
- "to current locale");
+ ntfs_log_perror("Error: Volume name could not be "
+ "converted to current locale");
ntfs_log_debug("Forcing name into ASCII by replacing "
"non-ASCII characters with underscores.\n");
vol->vol_name = ntfs_malloc(u + 1);
@@ -1083,8 +1089,8 @@ ntfs_volume *ntfs_device_mount(struct nt
/* Check we don't overflow 32-bits. */
if (na->data_size > 0xffffffffLL) {
ntfs_log_debug(FAILED);
- ntfs_log_debug("Error: Attribute definition table is too big (max "
- "32-bit allowed).\n");
+ ntfs_log_debug("Error: Attribute definition table is too big "
+ "(max 32-bit allowed).\n");
errno = EINVAL;
goto error_exit;
}
@@ -1098,8 +1104,8 @@ ntfs_volume *ntfs_device_mount(struct nt
l = ntfs_attr_pread(na, 0, na->data_size, vol->attrdef);
if (l != na->data_size) {
ntfs_log_debug(FAILED);
- ntfs_log_debug("Amount of data read does not correspond to expected "
- "length!\n");
+ ntfs_log_debug("Amount of data read does not correspond to "
+ "expected length!\n");
errno = EIO;
goto error_exit;
}
@@ -1112,7 +1118,7 @@ ntfs_volume *ntfs_device_mount(struct nt
* Check for dirty logfile and hibernated Windows.
* We care only about read-write mounts.
*/
- if (!(flags & MS_RDONLY)) {
+ if (!(flags & NTFS_MNT_RDONLY)) {
if (ntfs_volume_check_logfile(vol) < 0)
goto error_exit;
if (ntfs_volume_check_hiberfile(vol) < 0)
@@ -1141,11 +1147,13 @@ error_exit:
* This function mounts an ntfs volume. @name should contain the name of the
* device/file to mount as the ntfs volume.
*
- * @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
+ * @flags is an optional second parameter. Some flags are similar to flags used
+ * as for the mount system call (man 2 mount). Currently the following flags
* are implemented:
- * MS_RDONLY - mount volume read-only
- * MS_NOATIME - do not update access time
+ * NTFS_MNT_RDONLY - mount volume read-only
+ * 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
*
* 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
@@ -1160,7 +1168,7 @@ error_exit:
* soon as the function returns.
*/
ntfs_volume *ntfs_mount(const char *name __attribute__((unused)),
- unsigned long flags __attribute__((unused)))
+ ntfs_mount_flags flags __attribute__((unused)))
{
#ifndef NO_NTFS_DEVICE_DEFAULT_IO_OPS
struct ntfs_device *dev;
@@ -1378,7 +1386,7 @@ int ntfs_check_if_mounted(const char *fi
* Version 1.1 and 1.2 are used by Windows NT3.x and NT4.
* Version 2.x is used by Windows 2000 Betas.
* Version 3.0 is used by Windows 2000.
- * Version 3.1 is used by Windows XP, Windows Server 2003 and Longhorn.
+ * Version 3.1 is used by Windows XP, Windows Server 2003 and Vista.
*
* Return 0 if NTFS version is supported otherwise -1 with errno set.
*
|