Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions | Variables
ntfs.h File Reference
#include <linux/stddef.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/compiler.h>
#include <linux/fs.h>
#include <linux/nls.h>
#include <linux/smp.h>
#include <linux/pagemap.h>
#include "types.h"
#include "volume.h"
#include "layout.h"

Go to the source code of this file.

Data Structures

struct  option_t
 

Macros

#define default_upcase_len   0x10000
 

Enumerations

enum  NTFS_CONSTANTS {
  NTFS_BLOCK_SIZE = 512, NTFS_BLOCK_SIZE_BITS = 9, NTFS_SB_MAGIC = 0x5346544e, NTFS_MAX_NAME_LEN = 255,
  NTFS_MAX_ATTR_NAME_LEN = 255, NTFS_MAX_CLUSTER_SIZE = 64 * 1024, NTFS_MAX_PAGES_PER_CLUSTER = NTFS_MAX_CLUSTER_SIZE / PAGE_CACHE_SIZE
}
 

Functions

int ntfs_read_compressed_block (struct page *page)
 
int allocate_compression_buffers (void)
 
void free_compression_buffers (void)
 
int post_read_mst_fixup (NTFS_RECORD *b, const u32 size)
 
int pre_write_mst_fixup (NTFS_RECORD *b, const u32 size)
 
void post_write_mst_fixup (NTFS_RECORD *b)
 
bool ntfs_are_names_equal (const ntfschar *s1, size_t s1_len, const ntfschar *s2, size_t s2_len, const IGNORE_CASE_BOOL ic, const ntfschar *upcase, const u32 upcase_size)
 
int ntfs_collate_names (const ntfschar *name1, const u32 name1_len, const ntfschar *name2, const u32 name2_len, const int err_val, const IGNORE_CASE_BOOL ic, const ntfschar *upcase, const u32 upcase_len)
 
int ntfs_ucsncmp (const ntfschar *s1, const ntfschar *s2, size_t n)
 
int ntfs_ucsncasecmp (const ntfschar *s1, const ntfschar *s2, size_t n, const ntfschar *upcase, const u32 upcase_size)
 
void ntfs_upcase_name (ntfschar *name, u32 name_len, const ntfschar *upcase, const u32 upcase_len)
 
void ntfs_file_upcase_value (FILE_NAME_ATTR *file_name_attr, const ntfschar *upcase, const u32 upcase_len)
 
int ntfs_file_compare_values (FILE_NAME_ATTR *file_name_attr1, FILE_NAME_ATTR *file_name_attr2, const int err_val, const IGNORE_CASE_BOOL ic, const ntfschar *upcase, const u32 upcase_len)
 
int ntfs_nlstoucs (const ntfs_volume *vol, const char *ins, const int ins_len, ntfschar **outs)
 
int ntfs_ucstonls (const ntfs_volume *vol, const ntfschar *ins, const int ins_len, unsigned char **outs, int outs_len)
 
ntfschargenerate_default_upcase (void)
 

Variables

typedef __attribute__
 
struct kmem_cachentfs_name_cache
 
struct kmem_cachentfs_inode_cache
 
struct kmem_cachentfs_big_inode_cache
 
struct kmem_cachentfs_attr_ctx_cache
 
struct kmem_cachentfs_index_ctx_cache
 
struct address_space_operations ntfs_aops
 
struct address_space_operations ntfs_mst_aops
 
struct file_operations ntfs_file_ops
 
struct inode_operations ntfs_file_inode_ops
 
struct file_operations ntfs_dir_ops
 
struct inode_operations ntfs_dir_inode_ops
 
struct file_operations ntfs_empty_file_ops
 
struct inode_operations ntfs_empty_inode_ops
 
struct export_operations ntfs_export_ops
 
struct mutex ntfs_lock
 
const option_t on_errors_arr []
 

Macro Definition Documentation

#define default_upcase_len   0x10000

Definition at line 93 of file ntfs.h.

Enumeration Type Documentation

Enumerator:
NTFS_BLOCK_SIZE 
NTFS_BLOCK_SIZE_BITS 
NTFS_SB_MAGIC 
NTFS_MAX_NAME_LEN 
NTFS_MAX_ATTR_NAME_LEN 
NTFS_MAX_CLUSTER_SIZE 
NTFS_MAX_PAGES_PER_CLUSTER 

Definition at line 40 of file ntfs.h.

Function Documentation

int allocate_compression_buffers ( void  )

allocate_compression_buffers - allocate the decompression buffers

Caller has to hold the ntfs_lock mutex.

Return 0 on success or -ENOMEM if the allocations failed.

Definition at line 75 of file compress.c.

void free_compression_buffers ( void  )

