Changes by: antona
Update of /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27122/ntfsprogs
Modified Files:
cluster.c mkntfs.c ntfsclone.c ntfscmp.c ntfsfix.8.in
ntfsfix.c ntfsinfo.c ntfslabel.c ntfsls.c ntfsmove.c
ntfsresize.c ntfsrm.c ntfswipe.c utils.c
Log Message:
Megapatch!!! Check evecrything!!! I probably broke everything!!!
Index: cluster.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/cluster.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -p -r1.6 -r1.7
--- cluster.c 20 Aug 2004 12:04:47 -0000 1.6
+++ cluster.c 24 Sep 2005 22:54:55 -0000 1.7
@@ -81,7 +81,7 @@ int cluster_find (ntfs_volume *vol, LCN
Vprintf ("Inode: %llu\n", (unsigned long long)
m_ctx->inode->mft_no);
- a_ctx = ntfs_attr_get_search_ctx (NULL, m_ctx->inode->mrec);
+ a_ctx = ntfs_attr_get_search_ctx (m_ctx->inode, NULL);
while ((rec = find_attribute (AT_UNUSED, a_ctx))) {
Index: mkntfs.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/mkntfs.c,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -p -r1.64 -r1.65
--- mkntfs.c 4 Aug 2005 09:59:43 -0000 1.64
+++ mkntfs.c 24 Sep 2005 22:54:55 -0000 1.65
@@ -1181,6 +1181,297 @@ err_end:
}
/**
+ * Internal:
+ *
+ * ntfs_attr_find - find (next) attribute in mft record
+ * @type: attribute type to find
+ * @name: attribute name to find (optional, i.e. NULL means don't care)
+ * @name_len: attribute name length (only needed if @name present)
+ * @ic: IGNORE_CASE or CASE_SENSITIVE (ignored if @name not present)
+ * @val: attribute value to find (optional, resident attributes only)
+ * @val_len: attribute value length
+ * @ctx: search context with mft record and attribute to search from
+ *
+ * You shouldn't need to call this function directly. Use lookup_attr() instead.
+ *
+ * ntfs_attr_find() takes a search context @ctx as parameter and searches the
+ * mft record specified by @ctx->mrec, beginning at @ctx->attr, for an
+ * attribute of @type, optionally @name and @val. If found, ntfs_attr_find()
+ * returns 0 and @ctx->attr will point to the found attribute.
+ *
+ * If not found, ntfs_attr_find() returns -1, with errno set to ENOENT and
+ * @ctx->attr will point to the attribute before which the attribute being
+ * searched for would need to be inserted if such an action were to be desired.
+ *
+ * On actual error, ntfs_attr_find() returns -1 with errno set to the error
+ * code but not to ENOENT. In this case @ctx->attr is undefined and in
+ * particular do not rely on it not changing.
+ *
+ * If @ctx->is_first is TRUE, the search begins with @ctx->attr itself. If it
+ * is FALSE, the search begins after @ctx->attr.
+ *
+ * If @type is AT_UNUSED, return the first found attribute, i.e. one can
+ * enumerate all attributes by setting @type to AT_UNUSED and then calling
+ * ntfs_attr_find() repeatedly until it returns -1 with errno set to ENOENT to
+ * indicate that there are no more entries. During the enumeration, each
+ * successful call of ntfs_attr_find() will return the next attribute in the
+ * mft record @ctx->mrec.
+ *
+ * If @type is AT_END, seek to the end and return -1 with errno set to ENOENT.
+ * AT_END is not a valid attribute, its length is zero for example, thus it is
+ * safer to return error instead of success in this case. This also allows us
+ * to interoperate cleanly with ntfs_external_attr_find().
+ *
+ * If @name is AT_UNNAMED search for an unnamed attribute. If @name is present
+ * but not AT_UNNAMED search for a named attribute matching @name. Otherwise,
+ * match both named and unnamed attributes.
+ *
+ * If @ic is IGNORE_CASE, the @name comparison is not case sensitive and
+ * @ctx->ntfs_ino must be set to the ntfs inode to which the mft record
+ * @ctx->mrec belongs. This is so we can get at the ntfs volume and hence at
+ * the upcase table. If @ic is CASE_SENSITIVE, the comparison is case
+ * sensitive. When @name is present, @name_len is the @name length in Unicode
+ * characters.
+ *
+ * If @name is not present (NULL), we assume that the unnamed attribute is
+ * being searched for.
+ *
+ * Finally, the resident attribute value @val is looked for, if present.
+ * If @val is not present (NULL), @val_len is ignored.
+ *
+ * ntfs_attr_find() only searches the specified mft record and it ignores the
+ * presence of an attribute list attribute (unless it is the one being searched
+ * for, obviously). If you need to take attribute lists into consideration, use
+ * ntfs_attr_lookup() instead (see below). This also means that you cannot use
+ * ntfs_attr_find() to search for extent records of non-resident attributes, as
+ * extents with lowest_vcn != 0 are usually described by the attribute list
+ * attribute only. - Note that it is possible that the first extent is only in
+ * the attribute list while the last extent is in the base mft record, so don't
+ * rely on being able to find the first extent in the base mft record.
+ *
+ * Warning: Never use @val when looking for attribute types which can be
+ * non-resident as this most likely will result in a crash!
+ */
+static int mkntfs_attr_find(const ATTR_TYPES type, const ntfschar *name,
+ const u32 name_len, const IGNORE_CASE_BOOL ic,
+ const u8 *val, const u32 val_len, ntfs_attr_search_ctx *ctx)
+{
+ ATTR_RECORD *a;
+ ntfschar *upcase = vol->upcase;
+ u32 upcase_len = vol->upcase_len;
+
+ /*
+ * Iterate over attributes in mft record starting at @ctx->attr, or the
+ * attribute following that, if @ctx->is_first is TRUE.
+ */
+ if (ctx->is_first) {
+ a = ctx->attr;
+ ctx->is_first = FALSE;
+ } else
+ a = (ATTR_RECORD*)((char*)ctx->attr +
+ le32_to_cpu(ctx->attr->length));
+ for (;; a = (ATTR_RECORD*)((char*)a + le32_to_cpu(a->length))) {
+ if (p2n(a) < p2n(ctx->mrec) || (char*)a > (char*)ctx->mrec +
+ le32_to_cpu(ctx->mrec->bytes_allocated))
+ break;
+ ctx->attr = a;
+ if (((type != AT_UNUSED) && (le32_to_cpu(a->type) >
+ le32_to_cpu(type))) ||
+ (a->type == AT_END)) {
+ errno = ENOENT;
+ return -1;
+ }
+ if (!a->length)
+ break;
+ /* If this is an enumeration return this attribute. */
+ if (type == AT_UNUSED)
+ return 0;
+ if (a->type != type)
+ continue;
+ /*
+ * If @name is AT_UNNAMED we want an unnamed attribute.
+ * If @name is present, compare the two names.
+ * Otherwise, match any attribute.
+ */
+ if (name == AT_UNNAMED) {
+ /* The search failed if the found attribute is named. */
+ if (a->name_length) {
+ errno = ENOENT;
+ return -1;
+ }
+ } else if (name && !ntfs_names_are_equal(name, name_len,
+ (ntfschar*)((char*)a + le16_to_cpu(a->name_offset)),
+ a->name_length, ic, upcase, upcase_len)) {
+ register int rc;
+
+ rc = ntfs_names_collate(name, name_len,
+ (ntfschar*)((char*)a +
+ le16_to_cpu(a->name_offset)),
+ a->name_length, 1, IGNORE_CASE,
+ upcase, upcase_len);
+ /*
+ * If @name collates before a->name, there is no
+ * matching attribute.
+ */
+ if (rc == -1) {
+ errno = ENOENT;
+ return -1;
+ }
+ /* If the strings are not equal, continue search. */
+ if (rc)
+ continue;
+ rc = ntfs_names_collate(name, name_len,
+ (ntfschar*)((char*)a +
+ le16_to_cpu(a->name_offset)),
+ a->name_length, 1, CASE_SENSITIVE,
+ upcase, upcase_len);
+ if (rc == -1) {
+ errno = ENOENT;
+ return -1;
+ }
+ if (rc)
+ continue;
+ }
+ /*
+ * The names match or @name not present and attribute is
+ * unnamed. If no @val specified, we have found the attribute
+ * and are done.
+ */
+ if (!val)
+ return 0;
+ /* @val is present; compare values. */
+ else {
+ register int rc;
+
+ rc = memcmp(val, (char*)a +le16_to_cpu(a->value_offset),
+ min(val_len,
+ le32_to_cpu(a->value_length)));
+ /*
+ * If @val collates before the current attribute's
+ * value, there is no matching attribute.
+ */
+ if (!rc) {
+ register u32 avl;
+ avl = le32_to_cpu(a->value_length);
+ if (val_len == avl)
+ return 0;
+ if (val_len < avl) {
+ errno = ENOENT;
+ return -1;
+ }
+ } else if (rc < 0) {
+ errno = ENOENT;
+ return -1;
+ }
+ }
+ }
+ Dputs("mkntfs_attr_find(): File is corrupt. Run chkdsk.");
+ errno = EIO;
+ return -1;
+}
+
+/**
+ * ntfs_attr_lookup - find an attribute in an ntfs inode
+ * @type: attribute type to find
+ * @name: attribute name to find (optional, i.e. NULL means don't care)
+ * @name_len: attribute name length (only needed if @name present)
+ * @ic: IGNORE_CASE or CASE_SENSITIVE (ignored if @name not present)
+ * @lowest_vcn: lowest vcn to find (optional, non-resident attributes only)
+ * @val: attribute value to find (optional, resident attributes only)
+ * @val_len: attribute value length
+ * @ctx: search context with mft record and attribute to search from
+ *
+ * Find an attribute in an ntfs inode. On first search @ctx->ntfs_ino must
+ * be the base mft record and @ctx must have been obtained from a call to
+ * ntfs_attr_get_search_ctx().
+ *
+ * This function transparently handles attribute lists and @ctx is used to
+ * continue searches where they were left off at.
+ *
+ * If @type is AT_UNUSED, return the first found attribute, i.e. one can
+ * enumerate all attributes by setting @type to AT_UNUSED and then calling
+ * ntfs_attr_lookup() repeatedly until it returns -1 with errno set to ENOENT
+ * to indicate that there are no more entries. During the enumeration, each
+ * successful call of ntfs_attr_lookup() will return the next attribute, with
+ * the current attribute being described by the search context @ctx.
+ *
+ * If @type is AT_END, seek to the end of the base mft record ignoring the
+ * attribute list completely and return -1 with errno set to ENOENT. AT_END is
+ * not a valid attribute, its length is zero for example, thus it is safer to
+ * return error instead of success in this case. It should never ne needed to
+ * do this, but we implement the functionality because it allows for simpler
+ * code inside ntfs_external_attr_find().
+ *
+ * If @name is AT_UNNAMED search for an unnamed attribute. If @name is present
+ * but not AT_UNNAMED search for a named attribute matching @name. Otherwise,
+ * match both named and unnamed attributes.
+ *
+ * After finishing with the attribute/mft record you need to call
+ * ntfs_attr_put_search_ctx() to cleanup the search context (unmapping any
+ * mapped extent inodes, etc).
+ *
+ * Return 0 if the search was successful and -1 if not, with errno set to the
+ * error code.
+ *
+ * On success, @ctx->attr is the found attribute, it is in mft record
+ * @ctx->mrec, and @ctx->al_entry is the attribute list entry for this
+ * attribute with @ctx->base_* being the base mft record to which @ctx->attr
+ * belongs. If no attribute list attribute is present @ctx->al_entry and
+ * @ctx->base_* are NULL.
+ *
+ * On error ENOENT, i.e. attribute not found, @ctx->attr is set to the
+ * attribute which collates just after the attribute being searched for in the
+ * base ntfs inode, i.e. if one wants to add the attribute to the mft record
+ * this is the correct place to insert it into, and if there is not enough
+ * space, the attribute should be placed in an extent mft record.
+ * @ctx->al_entry points to the position within @ctx->base_ntfs_ino->attr_list
+ * at which the new attribute's attribute list entry should be inserted. The
+ * other @ctx fields, base_ntfs_ino, base_mrec, and base_attr are set to NULL.
+ * The only exception to this is when @type is AT_END, in which case
+ * @ctx->al_entry is set to NULL also (see above).
+ *
+ *
+ * The following error codes are defined:
+ * ENOENT Attribute not found, not an error as such.
+ * EINVAL Invalid arguments.
+ * EIO I/O error or corrupt data structures found.
+ * ENOMEM Not enough memory to allocate necessary buffers.
+ */
+int mkntfs_attr_lookup(const ATTR_TYPES type, const ntfschar *name,
+ const u32 name_len, const IGNORE_CASE_BOOL ic,
+ const VCN lowest_vcn, const u8 *val, const u32 val_len,
+ ntfs_attr_search_ctx *ctx)
+{
+ ntfs_inode *base_ni;
+
+ if (!ctx || !ctx->mrec || !ctx->attr) {
+ errno = EINVAL;
+ return -1;
+ }
+ if (ctx->base_ntfs_ino)
+ base_ni = ctx->base_ntfs_ino;
+ else
+ base_ni = ctx->ntfs_ino;
+ if (!base_ni || !NInoAttrList(base_ni) || type == AT_ATTRIBUTE_LIST)
+ return mkntfs_attr_find(type, name, name_len, ic, val, val_len,
+ ctx);
+ errno = EOPNOTSUPP;
+ return -1;
+}
+
+/**
+ * ntfs_attr_put_search_ctx - release an attribute search context
+ * @ctx: attribute search context to free
+ *
+ * Release the attribute search context @ctx.
+ */
+void ntfs_attr_put_search_ctx(ntfs_attr_search_ctx *ctx)
+{
+ free(ctx);
+ return;
+}
+
+/**
* insert_positioned_attr_in_mft_record
* Create a non-resident attribute with a predefined on disk location
* specified by the runlist @rl. The clusters specified by @rl are assumed to
@@ -1229,7 +1520,7 @@ static int insert_positioned_attr_in_mft
err = -EOPNOTSUPP;
goto err_out;
}
- if (!ntfs_attr_lookup(type, uname, name_len, ic, 0, NULL, 0, ctx)) {
+ if (!mkntfs_attr_lookup(type, uname, name_len, ic, 0, NULL, 0, ctx)) {
err = -EEXIST;
goto err_out;
}
@@ -1414,7 +1705,7 @@ static int insert_non_resident_attr_in_m
err = -EOPNOTSUPP;
goto err_out;
}
- if (!ntfs_attr_lookup(type, uname, name_len, ic, 0, NULL, 0, ctx)) {
+ if (!mkntfs_attr_lookup(type, uname, name_len, ic, 0, NULL, 0, ctx)) {
err = -EEXIST;
goto err_out;
}
@@ -1576,7 +1867,7 @@ static int insert_resident_attr_in_mft_r
ntfschar *uname;
/*
if (base record)
- ntfs_attr_lookup();
+ mkntfs_attr_lookup();
else
*/
if (name_len) {
@@ -1603,7 +1894,7 @@ static int insert_resident_attr_in_mft_r
err = -EOPNOTSUPP;
goto err_out;
}
- if (!ntfs_attr_lookup(type, uname, name_len, ic, 0, val, val_len,
+ if (!mkntfs_attr_lookup(type, uname, name_len, ic, 0, val, val_len,
ctx)) {
err = -EEXIST;
goto err_out;
@@ -1726,7 +2017,7 @@ static int add_attr_file_name(MFT_RECORD
Eprintf("Failed to allocate attribute search context.\n");
return -ENOMEM;
}
- if (ntfs_attr_lookup(AT_STANDARD_INFORMATION, AT_UNNAMED, 0, 0, 0, NULL, 0,
+ if (mkntfs_attr_lookup(AT_STANDARD_INFORMATION, AT_UNNAMED, 0, 0, 0, NULL, 0,
ctx)) {
int eo = errno;
Eprintf("BUG: Standard information attribute not present in "
@@ -2126,7 +2417,7 @@ static int upgrade_to_large_index(MFT_RE
free(uname);
goto err_out;
}
- err = ntfs_attr_lookup(AT_INDEX_ROOT, uname, name_len, ic, 0, NULL, 0,
+ err = mkntfs_attr_lookup(AT_INDEX_ROOT, uname, name_len, ic, 0, NULL, 0,
ctx);
if (uname)
free(uname);
@@ -3399,7 +3690,7 @@ static void mkntfs_create_root_structure
err_exit("Failed to allocate attribute search "
"context: %s\n", strerror(errno));
/* There is exactly one file name so this is ok. */
- if (ntfs_attr_lookup(AT_FILE_NAME, AT_UNNAMED, 0, 0, 0, NULL, 0,
+ if (mkntfs_attr_lookup(AT_FILE_NAME, AT_UNNAMED, 0, 0, 0, NULL, 0,
ctx)) {
ntfs_attr_put_search_ctx(ctx);
err_exit("BUG: $FILE_NAME attribute not found.\n");
@@ -3780,7 +4071,7 @@ int main(int argc, char **argv)
err_exit("Failed to allocate attribute search context: %s\n",
strerror(errno));
// FIXME: This should be IGNORE_CASE!
- if (ntfs_attr_lookup(AT_INDEX_ALLOCATION, I30, 4, 0, 0,
+ if (mkntfs_attr_lookup(AT_INDEX_ALLOCATION, I30, 4, 0, 0,
NULL, 0, ctx)) {
ntfs_attr_put_search_ctx(ctx);
err_exit("BUG: $INDEX_ALLOCATION attribute not found.\n");
@@ -3814,7 +4105,7 @@ int main(int argc, char **argv)
if (!ctx)
err_exit("Failed to allocate attribute search context: %s\n",
strerror(errno));
- if (ntfs_attr_lookup(AT_DATA, AT_UNNAMED, 0, 0, 0, NULL, 0, ctx)) {
+ if (mkntfs_attr_lookup(AT_DATA, AT_UNNAMED, 0, 0, 0, NULL, 0, ctx)) {
ntfs_attr_put_search_ctx(ctx);
err_exit("BUG: $DATA attribute not found.\n");
}
Index: ntfsclone.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/ntfsclone.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -p -r1.48 -r1.49
--- ntfsclone.c 24 Sep 2005 21:36:51 -0000 1.48
+++ ntfsclone.c 24 Sep 2005 22:54:55 -0000 1.49
@@ -1335,11 +1335,11 @@ static void check_output_device(s64 inpu
set_filesize(input_size);
}
-static ntfs_attr_search_ctx *attr_get_search_ctx(ntfs_inode *ni, MFT_RECORD *mrec)
+static ntfs_attr_search_ctx *attr_get_search_ctx(ntfs_inode *ni)
{
ntfs_attr_search_ctx *ret;
- if ((ret = ntfs_attr_get_search_ctx(ni, mrec)) == NULL)
+ if ((ret = ntfs_attr_get_search_ctx(ni, NULL)) == NULL)
perr_printf("ntfs_attr_get_search_ctx");
return ret;
@@ -1371,7 +1371,7 @@ static ntfs_attr_search_ctx *lookup_data
ntfschar *ustr = NULL;
int len = 0;
- if ((ctx = attr_get_search_ctx(ni, NULL)) == NULL)
+ if ((ctx = attr_get_search_ctx(ni)) == NULL)
return NULL;
if (str2unicode(aname, &ustr, &len) == -1)
Index: ntfscmp.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/ntfscmp.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -p -r1.1 -r1.2
--- ntfscmp.c 25 Aug 2005 20:42:55 -0000 1.1
+++ ntfscmp.c 24 Sep 2005 22:54:55 -0000 1.2
@@ -237,11 +237,11 @@ static void parse_options(int argc, char
#endif
}
-static ntfs_attr_search_ctx *attr_get_search_ctx(ntfs_inode *ni, MFT_RECORD *mrec)
+static ntfs_attr_search_ctx *attr_get_search_ctx(ntfs_inode *ni)
{
ntfs_attr_search_ctx *ret;
- if ((ret = ntfs_attr_get_search_ctx(ni, mrec)) == NULL)
+ if ((ret = ntfs_attr_get_search_ctx(ni, NULL)) == NULL)
perr_println("ntfs_attr_get_search_ctx");
return ret;
@@ -612,9 +612,9 @@ static int cmp_attributes(ntfs_inode *ni
ATTR_TYPES prev_atype, atype1, atype2;
ntfs_attr_search_ctx *ctx1, *ctx2;
- if (!(ctx1 = attr_get_search_ctx(ni1, NULL)))
+ if (!(ctx1 = attr_get_search_ctx(ni1)))
return -1;
- if (!(ctx2 = attr_get_search_ctx(ni2, NULL)))
+ if (!(ctx2 = attr_get_search_ctx(ni2)))
goto out;
atype1 = ctx1->attr->type;
Index: ntfsfix.8.in
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/ntfsfix.8.in,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -p -r1.6 -r1.7
--- ntfsfix.8.in 10 Jul 2005 22:44:00 -0000 1.6
+++ ntfsfix.8.in 24 Sep 2005 22:54:55 -0000 1.7
@@ -16,16 +16,15 @@
.\" .sp <n> insert n+1 empty lines
.\" for manpage-specific macros, see man(7)
.SH NAME
-ntfsfix \- fix common errors and force Windows to check NTFS
+ntfsfix \- fix common errors
.SH SYNOPSIS
.B ntfsfix
.I device
.SH DESCRIPTION
\fBntfsfix\fP is a utility that fixes some common NTFS problems.
\fBntfsfix\fP is \fBNOT\fP a Linux
-version of chkdsk. It only repairs some fundamental NTFS inconsistencies,
-resets the NTFS journal file and schedules an NTFS consistency check for
-the first boot into Windows.
+version of chkdsk. It only repairs some fundamental NTFS inconsistencies and
+resets the NTFS journal file.
.sp
You may run
.B ntfsfix
Index: ntfsfix.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/ntfsfix.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -p -r1.15 -r1.16
--- ntfsfix.c 12 Jul 2005 16:18:13 -0000 1.15
+++ ntfsfix.c 24 Sep 2005 22:54:55 -0000 1.16
@@ -73,7 +73,6 @@ GEN_PRINTF(Qprintf, stdout, NULL, FALSE)
static const char *EXEC_NAME = "ntfsfix";
static const char *OK = "OK";
static const char *FAILED = "FAILED";
-static BOOL vol_is_dirty = FALSE;
static BOOL journal_is_empty = FALSE;
struct {
@@ -146,32 +145,6 @@ static void parse_options(int argc, char
}
}
-static int set_dirty_flag(ntfs_volume *vol)
-{
- u16 flags;
-
- if (vol_is_dirty == TRUE)
- return 0;
-
- printf("Setting required flags on partition... ");
- /*
- * Set chkdsk flag, i.e. mark the partition dirty so chkdsk will run
- * and fix it for us.
- */
- flags = vol->flags | VOLUME_IS_DIRTY;
- /* If NTFS volume version >= 2.0 then set mounted on NT4 flag. */
- if (vol->major_ver >= 2)
- flags |= VOLUME_MOUNTED_ON_NT4;
- if (ntfs_volume_set_flags(vol, flags)) {
- puts(FAILED);
- fprintf(stderr, "Error setting volume flags.\n");
- return -1;
- }
- puts(OK);
- vol_is_dirty = TRUE;
- return 0;
-}
-
static int empty_journal(ntfs_volume *vol)
{
if (journal_is_empty == TRUE)
@@ -349,9 +322,6 @@ int main(int argc, char **argv)
printf("Processing of $MFT and $MFTMirr completed successfully.\n");
- if (set_dirty_flag(vol) < 0)
- goto error_exit;
-
if (empty_journal(vol) < 0)
goto error_exit;
@@ -374,9 +344,6 @@ mount_ok:
goto error_exit;
}
- if (set_dirty_flag(vol) < 0)
- goto error_exit;
-
if (empty_journal(vol) < 0)
goto error_exit;
Index: ntfsinfo.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/ntfsinfo.c,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -p -r1.74 -r1.75
--- ntfsinfo.c 14 Aug 2005 15:44:47 -0000 1.74
+++ ntfsinfo.c 24 Sep 2005 22:54:55 -0000 1.75
@@ -1253,7 +1253,7 @@ static int get_type_and_size_of_indx(ntf
memcpy(name, (u8 *)attr + attr->name_offset,
attr->name_length * sizeof(ntfschar));
}
- ctx = ntfs_attr_get_search_ctx(ni, 0);
+ ctx = ntfs_attr_get_search_ctx(ni, NULL);
if (!ctx) {
perror("ntfs_get_search_ctx failed");
free(name);
Index: ntfslabel.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/ntfslabel.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -p -r1.13 -r1.14
--- ntfslabel.c 12 Aug 2004 08:15:25 -0000 1.13
+++ ntfslabel.c 24 Sep 2005 22:54:55 -0000 1.14
@@ -248,9 +248,8 @@ static int resize_resident_attribute_val
*/
static int change_label(ntfs_volume *vol, unsigned long mnt_flags, char *label, BOOL force)
{
- ntfs_attr_search_ctx *ctx = NULL;
+ ntfs_attr_search_ctx *ctx;
ntfschar *new_label = NULL;
- MFT_RECORD *mrec = NULL;
ATTR_RECORD *a;
int label_len;
int result = 0;
@@ -269,17 +268,7 @@ static int change_label(ntfs_volume *vol
}
}
}
-
- if (ntfs_file_record_read(vol, (MFT_REF)FILE_Volume, &mrec, NULL)) {
- perror("Error reading file record");
- goto err_out;
- }
- if (!(mrec->flags & MFT_RECORD_IN_USE)) {
- fprintf(stderr, "Error: $Volume has been deleted. Run "
- "chkdsk to fix this.\n");
- goto err_out;
- }
- ctx = ntfs_attr_get_search_ctx(NULL, mrec);
+ ctx = ntfs_attr_get_search_ctx(vol->vol_ni, NULL);
if (!ctx) {
perror("Failed to get attribute search context");
goto err_out;
@@ -314,39 +303,38 @@ static int change_label(ntfs_volume *vol
new_label[label_len / sizeof(ntfschar)] = cpu_to_le16(L'\0');
}
if (a) {
- if (resize_resident_attribute_value(mrec, a, label_len)) {
+ if (resize_resident_attribute_value(ctx->mrec, a, label_len)) {
perror("Error resizing resident attribute");
goto err_out;
}
} else {
/* sizeof(resident attribute record header) == 24 */
int asize = (24 + label_len + 7) & ~7;
- u32 biu = le32_to_cpu(mrec->bytes_in_use);
- if (biu + asize > le32_to_cpu(mrec->bytes_allocated)) {
+ u32 biu = le32_to_cpu(ctx->mrec->bytes_in_use);
+ if (biu + asize > le32_to_cpu(ctx->mrec->bytes_allocated)) {
errno = ENOSPC;
perror("Error adding resident attribute");
goto err_out;
}
a = ctx->attr;
- memmove((u8*)a + asize, a, biu - ((u8*)a - (u8*)mrec));
- mrec->bytes_in_use = cpu_to_le32(biu + asize);
+ memmove((u8*)a + asize, a, biu - ((u8*)a - (u8*)ctx->mrec));
+ ctx->mrec->bytes_in_use = cpu_to_le32(biu + asize);
a->type = AT_VOLUME_NAME;
a->length = cpu_to_le32(asize);
a->non_resident = 0;
a->name_length = 0;
a->name_offset = cpu_to_le16(24);
a->flags = cpu_to_le16(0);
- a->instance = mrec->next_attr_instance;
- mrec->next_attr_instance = cpu_to_le16((le16_to_cpu(
- mrec->next_attr_instance) + 1) & 0xffff);
+ a->instance = ctx->mrec->next_attr_instance;
+ ctx->mrec->next_attr_instance = cpu_to_le16((le16_to_cpu(
+ ctx->mrec->next_attr_instance) + 1) & 0xffff);
a->value_length = cpu_to_le32(label_len);
a->value_offset = a->name_offset;
a->resident_flags = 0;
a->reservedR = 0;
}
memcpy((u8*)a + le16_to_cpu(a->value_offset), new_label, label_len);
- if (!opts.noaction &&
- ntfs_mft_record_write(vol, (MFT_REF)FILE_Volume, mrec)) {
+ if (!opts.noaction && ntfs_inode_sync(vol->vol_ni)) {
perror("Error writing MFT Record to disk");
goto err_out;
}
@@ -354,8 +342,6 @@ static int change_label(ntfs_volume *vol
err_out:
if (new_label)
free(new_label);
- if (mrec)
- free(mrec);
return result;
}
Index: ntfsls.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/ntfsls.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -p -r1.28 -r1.29
--- ntfsls.c 14 Aug 2005 15:44:48 -0000 1.28
+++ ntfsls.c 24 Sep 2005 22:54:55 -0000 1.29
@@ -534,7 +534,7 @@ static int list_dir_entry(ntfsls_dirent
if (!ni)
goto release;
- ctx = ntfs_attr_get_search_ctx(ni, ni->mrec);
+ ctx = ntfs_attr_get_search_ctx(ni, NULL);
if (!ctx)
goto release;
@@ -658,7 +658,7 @@ int main(int argc, char **argv)
ntfschar *name = NULL;
int name_len = 0;;
- ctx = ntfs_attr_get_search_ctx (NULL, ni->mrec);
+ ctx = ntfs_attr_get_search_ctx(ni, NULL);
if (!ctx)
return -1;
Index: ntfsmove.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/ntfsmove.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -p -r1.13 -r1.14
--- ntfsmove.c 6 Jul 2005 22:47:19 -0000 1.13
+++ ntfsmove.c 24 Sep 2005 22:54:55 -0000 1.14
@@ -867,7 +867,8 @@ int main (int argc, char *argv[])
count = move_file (vol, inode, opts.location, 0);
if ((count > 0) && (!opts.nodirty)) {
- if (ntfs_volume_set_flags (vol, VOLUME_IS_DIRTY) < 0) {
+ if (ntfs_volume_set_flags (vol, vol->flags | VOLUME_IS_DIRTY) <
+ 0) {
Eprintf ("Couldn't mark volume dirty\n");
}
printf ("Relocated %lld bytes\n", count);
@@ -884,4 +885,3 @@ int main (int argc, char *argv[])
ntfs_umount (vol, FALSE);
return result;
}
-
Index: ntfsresize.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/ntfsresize.c,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -p -r1.88 -r1.89
--- ntfsresize.c 24 Sep 2005 20:12:36 -0000 1.88
+++ ntfsresize.c 24 Sep 2005 22:54:55 -0000 1.89
@@ -2249,7 +2249,7 @@ static void prepare_volume_fixup(ntfs_vo
printf("Schedule chkdsk for NTFS consistency check at Windows "
"boot time ...\n");
- if (ntfs_volume_set_flags(vol, flags))
+ if (ntfs_volume_write_flags(vol, flags))
perr_exit("Failed to set $Volume dirty");
if (vol->dev->d_ops->sync(vol->dev) == -1)
Index: ntfsrm.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/ntfsrm.c,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -p -r1.60 -r1.61
--- ntfsrm.c 20 Sep 2005 00:05:49 -0000 1.60
+++ ntfsrm.c 24 Sep 2005 22:54:55 -0000 1.61
@@ -2301,7 +2301,7 @@ static int utils_free_non_residents2 (nt
if (!bmp)
return -1;
- ctx = ntfs_attr_get_search_ctx (NULL, inode->mrec);
+ ctx = ntfs_attr_get_search_ctx (inode, NULL);
if (!ctx) {
printf ("can't create a search context\n");
return -1;
@@ -2480,7 +2480,7 @@ static int ntfs_mft_resize_resident (ntf
//printf ("mft_free = %d\n", mft_free);
//printf ("\n");
- ctx = ntfs_attr_get_search_ctx (NULL, mrec);
+ ctx = ntfs_attr_get_search_ctx (inode, NULL);
if (!ctx)
goto done;
Index: ntfswipe.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/ntfswipe.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -p -r1.36 -r1.37
--- ntfswipe.c 6 Jul 2005 22:47:20 -0000 1.36
+++ ntfswipe.c 24 Sep 2005 22:54:55 -0000 1.37
@@ -1391,10 +1391,6 @@ int main (int argc, char *argv[])
printf ("%lld bytes were wiped\n", (long long)total);
}
- if (ntfs_volume_set_flags (vol, VOLUME_IS_DIRTY) < 0) {
- Eprintf ("Couldn't mark volume dirty\n");
- }
-
result = 0;
umount:
ntfs_umount (vol, FALSE);
@@ -1403,4 +1399,3 @@ free:
free (opts.bytes);
return result;
}
-
Index: utils.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/utils.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -p -r1.43 -r1.44
--- utils.c 10 Sep 2005 07:55:58 -0000 1.43
+++ utils.c 24 Sep 2005 22:54:55 -0000 1.44
@@ -903,7 +903,7 @@ int mft_next_record (struct mft_search_c
ctx->flags_match |= FEMR_FILE;
if (ctx->flags_search & FEMR_DIR) {
- attr_ctx = ntfs_attr_get_search_ctx (NULL, ctx->inode->mrec);
+ attr_ctx = ntfs_attr_get_search_ctx (ctx->inode, NULL);
if (attr_ctx) {
if (ntfs_attr_lookup (AT_INDEX_ROOT, I30, 4, 0, 0, NULL, 0, attr_ctx) == 0)
ctx->flags_match |= FEMR_DIR;
|