summaryrefslogtreecommitdiffstats
path: root/disk-utils/minix_programs.h
diff options
context:
space:
mode:
authorKarel Zak2011-07-21 11:26:42 +0200
committerKarel Zak2011-07-21 11:26:42 +0200
commite844147d17337ffa492ad8ca4887e1e0112ec409 (patch)
tree6b5f4ec4e5ccbc69e830dde7356dda976e243b7a /disk-utils/minix_programs.h
parentlibmount: fix mtab update for "none" source (diff)
parentlibblkid: move MINIX_MAXPARTITIONS to minix.h (diff)
downloadkernel-qcow2-util-linux-e844147d17337ffa492ad8ca4887e1e0112ec409.tar.gz
kernel-qcow2-util-linux-e844147d17337ffa492ad8ca4887e1e0112ec409.tar.xz
kernel-qcow2-util-linux-e844147d17337ffa492ad8ca4887e1e0112ec409.zip
Merge branch 'minix' of https://github.com/kerolasa/lelux-utiliteetit
* 'minix' of https://github.com/kerolasa/lelux-utiliteetit: libblkid: move MINIX_MAXPARTITIONS to minix.h minix: move globals and inline functions to minix_programs.h libblkid: use MINIX_BLOCK_SIZE from minix.h libblkid: use superblock structure from minix.h include: move minix.h to include directory include: remove kernel headers from minix.h include: minix.h: use data types from stdint.h Conflicts: disk-utils/Makefile.am Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'disk-utils/minix_programs.h')
-rw-r--r--disk-utils/minix_programs.h113
1 files changed, 113 insertions, 0 deletions
diff --git a/disk-utils/minix_programs.h b/disk-utils/minix_programs.h
new file mode 100644
index 000000000..3e6c649ac
--- /dev/null
+++ b/disk-utils/minix_programs.h
@@ -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 */