[Patch-NTFS-2.3.99-pre6/7-1]

From: Anton Altaparmakov (aia21@cus.cam.ac.uk)
Date: Tue May 02 2000 - 01:11:59 EST


Linus,

please consider this patch for the next 2.3.99-pre* kernel. Thanks.

Description of patch:

* fixed two bugs in the two unicode and unicode/ASCII strncmp functions

* fixed a bug in attribute detection

* added the rest of the NT4 NTFS attributes (except the extended ones) to
the detection code and the ntfs super_block structures

* added detection of the ntfs volume version number and set the
appropriate flag to readonly if the version is 3.0 or above (ie. Win2k).
[If anyone is interested, WinNT4 SP6a uses version 1.2] - These version
numbers were derived empirically but they seem reasonable so I hope they
are fine.

* patch includes the gcc 2.7.2.3 ntfs compilation fixlet submitted by
Arjan van de Ven (in case you haven't committed it already).

* Bumped the version number up to 000502.

That's all for now.

Regards,

Anton

-- 
Anton Altaparmakov       Phone: +44-(0)1223-333541 (lab)
Christ's College         eMail: AntonA@bigfoot.com
Cambridge CB2 3BU          WWW: http://www-stu.christs.cam.ac.uk/~aia21/
United Kingdom             ICQ: 8561279

diff -ur linux-2.3.99-pre6/Documentation/Configure.help linux/Documentation/Configure.help --- linux-2.3.99-pre6/Documentation/Configure.help Tue Apr 25 00:15:01 2000 +++ linux/Documentation/Configure.help Tue May 2 04:43:38 2000 @@ -10444,6 +10444,8 @@ damaged. Also, make sure to run chkdsk from within Microsoft Windows NT after having performed any writes to a NTFS partition from Linux to detect any problems as early as possible. + Please note that write support is limited to Windows NT4 and + earlier versions. If unsure, say N. diff -ur linux-2.3.99-pre6/Documentation/filesystems/ntfs.txt linux/Documentation/filesystems/ntfs.txt --- linux-2.3.99-pre6/Documentation/filesystems/ntfs.txt Tue Apr 11 07:02:59 2000 +++ linux/Documentation/filesystems/ntfs.txt Tue May 2 04:43:38 2000 @@ -12,6 +12,9 @@ sets should work as well - if the md driver can be talked into using the same layout as Windows NT. +Please note that the experimental write support is limited to +Windows NT4 and earlier versions. + The ntfs driver supports the following mount options: iocharset=name Character set to use when returning file names. Unlike VFAT, NTFS suppresses names that contain diff -ur linux-2.3.99-pre6/fs/ntfs/Makefile linux/fs/ntfs/Makefile --- linux-2.3.99-pre6/fs/ntfs/Makefile Tue Apr 11 07:02:59 2000 +++ linux/fs/ntfs/Makefile Tue May 2 04:43:38 2000 @@ -3,7 +3,7 @@ O_TARGET := ntfs.o O_OBJS := fs.o sysctl.o support.o util.o inode.o dir.o super.o attr.o M_OBJS := $(O_TARGET) -EXTRA_CFLAGS = -DNTFS_IN_LINUX_KERNEL -DNTFS_VERSION=\"000410\" +EXTRA_CFLAGS = -DNTFS_IN_LINUX_KERNEL -DNTFS_VERSION=\"000502\" include $(TOPDIR)/Rules.make diff -ur linux-2.3.99-pre6/fs/ntfs/fs.c linux/fs/ntfs/fs.c --- linux-2.3.99-pre6/fs/ntfs/fs.c Wed Apr 26 01:28:56 2000 +++ linux/fs/ntfs/fs.c Tue May 2 04:43:38 2000 @@ -2,10 +2,10 @@ * fs.c * NTFS driver for Linux 2.3.x * - * Copyright (C) 2000, Anton Altaparmakov * Copyright (C) 1995-1997, 1999 Martin von Löwis * Copyright (C) 1996 Richard Russon * Copyright (C) 1996-1997 Régis Duchesne + * Copyright (C) 2000, Anton Altaparmakov */ #ifdef HAVE_CONFIG_H @@ -937,7 +937,7 @@ return register_filesystem(&ntfs_fs_type); } -static __exit void exit_ntfs_fs(void) +static void __exit exit_ntfs_fs(void) { SYSCTL(0); ntfs_debug(DEBUG_OTHER, "unregistering %s\n",ntfs_fs_type.name); diff -ur linux-2.3.99-pre6/fs/ntfs/struct.h linux/fs/ntfs/struct.h --- linux-2.3.99-pre6/fs/ntfs/struct.h Fri Dec 19 23:24:21 1997 +++ linux/fs/ntfs/struct.h Tue May 2 04:43:38 2000 @@ -3,6 +3,7 @@ * Structure definitions * * Copyright (C) 1997 Régis Duchesne + * Copyright (C) 2000 Anton Altaparmakov */ /* Necessary forward definition */ @@ -42,7 +43,10 @@ ntfs_u32 at_standard_information; ntfs_u32 at_attribute_list; ntfs_u32 at_file_name; + ntfs_u32 at_volume_version; ntfs_u32 at_security_descriptor; + ntfs_u32 at_volume_name; + ntfs_u32 at_volume_information; ntfs_u32 at_data; ntfs_u32 at_index_root; ntfs_u32 at_index_allocation; diff -ur linux-2.3.99-pre6/fs/ntfs/super.c linux/fs/ntfs/super.c --- linux-2.3.99-pre6/fs/ntfs/super.c Thu Dec 9 21:14:30 1999 +++ linux/fs/ntfs/super.c Tue May 2 06:40:20 2000 @@ -4,6 +4,7 @@ * Copyright (C) 1995-1997, 1999 Martin von Löwis * Copyright (C) 1996-1997 Régis Duchesne * Copyright (C) 1999 Steve Dodd + * Copyright (C) 2000 Anton Altparmakov */ #include "ntfstypes.h" @@ -62,7 +63,10 @@ vol->at_standard_information=0x10; vol->at_attribute_list=0x20; vol->at_file_name=0x30; + vol->at_volume_version=0x40; vol->at_security_descriptor=0x50; + vol->at_volume_name=0x60; + vol->at_volume_information=0x70; vol->at_data=0x80; vol->at_index_root=0x90; vol->at_index_allocation=0xA0; @@ -141,8 +145,18 @@ }else if(ntfs_ua_strncmp(name,"$FILE_NAME",64)==0){ vol->at_file_name=type; check_type=0x30; + }else if(ntfs_ua_strncmp(name,"$VOLUME_VERSION",64)==0){ + vol->at_volume_version=type; + check_type=0x40; }else if(ntfs_ua_strncmp(name,"$SECURITY_DESCRIPTOR",64)==0){ - vol->at_file_name=type; + vol->at_security_descriptor=type; + check_type=0x50; + }else if(ntfs_ua_strncmp(name,"$VOLUME_NAME",64)==0){ + vol->at_volume_name=type; + check_type=0x60; + }else if(ntfs_ua_strncmp(name,"$VOLUME_INFORMATION",64)==0){ + vol->at_volume_information=type; + check_type=0x70; }else if(ntfs_ua_strncmp(name,"$DATA",64)==0){ vol->at_data=type; check_type=0x80; @@ -158,6 +172,7 @@ }else if(ntfs_ua_strncmp(name,"$SYMBOLIC_LINK",64)==0 || ntfs_ua_strncmp(name,"$REPARSE_POINT",64)==0){ vol->at_symlink=type; + check_type=0xC0; } if(check_type && check_type!=type){ ntfs_error("Unexpected type %x for %x\n",type,check_type); @@ -196,10 +211,32 @@ return error; } +/* ntfs_get_version will determine the NTFS version of the + volume and will return the version in a BCD format, with + the MSB being the major version number and the LSB the + minor one. Otherwise return <0 on error. + Example: version 3.1 will be returned as 0x0301. + This has the obvious limitation of not coping with version + numbers above 0x80 but that shouldn't be a problem... */ +int ntfs_get_version(ntfs_inode* volume) +{ + ntfs_attribute *volinfo; + int i; + + volinfo = ntfs_find_attr(volume, volume->vol->at_volume_information, 0); + if (!volinfo) + return -EINVAL; + if (!volinfo->resident) { + ntfs_error("Volume information attribute is not resident!\n"); + return -EINVAL; + } + return ((ntfs_u8*)volinfo->d.data)[8] << 8 | ((ntfs_u8*)volinfo->d.data)[9]; +} + int ntfs_load_special_files(ntfs_volume *vol) { int error; - ntfs_inode upcase,attrdef; + ntfs_inode upcase, attrdef, volume; vol->mft_ino=(ntfs_inode*)ntfs_calloc(3*sizeof(ntfs_inode)); error=ENOMEM; @@ -232,6 +269,21 @@ error=ntfs_init_attrdef(&attrdef); ntfs_clear_inode(&attrdef); if(error)return error; + + /* Check for NTFS version and if Win2k version (ie. 3.0+) + do not allow write access since the driver write support + is broken, especially for Win2k. */ + ntfs_debug(DEBUG_BSD,"Going to load VOLUME\n"); + error = ntfs_init_inode(&volume,vol,FILE_VOLUME); + if (error) return error; + if ((error = ntfs_get_version(&volume)) >= 0x0300) { + NTFS_SB(vol)->s_flags |= MS_RDONLY; + ntfs_error("Warning! NTFS volume version is Win2k+: Mounting read-only\n"); + } + ntfs_clear_inode(&volume); + if (error < 0) return error; + ntfs_debug(DEBUG_BSD, "NTFS volume is version %d.%d\n", error >> 8, error & 0xff); + return 0; } diff -ur linux-2.3.99-pre6/fs/ntfs/util.c linux/fs/ntfs/util.c --- linux-2.3.99-pre6/fs/ntfs/util.c Wed Jun 2 07:25:47 1999 +++ linux/fs/ntfs/util.c Tue May 2 06:32:09 2000 @@ -267,6 +267,8 @@ return -1; if(b[i]<a[i]) return 1; + if (a[i] == 0) + return 0; } return 0; } @@ -282,6 +284,8 @@ return -1; if(b[i]<NTFS_GETU16(a+i)) return 1; + if (b[i] == 0) + return 0; } return 0; } diff -ur linux-2.3.99-pre6/include/linux/ntfs_fs_sb.h linux/include/linux/ntfs_fs_sb.h --- linux-2.3.99-pre6/include/linux/ntfs_fs_sb.h Thu Dec 9 21:14:30 1999 +++ linux/include/linux/ntfs_fs_sb.h Tue May 2 04:43:38 2000 @@ -15,7 +15,10 @@ ntfs_u32 at_standard_information; ntfs_u32 at_attribute_list; ntfs_u32 at_file_name; + ntfs_u32 at_volume_version; ntfs_u32 at_security_descriptor; + ntfs_u32 at_volume_name; + ntfs_u32 at_volume_information; ntfs_u32 at_data; ntfs_u32 at_index_root; ntfs_u32 at_index_allocation;

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun May 07 2000 - 21:00:09 EST