]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
minix: move globals and inline functions to minix_programs.h
authorSami Kerola <kerolasa@iki.fi>
Wed, 20 Jul 2011 18:28:55 +0000 (20:28 +0200)
committerSami Kerola <kerolasa@iki.fi>
Wed, 20 Jul 2011 18:43:16 +0000 (20:43 +0200)
Global variables and inline functions are moved from minix.h to
minix_programs.h which is included in mkfs.minix and fsck.minix.
The minix.h will have only struct definitions etc generic
contents which is reasonable to share with utilities and
libraries.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
disk-utils/Makefile.am
disk-utils/fsck.minix.c
disk-utils/minix_programs.h [new file with mode: 0644]
disk-utils/mkfs.minix.c
include/minix.h

index dc1b9c76447b1902510fc0ffbce487838503b9c3..4816c1fb2ed321fc6422f4e0009cccc88ef90496 100644 (file)
@@ -15,8 +15,8 @@ dist_man_MANS = isosize.8 mkfs.8 mkswap.8 \
 
 sbin_PROGRAMS = mkfs mkswap fsck.minix mkfs.minix mkfs.bfs
 
-fsck_minix_SOURCES = fsck.minix.c $(top_srcdir)/lib/ismounted.c
-mkfs_minix_SOURCES = mkfs.minix.c mkfs.h $(utils_common) $(top_srcdir)/lib/strutils.c
+fsck_minix_SOURCES = fsck.minix.c minix_programs.h $(top_srcdir)/lib/ismounted.c
+mkfs_minix_SOURCES = mkfs.minix.c minix_programs.h mkfs.h $(utils_common) $(top_srcdir)/lib/strutils.c
 mkfs_bfs_SOURCES = mkfs.bfs.c $(utils_common)
 
 swaplabel_SOURCES = swaplabel.c $(utils_common)
index abb4d9bf6a82e34177f15155d9b2323d1ee2865b..673dcd97b9a25e5f2d1b12303b618a72430372c8 100644 (file)
 #include <signal.h>
 
 #include "minix.h"
+#include "minix_programs.h"
 #include "nls.h"
 #include "pathnames.h"
 #include "bitops.h"
diff --git a/disk-utils/minix_programs.h b/disk-utils/minix_programs.h
new file mode 100644 (file)
index 0000000..3e6c649
--- /dev/null
@@ -0,0 +1,113 @@
+#ifndef UTIL_LINUX_MINIX_PROGRAMS_H
+#define UTIL_LINUX_MINIX_PROGRAMS_H
+
+#include "minix.h"
+
+/*
+ * Global variables.
+ */
+static int fs_version = 1;     /* this default value needs to change in a near future */
+
+static char *super_block_buffer;
+static char *inode_buffer = NULL;
+
+static char *inode_map;
+static char *zone_map;
+
+/*
+ * Inline functions.
+ */
+static inline unsigned long get_ninodes(void)
+{
+       switch (fs_version) {
+       case 3:
+               return Super3.s_ninodes;
+       default:
+               return (unsigned long)Super.s_ninodes;
+       }
+}
+
+static inline unsigned long get_nzones(void)
+{
+       switch (fs_version) {
+       case 3:
+               return (unsigned long)Super3.s_zones;
+       case 2:
+               return (unsigned long)Super.s_zones;
+       default:
+               return (unsigned long)Super.s_nzones;
+       }
+}
+
+static inline unsigned long get_nimaps(void)
+{
+       switch (fs_version) {
+       case 3:
+               return (unsigned long)Super3.s_imap_blocks;
+       default:
+               return (unsigned long)Super.s_imap_blocks;
+       }
+}
+
+static inline unsigned long get_nzmaps(void)
+{
+       switch (fs_version) {
+       case 3:
+               return (unsigned long)Super3.s_zmap_blocks;
+       default:
+               return (unsigned long)Super.s_zmap_blocks;
+       }
+}
+
+static inline unsigned long get_first_zone(void)
+{
+       switch (fs_version) {
+       case 3:
+               return (unsigned long)Super3.s_firstdatazone;
+       default:
+               return (unsigned long)Super.s_firstdatazone;
+       }
+}
+
+static inline unsigned long get_zone_size(void)
+{
+       switch (fs_version) {
+       case 3:
+               return (unsigned long)Super3.s_log_zone_size;
+       default:
+               return (unsigned long)Super.s_log_zone_size;
+       }
+}
+
+static inline unsigned long get_max_size(void)
+{
+       switch (fs_version) {
+       case 3:
+               return (unsigned long)Super3.s_max_size;
+       default:
+               return (unsigned long)Super.s_max_size;
+       }
+}
+
+static unsigned long inode_blocks(void)
+{
+       switch (fs_version) {
+       case 3:
+       case 2:
+               return UPPER(get_ninodes(), MINIX2_INODES_PER_BLOCK);
+       default:
+               return UPPER(get_ninodes(), MINIX_INODES_PER_BLOCK);
+       }
+}
+
+static inline unsigned long first_zone_data(void)
+{
+       return 2 + get_nimaps() + get_nzmaps() + inode_blocks();
+}
+
+static inline unsigned long get_inode_buffer_size(void)
+{
+       return inode_blocks() * MINIX_BLOCK_SIZE;
+}
+
+#endif                         /* UTIL_LINUX_MINIX_PROGRAMS_H */
index 489f032ac061eca0924342a8d6a467087f9017fe..8469d3df2c4658df9410674ab8b15fe784a281a3 100644 (file)
@@ -79,6 +79,7 @@
 
 #include "blkdev.h"
 #include "minix.h"
