Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * ntfs.h - Defines for NTFS Linux kernel driver.
0004  *
0005  * Copyright (c) 2001-2014 Anton Altaparmakov and Tuxera Inc.
0006  * Copyright (C) 2002 Richard Russon
0007  */
0008 
0009 #ifndef _LINUX_NTFS_H
0010 #define _LINUX_NTFS_H
0011 
0012 #include <linux/stddef.h>
0013 #include <linux/kernel.h>
0014 #include <linux/module.h>
0015 #include <linux/compiler.h>
0016 #include <linux/fs.h>
0017 #include <linux/nls.h>
0018 #include <linux/smp.h>
0019 #include <linux/pagemap.h>
0020 
0021 #include "types.h"
0022 #include "volume.h"
0023 #include "layout.h"
0024 
0025 typedef enum {
0026     NTFS_BLOCK_SIZE     = 512,
0027     NTFS_BLOCK_SIZE_BITS    = 9,
0028     NTFS_SB_MAGIC       = 0x5346544e,   /* 'NTFS' */
0029     NTFS_MAX_NAME_LEN   = 255,
0030     NTFS_MAX_ATTR_NAME_LEN  = 255,
0031     NTFS_MAX_CLUSTER_SIZE   = 64 * 1024,    /* 64kiB */
0032     NTFS_MAX_PAGES_PER_CLUSTER = NTFS_MAX_CLUSTER_SIZE / PAGE_SIZE,
0033 } NTFS_CONSTANTS;
0034 
0035 /* Global variables. */
0036 
0037 /* Slab caches (from super.c). */
0038 extern struct kmem_cache *ntfs_name_cache;
0039 extern struct kmem_cache *ntfs_inode_cache;
0040 extern struct kmem_cache *ntfs_big_inode_cache;
0041 extern struct kmem_cache *ntfs_attr_ctx_cache;
0042 extern struct kmem_cache *ntfs_index_ctx_cache;
0043 
0044 /* The various operations structs defined throughout the driver files. */
0045 extern const struct address_space_operations ntfs_normal_aops;
0046 extern const struct address_space_operations ntfs_compressed_aops;
0047 extern const struct address_space_operations ntfs_mst_aops;
0048 
0049 extern const struct  file_operations ntfs_file_ops;
0050 extern const struct inode_operations ntfs_file_inode_ops;
0051 
0052 extern const struct  file_operations ntfs_dir_ops;
0053 extern const struct inode_operations ntfs_dir_inode_ops;
0054 
0055 extern const struct  file_operations ntfs_empty_file_ops;
0056 extern const struct inode_operations ntfs_empty_inode_ops;
0057 
0058 extern const struct export_operations ntfs_export_ops;
0059 
0060 /**
0061  * NTFS_SB - return the ntfs volume given a vfs super block
0062  * @sb:     VFS super block
0063  *
0064  * NTFS_SB() returns the ntfs volume associated with the VFS super block @sb.
0065  */
0066 static inline ntfs_volume *NTFS_SB(struct super_block *sb)
0067 {
0068     return sb->s_fs_info;
0069 }
0070 
0071 /* Declarations of functions and global variables. */
0072 
0073 /* From fs/ntfs/compress.c */
0074 extern int ntfs_read_compressed_block(struct page *page);
0075 extern int allocate_compression_buffers(void);
0076 extern void free_compression_buffers(void);
0077 
0078 /* From fs/ntfs/super.c */
0079 #define default_upcase_len 0x10000
0080 extern struct mutex ntfs_lock;
0081 
0082 typedef struct {
0083     int val;
0084     char *str;
0085 } option_t;
0086 extern const option_t on_errors_arr[];
0087 
0088 /* From fs/ntfs/mst.c */
0089 extern int post_read_mst_fixup(NTFS_RECORD *b, const u32 size);
0090 extern int pre_write_mst_fixup(NTFS_RECORD *b, const u32 size);
0091 extern void post_write_mst_fixup(NTFS_RECORD *b);
0092 
0093 /* From fs/ntfs/unistr.c */
0094 extern bool ntfs_are_names_equal(const ntfschar *s1, size_t s1_len,
0095         const ntfschar *s2, size_t s2_len,
0096         const IGNORE_CASE_BOOL ic,
0097         const ntfschar *upcase, const u32 upcase_size);
0098 extern int ntfs_collate_names(const ntfschar *name1, const u32 name1_len,
0099         const ntfschar *name2, const u32 name2_len,
0100         const int err_val, const IGNORE_CASE_BOOL ic,
0101         const ntfschar *upcase, const u32 upcase_len);
0102 extern int ntfs_ucsncmp(const ntfschar *s1, const ntfschar *s2, size_t n);
0103 extern int ntfs_ucsncasecmp(const ntfschar *s1, const ntfschar *s2, size_t n,
0104         const ntfschar *upcase, const u32 upcase_size);
0105 extern void ntfs_upcase_name(ntfschar *name, u32 name_len,
0106         const ntfschar *upcase, const u32 upcase_len);
0107 extern void ntfs_file_upcase_value(FILE_NAME_ATTR *file_name_attr,
0108         const ntfschar *upcase, const u32 upcase_len);
0109 extern int ntfs_file_compare_values(FILE_NAME_ATTR *file_name_attr1,
0110         FILE_NAME_ATTR *file_name_attr2,
0111         const int err_val, const IGNORE_CASE_BOOL ic,
0112         const ntfschar *upcase, const u32 upcase_len);
0113 extern int ntfs_nlstoucs(const ntfs_volume *vol, const char *ins,
0114         const int ins_len, ntfschar **outs);
0115 extern int ntfs_ucstonls(const ntfs_volume *vol, const ntfschar *ins,
0116         const int ins_len, unsigned char **outs, int outs_len);
0117 
0118 /* From fs/ntfs/upcase.c */
0119 extern ntfschar *generate_default_upcase(void);
0120 
0121 static inline int ntfs_ffs(int x)
0122 {
0123     int r = 1;
0124 
0125     if (!x)
0126         return 0;
0127     if (!(x & 0xffff)) {
0128         x >>= 16;
0129         r += 16;
0130     }
0131     if (!(x & 0xff)) {
0132         x >>= 8;
0133         r += 8;
0134     }
0135     if (!(x & 0xf)) {
0136         x >>= 4;
0137         r += 4;
0138     }
0139     if (!(x & 3)) {
0140         x >>= 2;
0141         r += 2;
0142     }
0143     if (!(x & 1)) {
0144         x >>= 1;
0145         r += 1;
0146     }
0147     return r;
0148 }
0149 
0150 #endif /* _LINUX_NTFS_H */