The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/fs/hpfs/hpfs_fn.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  *  linux/fs/hpfs/hpfs_fn.h
    3  *
    4  *  Mikulas Patocka (mikulas@artax.karlin.mff.cuni.cz), 1998-1999
    5  *
    6  *  function headers
    7  */
    8 
    9 //#define DBG
   10 //#define DEBUG_LOCKS
   11 
   12 #include <linux/fs.h>
   13 #include <linux/hpfs_fs.h>
   14 #include <linux/errno.h>
   15 #include <linux/slab.h>
   16 #include <linux/kernel.h>
   17 #include <linux/sched.h>
   18 #include <linux/locks.h>
   19 #include <linux/stat.h>
   20 #include <linux/string.h>
   21 #include <asm/bitops.h>
   22 #include <asm/segment.h>
   23 #include <asm/uaccess.h>
   24 #include <linux/smp_lock.h>
   25 
   26 #include <stdarg.h>
   27 
   28 #include "hpfs.h"
   29 
   30 #define memcpy_tofs memcpy
   31 #define memcpy_fromfs memcpy
   32 
   33 #define EIOERROR  EIO
   34 #define EFSERROR  EPERM
   35 #define EMEMERROR ENOMEM
   36 
   37 #define ANODE_ALLOC_FWD 512
   38 #define FNODE_ALLOC_FWD 0
   39 #define ALLOC_FWD_MIN   16
   40 #define ALLOC_FWD_MAX   128
   41 #define ALLOC_M         1
   42 #define FNODE_RD_AHEAD  16
   43 #define ANODE_RD_AHEAD  16
   44 #define DNODE_RD_AHEAD  4
   45 
   46 #define FREE_DNODES_ADD 58
   47 #define FREE_DNODES_DEL 29
   48 
   49 #define CHKCOND(x,y) if (!(x)) printk y
   50 
   51 #ifdef DBG
   52 #define PRINTK(x) printk x
   53 #else
   54 #undef PRINTK
   55 #define PRINTK(x)
   56 #endif
   57 
   58 typedef void nonconst; /* What this is for ? */
   59 
   60 /*
   61  * local time (HPFS) to GMT (Unix)
   62  */
   63 
   64 extern inline time_t local_to_gmt(struct super_block *s, time_t t)
   65 {
   66         extern struct timezone sys_tz;
   67         return t + sys_tz.tz_minuteswest * 60 + s->s_hpfs_timeshift;
   68 }
   69 
   70 extern inline time_t gmt_to_local(struct super_block *s, time_t t)
   71 {
   72         extern struct timezone sys_tz;
   73         return t - sys_tz.tz_minuteswest * 60 - s->s_hpfs_timeshift;
   74 }
   75 
   76 /*
   77  * conv= options
   78  */
   79 
   80 #define CONV_BINARY 0                   /* no conversion */
   81 #define CONV_TEXT 1                     /* crlf->newline */
   82 #define CONV_AUTO 2                     /* decide based on file contents */
   83 
   84 /* Four 512-byte buffers and the 2k block obtained by concatenating them */
   85 
   86 struct quad_buffer_head {
   87         struct buffer_head *bh[4];
   88         void *data;
   89 };
   90 
   91 /* The b-tree down pointer from a dir entry */
   92 
   93 extern inline dnode_secno de_down_pointer (struct hpfs_dirent *de)
   94 {
   95   CHKCOND(de->down,("HPFS: de_down_pointer: !de->down\n"));
   96   return *(dnode_secno *) ((void *) de + de->length - 4);
   97 }
   98 
   99 /* The first dir entry in a dnode */
  100 
  101 extern inline struct hpfs_dirent *dnode_first_de (struct dnode *dnode)
  102 {
  103   return (void *) dnode->dirent;
  104 }
  105 
  106 /* The end+1 of the dir entries */
  107 
  108 extern inline struct hpfs_dirent *dnode_end_de (struct dnode *dnode)
  109 {
  110   CHKCOND(dnode->first_free>=0x14 && dnode->first_free<=0xa00,("HPFS: dnode_end_de: dnode->first_free = %d\n",(int)dnode->first_free));
  111   return (void *) dnode + dnode->first_free;
  112 }
  113 
  114 /* The dir entry after dir entry de */
  115 
  116 extern inline struct hpfs_dirent *de_next_de (struct hpfs_dirent *de)
  117 {
  118   CHKCOND(de->length>=0x20 && de->length<0x800,("HPFS: de_next_de: de->length = %d\n",(int)de->length));
  119   return (void *) de + de->length;
  120 }
  121 
  122 extern inline struct extended_attribute *fnode_ea(struct fnode *fnode)
  123 {
  124         return (struct extended_attribute *)((char *)fnode + fnode->ea_offs);
  125 }
  126 
  127 extern inline struct extended_attribute *fnode_end_ea(struct fnode *fnode)
  128 {
  129         return (struct extended_attribute *)((char *)fnode + fnode->ea_offs + fnode->ea_size_s);
  130 }
  131 
  132 extern inline struct extended_attribute *next_ea(struct extended_attribute *ea)
  133 {
  134         return (struct extended_attribute *)((char *)ea + 5 + ea->namelen + ea->valuelen);
  135 }
  136 
  137 extern inline secno ea_sec(struct extended_attribute *ea)
  138 {
  139         return *(secno *)((char *)ea + 9 + ea->namelen);
  140 }
  141 
  142 extern inline secno ea_len(struct extended_attribute *ea)
  143 {
  144         return *(secno *)((char *)ea + 5 + ea->namelen);
  145 }
  146 
  147 extern inline char *ea_data(struct extended_attribute *ea)
  148 {
  149         return (char *)((char *)ea + 5 + ea->namelen);
  150 }
  151 
  152 extern inline unsigned de_size(int namelen, secno down_ptr)
  153 {
  154         return ((0x1f + namelen + 3) & ~3) + (down_ptr ? 4 : 0);
  155 }
  156 
  157 extern inline void copy_de(struct hpfs_dirent *dst, struct hpfs_dirent *src)
  158 {
  159         int a;
  160         int n;
  161         if (!dst || !src) return;
  162         a = dst->down;
  163         n = dst->not_8x3;
  164         memcpy((char *)dst + 2, (char *)src + 2, 28);
  165         dst->down = a;
  166         dst->not_8x3 = n;
  167 }
  168 
  169 extern inline unsigned tstbits(unsigned *bmp, unsigned b, unsigned n)
  170 {
  171         int i;
  172         if ((b >= 0x4000) || (b + n - 1 >= 0x4000)) return n;
  173         if (!((bmp[(b & 0x3fff) >> 5] >> (b & 0x1f)) & 1)) return 1;
  174         for (i = 1; i < n; i++)
  175                 if (/*b+i < 0x4000 &&*/ !((bmp[((b+i) & 0x3fff) >> 5] >> ((b+i) & 0x1f)) & 1))
  176                         return i + 1;
  177         return 0;
  178 }
  179 
  180 /* alloc.c */
  181 
  182 int hpfs_chk_sectors(struct super_block *, secno, int, char *);
  183 secno hpfs_alloc_sector(struct super_block *, secno, unsigned, int, int);
  184 int hpfs_alloc_if_possible_nolock(struct super_block *, secno);
  185 int hpfs_alloc_if_possible(struct super_block *, secno);
  186 void hpfs_free_sectors(struct super_block *, secno, unsigned);
  187 int hpfs_check_free_dnodes(struct super_block *, int);
  188 void hpfs_free_dnode(struct super_block *, secno);
  189 struct dnode *hpfs_alloc_dnode(struct super_block *, secno, dnode_secno *, struct quad_buffer_head *, int);
  190 struct fnode *hpfs_alloc_fnode(struct super_block *, secno, fnode_secno *, struct buffer_head **);
  191 struct anode *hpfs_alloc_anode(struct super_block *, secno, anode_secno *, struct buffer_head **);
  192 
  193 /* anode.c */
  194 
  195 secno hpfs_bplus_lookup(struct super_block *, struct inode *, struct bplus_header *, unsigned, struct buffer_head *);
  196 secno hpfs_add_sector_to_btree(struct super_block *, secno, int, unsigned);
  197 void hpfs_remove_btree(struct super_block *, struct bplus_header *);
  198 int hpfs_ea_read(struct super_block *, secno, int, unsigned, unsigned, char *);
  199 int hpfs_ea_write(struct super_block *, secno, int, unsigned, unsigned, char *);
  200 void hpfs_ea_remove(struct super_block *, secno, int, unsigned);
  201 void hpfs_truncate_btree(struct super_block *, secno, int, unsigned);
  202 void hpfs_remove_fnode(struct super_block *, fnode_secno fno);
  203 
  204 /* buffer.c */
  205 
  206 void hpfs_lock_creation(struct super_block *);
  207 void hpfs_unlock_creation(struct super_block *);
  208 void hpfs_lock_iget(struct super_block *, int);
  209 void hpfs_unlock_iget(struct super_block *);
  210 void hpfs_lock_inode(struct inode *);
  211 void hpfs_unlock_inode(struct inode *);
  212 void hpfs_lock_2inodes(struct inode *, struct inode *);
  213 void hpfs_unlock_2inodes(struct inode *, struct inode *);
  214 void hpfs_lock_3inodes(struct inode *, struct inode *, struct inode *);
  215 void hpfs_unlock_3inodes(struct inode *, struct inode *, struct inode *);
  216 void *hpfs_map_sector(struct super_block *, unsigned, struct buffer_head **, int);
  217 void *hpfs_get_sector(struct super_block *, unsigned, struct buffer_head **);
  218 void *hpfs_map_4sectors(struct super_block *, unsigned, struct quad_buffer_head *, int);
  219 void *hpfs_get_4sectors(struct super_block *, unsigned, struct quad_buffer_head *);
  220 void hpfs_brelse4(struct quad_buffer_head *);
  221 void hpfs_mark_4buffers_dirty(struct quad_buffer_head *);
  222 
  223 /* dentry.c */
  224 
  225 void hpfs_set_dentry_operations(struct dentry *);
  226 
  227 /* dir.c */
  228 
  229 int hpfs_dir_release(struct inode *, struct file *);
  230 loff_t hpfs_dir_lseek(struct file *, loff_t, int);
  231 int hpfs_readdir(struct file *, void *, filldir_t);
  232 struct dentry *hpfs_lookup(struct inode *, struct dentry *);
  233 
  234 /* dnode.c */
  235 
  236 void hpfs_add_pos(struct inode *, loff_t *);
  237 void hpfs_del_pos(struct inode *, loff_t *);
  238 struct hpfs_dirent *hpfs_add_de(struct super_block *, struct dnode *, unsigned char *, unsigned, secno);
  239 void hpfs_delete_de(struct super_block *, struct dnode *, struct hpfs_dirent *);
  240 int hpfs_add_to_dnode(struct inode *, dnode_secno, unsigned char *, unsigned, struct hpfs_dirent *, dnode_secno);
  241 int hpfs_add_dirent(struct inode *, unsigned char *, unsigned, struct hpfs_dirent *, int);
  242 int hpfs_remove_dirent(struct inode *, dnode_secno, struct hpfs_dirent *, struct quad_buffer_head *, int);
  243 void hpfs_count_dnodes(struct super_block *, dnode_secno, int *, int *, int *);
  244 dnode_secno hpfs_de_as_down_as_possible(struct super_block *, dnode_secno dno);
  245 struct hpfs_dirent *map_pos_dirent(struct inode *, loff_t *, struct quad_buffer_head *);
  246 struct hpfs_dirent *map_dirent(struct inode *, dnode_secno, char *, unsigned, dnode_secno *, struct quad_buffer_head *);
  247 void hpfs_remove_dtree(struct super_block *, dnode_secno);
  248 struct hpfs_dirent *map_fnode_dirent(struct super_block *, fnode_secno, struct fnode *, struct quad_buffer_head *);
  249 
  250 /* ea.c */
  251 
  252 void hpfs_ea_ext_remove(struct super_block *, secno, int, unsigned);
  253 int hpfs_read_ea(struct super_block *, struct fnode *, char *, char *, int);
  254 char *hpfs_get_ea(struct super_block *, struct fnode *, char *, int *);
  255 void hpfs_set_ea(struct inode *, struct fnode *, char *, char *, int);
  256 
  257 /* file.c */
  258 
  259 int hpfs_file_release(struct inode *, struct file *);
  260 int hpfs_open(struct inode *, struct file *);
  261 int hpfs_file_fsync(struct file *, struct dentry *, int);
  262 secno hpfs_bmap(struct inode *, unsigned);
  263 void hpfs_truncate(struct inode *);
  264 int hpfs_get_block(struct inode *inode, long iblock, struct buffer_head *bh_result, int create);
  265 ssize_t hpfs_file_write(struct file *file, const char *buf, size_t count, loff_t *ppos);
  266 
  267 /* inode.c */
  268 
  269 void hpfs_read_inode(struct inode *);
  270 void hpfs_write_inode_ea(struct inode *, struct fnode *);
  271 void hpfs_write_inode(struct inode *);
  272 void hpfs_write_inode_nolock(struct inode *);
  273 int hpfs_notify_change(struct dentry *, struct iattr *);
  274 void hpfs_write_if_changed(struct inode *);
  275 void hpfs_delete_inode(struct inode *);
  276 
  277 /* map.c */
  278 
  279 unsigned *hpfs_map_dnode_bitmap(struct super_block *, struct quad_buffer_head *);
  280 unsigned *hpfs_map_bitmap(struct super_block *, unsigned, struct quad_buffer_head *, char *);
  281 char *hpfs_load_code_page(struct super_block *, secno);
  282 secno *hpfs_load_bitmap_directory(struct super_block *, secno bmp);
  283 struct fnode *hpfs_map_fnode(struct super_block *s, ino_t, struct buffer_head **);
  284 struct anode *hpfs_map_anode(struct super_block *s, anode_secno, struct buffer_head **);
  285 struct dnode *hpfs_map_dnode(struct super_block *s, dnode_secno, struct quad_buffer_head *);
  286 dnode_secno hpfs_fnode_dno(struct super_block *s, ino_t ino);
  287 
  288 /* name.c */
  289 
  290 unsigned char hpfs_upcase(unsigned char *, unsigned char);
  291 int hpfs_chk_name(unsigned char *, unsigned *);
  292 char *hpfs_translate_name(struct super_block *, unsigned char *, unsigned, int, int);
  293 int hpfs_compare_names(struct super_block *, unsigned char *, unsigned, unsigned char *, unsigned, int);
  294 int hpfs_is_name_long(unsigned char *, unsigned);
  295 void hpfs_adjust_length(unsigned char *, unsigned *);
  296 void hpfs_decide_conv(struct inode *, unsigned char *, unsigned);
  297 
  298 /* namei.c */
  299 
  300 int hpfs_mkdir(struct inode *, struct dentry *, int);
  301 int hpfs_create(struct inode *, struct dentry *, int);
  302 int hpfs_mknod(struct inode *, struct dentry *, int, int);
  303 int hpfs_symlink(struct inode *, struct dentry *, const char *);
  304 int hpfs_unlink(struct inode *, struct dentry *);
  305 int hpfs_rmdir(struct inode *, struct dentry *);
  306 int hpfs_symlink_readpage(struct file *, struct page *);
  307 int hpfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
  308 
  309 /* super.c */
  310 
  311 void hpfs_error(struct super_block *, char *, ...);
  312 int hpfs_stop_cycles(struct super_block *, int, int *, int *, char *);
  313 int hpfs_remount_fs(struct super_block *, int *, char *);
  314 void hpfs_put_super(struct super_block *);
  315 unsigned hpfs_count_one_bitmap(struct super_block *, secno);
  316 int hpfs_statfs(struct super_block *, struct statfs *);
  317 
  318 extern struct address_space_operations hpfs_aops;

Cache object: fb04f7b870348ebf408acfac404409b4


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.