| Changes by: antona
Update of /cvsroot/linux-ntfs/linux-ntfs/ntfstools
In directory usw-pr-cvs1:/tmp/cvs-serv8453/ntfstools
Modified Files:
	Makefile.am Makefile.in mkntfs.c 
Log Message:
Integrate ldm.c into automatic build process.
A bit more on mkntfs and make it compile (do _not_ run as it is - am working on
directory creation so chances are it will hang if you run it or something).
Index: Makefile.am
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/ntfstools/Makefile.am,v
retrieving revision 1.5
retrieving revision 1.6
diff -U2 -r1.5 -r1.6
--- Makefile.am	2001/06/01 02:07:26	1.5
+++ Makefile.am	2001/06/04 23:38:55	1.6
@@ -6,5 +6,5 @@
 endif
 
-bin_PROGRAMS		= ntfsfix ntfsdump_logfile mkntfs
+bin_PROGRAMS		= ntfsfix ntfsdump_logfile mkntfs ldm
 
 linux_ntfsincludedir	= -I$(top_srcdir)/include
@@ -24,3 +24,5 @@
 mkntfs_LDADD		= $(top_srcdir)/libntfs/libntfs.la
 mkntfs_LDFLAGS		= $(all_libraries)
+
+ldm_SOURCES		= ldm.c
 
Index: Makefile.in
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/ntfstools/Makefile.in,v
retrieving revision 1.4
retrieving revision 1.5
diff -U2 -r1.4 -r1.5
--- Makefile.in	2001/06/01 02:07:26	1.4
+++ Makefile.in	2001/06/04 23:38:55	1.5
@@ -92,5 +92,5 @@
 @DEBUG_FALSE@AM_CFLAGS = -D_FILE_OFFSET_BITS=64
 
-bin_PROGRAMS = ntfsfix ntfsdump_logfile mkntfs
+bin_PROGRAMS = ntfsfix ntfsdump_logfile mkntfs ldm
 
 linux_ntfsincludedir = -I$(top_srcdir)/include
@@ -110,9 +110,11 @@
 mkntfs_LDADD = $(top_srcdir)/libntfs/libntfs.la
 mkntfs_LDFLAGS = $(all_libraries)
+
+ldm_SOURCES = ldm.c
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
 CONFIG_HEADER = ../config.h
 CONFIG_CLEAN_FILES = 
 bin_PROGRAMS =  ntfsfix$(EXEEXT) ntfsdump_logfile$(EXEEXT) \
-mkntfs$(EXEEXT)
+mkntfs$(EXEEXT) ldm$(EXEEXT)
 PROGRAMS =  $(bin_PROGRAMS)
 
@@ -127,4 +129,8 @@
 sd.$(OBJEXT) mkntfs.$(OBJEXT)
 mkntfs_DEPENDENCIES =  $(top_srcdir)/libntfs/libntfs.la
+ldm_OBJECTS =  ldm.$(OBJEXT)
+ldm_LDADD = $(LDADD)
+ldm_DEPENDENCIES = 
+ldm_LDFLAGS = 
 COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
@@ -138,8 +144,8 @@
 TAR = gtar
 GZIP_ENV = --best
-DEP_FILES =  .deps/attrdef.P .deps/boot.P .deps/mkntfs.P \
+DEP_FILES =  .deps/attrdef.P .deps/boot.P .deps/ldm.P .deps/mkntfs.P \
 .deps/ntfsdump_logfile.P .deps/ntfsfix.P .deps/sd.P .deps/upcase.P
-SOURCES = $(ntfsfix_SOURCES) $(ntfsdump_logfile_SOURCES) $(mkntfs_SOURCES)
-OBJECTS = $(ntfsfix_OBJECTS) $(ntfsdump_logfile_OBJECTS) $(mkntfs_OBJECTS)
+SOURCES = $(ntfsfix_SOURCES) $(ntfsdump_logfile_SOURCES) $(mkntfs_SOURCES) $(ldm_SOURCES)
+OBJECTS = $(ntfsfix_OBJECTS) $(ntfsdump_logfile_OBJECTS) $(mkntfs_OBJECTS) $(ldm_OBJECTS)
 
 all: all-redirect
@@ -228,4 +234,8 @@
 	@rm -f mkntfs$(EXEEXT)
 	$(LINK) $(mkntfs_LDFLAGS) $(mkntfs_OBJECTS) $(mkntfs_LDADD) $(LIBS)
+
+ldm$(EXEEXT): $(ldm_OBJECTS) $(ldm_DEPENDENCIES)
+	@rm -f ldm$(EXEEXT)
+	$(LINK) $(ldm_LDFLAGS) $(ldm_OBJECTS) $(ldm_LDADD) $(LIBS)
 
 tags: TAGS
Index: mkntfs.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/ntfstools/mkntfs.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -U2 -r1.8 -r1.9
--- mkntfs.c	2001/06/04 14:04:31	1.8
+++ mkntfs.c	2001/06/04 23:38:55	1.9
@@ -752,7 +752,7 @@
 	/* Aligned to 2-byte boundary. */
 	m->usa_ofs = cpu_to_le16(sizeof(MFT_RECORD) + 1 & ~1);
