[ntfs-3g-devel] [PATCH v5] Add ioctl support to ntfs-3g and implement FITRIM (fstrim) ioctl.

2014-07-31 Thread Richard W.M. Jones
---
 configure.ac |   3 +-
 include/ntfs-3g/ioctl.h  |  30 
 include/ntfs-3g/volume.h |   3 -
 libntfs-3g/Makefile.am   |   1 +
 libntfs-3g/ioctl.c   | 382 +++
 src/ntfs-3g.c|  31 +++-
 6 files changed, 440 insertions(+), 10 deletions(-)
 create mode 100644 include/ntfs-3g/ioctl.h
 create mode 100644 libntfs-3g/ioctl.c

diff --git a/configure.ac b/configure.ac
index d1f7e10..0da527f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -471,7 +471,8 @@ AC_CHECK_HEADERS([ctype.h fcntl.h libgen.h libintl.h 
limits.h locale.h \
regex.h endian.h byteswap.h sys/byteorder.h sys/disk.h sys/endian.h \
sys/param.h sys/ioctl.h sys/mkdev.h sys/mount.h sys/stat.h sys/types.h \
sys/vfs.h sys/statvfs.h sys/sysmacros.h linux/major.h linux/fd.h \
-   linux/hdreg.h machine/endian.h windows.h syslog.h pwd.h malloc.h])
+   linux/fs.h inttypes.h linux/hdreg.h \
+   machine/endian.h windows.h syslog.h pwd.h malloc.h])
 
 # Checks for typedefs, structures, and compiler characteristics.
 AC_HEADER_STDBOOL
diff --git a/include/ntfs-3g/ioctl.h b/include/ntfs-3g/ioctl.h
new file mode 100644
index 000..4ed6c01
--- /dev/null
+++ b/include/ntfs-3g/ioctl.h
@@ -0,0 +1,30 @@
+/*
+ *
+ * Copyright (c) 2014 Jean-Pierre Andre
+ *
+ */
+
+/*
+ * 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
+ */
+
+#ifndef IOCTL_H
+#define IOCTL_H
+
+int ntfs_ioctl(ntfs_inode *ni, int cmd, void *arg,
+unsigned int flags, void *data);
+
+#endif /* IOCTL_H */
diff --git a/include/ntfs-3g/volume.h b/include/ntfs-3g/volume.h
index a181ccc..aeb779a 100644
--- a/include/ntfs-3g/volume.h
+++ b/include/ntfs-3g/volume.h
@@ -36,9 +36,6 @@
 #ifdef HAVE_SYS_PARAM_H
 #include sys/param.h
 #endif
-#ifdef HAVE_SYS_MOUNT_H
-#include sys/mount.h
-#endif
 #ifdef HAVE_MNTENT_H
 #include mntent.h
 #endif
diff --git a/libntfs-3g/Makefile.am b/libntfs-3g/Makefile.am
index 47337b2..d6b150e 100644
--- a/libntfs-3g/Makefile.am
+++ b/libntfs-3g/Makefile.am
@@ -31,6 +31,7 @@ libntfs_3g_la_SOURCES =   \
efs.c   \
index.c \
inode.c \
+   ioctl.c \
lcnalloc.c  \
logfile.c   \
logging.c   \
diff --git a/libntfs-3g/ioctl.c b/libntfs-3g/ioctl.c
new file mode 100644
index 000..bbbceb9
--- /dev/null
+++ b/libntfs-3g/ioctl.c
@@ -0,0 +1,382 @@
+/**
+ * ioctl.c - Processing of ioctls
+ *
+ *  This module is part of ntfs-3g library
+ *
+ * Copyright (c) 2014 Jean-Pierre Andre
+ * Copyright (c) 2014 Red Hat, 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
+ * 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
+ */
+
+#include config.h
+
+#ifdef HAVE_STDIO_H
+#include stdio.h
+#endif
+#ifdef HAVE_INTTYPES_H
+#include inttypes.h
+#endif
+#ifdef HAVE_STRING_H
+#include string.h
+#endif
+#ifdef HAVE_ERRNO_H
+#include errno.h
+#endif
+#ifdef HAVE_FCNTL_H
+#include fcntl.h
+#endif
+#ifdef HAVE_UNISTD_H
+#include unistd.h
+#endif
+#ifdef HAVE_STDLIB_H
+#include stdlib.h
+#endif
+#ifdef HAVE_LIMITS_H
+#include limits.h
+#endif
+#include syslog.h
+
+#ifdef HAVE_SETXATTR
+#include sys/xattr.h
+#endif
+
+#ifdef HAVE_SYS_TYPES_H
+#include sys/types.h
+#endif
+
+#ifdef HAVE_SYS_STAT_H
+#include sys/stat.h
+#endif
+
+#ifdef HAVE_LINUX_FS_H
+#include linux/fs.h
+#endif
+
+#include dirent.h
+
+#include compat.h
+#include debug.h
+#include bitmap.h
+#include attrib.h
+#include inode.h
+#include layout.h
+#include 

