blob: 1c0b355aa51548174e2b7325c62ab8664d2ae3e3 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * include/linux/bfs_fs.h - BFS data structures on disk.
3 * Copyright (C) 1999 Tigran Aivazian <tigran@veritas.com>
4 */
5
6#ifndef _LINUX_BFS_FS_H
7#define _LINUX_BFS_FS_H
8
Jaswinder Singh Rajput1da9ebd2009-01-30 20:34:15 +05309#include <linux/types.h>
10
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#define BFS_BSIZE_BITS 9
12#define BFS_BSIZE (1<<BFS_BSIZE_BITS)
13
14#define BFS_MAGIC 0x1BADFACE
15#define BFS_ROOT_INO 2
16#define BFS_INODES_PER_BLOCK 8
17
18/* SVR4 vnode type values (bfs_inode->i_vtype) */
Andrew Stribblehillfac92be2005-09-09 13:02:04 -070019#define BFS_VDIR 2L
20#define BFS_VREG 1L
21
Linus Torvalds1da177e2005-04-16 15:20:36 -070022/* BFS inode layout on disk */
23struct bfs_inode {
Alexey Dobriyance0fe7e2005-10-04 17:43:06 +010024 __le16 i_ino;
Linus Torvalds1da177e2005-04-16 15:20:36 -070025 __u16 i_unused;
Alexey Dobriyance0fe7e2005-10-04 17:43:06 +010026 __le32 i_sblock;
27 __le32 i_eblock;
28 __le32 i_eoffset;
29 __le32 i_vtype;
30 __le32 i_mode;
31 __le32 i_uid;
32 __le32 i_gid;
33 __le32 i_nlink;
34 __le32 i_atime;
35 __le32 i_mtime;
36 __le32 i_ctime;
Linus Torvalds1da177e2005-04-16 15:20:36 -070037 __u32 i_padding[4];
38};
39
40#define BFS_NAMELEN 14
41#define BFS_DIRENT_SIZE 16
42#define BFS_DIRS_PER_BLOCK 32
43
44struct bfs_dirent {
Alexey Dobriyance0fe7e2005-10-04 17:43:06 +010045 __le16 ino;
Linus Torvalds1da177e2005-04-16 15:20:36 -070046 char name[BFS_NAMELEN];
47};
48
49/* BFS superblock layout on disk */
50struct bfs_super_block {
Alexey Dobriyance0fe7e2005-10-04 17:43:06 +010051 __le32 s_magic;
52 __le32 s_start;
53 __le32 s_end;
54 __le32 s_from;
55 __le32 s_to;
Linus Torvalds1da177e2005-04-16 15:20:36 -070056 __s32 s_bfrom;
57 __s32 s_bto;
58 char s_fsname[6];
59 char s_volume[6];
60 __u32 s_padding[118];
61};
62
Linus Torvalds1da177e2005-04-16 15:20:36 -070063
64#define BFS_OFF2INO(offset) \
65 ((((offset) - BFS_BSIZE) / sizeof(struct bfs_inode)) + BFS_ROOT_INO)
66
67#define BFS_INO2OFF(ino) \
68 ((__u32)(((ino) - BFS_ROOT_INO) * sizeof(struct bfs_inode)) + BFS_BSIZE)
Andrew Stribblehillfac92be2005-09-09 13:02:04 -070069#define BFS_NZFILESIZE(ip) \
Alexey Dobriyance0fe7e2005-10-04 17:43:06 +010070 ((le32_to_cpu((ip)->i_eoffset) + 1) - le32_to_cpu((ip)->i_sblock) * BFS_BSIZE)
Linus Torvalds1da177e2005-04-16 15:20:36 -070071
Andrew Stribblehillfac92be2005-09-09 13:02:04 -070072#define BFS_FILESIZE(ip) \
73 ((ip)->i_sblock == 0 ? 0 : BFS_NZFILESIZE(ip))
74
75#define BFS_FILEBLOCKS(ip) \
Alexey Dobriyance0fe7e2005-10-04 17:43:06 +010076 ((ip)->i_sblock == 0 ? 0 : (le32_to_cpu((ip)->i_eblock) + 1) - le32_to_cpu((ip)->i_sblock))
Linus Torvalds1da177e2005-04-16 15:20:36 -070077#define BFS_UNCLEAN(bfs_sb, sb) \
Alexey Dobriyance0fe7e2005-10-04 17:43:06 +010078 ((le32_to_cpu(bfs_sb->s_from) != -1) && (le32_to_cpu(bfs_sb->s_to) != -1) && !(sb->s_flags & MS_RDONLY))
Andrew Stribblehillfac92be2005-09-09 13:02:04 -070079
Linus Torvalds1da177e2005-04-16 15:20:36 -070080
81#endif /* _LINUX_BFS_FS_H */