Changes by: antona
Update of /cvsroot/linux-ntfs/ntfsprogs/libntfs
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6285/libntfs
Modified Files:
bootsect.c device.c gnome-vfs-method.c unix_io.c volume.c
win32_io.c
Log Message:
Wheee! Lots of last minute fixes and enhancements.
- Compiler warning fixes for gnome-vfs and fuse modules. (Anton)
- Change volume mounting (actually device opening) to happen with
O_EXCL bit set so at least on Linux no one can change the device
block size under our feet. (Anton)
- Change volume mounting and mkntfs to set the device block size to the
sector size using BLKBSZSET ioctl (Linux only). This should be
optimal for performance and should fixes the bug of not being able to
create the backup boot sector if the number of sectors on the device
is odd, the sector size is 512 bytes, and the kernel is 2.4. (Anton)
- Enforce cluster size, mft record size, and index record size to be at
least equal to the sector size and verify they are still valid and in
particular display a warning message if the volume will not be
mountable by the kernel driver (it requires mft record size and index
record size to be below or equal to the system page size which we
determine using sysconf()). (Anton)
Index: bootsect.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/libntfs/bootsect.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -p -r1.19 -r1.20
--- bootsect.c 5 Nov 2005 01:34:21 -0000 1.19
+++ bootsect.c 3 Feb 2006 22:19:19 -0000 1.20
@@ -1,7 +1,7 @@
/**
* bootsect.c - Boot sector handling code. Part of the Linux-NTFS project.
*
- * Copyright (c) 2000-2005 Anton Altaparmakov
+ * Copyright (c) 2000-2006 Anton Altaparmakov
* Copyright (c) 2005 Yura Pakhuchiy
*
* This program/include file is free software; you can redistribute it and/or
@@ -270,4 +270,3 @@ int ntfs_boot_sector_parse(ntfs_volume *
vol->mftmirr_size = vol->cluster_size / vol->mft_record_size;
return 0;
}
-
Index: device.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/libntfs/device.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -p -r1.23 -r1.24
--- device.c 19 Nov 2005 14:55:52 -0000 1.23
+++ device.c 3 Feb 2006 22:19:19 -0000 1.24
@@ -1,7 +1,7 @@
/**
* device.c - Low level device io functions. Part of the Linux-NTFS project.
*
- * Copyright (c) 2004 Anton Altaparmakov
+ * Copyright (c) 2004-2006 Anton Altaparmakov
*
* 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
@@ -50,6 +50,9 @@
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
+#ifdef HAVE_SYS_MOUNT_H
+#include <sys/mount.h>
+#endif
#ifdef HAVE_LINUX_FD_H
#include <linux/fd.h>
#endif
@@ -75,6 +78,9 @@
#if defined(linux) && defined(_IO) && !defined(BLKSSZGET)
# define BLKSSZGET _IO(0x12,104) /* Get device sector size in bytes. */
#endif
+#if defined(linux) && defined(_IO) && !defined(BLKBSZSET)
+# define BLKBSZSET _IOW(0x12,113,size_t) /* Set device block size in bytes. */
+#endif
/**
* ntfs_device_alloc - allocate an ntfs device structure and pre-initialize it
@@ -641,6 +647,7 @@ int ntfs_device_sectors_per_track_get(st
#endif
return -1;
}
+
/**
* ntfs_device_sector_size_get - get sector size of a device
* @dev: open device
@@ -650,8 +657,8 @@ int ntfs_device_sectors_per_track_get(st
*
* The following error codes are defined:
* EINVAL Input parameter error
- * EOPNOTSUPP System does not support HDIO_GETGEO ioctl
- * ENOTTY @dev is a file or a device not supporting HDIO_GETGEO
+ * EOPNOTSUPP System does not support BLKSSZGET ioctl
+ * ENOTTY @dev is a file or a device not supporting BLKSSZGET
*/
int ntfs_device_sector_size_get(struct ntfs_device *dev)
{
@@ -674,3 +681,37 @@ int ntfs_device_sector_size_get(struct n
return -1;
}
+/**
+ * ntfs_device_block_size_set - set block size of a device
+ * @dev: open device
+ * @block_size: block size to set @dev to
+ *
+ * On success, return 0.
+ * On error return -1 with errno set to the error code.
+ *
+ * The following error codes are defined:
+ * EINVAL Input parameter error
+ * EOPNOTSUPP System does not support HDIO_GETGEO ioctl
+ * ENOTTY @dev is a file or a device not supporting HDIO_GETGEO
+ */
+int ntfs_device_block_size_set(struct ntfs_device *dev, int block_size)
+{
+ if (!dev) {
+ errno = EINVAL;
+ return -1;
+ }
+#ifdef BLKBSZSET
+ {
+ size_t s_block_size = block_size;
+ if (!dev->d_ops->ioctl(dev, BLKBSZSET, &s_block_size)) {
+ ntfs_log_debug("Used BLKBSZSET to set block size to "
+ "%d bytes\n", block_size);
+ return 0;
+ }
+ }
+#else
+ errno = EOPNOTSUPP;
+#endif
+ return -1;
+}
+
Index: gnome-vfs-method.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/libntfs/gnome-vfs-method.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -p -r1.7 -r1.8
--- gnome-vfs-method.c 28 Sep 2005 13:47:48 -0000 1.7
+++ gnome-vfs-method.c 3 Feb 2006 22:19:19 -0000 1.8
@@ -3,7 +3,7 @@
* libntfs. Part of the Linux-NTFS project.
*
* Copyright (c) 2003 Jan Kratochvil <pro...@ja...>
- * Copyright (c) 2003-2005 Anton Altaparmakov
+ * Copyright (c) 2003-2006 Anton Altaparmakov
*
* 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
@@ -659,7 +659,7 @@ static GnomeVFSResult libntfs_gnomevfs_s
static GnomeVFSResult libntfs_gnomevfs_tell(GnomeVFSMethod *method,
GnomeVFSMethodHandle *method_handle,
- GnomeVFSFileOffset *offset_return)
+ GnomeVFSFileSize *offset_return)
{
GnomeVFSResult errvfsresult;
struct libntfs_file *libntfs_file;
@@ -676,7 +676,7 @@ static GnomeVFSResult libntfs_gnomevfs_t
return errvfsresult;
*offset_return = libntfs_file->pos;
- g_assert(*offset_return == libntfs_file->pos);
+ g_assert((s64)*offset_return == libntfs_file->pos);
return errvfsresult;
}
Index: unix_io.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/libntfs/unix_io.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -p -r1.9 -r1.10
--- unix_io.c 4 Dec 2005 22:42:51 -0000 1.9
+++ unix_io.c 3 Feb 2006 22:19:19 -0000 1.10
@@ -1,7 +1,7 @@
/**
* unix_io.c - Unix style disk io functions. Part of the Linux-NTFS project.
*
- * Copyright (c) 2000-2003 Anton Altaparmakov
+ * Copyright (c) 2000-2006 Anton Altaparmakov
*
* 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
@@ -60,12 +60,13 @@
#include "device.h"
#include "logging.h"
-#if defined(linux) && defined(_IO) && !defined(BLKGETSIZE)
-# define BLKGETSIZE _IO(0x12,96) /* Get device size in 512byte blocks. */
-#endif
-
#define DEV_FD(dev) (*(int *)dev->d_private)
+/* Define to nothing if not present on this system. */
+#ifndef O_EXCL
+# define O_EXCL 0
+#endif
+
/**
* ntfs_device_unix_io_open - Open a device and lock it exclusively
* @dev:
@@ -86,8 +87,12 @@ static int ntfs_device_unix_io_open(stru
}
if (!(dev->d_private = malloc(sizeof(int))))
return -1;
- /* Open the device/file obtaining the file descriptor. */
- if ((*(int *)dev->d_private = open(dev->d_name, flags)) == -1) {
+ /*
+ * Open the device/file obtaining the file descriptor for exclusive
+ * access.
+ */
+ *(int*)dev->d_private = open(dev->d_name, flags | O_EXCL);
+ if (*(int*)dev->d_private == -1) {
err = errno;
goto err_out;
}
Index: volume.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/libntfs/volume.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -p -r1.67 -r1.68
--- volume.c 15 Nov 2005 16:31:40 -0000 1.67
+++ volume.c 3 Feb 2006 22:19:19 -0000 1.68
@@ -1,7 +1,7 @@
/**
* volume.c - NTFS volume handling code. Part of the Linux-NTFS project.
*
- * Copyright (c) 2000-2005 Anton Altaparmakov
+ * Copyright (c) 2000-2006 Anton Altaparmakov
* Copyright (c) 2002-2005 Szabolcs Szakacsits
* Copyright (c) 2004-2005 Richard Russon
*
@@ -467,7 +467,12 @@ ntfs_volume *ntfs_volume_startup(struct
}
free(bs);
bs = NULL;
-
+ /* Now set the device block size to the sector size. */
+ if (ntfs_device_block_size_set(vol->dev, vol->sector_size))
+ ntfs_log_debug("Failed to set the device block size to the "
+ "sector size. This may affect performance "
+ "but should be harmless otherwise. Error: "
+ "%s\n", strerror(errno));
/*
* We now initialize the cluster allocator.
*
Index: win32_io.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/libntfs/win32_io.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -p -r1.45 -r1.46
--- win32_io.c 4 Dec 2005 22:42:51 -0000 1.45
+++ win32_io.c 3 Feb 2006 22:19:20 -0000 1.46
@@ -4,7 +4,7 @@
* Part of the Linux-NTFS project.
*
* Copyright (c) 2003-2004 Lode Leroy
- * Copyright (c) 2003-2005 Anton Altaparmakov
+ * Copyright (c) 2003-2006 Anton Altaparmakov
* Copyright (c) 2004-2005 Yuval Fledel
*
* This program/include file is free software; you can redistribute it and/or
@@ -1434,6 +1434,12 @@ static int ntfs_device_win32_ioctl(struc
ntfs_log_debug("BLKSSZGET detected.\n");
return ntfs_win32_blksszget(dev, (int *)argp);
#endif
+#ifdef BLKBSZSET
+ case BLKBSZSET:
+ ntfs_log_debug("BLKBSZSET detected.\n");
+ /* Nothing to do on Windows. */
+ return 0;
+#endif
default:
ntfs_log_debug("unimplemented ioctl %d.\n", request);
errno = EOPNOTSUPP;
|