free_compression_buffers - free the decompression buffers

Caller has to hold the ntfs_lock mutex.

Definition at line 90 of file compress.c.

ntfschar* generate_default_upcase ( void  )

Definition at line 27 of file upcase.c.

bool ntfs_are_names_equal ( const ntfschar s1,
size_t  s1_len,
const ntfschar s2,
size_t  s2_len,
const IGNORE_CASE_BOOL  ic,
const ntfschar upcase,
const u32  upcase_size 
)

ntfs_are_names_equal - compare two Unicode names for equality : name to compare to : length in Unicode characters of : name to compare to : length in Unicode characters of : ignore case bool : upcase table (only if == IGNORE_CASE) : length in Unicode characters of (if present)

Compare the names and and return 'true' (1) if the names are identical, or 'false' (0) if they are not identical. If is IGNORE_CASE, the table is used to performa a case insensitive comparison.

Definition at line 68 of file unistr.c.

int ntfs_collate_names ( const ntfschar name1,
const u32  name1_len,
const ntfschar name2,
const u32  name2_len,
const int  err_val,
const IGNORE_CASE_BOOL  ic,
const ntfschar upcase,
const u32  upcase_len 
)

Definition at line 97 of file unistr.c.

int ntfs_file_compare_values ( FILE_NAME_ATTR *  file_name_attr1,
FILE_NAME_ATTR *  file_name_attr2,
const int  err_val,
const IGNORE_CASE_BOOL  ic,
const ntfschar upcase,
const u32  upcase_len 
)

Definition at line 224 of file unistr.c.

void ntfs_file_upcase_value ( FILE_NAME_ATTR *  file_name_attr,
const ntfschar upcase,
const u32  upcase_len 
)

Definition at line 217 of file unistr.c.

int ntfs_nlstoucs ( const ntfs_volume vol,
const char ins,
const int  ins_len,
ntfschar **  outs 
)

ntfs_nlstoucs - convert NLS string to little endian Unicode string : ntfs volume which we are working with : input NLS string buffer : length of input string in bytes : on return contains the allocated output Unicode string buffer

Convert the input string , which is in whatever format the loaded NLS map dictates, into a little endian, 2-byte Unicode string.

This function allocates the string and the caller is responsible for calling kmem_cache_free(ntfs_name_cache, *); when finished with it.

On success the function returns the number of Unicode characters written to the output string * (>= 0), not counting the terminating Unicode NULL character. * is set to the allocated output string buffer.

On error, a negative number corresponding to the error code is returned. In that case the output string is not allocated. Both * and * are then undefined.

This might look a bit odd due to fast path optimization...

Definition at line 259 of file unistr.c.

int ntfs_read_compressed_block ( struct page page)

Definition at line 482 of file compress.c.

int ntfs_ucsncasecmp ( const ntfschar s1,
const ntfschar s2,
size_t  n,
const ntfschar upcase,
const u32  upcase_size 
)

ntfs_ucsncasecmp - compare two little endian Unicode strings, ignoring case : first string : second string
: maximum unicode characters to compare : upcase table : upcase table size in Unicode characters

Compare the first
characters of the Unicode strings and , ignoring case. The strings in little endian format and appropriate le16_to_cpu() conversion is performed on non-little endian machines.

Each character is uppercased using the table before the comparison.

The function returns an integer less than, equal to, or greater than zero if (or the first
Unicode characters thereof) is found, respectively, to be less than, to match, or be greater than .

Definition at line 185 of file unistr.c.

int ntfs_ucsncmp ( const ntfschar s1,
const ntfschar s2,
size_t  n 
)

ntfs_ucsncmp - compare two little endian Unicode strings : first string : second string
: maximum unicode characters to compare

Compare the first
characters of the Unicode strings and , The strings in little endian format and appropriate le16_to_cpu() conversion is performed on non-little endian machines.

The function returns an integer less than, equal to, or greater than zero if (or the first
Unicode characters thereof) is found, respectively, to be less than, to match, or be greater than .

Definition at line 149 of file unistr.c.

int ntfs_ucstonls ( const ntfs_volume vol,
const ntfschar ins,
const int  ins_len,
unsigned char **  outs,
int  outs_len 
)

ntfs_ucstonls - convert little endian Unicode string to NLS string : ntfs volume which we are working with : input Unicode string buffer : length of input string in Unicode characters : on return contains the (allocated) output NLS string buffer : length of output string buffer in bytes

Convert the input little endian, 2-byte Unicode string , of length into the string format dictated by the loaded NLS.

If * is NULL, this function allocates the string and the caller is responsible for calling kfree(*); when finished with it. In this case is ignored and can be 0.

