Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / fs / ntfs / inode.h
index 59af63e..f088291 100644 (file)
@@ -2,7 +2,7 @@
  * inode.h - Defines for inode structures NTFS Linux kernel driver. Part of
  *          the Linux-NTFS project.
  *
- * Copyright (c) 2001-2004 Anton Altaparmakov
+ * Copyright (c) 2001-2005 Anton Altaparmakov
  * Copyright (c) 2002 Richard Russon
  *
  * This program/include file is free software; you can redistribute it and/or
 #ifndef _LINUX_NTFS_INODE_H
 #define _LINUX_NTFS_INODE_H
 
+#include <asm/atomic.h>
+
+#include <linux/fs.h>
+#include <linux/list.h>
+#include <linux/mm.h>
+#include <linux/mutex.h>
 #include <linux/seq_file.h>
 
 #include "layout.h"
 #include "volume.h"
+#include "types.h"
+#include "runlist.h"
+#include "debug.h"
 
 typedef struct _ntfs_inode ntfs_inode;
 
@@ -36,6 +45,7 @@ typedef struct _ntfs_inode ntfs_inode;
  * fields already provided in the VFS inode.
  */
 struct _ntfs_inode {
+       rwlock_t size_lock;     /* Lock serializing access to inode sizes. */
        s64 initialized_size;   /* Copy from the attribute record. */
        s64 allocated_size;     /* Copy from the attribute record. */
        unsigned long state;    /* NTFS specific flags describing this inode.
@@ -53,26 +63,26 @@ struct _ntfs_inode {
         * name_len = 0 for files and name = I30 (global constant) and
         * name_len = 4 for directories.
         */
-       ATTR_TYPES type;        /* Attribute type of this fake inode. */
+       ATTR_TYPE type; /* Attribute type of this fake inode. */
        ntfschar *name;         /* Attribute name of this fake inode. */
        u32 name_len;           /* Attribute name length of this fake inode. */
-       run_list run_list;      /* If state has the NI_NonResident bit set,
-                                  the run list of the unnamed data attribute
+       runlist runlist;        /* If state has the NI_NonResident bit set,
+                                  the runlist of the unnamed data attribute
                                   (if a file) or of the index allocation
                                   attribute (directory) or of the attribute
                                   described by the fake inode (if NInoAttr()).
-                                  If run_list.rl is NULL, the run list has not
+                                  If runlist.rl is NULL, the runlist has not
                                   been read in yet or has been unmapped. If
                                   NI_NonResident is clear, the attribute is
                                   resident (file and fake inode) or there is
                                   no $I30 index allocation attribute
                                   (small directory). In the latter case
-                                  run_list.rl is always NULL.*/
+                                  runlist.rl is always NULL.*/
        /*
         * The following fields are only valid for real inodes and extent
         * inodes.
         */
-       struct semaphore mrec_lock; /* Lock for serializing access to the
+       struct mutex mrec_lock; /* Lock for serializing access to the
                                   mft record belonging to this inode. */
        struct page *page;      /* The page containing the mft record of the
                                   inode. This should only be touched by the
@@ -88,18 +98,20 @@ struct _ntfs_inode {
         */
        u32 attr_list_size;     /* Length of attribute list value in bytes. */
        u8 *attr_list;          /* Attribute list value itself. */
-       run_list attr_list_rl;  /* Run list for the attribute list value. */
+       runlist attr_list_rl;   /* Run list for the attribute list value. */
        union {
-               struct { /* It is a directory or $MFT. */
+               struct { /* It is a directory, $MFT, or an index inode. */
                        struct inode *bmp_ino;  /* Attribute inode for the
-                                                  directory index $BITMAP. */
+                                                  index $BITMAP. */
                        u32 block_size;         /* Size of an index block. */
                        u32 vcn_size;           /* Size of a vcn in this
-                                                  directory index. */
+                                                  index. */
+                       COLLATION_RULE collation_rule; /* The collation rule
+                                                  for the index. */
                        u8 block_size_bits;     /* Log2 of the above. */
                        u8 vcn_size_bits;       /* Log2 of the above. */
                } index;
-               struct { /* It is a compressed file or fake inode. */
+               struct { /* It is a compressed/sparse file/attribute inode. */
                        s64 size;               /* Copy of compressed_size from
                                                   $DATA. */
                        u32 block_size;         /* Size of a compression block
@@ -108,7 +120,7 @@ struct _ntfs_inode {
                        u8 block_clusters;      /* Number of clusters per cb. */
                } compressed;
        } itype;
-       struct semaphore extent_lock;   /* Lock for accessing/modifying the
+       struct mutex extent_lock;       /* Lock for accessing/modifying the
                                           below . */
        s32 nr_extents; /* For a base mft record, the number of attached extent
                           inodes (0 if none), for extent records and for fake
@@ -155,6 +167,8 @@ typedef enum {
        NI_Sparse,              /* 1: Unnamed data attr is sparse (f).
                                   1: Create sparse files by default (d).
                                   1: Attribute is sparse (a). */
+       NI_SparseDisabled,      /* 1: May not create sparse regions. */
+       NI_TruncateFailed,      /* 1: Last ntfs_truncate() call failed. */
 } ntfs_inode_state_bits;
 
 /*
@@ -206,6 +220,8 @@ NINO_FNS(IndexAllocPresent)
 NINO_FNS(Compressed)
 NINO_FNS(Encrypted)
 NINO_FNS(Sparse)
+NINO_FNS(SparseDisabled)
+NINO_FNS(TruncateFailed)
 
 /*
  * The full structure containing a ntfs_inode and a vfs struct inode. Used for
@@ -250,7 +266,7 @@ typedef struct {
        unsigned long mft_no;
        ntfschar *name;
        u32 name_len;
-       ATTR_TYPES type;
+       ATTR_TYPE type;
 } ntfs_attr;
 
 typedef int (*test_t)(struct inode *, void *);
@@ -258,13 +274,26 @@ typedef int (*test_t)(struct inode *, void *);
 extern int ntfs_test_inode(struct inode *vi, ntfs_attr *na);
 
 extern struct inode *ntfs_iget(struct super_block *sb, unsigned long mft_no);
-extern struct inode *ntfs_attr_iget(struct inode *base_vi, ATTR_TYPES type,
+extern struct inode *ntfs_attr_iget(struct inode *base_vi, ATTR_TYPE type,
                ntfschar *name, u32 name_len);
+extern struct inode *ntfs_index_iget(struct inode *base_vi, ntfschar *name,
+               u32 name_len);
 
 extern struct inode *ntfs_alloc_big_inode(struct super_block *sb);
 extern void ntfs_destroy_big_inode(struct inode *inode);
 extern void ntfs_clear_big_inode(struct inode *vi);
 
+extern void __ntfs_init_inode(struct super_block *sb, ntfs_inode *ni);
+
+static inline void ntfs_init_big_inode(struct inode *vi)
+{
+       ntfs_inode *ni = NTFS_I(vi);
+
+       ntfs_debug("Entering.");
+       __ntfs_init_inode(vi->i_sb, ni);
+       ni->mft_no = vi->i_ino;
+}
+
 extern ntfs_inode *ntfs_new_extent_inode(struct super_block *sb,
                unsigned long mft_no);
 extern void ntfs_clear_extent_inode(ntfs_inode *ni);
@@ -277,11 +306,12 @@ extern int ntfs_show_options(struct seq_file *sf, struct vfsmount *mnt);
 
 #ifdef NTFS_RW
 
-extern void ntfs_truncate(struct inode *vi);
+extern int ntfs_truncate(struct inode *vi);
+extern void ntfs_truncate_vfs(struct inode *vi);
 
 extern int ntfs_setattr(struct dentry *dentry, struct iattr *attr);
 
-extern void ntfs_write_inode(struct inode *vi, int sync);
+extern int ntfs_write_inode(struct inode *vi, int sync);
 
 static inline void ntfs_commit_inode(struct inode *vi)
 {