Re: [ntfs-3g-devel] [PATCH v5] Add ioctl support to ntfs-3g and implement FITRIM (fstrim) ioctl.

2014-07-31 Thread Jean-Pierre André
Hi,

Thanks, Richard, for your contribution to ntfs-3g.

This is now available on
http://sourceforge.net/p/ntfs-3g/ntfs-3g/ci/f4e3f126df0a577903ec043dbcbe38e2863ce3d6/

Please use this as a reference for further changes.

I have added a comment to explain why sys/mount.h should
not be included. I have also added support for fstrim from
lowntfs-3g.

I have borrowed a computer with a SSD, the returned
discard parameters were :
discard_granularity : 512
discard_max_bytes : 2147450880
sector_size : 512
optimal_iosize : 0 (?)

So I would expect fstrim would run fine with a SSD,
but as this is not my computer, I did not actually fstrim.

Jean-Pierre

Richard W.M. Jones wrote:
 ---
   configure.ac |   3 +-
   include/ntfs-3g/ioctl.h  |  30 
   include/ntfs-3g/volume.h |   3 -
   libntfs-3g/Makefile.am   |   1 +
   libntfs-3g/ioctl.c   | 382 
 +++
   src/ntfs-3g.c|  31 +++-
   6 files changed, 440 insertions(+), 10 deletions(-)
   create mode 100644 include/ntfs-3g/ioctl.h
   create mode 100644 libntfs-3g/ioctl.c




--
Infragistics Professional
Build stunning WinForms apps today!
Reboot your WinForms applications with our WinForms controls. 
Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071iu=/4140/ostg.clktrk
___
ntfs-3g-devel mailing list
ntfs-3g-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ntfs-3g-devel


Re: [ntfs-3g-devel] [PATCH v5] Add ioctl support to ntfs-3g and implement FITRIM (fstrim) ioctl.

2014-07-31 Thread Richard W.M. Jones
On Thu, Jul 31, 2014 at 02:23:59PM +0200, Jean-Pierre André wrote:
 Hi,
 
 Thanks, Richard, for your contribution to ntfs-3g.
 
 This is now available on
 http://sourceforge.net/p/ntfs-3g/ntfs-3g/ci/f4e3f126df0a577903ec043dbcbe38e2863ce3d6/

Thanks.  I have added the feature to Fedora Rawhide so it should get
some wider testing, particularly as that will enable the code to be
used through libguestfs on real Windows disk images.

http://pkgs.fedoraproject.org/cgit/ntfs-3g.git/commit/?id=03ba43f400387aed1bdb55ffba7cb8bccc70f700

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
libguestfs lets you edit virtual machines.  Supports shell scripting,
bindings from many languages.  http://libguestfs.org

--
Infragistics Professional
Build stunning WinForms apps today!
Reboot your WinForms applications with our WinForms controls. 
Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071iu=/4140/ostg.clktrk
___
ntfs-3g-devel mailing list
ntfs-3g-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ntfs-3g-devel