bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 03/17] ext2fs: remove __KERNEL__


From: Samuel Thibault
Subject: Re: [PATCH 03/17] ext2fs: remove __KERNEL__
Date: Sun, 23 Jan 2022 10:56:28 +0100
User-agent: NeoMutt/20170609 (1.8.3)

Etienne Brateau, le dim. 23 janv. 2022 05:17:01 +0100, a ecrit:
> This makes the header more clear and btw it’s not anymore in the linux tree

Applied modulo some typo in EXT2_DESC_PER_BLOCK and EXT2_INODES_PER_GROUP, 
thanks!

> ---
>  ext2fs/ext2_fs.h | 247 ++++++++---------------------------------------
>  1 file changed, 38 insertions(+), 209 deletions(-)
> 
> diff --git a/ext2fs/ext2_fs.h b/ext2fs/ext2_fs.h
> index d1a972b7..d3701553 100644
> --- a/ext2fs/ext2_fs.h
> +++ b/ext2fs/ext2_fs.h
> @@ -35,7 +35,7 @@
>  /*
>   * Special inodes numbers
>   */
> -#define      EXT2_BAD_INO             1      /* Bad blocks inode */
> +#define EXT2_BAD_INO          1      /* Bad blocks inode */
>  #define EXT2_ROOT_INO                 2      /* Root inode */
>  #define EXT2_ACL_IDX_INO      3      /* ACL inode */
>  #define EXT2_ACL_DATA_INO     4      /* ACL inode */
> @@ -59,46 +59,27 @@
>   * Macro-instructions used to manage several block sizes
>   */
>  #define EXT2_MIN_BLOCK_SIZE          1024
> -#define      EXT2_MAX_BLOCK_SIZE             4096
> +#define EXT2_MAX_BLOCK_SIZE          4096
>  #define EXT2_MIN_BLOCK_LOG_SIZE                10
> -#ifdef __KERNEL__
> -# define EXT2_BLOCK_SIZE(s)          ((s)->s_blocksize)
> -#else
> -# define EXT2_BLOCK_SIZE(s)          (EXT2_MIN_BLOCK_SIZE << 
> (s)->s_log_block_size)
> -#endif
> -#define EXT2_ACLE_PER_BLOCK(s)               (EXT2_BLOCK_SIZE(s) / sizeof 
> (struct ext2_acl_entry))
> -#define      EXT2_ADDR_PER_BLOCK(s)          (EXT2_BLOCK_SIZE(s) / sizeof 
> (__u32))
> -#ifdef __KERNEL__
> -# define EXT2_BLOCK_SIZE_BITS(s)     ((s)->s_blocksize_bits)
> -#else
> -# define EXT2_BLOCK_SIZE_BITS(s)     ((s)->s_log_block_size + 10)
> -#endif
> -#ifdef __KERNEL__
> -#define      EXT2_ADDR_PER_BLOCK_BITS(s)     
> ((s)->u.ext2_sb.s_addr_per_block_bits)
> -#define EXT2_INODE_SIZE(s)           ((s)->u.ext2_sb.s_inode_size)
> -#define EXT2_FIRST_INO(s)            ((s)->u.ext2_sb.s_first_ino)
> -#else
> -#define EXT2_INODE_SIZE(s)   (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
> -                              EXT2_GOOD_OLD_INODE_SIZE : \
> -                              (s)->s_inode_size)
> -#define EXT2_FIRST_INO(s)    (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
> -                              EXT2_GOOD_OLD_FIRST_INO : \
> -                              (s)->s_first_ino)
> -#endif
> +#define EXT2_BLOCK_SIZE(s)            (EXT2_MIN_BLOCK_SIZE << 
> (s)->s_log_block_size)
> +#define EXT2_ACLE_PER_BLOCK(s)         (EXT2_BLOCK_SIZE(s) / sizeof (struct 
> ext2_acl_entry))
> +#define EXT2_ADDR_PER_BLOCK(s)          (EXT2_BLOCK_SIZE(s) / sizeof (__u32))
> +#define EXT2_BLOCK_SIZE_BITS(s)       ((s)->s_log_block_size + 10)
> +#define EXT2_INODE_SIZE(s)     (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
> +                                EXT2_GOOD_OLD_INODE_SIZE : \
> +                                (s)->s_inode_size)
> +#define EXT2_FIRST_INO(s)      (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
> +                                EXT2_GOOD_OLD_FIRST_INO : \
> +                                (s)->s_first_ino)
>  
>  /*
>   * Macro-instructions used to manage fragments
>   */
>  #define EXT2_MIN_FRAG_SIZE           1024
> -#define      EXT2_MAX_FRAG_SIZE              4096
> +#define EXT2_MAX_FRAG_SIZE           4096
>  #define EXT2_MIN_FRAG_LOG_SIZE                 10
> -#ifdef __KERNEL__
> -# define EXT2_FRAG_SIZE(s)           ((s)->u.ext2_sb.s_frag_size)
> -# define EXT2_FRAGS_PER_BLOCK(s)     ((s)->u.ext2_sb.s_frags_per_block)
> -#else
> -# define EXT2_FRAG_SIZE(s)           (EXT2_MIN_FRAG_SIZE << 
> (s)->s_log_frag_size)
> -# define EXT2_FRAGS_PER_BLOCK(s)     (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s))
> -#endif
> +#define EXT2_FRAG_SIZE(s)                            (EXT2_MIN_FRAG_SIZE << 
> (s)->s_log_frag_size)
> +#define EXT2_FRAGS_PER_BLOCK(s)              (EXT2_BLOCK_SIZE(s) / 
> EXT2_FRAG_SIZE(s))
>  
>  /*
>   * ACL structures
> @@ -140,16 +121,9 @@ struct ext2_group_desc
>  /*
>   * Macro-instructions used to manage group descriptors
>   */
> -#ifdef __KERNEL__
> -# define EXT2_BLOCKS_PER_GROUP(s)    ((s)->u.ext2_sb.s_blocks_per_group)
> -# define EXT2_DESC_PER_BLOCK(s)              
> ((s)->u.ext2_sb.s_desc_per_block)
> -# define EXT2_INODES_PER_GROUP(s)    ((s)->u.ext2_sb.s_inodes_per_group)
> -# define EXT2_DESC_PER_BLOCK_BITS(s) ((s)->u.ext2_sb.s_desc_per_block_bits)
> -#else
> -# define EXT2_BLOCKS_PER_GROUP(s)    ((s)->s_blocks_per_group)
> -# define EXT2_DESC_PER_BLOCK(s)              (EXT2_BLOCK_SIZE(s) / sizeof 
> (struct ext2_group_desc))
> -# define EXT2_INODES_PER_GROUP(s)    ((s)->s_inodes_per_group)
> -#endif
> +#define EXT2_BLOCKS_PER_GROUP(s)                     
> ((s)->s_blocks_per_group)
> +#define EXT2_DESC_PER_BLOCK(s)                               
> (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group
> +#define EXT2_INODES_PER_GROUP(s)                     ((s)->s_inodes_per_group
>  
>  /*
>   * Constants relative to the data blocks
> @@ -215,12 +189,12 @@ static __inline__ __u32 ext2_mask_flags(mode_t mode, 
> __u32 flags)
>  /*
>   * ioctl commands
>   */
> -#define      EXT2_IOC_GETFLAGS               _IOR('f', 1, long)
> -#define      EXT2_IOC_SETFLAGS               _IOW('f', 2, long)
> -#define      EXT2_IOC_GETVERSION             _IOR('v', 1, long)
> -#define      EXT2_IOC_SETVERSION             _IOW('v', 2, long)
> -#define      EXT2_IOC_GETRSVSZ               _IOR('f', 5, long)
> -#define      EXT2_IOC_SETRSVSZ               _IOW('f', 6, long)
> +#define EXT2_IOC_GETFLAGS            _IOR('f', 1, long)
> +#define EXT2_IOC_SETFLAGS            _IOW('f', 2, long)
> +#define EXT2_IOC_GETVERSION          _IOR('v', 1, long)
> +#define EXT2_IOC_SETVERSION          _IOW('v', 2, long)
> +#define EXT2_IOC_GETRSVSZ            _IOR('f', 5, long)
> +#define EXT2_IOC_SETRSVSZ            _IOW('f', 6, long)
>  
>  
>  /*
> @@ -288,38 +262,18 @@ struct ext2_inode {
>  
>  #define i_size_high  i_dir_acl
>  
> -#if defined(__KERNEL__) || defined(__linux__)
> -#define i_reserved1  osd1.linux1.l_i_reserved1
> -#define i_frag               osd2.linux2.l_i_frag
> -#define i_fsize              osd2.linux2.l_i_fsize
> -#define i_uid_low    i_uid
> -#define i_gid_low    i_gid
> -#define i_uid_high   osd2.linux2.l_i_uid_high
> -#define i_gid_high   osd2.linux2.l_i_gid_high
> -#define i_reserved2  osd2.linux2.l_i_reserved2
> -#endif
> -
> -#ifdef       __hurd__
>  #define i_translator osd1.hurd1.h_i_translator
>  #define i_frag               osd2.hurd2.h_i_frag
>  #define i_fsize              osd2.hurd2.h_i_fsize
>  #define i_uid_high   osd2.hurd2.h_i_uid_high
>  #define i_gid_high   osd2.hurd2.h_i_gid_high
>  #define i_author     osd2.hurd2.h_i_author
> -#endif
> -
> -#ifdef       __masix__
> -#define i_reserved1  osd1.masix1.m_i_reserved1
> -#define i_frag               osd2.masix2.m_i_frag
> -#define i_fsize              osd2.masix2.m_i_fsize
> -#define i_reserved2  osd2.masix2.m_i_reserved2
> -#endif
>  
>  /*
>   * File system states
>   */
> -#define      EXT2_VALID_FS                   0x0001  /* Unmounted cleanly */
> -#define      EXT2_ERROR_FS                   0x0002  /* Errors detected */
> +#define EXT2_VALID_FS                        0x0001  /* Unmounted cleanly */
> +#define EXT2_ERROR_FS                        0x0002  /* Errors detected */
>  
>  /*
>   * Mount flags
> @@ -347,8 +301,7 @@ struct ext2_inode {
>  
>  #define clear_opt(o, opt)            o &= ~EXT2_MOUNT_##opt
>  #define set_opt(o, opt)                      o |= EXT2_MOUNT_##opt
> -#define test_opt(sb, opt)            ((sb)->u.ext2_sb.s_mount_opt & \
> -                                      EXT2_MOUNT_##opt)
> +#define test_opt(o, opt)             o & EXT2_MOUNT_##opt
>  /*
>   * Maximal mount counts between two filesystem checks
>   */
> @@ -438,15 +391,6 @@ struct ext2_super_block {
>       __u32   s_reserved[190];        /* Padding to the end of the block */
>  };
>  
> -#ifdef __KERNEL__
> -#define EXT2_SB(sb)  (&((sb)->u.ext2_sb))
> -#else
> -/* Assume that user mode programs are passing in an ext2fs superblock, not
> - * a kernel struct super_block.  This will allow us to call the feature-test
> - * macros from user land. */
> -#define EXT2_SB(sb)  (sb)
> -#endif
> -
>  /*
>   * Codes for operating systems
>   */
> @@ -472,23 +416,23 @@ struct ext2_super_block {
>   */
>  
>  #define EXT2_HAS_COMPAT_FEATURE(sb,mask)                     \
> -     ( EXT2_SB(sb)->s_feature_compat & (mask) )
> +     ( (sb)->s_feature_compat & (mask) )
>  #define EXT2_HAS_RO_COMPAT_FEATURE(sb,mask)                  \
> -     ( EXT2_SB(sb)->s_feature_ro_compat & (mask) )
> +     ( (sb)->s_feature_ro_compat & (mask) )
>  #define EXT2_HAS_INCOMPAT_FEATURE(sb,mask)                   \
> -     ( EXT2_SB(sb)->s_feature_incompat & (mask) )
> +     ( (sb)->s_feature_incompat & (mask) )
>  #define EXT2_SET_COMPAT_FEATURE(sb,mask)                     \
> -     EXT2_SB(sb)->s_es->s_feature_compat |= (mask)
> +     (sb)->s_feature_compat |= (mask)
>  #define EXT2_SET_RO_COMPAT_FEATURE(sb,mask)                  \
> -     EXT2_SB(sb)->s_es->s_feature_ro_compat |= (mask)
> +     (sb)->s_feature_ro_compat |= (mask)
>  #define EXT2_SET_INCOMPAT_FEATURE(sb,mask)                   \
> -     EXT2_SB(sb)->s_es->s_feature_incompat |= (mask)
> +     (sb)->s_feature_incompat |= (mask)
>  #define EXT2_CLEAR_COMPAT_FEATURE(sb,mask)                   \
> -     EXT2_SB(sb)->s_es->s_feature_compat &= ~(mask)
> +     (sb)->s_feature_compat &= ~(mask)
>  #define EXT2_CLEAR_RO_COMPAT_FEATURE(sb,mask)                        \
> -     EXT2_SB(sb)->s_es->s_feature_ro_compat &= ~(mask)
> +     (sb)->s_feature_ro_compat &= ~(mask)
>  #define EXT2_CLEAR_INCOMPAT_FEATURE(sb,mask)                 \
> -     EXT2_SB(sb)->s_es->s_feature_incompat &= ~(mask)
> +     (sb)->s_feature_incompat &= ~(mask)
>  
>  #define EXT2_FEATURE_COMPAT_DIR_PREALLOC     0x0001
>  #define EXT2_FEATURE_COMPAT_IMAGIC_INODES    0x0002
> @@ -521,8 +465,8 @@ struct ext2_super_block {
>  /*
>   * Default values for user and/or group using reserved blocks
>   */
> -#define      EXT2_DEF_RESUID         0
> -#define      EXT2_DEF_RESGID         0
> +#define EXT2_DEF_RESUID              0
> +#define EXT2_DEF_RESGID              0
>  
>  /*
>   * Default mount options
> @@ -612,119 +556,4 @@ struct ext2_inode_info {
>       int     i_new_inode:1;  /* Is a freshly allocated inode */
>  };
>  
> -#ifdef __KERNEL__
> -/*
> - * Function prototypes
> - */
> -
> -/*
> - * Ok, these declarations are also in <linux/kernel.h> but none of the
> - * ext2 source programs needs to include it so they are duplicated here.
> - */
> -# define NORET_TYPE    /**/
> -# define ATTRIB_NORET  __attribute__((noreturn))
> -# define NORET_AND     noreturn,
> -
> -/* acl.c */
> -extern int ext2_permission (struct inode *, int);
> -
> -/* balloc.c */
> -extern int ext2_group_sparse(int group);
> -extern int ext2_new_block (const struct inode *, unsigned long,
> -                        __u32 *, __u32 *, int *);
> -extern void ext2_free_blocks (const struct inode *, unsigned long,
> -                           unsigned long);
> -extern unsigned long ext2_count_free_blocks (struct super_block *);
> -extern void ext2_check_blocks_bitmap (struct super_block *);
> -extern struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb,
> -                                                 unsigned int block_group,
> -                                                 struct buffer_head ** bh);
> -
> -/* bitmap.c */
> -extern unsigned long ext2_count_free (struct buffer_head *, unsigned);
> -
> -/* dir.c */
> -extern int ext2_check_dir_entry (const char *, struct inode *,
> -                              struct ext2_dir_entry_2 *, struct buffer_head 
> *,
> -                              unsigned long);
> -
> -/* file.c */
> -extern int ext2_read (struct inode *, struct file *, char *, int);
> -extern int ext2_write (struct inode *, struct file *, char *, int);
> -
> -/* fsync.c */
> -extern int ext2_sync_file (struct file *, struct dentry *);
> -
> -/* ialloc.c */
> -extern struct inode * ext2_new_inode (const struct inode *, int, int *);
> -extern void ext2_free_inode (struct inode *);
> -extern unsigned long ext2_count_free_inodes (struct super_block *);
> -extern void ext2_check_inodes_bitmap (struct super_block *);
> -
> -/* inode.c */
> -extern long ext2_bmap (struct inode *, long);
> -extern int ext2_get_block (struct inode *, long, struct buffer_head *, int);
> -
> -extern struct buffer_head * ext2_getblk (struct inode *, long, int, int *);
> -extern int ext2_getblk_block (struct inode *, long, int, int *, int *);
> -extern struct buffer_head * ext2_bread (struct inode *, int, int, int *);
> -
> -extern int ext2_getcluster (struct inode * inode, long block);
> -extern void ext2_read_inode (struct inode *);
> -extern void ext2_write_inode (struct inode *);
> -extern void ext2_put_inode (struct inode *);
> -extern void ext2_delete_inode (struct inode *);
> -extern int ext2_sync_inode (struct inode *);
> -extern void ext2_discard_prealloc (struct inode *);
> -
> -/* ioctl.c */
> -extern int ext2_ioctl (struct inode *, struct file *, unsigned int,
> -                    unsigned long);
> -
> -/* namei.c */
> -extern void ext2_release (struct inode *, struct file *);
> -extern struct dentry *ext2_lookup (struct inode *, struct dentry *);
> -extern int ext2_create (struct inode *,struct dentry *,int);
> -extern int ext2_mkdir (struct inode *,struct dentry *,int);
> -extern int ext2_rmdir (struct inode *,struct dentry *);
> -extern int ext2_unlink (struct inode *,struct dentry *);
> -extern int ext2_symlink (struct inode *,struct dentry *,const char *);
> -extern int ext2_link (struct dentry *, struct inode *, struct dentry *);
> -extern int ext2_mknod (struct inode *, struct dentry *, int, int);
> -extern int ext2_rename (struct inode *, struct dentry *,
> -                     struct inode *, struct dentry *);
> -
> -/* super.c */
> -extern void ext2_error (struct super_block *, const char *, const char *, 
> ...)
> -     __attribute__ ((format (printf, 3, 4)));
> -extern NORET_TYPE void ext2_panic (struct super_block *, const char *,
> -                                const char *, ...)
> -     __attribute__ ((NORET_AND format (printf, 3, 4)));
> -extern void ext2_warning (struct super_block *, const char *, const char *, 
> ...)
> -     __attribute__ ((format (printf, 3, 4)));
> -extern void ext2_put_super (struct super_block *);
> -extern void ext2_write_super (struct super_block *);
> -extern int ext2_remount (struct super_block *, int *, char *);
> -extern struct super_block * ext2_read_super (struct super_block *,void 
> *,int);
> -extern int ext2_statfs (struct super_block *, struct statfs *, int);
> -
> -/* truncate.c */
> -extern void ext2_truncate (struct inode *);
> -
> -/*
> - * Inodes and files operations
> - */
> -
> -/* dir.c */
> -extern struct inode_operations ext2_dir_inode_operations;
> -
> -/* file.c */
> -extern struct inode_operations ext2_file_inode_operations;
> -
> -/* symlink.c */
> -extern struct inode_operations ext2_symlink_inode_operations;
> -extern struct inode_operations ext2_fast_symlink_inode_operations;
> -
> -#endif       /* __KERNEL__ */
> -
>  #endif       /* _LINUX_EXT2_FS_H */
> -- 
> 2.34.1
> 
> 

-- 
Samuel
"c'est pas nous qui sommes à la rue, c'est la rue qui est à nous"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]