summaryrefslogtreecommitdiff
Diffstat
-rwxr-xr-xAndroid.mk138
-rwxr-xr-xAndroid.mk.bak89
-rwxr-xr-xCREDITS20
-rwxr-xr-xINSTALL200
-rwxr-xr-xMakefile715
-rwxr-xr-xMakefile.am106
-rwxr-xr-xMakefile.in955
-rwxr-xr-xNEWS4
-rwxr-xr-xREADME80
-rwxr-xr-xTODO.ntfsprogs126
-rwxr-xr-xaclocal.m47091
-rwxr-xr-xcompile21
-rwxr-xr-xconfig.guess292
-rw-r--r--[-rwxr-xr-x]config.h165
-rwxr-xr-xconfig.h.in110
-rwxr-xr-xconfig.log3290
-rwxr-xr-xconfig.status1220
-rwxr-xr-xconfig.sub104
-rwxr-xr-xconfigure26448
-rwxr-xr-xconfigure.ac291
-rwxr-xr-xdepcomp87
-rwxr-xr-xinclude/Makefile.in181
-rwxr-xr-xinclude/fuse-lite/Makefile.in112
-rwxr-xr-xinclude/fuse-lite/fuse.h61
-rwxr-xr-xinclude/fuse-lite/fuse_common.h49
-rwxr-xr-xinclude/fuse-lite/fuse_kernel.h6
-rwxr-xr-xinclude/fuse-lite/fuse_lowlevel.h20
-rwxr-xr-xinclude/ntfs-3g/Makefile.am4
-rwxr-xr-xinclude/ntfs-3g/Makefile.in163
-rwxr-xr-xinclude/ntfs-3g/acls.h3
-rwxr-xr-xinclude/ntfs-3g/attrib.h50
-rwxr-xr-xinclude/ntfs-3g/cache.h7
-rwxr-xr-xinclude/ntfs-3g/compat.h6
-rwxr-xr-xinclude/ntfs-3g/compress.h6
-rwxr-xr-xinclude/ntfs-3g/debug.h4
-rwxr-xr-xinclude/ntfs-3g/device.h18
-rwxr-xr-xinclude/ntfs-3g/device_io.h21
-rwxr-xr-xinclude/ntfs-3g/dir.h11
-rwxr-xr-xinclude/ntfs-3g/layout.h32
-rwxr-xr-xinclude/ntfs-3g/lcnalloc.h1
-rwxr-xr-xinclude/ntfs-3g/logging.h3
-rwxr-xr-xinclude/ntfs-3g/mst.h3
-rwxr-xr-xinclude/ntfs-3g/ntfstime.h12
-rwxr-xr-xinclude/ntfs-3g/param.h72
-rwxr-xr-xinclude/ntfs-3g/realpath.h24
-rwxr-xr-xinclude/ntfs-3g/runlist.h3
-rwxr-xr-xinclude/ntfs-3g/security.h20
-rwxr-xr-xinclude/ntfs-3g/types.h8
-rwxr-xr-xinclude/ntfs-3g/unistr.h13
-rwxr-xr-xinclude/ntfs-3g/volume.h78
-rwxr-xr-xinclude/ntfs-3g/xattrs.h75
-rwxr-xr-xinstall-sh5
-rwxr-xr-xlibfuse-lite/Makefile.am3
-rwxr-xr-xlibfuse-lite/Makefile.in188
-rwxr-xr-xlibfuse-lite/fuse.c418
-rwxr-xr-xlibfuse-lite/fuse_kern_chan.c2
-rwxr-xr-xlibfuse-lite/fuse_lowlevel.c53
-rwxr-xr-xlibfuse-lite/fuse_opt.c20
-rwxr-xr-xlibfuse-lite/fuse_session.c12
-rwxr-xr-xlibfuse-lite/fusermount.c97
-rwxr-xr-xlibfuse-lite/helper.c21
-rwxr-xr-xlibfuse-lite/mount.c486
-rwxr-xr-xlibfuse-lite/mount_util.c246
-rwxr-xr-xlibfuse-lite/mount_util.h11
-rwxr-xr-xlibntfs-3g/Makefile.am15
-rwxr-xr-xlibntfs-3g/Makefile.in420
-rwxr-xr-xlibntfs-3g/acls.c219
-rwxr-xr-xlibntfs-3g/attrib.c1205
-rwxr-xr-xlibntfs-3g/bootsect.c4
-rwxr-xr-xlibntfs-3g/cache.c7
-rwxr-xr-xlibntfs-3g/compress.c962
-rwxr-xr-xlibntfs-3g/device.c252
-rwxr-xr-xlibntfs-3g/dir.c374
-rwxr-xr-xlibntfs-3g/efs.c217
-rwxr-xr-xlibntfs-3g/index.c30
-rwxr-xr-xlibntfs-3g/inode.c46
-rwxr-xr-xlibntfs-3g/lcnalloc.c36
-rw-r--r--libntfs-3g/libntfs-3g.pc10
-rw-r--r--libntfs-3g/libntfs-3g.script.so2
-rwxr-xr-xlibntfs-3g/logfile.c23
-rwxr-xr-xlibntfs-3g/logging.c24
-rwxr-xr-xlibntfs-3g/mft.c12
-rwxr-xr-xlibntfs-3g/mst.c24
-rwxr-xr-xlibntfs-3g/object_id.c9
-rwxr-xr-xlibntfs-3g/realpath.c103
-rwxr-xr-xlibntfs-3g/reparse.c67
-rwxr-xr-xlibntfs-3g/runlist.c62
-rwxr-xr-xlibntfs-3g/security.c345
-rwxr-xr-xlibntfs-3g/unistr.c244
-rwxr-xr-xlibntfs-3g/unix_io.c19
-rwxr-xr-xlibntfs-3g/volume.c365
-rwxr-xr-xlibntfs-3g/win32_io.c708
-rwxr-xr-xlibntfs-3g/xattrs.c791
-rwxr-xr-xlibtool9301
-rwxr-xr-xltmain.sh8439
-rwxr-xr-xm4/libtool.m47377
-rwxr-xr-xm4/ltoptions.m4368
-rwxr-xr-xm4/ltsugar.m4123
-rwxr-xr-xm4/ltversion.m423
-rwxr-xr-xm4/lt~obsolete.m492
-rwxr-xr-xmissing49
-rwxr-xr-xntfsprogs/Makefile.am154
-rwxr-xr-xntfsprogs/Makefile.in1199
-rwxr-xr-xntfsprogs/attrdef.c168
-rwxr-xr-xntfsprogs/attrdef.h7
-rwxr-xr-xntfsprogs/boot.c268
-rwxr-xr-xntfsprogs/boot.h7
-rwxr-xr-xntfsprogs/cluster.c118
-rwxr-xr-xntfsprogs/cluster.h39
-rwxr-xr-xntfsprogs/list.h194
-rw-r--r--ntfsprogs/mkntfs.8290
-rwxr-xr-xntfsprogs/mkntfs.8.in290
-rwxr-xr-xntfsprogs/mkntfs.c5177
-rw-r--r--ntfsprogs/ntfscat.8136
-rwxr-xr-xntfsprogs/ntfscat.8.in136
-rwxr-xr-xntfsprogs/ntfscat.c440
-rwxr-xr-xntfsprogs/ntfscat.h46
-rwxr-xr-xntfsprogs/ntfsck.c883
-rw-r--r--ntfsprogs/ntfsclone.8391
-rwxr-xr-xntfsprogs/ntfsclone.8.in391
-rwxr-xr-xntfsprogs/ntfsclone.c2701
-rw-r--r--ntfsprogs/ntfscluster.8124
-rwxr-xr-xntfsprogs/ntfscluster.8.in124
-rwxr-xr-xntfsprogs/ntfscluster.c563
-rwxr-xr-xntfsprogs/ntfscluster.h63
-rw-r--r--ntfsprogs/ntfscmp.877
-rwxr-xr-xntfsprogs/ntfscmp.8.in77
-rwxr-xr-xntfsprogs/ntfscmp.c1012
-rw-r--r--ntfsprogs/ntfscp.8111
-rwxr-xr-xntfsprogs/ntfscp.8.in111
-rwxr-xr-xntfsprogs/ntfscp.c590
-rwxr-xr-xntfsprogs/ntfsdecrypt.c1436
-rwxr-xr-xntfsprogs/ntfsdump_logfile.c779
-rw-r--r--ntfsprogs/ntfsfix.881
-rwxr-xr-xntfsprogs/ntfsfix.8.in81
-rwxr-xr-xntfsprogs/ntfsfix.c1657
-rw-r--r--ntfsprogs/ntfsinfo.889
-rwxr-xr-xntfsprogs/ntfsinfo.8.in89
-rwxr-xr-xntfsprogs/ntfsinfo.c2384
-rw-r--r--ntfsprogs/ntfslabel.8118
-rwxr-xr-xntfsprogs/ntfslabel.8.in118
-rwxr-xr-xntfsprogs/ntfslabel.c458
-rw-r--r--ntfsprogs/ntfsls.8172
-rwxr-xr-xntfsprogs/ntfsls.8.in172
-rwxr-xr-xntfsprogs/ntfsls.c717
-rwxr-xr-xntfsprogs/ntfsmftalloc.c368
-rwxr-xr-xntfsprogs/ntfsmove.c923
-rwxr-xr-xntfsprogs/ntfsmove.h46
-rw-r--r--ntfsprogs/ntfsprogs.869
-rwxr-xr-xntfsprogs/ntfsprogs.8.in69
-rw-r--r--ntfsprogs/ntfsresize.8326
-rwxr-xr-xntfsprogs/ntfsresize.8.in326
-rwxr-xr-xntfsprogs/ntfsresize.c4497
-rwxr-xr-xntfsprogs/ntfstruncate.c809
-rw-r--r--ntfsprogs/ntfsundelete.8324
-rwxr-xr-xntfsprogs/ntfsundelete.8.in324
-rwxr-xr-xntfsprogs/ntfsundelete.c2490
-rwxr-xr-xntfsprogs/ntfsundelete.h112
-rwxr-xr-xntfsprogs/ntfswipe.c2131
-rwxr-xr-xntfsprogs/ntfswipe.h54
-rwxr-xr-xntfsprogs/sd.c607
-rwxr-xr-xntfsprogs/sd.h11
-rwxr-xr-xntfsprogs/utils.c1184
-rwxr-xr-xntfsprogs/utils.h137
-rwxr-xr-xprog.IAB1071
-rwxr-xr-xprog.IAD5
-rwxr-xr-xprog.IMB466
-rwxr-xr-xprog.IMD2
-rwxr-xr-xprog.PFI2
-rwxr-xr-xprog.PO1
-rwxr-xr-xprog.PR14
-rwxr-xr-xprog.PRI219
-rwxr-xr-xprog.PS979
-rwxr-xr-xprog.SearchResults3
-rwxr-xr-xprog.WK39
-rwxr-xr-xsrc/Makefile.am86
-rwxr-xr-xsrc/Makefile.in938
-rwxr-xr-xsrc/lowntfs-3g.c1538
-rw-r--r--src/ntfs-3g.8448
-rwxr-xr-xsrc/ntfs-3g.8.in217
-rwxr-xr-xsrc/ntfs-3g.c1357
-rw-r--r--src/ntfs-3g.probe.881
-rwxr-xr-xsrc/ntfs-3g.probe.8.in4
-rwxr-xr-xsrc/ntfs-3g.probe.c9
-rw-r--r--src/ntfs-3g.secaudit.8184
-rwxr-xr-xsrc/ntfs-3g.secaudit.8.in15
-rw-r--r--src/ntfs-3g.usermap.896
-rwxr-xr-xsrc/ntfs-3g_common.c745
-rwxr-xr-xsrc/ntfs-3g_common.h185
-rwxr-xr-xsrc/secaudit.c673
-rwxr-xr-xsrc/secaudit.h32
-rwxr-xr-xsrc/usermap.c3
-rw-r--r--[-rwxr-xr-x]stamp-h10
193 files changed, 80411 insertions, 44563 deletions
diff --git a/libntfs-3g/efs.c b/libntfs-3g/efs.c
index 0af1a4d..7957005 100755
--- a/libntfs-3g/efs.c
+++ b/libntfs-3g/efs.c
@@ -4,7 +4,7 @@
* This module is part of ntfs-3g library
*
* Copyright (c) 2009 Martin Bene
- * Copyright (c) 2009 Jean-Pierre Andre
+ * Copyright (c) 2009-2010 Jean-Pierre Andre
*
* This program/include file is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
@@ -121,6 +121,91 @@ int ntfs_get_efs_info(ntfs_inode *ni, char *value, size_t size)
}
/*
+ * Fix all encrypted AT_DATA attributes of an inode
+ *
+ * The fix may require making an attribute non resident, which
+ * requires more space in the MFT record, and may cause some
+ * attribute to be expelled and the full record to be reorganized.
+ * When this happens, the search for data attributes has to be
+ * reinitialized.
+ *
+ * Returns zero if successful.
+ * -1 if there is a problem.
+ */
+
+static int fixup_loop(ntfs_inode *ni)
+{
+ ntfs_attr_search_ctx *ctx;
+ ntfs_attr *na;
+ ATTR_RECORD *a;
+ BOOL restart;
+ int cnt;
+ int maxcnt;
+ int res = 0;
+
+ maxcnt = 0;
+ do {
+ restart = FALSE;
+ ctx = ntfs_attr_get_search_ctx(ni, NULL);
+ if (!ctx) {
+ ntfs_log_error("Failed to get ctx for efs\n");
+ res = -1;
+ }
+ cnt = 0;
+ while (!restart && !res
+ && !ntfs_attr_lookup(AT_DATA, NULL, 0,
+ CASE_SENSITIVE, 0, NULL, 0, ctx)) {
+ cnt++;
+ a = ctx->attr;
+ na = ntfs_attr_open(ctx->ntfs_ino, AT_DATA,
+ (ntfschar*)((u8*)a + le16_to_cpu(a->name_offset)),
+ a->name_length);
+ if (!na) {
+ ntfs_log_error("can't open DATA Attribute\n");
+ res = -1;
+ }
+ if (na && !(ctx->attr->flags & ATTR_IS_ENCRYPTED)) {
+ if (!NAttrNonResident(na)
+ && ntfs_attr_make_non_resident(na, ctx)) {
+ /*
+ * ntfs_attr_make_non_resident fails if there
+ * is not enough space in the MFT record.
+ * When this happens, force making non-resident
+ * so that some other attribute is expelled.
+ */
+ if (ntfs_attr_force_non_resident(na)) {
+ res = -1;
+ } else {
+ /* make sure there is some progress */
+ if (cnt <= maxcnt) {
+ errno = EIO;
+ ntfs_log_error("Multiple failure"
+ " making non resident\n");
+ res = -1;
+ } else {
+ ntfs_attr_put_search_ctx(ctx);
+ ctx = (ntfs_attr_search_ctx*)NULL;
+ restart = TRUE;
+ maxcnt = cnt;
+ }
+ }
+ }
+ if (!restart && !res
+ && ntfs_efs_fixup_attribute(ctx, na)) {
+ ntfs_log_error("Error in efs fixup of AT_DATA Attribute\n");
+ res = -1;
+ }
+ }
+ if (na)
+ ntfs_attr_close(na);
+ }
+ } while (restart && !res);
+ if (ctx)
+ ntfs_attr_put_search_ctx(ctx);
+ return (res);
+}
+
+/*
* Set the efs data from an extended attribute
* Warning : the new data is not checked
* Returns 0, or -1 if there is a problem
@@ -134,7 +219,6 @@ int ntfs_set_efs_info(ntfs_inode *ni, const char *value, size_t size,
int written;
ntfs_attr *na;
const EFS_ATTR_HEADER *info_header;
- ntfs_attr_search_ctx *ctx;
res = 0;
if (ni && value && size) {
@@ -210,20 +294,8 @@ int ntfs_set_efs_info(ntfs_inode *ni, const char *value, size_t size,
/* iterate over AT_DATA attributes */
/* set encrypted flag, truncate attribute to match padding bytes */
- ctx = ntfs_attr_get_search_ctx(ni, NULL);
- if (!ctx) {
- ntfs_log_error("Failed to get ctx for efs\n");
- return (-1);
- }
- while (!ntfs_attr_lookup(AT_DATA, NULL, 0,
- CASE_SENSITIVE, 0, NULL, 0, ctx)) {
- if (ntfs_efs_fixup_attribute(ctx, NULL)) {
- ntfs_log_error("Error in efs fixup of AT_DATA Attribute\n");
- ntfs_attr_put_search_ctx(ctx);
- return(-1);
- }
- }
- ntfs_attr_put_search_ctx(ctx);
+ if (fixup_loop(ni))
+ return -1;
}
ni->flags |= FILE_ATTR_ENCRYPTED;
NInoSetDirty(ni);
@@ -250,15 +322,14 @@ int ntfs_set_efs_info(ntfs_inode *ni, const char *value, size_t size,
int ntfs_efs_fixup_attribute(ntfs_attr_search_ctx *ctx, ntfs_attr *na)
{
u64 newsize;
+ u64 oldsize;
le16 appended_bytes;
u16 padding_length;
- ATTR_RECORD *a;
ntfs_inode *ni;
- BOOL close_na = FALSE;
BOOL close_ctx = FALSE;
- if (!ctx && !na) {
- ntfs_log_error("neither ctx nor na specified for efs_fixup_attribute\n");
+ if (!na) {
+ ntfs_log_error("no na specified for efs_fixup_attribute\n");
goto err_out;
}
if (!ctx) {
@@ -267,55 +338,79 @@ int ntfs_efs_fixup_attribute(ntfs_attr_search_ctx *ctx, ntfs_attr *na)
ntfs_log_error("Failed to get ctx for efs\n");
goto err_out;
}
- close_ctx=TRUE;
+ close_ctx = TRUE;
if (ntfs_attr_lookup(AT_DATA, na->name, na->name_len,
CASE_SENSITIVE, 0, NULL, 0, ctx)) {
ntfs_log_error("attr lookup for AT_DATA attribute failed in efs fixup\n");
goto err_out;
}
- }
-
- a = ctx->attr;
- if (!na) {
- na = ntfs_attr_open(ctx->ntfs_ino, AT_DATA,
- (ntfschar*)((u8*)a + le16_to_cpu(a->name_offset)),
- a->name_length);
- if (!na) {
- ntfs_log_error("can't open DATA Attribute\n");
- return (-1);
+ } else {
+ if (!NAttrNonResident(na)) {
+ ntfs_log_error("Cannot make non resident"
+ " when a context has been allocated\n");
+ goto err_out;
}
- close_na = TRUE;
}
+
+ /* no extra bytes are added to void attributes */
+ oldsize = na->data_size;
+ if (oldsize) {
/* make sure size is valid for a raw encrypted stream */
- if ((na->data_size & 511) != 2) {
- ntfs_log_error("Bad raw encrypted stream\n");
- goto err_out;
- }
- /* read padding length from last two bytes of attribute */
- if (ntfs_attr_pread(na, na->data_size-2, 2, &appended_bytes) != 2) {
- ntfs_log_error("Error reading padding length\n");
- goto err_out;
- }
- padding_length = le16_to_cpu(appended_bytes);
- if (padding_length > 511 || padding_length > na->data_size-2) {
- errno = EINVAL;
- ntfs_log_error("invalid padding length %d for data_size %lld\n",
- padding_length, (long long)na->data_size);
- goto err_out;
- }
- newsize = na->data_size - padding_length - 2;
- /* truncate attribute to possibly free clusters allocated
- for the last two bytes */
- if (ntfs_attr_truncate(na, na->data_size-2)) {
- ntfs_log_error("Error truncating attribute\n");
- goto err_out;
- }
+ if ((oldsize & 511) != 2) {
+ ntfs_log_error("Bad raw encrypted stream\n");
+ goto err_out;
+ }
+ /* read padding length from last two bytes of attribute */
+ if (ntfs_attr_pread(na, oldsize - 2, 2, &appended_bytes) != 2) {
+ ntfs_log_error("Error reading padding length\n");
+ goto err_out;
+ }
+ padding_length = le16_to_cpu(appended_bytes);
+ if (padding_length > 511 || padding_length > na->data_size-2) {
+ errno = EINVAL;
+ ntfs_log_error("invalid padding length %d for data_size %lld\n",
+ padding_length, (long long)oldsize);
+ goto err_out;
+ }
+ newsize = oldsize - padding_length - 2;
+ /*
+ * truncate attribute to possibly free clusters allocated
+ * for the last two bytes, but do not truncate to new size
+ * to avoid losing useful data
+ */
+ if (ntfs_attr_truncate(na, oldsize - 2)) {
+ ntfs_log_error("Error truncating attribute\n");
+ goto err_out;
+ }
+ } else
+ newsize = 0;
- /* Encrypted AT_DATA Attributes MUST be non-resident */
+ /*
+ * Encrypted AT_DATA Attributes MUST be non-resident
+ * This has to be done after the attribute is resized, as
+ * resizing down to zero may cause the attribute to be made
+ * resident.
+ */
if (!NAttrNonResident(na)
- && ntfs_attr_make_non_resident(na, ctx)) {
- ntfs_log_error("Error making DATA attribute non-resident\n");
- goto err_out;
+ && ntfs_attr_make_non_resident(na, ctx)) {
+ if (!close_ctx
+ || ntfs_attr_force_non_resident(na)) {
+ ntfs_log_error("Error making DATA attribute non-resident\n");
+ goto err_out;
+ } else {
+ /*
+ * must reinitialize context after forcing
+ * non-resident. We need a context for updating
+ * the state, and at this point, we are sure
+ * the context is not used elsewhere.
+ */
+ ntfs_attr_reinit_search_ctx(ctx);
+ if (ntfs_attr_lookup(AT_DATA, na->name, na->name_len,
+ CASE_SENSITIVE, 0, NULL, 0, ctx)) {
+ ntfs_log_error("attr lookup for AT_DATA attribute failed in efs fixup\n");
+ goto err_out;
+ }
+ }
}
ni = na->ni;
if (!na->name_len) {
@@ -324,8 +419,6 @@ int ntfs_efs_fixup_attribute(ntfs_attr_search_ctx *ctx, ntfs_attr *na)
}
NInoSetDirty(ni);
NInoFileNameSetDirty(ni);
- if (close_na)
- ntfs_attr_close(na);
ctx->attr->data_size = cpu_to_le64(newsize);
if (le64_to_cpu(ctx->attr->initialized_size) > newsize)
@@ -336,8 +429,6 @@ int ntfs_efs_fixup_attribute(ntfs_attr_search_ctx *ctx, ntfs_attr *na)
return (0);
err_out:
- if (close_na && na)
- ntfs_attr_close(na);
if (close_ctx && ctx)
ntfs_attr_put_search_ctx(ctx);
return (-1);