summaryrefslogtreecommitdiff
Diffstat
-rwxr-xr-xAUTHORS23
-rwxr-xr-xAndroid.mk89
-rwxr-xr-xAndroid.mk.bak89
-rwxr-xr-xCOPYING340
-rwxr-xr-xCOPYING.LIB482
-rwxr-xr-xCREDITS41
-rwxr-xr-xChangeLog7
-rwxr-xr-xINSTALL237
-rwxr-xr-xMakefile715
-rwxr-xr-xMakefile.am66
-rwxr-xr-xMakefile.in722
-rwxr-xr-xNEWS5
-rwxr-xr-xREADME68
-rwxr-xr-xaclocal.m47723
-rwxr-xr-xautogen.sh22
-rwxr-xr-xcompile142
-rwxr-xr-xconfig.guess1536
-rwxr-xr-xconfig.h361
-rwxr-xr-xconfig.h.in350
-rwxr-xr-xconfig.log3290
-rwxr-xr-xconfig.status1220
-rwxr-xr-xconfig.sub1658
-rwxr-xr-xconfigure25302
-rwxr-xr-xconfigure.ac441
-rwxr-xr-xdepcomp589
-rwxr-xr-xinclude/Makefile.am4
-rwxr-xr-xinclude/Makefile.in503
-rwxr-xr-xinclude/fuse-lite/Makefile.am10
-rwxr-xr-xinclude/fuse-lite/Makefile.in400
-rwxr-xr-xinclude/fuse-lite/fuse.h654
-rwxr-xr-xinclude/fuse-lite/fuse_common.h193
-rwxr-xr-xinclude/fuse-lite/fuse_kernel.h422
-rwxr-xr-xinclude/fuse-lite/fuse_lowlevel.h1375
-rwxr-xr-xinclude/fuse-lite/fuse_lowlevel_compat.h16
-rwxr-xr-xinclude/fuse-lite/fuse_opt.h261
-rwxr-xr-xinclude/ntfs-3g/Makefile.am45
-rwxr-xr-xinclude/ntfs-3g/Makefile.in471
-rwxr-xr-xinclude/ntfs-3g/acls.h199
-rwxr-xr-xinclude/ntfs-3g/attrib.h358
-rwxr-xr-xinclude/ntfs-3g/attrlist.h51
-rwxr-xr-xinclude/ntfs-3g/bitmap.h96
-rwxr-xr-xinclude/ntfs-3g/bootsect.h42
-rwxr-xr-xinclude/ntfs-3g/cache.h115
-rwxr-xr-xinclude/ntfs-3g/collate.h34
-rwxr-xr-xinclude/ntfs-3g/compat.h69
-rwxr-xr-xinclude/ntfs-3g/compress.h39
-rwxr-xr-xinclude/ntfs-3g/debug.h47
-rwxr-xr-xinclude/ntfs-3g/device.h128
-rwxr-xr-xinclude/ntfs-3g/device_io.h77
-rwxr-xr-xinclude/ntfs-3g/dir.h128
-rwxr-xr-xinclude/ntfs-3g/efs.h30
-rwxr-xr-xinclude/ntfs-3g/endians.h203
-rwxr-xr-xinclude/ntfs-3g/index.h167
-rwxr-xr-xinclude/ntfs-3g/inode.h225
-rwxr-xr-xinclude/ntfs-3g/layout.h2661
-rwxr-xr-xinclude/ntfs-3g/lcnalloc.h50
-rwxr-xr-xinclude/ntfs-3g/logfile.h394
-rwxr-xr-xinclude/ntfs-3g/logging.h118
-rwxr-xr-xinclude/ntfs-3g/mft.h132
-rwxr-xr-xinclude/ntfs-3g/misc.h30
-rwxr-xr-xinclude/ntfs-3g/mst.h34
-rwxr-xr-xinclude/ntfs-3g/ntfstime.h131
-rwxr-xr-xinclude/ntfs-3g/object_id.h35
-rwxr-xr-xinclude/ntfs-3g/param.h63
-rwxr-xr-xinclude/ntfs-3g/reparse.h39
-rwxr-xr-xinclude/ntfs-3g/runlist.h89
-rwxr-xr-xinclude/ntfs-3g/security.h353
-rwxr-xr-xinclude/ntfs-3g/support.h85
-rwxr-xr-xinclude/ntfs-3g/types.h124
-rwxr-xr-xinclude/ntfs-3g/unistr.h116
-rwxr-xr-xinclude/ntfs-3g/volume.h277
-rwxr-xr-xinstall-sh519
-rwxr-xr-xlibfuse-lite/Makefile.am28
-rwxr-xr-xlibfuse-lite/Makefile.in572
-rwxr-xr-xlibfuse-lite/fuse.c2789
-rwxr-xr-xlibfuse-lite/fuse_i.h25
-rwxr-xr-xlibfuse-lite/fuse_kern_chan.c96
-rwxr-xr-xlibfuse-lite/fuse_loop.c40
-rwxr-xr-xlibfuse-lite/fuse_lowlevel.c1395
-rwxr-xr-xlibfuse-lite/fuse_misc.h106
-rwxr-xr-xlibfuse-lite/fuse_opt.c368
-rwxr-xr-xlibfuse-lite/fuse_session.c183
-rwxr-xr-xlibfuse-lite/fuse_signals.c73
-rwxr-xr-xlibfuse-lite/fusermount.c772
-rwxr-xr-xlibfuse-lite/helper.c40
-rwxr-xr-xlibfuse-lite/mount.c256
-rwxr-xr-xlibfuse-lite/mount_util.c219
-rwxr-xr-xlibfuse-lite/mount_util.h22
-rwxr-xr-xlibntfs-3g/Makefile.am79
-rwxr-xr-xlibntfs-3g/Makefile.in841
-rwxr-xr-xlibntfs-3g/acls.c4296
-rwxr-xr-xlibntfs-3g/attrib.c5913
-rwxr-xr-xlibntfs-3g/attrlist.c314
-rwxr-xr-xlibntfs-3g/bitmap.c300
-rwxr-xr-xlibntfs-3g/bootsect.c285
-rwxr-xr-xlibntfs-3g/cache.c609
-rwxr-xr-xlibntfs-3g/collate.c271
-rwxr-xr-xlibntfs-3g/compat.c250
-rwxr-xr-xlibntfs-3g/compress.c1431
-rwxr-xr-xlibntfs-3g/debug.c79
-rwxr-xr-xlibntfs-3g/device.c730
-rwxr-xr-xlibntfs-3g/dir.c2582
-rwxr-xr-xlibntfs-3g/efs.c346
-rwxr-xr-xlibntfs-3g/index.c2063
-rwxr-xr-xlibntfs-3g/inode.c1566
-rwxr-xr-xlibntfs-3g/lcnalloc.c735
-rwxr-xr-xlibntfs-3g/libntfs-3g.pc.in10
-rwxr-xr-xlibntfs-3g/libntfs-3g.script.so.in2
-rwxr-xr-xlibntfs-3g/logfile.c737
-rwxr-xr-xlibntfs-3g/logging.c613
-rwxr-xr-xlibntfs-3g/mft.c1909
-rwxr-xr-xlibntfs-3g/misc.c61
-rwxr-xr-xlibntfs-3g/mst.c231
-rwxr-xr-xlibntfs-3g/object_id.c637
-rwxr-xr-xlibntfs-3g/reparse.c1222
-rwxr-xr-xlibntfs-3g/runlist.c2166
-rwxr-xr-xlibntfs-3g/security.c5167
-rwxr-xr-xlibntfs-3g/unistr.c1321
-rwxr-xr-xlibntfs-3g/unix_io.c386
-rwxr-xr-xlibntfs-3g/volume.c1663
-rwxr-xr-xlibntfs-3g/win32_io.c1477
-rwxr-xr-xlibtool7621
-rwxr-xr-xltmain.sh6956
-rwxr-xr-xm4/.keep0
-rwxr-xr-xmissing367
-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/lowntfs-3g.c4492
-rwxr-xr-xsrc/ntfs-3g.8.in349
-rwxr-xr-xsrc/ntfs-3g.c4461
-rwxr-xr-xsrc/ntfs-3g.probe.8.in81
-rwxr-xr-xsrc/ntfs-3g.probe.c163
-rwxr-xr-xsrc/ntfs-3g.secaudit.8.in171
-rwxr-xr-xsrc/ntfs-3g.usermap.8.in96
-rwxr-xr-xsrc/secaudit.c7176
-rwxr-xr-xsrc/secaudit.h731
-rwxr-xr-xsrc/test.c88
-rwxr-xr-xsrc/usermap.c1356
-rwxr-xr-xstamp-h11
148 files changed, 141286 insertions, 0 deletions
diff --git a/libntfs-3g/bootsect.c b/libntfs-3g/bootsect.c
new file mode 100755
index 0000000..e9bea37
--- a/dev/null
+++ b/libntfs-3g/bootsect.c
@@ -0,0 +1,285 @@
+/**
+ * bootsect.c - Boot sector handling code. Originated from the Linux-NTFS project.
+ *
+ * Copyright (c) 2000-2006 Anton Altaparmakov
+ * Copyright (c) 2003-2008 Szabolcs Szakacsits
+ * Copyright (c) 2005 Yura Pakhuchiy
+ *
+ * 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
+ * by the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program/include file is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program (in the main directory of the NTFS-3G
+ * distribution in the file COPYING); if not, write to the Free Software
+ * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef HAVE_STDIO_H
+#include <stdio.h>
+#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+
+#include "compat.h"
+#include "bootsect.h"
+#include "debug.h"
+#include "logging.h"
+
+/**
+ * ntfs_boot_sector_is_ntfs - check if buffer contains a valid ntfs boot sector
+ * @b: buffer containing putative boot sector to analyze
+ * @silent: if zero, output progress messages to stderr
+ *
+ * Check if the buffer @b contains a valid ntfs boot sector. The buffer @b
+ * must be at least 512 bytes in size.
+ *
+ * If @silent is zero, output progress messages to stderr. Otherwise, do not
+ * output any messages (except when configured with --enable-debug in which
+ * case warning/debug messages may be displayed).
+ *
+ * Return TRUE if @b contains a valid ntfs boot sector and FALSE if not.
+ */
+BOOL ntfs_boot_sector_is_ntfs(NTFS_BOOT_SECTOR *b)
+{
+ u32 i;
+ BOOL ret = FALSE;
+
+ ntfs_log_debug("Beginning bootsector check.\n");
+
+ ntfs_log_debug("Checking OEMid, NTFS signature.\n");
+ if (b->oem_id != cpu_to_le64(0x202020205346544eULL)) { /* "NTFS " */
+ ntfs_log_error("NTFS signature is missing.\n");
+ goto not_ntfs;
+ }
+
+ ntfs_log_debug("Checking bytes per sector.\n");
+ if (le16_to_cpu(b->bpb.bytes_per_sector) < 256 ||
+ le16_to_cpu(b->bpb.bytes_per_sector) > 4096) {
+ ntfs_log_error("Unexpected bytes per sector value (%d).\n",
+ le16_to_cpu(b->bpb.bytes_per_sector));
+ goto not_ntfs;
+ }
+
+ ntfs_log_debug("Checking sectors per cluster.\n");
+ switch (b->bpb.sectors_per_cluster) {
+ case 1: case 2: case 4: case 8: case 16: case 32: case 64: case 128:
+ break;
+ default:
+ ntfs_log_error("Unexpected sectors per cluster value (%d).\n",
+ b->bpb.sectors_per_cluster);
+ goto not_ntfs;
+ }
+
+ ntfs_log_debug("Checking cluster size.\n");
+ i = (u32)le16_to_cpu(b->bpb.bytes_per_sector) *
+ b->bpb.sectors_per_cluster;
+ if (i > 65536) {
+ ntfs_log_error("Unexpected cluster size (%d).\n", i);
+ goto not_ntfs;
+ }
+
+ ntfs_log_debug("Checking reserved fields are zero.\n");
+ if (le16_to_cpu(b->bpb.reserved_sectors) ||
+ le16_to_cpu(b->bpb.root_entries) ||
+ le16_to_cpu(b->bpb.sectors) ||
+ le16_to_cpu(b->bpb.sectors_per_fat) ||
+ le32_to_cpu(b->bpb.large_sectors) ||
+ b->bpb.fats) {
+ ntfs_log_error("Reserved fields aren't zero "
+ "(%d, %d, %d, %d, %d, %d).\n",
+ le16_to_cpu(b->bpb.reserved_sectors),
+ le16_to_cpu(b->bpb.root_entries),
+ le16_to_cpu(b->bpb.sectors),
+ le16_to_cpu(b->bpb.sectors_per_fat),
+ le32_to_cpu(b->bpb.large_sectors),
+ b->bpb.fats);
+ goto not_ntfs;
+ }
+
+ ntfs_log_debug("Checking clusters per mft record.\n");
+ if ((u8)b->clusters_per_mft_record < 0xe1 ||
+ (u8)b->clusters_per_mft_record > 0xf7) {
+ switch (b->clusters_per_mft_record) {
+ case 1: case 2: case 4: case 8: case 0x10: case 0x20: case 0x40:
+ break;
+ default:
+ ntfs_log_error("Unexpected clusters per mft record "
+ "(%d).\n", b->clusters_per_mft_record);
+ goto not_ntfs;
+ }
+ }
+
+ ntfs_log_debug("Checking clusters per index block.\n");
+ if ((u8)b->clusters_per_index_record < 0xe1 ||
+ (u8)b->clusters_per_index_record > 0xf7) {
+ switch (b->clusters_per_index_record) {
+ case 1: case 2: case 4: case 8: case 0x10: case 0x20: case 0x40:
+ break;
+ default:
+ ntfs_log_error("Unexpected clusters per index record "
+ "(%d).\n", b->clusters_per_index_record);
+ goto not_ntfs;
+ }
+ }
+
+ if (b->end_of_sector_marker != cpu_to_le16(0xaa55))
+ ntfs_log_debug("Warning: Bootsector has invalid end of sector "
+ "marker.\n");
+
+ ntfs_log_debug("Bootsector check completed successfully.\n");
+
+ ret = TRUE;
+not_ntfs:
+ return ret;
+}
+
+static const char *last_sector_error =
+"HINTS: Either the volume is a RAID/LDM but it wasn't setup yet,\n"
+" or it was not setup correctly (e.g. by not using mdadm --build ...),\n"
+" or a wrong device is tried to be mounted,\n"
+" or the partition table is corrupt (partition is smaller than NTFS),\n"
+" or the NTFS boot sector is corrupt (NTFS size is not valid).\n";
+
+/**
+ * ntfs_boot_sector_parse - setup an ntfs volume from an ntfs boot sector
+ * @vol: ntfs_volume to setup
+ * @bs: buffer containing ntfs boot sector to parse
+ *
+ * Parse the ntfs bootsector @bs and setup the ntfs volume @vol with the
+ * obtained values.
+ *
+ * Return 0 on success or -1 on error with errno set to the error code EINVAL.
+ */
+int ntfs_boot_sector_parse(ntfs_volume *vol, const NTFS_BOOT_SECTOR *bs)
+{
+ s64 sectors;
+ u8 sectors_per_cluster;
+ s8 c;
+
+ /* We return -1 with errno = EINVAL on error. */
+ errno = EINVAL;
+
+ vol->sector_size = le16_to_cpu(bs->bpb.bytes_per_sector);
+ vol->sector_size_bits = ffs(vol->sector_size) - 1;
+ ntfs_log_debug("SectorSize = 0x%x\n", vol->sector_size);
+ ntfs_log_debug("SectorSizeBits = %u\n", vol->sector_size_bits);
+ /*
+ * The bounds checks on mft_lcn and mft_mirr_lcn (i.e. them being
+ * below or equal the number_of_clusters) really belong in the
+ * ntfs_boot_sector_is_ntfs but in this way we can just do this once.
+ */
+ sectors_per_cluster = bs->bpb.sectors_per_cluster;
+ ntfs_log_debug("SectorsPerCluster = 0x%x\n", sectors_per_cluster);
+ if (sectors_per_cluster & (sectors_per_cluster - 1)) {
+ ntfs_log_error("sectors_per_cluster (%d) is not a power of 2."
+ "\n", sectors_per_cluster);
+ return -1;
+ }
+
+ sectors = sle64_to_cpu(bs->number_of_sectors);
+ ntfs_log_debug("NumberOfSectors = %lld\n", (long long)sectors);
+ if (!sectors) {
+ ntfs_log_error("Volume size is set to zero.\n");
+ return -1;
+ }
+ if (vol->dev->d_ops->seek(vol->dev,
+ (sectors - 1) << vol->sector_size_bits,
+ SEEK_SET) == -1) {
+ ntfs_log_perror("Failed to read last sector (%lld)",
+ (long long)sectors);
+ ntfs_log_error("%s", last_sector_error);
+ return -1;
+ }
+
+ vol->nr_clusters = sectors >> (ffs(sectors_per_cluster) - 1);
+
+ vol->mft_lcn = sle64_to_cpu(bs->mft_lcn);
+ vol->mftmirr_lcn = sle64_to_cpu(bs->mftmirr_lcn);
+ ntfs_log_debug("MFT LCN = %lld\n", (long long)vol->mft_lcn);
+ ntfs_log_debug("MFTMirr LCN = %lld\n", (long long)vol->mftmirr_lcn);
+ if (vol->mft_lcn > vol->nr_clusters ||
+ vol->mftmirr_lcn > vol->nr_clusters) {
+ ntfs_log_error("$MFT LCN (%lld) or $MFTMirr LCN (%lld) is "
+ "greater than the number of clusters (%lld).\n",
+ (long long)vol->mft_lcn, (long long)vol->mftmirr_lcn,
+ (long long)vol->nr_clusters);
+ return -1;
+ }
+
+ vol->cluster_size = sectors_per_cluster * vol->sector_size;
+ if (vol->cluster_size & (vol->cluster_size - 1)) {
+ ntfs_log_error("cluster_size (%d) is not a power of 2.\n",
+ vol->cluster_size);
+ return -1;
+ }
+ vol->cluster_size_bits = ffs(vol->cluster_size) - 1;
+ /*
+ * Need to get the clusters per mft record and handle it if it is
+ * negative. Then calculate the mft_record_size. A value of 0x80 is
+ * illegal, thus signed char is actually ok!
+ */
+ c = bs->clusters_per_mft_record;
+ ntfs_log_debug("ClusterSize = 0x%x\n", (unsigned)vol->cluster_size);
+ ntfs_log_debug("ClusterSizeBits = %u\n", vol->cluster_size_bits);
+ ntfs_log_debug("ClustersPerMftRecord = 0x%x\n", c);
+ /*
+ * When clusters_per_mft_record is negative, it means that it is to
+ * be taken to be the negative base 2 logarithm of the mft_record_size
+ * min bytes. Then:
+ * mft_record_size = 2^(-clusters_per_mft_record) bytes.
+ */
+ if (c < 0)
+ vol->mft_record_size = 1 << -c;
+ else
+ vol->mft_record_size = c << vol->cluster_size_bits;
+ if (vol->mft_record_size & (vol->mft_record_size - 1)) {
+ ntfs_log_error("mft_record_size (%d) is not a power of 2.\n",
+ vol->mft_record_size);
+ return -1;
+ }
+ vol->mft_record_size_bits = ffs(vol->mft_record_size) - 1;
+ ntfs_log_debug("MftRecordSize = 0x%x\n", (unsigned)vol->mft_record_size);
+ ntfs_log_debug("MftRecordSizeBits = %u\n", vol->mft_record_size_bits);
+ /* Same as above for INDX record. */
+ c = bs->clusters_per_index_record;
+ ntfs_log_debug("ClustersPerINDXRecord = 0x%x\n", c);
+ if (c < 0)
+ vol->indx_record_size = 1 << -c;
+ else
+ vol->indx_record_size = c << vol->cluster_size_bits;
+ vol->indx_record_size_bits = ffs(vol->indx_record_size) - 1;
+ ntfs_log_debug("INDXRecordSize = 0x%x\n", (unsigned)vol->indx_record_size);
+ ntfs_log_debug("INDXRecordSizeBits = %u\n", vol->indx_record_size_bits);
+ /*
+ * Work out the size of the MFT mirror in number of mft records. If the
+ * cluster size is less than or equal to the size taken by four mft
+ * records, the mft mirror stores the first four mft records. If the
+ * cluster size is bigger than the size taken by four mft records, the
+ * mft mirror contains as many mft records as will fit into one
+ * cluster.
+ */
+ if (vol->cluster_size <= 4 * vol->mft_record_size)
+ vol->mftmirr_size = 4;
+ else
+ vol->mftmirr_size = vol->cluster_size / vol->mft_record_size;
+ return 0;
+}
+