diff options
| author | Linus Torvalds <torvalds@athlon.transmeta.com> | 2002-02-04 20:23:59 -0800 |
|---|---|---|
| committer | Linus Torvalds <torvalds@athlon.transmeta.com> | 2002-02-04 20:23:59 -0800 |
| commit | 14450c4668484d2413b09ca77753133bce60a3e9 (patch) | |
| tree | caf851f902a2601b1c41436693c0c48fc79e5608 /include/linux | |
| parent | ad8dcf57e93e8e5f9b815e786da35ef03fc70f89 (diff) | |
v2.4.12.1 -> v2.4.12.2
- Alan Cox: more merging
- Ben Fennema: UDF module license
- Jeff Mahoney: reiserfs endian safeness
- Chris Mason: reiserfs O_SYNC/fsync performance improvements
- Jean Tourrilhes: wireless extension update
- Joerg Reuter: AX.25 updates
- David Miller: 64-bit DMA interfaces
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/msdos_fs.h | 237 | ||||
| -rw-r--r-- | include/linux/msdos_fs_sb.h | 7 | ||||
| -rw-r--r-- | include/linux/pci.h | 8 | ||||
| -rw-r--r-- | include/linux/reiserfs_fs.h | 338 | ||||
| -rw-r--r-- | include/linux/reiserfs_fs_i.h | 6 | ||||
| -rw-r--r-- | include/linux/reiserfs_fs_sb.h | 91 | ||||
| -rw-r--r-- | include/linux/wireless.h | 78 |
7 files changed, 525 insertions, 240 deletions
diff --git a/include/linux/msdos_fs.h b/include/linux/msdos_fs.h index e93201f56b10..1baa0a77a9ac 100644 --- a/include/linux/msdos_fs.h +++ b/include/linux/msdos_fs.h @@ -92,6 +92,15 @@ #define VFAT_IOCTL_READDIR_BOTH _IOR('r', 1, struct dirent [2]) #define VFAT_IOCTL_READDIR_SHORT _IOR('r', 2, struct dirent [2]) +/* + * vfat shortname flags + */ +#define VFAT_SFN_DISPLAY_LOWER 0x0001 /* convert to lowercase for display */ +#define VFAT_SFN_DISPLAY_WIN95 0x0002 /* emulate win95 rule for display */ +#define VFAT_SFN_DISPLAY_WINNT 0x0004 /* emulate winnt rule for display */ +#define VFAT_SFN_CREATE_WIN95 0x0100 /* emulate win95 rule for create */ +#define VFAT_SFN_CREATE_WINNT 0x0200 /* emulate winnt rule for create */ + /* * Conversion from and to little-endian byte order. (no-op on i386/i486) * @@ -132,7 +141,7 @@ struct fat_boot_sector { }; struct fat_boot_fsinfo { - __u32 signature1; /* 0x61417272L */ + __u32 signature1; /* 0x41615252L */ __u32 reserved1[120]; /* Nothing as far as I can tell */ __u32 signature2; /* 0x61417272L */ __u32 free_clusters; /* Free cluster count. -1 if unknown */ @@ -188,6 +197,8 @@ struct vfat_slot_info { #ifdef __KERNEL__ +#include <linux/nls.h> + struct fat_cache { kdev_t device; /* device number. 0 means unused. */ int start_cluster; /* first cluster of the chain. */ @@ -196,21 +207,111 @@ struct fat_cache { struct fat_cache *next; /* next cache entry */ }; -/* misc.c */ -extern int fat_is_binary(char conversion,char *extension); +static inline void fat16_towchar(wchar_t *dst, const __u8 *src, size_t len) +{ +#ifdef __BIG_ENDIAN + while (len--) { + *dst++ = src[0] | (src[1] << 8); + src += 2; + } +#else + memcpy(dst, src, len * 2); +#endif +} + +static inline void fatwchar_to16(__u8 *dst, const wchar_t *src, size_t len) +{ +#ifdef __BIG_ENDIAN + while (len--) { + dst[0] = *src & 0x00FF; + dst[1] = (*src & 0xFF00) >> 8; + dst += 2; + src++; + } +#else + memcpy(dst, src, len * 2); +#endif +} + +/* fat/buffer.c */ +extern struct buffer_head *fat_bread(struct super_block *sb, int block); +extern struct buffer_head *fat_getblk(struct super_block *sb, int block); +extern void fat_brelse(struct super_block *sb, struct buffer_head *bh); +extern void fat_mark_buffer_dirty(struct super_block *sb, struct buffer_head *bh); +extern void fat_set_uptodate(struct super_block *sb, struct buffer_head *bh, + int val); +extern int fat_is_uptodate(struct super_block *sb, struct buffer_head *bh); +extern void fat_ll_rw_block(struct super_block *sb, int opr, int nbreq, + struct buffer_head *bh[32]); + +/* fat/cache.c */ +extern int fat_access(struct super_block *sb, int nr, int new_value); +extern int fat_bmap(struct inode *inode, int sector); +extern void fat_cache_init(void); +extern void fat_cache_lookup(struct inode *inode, int cluster, int *f_clu, + int *d_clu); +extern void fat_cache_add(struct inode *inode, int f_clu, int d_clu); +extern void fat_cache_inval_inode(struct inode *inode); +extern void fat_cache_inval_dev(kdev_t device); +extern int fat_get_cluster(struct inode *inode, int cluster); +extern int fat_free(struct inode *inode, int skip); + +/* fat/dir.c */ +extern struct file_operations fat_dir_operations; +extern int fat_search_long(struct inode *inode, const char *name, int name_len, + int anycase, loff_t *spos, loff_t *lpos); +extern int fat_readdir(struct file *filp, void *dirent, filldir_t filldir); +extern int fat_dir_ioctl(struct inode * inode, struct file * filp, + unsigned int cmd, unsigned long arg); +extern int fat_dir_empty(struct inode *dir); +extern int fat_add_entries(struct inode *dir, int slots, struct buffer_head **bh, + struct msdos_dir_entry **de, int *ino); +extern int fat_new_dir(struct inode *dir, struct inode *parent, int is_vfat); + +/* fat/file.c */ +extern struct file_operations fat_file_operations; +extern struct inode_operations fat_file_inode_operations; +extern ssize_t fat_file_read(struct file *filp, char *buf, size_t count, + loff_t *ppos); +extern int fat_get_block(struct inode *inode, long iblock, + struct buffer_head *bh_result, int create); +extern ssize_t fat_file_write(struct file *filp, const char *buf, size_t count, + loff_t *ppos); +extern void fat_truncate(struct inode *inode); + +/* fat/inode.c */ +extern void fat_hash_init(void); +extern void fat_attach(struct inode *inode, int i_pos); +extern void fat_detach(struct inode *inode); +extern struct inode *fat_iget(struct super_block *sb, int i_pos); +extern struct inode *fat_build_inode(struct super_block *sb, + struct msdos_dir_entry *de, int ino, int *res); +extern void fat_delete_inode(struct inode *inode); +extern void fat_clear_inode(struct inode *inode); +extern void fat_put_super(struct super_block *sb); +extern struct super_block * +fat_read_super(struct super_block *sb, void *data, int silent, + struct inode_operations *fs_dir_inode_ops); +extern int fat_statfs(struct super_block *sb, struct statfs *buf); +extern void fat_write_inode(struct inode *inode, int wait); +extern int fat_notify_change(struct dentry * dentry, struct iattr * attr); + +/* fat/misc.c */ +extern void fat_fs_panic(struct super_block *s, const char *msg); +extern int fat_is_binary(char conversion, char *extension); extern void lock_fat(struct super_block *sb); extern void unlock_fat(struct super_block *sb); +extern void fat_clusters_flush(struct super_block *sb); extern int fat_add_cluster(struct inode *inode); extern struct buffer_head *fat_extend_dir(struct inode *inode); -extern int date_dos2unix(__u16 time, __u16 date); -extern void fat_fs_panic(struct super_block *s,const char *msg); -extern void fat_lock_creation(void); -extern void fat_unlock_creation(void); -extern void fat_date_unix2dos(int unix_date,__u16 *time, __u16 *date); -extern int fat__get_entry(struct inode *dir,loff_t *pos,struct buffer_head **bh, - struct msdos_dir_entry **de,int *ino); -static __inline__ int fat_get_entry(struct inode *dir,loff_t *pos, - struct buffer_head **bh,struct msdos_dir_entry **de,int *ino) +extern int date_dos2unix(unsigned short time, unsigned short date); +extern void fat_date_unix2dos(int unix_date, unsigned short *time, + unsigned short *date); +extern int fat__get_entry(struct inode *dir, loff_t *pos, struct buffer_head **bh, + struct msdos_dir_entry **de, int *ino); +static __inline__ int fat_get_entry(struct inode *dir, loff_t *pos, + struct buffer_head **bh, + struct msdos_dir_entry **de, int *ino) { /* Fast stuff first */ if (*bh && *de && @@ -222,103 +323,33 @@ static __inline__ int fat_get_entry(struct inode *dir,loff_t *pos, } return fat__get_entry(dir,pos,bh,de,ino); } -extern int fat_scan(struct inode *dir,const char *name,struct buffer_head **res_bh, - struct msdos_dir_entry **res_de,int *ino); -extern int fat_parent_ino(struct inode *dir,int locked); extern int fat_subdirs(struct inode *dir); -void fat_clusters_flush(struct super_block *sb); +extern int fat_scan(struct inode *dir, const char *name, + struct buffer_head **res_bh, + struct msdos_dir_entry **res_de, int *ino); -/* fat.c */ -extern int fat_access(struct super_block *sb,int nr,int new_value); -extern int fat_free(struct inode *inode,int skip); -void fat_cache_inval_inode(struct inode *inode); -void fat_cache_inval_dev(kdev_t device); -extern void fat_cache_init(void); -void fat_cache_lookup(struct inode *inode,int cluster,int *f_clu,int *d_clu); -void fat_cache_add(struct inode *inode,int f_clu,int d_clu); -int fat_get_cluster(struct inode *inode,int cluster); - -/* inode.c */ -extern void fat_hash_init(void); -extern int fat_bmap(struct inode *inode,int block); -extern int fat_get_block(struct inode *, long, struct buffer_head *, int); -extern int fat_notify_change(struct dentry *, struct iattr *); -extern void fat_clear_inode(struct inode *inode); -extern void fat_delete_inode(struct inode *inode); -extern void fat_put_super(struct super_block *sb); -extern void fat_attach(struct inode *inode, int ino); -extern void fat_detach(struct inode *inode); -extern struct inode *fat_iget(struct super_block*,int); -extern struct inode *fat_build_inode(struct super_block*,struct msdos_dir_entry*,int,int*); -extern struct super_block *fat_read_super(struct super_block *s, void *data, int silent, struct inode_operations *dir_ops); +/* msdos/namei.c - these are for Umsdos */ extern void msdos_put_super(struct super_block *sb); -extern int fat_statfs(struct super_block *sb,struct statfs *buf); -extern void fat_write_inode(struct inode *inode, int); - -/* dir.c */ -extern struct file_operations fat_dir_operations; -extern int fat_search_long(struct inode *dir, const char *name, int len, - int anycase, loff_t *spos, loff_t *lpos); -extern int fat_readdir(struct file *filp, - void *dirent, filldir_t); -extern int fat_dir_ioctl(struct inode * inode, struct file * filp, - unsigned int cmd, unsigned long arg); -int fat_add_entries(struct inode *dir,int slots, struct buffer_head **bh, - struct msdos_dir_entry **de, int *ino); -int fat_dir_empty(struct inode *dir); -int fat_new_dir(struct inode *inode, struct inode *parent, int is_vfat); - -/* file.c */ -extern struct inode_operations fat_file_inode_operations; -extern struct inode_operations fat_file_inode_operations_1024; -extern struct inode_operations fat_file_inode_operations_readpage; -extern struct file_operations fat_file_operations; -extern ssize_t fat_file_read(struct file *, char *, size_t, loff_t *); -extern ssize_t fat_file_write(struct file *, const char *, size_t, loff_t *); -extern void fat_truncate(struct inode *inode); - -/* msdos.c */ -extern struct super_block *msdos_read_super(struct super_block *sb,void *data, int silent); - -/* msdos.c - these are for Umsdos */ -extern void msdos_read_inode(struct inode *inode); -extern struct dentry *msdos_lookup(struct inode *dir,struct dentry *); -extern int msdos_create(struct inode *dir,struct dentry *dentry,int mode); -extern int msdos_rmdir(struct inode *dir,struct dentry *dentry); -extern int msdos_mkdir(struct inode *dir,struct dentry *dentry,int mode); -extern int msdos_unlink(struct inode *dir,struct dentry *dentry); -extern int msdos_rename(struct inode *old_dir,struct dentry *old_dentry, - struct inode *new_dir,struct dentry *new_dentry); - -/* nls.c */ -extern struct fat_nls_table *fat_load_nls(int codepage); - -/* tables.c */ -extern unsigned char fat_uni2esc[]; -extern unsigned char fat_esc2uni[]; - -/* fatfs_syms.c */ -extern void cleanup_fat_fs(void); - -/* nls.c */ -extern int fat_register_nls(struct fat_nls_table * fmt); -extern int fat_unregister_nls(struct fat_nls_table * fmt); -extern struct fat_nls_table *fat_find_nls(int codepage); -extern struct fat_nls_table *fat_load_nls(int codepage); -extern void fat_unload_nls(int codepage); -extern int init_fat_nls(void); +extern struct dentry *msdos_lookup(struct inode *dir, struct dentry *); +extern int msdos_create(struct inode *dir, struct dentry *dentry, int mode); +extern int msdos_rmdir(struct inode *dir, struct dentry *dentry); +extern int msdos_mkdir(struct inode *dir, struct dentry *dentry, int mode); +extern int msdos_unlink(struct inode *dir, struct dentry *dentry); +extern int msdos_rename(struct inode *old_dir, struct dentry *old_dentry, + struct inode *new_dir, struct dentry *new_dentry); +extern struct super_block *msdos_read_super(struct super_block *sb, + void *data, int silent); /* vfat/namei.c - these are for dmsdos */ -extern int vfat_create(struct inode *dir,struct dentry *dentry,int mode); -extern int vfat_unlink(struct inode *dir,struct dentry *dentry); -extern int vfat_mkdir(struct inode *dir,struct dentry *dentry,int mode); -extern int vfat_rmdir(struct inode *dir,struct dentry *dentry); -extern int vfat_rename(struct inode *old_dir,struct dentry *old_dentry, - struct inode *new_dir,struct dentry *new_dentry); -extern struct super_block *vfat_read_super(struct super_block *sb,void *data, +extern struct dentry *vfat_lookup(struct inode *dir, struct dentry *); +extern int vfat_create(struct inode *dir, struct dentry *dentry, int mode); +extern int vfat_rmdir(struct inode *dir, struct dentry *dentry); +extern int vfat_unlink(struct inode *dir, struct dentry *dentry); +extern int vfat_mkdir(struct inode *dir, struct dentry *dentry, int mode); +extern int vfat_rename(struct inode *old_dir, struct dentry *old_dentry, + struct inode *new_dir, struct dentry *new_dentry); +extern struct super_block *vfat_read_super(struct super_block *sb, void *data, int silent); -extern void vfat_read_inode(struct inode *inode); -extern struct dentry *vfat_lookup(struct inode *dir,struct dentry *); /* vfat/vfatfs_syms.c */ extern struct file_system_type vfat_fs_type; diff --git a/include/linux/msdos_fs_sb.h b/include/linux/msdos_fs_sb.h index 0421836a2059..e622a038c7d5 100644 --- a/include/linux/msdos_fs_sb.h +++ b/include/linux/msdos_fs_sb.h @@ -12,6 +12,7 @@ struct fat_mount_options { unsigned short fs_umask; unsigned short codepage; /* Codepage for shortname conversions */ char *iocharset; /* Charset used for filename input/display */ + unsigned short shortname; /* flags for shortname display/create rule */ unsigned char name_check; /* r = relaxed, n = normal, s = strict */ unsigned char conversion; /* b = binary, t = text, a = auto */ unsigned quiet:1, /* set = fake successful chmods and chowns */ @@ -28,11 +29,6 @@ struct fat_mount_options { nocase:1; /* Does this need case conversion? 0=need case conversion*/ }; -struct vfat_unicode { - unsigned char uni1; - unsigned char uni2; -}; - struct msdos_sb_info { unsigned short cluster_size; /* sectors/cluster */ unsigned short cluster_bits; /* sectors/cluster */ @@ -45,7 +41,6 @@ struct msdos_sb_info { unsigned long clusters; /* number of clusters */ unsigned long root_cluster; /* first cluster of the root directory */ unsigned long fsinfo_sector; /* FAT32 fsinfo offset from start of disk */ - wait_queue_head_t fat_wait; struct semaphore fat_lock; int prev_free; /* previously returned free cluster number */ int free_clusters; /* -1 if undefined */ diff --git a/include/linux/pci.h b/include/linux/pci.h index ede11cc972f3..99789799a019 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -353,7 +353,7 @@ struct pci_dev { struct pci_driver *driver; /* which driver has allocated this device */ void *driver_data; /* data private to the driver */ - dma_addr_t dma_mask; /* Mask of the bits of bus address this + u64 dma_mask; /* Mask of the bits of bus address this device implements. Normally this is 0xffffffff. You only need to change this if your device has broken DMA @@ -559,7 +559,8 @@ int pci_write_config_dword(struct pci_dev *dev, int where, u32 val); int pci_enable_device(struct pci_dev *dev); void pci_disable_device(struct pci_dev *dev); void pci_set_master(struct pci_dev *dev); -int pci_set_dma_mask(struct pci_dev *dev, dma_addr_t mask); +int pci_set_dma_mask(struct pci_dev *dev, u64 mask); +int pci_dac_set_dma_mask(struct pci_dev *dev, u64 mask); int pci_assign_resource(struct pci_dev *dev, int i); /* Power management related routines */ @@ -641,7 +642,8 @@ static inline void pci_set_master(struct pci_dev *dev) { } static inline int pci_enable_device(struct pci_dev *dev) { return -EIO; } static inline void pci_disable_device(struct pci_dev *dev) { } static inline int pci_module_init(struct pci_driver *drv) { return -ENODEV; } -static inline int pci_set_dma_mask(struct pci_dev *dev, dma_addr_t mask) { return -EIO; } +static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask) { return -EIO; } +static inline int pci_dac_set_dma_mask(struct pci_dev *dev, u64 mask) { return -EIO; } static inline int pci_assign_resource(struct pci_dev *dev, int i) { return -EBUSY;} static inline int pci_register_driver(struct pci_driver *drv) { return 0;} static inline void pci_unregister_driver(struct pci_driver *drv) { } diff --git a/include/linux/reiserfs_fs.h b/include/linux/reiserfs_fs.h index 018320e36d51..78289269fb93 100644 --- a/include/linux/reiserfs_fs.h +++ b/include/linux/reiserfs_fs.h @@ -12,11 +12,12 @@ #ifndef _LINUX_REISER_FS_H #define _LINUX_REISER_FS_H - #include <linux/types.h> #ifdef __KERNEL__ #include <linux/slab.h> #include <linux/tqueue.h> +#include <asm/unaligned.h> +#include <linux/bitops.h> #include <asm/hardirq.h> #endif @@ -293,11 +294,57 @@ struct offset_v1 { } __attribute__ ((__packed__)); struct offset_v2 { - __u64 k_offset:60; - __u64 k_type: 4; +#ifdef __LITTLE_ENDIAN + /* little endian version */ + __u64 k_offset:60; + __u64 k_type: 4; +#else + /* big endian version */ + __u64 k_type: 4; + __u64 k_offset:60; +#endif } __attribute__ ((__packed__)); +#ifndef __LITTLE_ENDIAN +typedef union { + struct offset_v2 offset_v2; + __u64 linear; +} __attribute__ ((__packed__)) offset_v2_esafe_overlay; + +static inline __u16 offset_v2_k_type( struct offset_v2 *v2 ) +{ + offset_v2_esafe_overlay tmp = *(offset_v2_esafe_overlay *)v2; + tmp.linear = le64_to_cpu( tmp.linear ); + return tmp.offset_v2.k_type; +} + +static inline void set_offset_v2_k_type( struct offset_v2 *v2, int type ) +{ + offset_v2_esafe_overlay *tmp = (offset_v2_esafe_overlay *)v2; + tmp->linear = le64_to_cpu(tmp->linear); + tmp->offset_v2.k_type = type; + tmp->linear = le64_to_cpu(tmp->linear); +} + +static inline loff_t offset_v2_k_offset( struct offset_v2 *v2 ) +{ + offset_v2_esafe_overlay tmp = *(offset_v2_esafe_overlay *)v2; + tmp.linear = le64_to_cpu( tmp.linear ); + return tmp.offset_v2.k_offset; +} +static inline void set_offset_v2_k_offset( struct offset_v2 *v2, loff_t offset ){ + offset_v2_esafe_overlay *tmp = (offset_v2_esafe_overlay *)v2; + tmp->linear = le64_to_cpu(tmp->linear); + tmp->offset_v2.k_offset = offset; + tmp->linear = le64_to_cpu(tmp->linear); +} +#else +# define offset_v2_k_type(v2) ((v2)->k_type) +# define set_offset_v2_k_type(v2,val) (offset_v2_k_type(v2) = (val)) +# define offset_v2_k_offset(v2) ((v2)->k_offset) +# define set_offset_v2_k_offset(v2,val) (offset_v2_k_offset(v2) = (val)) +#endif /* Key of an item determines its location in the S+tree, and is composed of 4 components */ @@ -387,8 +434,8 @@ struct item_head __u16 ih_entry_count; /* Iff this is a directory item, this field equals the number of directory entries in the directory item. */ } __attribute__ ((__packed__)) u; - __u16 ih_item_len; /* total size of the item body */ - __u16 ih_item_location; /* an offset to the item body within the block */ + __u16 ih_item_len; /* total size of the item body */ + __u16 ih_item_location; /* an offset to the item body within the block */ /* I thought we were going to use this for having lots of item types? Why don't you use this for item type @@ -423,11 +470,19 @@ struct item_head // FIXME: now would that work for other than i386 archs -#define unreachable_item(ih) (ih->ih_version & (1 << 15)) +#define unreachable_item(ih) (ih_version(ih) & (1 << 15)) #define get_ih_free_space(ih) (ih_version (ih) == ITEM_VERSION_2 ? 0 : ih_free_space (ih)) #define set_ih_free_space(ih,val) put_ih_free_space((ih), ((ih_version(ih) == ITEM_VERSION_2) ? 0 : (val))) +/* these operate on indirect items, where you've got an array of ints +** at a possibly unaligned location. These are a noop on ia32 +** +** p is the array of __u32, i is the index into the array, v is the value +** to store there. +*/ +#define get_block_num(p, i) le32_to_cpu(get_unaligned((p) + (i))) +#define put_block_num(p, i, v) put_unaligned(cpu_to_le32(v), (p) + (i)) // // there are 5 item types currently @@ -490,8 +545,9 @@ static inline __u32 type2uniqueness (int type) // static inline loff_t le_key_k_offset (int version, struct key * key) { - return (version == ITEM_VERSION_1) ? key->u.k_offset_v1.k_offset : - le64_to_cpu (key->u.k_offset_v2.k_offset); + return (version == ITEM_VERSION_1) ? + le32_to_cpu( key->u.k_offset_v1.k_offset ) : + offset_v2_k_offset( &(key->u.k_offset_v2) ); } static inline loff_t le_ih_k_offset (struct item_head * ih) { @@ -501,8 +557,9 @@ static inline loff_t le_ih_k_offset (struct item_head * ih) static inline loff_t le_key_k_type (int version, struct key * key) { - return (version == ITEM_VERSION_1) ? uniqueness2type (key->u.k_offset_v1.k_uniqueness) : - le16_to_cpu (key->u.k_offset_v2.k_type); + return (version == ITEM_VERSION_1) ? + uniqueness2type( le32_to_cpu( key->u.k_offset_v1.k_uniqueness)) : + offset_v2_k_type( &(key->u.k_offset_v2) ); } static inline loff_t le_ih_k_type (struct item_head * ih) { @@ -512,8 +569,9 @@ static inline loff_t le_ih_k_type (struct item_head * ih) static inline void set_le_key_k_offset (int version, struct key * key, loff_t offset) { - (version == ITEM_VERSION_1) ? (key->u.k_offset_v1.k_offset = offset) : - (key->u.k_offset_v2.k_offset = cpu_to_le64 (offset)); + (version == ITEM_VERSION_1) ? + (key->u.k_offset_v1.k_offset = cpu_to_le32 (offset)) : /* jdm check */ + (set_offset_v2_k_offset( &(key->u.k_offset_v2), offset )); } static inline void set_le_ih_k_offset (struct item_head * ih, loff_t offset) { @@ -524,8 +582,9 @@ static inline void set_le_ih_k_offset (struct item_head * ih, loff_t offset) static inline void set_le_key_k_type (int version, struct key * key, int type) { - (version == ITEM_VERSION_1) ? (key->u.k_offset_v1.k_uniqueness = type2uniqueness (type)) : - (key->u.k_offset_v2.k_type = cpu_to_le16 (type)); + (version == ITEM_VERSION_1) ? + (key->u.k_offset_v1.k_uniqueness = cpu_to_le32(type2uniqueness(type))): + (set_offset_v2_k_type( &(key->u.k_offset_v2), type )); } static inline void set_le_ih_k_type (struct item_head * ih, int type) { @@ -553,26 +612,30 @@ static inline void set_le_ih_k_type (struct item_head * ih, int type) // static inline loff_t cpu_key_k_offset (struct cpu_key * key) { - return (key->version == ITEM_VERSION_1) ? key->on_disk_key.u.k_offset_v1.k_offset : + return (key->version == ITEM_VERSION_1) ? + key->on_disk_key.u.k_offset_v1.k_offset : key->on_disk_key.u.k_offset_v2.k_offset; } static inline loff_t cpu_key_k_type (struct cpu_key * key) { - return (key->version == ITEM_VERSION_1) ? uniqueness2type (key->on_disk_key.u.k_offset_v1.k_uniqueness) : + return (key->version == ITEM_VERSION_1) ? + uniqueness2type (key->on_disk_key.u.k_offset_v1.k_uniqueness) : key->on_disk_key.u.k_offset_v2.k_type; } static inline void set_cpu_key_k_offset (struct cpu_key * key, loff_t offset) { - (key->version == ITEM_VERSION_1) ? (key->on_disk_key.u.k_offset_v1.k_offset = offset) : + (key->version == ITEM_VERSION_1) ? + (key->on_disk_key.u.k_offset_v1.k_offset = offset) : (key->on_disk_key.u.k_offset_v2.k_offset = offset); } static inline void set_cpu_key_k_type (struct cpu_key * key, int type) { - (key->version == ITEM_VERSION_1) ? (key->on_disk_key.u.k_offset_v1.k_uniqueness = type2uniqueness (type)) : + (key->version == ITEM_VERSION_1) ? + (key->on_disk_key.u.k_offset_v1.k_uniqueness = type2uniqueness (type)): (key->on_disk_key.u.k_offset_v2.k_type = type); } @@ -638,7 +701,17 @@ struct block_head { struct key blk_right_delim_key; /* kept only for compatibility */ }; -#define BLKH_SIZE (sizeof(struct block_head)) +#define BLKH_SIZE (sizeof(struct block_head)) +#define blkh_level(p_blkh) (le16_to_cpu((p_blkh)->blk_level)) +#define blkh_nr_item(p_blkh) (le16_to_cpu((p_blkh)->blk_nr_item)) +#define blkh_free_space(p_blkh) (le16_to_cpu((p_blkh)->blk_free_space)) +#define blkh_reserved(p_blkh) (le16_to_cpu((p_blkh)->blk_reserved)) +#define set_blkh_level(p_blkh,val) ((p_blkh)->blk_level = cpu_to_le16(val)) +#define set_blkh_nr_item(p_blkh,val) ((p_blkh)->blk_nr_item = cpu_to_le16(val)) +#define set_blkh_free_space(p_blkh,val) ((p_blkh)->blk_free_space = cpu_to_le16(val)) +#define set_blkh_reserved(p_blkh,val) ((p_blkh)->blk_reserved = cpu_to_le16(val)) +#define blkh_right_delim_key(p_blkh) ((p_blkh)->blk_right_delim_key) +#define set_blkh_right_delim_key(p_blkh,val) ((p_blkh)->blk_right_delim_key = val) /* * values for blk_level field of the struct block_head @@ -652,25 +725,26 @@ struct block_head { #define DISK_LEAF_NODE_LEVEL 1 /* Leaf node level.*/ /* Given the buffer head of a formatted node, resolve to the block head of that node. */ -#define B_BLK_HEAD(p_s_bh) ((struct block_head *)((p_s_bh)->b_data)) +#define B_BLK_HEAD(p_s_bh) ((struct block_head *)((p_s_bh)->b_data)) /* Number of items that are in buffer. */ -#define B_NR_ITEMS(p_s_bh) (le16_to_cpu ( B_BLK_HEAD(p_s_bh)->blk_nr_item )) -#define B_LEVEL(bh) (le16_to_cpu ( B_BLK_HEAD(bh)->blk_level )) -#define B_FREE_SPACE(bh) (le16_to_cpu ( B_BLK_HEAD(bh)->blk_free_space )) +#define B_NR_ITEMS(p_s_bh) (blkh_nr_item(B_BLK_HEAD(p_s_bh))) +#define B_LEVEL(p_s_bh) (blkh_level(B_BLK_HEAD(p_s_bh))) +#define B_FREE_SPACE(p_s_bh) (blkh_free_space(B_BLK_HEAD(p_s_bh))) + +#define PUT_B_NR_ITEMS(p_s_bh,val) do { set_blkh_nr_item(B_BLK_HEAD(p_s_bh),val); } while (0) +#define PUT_B_LEVEL(p_s_bh,val) do { set_blkh_level(B_BLK_HEAD(p_s_bh),val); } while (0) +#define PUT_B_FREE_SPACE(p_s_bh,val) do { set_blkh_free_space(B_BLK_HEAD(p_s_bh),val); } while (0) -#define PUT_B_NR_ITEMS(p_s_bh) do { B_BLK_HEAD(p_s_bh)->blk_nr_item = cpu_to_le16(val); } while (0) -#define PUT_B_LEVEL(bh, val) do { B_BLK_HEAD(bh)->blk_level = cpu_to_le16(val); } while (0) -#define PUT_B_FREE_SPACE(bh) do { B_BLK_HEAD(bh)->blk_free_space = cpu_to_le16(val); } while (0) -/* Get right delimiting key. */ -#define B_PRIGHT_DELIM_KEY(p_s_bh) ( &(B_BLK_HEAD(p_s_bh)->blk_right_delim_key) ) +/* Get right delimiting key. -- little endian */ +#define B_PRIGHT_DELIM_KEY(p_s_bh) (&(blk_right_delim_key(B_BLK_HEAD(p_s_bh)) /* Does the buffer contain a disk leaf. */ -#define B_IS_ITEMS_LEVEL(p_s_bh) ( B_BLK_HEAD(p_s_bh)->blk_level == DISK_LEAF_NODE_LEVEL ) +#define B_IS_ITEMS_LEVEL(p_s_bh) (B_LEVEL(p_s_bh) == DISK_LEAF_NODE_LEVEL) /* Does the buffer contain a disk internal node */ -#define B_IS_KEYS_LEVEL(p_s_bh) ( B_BLK_HEAD(p_s_bh)->blk_level > DISK_LEAF_NODE_LEVEL &&\ - B_BLK_HEAD(p_s_bh)->blk_level <= MAX_HEIGHT ) +#define B_IS_KEYS_LEVEL(p_s_bh) (B_LEVEL(p_s_bh) > DISK_LEAF_NODE_LEVEL \ + && B_LEVEL(p_s_bh) <= MAX_HEIGHT) @@ -709,8 +783,32 @@ struct stat_data_v1 policy. Someday. -Hans */ } __attribute__ ((__packed__)); -#define SD_V1_SIZE (sizeof(struct stat_data_v1)) - +#define SD_V1_SIZE (sizeof(struct stat_data_v1)) +#define stat_data_v1(ih) (ih_version (ih) == ITEM_VERSION_1) +#define sd_v1_mode(sdp) (le16_to_cpu((sdp)->sd_mode)) +#define set_sd_v1_mode(sdp,v) ((sdp)->sd_mode = cpu_to_le16(v)) +#define sd_v1_nlink(sdp) (le16_to_cpu((sdp)->sd_nlink)) +#define set_sd_v1_nlink(sdp,v) ((sdp)->sd_nlink = cpu_to_le16(v)) +#define sd_v1_uid(sdp) (le16_to_cpu((sdp)->sd_uid)) +#define set_sd_v1_uid(sdp,v) ((sdp)->sd_uid = cpu_to_le16(v)) +#define sd_v1_gid(sdp) (le16_to_cpu((sdp)->sd_gid)) +#define set_sd_v1_gid(sdp,v) ((sdp)->sd_gid = cpu_to_le16(v)) +#define sd_v1_size(sdp) (le32_to_cpu((sdp)->sd_size)) +#define set_sd_v1_size(sdp,v) ((sdp)->sd_size = cpu_to_le32(v)) +#define sd_v1_atime(sdp) (le32_to_cpu((sdp)->sd_atime)) +#define set_sd_v1_atime(sdp,v) ((sdp)->sd_atime = cpu_to_le32(v)) +#define sd_v1_mtime(sdp) (le32_to_cpu((sdp)->sd_mtime)) +#define set_sd_v1_mtime(sdp,v) ((sdp)->sd_mtime = cpu_to_le32(v)) +#define sd_v1_ctime(sdp) (le32_to_cpu((sdp)->sd_ctime)) +#define set_sd_v1_ctime(sdp,v) ((sdp)->sd_ctime = cpu_to_le32(v)) +#define sd_v1_rdev(sdp) (le32_to_cpu((sdp)->u.sd_rdev)) +#define set_sd_v1_rdev(sdp,v) ((sdp)->u.sd_rdev = cpu_to_le32(v)) +#define sd_v1_blocks(sdp) (le32_to_cpu((sdp)->u.sd_blocks)) +#define set_sd_v1_blocks(sdp,v) ((sdp)->u.sd_blocks = cpu_to_le32(v)) +#define sd_v1_first_direct_byte(sdp) \ + (le32_to_cpu((sdp)->sd_first_direct_byte)) +#define set_sd_v1_first_direct_byte(sdp,v) \ + ((sdp)->sd_first_direct_byte = cpu_to_le32(v)) /* Stat Data on disk (reiserfs version of UFS disk inode minus the address blocks) */ @@ -743,8 +841,32 @@ struct stat_data { // this is 40 bytes long // #define SD_SIZE (sizeof(struct stat_data)) - -#define stat_data_v1(ih) (ih_version (ih) == ITEM_VERSION_1) +#define SD_V2_SIZE SD_SIZE +#define stat_data_v2(ih) (ih_version (ih) == ITEM_VERSION_2) +#define sd_v2_mode(sdp) (le16_to_cpu((sdp)->sd_mode)) +#define set_sd_v2_mode(sdp,v) ((sdp)->sd_mode = cpu_to_le16(v)) +/* sd_reserved */ +/* set_sd_reserved */ +#define sd_v2_nlink(sdp) (le32_to_cpu((sdp)->sd_nlink)) +#define set_sd_v2_nlink(sdp,v) ((sdp)->sd_nlink = cpu_to_le32(v)) +#define sd_v2_size(sdp) (le64_to_cpu((sdp)->sd_size)) +#define set_sd_v2_size(sdp,v) ((sdp)->sd_size = cpu_to_le64(v)) +#define sd_v2_uid(sdp) (le32_to_cpu((sdp)->sd_uid)) +#define set_sd_v2_uid(sdp,v) ((sdp)->sd_uid = cpu_to_le32(v)) +#define sd_v2_gid(sdp) (le32_to_cpu((sdp)->sd_gid)) +#define set_sd_v2_gid(sdp,v) ((sdp)->sd_gid = cpu_to_le32(v)) +#define sd_v2_atime(sdp) (le32_to_cpu((sdp)->sd_atime)) +#define set_sd_v2_atime(sdp,v) ((sdp)->sd_atime = cpu_to_le32(v)) +#define sd_v2_mtime(sdp) (le32_to_cpu((sdp)->sd_mtime)) +#define set_sd_v2_mtime(sdp,v) ((sdp)->sd_mtime = cpu_to_le32(v)) +#define sd_v2_ctime(sdp) (le32_to_cpu((sdp)->sd_ctime)) +#define set_sd_v2_ctime(sdp,v) ((sdp)->sd_ctime = cpu_to_le32(v)) +#define sd_v2_blocks(sdp) (le32_to_cpu((sdp)->sd_blocks)) +#define set_sd_v2_blocks(sdp,v) ((sdp)->sd_blocks = cpu_to_le32(v)) +#define sd_v2_rdev(sdp) (le32_to_cpu((sdp)->u.sd_rdev)) +#define set_sd_v2_rdev(sdp,v) ((sdp)->u.sd_rdev = cpu_to_le32(v)) +#define sd_v2_generation(sdp) (le32_to_cpu((sdp)->u.sd_generation)) +#define set_sd_v2_generation(sdp,v) ((sdp)->u.sd_generation = cpu_to_le32(v)) /***************************************************************************/ @@ -793,7 +915,18 @@ struct reiserfs_de_head __u16 deh_state; /* whether 1) entry contains stat data (for future), and 2) whether entry is hidden (unlinked) */ } __attribute__ ((__packed__)); -#define DEH_SIZE sizeof(struct reiserfs_de_head) +#define DEH_SIZE sizeof(struct reiserfs_de_head) +#define deh_offset(p_deh) (le32_to_cpu((p_deh)->deh_offset)) +#define deh_dir_id(p_deh) (le32_to_cpu((p_deh)->deh_dir_id)) +#define deh_objectid(p_deh) (le32_to_cpu((p_deh)->deh_objectid)) +#define deh_location(p_deh) (le16_to_cpu((p_deh)->deh_location)) +#define deh_state(p_deh) (le16_to_cpu((p_deh)->deh_state)) + +#define put_deh_offset(p_deh,v) ((p_deh)->deh_offset = cpu_to_le32((v))) +#define put_deh_dir_id(p_deh,v) ((p_deh)->deh_dir_id = cpu_to_le32((v))) +#define put_deh_objectid(p_deh,v) ((p_deh)->deh_objectid = cpu_to_le32((v))) +#define put_deh_location(p_deh,v) ((p_deh)->deh_location = cpu_to_le16((v))) +#define put_deh_state(p_deh,v) ((p_deh)->deh_state = cpu_to_le16((v))) /* empty directory contains two entries "." and ".." and their headers */ #define EMPTY_DIR_SIZE \ @@ -805,34 +938,31 @@ struct reiserfs_de_head #define DEH_Statdata 0 /* not used now */ #define DEH_Visible 2 -/* bitops which deals with unaligned addrs; - needed for alpha port. --zam */ -#ifdef __alpha__ -# define ADDR_UNALIGNED_BITS (5) +/* 64 bit systems (and the S/390) need to be aligned explicitly -jdm */ +#if BITS_PER_LONG == 64 || defined(__s390__) || defined(__hppa__) +# define ADDR_UNALIGNED_BITS (3) #endif +/* These are only used to manipulate deh_state. + * Because of this, we'll use the ext2_ bit routines, + * since they are little endian */ #ifdef ADDR_UNALIGNED_BITS # define aligned_address(addr) ((void *)((long)(addr) & ~((1UL << ADDR_UNALIGNED_BITS) - 1))) # define unaligned_offset(addr) (((int)((long)(addr) & ((1 << ADDR_UNALIGNED_BITS) - 1))) << 3) -# define set_bit_unaligned(nr, addr) set_bit((nr) + unaligned_offset(addr), aligned_address(addr)) -# define clear_bit_unaligned(nr, addr) clear_bit((nr) + unaligned_offset(addr), aligned_address(addr)) -# define test_bit_unaligned(nr, addr) test_bit((nr) + unaligned_offset(addr), aligned_address(addr)) +# define set_bit_unaligned(nr, addr) ext2_set_bit((nr) + unaligned_offset(addr), aligned_address(addr)) +# define clear_bit_unaligned(nr, addr) ext2_clear_bit((nr) + unaligned_offset(addr), aligned_address(addr)) +# define test_bit_unaligned(nr, addr) ext2_test_bit((nr) + unaligned_offset(addr), aligned_address(addr)) #else -# define set_bit_unaligned(nr, addr) set_bit(nr, addr) -# define clear_bit_unaligned(nr, addr) clear_bit(nr, addr) -# define test_bit_unaligned(nr, addr) test_bit(nr, addr) +# define set_bit_unaligned(nr, addr) ext2_set_bit(nr, addr) +# define clear_bit_unaligned(nr, addr) ext2_clear_bit(nr, addr) +# define test_bit_unaligned(nr, addr) ext2_test_bit(nr, addr) #endif -#define deh_dir_id(deh) (__le32_to_cpu ((deh)->deh_dir_id)) -#define deh_objectid(deh) (__le32_to_cpu ((deh)->deh_objectid)) -#define deh_offset(deh) (__le32_to_cpu ((deh)->deh_offset)) - - #define mark_de_with_sd(deh) set_bit_unaligned (DEH_Statdata, &((deh)->deh_state)) #define mark_de_without_sd(deh) clear_bit_unaligned (DEH_Statdata, &((deh)->deh_state)) #define mark_de_visible(deh) set_bit_unaligned (DEH_Visible, &((deh)->deh_state)) @@ -844,7 +974,9 @@ struct reiserfs_de_head /* compose directory item containing "." and ".." entries (entries are not aligned to 4 byte boundary) */ -static inline void make_empty_dir_item_v1 (char * body, __u32 dirid, __u32 objid, +/* the last four params are LE */ +static inline void make_empty_dir_item_v1 (char * body, + __u32 dirid, __u32 objid, __u32 par_dirid, __u32 par_objid) { struct reiserfs_de_head * deh; @@ -853,29 +985,32 @@ static inline void make_empty_dir_item_v1 (char * body, __u32 dirid, __u32 objid deh = (struct reiserfs_de_head *)body; /* direntry header of "." */ - deh[0].deh_offset = cpu_to_le32 (DOT_OFFSET); - deh[0].deh_dir_id = cpu_to_le32 (dirid); - deh[0].deh_objectid = cpu_to_le32 (objid); - deh[0].deh_location = cpu_to_le16 (EMPTY_DIR_SIZE_V1 - strlen (".")); - deh[0].deh_state = 0; + put_deh_offset( &(deh[0]), DOT_OFFSET ); + /* these two are from make_le_item_head, and are are LE */ + deh[0].deh_dir_id = dirid; + deh[0].deh_objectid = objid; + deh[0].deh_state = 0; /* Endian safe if 0 */ + put_deh_location( &(deh[0]), EMPTY_DIR_SIZE_V1 - strlen( "." )); mark_de_visible(&(deh[0])); /* direntry header of ".." */ - deh[1].deh_offset = cpu_to_le32 (DOT_DOT_OFFSET); + put_deh_offset( &(deh[1]), DOT_DOT_OFFSET); /* key of ".." for the root directory */ - deh[1].deh_dir_id = cpu_to_le32 (par_dirid); - deh[1].deh_objectid = cpu_to_le32 (par_objid); - deh[1].deh_location = cpu_to_le16 (le16_to_cpu (deh[0].deh_location) - strlen ("..")); - deh[1].deh_state = 0; + /* these two are from the inode, and are are LE */ + deh[1].deh_dir_id = par_dirid; + deh[1].deh_objectid = par_objid; + deh[1].deh_state = 0; /* Endian safe if 0 */ + put_deh_location( &(deh[1]), deh_location( &(deh[0]) ) - strlen( ".." ) ); mark_de_visible(&(deh[1])); /* copy ".." and "." */ - memcpy (body + deh[0].deh_location, ".", 1); - memcpy (body + deh[1].deh_location, "..", 2); + memcpy (body + deh_location( &(deh[0]) ), ".", 1); + memcpy (body + deh_location( &(deh[1]) ), "..", 2); } /* compose directory item containing "." and ".." entries */ -static inline void make_empty_dir_item (char * body, __u32 dirid, __u32 objid, +static inline void make_empty_dir_item (char * body, + __u32 dirid, __u32 objid, __u32 par_dirid, __u32 par_objid) { struct reiserfs_de_head * deh; @@ -884,31 +1019,33 @@ static inline void make_empty_dir_item (char * body, __u32 dirid, __u32 objid, deh = (struct reiserfs_de_head *)body; /* direntry header of "." */ - deh[0].deh_offset = cpu_to_le32 (DOT_OFFSET); - deh[0].deh_dir_id = cpu_to_le32 (dirid); - deh[0].deh_objectid = cpu_to_le32 (objid); - deh[0].deh_location = cpu_to_le16 (EMPTY_DIR_SIZE - ROUND_UP (strlen ("."))); - deh[0].deh_state = 0; + put_deh_offset( &(deh[0]), DOT_OFFSET ); + /* these two are from make_le_item_head, and are are LE */ + deh[0].deh_dir_id = dirid; + deh[0].deh_objectid = objid; + deh[0].deh_state = 0; /* Endian safe if 0 */ + put_deh_location( &(deh[0]), EMPTY_DIR_SIZE - ROUND_UP( strlen( "." ) ) ); mark_de_visible(&(deh[0])); /* direntry header of ".." */ - deh[1].deh_offset = cpu_to_le32 (DOT_DOT_OFFSET); + put_deh_offset( &(deh[1]), DOT_DOT_OFFSET ); /* key of ".." for the root directory */ - deh[1].deh_dir_id = cpu_to_le32 (par_dirid); - deh[1].deh_objectid = cpu_to_le32 (par_objid); - deh[1].deh_location = cpu_to_le16 (le16_to_cpu (deh[0].deh_location) - ROUND_UP (strlen (".."))); - deh[1].deh_state = 0; + /* these two are from the inode, and are are LE */ + deh[1].deh_dir_id = par_dirid; + deh[1].deh_objectid = par_objid; + deh[1].deh_state = 0; /* Endian safe if 0 */ + put_deh_location( &(deh[1]), deh_location( &(deh[0])) - ROUND_UP( strlen( ".." ) ) ); mark_de_visible(&(deh[1])); /* copy ".." and "." */ - memcpy (body + deh[0].deh_location, ".", 1); - memcpy (body + deh[1].deh_location, "..", 2); + memcpy (body + deh_location( &(deh[0]) ), ".", 1); + memcpy (body + deh_location( &(deh[1]) ), "..", 2); } /* array of the entry headers */ /* get item body */ -#define B_I_PITEM(bh,ih) ( (bh)->b_data + (ih)->ih_item_location ) +#define B_I_PITEM(bh,ih) ( (bh)->b_data + ih_location(ih) ) #define B_I_DEH(bh,ih) ((struct reiserfs_de_head *)(B_I_PITEM(bh,ih))) /* length of the directory entry in directory item. This define @@ -919,7 +1056,7 @@ static inline void make_empty_dir_item (char * body, __u32 dirid, __u32 objid, See picture above.*/ /* #define I_DEH_N_ENTRY_LENGTH(ih,deh,i) \ -((i) ? (((deh)-1)->deh_location - (deh)->deh_location) : ((ih)->ih_item_len) - (deh)->deh_location) +((i) ? (deh_location((deh)-1) - deh_location((deh))) : (ih_item_len((ih)) - deh_location((deh)))) */ static inline int entry_length (struct buffer_head * bh, struct item_head * ih, int pos_in_item) @@ -928,18 +1065,19 @@ static inline int entry_length (struct buffer_head * bh, struct item_head * ih, deh = B_I_DEH (bh, ih) + pos_in_item; if (pos_in_item) - return (le16_to_cpu ((deh - 1)->deh_location) - le16_to_cpu (deh->deh_location)); - return (le16_to_cpu (ih->ih_item_len) - le16_to_cpu (deh->deh_location)); + return deh_location(deh-1) - deh_location(deh); + + return ih_item_len(ih) - deh_location(deh); } /* number of entries in the directory item, depends on ENTRY_COUNT being at the start of directory dynamic data. */ -#define I_ENTRY_COUNT(ih) ((ih)->u.ih_entry_count) +#define I_ENTRY_COUNT(ih) (ih_entry_count((ih))) /* name by bh, ih and entry_num */ -#define B_I_E_NAME(bh,ih,entry_num) ((char *)(bh->b_data + ih->ih_item_location + (B_I_DEH(bh,ih)+(entry_num))->deh_location)) +#define B_I_E_NAME(bh,ih,entry_num) ((char *)(bh->b_data + ih_location(ih) + deh_location(B_I_DEH(bh,ih)+(entry_num)))) // two entries per block (at least) //#define REISERFS_MAX_NAME_LEN(block_size) @@ -976,7 +1114,7 @@ struct reiserfs_dir_entry /* these defines are useful when a particular member of a reiserfs_dir_entry is needed */ /* pointer to file name, stored in entry */ -#define B_I_DEH_ENTRY_FILE_NAME(bh,ih,deh) (B_I_PITEM (bh, ih) + (deh)->deh_location) +#define B_I_DEH_ENTRY_FILE_NAME(bh,ih,deh) (B_I_PITEM (bh, ih) + deh_location(deh)) /* length of name */ #define I_DEH_N_ENTRY_FILE_NAME_LENGTH(ih,deh,entry_num) \ @@ -1014,14 +1152,18 @@ struct disk_child { }; #define DC_SIZE (sizeof(struct disk_child)) +#define dc_block_number(dc_p) (le32_to_cpu((dc_p)->dc_block_number)) +#define dc_size(dc_p) (le16_to_cpu((dc_p)->dc_size)) +#define put_dc_block_number(dc_p, val) do { (dc_p)->dc_block_number = cpu_to_le32(val); } while(0) +#define put_dc_size(dc_p, val) do { (dc_p)->dc_size = cpu_to_le16(val); } while(0) /* Get disk child by buffer header and position in the tree node. */ #define B_N_CHILD(p_s_bh,n_pos) ((struct disk_child *)\ ((p_s_bh)->b_data+BLKH_SIZE+B_NR_ITEMS(p_s_bh)*KEY_SIZE+DC_SIZE*(n_pos))) /* Get disk child number by buffer header and position in the tree node. */ -#define B_N_CHILD_NUM(p_s_bh,n_pos) (le32_to_cpu (B_N_CHILD(p_s_bh,n_pos)->dc_block_number)) -#define PUT_B_N_CHILD_NUM(p_s_bh,n_pos, val) do { B_N_CHILD(p_s_bh,n_pos)->dc_block_number = cpu_to_le32(val); } while (0) +#define B_N_CHILD_NUM(p_s_bh,n_pos) (dc_block_number(B_N_CHILD(p_s_bh,n_pos))) +#define PUT_B_N_CHILD_NUM(p_s_bh,n_pos, val) (put_dc_block_number(B_N_CHILD(p_s_bh,n_pos), val )) /* maximal value of field child_size in structure disk_child */ /* child size is the combined size of all items and their headers */ @@ -1459,10 +1601,10 @@ extern struct item_operations * item_ops [4]; /* number of blocks pointed to by the indirect item */ -#define I_UNFM_NUM(p_s_ih) ( (p_s_ih)->ih_item_len / UNFM_P_SIZE ) +#define I_UNFM_NUM(p_s_ih) ( ih_item_len(p_s_ih) / UNFM_P_SIZE ) /* the used space within the unformatted node corresponding to pos within the item pointed to by ih */ -#define I_POS_UNFM_SIZE(ih,pos,size) (((pos) == I_UNFM_NUM(ih) - 1 ) ? (size) - (ih)->u.ih_free_space : (size)) +#define I_POS_UNFM_SIZE(ih,pos,size) (((pos) == I_UNFM_NUM(ih) - 1 ) ? (size) - ih_free_space(ih) : (size)) /* number of bytes contained by the direct item or the unformatted nodes the indirect item points to */ @@ -1477,16 +1619,16 @@ extern struct item_operations * item_ops [4]; #define B_N_PKEY(bh,item_num) ( &(B_N_PITEM_HEAD(bh,item_num)->ih_key) ) /* get item body */ -#define B_N_PITEM(bh,item_num) ( (bh)->b_data + B_N_PITEM_HEAD((bh),(item_num))->ih_item_location) +#define B_N_PITEM(bh,item_num) ( (bh)->b_data + ih_location(B_N_PITEM_HEAD((bh),(item_num)))) /* get the stat data by the buffer header and the item order */ #define B_N_STAT_DATA(bh,nr) \ -( (struct stat_data *)((bh)->b_data+B_N_PITEM_HEAD((bh),(nr))->ih_item_location ) ) +( (struct stat_data *)((bh)->b_data + ih_location(B_N_PITEM_HEAD((bh),(nr))) ) ) - /* following defines use reiserfs buffer header and item header */ + /* following defines use reiserfs buffer header and item header */ /* get stat-data */ -#define B_I_STAT_DATA(bh, ih) ( (struct stat_data * )((bh)->b_data + (ih)->ih_item_location) ) +#define B_I_STAT_DATA(bh, ih) ( (struct stat_data * )((bh)->b_data + ih_location(ih)) ) // this is 3976 for size==4096 #define MAX_DIRECT_ITEM_LEN(size) ((size) - BLKH_SIZE - 2*IH_SIZE - SD_SIZE - UNFM_P_SIZE) @@ -1494,7 +1636,7 @@ extern struct item_operations * item_ops [4]; /* indirect items consist of entries which contain blocknrs, pos indicates which entry, and B_I_POS_UNFM_POINTER resolves to the blocknr contained by the entry pos points to */ -#define B_I_POS_UNFM_POINTER(bh,ih,pos) (*(((unp_t *)B_I_PITEM(bh,ih)) + (pos))) +#define B_I_POS_UNFM_POINTER(bh,ih,pos) le32_to_cpu(*(((unp_t *)B_I_PITEM(bh,ih)) + (pos))) #define PUT_B_I_POS_UNFM_POINTER(bh,ih,pos, val) do {*(((unp_t *)B_I_PITEM(bh,ih)) + (pos)) = cpu_to_le32(val); } while (0) /* Reiserfs buffer cache statistics. */ @@ -1596,6 +1738,8 @@ extern wait_queue_head_t reiserfs_commit_thread_wait ; */ #define JOURNAL_BUFFER(j,n) ((j)->j_ap_blocks[((j)->j_start + (n)) % JOURNAL_BLOCK_COUNT]) +void reiserfs_commit_for_inode(struct inode *) ; +void reiserfs_update_inode_transaction(struct inode *) ; void reiserfs_wait_on_write_block(struct super_block *s) ; void reiserfs_block_writes(struct reiserfs_transaction_handle *th) ; void reiserfs_allow_writes(struct super_block *s) ; @@ -1692,7 +1836,7 @@ static inline int le_key_version (struct key * key) { int type; - type = le16_to_cpu (key->u.k_offset_v2.k_type); + type = offset_v2_k_type( &(key->u.k_offset_v2)); if (type != TYPE_DIRECT && type != TYPE_INDIRECT && type != TYPE_DIRENTRY) return ITEM_VERSION_1; @@ -1943,9 +2087,9 @@ void reiserfs_discard_all_prealloc (struct reiserfs_transaction_handle *th); #endif /* hashes.c */ -__u32 keyed_hash (const char *msg, int len); -__u32 yura_hash (const char *msg, int len); -__u32 r5_hash (const char *msg, int len); +__u32 keyed_hash (const signed char *msg, int len); +__u32 yura_hash (const signed char *msg, int len); +__u32 r5_hash (const signed char *msg, int len); /* version.c */ char *reiserfs_get_version_string(void) ; diff --git a/include/linux/reiserfs_fs_i.h b/include/linux/reiserfs_fs_i.h index a43342f84d56..08445c12024c 100644 --- a/include/linux/reiserfs_fs_i.h +++ b/include/linux/reiserfs_fs_i.h @@ -40,6 +40,12 @@ struct reiserfs_inode_info { is a comment you should make.... -Hans */ //nopack-attribute int nopack; + + /* we use these for fsync or O_SYNC to decide which transaction needs + ** to be committed in order for this inode to be properly flushed + */ + unsigned long i_trans_id ; + unsigned long i_trans_index ; }; diff --git a/include/linux/reiserfs_fs_sb.h b/include/linux/reiserfs_fs_sb.h index 6e203657bfc7..ffd16a92c8f0 100644 --- a/include/linux/reiserfs_fs_sb.h +++ b/include/linux/reiserfs_fs_sb.h @@ -65,6 +65,57 @@ struct reiserfs_super_block } __attribute__ ((__packed__)); #define SB_SIZE (sizeof(struct reiserfs_super_block)) +/* struct reiserfs_super_block accessors/mutators + * since this is a disk structure, it will always be in + * little endian format. */ +#define sb_block_count(sbp) (le32_to_cpu((sbp)->s_block_count)) +#define set_sb_block_count(sbp,v) ((sbp)->s_block_count = cpu_to_le32(v)) +#define sb_free_blocks(sbp) (le32_to_cpu((sbp)->s_free_blocks)) +#define set_sb_free_blocks(sbp,v) ((sbp)->s_free_blocks = cpu_to_le32(v)) +#define sb_root_block(sbp) (le32_to_cpu((sbp)->s_root_block)) +#define set_sb_root_block(sbp,v) ((sbp)->s_root_block = cpu_to_le32(v)) +#define sb_journal_block(sbp) (le32_to_cpu((sbp)->s_journal_block)) +#define set_sb_journal_block(sbp,v) ((sbp)->s_journal_block = cpu_to_le32(v)) +#define sb_journal_dev(sbp) (le32_to_cpu((sbp)->s_journal_dev)) +#define set_sb_journal_dev(sbp,v) ((sbp)->s_journal_dev = cpu_to_le32(v)) +#define sb_orig_journal_size(sbp) (le32_to_cpu((sbp)->s_orig_journal_size)) +#define set_sb_orig_journal_size(sbp,v) \ + ((sbp)->s_orig_journal_size = cpu_to_le32(v)) +#define sb_journal_trans_max(sbp) (le32_to_cpu((sbp)->s_journal_trans_max)) +#define set_journal_trans_max(sbp,v) \ + ((sbp)->s_journal_trans_max = cpu_to_le32(v)) +#define sb_journal_block_count(sbp) (le32_to_cpu((sbp)->journal_block_count)) +#define sb_set_journal_block_count(sbp,v) \ + ((sbp)->s_journal_block_count = cpu_to_le32(v)) +#define sb_journal_max_batch(sbp) (le32_to_cpu((sbp)->s_journal_max_batch)) +#define set_sb_journal_max_batch(sbp,v) \ + ((sbp)->s_journal_max_batch = cpu_to_le32(v)) +#define sb_jourmal_max_commit_age(sbp) \ + (le32_to_cpu((sbp)->s_journal_max_commit_age)) +#define set_sb_journal_max_commit_age(sbp,v) \ + ((sbp)->s_journal_max_commit_age = cpu_to_le32(v)) +#define sb_jourmal_max_trans_age(sbp) \ + (le32_to_cpu((sbp)->s_journal_max_trans_age)) +#define set_sb_journal_max_trans_age(sbp,v) \ + ((sbp)->s_journal_max_trans_age = cpu_to_le32(v)) +#define sb_blocksize(sbp) (le16_to_cpu((sbp)->s_blocksize)) +#define set_sb_blocksize(sbp,v) ((sbp)->s_blocksize = cpu_to_le16(v)) +#define sb_oid_maxsize(sbp) (le16_to_cpu((sbp)->s_oid_maxsize)) +#define set_sb_oid_maxsize(sbp,v) ((sbp)->s_oid_maxsize = cpu_to_le16(v)) +#define sb_oid_cursize(sbp) (le16_to_cpu((sbp)->s_oid_cursize)) +#define set_sb_oid_cursize(sbp,v) ((sbp)->s_oid_cursize = cpu_to_le16(v)) +#define sb_state(sbp) (le16_to_cpu((sbp)->s_state)) +#define set_sb_state(sbp,v) ((sbp)->s_state = cpu_to_le16(v)) +#define sb_hash_function_code(sbp) \ + (le32_to_cpu((sbp)->s_hash_function_code)) +#define set_sb_hash_function_code(sbp,v) \ + ((sbp)->s_hash_function_code = cpu_to_le32(v)) +#define sb_tree_height(sbp) (le16_to_cpu((sbp)->s_tree_height)) +#define set_sb_tree_height(sbp,v) ((sbp)->s_tree_height = cpu_to_le16(v)) +#define sb_bmap_nr(sbp) (le16_to_cpu((sbp)->s_bmap_nr)) +#define set_sb_bmap_nr(sbp,v) ((sbp)->s_bmap_nr = cpu_to_le16(v)) +#define sb_version(sbp) (le16_to_cpu((sbp)->s_version)) +#define set_sb_version(sbp,v) ((sbp)->s_version = cpu_to_le16(v)) /* this is the super from 3.5.X, where X >= 10 */ struct reiserfs_super_block_v1 @@ -180,7 +231,6 @@ struct reiserfs_transaction_handle { unsigned long t_trans_id ; /* sanity check, equals the current trans id */ struct super_block *t_super ; /* super for this FS when journal_begin was called. saves calls to reiserfs_get_super */ - } ; /* @@ -262,7 +312,7 @@ struct reiserfs_journal { #define JOURNAL_DESC_MAGIC "ReIsErLB" /* ick. magic string to find desc blocks in the journal */ -typedef __u32 (*hashf_t) (const char *, int); +typedef __u32 (*hashf_t) (const signed char *, int); /* reiserfs union of in-core super block data */ struct reiserfs_sb_info @@ -377,25 +427,22 @@ int reiserfs_resize(struct super_block *, unsigned long) ; // on-disk super block fields converted to cpu form -#define SB_DISK_SUPER_BLOCK(s) ((s)->u.reiserfs_sb.s_rs) -#define SB_BLOCK_COUNT(s) le32_to_cpu ((SB_DISK_SUPER_BLOCK(s)->s_block_count)) -#define SB_FREE_BLOCKS(s) le32_to_cpu ((SB_DISK_SUPER_BLOCK(s)->s_free_blocks)) -#define SB_REISERFS_MAGIC(s) (SB_DISK_SUPER_BLOCK(s)->s_magic) -#define SB_ROOT_BLOCK(s) le32_to_cpu ((SB_DISK_SUPER_BLOCK(s)->s_root_block)) -#define SB_TREE_HEIGHT(s) le16_to_cpu ((SB_DISK_SUPER_BLOCK(s)->s_tree_height)) -#define SB_REISERFS_STATE(s) le16_to_cpu ((SB_DISK_SUPER_BLOCK(s)->s_state)) -#define SB_VERSION(s) le16_to_cpu ((SB_DISK_SUPER_BLOCK(s)->s_version)) -#define SB_BMAP_NR(s) le16_to_cpu ((SB_DISK_SUPER_BLOCK(s)->s_bmap_nr)) - -#define PUT_SB_BLOCK_COUNT(s, val) do { SB_DISK_SUPER_BLOCK(s)->s_block_count = cpu_to_le32(val); } while (0) -#define PUT_SB_FREE_BLOCKS(s, val) do { SB_DISK_SUPER_BLOCK(s)->s_free_blocks = cpu_to_le32(val); } while (0) -#define PUT_SB_ROOT_BLOCK(s, val) do { SB_DISK_SUPER_BLOCK(s)->s_root_block = cpu_to_le32(val); } while (0) -#define PUT_SB_TREE_HEIGHT(s, val) do { SB_DISK_SUPER_BLOCK(s)->s_tree_height = cpu_to_le16(val); } while (0) -#define PUT_SB_REISERFS_STATE(s, val) do { SB_DISK_SUPER_BLOCK(s)->s_state = cpu_to_le16(val); } while (0) -#define PUT_SB_VERSION(s, val) do { SB_DISK_SUPER_BLOCK(s)->s_version = cpu_to_le16(val); } while (0) -#define PUT_SB_BMAP_NR(s, val) do { SB_DISK_SUPER_BLOCK(s)->s_bmap_nr = cpu_to_le16 (val); } while (0) +#define SB_DISK_SUPER_BLOCK(s) ((s)->u.reiserfs_sb.s_rs) +#define SB_BLOCK_COUNT(s) sb_block_count (SB_DISK_SUPER_BLOCK(s)) +#define SB_FREE_BLOCKS(s) sb_free_blocks (SB_DISK_SUPER_BLOCK(s)) +#define SB_REISERFS_MAGIC(s) (SB_DISK_SUPER_BLOCK(s)->s_magic) +#define SB_ROOT_BLOCK(s) sb_root_block (SB_DISK_SUPER_BLOCK(s)) +#define SB_TREE_HEIGHT(s) sb_tree_height (SB_DISK_SUPER_BLOCK(s)) +#define SB_REISERFS_STATE(s) sb_state (SB_DISK_SUPER_BLOCK(s)) +#define SB_VERSION(s) sb_version (SB_DISK_SUPER_BLOCK(s)) +#define SB_BMAP_NR(s) sb_bmap_nr(SB_DISK_SUPER_BLOCK(s)) + +#define PUT_SB_BLOCK_COUNT(s, val) do { set_sb_block_count( SB_DISK_SUPER_BLOCK(s), val); } while (0) +#define PUT_SB_FREE_BLOCKS(s, val) do { set_sb_free_blocks( SB_DISK_SUPER_BLOCK(s), val); } while (0) +#define PUT_SB_ROOT_BLOCK(s, val) do { set_sb_root_block( SB_DISK_SUPER_BLOCK(s), val); } while (0) +#define PUT_SB_TREE_HEIGHT(s, val) do { set_sb_tree_height( SB_DISK_SUPER_BLOCK(s), val); } while (0) +#define PUT_SB_REISERFS_STATE(s, val) do { set_sb_state( SB_DISK_SUPER_BLOCK(s), val); } while (0) +#define PUT_SB_VERSION(s, val) do { set_sb_version( SB_DISK_SUPER_BLOCK(s), val); } while (0) +#define PUT_SB_BMAP_NR(s, val) do { set_sb_bmap_nr( SB_DISK_SUPER_BLOCK(s), val); } while (0) #endif /* _LINUX_REISER_FS_SB */ - - - diff --git a/include/linux/wireless.h b/include/linux/wireless.h index ed279856efe3..3fe8709b469d 100644 --- a/include/linux/wireless.h +++ b/include/linux/wireless.h @@ -1,7 +1,7 @@ /* * This file define a set of standard wireless extensions * - * Version : 11 28.3.01 + * Version : 12 5.10.01 * * Authors : Jean Tourrilhes - HPL - <jt@hpl.hp.com> */ @@ -63,7 +63,7 @@ * (there is some stuff that will be added in the future...) * I just plan to increment with each new version. */ -#define WIRELESS_EXT 11 +#define WIRELESS_EXT 12 /* * Changes : @@ -116,6 +116,13 @@ * ---------- * - Add WE version in range (help backward/forward compatibility) * - Add retry ioctls (work like PM) + * + * V11 to V12 + * ---------- + * - Add SIOCSIWSTATS to get /proc/net/wireless programatically + * - Add DEV PRIVATE IOCTL to avoid collisions in SIOCDEVPRIVATE space + * - Add new statistics (frag, retry, beacon) + * - Add average quality (for user space calibration) */ /* -------------------------- IOCTL LIST -------------------------- */ @@ -137,6 +144,8 @@ #define SIOCGIWRANGE 0x8B0B /* Get range of parameters */ #define SIOCSIWPRIV 0x8B0C /* Unused */ #define SIOCGIWPRIV 0x8B0D /* get private ioctl interface info */ +#define SIOCSIWSTATS 0x8B0E /* Unused */ +#define SIOCGIWSTATS 0x8B0F /* Get /proc/net/wireless stats */ /* Mobile IP support */ #define SIOCSIWSPY 0x8B10 /* set spy addresses */ @@ -177,11 +186,33 @@ #define SIOCSIWPOWER 0x8B2C /* set Power Management settings */ #define SIOCGIWPOWER 0x8B2D /* get Power Management settings */ +/* -------------------- DEV PRIVATE IOCTL LIST -------------------- */ + +/* These 16 ioctl are wireless device private. + * Each driver is free to use them for whatever purpose it chooses, + * however the driver *must* export the description of those ioctls + * with SIOCGIWPRIV and *must* use arguments as defined below. + * If you don't follow those rules, DaveM is going to hate you (reason : + * it make mixed 32/64bit operation impossible). + */ +#define SIOCIWFIRSTPRIV 0x8BE0 +#define SIOCIWLASTPRIV 0x8BFF +/* Previously, we were using SIOCDEVPRIVATE, but we now have our + * separate range because of collisions with other tools such as + * 'mii-tool'. + * We now have 32 commands, so a bit more space ;-). + * Also, all 'odd' commands are only usable by root and don't return the + * content of ifr/iwr to user (but you are not obliged to use the set/get + * convention, just use every other two command). + * And I repeat : you are not obliged to use them with iwspy, but you + * must be compliant with it. + */ + /* ------------------------- IOCTL STUFF ------------------------- */ /* The first and the last (range) */ #define SIOCIWFIRST 0x8B00 -#define SIOCIWLAST 0x8B30 +#define SIOCIWLAST SIOCIWLASTPRIV /* 0x8BFF */ /* Even : get (world access), odd : set (root access) */ #define IW_IS_SET(cmd) (!((cmd) & 0x1)) @@ -191,7 +222,7 @@ /* * The following is used with SIOCGIWPRIV. It allow a driver to define * the interface (name, type of data) for its private ioctl. - * Privates ioctl are SIOCDEVPRIVATE -> SIOCDEVPRIVATE + 0xF + * Privates ioctl are SIOCIWFIRSTPRIV -> SIOCIWLASTPRIV */ #define IW_PRIV_TYPE_MASK 0x7000 /* Type of arguments */ @@ -334,23 +365,38 @@ struct iw_freq */ struct iw_quality { - __u8 qual; /* link quality (%retries, SNR or better...) */ - __u8 level; /* signal level */ - __u8 noise; /* noise level */ + __u8 qual; /* link quality (%retries, SNR, + %missed beacons or better...) */ + __u8 level; /* signal level (dBm) */ + __u8 noise; /* noise level (dBm) */ __u8 updated; /* Flags to know if updated */ }; /* * Packet discarded in the wireless adapter due to * "wireless" specific problems... + * Note : the list of counter and statistics in net_device_stats + * is already pretty exhaustive, and you should use that first. + * This is only additional stats... */ struct iw_discarded { - __u32 nwid; /* Wrong nwid */ - __u32 code; /* Unable to code/decode */ + __u32 nwid; /* Rx : Wrong nwid/essid */ + __u32 code; /* Rx : Unable to code/decode (WEP) */ + __u32 fragment; /* Rx : Can't perform MAC reassembly */ + __u32 retries; /* Tx : Max MAC retries num reached */ __u32 misc; /* Others cases */ }; +/* + * Packet/Time period missed in the wireless adapter due to + * "wireless" specific problems... + */ +struct iw_missed +{ + __u32 beacon; /* Missed beacons/superframe */ +}; + /* ------------------------ WIRELESS STATS ------------------------ */ /* * Wireless statistics (used for /proc/net/wireless) @@ -363,6 +409,7 @@ struct iw_statistics struct iw_quality qual; /* Quality of the link * (instant/mean/max) */ struct iw_discarded discard; /* Packet discarded counts */ + struct iw_missed miss; /* Packet missed counts */ }; /* ------------------------ IOCTL REQUEST ------------------------ */ @@ -493,6 +540,19 @@ struct iw_range __s32 max_retry; /* Maximal number of retries */ __s32 min_r_time; /* Minimal retry lifetime */ __s32 max_r_time; /* Maximal retry lifetime */ + + /* Average quality of link & SNR */ + struct iw_quality avg_qual; /* Quality of the link */ + /* This should contain the average/typical values of the quality + * indicator. This should be the threshold between a "good" and + * a "bad" link (example : monitor going from green to orange). + * Currently, user space apps like quality monitors don't have any + * way to calibrate the measurement. With this, they can split + * the range between 0 and max_qual in different quality level + * (using a geometric subdivision centered on the average). + * I expect that people doing the user space apps will feedback + * us on which value we need to put in each driver... + */ }; /* |
