linux-bk/include/linux/amigaffs.h
<<
>>
Prefs
   1#ifndef AMIGAFFS_H
   2#define AMIGAFFS_H
   3
   4#include <linux/types.h>
   5#include <linux/buffer_head.h>
   6#include <linux/string.h>
   7#include <asm/byteorder.h>
   8
   9/* AmigaOS allows file names with up to 30 characters length.
  10 * Names longer than that will be silently truncated. If you
  11 * want to disallow this, comment out the following #define.
  12 * Creating filesystem objects with longer names will then
  13 * result in an error (ENAMETOOLONG).
  14 */
  15/*#define AFFS_NO_TRUNCATE */
  16
  17/* Ugly macros make the code more pretty. */
  18
  19#define GET_END_PTR(st,p,sz)             ((st *)((char *)(p)+((sz)-sizeof(st))))
  20#define AFFS_GET_HASHENTRY(data,hashkey) be32_to_cpu(((struct dir_front *)data)->hashtable[hashkey])
  21#define AFFS_BLOCK(sb, bh, blk)         (AFFS_HEAD(bh)->table[AFFS_SB(sb)->s_hashsize-1-(blk)])
  22
  23static inline void
  24affs_set_blocksize(struct super_block *sb, int size)
  25{
  26        sb_set_blocksize(sb, size);
  27}
  28static inline struct buffer_head *
  29affs_bread(struct super_block *sb, int block)
  30{
  31        pr_debug("affs_bread: %d\n", block);
  32        if (block >= AFFS_SB(sb)->s_reserved && block < AFFS_SB(sb)->s_partition_size)
  33                return sb_bread(sb, block);
  34        return NULL;
  35}
  36static inline struct buffer_head *
  37affs_getblk(struct super_block *sb, int block)
  38{
  39        pr_debug("affs_getblk: %d\n", block);
  40        if (block >= AFFS_SB(sb)->s_reserved && block < AFFS_SB(sb)->s_partition_size)
  41                return sb_getblk(sb, block);
  42        return NULL;
  43}
  44static inline struct buffer_head *
  45affs_getzeroblk(struct super_block *sb, int block)
  46{
  47        struct buffer_head *bh;
  48        pr_debug("affs_getzeroblk: %d\n", block);
  49        if (block >= AFFS_SB(sb)->s_reserved && block < AFFS_SB(sb)->s_partition_size) {
  50                bh = sb_getblk(sb, block);
  51                lock_buffer(bh);
  52                memset(bh->b_data, 0 , sb->s_blocksize);
  53                set_buffer_uptodate(bh);
  54                unlock_buffer(bh);
  55                return bh;
  56        }
  57        return NULL;
  58}
  59static inline struct buffer_head *
  60affs_getemptyblk(struct super_block *sb, int block)
  61{
  62        struct buffer_head *bh;
  63        pr_debug("affs_getemptyblk: %d\n", block);
  64        if (block >= AFFS_SB(sb)->s_reserved && block < AFFS_SB(sb)->s_partition_size) {
  65                bh = sb_getblk(sb, block);
  66                wait_on_buffer(bh);
  67                set_buffer_uptodate(bh);
  68                return bh;
  69        }
  70        return NULL;
  71}
  72static inline void
  73affs_brelse(struct buffer_head *bh)
  74{
  75        if (bh)
  76                pr_debug("affs_brelse: %lld\n", (long long) bh->b_blocknr);
  77        brelse(bh);
  78}
  79
  80static inline void
  81affs_adjust_checksum(struct buffer_head *bh, u32 val)
  82{
  83        u32 tmp = be32_to_cpu(((__be32 *)bh->b_data)[5]);
  84        ((__be32 *)bh->b_data)[5] = cpu_to_be32(tmp - val);
  85}
  86static inline void
  87affs_adjust_bitmapchecksum(struct buffer_head *bh, u32 val)
  88{
  89        u32 tmp = be32_to_cpu(((__be32 *)bh->b_data)[0]);
  90        ((__be32 *)bh->b_data)[0] = cpu_to_be32(tmp - val);
  91}
  92
  93static inline void
  94affs_lock_link(struct inode *inode)
  95{
  96        down(&AFFS_I(inode)->i_link_lock);
  97}
  98static inline void
  99affs_unlock_link(struct inode *inode)
 100{
 101        up(&AFFS_I(inode)->i_link_lock);
 102}
 103static inline void
 104affs_lock_dir(struct inode *inode)
 105{
 106        down(&AFFS_I(inode)->i_hash_lock);
 107}
 108static inline void
 109affs_unlock_dir(struct inode *inode)
 110{
 111        up(&AFFS_I(inode)->i_hash_lock);
 112}
 113static inline void
 114affs_lock_ext(struct inode *inode)
 115{
 116        down(&AFFS_I(inode)->i_ext_lock);
 117}
 118static inline void
 119affs_unlock_ext(struct inode *inode)
 120{
 121        up(&AFFS_I(inode)->i_ext_lock);
 122}
 123
 124#ifdef __LITTLE_ENDIAN
 125#define BO_EXBITS       0x18UL
 126#elif defined(__BIG_ENDIAN)
 127#define BO_EXBITS       0x00UL
 128#else
 129#error Endianness must be known for affs to work.
 130#endif
 131
 132#define FS_OFS          0x444F5300
 133#define FS_FFS          0x444F5301
 134#define FS_INTLOFS      0x444F5302
 135#define FS_INTLFFS      0x444F5303
 136#define FS_DCOFS        0x444F5304
 137#define FS_DCFFS        0x444F5305
 138#define MUFS_FS         0x6d754653   /* 'muFS' */
 139#define MUFS_OFS        0x6d754600   /* 'muF\0' */
 140#define MUFS_FFS        0x6d754601   /* 'muF\1' */
 141#define MUFS_INTLOFS    0x6d754602   /* 'muF\2' */
 142#define MUFS_INTLFFS    0x6d754603   /* 'muF\3' */
 143#define MUFS_DCOFS      0x6d754604   /* 'muF\4' */
 144#define MUFS_DCFFS      0x6d754605   /* 'muF\5' */
 145
 146#define T_SHORT         2
 147#define T_LIST          16
 148#define T_DATA          8
 149
 150#define ST_LINKFILE     -4
 151#define ST_FILE         -3
 152#define ST_ROOT         1
 153#define ST_USERDIR      2
 154#define ST_SOFTLINK     3
 155#define ST_LINKDIR      4
 156
 157#define AFFS_ROOT_BMAPS         25
 158
 159#define AFFS_HEAD(bh)           ((struct affs_head *)(bh)->b_data)
 160#define AFFS_TAIL(sb, bh)       ((struct affs_tail *)((bh)->b_data+(sb)->s_blocksize-sizeof(struct affs_tail)))
 161#define AFFS_ROOT_HEAD(bh)      ((struct affs_root_head *)(bh)->b_data)
 162#define AFFS_ROOT_TAIL(sb, bh)  ((struct affs_root_tail *)((bh)->b_data+(sb)->s_blocksize-sizeof(struct affs_root_tail)))
 163#define AFFS_DATA_HEAD(bh)      ((struct affs_data_head *)(bh)->b_data)
 164#define AFFS_DATA(bh)           (((struct affs_data_head *)(bh)->b_data)->data)
 165
 166struct affs_date {
 167        __be32 days;
 168        __be32 mins;
 169        __be32 ticks;
 170};
 171
 172struct affs_short_date {
 173        __be16 days;
 174        __be16 mins;
 175        __be16 ticks;
 176};
 177
 178struct affs_root_head {
 179        __be32 ptype;
 180        __be32 spare1;
 181        __be32 spare2;
 182        __be32 hash_size;
 183        __be32 spare3;
 184        __be32 checksum;
 185        __be32 hashtable[1];
 186};
 187
 188struct affs_root_tail {
 189        __be32 bm_flag;
 190        __be32 bm_blk[AFFS_ROOT_BMAPS];
 191        __be32 bm_ext;
 192        struct affs_date root_change;
 193        u8 disk_name[32];
 194        __be32 spare1;
 195        __be32 spare2;
 196        struct affs_date disk_change;
 197        struct affs_date disk_create;
 198        __be32 spare3;
 199        __be32 spare4;
 200        __be32 dcache;
 201        __be32 stype;
 202};
 203
 204struct affs_head {
 205        __be32 ptype;
 206        __be32 key;
 207        __be32 block_count;
 208        __be32 spare1;
 209        __be32 first_data;
 210        __be32 checksum;
 211        __be32 table[1];
 212};
 213
 214struct affs_tail {
 215        __be32 spare1;
 216        __be16 uid;
 217        __be16 gid;
 218        __be32 protect;
 219        __be32 size;
 220        u8 comment[92];
 221        struct affs_date change;
 222        u8 name[32];
 223        __be32 spare2;
 224        __be32 original;
 225        __be32 link_chain;
 226        __be32 spare[5];
 227        __be32 hash_chain;
 228        __be32 parent;
 229        __be32 extension;
 230        __be32 stype;
 231};
 232
 233struct slink_front
 234{
 235        __be32 ptype;
 236        __be32 key;
 237        __be32 spare1[3];
 238        __be32 checksum;
 239        u8 symname[1];  /* depends on block size */
 240};
 241
 242struct affs_data_head
 243{
 244        __be32 ptype;
 245        __be32 key;
 246        __be32 sequence;
 247        __be32 size;
 248        __be32 next;
 249        __be32 checksum;
 250        u8 data[1];     /* depends on block size */
 251};
 252
 253/* Permission bits */
 254
 255#define FIBF_OTR_READ           0x8000
 256#define FIBF_OTR_WRITE          0x4000
 257#define FIBF_OTR_EXECUTE        0x2000
 258#define FIBF_OTR_DELETE         0x1000
 259#define FIBF_GRP_READ           0x0800
 260#define FIBF_GRP_WRITE          0x0400
 261#define FIBF_GRP_EXECUTE        0x0200
 262#define FIBF_GRP_DELETE         0x0100
 263
 264#define FIBF_HIDDEN             0x0080
 265#define FIBF_SCRIPT             0x0040
 266#define FIBF_PURE               0x0020          /* no use under linux */
 267#define FIBF_ARCHIVED           0x0010          /* never set, always cleared on write */
 268#define FIBF_NOREAD             0x0008          /* 0 means allowed */
 269#define FIBF_NOWRITE            0x0004          /* 0 means allowed */
 270#define FIBF_NOEXECUTE          0x0002          /* 0 means allowed, ignored under linux */
 271#define FIBF_NODELETE           0x0001          /* 0 means allowed */
 272
 273#define FIBF_OWNER              0x000F          /* Bits pertaining to owner */
 274#define FIBF_MASK               0xEE0E          /* Bits modified by Linux */
 275
 276#endif
 277
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.