diff --git a/Makefile.am b/Makefile.am index 44fb1f6c..3cfc6525 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,17 +1,23 @@ -SUBDIRS = include libntfs-3g src - -EXTRA_DIST = AUTHORS CREDITS COPYING INSTALL NEWS README autogen.sh AUTOMAKE_OPTIONS = gnu -MAINTAINERCLEANFILES = configure Makefile.in aclocal.m4 compile depcomp \ - install-sh ltmain.sh missing config.guess config.sub config.h.in INSTALL +EXTRA_DIST = AUTHORS CREDITS COPYING NEWS autogen.sh -libtool: $(LIBTOOL_DEPS) - $(SHELL) ./config.status --recheck +MAINTAINERCLEANFILES=\ + configure \ + Makefile.in \ + aclocal.m4 \ + compile \ + depcomp \ + install-sh \ + ltmain.sh \ + missing \ + config.guess \ + config.sub \ + config.h.in \ + config.h.in~ \ + INSTALL -strip: - (cd src && $(MAKE) strip) || exit 1; +SUBDIRS= include libfuse-lite libntfs-3g src -libs: - (cd libntfs-3g && $(MAKE) libs) || exit 1; +doc_DATA = README diff --git a/include/Makefile.am b/include/Makefile.am index 8c73deb8..38cd3003 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -1,3 +1,3 @@ -SUBDIRS = ntfs-3g - MAINTAINERCLEANFILES = Makefile.in + +SUBDIRS = ntfs-3g fuse-lite diff --git a/include/ntfs-3g/Makefile.am b/include/ntfs-3g/Makefile.am index c8f9f9d1..870ec2a5 100644 --- a/include/ntfs-3g/Makefile.am +++ b/include/ntfs-3g/Makefile.am @@ -1,35 +1,36 @@ +MAINTAINERCLEANFILES = Makefile.in + if INSTALL_LIBRARY -linux_ntfsincludedir = $(includedir)/ntfs-3g -linux_ntfsinclude_HEADERS = \ - attrib.h \ - attrlist.h \ - bitmap.h \ - bootsect.h \ - collate.h \ - compat.h \ - compress.h \ - debug.h \ - device.h \ - device_io.h \ - dir.h \ - endians.h \ - index.h \ - inode.h \ - layout.h \ - lcnalloc.h \ - logfile.h \ - logging.h \ - mft.h \ - mst.h \ - ntfstime.h \ - runlist.h \ - security.h \ - support.h \ - types.h \ - unistr.h \ - version.h \ +ntfs3ginclude_HEADERS = \ + attrib.h \ + attrlist.h \ + bitmap.h \ + bootsect.h \ + collate.h \ + compat.h \ + compress.h \ + debug.h \ + device.h \ + device_io.h \ + dir.h \ + endians.h \ + index.h \ + inode.h \ + layout.h \ + lcnalloc.h \ + logfile.h \ + logging.h \ + mft.h \ + misc.h \ + mst.h \ + ntfstime.h \ + runlist.h \ + security.h \ + support.h \ + types.h \ + unistr.h \ + version.h \ volume.h endif -MAINTAINERCLEANFILES = Makefile.in diff --git a/libntfs-3g/Makefile.am b/libntfs-3g/Makefile.am index 5dca7cf5..f2df582d 100644 --- a/libntfs-3g/Makefile.am +++ b/libntfs-3g/Makefile.am @@ -1,70 +1,75 @@ -# -# Before making a release, the LTVERSION string should be modified. -# The string is of the form CURRENT:REVISION:AGE. -# -# CURRENT (C) -# The most recent interface number that this library implements. -# -# REVISION (R) -# The implementation number that this library implements. -# -# AGE (A) -# The difference between the newest and oldest interfaces that this -# library implements. In other works, the library implements all the -# interface numbers in the range from number 'CURRENT - AGE' to -# 'CURRENT'. -# -# This means that: -# -# - If interfaces have been changed or added, but binary compatibility has -# been preserved, change to C+1:0:A+1 -# -# - If binary compatibility has been broken (eg removed or changed -# interfaces) change to C+1:0:0 -# -# - If the interface is the same as the previous version, change to C:R+1:A -# -linux_ntfsincludedir = -I$(top_srcdir)/include/ntfs-3g +MAINTAINERCLEANFILES = Makefile.in if INSTALL_LIBRARY -lib_LTLIBRARIES = libntfs-3g.la +rootlib_LTLIBRARIES=#Create directory +lib_LTLIBRARIES = libntfs-3g.la +pkgconfig_DATA = libntfs-3g.pc else noinst_LTLIBRARIES = libntfs-3g.la endif -libntfs_3g_la_LDFLAGS = -version-number $(LIBNTFS_3G_VERSION) -libntfs_3g_la_CFLAGS = $(LIBNTFS_3G_CFLAGS) +libntfs_3g_la_CFLAGS = $(AM_CFLAGS) -I$(top_srcdir)/include/ntfs-3g + +libntfs_3g_la_LDFLAGS = -version-info $(LIBNTFS_3G_VERSION) -no-undefined + +if FUSE_INTERNAL +libntfs_3g_la_LIBADD = $(top_srcdir)/libfuse-lite/libfuse-lite.la +endif + libntfs_3g_la_SOURCES = \ - attrib.c \ - attrlist.c \ - bitmap.c \ - bootsect.c \ - collate.c \ - compat.c \ - compress.c \ - debug.c \ - device.c \ - device_io.c \ - dir.c \ - index.c \ - inode.c \ - lcnalloc.c \ - logfile.c \ - logging.c \ - mft.c \ - misc.c \ - mst.c \ - runlist.c \ - security.c \ - unistr.c \ - version.c \ + attrib.c \ + attrlist.c \ + bitmap.c \ + bootsect.c \ + collate.c \ + compat.c \ + compress.c \ + debug.c \ + device.c \ + dir.c \ + index.c \ + inode.c \ + lcnalloc.c \ + logfile.c \ + logging.c \ + mft.c \ + misc.c \ + mst.c \ + runlist.c \ + security.c \ + unistr.c \ + version.c \ volume.c -AM_CPPFLAGS = $(linux_ntfsincludedir) $(all_includes) +if NTFS_DEVICE_DEFAULT_IO_OPS +if WINDOWS +libntfs_3g_la_SOURCES += win32_io.c +else +libntfs_3g_la_SOURCES += unix_io.c +endif +endif -EXTRA_DIST = unix_io.c +# We may need to move .so files to root +# And create ldscript or symbolic link from /usr +install-exec-hook: install-rootlibLTLIBRARIES +if INSTALL_LIBRARY + if [ "$(rootlibdir)" != "$(libdir)" ]; then \ + $(MV) -f "$(DESTDIR)/$(libdir)"/libntfs-3g.so* "$(DESTDIR)/$(rootlibdir)"; \ + fi +if GENERATE_LDSCRIPT + if [ "$(rootlibdir)" != "$(libdir)" ]; then \ + $(install_sh_PROGRAM) "libntfs-3g.script.so" "$(DESTDIR)/$(libdir)/libntfs-3g.so"; \ + fi +else + if [ "$(rootlibdir)" != "$(libdir)" ]; then \ + $(LN_S) "$(rootlibdir)/libntfs-3g.so" "$(DESTDIR)/$(libdir)/libntfs-3g.so"; \ + fi +endif +endif -MAINTAINERCLEANFILES = Makefile.in +uninstall-local: +if INSTALL_LIBRARY + $(RM) -f "$(DESTDIR)/$(rootlibdir)"/libntfs-3g.so* +endif -libs: $(lib_LTLIBRARIES) diff --git a/src/Makefile.am b/src/Makefile.am index f7e10dbc..c7da069c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,39 +1,36 @@ -if REALLYSTATIC -AM_LIBS = $(top_builddir)/libntfs-3g/.libs/libntfs-3g.a -AM_LFLAGS = -static -STATIC_LINK = $(CC) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ + +MAINTAINERCLEANFILES = Makefile.in + +if FUSE_INTERNAL +FUSE_CFLAGS = -I$(top_srcdir)/include/fuse-lite +FUSE_LIBS = else -AM_LIBS = $(top_builddir)/libntfs-3g/libntfs-3g.la -AM_LFLAGS = $(all_libraries) -LIBTOOL_LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ +FUSE_CFLAGS = $(FUSE_MODULE_CFLAGS) +FUSE_LIBS = $(FUSE_MODULE_LIBS) endif -# Workaround to make REALLYSTATIC work with automake 1.5. -LINK=$(STATIC_LINK) $(LIBTOOL_LINK) +bin_PROGRAMS = ntfs-3g.probe +rootbin_PROGRAMS = ntfs-3g +rootsbin_DATA = #Create directory +man_MANS = ntfs-3g.8 ntfs-3g.probe.8 -man_MANS = ntfs-3g.8 +ntfs_3g_LDADD = $(FUSE_LIBS) $(top_builddir)/libntfs-3g/libntfs-3g.la +if REALLYSTATIC +ntfs_3g_LDFLAGS = $(AM_LDFLAGS) -all-static +endif +ntfs_3g_CFLAGS = \ + $(AM_CFLAGS) \ + -DFUSE_USE_VERSION=26 \ + $(FUSE_CFLAGS) \ + -I$(top_srcdir)/include/ntfs-3g +ntfs_3g_SOURCES = ntfs-3g.c utils.c utils.h -MAINTAINERCLEANFILES = Makefile.in - -linux_ntfsincludedir = -I$(top_srcdir)/include/ntfs - -bin_PROGRAMS = ntfs-3g - -# Set the include path. -AM_CPPFLAGS = -I$(top_srcdir)/include/ntfs-3g $(all_includes) - -ntfs_3g_SOURCES = ntfs-3g.c utils.c utils.h -ntfs_3g_LDADD = $(AM_LIBS) $(FUSE_MODULE_LIBS) $(libfuse_libs) -ntfs_3g_LDFLAGS = $(AM_LFLAGS) -ntfs_3g_CFLAGS = $(FUSE_MODULE_CFLAGS) -DFUSE_USE_VERSION=26 - -# Extra targets - -strip: $(bin_PROGRAMS) - $(STRIP) $^ - -libs: - (cd ../libntfs-3g && $(MAKE) libs) || exit 1; +ntfs_3g_probe_LDADD = $(top_builddir)/libntfs-3g/libntfs-3g.la +if REALLYSTATIC +ntfs_3g_probe_LDFLAGS = $(AM_LDFLAGS) -all-static +endif +ntfs_3g_probe_CFLAGS = $(AM_CFLAGS) -I$(top_srcdir)/include/ntfs-3g +ntfs_3g_probe_SOURCES = ntfs-3g.probe.c utils.c utils.h if RUN_LDCONFIG install-exec-hook: @@ -41,14 +38,13 @@ install-exec-hook: endif install-exec-local: - $(INSTALL) -d $(DESTDIR)/sbin - $(LN_S) -f $(bindir)/ntfs-3g $(DESTDIR)/sbin/mount.ntfs-3g + $(INSTALL) -d "$(DESTDIR)$(rootsbindir)" + $(LN_S) -f "$(rootbindir)/ntfs-3g" "$(DESTDIR)/sbin/mount.ntfs-3g" install-data-local: - $(INSTALL) -d $(DESTDIR)$(man8dir) - $(LN_S) -f ntfs-3g.8 $(DESTDIR)$(man8dir)/mount.ntfs-3g.8 + $(INSTALL) -d "$(DESTDIR)$(man8dir)" + $(LN_S) -f ntfs-3g.8 "$(DESTDIR)$(man8dir)/mount.ntfs-3g.8" uninstall-local: - $(RM) -f $(DESTDIR)/sbin/mount.ntfs-3g - $(RM) -f $(DESTDIR)$(man8dir)/mount.ntfs-3g.8 - + $(RM) -f "$(DESTDIR)/sbin/mount.ntfs-3g" + $(RM) -f "$(DESTDIR)$(man8dir)/mount.ntfs-3g.8" diff --git a/src/ntfs-3g.probe.c b/src/ntfs-3g.probe.c new file mode 100644 index 00000000..8981c064 --- /dev/null +++ b/src/ntfs-3g.probe.c @@ -0,0 +1,167 @@ +/** + * ntfs-3g.probe - Probe NTFS volume mountability + * + * Copyright (c) 2007 Szabolcs Szakacsits + * + * This program 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 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 + */ + +#include "config.h" + +#ifdef HAVE_STDLIB_H +#include +#endif +#ifdef HAVE_STRING_H +#include +#endif +#ifdef HAVE_ERRNO_H +#include +#endif +#include + +#include "volume.h" +#include "utils.h" +#include "misc.h" + +#ifndef PATH_MAX +#define PATH_MAX 4096 +#endif + +typedef enum { + PROBE_UNSET, + PROBE_READONLY, + PROBE_READWRITE +} probe_t; + +static struct options { + probe_t probetype; + char *device; +} opts; + +static const char *EXEC_NAME = "ntfs-3g.probe"; + +static const char *usage_msg = +"\n" +"%s %s - Probe NTFS volume mountability\n" +"\n" +"Copyright (C) 2007 Szabolcs Szakacsits\n" +"\n" +"Usage: %s <--readonly|--readwrite> \n" +"\n" +"Example: ntfs-3g.probe --readwrite /dev/sda1\n" +"\n" +"%s"; + +static int ntfs_open(const char *device) +{ + ntfs_volume *vol; + unsigned long flags = 0; + int ret = NTFS_VOLUME_OK; + + if (opts.probetype == PROBE_READONLY) + flags |= MS_RDONLY; + + vol = ntfs_mount(device, flags); + if (!vol) + ret = ntfs_volume_error(errno); + + ntfs_umount(vol, FALSE); + + return ret; +} + +static void usage(void) +{ + ntfs_log_info(usage_msg, EXEC_NAME, VERSION, EXEC_NAME, ntfs_home); +} + +static int parse_options(int argc, char *argv[]) +{ + int c; + + static const char *sopt = "-hrw"; + static const struct option lopt[] = { + { "readonly", no_argument, NULL, 'r' }, + { "readwrite", no_argument, NULL, 'w' }, + { "help", no_argument, NULL, 'h' }, + { NULL, 0, NULL, 0 } + }; + + opterr = 0; /* We handle errors. */ + opts.probetype = PROBE_UNSET; + + while ((c = getopt_long(argc, argv, sopt, lopt, NULL)) != -1) { + switch (c) { + case 1: /* A non-option argument */ + if (!opts.device) { + opts.device = ntfs_malloc(PATH_MAX + 1); + if (!opts.device) + return -1; + + strncpy(opts.device, optarg, PATH_MAX); + opts.device[PATH_MAX] = 0; + } else { + ntfs_log_error("%s: You must specify exactly " + "one device\n", EXEC_NAME); + return -1; + } + break; + case 'h': + usage(); + exit(0); + case 'r': + opts.probetype = PROBE_READONLY; + break; + case 'w': + opts.probetype = PROBE_READWRITE; + break; + default: + ntfs_log_error("%s: Unknown option '%s'.\n", EXEC_NAME, + argv[optind - 1]); + return -1; + } + } + + if (!opts.device) { + ntfs_log_error("ERROR: %s: Device is missing\n", EXEC_NAME); + return -1; + } + + if (opts.probetype == PROBE_UNSET) { + ntfs_log_error("ERROR: %s: Probe type is missing\n", EXEC_NAME); + return -1; + } + + return 0; +} + +int main(int argc, char *argv[]) +{ + int err; + + ntfs_log_set_handler(ntfs_log_handler_stderr); + + if (parse_options(argc, argv)) { + usage(); + exit(NTFS_VOLUME_SYNTAX_ERROR); + } + + err = ntfs_open(opts.device); + + free(opts.device); + exit(err); +} + diff --git a/src/utils.h b/src/utils.h index 400d465f..2d47ca4b 100644 --- a/src/utils.h +++ b/src/utils.h @@ -32,8 +32,6 @@ extern const char *ntfs_home; extern const char *ntfs_gpl; int utils_set_locale(void); - -ntfs_volume *utils_mount_volume(const char *device, const char *mntpoint, - unsigned long flags); +void utils_mount_error(const char *vol, const char *mntpoint, int err); #endif /* _NTFS_UTILS_H_ */