-	if (opt.mft_record_size >= opt.sector_size)
+	if (opt.mft_record_size >= NTFS_SECTOR_SIZE)
 		m->usa_count = cpu_to_le16(opt.mft_record_size /
-				opt.sector_size + 1);
+				NTFS_SECTOR_SIZE + 1);
 	else {
 		m->usa_count = cpu_to_le16(1);
@@ -1861,5 +1861,5 @@
  */
 int upgrade_to_large_index(MFT_RECORD *m, const char *name,
-		const __u32 name_len, const IGNORE_CASE_BOOL ic,
+		__u32 name_len, const IGNORE_CASE_BOOL ic,
 		const uchar_t *upcase, const __u32 upcase_len)
 {
@@ -1890,5 +1890,5 @@
 	ctx.mrec = m;
 	err = find_first_attr($INDEX_ROOT, uname, name_len, ic, upcase,
-			upcase_len, NULL, NULL, &ctx);
+			upcase_len, NULL, 0, &ctx);
 	if (uname)
 		free(uname);
@@ -1905,17 +1905,27 @@
 	ntfs_set_bit(&bmp, 0, 1);
 	/* Bitmap has to be at least 8 bytes in size. */
-	err = add_attr_bitmap(m, uname, name_len, ic, upcase, upcase_len,
-			&bmp, sizeof(bmp));
+	err = add_attr_bitmap(m, name, name_len, ic, upcase, upcase_len,
+			(char*)&bmp, sizeof(bmp));
 	if (err)
 		return err;
 	ia_val = calloc(1, index_block_size);
 	if (!ia_val)
-		return = -errno;
+		return -errno;
 	/* Setup header. */
 	ia_val->magic = magic_INDX;
 	ia_val->usa_ofs = cpu_to_le16(sizeof(INDEX_ALLOCATION));
-	ia_val->usa_count = cpu_to_le16();
+	if (index_block_size >= NTFS_SECTOR_SIZE)
+		ia_val->usa_count = cpu_to_le16(index_block_size /
+				NTFS_SECTOR_SIZE + 1);
+	else {
+		ia_val->usa_count = cpu_to_le16(1);
+		Qprintf("Sector size is bigger than index block size. Setting "
+			"usa_count to 1. If Windows\nchkdsk reports this as "
+			"corruption, please email lin...@li...\n"
+			"stating that you saw this message and that the file "
+			"system created was corrupt.\nThank you.");
+	}
 	/* Set USN to 1. */
-	*(__u16)((char*)ia_val + le16_to_cpu(ia_val->usa_ofs)) =
+	*(__u16*)((char*)ia_val + le16_to_cpu(ia_val->usa_ofs)) =
 			cpu_to_le16(1);
 	ia_val->lsn = cpu_to_le64(0);
@@ -1949,6 +1959,6 @@
 	 * vcn inside it which is 0LL. */
 	// re at the moment points to the index root termination index entry
-	err = add_attr_index_alloc(m, uname, name_len, ic, upcase, upcase_len,
-			/*TODO: ...*/);
+	err = add_attr_index_alloc(m, name, name_len, ic, upcase, upcase_len,
+			(char*)ia_val, index_block_size);
 	if (err) {
 		// TODO: Remove the added bitmap!
@@ -1960,5 +1970,5 @@
 
 /* Return 0 on success or -errno on error. */
-int insert_file_link_in_dir(m, )
+int insert_file_link_in_dir(MFT_RECORD *m)
 {
 	return -ENOTSUP;
@@ -1973,5 +1983,4 @@
 	opt.mft_record_size = 1024;
 	opt.index_block_size = 4096;
-	opt.sector_size = 512;
 	opt.attr_defs = (ATTR_DEF*)&attrdef_ntfs12_array;
 	opt.attr_defs_len = sizeof(attrdef_ntfs12_array);
@@ -2116,9 +2125,11 @@
 		int _sect_size = 0;
 		err = ioctl(f, BLKSSZGET, &_sect_size);
-		if (err == -1)
-			err_exit("IOCTL BLKSSZGET failed for %s: %s\n",
+		if (err == -1) {
+			Eprintf("IOCTL BLKSSZGET failed for %s: %s\nAssuming "
+					"sector size is 512 bytes.\n",
 					opt.dev_name, strerror(errno));
-		opt.sector_size = _sect_size;
-		Dprintf("BLKSSZGET sector_size = %d\n", _sect_size);
+			opt.sector_size = 512;
+		} else
+			opt.sector_size = _sect_size;
 	}
 	/* Validate sector size. */
@@ -2465,5 +2476,5 @@
 				opt.index_block_size);
 	if (!err)
-		err = insert_file_link_in_dir(m, );
+		err = insert_file_link_in_dir(m);
 	// add_attr_bitmap(m, );
 	// add_attr_index_alloc(m, );
 |