blob: 940b04772af801345a07687c0f920a5dd9ce4cfb [file] [log] [blame]
Greg Kroah-Hartman6f52b162017-11-01 15:08:43 +01001/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3 * include/linux/bfs_fs.h - BFS data structures on disk.
4 * Copyright (C) 1999 Tigran Aivazian <tigran@veritas.com>
5 */
6
7#ifndef _LINUX_BFS_FS_H
8#define _LINUX_BFS_FS_H
9
Jaswinder Singh Rajput1da9ebd2009-01-30 20:34:15 +053010#include <linux/types.h>
11
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#define BFS_BSIZE_BITS 9
13#define BFS_BSIZE (1<<BFS_BSIZE_BITS)
14
15#define BFS_MAGIC 0x1BADFACE
16#define BFS_ROOT_INO 2
17#define BFS_INODES_PER_BLOCK 8
18
19/* SVR4 vnode type values (bfs_inode->i_vtype) */
Andrew Stribblehillfac92be2005-09-09 13:02:04 -070020#define BFS_VDIR 2L
21#define BFS_VREG 1L
22
Linus Torvalds1da177e2005-04-16 15:20:36 -070023/* BFS inode layout on disk */
24struct bfs_inode {
Alexey Dobriyance0fe7e2005-10-04 17:43:06 +010025 __le16 i_ino;
Linus Torvalds1da177e2005-04-16 15:20:36 -070026 __u16 i_unused;
Alexey Dobriyance0fe7e2005-10-04 17:43:06 +010027 __le32 i_sblock;
28 __le32 i_eblock;
29 __le32 i_eoffset;
30 __le32 i_vtype;
31 __le32 i_mode;
32 __le32 i_uid;
33 __le32 i_gid;
34 __le32 i_nlink;
35 __le32 i_atime;
36 __le32 i_mtime;
37 __le32 i_ctime;
Linus Torvalds1da177e2005-04-16 15:20:36 -070038 __u32 i_padding[4];
39};
40
41#define BFS_NAMELEN 14
42#define BFS_DIRENT_SIZE 16
43#define BFS_DIRS_PER_BLOCK 32
44
45struct bfs_dirent {
Alexey Dobriyance0fe7e2005-10-04 17:43:06 +010046 __le16 ino;
Linus Torvalds1da177e2005-04-16 15:20:36 -070047 char name[BFS_NAMELEN];
48};
49
50/* BFS superblock layout on disk */
51struct bfs_super_block {
Alexey Dobriyance0fe7e2005-10-04 17:43:06 +010052 __le32 s_magic;
53 __le32 s_start;
54 __le32 s_end;
55 __le32 s_from;
56 __le32 s_to;
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 __s32 s_bfrom;
58 __s32 s_bto;
59 char s_fsname[6];
60 char s_volume[6];
61 __u32 s_padding[118];
62};
63
Linus Torvalds1da177e2005-04-16 15:20:36 -070064
65#define BFS_OFF2INO(offset) \
66 ((((offset) - BFS_BSIZE) / sizeof(struct bfs_inode)) + BFS_ROOT_INO)
67
68#define BFS_INO2OFF(ino) \
69 ((__u32)(((ino) - BFS_ROOT_INO) * sizeof(struct bfs_inode)) + BFS_BSIZE)
Andrew Stribblehillfac92be2005-09-09 13:02:04 -070070#define BFS_NZFILESIZE(ip) \
Alexey Dobriyance0fe7e2005-10-04 17:43:06 +010071 ((le32_to_cpu((ip)->i_eoffset) + 1) - le32_to_cpu((ip)->i_sblock) * BFS_BSIZE)
Linus Torvalds1da177e2005-04-16 15:20:36 -070072
Andrew Stribblehillfac92be2005-09-09 13:02:04 -070073#define BFS_FILESIZE(ip) \
74 ((ip)->i_sblock == 0 ? 0 : BFS_NZFILESIZE(ip))
75
76#define BFS_FILEBLOCKS(ip) \
Alexey Dobriyance0fe7e2005-10-04 17:43:06 +010077 ((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 -070078#define BFS_UNCLEAN(bfs_sb, sb) \
Linus Torvalds1751e8a2017-11-27 13:05:09 -080079 ((le32_to_cpu(bfs_sb->s_from) != -1) && (le32_to_cpu(bfs_sb->s_to) != -1) && !(sb->s_flags & SB_RDONLY))
Andrew Stribblehillfac92be2005-09-09 13:02:04 -070080
Linus Torvalds1da177e2005-04-16 15:20:36 -070081
82#endif /* _LINUX_BFS_FS_H */