summaryrefslogtreecommitdiffstats
path: root/fs/ntfs
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2000-05-12 21:05:59 +0000
committerRalf Baechle <ralf@linux-mips.org>2000-05-12 21:05:59 +0000
commitba2dacab305c598cd4c34a604f8e276bf5bab5ff (patch)
tree78670a0139bf4d5ace617b29b7eba82bbc74d602 /fs/ntfs
parentb77bf69998121e689c5e86cc5630d39a0a9ee6ca (diff)
Merge with Linux 2.3.99-pre7 and various other bits.
Diffstat (limited to 'fs/ntfs')
-rw-r--r--fs/ntfs/Makefile2
-rw-r--r--fs/ntfs/fs.c8
-rw-r--r--fs/ntfs/struct.h4
-rw-r--r--fs/ntfs/super.c56
-rw-r--r--fs/ntfs/util.c4
5 files changed, 67 insertions, 7 deletions
diff --git a/fs/ntfs/Makefile b/fs/ntfs/Makefile
index 6ec49bfd7..6f0e188d1 100644
--- a/fs/ntfs/Makefile
+++ b/fs/ntfs/Makefile
@@ -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 --git a/fs/ntfs/fs.c b/fs/ntfs/fs.c
index 238e5c61b..3d58541ad 100644
--- a/fs/ntfs/fs.c
+++ b/fs/ntfs/fs.c
@@ -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
@@ -587,11 +587,11 @@ static struct inode_operations ntfs_dir_inode_operations = {
#endif
};
-static int ntfs_writepage(struct file *file, struct dentry *dentry, struct page *page)
+static int ntfs_writepage(struct file *file, struct page *page)
{
return block_write_full_page(page,ntfs_get_block);
}
-static int ntfs_readpage(struct dentry *dentry, struct page *page)
+static int ntfs_readpage(struct file *file, struct page *page)
{
return block_read_full_page(page,ntfs_get_block);
}
@@ -937,7 +937,7 @@ static int __init init_ntfs_fs(void)
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 --git a/fs/ntfs/struct.h b/fs/ntfs/struct.h
index 2b032d744..6e757e830 100644
--- a/fs/ntfs/struct.h
+++ b/fs/ntfs/struct.h
@@ -3,6 +3,7 @@
* Structure definitions
*
* Copyright (C) 1997 Régis Duchesne
+ * Copyright (C) 2000 Anton Altaparmakov
*/
/* Necessary forward definition */
@@ -42,7 +43,10 @@ typedef struct _ntfs_volume{
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 --git a/fs/ntfs/super.c b/fs/ntfs/super.c
index d7dcb127f..7f2a7fe86 100644
--- a/fs/ntfs/super.c
+++ b/fs/ntfs/super.c
@@ -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 @@ int ntfs_init_volume(ntfs_volume *vol,char *boot)
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 @@ process_attrdef(ntfs_inode* attrdef,ntfs_u8* def)
}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 @@ process_attrdef(ntfs_inode* attrdef,ntfs_u8* def)
}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 @@ ntfs_init_attrdef(ntfs_inode* attrdef)
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 @@ int ntfs_load_special_files(ntfs_volume *vol)
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 --git a/fs/ntfs/util.c b/fs/ntfs/util.c
index e0f9b2362..8f4fc6ca8 100644
--- a/fs/ntfs/util.c
+++ b/fs/ntfs/util.c
@@ -267,6 +267,8 @@ int ntfs_uni_strncmp(short int* a,short int *b,int n)
return -1;
if(b[i]<a[i])
return 1;
+ if (a[i] == 0)
+ return 0;
}
return 0;
}
@@ -282,6 +284,8 @@ int ntfs_ua_strncmp(short int* a,char* b,int n)
return -1;
if(b[i]<NTFS_GETU16(a+i))
return 1;
+ if (b[i] == 0)
+ return 0;
}
return 0;
}