linux/fs/hfs/hfs_fs.h
<<
>>
Prefs
   1/*
   2 *  linux/fs/hfs/hfs_fs.h
   3 *
   4 * Copyright (C) 1995-1997  Paul H. Hargrove
   5 * (C) 2003 Ardis Technologies <roman@ardistech.com>
   6 * This file may be distributed under the terms of the GNU General Public License.
   7 */
   8
   9#ifndef _LINUX_HFS_FS_H
  10#define _LINUX_HFS_FS_H
  11
  12#include <linux/slab.h>
  13#include <linux/types.h>
  14#include <linux/mutex.h>
  15#include <linux/buffer_head.h>
  16#include <linux/fs.h>
  17#include <linux/workqueue.h>
  18
  19#include <asm/byteorder.h>
  20#include <asm/uaccess.h>
  21
  22#include "hfs.h"
  23
  24#define DBG_BNODE_REFS  0x00000001
  25#define DBG_BNODE_MOD   0x00000002
  26#define DBG_CAT_MOD     0x00000004
  27#define DBG_INODE       0x00000008
  28#define DBG_SUPER       0x00000010
  29#define DBG_EXTENT      0x00000020
  30#define DBG_BITMAP      0x00000040
  31
  32//#define DBG_MASK      (DBG_EXTENT|DBG_INODE|DBG_BNODE_MOD|DBG_CAT_MOD|DBG_BITMAP)
  33//#define DBG_MASK      (DBG_BNODE_MOD|DBG_CAT_MOD|DBG_INODE)
  34//#define DBG_MASK      (DBG_CAT_MOD|DBG_BNODE_REFS|DBG_INODE|DBG_EXTENT)
  35#define DBG_MASK        (0)
  36
  37#define dprint(flg, fmt, args...) \
  38        if (flg & DBG_MASK) printk(fmt , ## args)
  39
  40/*
  41 * struct hfs_inode_info
  42 *
  43 * The HFS-specific part of a Linux (struct inode)
  44 */
  45struct hfs_inode_info {
  46        atomic_t opencnt;
  47
  48        unsigned int flags;
  49
  50        /* to deal with localtime ugliness */
  51        int tz_secondswest;
  52
  53        struct hfs_cat_key cat_key;
  54
  55        struct list_head open_dir_list;
  56        struct inode *rsrc_inode;
  57
  58        struct mutex extents_lock;
  59
  60        u16 alloc_blocks, clump_blocks;
  61        sector_t fs_blocks;
  62        /* Allocation extents from catlog record or volume header */
  63        hfs_extent_rec first_extents;
  64        u16 first_blocks;
  65        hfs_extent_rec cached_extents;
  66        u16 cached_start, cached_blocks;
  67
  68        loff_t phys_size;
  69        struct inode vfs_inode;
  70};
  71
  72#define HFS_FLG_RSRC            0x0001
  73#define HFS_FLG_EXT_DIRTY       0x0002
  74#define HFS_FLG_EXT_NEW         0x0004
  75
  76#define HFS_IS_RSRC(inode)      (HFS_I(inode)->flags & HFS_FLG_RSRC)
  77
  78/*
  79 * struct hfs_sb_info
  80 *
  81 * The HFS-specific part of a Linux (struct super_block)
  82 */
  83struct hfs_sb_info {
  84        struct buffer_head *mdb_bh;             /* The hfs_buffer
  85                                                   holding the real
  86                                                   superblock (aka VIB
  87                                                   or MDB) */
  88        struct hfs_mdb *mdb;
  89        struct buffer_head *alt_mdb_bh;         /* The hfs_buffer holding
  90                                                   the alternate superblock */
  91        struct hfs_mdb *alt_mdb;
  92        __be32 *bitmap;                         /* The page holding the
  93                                                   allocation bitmap */
  94        struct hfs_btree *ext_tree;                     /* Information about
  95                                                   the extents b-tree */
  96        struct hfs_btree *cat_tree;                     /* Information about
  97                                                   the catalog b-tree */
  98        u32 file_count;                         /* The number of
  99                                                   regular files in
 100                                                   the filesystem */
 101        u32 folder_count;                       /* The number of
 102                                                   directories in the
 103                                                   filesystem */
 104        u32 next_id;                            /* The next available
 105                                                   file id number */
 106        u32 clumpablks;                         /* The number of allocation
 107                                                   blocks to try to add when
 108                                                   extending a file */
 109        u32 fs_start;                           /* The first 512-byte
 110                                                   block represented
 111                                                   in the bitmap */
 112        u32 part_start;
 113        u16 root_files;                         /* The number of
 114                                                   regular
 115                                                   (non-directory)
 116                                                   files in the root
 117                                                   directory */
 118        u16 root_dirs;                          /* The number of
 119                                                   directories in the
 120                                                   root directory */
 121        u16 fs_ablocks;                         /* The number of
 122                                                   allocation blocks
 123                                                   in the filesystem */
 124        u16 free_ablocks;                       /* the number of unused
 125                                                   allocation blocks
 126                                                   in the filesystem */
 127        u32 alloc_blksz;                        /* The size of an
 128                                                   "allocation block" */
 129        int s_quiet;                            /* Silent failure when
 130                                                   changing owner or mode? */
 131        __be32 s_type;                          /* Type for new files */
 132        __be32 s_creator;                       /* Creator for new files */
 133        umode_t s_file_umask;                   /* The umask applied to the
 134                                                   permissions on all files */
 135        umode_t s_dir_umask;                    /* The umask applied to the
 136                                                   permissions on all dirs */
 137        kuid_t s_uid;                           /* The uid of all files */
 138        kgid_t s_gid;                           /* The gid of all files */
 139
 140        int session, part;
 141        struct nls_table *nls_io, *nls_disk;
 142        struct mutex bitmap_lock;
 143        unsigned long flags;
 144        u16 blockoffset;
 145        int fs_div;
 146        struct super_block *sb;
 147        int work_queued;                /* non-zero delayed work is queued */
 148        struct delayed_work mdb_work;   /* MDB flush delayed work */
 149        spinlock_t work_lock;           /* protects mdb_work and work_queued */
 150};
 151
 152#define HFS_FLG_BITMAP_DIRTY    0
 153#define HFS_FLG_MDB_DIRTY       1
 154#define HFS_FLG_ALT_MDB_DIRTY   2
 155
 156/* bitmap.c */
 157extern u32 hfs_vbm_search_free(struct super_block *, u32, u32 *);
 158extern int hfs_clear_vbm_bits(struct super_block *, u16, u16);
 159
 160/* catalog.c */
 161extern int hfs_cat_keycmp(const btree_key *, const btree_key *);
 162struct hfs_find_data;
 163extern int hfs_cat_find_brec(struct super_block *, u32, struct hfs_find_data *);
 164extern int hfs_cat_create(u32, struct inode *, struct qstr *, struct inode *);
 165extern int hfs_cat_delete(u32, struct inode *, struct qstr *);
 166extern int hfs_cat_move(u32, struct inode *, struct qstr *,
 167                        struct inode *, struct qstr *);
 168extern void hfs_cat_build_key(struct super_block *, btree_key *, u32, struct qstr *);
 169
 170/* dir.c */
 171extern const struct file_operations hfs_dir_operations;
 172extern const struct inode_operations hfs_dir_inode_operations;
 173
 174/* extent.c */
 175extern int hfs_ext_keycmp(const btree_key *, const btree_key *);
 176extern int hfs_free_fork(struct super_block *, struct hfs_cat_file *, int);
 177extern void hfs_ext_write_extent(struct inode *);
 178extern int hfs_extend_file(struct inode *);
 179extern void hfs_file_truncate(struct inode *);
 180
 181extern int hfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
 182
 183/* inode.c */
 184extern const struct address_space_operations hfs_aops;
 185extern const struct address_space_operations hfs_btree_aops;
 186
 187extern struct inode *hfs_new_inode(struct inode *, struct qstr *, umode_t);
 188extern void hfs_inode_write_fork(struct inode *, struct hfs_extent *, __be32 *, __be32 *);
 189extern int hfs_write_inode(struct inode *, struct writeback_control *);
 190extern int hfs_inode_setattr(struct dentry *, struct iattr *);
 191extern void hfs_inode_read_fork(struct inode *inode, struct hfs_extent *ext,
 192                        __be32 log_size, __be32 phys_size, u32 clump_size);
 193extern struct inode *hfs_iget(struct super_block *, struct hfs_cat_key *, hfs_cat_rec *);
 194extern void hfs_evict_inode(struct inode *);
 195extern void hfs_delete_inode(struct inode *);
 196
 197/* attr.c */
 198extern int hfs_setxattr(struct dentry *dentry, const char *name,
 199                        const void *value, size_t size, int flags);
 200extern ssize_t hfs_getxattr(struct dentry *dentry, const char *name,
 201                            void *value, size_t size);
 202extern ssize_t hfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
 203
 204/* mdb.c */
 205extern int hfs_mdb_get(struct super_block *);
 206extern void hfs_mdb_commit(struct super_block *);
 207extern void hfs_mdb_close(struct super_block *);
 208extern void hfs_mdb_put(struct super_block *);
 209
 210/* part_tbl.c */
 211extern int hfs_part_find(struct super_block *, sector_t *, sector_t *);
 212
 213/* string.c */
 214extern const struct dentry_operations hfs_dentry_operations;
 215
 216extern int hfs_hash_dentry(const struct dentry *, const struct inode *,
 217                struct qstr *);
 218extern int hfs_strcmp(const unsigned char *, unsigned int,
 219                      const unsigned char *, unsigned int);
 220extern int hfs_compare_dentry(const struct dentry *parent,
 221                const struct inode *pinode,
 222                const struct dentry *dentry, const struct inode *inode,
 223                unsigned int len, const char *str, const struct qstr *name);
 224
 225/* trans.c */
 226extern void hfs_asc2mac(struct super_block *, struct hfs_name *, struct qstr *);
 227extern int hfs_mac2asc(struct super_block *, char *, const struct hfs_name *);
 228
 229/* super.c */
 230extern void hfs_mark_mdb_dirty(struct super_block *sb);
 231
 232extern struct timezone sys_tz;
 233
 234/*
 235 * There are two time systems.  Both are based on seconds since
 236 * a particular time/date.
 237 *      Unix:   unsigned lil-endian since 00:00 GMT, Jan. 1, 1970
 238 *      mac:    unsigned big-endian since 00:00 GMT, Jan. 1, 1904
 239 *
 240 */
 241#define __hfs_u_to_mtime(sec)   cpu_to_be32(sec + 2082844800U - sys_tz.tz_minuteswest * 60)
 242#define __hfs_m_to_utime(sec)   (be32_to_cpu(sec) - 2082844800U  + sys_tz.tz_minuteswest * 60)
 243
 244#define HFS_I(inode)    (list_entry(inode, struct hfs_inode_info, vfs_inode))
 245#define HFS_SB(sb)      ((struct hfs_sb_info *)(sb)->s_fs_info)
 246
 247#define hfs_m_to_utime(time)    (struct timespec){ .tv_sec = __hfs_m_to_utime(time) }
 248#define hfs_u_to_mtime(time)    __hfs_u_to_mtime((time).tv_sec)
 249#define hfs_mtime()             __hfs_u_to_mtime(get_seconds())
 250
 251static inline const char *hfs_mdb_name(struct super_block *sb)
 252{
 253        return sb->s_id;
 254}
 255
 256static inline void hfs_bitmap_dirty(struct super_block *sb)
 257{
 258        set_bit(HFS_FLG_BITMAP_DIRTY, &HFS_SB(sb)->flags);
 259        hfs_mark_mdb_dirty(sb);
 260}
 261
 262#define sb_bread512(sb, sec, data) ({                   \
 263        struct buffer_head *__bh;                       \
 264        sector_t __block;                               \
 265        loff_t __start;                                 \
 266        int __offset;                                   \
 267                                                        \
 268        __start = (loff_t)(sec) << HFS_SECTOR_SIZE_BITS;\
 269        __block = __start >> (sb)->s_blocksize_bits;    \
 270        __offset = __start & ((sb)->s_blocksize - 1);   \
 271        __bh = sb_bread((sb), __block);                 \
 272        if (likely(__bh != NULL))                       \
 273                data = (void *)(__bh->b_data + __offset);\
 274        else                                            \
 275                data = NULL;                            \
 276        __bh;                                           \
 277})
 278
 279#endif
 280
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.