Changes by: antona
Update of /cvsroot/linux-ntfs/linux-ntfs/ntfstools
In directory usw-pr-cvs1:/tmp/cvs-serv17127/ntfstools
Modified Files:
Makefile.am Makefile.in ntfsdump_logfile.c ntfsfix.c
Log Message:
Everything compiles again! Yey! (Don't know about working though, haven't tried
it... So be careful...)
The definitely final find_{first_}attr() functions are in place. Currently
still no support for attribute lists.
The two new _RE files contain the C-fied and more or less (more less than more
actually) cleaned up functions from the ntfs driver. Once they are cleaned
up (find_attr() is already completed but I left it in the _RE files for future
reference/educational value) and modified to suit my ideas of how they should
work, which are not quite the same as the driver way, they will make it into
attrib.[ch].
If anyone gives the new code a try, I would be interested in whether it worked
or not... (-;
Index: Makefile.am
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/ntfstools/Makefile.am,v
retrieving revision 1.3
retrieving revision 1.4
diff -U2 -r1.3 -r1.4
--- Makefile.am 2001/03/02 15:06:37 1.3
+++ Makefile.am 2001/04/02 02:04:37 1.4
@@ -1,3 +1,3 @@
-bin_PROGRAMS = ntfsfix ntfsdump_logfile mkntfs
+bin_PROGRAMS = ntfsfix ntfsdump_logfile #mkntfs
linux_ntfsincludedir = -I$(top_srcdir)/include
@@ -14,6 +14,6 @@
ntfsdump_logfile_LDFLAGS= $(all_libraries)
-mkntfs_SOURCES = mkntfs.c
-mkntfs_LDADD = $(top_srcdir)/libntfs/libntfs.la
-mkntfs_LDFLAGS = $(all_libraries)
+#mkntfs_SOURCES = mkntfs.c
+#mkntfs_LDADD = $(top_srcdir)/libntfs/libntfs.la
+#mkntfs_LDFLAGS = $(all_libraries)
Index: Makefile.in
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/ntfstools/Makefile.in,v
retrieving revision 1.2
retrieving revision 1.3
diff -U2 -r1.2 -r1.3
--- Makefile.in 2001/02/03 02:03:36 1.2
+++ Makefile.in 2001/04/02 02:04:37 1.3
@@ -83,19 +83,17 @@
all_libraries = @all_libraries@
-bin_PROGRAMS = ntfsfix ntfsdump_logfile
+bin_PROGRAMS = ntfsfix ntfsdump_logfile #mkntfs
linux_ntfsincludedir = -I$(top_srcdir)/include
+# Set the include path.
+INCLUDES = -I$(top_srcdir)/include $(all_includes)
+
ntfsfix_SOURCES = ntfsfix.c
ntfsfix_LDADD = $(top_srcdir)/libntfs/libntfs.la
+ntfsfix_LDFLAGS = $(all_libraries)
ntfsdump_logfile_SOURCES = ntfsdump_logfile.c
ntfsdump_logfile_LDADD = $(top_srcdir)/libntfs/libntfs.la
-
-# Set the include path.
-INCLUDES = -I$(top_srcdir)/include $(all_includes)
-
-# The library search path.
-ntfsfix_LDFLAGS = $(all_libraries)
ntfsdump_logfile_LDFLAGS = $(all_libraries)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@@ -360,4 +358,8 @@
mostlyclean distclean maintainer-clean
+
+#mkntfs_SOURCES = mkntfs.c
+#mkntfs_LDADD = $(top_srcdir)/libntfs/libntfs.la
+#mkntfs_LDFLAGS = $(all_libraries)
# Tell versions [3.59,3.63) of GNU make to not export all variables.
Index: ntfsdump_logfile.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/ntfstools/ntfsdump_logfile.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -U2 -r1.3 -r1.4
--- ntfsdump_logfile.c 2001/03/02 15:06:37 1.3
+++ ntfsdump_logfile.c 2001/04/02 02:04:37 1.4
@@ -1,7 +1,9 @@
const char *EXEC_NAME = "NtfsDump_LogFile";
-const char *EXEC_VERSION = "0.0.1";
+const char *EXEC_VERSION = "0.0.2";
/*
* NtfsDump_LogFile - Part of the Linux-NTFS project.
*
+ * $Id$
+ *
* Copyright (c) 2000,2001 Anton Altaparmakov.
*
@@ -60,6 +62,6 @@
int main(int argc, char **argv)
{
- unsigned char *b1 = NULL;
- NONRESIDENT_ATTRIBUTE_RECORD_HEADER *a;
+ MFT_RECORD *m = NULL;
+ ATTR_RECORD *a;
__u64 l;
unsigned char *lfd;
@@ -70,4 +72,6 @@
int pass = 1;
int i, lps;
+ MFT_REFERENCE mref;
+ attr_search_context ctx;
printf("\n");
@@ -91,31 +95,9 @@
exit(1);
}
- vol = ntfs_open(argv[1]);
+ vol = ntfs_mount(argv[1]);
if (!vol) {
- perror("ntfs_open() failed");
+ perror("ntfs_mount() failed");
exit(1);
}
- b1 = (__u8 *)malloc(vol->mft_record_size);
- if (!b1) {
- perror("Error allocating internal buffers");
- goto error_exit;
- }
- /* Read $MFT and $MFTmirr. */
- if (get_mft_records(vol, b1, 2, 1) != 1) {
- fprintf(stderr, "Error reading mft record for $LogFile.\n");
- goto error_exit;
- }
- /* Check the $LogFile mft record. */
- if (is_baad_record(b1)) {
- fprintf(stderr, "Error: Incomplete multi sector "
- "transfer detected in $LogFile.\nCannot "
- "handle this yet. )-:\n");
- goto error_exit;
- }
- if (!is_mft_recordp(b1)) {
- fprintf(stderr, "Error: Invalid mft record for $LogFile.\n"
- "Cannot handle this yet. )-:\n");
- goto error_exit;
- }
/* Check NTFS version is ok for us. */
printf("\nNTFS volume version is %i.%i.\n", vol->major_ver,
@@ -136,14 +118,21 @@
goto error_exit;
}
+ /* Read in $LogFile. */
+ memset(&ctx, 0, sizeof(attr_search_context));
+ *(__u64*)&mref = FILE_$LogFile;
+ if (read_file_record(vol, &mref, &m, NULL)) {
+ fprintf(stderr, "Error reading mft record for $LogFile.\n");
+ goto error_exit;
+ }
+ ctx.mrec = m;
/* Find the $DATA attribute of the $LogFile. */
- a = (NONRESIDENT_ATTRIBUTE_RECORD_HEADER*)
- find_first_attr(vol, (MFT_RECORD_HEADER*)b1, $DATA, NULL);
- if (!a) {
+ if (!find_first_attr(vol, $DATA, NULL, 0, 0, NULL, 0, &ctx)) {
fprintf(stderr, "Error: Attribute $DATA was not found in" \
"$LogFile!\n");
goto log_file_error;
}
+ a = ctx.attr;
/* Get length of $LogFile contents. */
- l = get_attribute_value_length((ATTRIBUTE_RECORD_HEADER*)a);
+ l = get_attribute_value_length(a);
if (!l) {
puts("$LogFile has zero length, no need to write to disk.");
@@ -157,5 +146,5 @@
}
/* Read in the $LogFile into the buffer. */
- if (l != get_attribute_value(vol, (ATTRIBUTE_RECORD_HEADER*)a, lfd)) {
+ if (l != get_attribute_value(vol, m, a, lfd)) {
puts("Amount of data read does not correspond to expected "
"length!");
@@ -173,5 +162,5 @@
lps = le32_to_cpu(rph->log_page_size);
pass_loc:
- if (!post_read_mst_fixup((NTFS_RECORD_HEADER*)rph, lps) ||
+ if (!post_read_mst_fixup((NTFS_RECORD*)rph, lps) ||
is_baad_recordp(rph)) {
puts("$LogFile incomplete multi sector transfer detected! "
@@ -183,5 +172,5 @@
le16_to_cpu(rph->minor_ver != 1)) {
fprintf(stderr, "$LogFile version %i.%i! Error: Unknown "
- "$LogFilee version!\n",
+ "$LogFile version!\n",
le16_to_cpu(rph->major_ver),
le16_to_cpu(rph->minor_ver));
@@ -253,8 +242,8 @@
i = 0;
final_exit:
- if (b1)
- free(b1);
+ if (m)
+ free(m);
if (vol)
- ntfs_close(vol, 0);
+ ntfs_umount(vol, 0);
return i;
error_exit:
Index: ntfsfix.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/ntfstools/ntfsfix.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -U2 -r1.6 -r1.7
--- ntfsfix.c 2001/03/02 15:06:37 1.6
+++ ntfsfix.c 2001/04/02 02:04:37 1.7
@@ -1,7 +1,9 @@
const char *EXEC_NAME = "NtfsFix";
-const char *EXEC_VERSION = "0.0.2";
+const char *EXEC_VERSION = "0.0.3";
/*
* NtfsFix - Part of the Linux-NTFS project.
*
+ * $Id$
+ *
* Copyright (c) 2000,2001 Anton Altaparmakov.
*
@@ -69,9 +71,11 @@
int i, ebits;
ssize_t br;
- NONRESIDENT_ATTRIBUTE_RECORD_HEADER *a;
+ ATTR_RECORD *a;
__u64 l;
unsigned char *lfd;
ntfs_volume *vol = NULL;
__u16 flags;
+ attr_search_context ctx;
+ MFT_REFERENCE mref;
printf("\n");
@@ -102,7 +106,7 @@
exit(1);
}
- vol = ntfs_open(argv[1]);
+ vol = ntfs_mount(argv[1]);
if (!vol) {
- perror("ntfs_open() failed");
+ perror("ntfs_mount() failed");
exit(1);
}
@@ -215,10 +219,10 @@
for (i = 0, ebits = 0; i < 4; ++i) {
if (memcmp(b1+i*mrs, b2+i*mrs,
- get_mft_record_data_size((MFT_RECORD_HEADER*)(b1 +
+ get_mft_record_data_size((MFT_RECORD*)(b1 +
i * mrs)))) {
ebits |= 1 << i;
#ifdef DEBUG
printf("in memcmp: i = %x, count = 0x%x\n", i,
- get_mft_record_data_size((MFT_RECORD_HEADER*)(b1
+ get_mft_record_data_size((MFT_RECORD*)(b1
+ i * mrs)));
#endif
@@ -239,5 +243,6 @@
memcpy(b2 + mrs * i, b1 + mrs * i, mrs);
/* Do the writes now. */
- br = put_mft_record(vol, b1 + mrs * i, i);
+ *(__u64*)&mref = i;
+ br = put_mft_record(vol, b1 + mrs * i, &mref);
if (br != 1)
goto mirr_sync_failed;
@@ -288,5 +293,5 @@
if (vol->major_ver >= 2)
flags |= VOLUME_MOUNTED_ON_NT4;
- if (!set_ntfs_volume_flags((MFT_RECORD_HEADER*)(b1+3*mrs), flags)) {
+ if (!set_ntfs_volume_flags(vol, (MFT_RECORD*)(b1+3*mrs), flags)) {
puts(FAILED);
fprintf(stderr, "Error setting volume flags.\n");
@@ -301,5 +306,6 @@
/* Write $Volume to $Mft. */
printf("Writing $Volume to $Mft... ");
- br = put_mft_record(vol, b1 + (3 * mrs), 3);
+ *(__u64*)&mref = 3ULL;
+ br = put_mft_record(vol, b1 + (3 * mrs), &mref);
if (br != 1) {
puts(FAILED);
@@ -333,8 +339,7 @@
printf("Going to empty the journal ($LogFile)... ");
/* Find the $DATA attribute. */
- a = (NONRESIDENT_ATTRIBUTE_RECORD_HEADER*)
- find_first_attr(vol, (MFT_RECORD_HEADER*)(b1+(2*mrs)), $DATA,
- NULL);
- if (!a) {
+ memset(&ctx, 0, sizeof(attr_search_context));
+ ctx.mrec = (MFT_RECORD*)(b1 + (2 * mrs));
+ if (!find_first_attr(vol, $DATA, NULL, 0, 0, NULL, 0, &ctx)) {
puts(FAILED);
fprintf(stderr, "Error: Attribute $DATA was not found in" \
@@ -342,6 +347,7 @@
goto log_file_error;
}
+ a = ctx.attr;
/* The $DATA attribute of the $LogFile has to be non-resident. */
- if (!a->attribute.non_resident) {
+ if (!a->non_resident) {
puts(FAILED);
fprintf(stderr, "$LogFile $DATA attribute is resident!?!\n");
@@ -349,5 +355,5 @@
}
/* Get length of $LogFile contents. */
- l = get_attribute_value_length((ATTRIBUTE_RECORD_HEADER*)a);
+ l = get_attribute_value_length((ATTR_RECORD*)a);
if (!l) {
puts(OK);
@@ -366,5 +372,6 @@
decompressing the mapping pairs array correctly and hence writing
below if safe as well. */
- if (l != get_attribute_value(vol, (ATTRIBUTE_RECORD_HEADER*)a, lfd)) {
+ if (l != get_attribute_value(vol, (MFT_RECORD*)(b1 + (2 * mrs)),
+ a, lfd)) {
puts(FAILED);
puts("Amount of data read does not correspond to expected "
@@ -377,13 +384,13 @@
/* Set the $DATA attribute. */
/* FIXME: set_attribute_value needs to either:
- * - know the MFT_RECORD_HEADER so it can adjust it accordingly with
+ * - know the MFT_RECORD so it can adjust it accordingly with
* changes in length of the resident part of the attribute.
* or
- * - return a copy of the attribute so the MFT_RECORD_HEADER can be
+ * - return a copy of the attribute so the MFT_RECORD can be
* adjusted accordingly with changes in the length of the resident
* part of the attribute by the caller.
* For now, just assume that attribute length remains constant, since
* this is the case for the $LogFile zeroing out. */
- if (!set_attribute_value(vol, (ATTRIBUTE_RECORD_HEADER*)a, lfd, l)) {
+ if (!set_attribute_value(vol, (ATTR_RECORD*)a, lfd, l)) {
puts(FAILED);
puts("Failed to set the $LogFile attribute value.");
@@ -418,5 +425,5 @@
free(b1);
if (vol)
- ntfs_close(vol, 0);
+ ntfs_umount(vol, 0);
return i;
error_exit:
|