+#include "minix_programs.h"
 #include "nls.h"
 #include "pathnames.h"
 #include "bitops.h"
index 7ef6eecb0033931080d44a63b751af2bd6c2592a..d89fc2ad99a120e06971fd22bfba1bfd1c643a30 100644 (file)
@@ -79,12 +79,6 @@ struct minix3_super_block {
 #define INODE_SIZE (sizeof(struct minix_inode))
 #define INODE2_SIZE (sizeof(struct minix2_inode))
 
-int fs_version = 1; /* this default value needs to change in a near future */
-char *super_block_buffer, *inode_buffer = NULL;
-
-static char *inode_map;
-static char *zone_map;
-
 #define BITS_PER_BLOCK (MINIX_BLOCK_SIZE<<3)
 
 #define UPPER(size,n) ((size+((n)-1))/(n))
@@ -95,97 +89,4 @@ static char *zone_map;
 #define Super (*(struct minix_super_block *)super_block_buffer)
 #define Super3 (*(struct minix3_super_block *)super_block_buffer)
 
-static inline unsigned long get_ninodes(void)
-{
-       switch (fs_version) {
-       case 3:
-               return Super3.s_ninodes;
-       default:
-               return (unsigned long) Super.s_ninodes;
-       }
-}
-
-static inline unsigned long get_nzones(void)
-{
-       switch (fs_version) {
-       case 3:
-               return (unsigned long) Super3.s_zones;
-       case 2:
-               return (unsigned long) Super.s_zones;
-       default:
-               return (unsigned long) Super.s_nzones;
-       }
-}
-
-static inline unsigned long get_nimaps(void)
-{
-       switch (fs_version) {
-       case 3:
-               return (unsigned long) Super3.s_imap_blocks;
-       default:
-               return (unsigned long) Super.s_imap_blocks;
-       }
-}
-
-static inline unsigned long get_nzmaps(void)
-{
-       switch (fs_version) {
-       case 3:
-               return (unsigned long) Super3.s_zmap_blocks;
-       default:
-               return (unsigned long) Super.s_zmap_blocks;
-       }
-}
-
-static inline unsigned long get_first_zone(void)
-{
-       switch (fs_version) {
-       case 3:
-               return (unsigned long) Super3.s_firstdatazone;
-       default:
-               return (unsigned long) Super.s_firstdatazone;
-       }
-}
-
-static inline unsigned long get_zone_size(void)
-{
-       switch (fs_version) {
-       case 3:
-               return (unsigned long) Super3.s_log_zone_size;
-       default:
-               return (unsigned long) Super.s_log_zone_size;
-       }
-}
-
-static inline unsigned long get_max_size(void)
-{
-       switch (fs_version) {
-       case 3:
-               return (unsigned long) Super3.s_max_size;
-       default:
-               return (unsigned long) Super.s_max_size;
-       }
-}
-
-static unsigned long inode_blocks(void)
-{
-       switch (fs_version) {
-       case 3:
-       case 2:
-               return UPPER(get_ninodes(), MINIX2_INODES_PER_BLOCK);
-       default:
-               return UPPER(get_ninodes(), MINIX_INODES_PER_BLOCK);
-       }
-}
-
-static inline unsigned long first_zone_data(void)
-{
-       return 2 + get_nimaps() + get_nzmaps() + inode_blocks();
-}
-
-static inline unsigned long get_inode_buffer_size(void)
-{
-       return inode_blocks() * MINIX_BLOCK_SIZE;
-}
-
 #endif /* UTIL_LINUX_MINIX_H */