On success the function returns the number of bytes written to the output string * (>= 0), not counting the terminating NULL byte. If the output string buffer was allocated, * is set to it.

On error, a negative number corresponding to the error code is returned. In that case the output string is not allocated. The contents of * are then undefined.

This might look a bit odd due to fast path optimization...

Definition at line 336 of file unistr.c.

void ntfs_upcase_name ( ntfschar name,
u32  name_len,
const ntfschar upcase,
const u32  upcase_len 
)

Definition at line 206 of file unistr.c.

int post_read_mst_fixup ( NTFS_RECORD *  b,
const u32  size 
)

post_read_mst_fixup - deprotect multi sector transfer protected data : pointer to the data to deprotect : size in bytes of

Perform the necessary post read multi sector transfer fixup and detect the presence of incomplete multi sector transfers. - In that case, overwrite the magic of the ntfs record header being processed with "BAAD" (in memory only!) and abort processing.

Return 0 on success and -EINVAL on error ("BAAD" magic will be present).

NOTE: We consider the absence / invalidity of an update sequence array to mean that the structure is not protected at all and hence doesn't need to be fixed up. Thus, we return success and not failure in this case. This is in contrast to pre_write_mst_fixup(), see below.

Definition at line 42 of file mst.c.

void post_write_mst_fixup ( NTFS_RECORD *  b)

post_write_mst_fixup - fast deprotect multi sector transfer protected data : pointer to the data to deprotect

Perform the necessary post write multi sector transfer fixup, not checking for any errors, because we assume we have just used pre_write_mst_fixup(), thus the data will be fine or we would never have gotten here.

Definition at line 179 of file mst.c.

int pre_write_mst_fixup ( NTFS_RECORD *  b,
const u32  size 
)

pre_write_mst_fixup - apply multi sector transfer protection : pointer to the data to protect : size in bytes of

Perform the necessary pre write multi sector transfer fixup on the data pointer to by of .

Return 0 if fixup applied (success) or -EINVAL if no fixup was performed (assumed not needed). This is in contrast to post_read_mst_fixup() above.

NOTE: We consider the absence / invalidity of an update sequence array to mean that the structure is not subject to protection and hence doesn't need to be fixed up. This means that you have to create a valid update sequence array header in the ntfs record before calling this function, otherwise it will fail (the header needs to contain the position of the update sequence array together with the number of elements in the array). You also need to initialise the update sequence number before calling this function otherwise a random word will be used (whatever was in the record at that position at that time).

Definition at line 123 of file mst.c.

Variable Documentation

typedef __attribute__

ntfs_aops - general address space operations for inodes and attributes

Definition at line 1544 of file aops.c.

struct kmem_cache* ntfs_attr_ctx_cache

Definition at line 3063 of file super.c.

struct kmem_cache* ntfs_big_inode_cache

Definition at line 3049 of file super.c.

struct inode_operations ntfs_dir_inode_ops

Inode operations for directories.

Definition at line 279 of file namei.c.

struct file_operations ntfs_dir_ops

Definition at line 1571 of file dir.c.

struct file_operations ntfs_empty_file_ops

Definition at line 2235 of file file.c.

struct inode_operations ntfs_empty_inode_ops

Definition at line 2237 of file file.c.

struct export_operations ntfs_export_ops

Export operations allowing NFS exporting of mounted NTFS partitions.

We use the default ->encode_fh() for now. Note that they use 32 bits to store the inode number which is an unsigned long so on 64-bit architectures is usually 64 bits so it would all fail horribly on huge volumes. I guess we need to define our own encode and decode fh functions that store 64-bit inode numbers at some point but for now we will ignore the problem...

We also use the default ->get_name() helper (used by ->decode_fh() via fs/exportfs/expfs.c::find_exported_dentry()) as that is completely fs independent.

The default ->get_parent() just returns -EACCES so we have to provide our own and the default ->get_dentry() is incompatible with NTFS due to not allowing the inode number 0 which is used in NTFS for the system file $MFT and due to using iget() whereas NTFS needs ntfs_iget().

Definition at line 400 of file namei.c.

struct inode_operations ntfs_file_inode_ops

Definition at line 2228 of file file.c.

struct file_operations ntfs_file_ops

Definition at line 2194 of file file.c.

struct kmem_cache* ntfs_index_ctx_cache

Definition at line 3064 of file super.c.

struct kmem_cache* ntfs_inode_cache

Definition at line 3048 of file super.c.

struct mutex ntfs_lock

ntfs_mst_aops - general address space operations for mst protecteed inodes and attributes

Definition at line 1559 of file aops.c.

struct kmem_cache* ntfs_name_cache

Definition at line 3045 of file super.c.

const option_t on_errors_arr[]

Definition at line 65 of file super.c.