]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - libfrog/fsgeom.h
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved.
5 #ifndef __LIBFROG_FSGEOM_H__
6 #define __LIBFROG_FSGEOM_H__
8 void xfs_report_geom(struct xfs_fsop_geom
*geo
, const char *mntpoint
,
9 const char *logname
, const char *rtname
);
10 int xfrog_geometry(int fd
, struct xfs_fsop_geom
*fsgeo
);
13 * Structure for recording whatever observations we want about the level of
14 * xfs runtime support for this fd. Right now we only store the fd and fs
18 /* ioctl file descriptor */
21 /* filesystem geometry */
22 struct xfs_fsop_geom fsgeom
;
24 /* log2 of sb_agblocks (rounded up) */
25 unsigned int agblklog
;
27 /* log2 of sb_blocksize */
28 unsigned int blocklog
;
30 /* log2 of sb_inodesize */
31 unsigned int inodelog
;
33 /* log2 of sb_inopblock */
34 unsigned int inopblog
;
36 /* bits for agino in inum */
37 unsigned int aginolog
;
40 /* Static initializers */
41 #define XFS_FD_INIT(_fd) { .fd = (_fd), }
42 #define XFS_FD_INIT_EMPTY XFS_FD_INIT(-1)
44 int xfd_prepare_geometry(struct xfs_fd
*xfd
);
45 int xfd_open(struct xfs_fd
*xfd
, const char *pathname
, int flags
);
46 int xfd_close(struct xfs_fd
*xfd
);
48 /* Convert AG number and AG inode number into fs inode number. */
49 static inline uint64_t
51 const struct xfs_fd
*xfd
,
55 return ((uint64_t)agno
<< xfd
->aginolog
) + agino
;
58 /* Convert fs inode number into AG number. */
59 static inline uint32_t
61 const struct xfs_fd
*xfd
,
64 return ino
>> xfd
->aginolog
;
67 /* Convert fs inode number into AG inode number. */
68 static inline uint32_t
70 const struct xfs_fd
*xfd
,
73 return ino
& ((1ULL << xfd
->aginolog
) - 1);
77 * Convert a linear fs block offset number into bytes. This is the runtime
78 * equivalent of XFS_FSB_TO_B, which means that it is /not/ for segmented fsbno
79 * format (= agno | agbno) that we use internally for the data device.
81 static inline uint64_t
83 const struct xfs_fd
*xfd
,
86 return fsb
<< xfd
->blocklog
;
90 * Convert bytes into a (rounded down) linear fs block offset number. This is
91 * the runtime equivalent of XFS_B_TO_FSBT. It does not produce segmented
92 * fsbno numbers (= agno | agbno).
94 static inline uint64_t
96 const struct xfs_fd
*xfd
,
99 return bytes
>> xfd
->blocklog
;
102 #endif /* __LIBFROG_FSGEOM_H__ */