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/device.c b/libntfs-3g/device.c
index c77d8f9..a5c32f4 100755
--- a/libntfs-3g/device.c
+++ b/libntfs-3g/device.c
@@ -1,8 +1,10 @@
/**
* device.c - Low level device io functions. Originated from the Linux-NTFS project.
*
- * Copyright (c) 2004-2006 Anton Altaparmakov
+ * Copyright (c) 2004-2013 Anton Altaparmakov
* Copyright (c) 2004-2006 Szabolcs Szakacsits
+ * Copyright (c) 2010 Jean-Pierre Andre
+ * Copyright (c) 2008-2013 Tuxera Inc.
*
* 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
@@ -57,12 +59,18 @@
#ifdef HAVE_SYS_MOUNT_H
#include <sys/mount.h>
#endif
+#ifdef HAVE_SYS_DISK_H
+#include <sys/disk.h>
+#endif
#ifdef HAVE_LINUX_FD_H
#include <linux/fd.h>
#endif
#ifdef HAVE_LINUX_HDREG_H
#include <linux/hdreg.h>
#endif
+#ifdef ENABLE_HD
+#include <hd.h>
+#endif
#include "types.h"
#include "mst.h"
@@ -124,6 +132,8 @@ struct ntfs_device *ntfs_device_alloc(const char *name, const long state,
dev->d_ops = dops;
dev->d_state = state;
dev->d_private = priv_data;
+ dev->d_heads = -1;
+ dev->d_sectors_per_track = -1;
}
return dev;
}
@@ -154,6 +164,25 @@ int ntfs_device_free(struct ntfs_device *dev)
return 0;
}
+/*
+ * Sync the device
+ *
+ * returns zero if successful.
+ */
+
+int ntfs_device_sync(struct ntfs_device *dev)
+{
+ int ret;
+ struct ntfs_device_operations *dops;
+
+ if (NDevDirty(dev)) {
+ dops = dev->d_ops;
+ ret = dops->sync(dev);
+ } else
+ ret = 0;
+ return ret;
+}
+
/**
* ntfs_pread - positioned read from disk
* @dev: device to read from
@@ -260,6 +289,9 @@ s64 ntfs_pwrite(struct ntfs_device *dev, const s64 pos, s64 count,
total = written;
break;
}
+ if (NDevSync(dev) && total && dops->sync(dev)) {
+ total--; /* on sync error, return partially written */
+ }
ret = total;
out:
return ret;
@@ -534,6 +566,36 @@ s64 ntfs_device_size_get(struct ntfs_device *dev, int block_size)
}
}
#endif
+#ifdef DIOCGMEDIASIZE
+ {
+ /* FreeBSD */
+ off_t size;
+
+ if (dev->d_ops->ioctl(dev, DIOCGMEDIASIZE, &size) >= 0) {
+ ntfs_log_debug("DIOCGMEDIASIZE nr bytes = %llu (0x%llx)\n",
+ (unsigned long long)size,
+ (unsigned long long)size);
+ return (s64)size / block_size;
+ }
+ }
+#endif
+#ifdef DKIOCGETBLOCKCOUNT
+ {
+ /* Mac OS X */
+ uint64_t blocks;
+ int sector_size;
+
+ sector_size = ntfs_device_sector_size_get(dev);
+ if (sector_size >= 0 && dev->d_ops->ioctl(dev,
+ DKIOCGETBLOCKCOUNT, &blocks) >= 0)
+ {
+ ntfs_log_debug("DKIOCGETBLOCKCOUNT nr blocks = %llu (0x%llx)\n",
+ (unsigned long long) blocks,
+ (unsigned long long) blocks);
+ return blocks * sector_size / block_size;
+ }
+ }
+#endif
/*
* We couldn't figure it out by using a specialized ioctl,
* so do binary search to find the size of the device.
@@ -586,6 +648,132 @@ s64 ntfs_device_partition_start_sector_get(struct ntfs_device *dev)
return -1;
}
+static int ntfs_device_get_geo(struct ntfs_device *dev)
+{
+ int err;
+
+ if (!dev) {
+ errno = EINVAL;
+ return -1;
+ }
+ err = EOPNOTSUPP;
+#ifdef ENABLE_HD
+ {
+ hd_data_t *hddata;
+ hd_t *hd, *devlist, *partlist = NULL;
+ str_list_t *names;
+ hd_res_t *res;
+ const int d_name_len = strlen(dev->d_name) + 1;
+ int done = 0;
+
+ hddata = calloc(1, sizeof(*hddata));
+ if (!hddata) {
+ err = ENOMEM;
+ goto skip_hd;
+ }
+ /* List all "disk" class devices on the system. */
+ devlist = hd_list(hddata, hw_disk, 1, NULL);
+ if (!devlist) {
+ free(hddata);
+ err = ENOMEM;
+ goto skip_hd;
+ }
+ /*
+ * Loop over each disk device looking for the device with the
+ * same unix name as @dev.
+ */
+ for (hd = devlist; hd; hd = hd->next) {
+ if (hd->unix_dev_name && !strncmp(dev->d_name,
+ hd->unix_dev_name, d_name_len))
+ goto got_hd;
+ if (hd->unix_dev_name2 && !strncmp(dev->d_name,
+ hd->unix_dev_name2, d_name_len))
+ goto got_hd;
+ for (names = hd->unix_dev_names; names;
+ names = names->next) {
+ if (names->str && !strncmp(dev->d_name,
+ names->str, d_name_len))
+ goto got_hd;
+ }
+ }
+ /*
+ * Device was not a whole disk device. Unless it is a file it
+ * is likely to be a partition device. List all "partition"
+ * class devices on the system.
+ */
+ partlist = hd_list(hddata, hw_partition, 1, NULL);
+ for (hd = partlist; hd; hd = hd->next) {
+ if (hd->unix_dev_name && !strncmp(dev->d_name,
+ hd->unix_dev_name, d_name_len))
+ goto got_part_hd;
+ if (hd->unix_dev_name2 && !strncmp(dev->d_name,
+ hd->unix_dev_name2, d_name_len))
+ goto got_part_hd;
+ for (names = hd->unix_dev_names; names;
+ names = names->next) {
+ if (names->str && !strncmp(dev->d_name,
+ names->str, d_name_len))
+ goto got_part_hd;
+ }
+ }
+ /* Failed to find the device. Stop trying and clean up. */
+ goto end_hd;
+got_part_hd:
+ /* Get the whole block device the partition device is on. */
+ hd = hd_get_device_by_idx(hddata, hd->attached_to);
+ if (!hd)
+ goto end_hd;
+got_hd:
+ /*
+ * @hd is now the whole block device either being formatted or
+ * that the partition being formatted is on.
+ *
+ * Loop over each resource of the disk device looking for the
+ * BIOS legacy geometry obtained from EDD which is what Windows
+ * needs to boot.
+ */
+ for (res = hd->res; res; res = res->next) {
+ /* geotype 3 is BIOS legacy. */
+ if (res->any.type != res_disk_geo ||
+ res->disk_geo.geotype != 3)
+ continue;
+ dev->d_heads = res->disk_geo.heads;
+ dev->d_sectors_per_track = res->disk_geo.sectors;
+ done = 1;
+ }
+end_hd:
+ if (partlist)
+ hd_free_hd_list(partlist);
+ hd_free_hd_list(devlist);
+ hd_free_hd_data(hddata);
+ free(hddata);
+ if (done) {
+ ntfs_log_debug("EDD/BIOD legacy heads = %u, sectors "
+ "per track = %u\n", dev->d_heads,
+ dev->d_sectors_per_track);
+ return 0;
+ }
+ }
+skip_hd:
+#endif
+#ifdef HDIO_GETGEO
+ { struct hd_geometry geo;
+
+ if (!dev->d_ops->ioctl(dev, HDIO_GETGEO, &geo)) {
+ dev->d_heads = geo.heads;
+ dev->d_sectors_per_track = geo.sectors;
+ ntfs_log_debug("HDIO_GETGEO heads = %u, sectors per "
+ "track = %u\n", dev->d_heads,
+ dev->d_sectors_per_track);
+ return 0;
+ }
+ err = errno;
+ }
+#endif
+ errno = err;
+ return -1;
+}
+
/**
* ntfs_device_heads_get - get number of heads of device
* @dev: open device
@@ -597,6 +785,7 @@ s64 ntfs_device_partition_start_sector_get(struct ntfs_device *dev)
* EINVAL Input parameter error
* EOPNOTSUPP System does not support HDIO_GETGEO ioctl
* ENOTTY @dev is a file or a device not supporting HDIO_GETGEO
+ * ENOMEM Not enough memory to complete the request
*/
int ntfs_device_heads_get(struct ntfs_device *dev)
{
@@ -604,20 +793,15 @@ int ntfs_device_heads_get(struct ntfs_device *dev)
errno = EINVAL;
return -1;
}
-#ifdef HDIO_GETGEO
- { struct hd_geometry geo;
-
- if (!dev->d_ops->ioctl(dev, HDIO_GETGEO, &geo)) {
- ntfs_log_debug("HDIO_GETGEO heads = %u (0x%x)\n",
- (unsigned)geo.heads,
- (unsigned)geo.heads);
- return geo.heads;
+ if (dev->d_heads == -1) {
+ if (ntfs_device_get_geo(dev) == -1)
+ return -1;
+ if (dev->d_heads == -1) {
+ errno = EINVAL;
+ return -1;
}
}
-#else
- errno = EOPNOTSUPP;
-#endif
- return -1;
+ return dev->d_heads;
}
/**
@@ -631,6 +815,7 @@ int ntfs_device_heads_get(struct ntfs_device *dev)
* EINVAL Input parameter error
* EOPNOTSUPP System does not support HDIO_GETGEO ioctl
* ENOTTY @dev is a file or a device not supporting HDIO_GETGEO
+ * ENOMEM Not enough memory to complete the request
*/
int ntfs_device_sectors_per_track_get(struct ntfs_device *dev)
{
@@ -638,20 +823,15 @@ int ntfs_device_sectors_per_track_get(struct ntfs_device *dev)
errno = EINVAL;
return -1;
}
-#ifdef HDIO_GETGEO
- { struct hd_geometry geo;
-
- if (!dev->d_ops->ioctl(dev, HDIO_GETGEO, &geo)) {
- ntfs_log_debug("HDIO_GETGEO sectors_per_track = %u (0x%x)\n",
- (unsigned)geo.sectors,
- (unsigned)geo.sectors);
- return geo.sectors;
+ if (dev->d_sectors_per_track == -1) {
+ if (ntfs_device_get_geo(dev) == -1)
+ return -1;
+ if (dev->d_sectors_per_track == -1) {
+ errno = EINVAL;
+ return -1;
}
}
-#else
- errno = EOPNOTSUPP;
-#endif
- return -1;
+ return dev->d_sectors_per_track;
}
/**
@@ -682,6 +862,28 @@ int ntfs_device_sector_size_get(struct ntfs_device *dev)
return sect_size;
}
}
+#elif defined(DIOCGSECTORSIZE)
+ {
+ /* FreeBSD */
+ size_t sect_size = 0;
+
+ if (!dev->d_ops->ioctl(dev, DIOCGSECTORSIZE, &sect_size)) {
+ ntfs_log_debug("DIOCGSECTORSIZE sector size = %d bytes\n",
+ (int) sect_size);
+ return sect_size;
+ }
+ }
+#elif defined(DKIOCGETBLOCKSIZE)
+ {
+ /* Mac OS X */
+ uint32_t sect_size = 0;
+
+ if (!dev->d_ops->ioctl(dev, DKIOCGETBLOCKSIZE, &sect_size)) {
+ ntfs_log_debug("DKIOCGETBLOCKSIZE sector size = %d bytes\n",
+ (int) sect_size);
+ return sect_size;
+ }
+ }
#else
errno = EOPNOTSUPP;
#endif