root/fs/affs/amigaffs.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. affs_get_key_entry
  2. affs_find_next_hash_entry
  3. affs_get_fh_hash_link
  4. affs_get_file_name
  5. affs_get_extension
  6. affs_checksum_block
  7. init_affs_fs

   1 /*
   2  *  linux/fs/affs/amigaffs.c
   3  *
   4  *  (C) 1993  Ray Burr - Amiga FFS filesystem.
   5  *
   6  */
   7 
   8 #include <linux/fs.h>
   9 #include <linux/affs_fs.h>
  10 #include <linux/mm.h>
  11 
  12 #include "amigaffs.h"
  13 
  14 /*
  15  * Functions for accessing Amiga-FFS structures.
  16  *
  17  */
  18 
  19 /* Get key entry number ENTRY_POS from the header block pointed to
  20    by DATA.  If ENTRY_POS is invalid, -1 is returned.  This is
  21    used to get entries from file and directory headers as well
  22    as extension and root blocks.  In the current FFS specs, these
  23    tables are defined to be the same size in all of these. */
  24 
  25 int affs_get_key_entry (int bsize, void *data, int entry_pos)
     /* [previous][next][first][last][top][bottom][index][help] */
  26 {
  27         struct dir_front *dir_front = (struct dir_front *)data;
  28         int key, hash_table_size;
  29 
  30         hash_table_size = MIDBLOCK_LONGS (bsize);
  31         key = 0;
  32         if (entry_pos >= 0 && entry_pos < hash_table_size)
  33                 key = swap_long (dir_front->hash_table[entry_pos]);
  34 
  35         return key;
  36 }
  37 
  38 /* Find the next used hash entry at or after *HASH_POS in a directory's hash
  39    table.  *HASH_POS is assigned that entry's number.  DIR_DATA points to
  40    the directory header block in memory.  If there are no more entries,
  41    0 is returned.  Otherwise, the key number in the next used hash slot
  42    is returned. */
  43 
  44 int affs_find_next_hash_entry (int bsize, void *dir_data, int *hash_pos)
     /* [previous][next][first][last][top][bottom][index][help] */
  45 {
  46         struct dir_front *dir_front = (struct dir_front *)dir_data;
  47         int i, hash_table_size;
  48 
  49         hash_table_size = MIDBLOCK_LONGS (bsize);
  50         if (*hash_pos < 0 || *hash_pos >= hash_table_size)
  51                 return -1;
  52         for (i = *hash_pos; i < hash_table_size; i++)
  53                 if (dir_front->hash_table[i] != 0)
  54                         break;
  55         if (i == hash_table_size)
  56                 return 0;
  57         *hash_pos = i;
  58         return swap_long (dir_front->hash_table[i]);
  59 }
  60 
  61 /* Get the hash_chain (next file header key in hash chain) entry from a
  62    file header block in memory pointed to by FH_DATA. */
  63 
  64 int affs_get_fh_hash_link (int bsize, void *fh_data)
     /* [previous][next][first][last][top][bottom][index][help] */
  65 {
  66         struct file_end *file_end;
  67         int key;
  68 
  69         file_end = GET_END_PTR (struct file_end, fh_data, bsize);
  70         key = swap_long (file_end->hash_chain);
  71         return key;
  72 }
  73 
  74 /* Set *NAME to point to the file name in a file header block in memory
  75    pointed to by FH_DATA.  The length of the name is returned. */
  76 
  77 int affs_get_file_name (int bsize, void *fh_data, char **name)
     /* [previous][next][first][last][top][bottom][index][help] */
  78 {
  79         struct file_end *file_end;
  80 
  81         file_end = GET_END_PTR (struct file_end, fh_data, bsize);
  82         if (file_end->file_name[0] == 0
  83             || file_end->file_name[0] > 30) {
  84                 printk ("affs_get_file_name: OOPS! bad filename\n");
  85                 printk ("  file_end->file_name[0] = %d\n",
  86                         file_end->file_name[0]);
  87                 *name = "***BAD_FILE***";
  88                 return 14;
  89         }
  90         *name = (char *) &file_end->file_name[1];
  91         return file_end->file_name[0];
  92 }
  93 
  94 /* Get the key number of the first extention block for the file
  95    header pointed to by FH_DATA. */
  96 
  97 int affs_get_extension (int bsize, void *fh_data)
     /* [previous][next][first][last][top][bottom][index][help] */
  98 {
  99         struct file_end *file_end;
 100         int key;
 101 
 102         file_end = GET_END_PTR (struct file_end, fh_data, bsize);
 103         key = swap_long (file_end->extension);
 104         return key;
 105 }
 106 
 107 /* Checksum a block, do various consistency checks and optionally return
 108    the blocks type number.  DATA points to the block.  If their pointers
 109    are non-null, *PTYPE and *STYPE are set to the primary and secondary
 110    block types respectively.  Returns non-zero if the block is not
 111    consistent. */
 112 
 113 int affs_checksum_block (int bsize, void *data, int *ptype, int *stype)
     /* [previous][next][first][last][top][bottom][index][help] */
 114 {
 115         if (ptype)
 116                 *ptype = swap_long (((long *) data)[0]);
 117         if (stype)
 118                 *stype = swap_long (((long *) data)[bsize / 4 - 1]);
 119         return 0;
 120 }
 121 
 122 static struct file_system_type affs_fs_type = {
 123         affs_read_super, "affs", 1, NULL
 124 };
 125 
 126 int init_affs_fs(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 127 {
 128         return register_filesystem(&affs_fs_type);
 129 }
 130 

/* [previous][next][first][last][top][bottom][index][help] */