Changes by: antona
Update of /cvsroot/linux-ntfs/linux-ntfs/ntfstools
In directory usw-pr-cvs1:/tmp/cvs-serv607
Modified Files:
mkntfs.c
Log Message:
More directory work in mkntfs
Index: mkntfs.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/ntfstools/mkntfs.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -U2 -r1.5 -r1.6
--- mkntfs.c 2001/06/03 02:09:08 1.5
+++ mkntfs.c 2001/06/03 12:04:30 1.6
@@ -1837,4 +1837,60 @@
}
+/*
+ * Create bitmap and index allocation attributes and modify index root
+ * attribute accordingly.
+ *
+ * Return 0 on success or -errno on error.
+ */
+int upgrade_to_large_index(MFT_RECORD *m, const char *name,
+ const __u32 name_len, const IGNORE_CASE_BOOL ic,
+ const uchar_t *upcase, const __u32 upcase_len)
+{
+ attr_search_context ctx;
+ ATTR_RECORD *a;
+ INDEX_ROOT *r;
+ INDEX_ENTRY *e, *e_end;
+ INDEX_ALLOCATION *a;
+ uchar_t *uname;
+ char *bmp;
+ int i, err, r_size, index_block_size;
+
+ if (name_len) {
+ i = (name_len + 1) * sizeof(uchar_t);
+ uname = (uchar_t*)calloc(1, i);
+ name_len = stoucs(uname, name, i);
+ if (name_len > 0xff)
+ return -ENAMETOOLONG;
+ } else
+ uname = NULL;
+ /* Find the index root attribute. */
+ memset(&ctx, 0, sizeof(ctx));
+ ctx.mrec = m;
+ if (!find_first_attr($INDEX_ROOT, uname, name_len, ic, upcase,
+ upcase_len, NULL, NULL, &ctx)) {
+ if (uname)
+ free(uname);
+ return -ENOTDIR;
+ }
+ a = ctx.attr;
+ if (a->non_resident || a->flags)
+ return -EINVAL;
+ r = (INDEX_ROOT*)((char*)a + le16_to_cpu(a->value_offset));
+ e_end = (INDEX_ENTRY*)((char)*r + le32_to_cpu(a->value_length));
+ e = (INDEX_ENTRY*)((char*)&r->index + r->index.entries_offset);
+ index_block_size = le32_to_cpu(r->index_block_size);
+ // add_attr_bitmap(m, );
+ // add_attr_index_alloc(m, );
+
+ err = -ENOTSUP;
+ return err;
+}
+
+/* Return 0 on success or -errno on error. */
+int insert_file_link_in_dir(m, )
+{
+ return -ENOTSUP;
+}
+
void init_options(void)
{
@@ -2320,4 +2376,28 @@
/* The root directory mft reference. */
root_ref = cpu_to_le64((__u64)FILE_$root << 48 | FILE_$root);
+ Dprintf("Creating root directory (mft record 5)\n");
+ m = (MFT_RECORD*)(buf + 5 * opt.mft_record_size);
+ m->flags |= MFT_RECORD_IS_DIRECTORY;
+ if (!err)
+ err = add_attr_file_name(m, root_ref, 0LL, 0LL,
+ FILE_ATTR_HIDDEN | FILE_ATTR_SYSTEM |
+ FILE_ATTR_DUP_FILE_NAME_INDEX_PRESENT, 0, 0,
+ ".", FILE_NAME_WIN32_AND_DOS);
+ if (!err) {
+ init_system_file_sd(FILE_$root, &sd, &i);
+ err = add_attr_sd(m, sd, i);
+ }
+ if (!err)
+ err = add_attr_index_root(m, "$I30", 4, IGNORE_CASE, opt.upcase,
+ opt.upcase_len, $FILE_NAME, COLLATION_FILE_NAME,
+ opt.index_block_size);
+ if (!err)
+ err = insert_file_link_in_dir(m, );
+ // add_attr_bitmap(m, );
+ // add_attr_index_alloc(m, );
+ if (err < 0)
+ err_exit("Couldn't create root directory: %s\n",
+ strerror(-err));
+ dump_mft_record(m);
/* Add all other attributes, on a per-file basis for clarity. */
Dprintf("Creating $MFT (mft record 0)\n");
@@ -2597,26 +2677,4 @@
//dump_mft_record(m);
}
- Dprintf("Creating root directory (mft record 5)\n");
- m = (MFT_RECORD*)(buf + 5 * opt.mft_record_size);
- m->flags |= MFT_RECORD_IS_DIRECTORY;
- if (!err)
- err = add_attr_file_name(m, root_ref, 0LL, 0LL,
- FILE_ATTR_HIDDEN | FILE_ATTR_SYSTEM |
- FILE_ATTR_DUP_FILE_NAME_INDEX_PRESENT, 0, 0,
- ".", FILE_NAME_WIN32_AND_DOS);
- if (!err) {
- init_system_file_sd(FILE_$root, &sd, &i);
- err = add_attr_sd(m, sd, i);
- }
- if (!err)
- err = add_attr_index_root(m, "$I30", 4, IGNORE_CASE, opt.upcase,
- opt.upcase_len, $FILE_NAME, COLLATION_FILE_NAME,
- opt.index_block_size);
- if (err < 0)
- err_exit("Couldn't create root directory: %s\n",
- strerror(-err));
- // add_attr_bitmap(m, );
- // add_attr_index_alloc(m, );
- dump_mft_record(m);
// - Do not step onto bad blocks!!!
// - If any bad blocks were specified or found, modify $BadClus, allocating the
|