]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - include/libxfs.h
Userspace support for lazy superblock counters
[thirdparty/xfsprogs-dev.git] / include / libxfs.h
CommitLineData
2bd0ea18 1/*
f302e9e4
NS
2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
2bd0ea18 4 *
f302e9e4
NS
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
2bd0ea18
NS
7 * published by the Free Software Foundation.
8 *
f302e9e4
NS
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
2bd0ea18 13 *
f302e9e4
NS
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2bd0ea18
NS
17 */
18#ifndef __LIBXFS_H__
19#define __LIBXFS_H__
20
2b288ccf
NS
21#define XFS_BIG_INUMS 1
22#define XFS_BIG_BLKNOS 1
23
2e542de0 24#include <xfs/platform_defs.h>
2bd0ea18 25
5eb668b2 26#include <pthread.h>
f5015c24 27#include <xfs/list.h>
f1b058f9
NS
28#include <xfs/cache.h>
29
2e542de0
NS
30#include <xfs/xfs_fs.h>
31#include <xfs/xfs_types.h>
32#include <xfs/xfs_arch.h>
2e542de0
NS
33#include <xfs/xfs_bit.h>
34#include <xfs/xfs_inum.h>
f302e9e4 35#include <xfs/xfs_sb.h>
2e542de0 36#include <xfs/xfs_ag.h>
f302e9e4
NS
37#include <xfs/xfs_dir2.h>
38#include <xfs/xfs_mount.h>
2e542de0
NS
39#include <xfs/xfs_da_btree.h>
40#include <xfs/xfs_bmap_btree.h>
41#include <xfs/xfs_alloc_btree.h>
42#include <xfs/xfs_ialloc_btree.h>
2e542de0 43#include <xfs/xfs_dir_sf.h>
2e542de0
NS
44#include <xfs/xfs_dir2_sf.h>
45#include <xfs/xfs_attr_sf.h>
46#include <xfs/xfs_dinode.h>
2e542de0
NS
47#include <xfs/xfs_inode.h>
48#include <xfs/xfs_buf_item.h>
49#include <xfs/xfs_inode_item.h>
f302e9e4
NS
50#include <xfs/xfs_alloc.h>
51#include <xfs/xfs_btree.h>
2e542de0 52#include <xfs/xfs_bmap.h>
f302e9e4 53
2bd0ea18 54
b391b7cd
NS
55#ifndef XFS_SUPER_MAGIC
56#define XFS_SUPER_MAGIC 0x58465342
57#endif
58
a580302f
ES
59#define xfs_isset(a,i) ((a)[(i)/(sizeof((a))*NBBY)] & (1<<((i)%(sizeof((a))*NBBY))))
60
2bd0ea18
NS
61/*
62 * Argument structure for libxfs_init().
63 */
64typedef struct {
dfc130f3
RC
65 /* input parameters */
66 char *volname; /* pathname of volume */
67 char *dname; /* pathname of data "subvolume" */
68 char *logname; /* pathname of log "subvolume" */
69 char *rtname; /* pathname of realtime "subvolume" */
70 int isreadonly; /* filesystem is only read in applic */
b74a1f6a 71 int isdirect; /* we can attempt to use direct I/O */
dfc130f3
RC
72 int disfile; /* data "subvolume" is a regular file */ int dcreat; /* try to create data subvolume */
73 int lisfile; /* log "subvolume" is a regular file */
74 int lcreat; /* try to create log subvolume */
75 int risfile; /* realtime "subvolume" is a reg file */ int rcreat; /* try to create realtime subvolume */
74668075 76 int setblksize; /* attempt to set device blksize */
dfc130f3
RC
77 /* output results */
78 dev_t ddev; /* device for data subvolume */
79 dev_t logdev; /* device for log subvolume */
80 dev_t rtdev; /* device for realtime subvolume */
81 long long dsize; /* size of data subvolume (BBs) */
82 long long logBBsize; /* size of log subvolume (BBs) */
83 /* (blocks allocated for use as
84 * log is stored in mount structure) */
74668075
NS
85 long long logBBstart; /* start block of log subvolume (BBs) */
86 long long rtsize; /* size of realtime subvolume (BBs) */
87 int dbsize; /* data subvolume device blksize */
88 int lbsize; /* log subvolume device blksize */
89 int rtbsize; /* realtime subvolume device blksize */
dfc130f3
RC
90 int dfd; /* data subvolume file descriptor */
91 int logfd; /* log subvolume file descriptor */
92 int rtfd; /* realtime subvolume file descriptor */
2bd0ea18
NS
93} libxfs_init_t;
94
9440d84d
NS
95#define LIBXFS_EXIT_ON_FAILURE 0x0001 /* exit the program if a call fails */
96#define LIBXFS_ISREADONLY 0x0002 /* disallow all mounted filesystems */
97#define LIBXFS_ISINACTIVE 0x0004 /* allow mounted only if mounted ro */
7eb6693f
NS
98#define LIBXFS_DANGEROUSLY 0x0008 /* repairing a device mounted ro */
99#define LIBXFS_EXCLUSIVELY 0x0010 /* disallow other accesses (O_EXCL) */
b74a1f6a 100#define LIBXFS_DIRECT 0x0020 /* can use direct I/O, not buffered */
2bd0ea18
NS
101
102extern char *progname;
103extern int libxfs_init (libxfs_init_t *);
f1b058f9 104extern void libxfs_destroy (void);
2bd0ea18 105extern int libxfs_device_to_fd (dev_t);
c5907b96 106extern dev_t libxfs_device_open (char *, int, int, int);
2bd0ea18
NS
107extern void libxfs_device_zero (dev_t, xfs_daddr_t, uint);
108extern void libxfs_device_close (dev_t);
b74a1f6a 109extern int libxfs_device_alignment (void);
b6281496 110extern void libxfs_report(FILE *);
2bd0ea18
NS
111
112/* check or write log footer: specify device, log size in blocks & uuid */
989b74bc
NS
113typedef xfs_caddr_t (libxfs_get_block_t)(xfs_caddr_t, int, void *);
114
73bf5988
SL
115extern int libxfs_log_clear (dev_t, xfs_daddr_t, uint, uuid_t *,
116 int, int, int);
989b74bc
NS
117extern int libxfs_log_header (xfs_caddr_t, uuid_t *, int, int, int,
118 libxfs_get_block_t *, void *);
119
2bd0ea18 120
dfc130f3 121/*
2bd0ea18
NS
122 * Define a user-level mount structure with all we need
123 * in order to make use of the numerous XFS_* macros.
124 */
125struct xfs_inode;
126typedef struct xfs_mount {
127 xfs_sb_t m_sb; /* copy of fs superblock */
062998e3 128 char *m_fsname; /* filesystem name */
2bd0ea18
NS
129 int m_bsize; /* fs logical block size */
130 xfs_agnumber_t m_agfrotor; /* last ag where space found */
131 xfs_agnumber_t m_agirotor; /* last ag dir inode alloced */
b391b7cd 132 xfs_agnumber_t m_maxagi; /* highest inode alloc group */
2bd0ea18
NS
133 uint m_rsumlevels; /* rt summary levels */
134 uint m_rsumsize; /* size of rt summary, bytes */
135 struct xfs_inode *m_rbmip; /* pointer to bitmap inode */
136 struct xfs_inode *m_rsumip; /* pointer to summary inode */
137 struct xfs_inode *m_rootip; /* pointer to root directory */
138 dev_t m_dev;
139 dev_t m_logdev;
140 dev_t m_rtdev;
141 __uint8_t m_dircook_elog; /* log d-cookie entry bits */
142 __uint8_t m_blkbit_log; /* blocklog + NBBY */
143 __uint8_t m_blkbb_log; /* blocklog - BBSHIFT */
9440d84d 144 __uint8_t m_sectbb_log; /* sectorlog - BBSHIFT */
2bd0ea18
NS
145 __uint8_t m_agno_log; /* log #ag's */
146 __uint8_t m_agino_log; /* #bits for agino in inum */
147 __uint16_t m_inode_cluster_size;/* min inode buf size */
148 uint m_blockmask; /* sb_blocksize-1 */
149 uint m_blockwsize; /* sb_blocksize in words */
150 uint m_blockwmask; /* blockwsize-1 */
151 uint m_alloc_mxr[2]; /* XFS_ALLOC_BLOCK_MAXRECS */
152 uint m_alloc_mnr[2]; /* XFS_ALLOC_BLOCK_MINRECS */
153 uint m_bmap_dmxr[2]; /* XFS_BMAP_BLOCK_DMAXRECS */
154 uint m_bmap_dmnr[2]; /* XFS_BMAP_BLOCK_DMINRECS */
155 uint m_inobt_mxr[2]; /* XFS_INOBT_BLOCK_MAXRECS */
156 uint m_inobt_mnr[2]; /* XFS_INOBT_BLOCK_MINRECS */
157 uint m_ag_maxlevels; /* XFS_AG_MAXLEVELS */
158 uint m_bm_maxlevels[2]; /* XFS_BM_MAXLEVELS */
159 uint m_in_maxlevels; /* XFS_IN_MAXLEVELS */
160 xfs_perag_t *m_perag; /* per-ag accounting info */
161 uint m_flags; /* global mount flags */
162 uint m_qflags; /* quota status flags */
163 uint m_attroffset; /* inode attribute offset */
6bef826c
NS
164 uint m_dir_node_ents; /* #entries in a dir danode */
165 uint m_attr_node_ents; /* #entries in attr danode */
2bd0ea18
NS
166 int m_ialloc_inos; /* inodes in inode allocation */
167 int m_ialloc_blks; /* blocks in inode allocation */
168 int m_litino; /* size of inode union area */
169 int m_inoalign_mask;/* mask sb_inoalignmt if used */
170 xfs_trans_reservations_t m_reservations;/* precomputed res values */
171 __uint64_t m_maxicount; /* maximum inode count */
172 int m_dalign; /* stripe unit */
173 int m_swidth; /* stripe width */
174 int m_sinoalign; /* stripe unit inode alignmnt */
57c9fccb 175 int m_attr_magicpct;/* 37% of the blocksize */
2bd0ea18
NS
176 int m_dir_magicpct; /* 37% of the dir blocksize */
177 __uint8_t m_dirversion; /* 1 or 2 */
178 int m_dirblksize; /* directory block sz--bytes */
179 int m_dirblkfsbs; /* directory block sz--fsbs */
180 xfs_dablk_t m_dirdatablk; /* blockno of dir data v2 */
181 xfs_dablk_t m_dirleafblk; /* blockno of dir non-data v2 */
182 xfs_dablk_t m_dirfreeblk; /* blockno of dirfreeindex v2 */
183} xfs_mount_t;
57c9fccb 184#define XFS_DIR_IS_V1(mp) ((mp)->m_dirversion == 1)
f302e9e4 185#define XFS_DIR_IS_V2(mp) ((mp)->m_dirversion == 2)
2bd0ea18 186
6239071d
NS
187#define LIBXFS_MOUNT_ROOTINOS 0x0001
188#define LIBXFS_MOUNT_DEBUGGER 0x0002
189#define LIBXFS_MOUNT_32BITINODES 0x0004
190#define LIBXFS_MOUNT_32BITINOOPT 0x0008
191#define LIBXFS_MOUNT_COMPAT_ATTR 0x0010
2bd0ea18 192
f1b058f9
NS
193#define LIBXFS_IHASHSIZE(sbp) (1<<16) /* tweak based on icount? */
194#define LIBXFS_BHASHSIZE(sbp) (1<<16) /* ditto, on blocks used? */
195
2bd0ea18
NS
196extern xfs_mount_t *libxfs_mount (xfs_mount_t *, xfs_sb_t *,
197 dev_t, dev_t, dev_t, int);
198extern void libxfs_mount_common (xfs_mount_t *, xfs_sb_t *);
062998e3 199extern xfs_agnumber_t libxfs_initialize_perag (xfs_mount_t *, xfs_agnumber_t);
cdded3d8 200extern int libxfs_initialize_perag_data (xfs_mount_t *, xfs_agnumber_t);
2bd0ea18
NS
201extern void libxfs_umount (xfs_mount_t *);
202extern int libxfs_rtmount_init (xfs_mount_t *);
f1b058f9 203extern void libxfs_rtmount_destroy (xfs_mount_t *);
2bd0ea18
NS
204extern void libxfs_alloc_compute_maxlevels (xfs_mount_t *);
205extern void libxfs_bmap_compute_maxlevels (xfs_mount_t *, int);
206extern void libxfs_ialloc_compute_maxlevels (xfs_mount_t *);
207extern void libxfs_trans_init (xfs_mount_t *);
208
209
210/*
211 * Simple I/O interface
212 */
213typedef struct xfs_buf {
f1b058f9
NS
214 struct cache_node b_node;
215 unsigned int b_flags;
216 xfs_daddr_t b_blkno;
217 unsigned b_bcount;
218 dev_t b_dev;
219 void *b_fsprivate;
220 void *b_fsprivate2;
221 void *b_fsprivate3;
222 char *b_addr;
2bd0ea18 223} xfs_buf_t;
f1b058f9
NS
224
225enum xfs_buf_flags_t { /* b_flags bits */
226 LIBXFS_B_EXIT = 0x0001, /* ==LIBXFS_EXIT_ON_FAILURE */
227 LIBXFS_B_DIRTY = 0x0002, /* buffer has been modified */
228 LIBXFS_B_STALE = 0x0004, /* buffer marked as invalid */
9f38f08d 229 LIBXFS_B_UPTODATE = 0x0008 /* buffer is sync'd to disk */
f1b058f9
NS
230};
231
2bd0ea18
NS
232#define XFS_BUF_PTR(bp) ((bp)->b_addr)
233#define xfs_buf_offset(bp, offset) (XFS_BUF_PTR(bp) + (offset))
234#define XFS_BUF_ADDR(bp) ((bp)->b_blkno)
57c9fccb 235#define XFS_BUF_SIZE(bp) ((bp)->b_bcount)
2bd0ea18
NS
236#define XFS_BUF_COUNT(bp) ((bp)->b_bcount)
237#define XFS_BUF_TARGET(bp) ((bp)->b_dev)
238#define XFS_BUF_SET_PTR(bp,p,cnt) ((bp)->b_addr = (char *)(p)); \
239 XFS_BUF_SETCOUNT(bp,cnt)
240#define XFS_BUF_SET_ADDR(bp,blk) ((bp)->b_blkno = (blk))
241#define XFS_BUF_SETCOUNT(bp,cnt) ((bp)->b_bcount = (cnt))
242
243#define XFS_BUF_FSPRIVATE(bp,type) ((type)(bp)->b_fsprivate)
244#define XFS_BUF_SET_FSPRIVATE(bp,val) (bp)->b_fsprivate = (void *)(val)
245#define XFS_BUF_FSPRIVATE2(bp,type) ((type)(bp)->b_fsprivate2)
246#define XFS_BUF_SET_FSPRIVATE2(bp,val) (bp)->b_fsprivate2 = (void *)(val)
247#define XFS_BUF_FSPRIVATE3(bp,type) ((type)(bp)->b_fsprivate3)
248#define XFS_BUF_SET_FSPRIVATE3(bp,val) (bp)->b_fsprivate3 = (void *)(val)
249
2bd0ea18 250extern xfs_buf_t *libxfs_getsb (xfs_mount_t *, int);
f1b058f9 251extern xfs_buf_t *libxfs_readbuf (dev_t, xfs_daddr_t, int, int);
2bd0ea18
NS
252extern int libxfs_readbufr (dev_t, xfs_daddr_t, xfs_buf_t *, int, int);
253extern int libxfs_writebuf (xfs_buf_t *, int);
f1b058f9 254extern int libxfs_writebufr (xfs_buf_t *);
2bd0ea18 255extern int libxfs_writebuf_int (xfs_buf_t *, int);
f1b058f9
NS
256
257/* Buffer Cache Interfaces */
258extern struct cache *libxfs_bcache;
259extern struct cache_operations libxfs_bcache_operations;
260extern void libxfs_bcache_purge (void);
33165ec3 261extern void libxfs_bcache_flush (void);
f1b058f9 262extern xfs_buf_t *libxfs_getbuf (dev_t, xfs_daddr_t, int);
2bd0ea18 263extern void libxfs_putbuf (xfs_buf_t *);
f1b058f9 264extern void libxfs_purgebuf (xfs_buf_t *);
2bd0ea18 265
e6b359b3
NS
266/* Buffer (Raw) Interfaces */
267extern xfs_buf_t *libxfs_getbufr (dev_t, xfs_daddr_t, int);
268extern void libxfs_putbufr (xfs_buf_t *);
269
9f38f08d
MV
270extern int libxfs_bhash_size;
271extern int libxfs_ihash_size;
272
57c9fccb
NS
273#define LIBXFS_BREAD 0x1
274#define LIBXFS_BWRITE 0x2
275#define LIBXFS_BZERO 0x4
276
277extern void libxfs_iomove (xfs_buf_t *, uint, int, void *, int);
278
2bd0ea18
NS
279
280/*
281 * Transaction interface
282 */
283
284typedef struct xfs_log_item {
285 struct xfs_log_item_desc *li_desc; /* ptr to current desc*/
286 struct xfs_mount *li_mountp; /* ptr to fs mount */
287 uint li_type; /* item type */
288} xfs_log_item_t;
289
290typedef struct xfs_inode_log_item {
291 xfs_log_item_t ili_item; /* common portion */
292 struct xfs_inode *ili_inode; /* inode pointer */
293 unsigned short ili_flags; /* misc flags */
294 unsigned int ili_last_fields; /* fields when flushed*/
295 xfs_inode_log_format_t ili_format; /* logged structure */
296} xfs_inode_log_item_t;
297
298typedef struct xfs_buf_log_item {
299 xfs_log_item_t bli_item; /* common item structure */
300 struct xfs_buf *bli_buf; /* real buffer pointer */
301 unsigned int bli_flags; /* misc flags */
302 unsigned int bli_recur; /* recursion count */
303 xfs_buf_log_format_t bli_format; /* in-log header */
304} xfs_buf_log_item_t;
305
2e542de0 306#include <xfs/xfs_trans.h>
2bd0ea18
NS
307
308typedef struct xfs_trans {
309 unsigned int t_type; /* transaction type */
ca86e759
NS
310 unsigned int t_log_res; /* amt of log space resvd */
311 unsigned int t_log_count; /* count for perm log res */
2bd0ea18
NS
312 xfs_mount_t *t_mountp; /* ptr to fs mount struct */
313 unsigned int t_flags; /* misc flags */
314 long t_icount_delta; /* superblock icount change */
315 long t_ifree_delta; /* superblock ifree change */
316 long t_fdblocks_delta; /* superblock fdblocks chg */
317 long t_frextents_delta; /* superblock freextents chg */
318 unsigned int t_items_free; /* log item descs free */
319 xfs_log_item_chunk_t t_items; /* first log item desc chunk */
320} xfs_trans_t;
321
322extern xfs_trans_t *libxfs_trans_alloc (xfs_mount_t *, int);
323extern xfs_trans_t *libxfs_trans_dup (xfs_trans_t *);
324extern int libxfs_trans_reserve (xfs_trans_t *, uint,uint,uint,uint,uint);
325extern int libxfs_trans_commit (xfs_trans_t *, uint, xfs_lsn_t *);
326extern void libxfs_trans_cancel (xfs_trans_t *, int);
327extern void libxfs_mod_sb (xfs_trans_t *, __int64_t);
f1b058f9 328extern xfs_buf_t *libxfs_trans_getsb (xfs_trans_t *, xfs_mount_t *, int);
2bd0ea18
NS
329
330extern int libxfs_trans_iget (xfs_mount_t *, xfs_trans_t *, xfs_ino_t,
46eca962 331 uint, uint, struct xfs_inode **);
2bd0ea18
NS
332extern void libxfs_trans_iput(xfs_trans_t *, struct xfs_inode *, uint);
333extern void libxfs_trans_ijoin (xfs_trans_t *, struct xfs_inode *, uint);
334extern void libxfs_trans_ihold (xfs_trans_t *, struct xfs_inode *);
335extern void libxfs_trans_log_inode (xfs_trans_t *, struct xfs_inode *,
336 uint);
337
338extern void libxfs_trans_brelse (xfs_trans_t *, struct xfs_buf *);
339extern void libxfs_trans_binval (xfs_trans_t *, struct xfs_buf *);
340extern void libxfs_trans_bjoin (xfs_trans_t *, struct xfs_buf *);
341extern void libxfs_trans_bhold (xfs_trans_t *, struct xfs_buf *);
342extern void libxfs_trans_log_buf (xfs_trans_t *, struct xfs_buf *,
343 uint, uint);
344extern xfs_buf_t *libxfs_trans_get_buf (xfs_trans_t *, dev_t,
345 xfs_daddr_t, int, uint);
346extern int libxfs_trans_read_buf (xfs_mount_t *, xfs_trans_t *, dev_t,
347 xfs_daddr_t, int, uint, struct xfs_buf **);
348
349
350/*
351 * Simple memory interface
352 */
353typedef struct xfs_zone {
836f654f
NS
354 int zone_unitsize; /* Size in bytes of zone unit */
355 char *zone_name; /* tag name */
356 int allocated; /* debug: How many currently allocated */
2bd0ea18
NS
357} xfs_zone_t;
358
359extern xfs_zone_t *libxfs_zone_init (int, char *);
360extern void *libxfs_zone_zalloc (xfs_zone_t *);
361extern void libxfs_zone_free (xfs_zone_t *, void *);
362extern void *libxfs_malloc (size_t);
363extern void libxfs_free (void *);
364extern void *libxfs_realloc (void *, size_t);
365
366
367/*
368 * Inode interface
369 */
2bd0ea18 370typedef struct xfs_inode {
f1b058f9 371 struct cache_node i_node;
2bd0ea18
NS
372 xfs_mount_t *i_mount; /* fs mount struct ptr */
373 xfs_ino_t i_ino; /* inode number (agno/agino) */
374 xfs_daddr_t i_blkno; /* blkno of inode buffer */
375 dev_t i_dev; /* dev for this inode */
376 ushort i_len; /* len of inode buffer */
377 ushort i_boffset; /* off of inode in buffer */
378 xfs_ifork_t *i_afp; /* attribute fork pointer */
379 xfs_ifork_t i_df; /* data fork */
f1b058f9
NS
380 xfs_trans_t *i_transp; /* ptr to owning transaction */
381 xfs_inode_log_item_t *i_itemp; /* logging information */
2bd0ea18
NS
382 unsigned int i_delayed_blks; /* count of delay alloc blks */
383 xfs_dinode_core_t i_d; /* most of ondisk inode */
384} xfs_inode_t;
385
57c9fccb
NS
386#define LIBXFS_ATTR_ROOT 0x0002 /* use attrs in root namespace */
387#define LIBXFS_ATTR_SECURE 0x0008 /* use attrs in security namespace */
388#define LIBXFS_ATTR_CREATE 0x0010 /* create, but fail if attr exists */
389#define LIBXFS_ATTR_REPLACE 0x0020 /* set, but fail if attr not exists */
390
9f064b7e 391typedef struct cred {
14290264
NS
392 uid_t cr_uid;
393 gid_t cr_gid;
394} cred_t;
395
2bd0ea18 396extern int libxfs_inode_alloc (xfs_trans_t **, xfs_inode_t *, mode_t,
9f064b7e
NS
397 nlink_t, xfs_dev_t, struct cred *,
398 struct fsxattr *, xfs_inode_t **);
2bd0ea18
NS
399extern void libxfs_trans_inode_alloc_buf (xfs_trans_t *, xfs_buf_t *);
400
401extern void libxfs_idata_realloc (xfs_inode_t *, int, int);
33a4da69 402extern void libxfs_idestroy_fork (xfs_inode_t *, int);
f1b058f9 403extern int libxfs_iformat (xfs_inode_t *, xfs_dinode_t *);
2bd0ea18
NS
404extern void libxfs_ichgtime (xfs_inode_t *, int);
405extern int libxfs_iflush_int (xfs_inode_t *, xfs_buf_t *);
406extern int libxfs_itobp (xfs_mount_t *, xfs_trans_t *, xfs_inode_t *,
407 xfs_dinode_t **, xfs_buf_t **, xfs_daddr_t);
f1b058f9
NS
408extern int libxfs_iread (xfs_mount_t *, xfs_trans_t *, xfs_ino_t,
409 xfs_inode_t *, xfs_daddr_t);
410
411/* Inode Cache Interfaces */
412extern struct cache *libxfs_icache;
413extern struct cache_operations libxfs_icache_operations;
414extern void libxfs_icache_purge (void);
2bd0ea18
NS
415extern int libxfs_iget (xfs_mount_t *, xfs_trans_t *, xfs_ino_t,
416 uint, xfs_inode_t **, xfs_daddr_t);
417extern void libxfs_iput (xfs_inode_t *, uint);
418
419
420/*
421 * Directory interface
422 */
f302e9e4
NS
423#include <xfs/xfs_dir_leaf.h>
424#include <xfs/xfs_dir2_data.h>
425#include <xfs/xfs_dir2_leaf.h>
426#include <xfs/xfs_dir2_block.h>
427#include <xfs/xfs_dir2_node.h>
428
2bd0ea18
NS
429extern void libxfs_dir_mount (xfs_mount_t *);
430extern void libxfs_dir2_mount (xfs_mount_t *);
431extern int libxfs_dir_init (xfs_trans_t *, xfs_inode_t *, xfs_inode_t *);
432extern int libxfs_dir2_init (xfs_trans_t *, xfs_inode_t *, xfs_inode_t *);
04d3ada9 433extern int libxfs_dir_createname (xfs_trans_t *, xfs_inode_t *, uchar_t *,
2bd0ea18
NS
434 int, xfs_ino_t, xfs_fsblock_t *,
435 xfs_bmap_free_t *, xfs_extlen_t);
04d3ada9 436extern int libxfs_dir2_createname (xfs_trans_t *, xfs_inode_t *, uchar_t *,
2bd0ea18
NS
437 int, xfs_ino_t, xfs_fsblock_t *,
438 xfs_bmap_free_t *, xfs_extlen_t);
439extern int libxfs_dir_lookup (xfs_trans_t *, xfs_inode_t *,
04d3ada9 440 uchar_t *, int, xfs_ino_t *);
2bd0ea18 441extern int libxfs_dir2_lookup (xfs_trans_t *, xfs_inode_t *,
04d3ada9 442 uchar_t *, int, xfs_ino_t *);
2bd0ea18 443extern int libxfs_dir_replace (xfs_trans_t *, xfs_inode_t *,
04d3ada9 444 uchar_t *, int, xfs_ino_t, xfs_fsblock_t *,
2bd0ea18
NS
445 xfs_bmap_free_t *, xfs_extlen_t);
446extern int libxfs_dir2_replace (xfs_trans_t *, xfs_inode_t *,
04d3ada9 447 uchar_t *, int, xfs_ino_t, xfs_fsblock_t *,
2bd0ea18
NS
448 xfs_bmap_free_t *, xfs_extlen_t);
449extern int libxfs_dir_removename (xfs_trans_t *, xfs_inode_t *,
04d3ada9 450 uchar_t *, int, xfs_ino_t, xfs_fsblock_t *,
2bd0ea18
NS
451 xfs_bmap_free_t *, xfs_extlen_t);
452extern int libxfs_dir2_removename (xfs_trans_t *, xfs_inode_t *,
04d3ada9 453 uchar_t *, int, xfs_ino_t, xfs_fsblock_t *,
2bd0ea18
NS
454 xfs_bmap_free_t *, xfs_extlen_t);
455extern int libxfs_dir_bogus_removename (xfs_trans_t *, xfs_inode_t *,
04d3ada9 456 uchar_t *, xfs_fsblock_t *, xfs_bmap_free_t *,
2bd0ea18
NS
457 xfs_extlen_t, xfs_dahash_t, int);
458extern int libxfs_dir2_bogus_removename (xfs_trans_t *, xfs_inode_t *,
04d3ada9 459 uchar_t *, xfs_fsblock_t *, xfs_bmap_free_t *,
2bd0ea18
NS
460 xfs_extlen_t, xfs_dahash_t, int);
461
462
463/*
464 * Block map interface
465 */
466extern int libxfs_bmapi (xfs_trans_t *, xfs_inode_t *, xfs_fileoff_t,
467 xfs_filblks_t, int, xfs_fsblock_t *,
468 xfs_extlen_t, xfs_bmbt_irec_t *, int *,
469 xfs_bmap_free_t *);
cb5b3ef4
MV
470extern int libxfs_bmapi_single(xfs_trans_t *, xfs_inode_t *, int,
471 xfs_fsblock_t *, xfs_fileoff_t);
2bd0ea18
NS
472extern int libxfs_bmap_finish (xfs_trans_t **, xfs_bmap_free_t *,
473 xfs_fsblock_t, int *);
33165ec3 474extern void libxfs_bmap_cancel(xfs_bmap_free_t *);
2bd0ea18
NS
475extern int libxfs_bmap_next_offset (xfs_trans_t *, xfs_inode_t *,
476 xfs_fileoff_t *, int);
33165ec3
BN
477extern int libxfs_bmap_last_offset(xfs_trans_t *, xfs_inode_t *,
478 xfs_fileoff_t *, int);
2bd0ea18
NS
479extern int libxfs_bunmapi (xfs_trans_t *, xfs_inode_t *, xfs_fileoff_t,
480 xfs_filblks_t, int, xfs_extnum_t,
481 xfs_fsblock_t *, xfs_bmap_free_t *, int *);
482extern void libxfs_bmap_del_free (xfs_bmap_free_t *,
483 xfs_bmap_free_item_t *, xfs_bmap_free_item_t *);
484
485
486/*
487 * All other routines we want to keep common...
488 */
489
490extern int libxfs_highbit32 (__uint32_t);
491extern int libxfs_highbit64 (__uint64_t);
492extern uint libxfs_da_log2_roundup (uint);
493
46eca962 494extern void libxfs_xlate_sb (void *, xfs_sb_t *, int, __int64_t);
2bd0ea18 495extern void libxfs_xlate_dinode_core (xfs_caddr_t buf,
46eca962 496 xfs_dinode_core_t *, int);
2bd0ea18
NS
497
498extern int libxfs_alloc_fix_freelist (xfs_alloc_arg_t *, int);
499extern int libxfs_alloc_file_space (xfs_inode_t *, xfs_off_t,
500 xfs_off_t, int, int);
501
80ce5460 502extern xfs_dahash_t libxfs_da_hashname (const uchar_t *, int);
ca86e759 503extern int libxfs_attr_leaf_newentsize (int, int, int, int *);
6239071d
NS
504extern int libxfs_attr_set_int (xfs_inode_t*, const char *, int, char *,
505 int, int);
506extern int libxfs_attr_remove_int (xfs_inode_t *, const char *, int, int);
57c9fccb 507
2bd0ea18 508
93cc2301 509extern void libxfs_bmbt_get_all (xfs_bmbt_rec_t *, xfs_bmbt_irec_t *);
b34acbba 510#if __BYTE_ORDER != __BIG_ENDIAN
f9e56f43
NS
511extern void libxfs_bmbt_disk_get_all (xfs_bmbt_rec_t *, xfs_bmbt_irec_t *);
512#else
513# define libxfs_bmbt_disk_get_all(r,s) libxfs_bmbt_get_all(r,s)
514#endif
2bd0ea18
NS
515
516extern int libxfs_free_extent (xfs_trans_t *, xfs_fsblock_t, xfs_extlen_t);
517extern int libxfs_rtfree_extent (xfs_trans_t *, xfs_rtblock_t,
518 xfs_extlen_t);
519
520/* Directory/Attribute routines used by xfs_repair */
521extern void libxfs_da_bjoin (xfs_trans_t *, xfs_dabuf_t *);
522extern int libxfs_da_shrink_inode (xfs_da_args_t *, xfs_dablk_t,
523 xfs_dabuf_t *);
524extern int libxfs_da_grow_inode (xfs_da_args_t *, xfs_dablk_t *);
525extern void libxfs_da_bhold (xfs_trans_t *, xfs_dabuf_t *);
526extern void libxfs_da_brelse (xfs_trans_t *, xfs_dabuf_t *);
527extern int libxfs_da_read_bufr (xfs_trans_t *, xfs_inode_t *, xfs_dablk_t,
528 xfs_daddr_t, xfs_dabuf_t **, int);
529extern int libxfs_da_read_buf (xfs_trans_t *, xfs_inode_t *,
530 xfs_dablk_t, xfs_daddr_t, xfs_dabuf_t **, int);
531extern int libxfs_da_get_buf (xfs_trans_t *, xfs_inode_t *,
532 xfs_dablk_t, xfs_daddr_t, xfs_dabuf_t **, int);
533extern void libxfs_da_log_buf (xfs_trans_t *, xfs_dabuf_t *, uint, uint);
534extern int libxfs_dir2_shrink_inode (xfs_da_args_t *, xfs_dir2_db_t,
535 xfs_dabuf_t *);
536extern int libxfs_dir2_grow_inode (xfs_da_args_t *, int, xfs_dir2_db_t *);
537extern int libxfs_dir2_isleaf (xfs_trans_t *, xfs_inode_t *, int *);
538extern int libxfs_dir2_isblock (xfs_trans_t *, xfs_inode_t *, int *);
539extern void libxfs_dir2_data_use_free (xfs_trans_t *, xfs_dabuf_t *,
540 xfs_dir2_data_unused_t *, xfs_dir2_data_aoff_t,
541 xfs_dir2_data_aoff_t, int *, int *);
542extern void libxfs_dir2_data_make_free (xfs_trans_t *, xfs_dabuf_t *,
543 xfs_dir2_data_aoff_t, xfs_dir2_data_aoff_t,
544 int *, int *);
545extern void libxfs_dir2_data_log_entry (xfs_trans_t *, xfs_dabuf_t *,
546 xfs_dir2_data_entry_t *);
547extern void libxfs_dir2_data_log_header (xfs_trans_t *, xfs_dabuf_t *);
548extern void libxfs_dir2_data_freescan (xfs_mount_t *, xfs_dir2_data_t *,
549 int *, char *);
550extern void libxfs_dir2_free_log_bests (xfs_trans_t *, xfs_dabuf_t *,
551 int, int);
552
553/* Shared utility routines */
554extern unsigned int libxfs_log2_roundup(unsigned int i);
555
1552a820
NS
556extern void cmn_err(int, char *, ...);
557enum ce { CE_DEBUG, CE_CONT, CE_NOTE, CE_WARN, CE_ALERT, CE_PANIC };
f302e9e4 558
cb5b3ef4
MV
559/* lio interface */
560/* lio_listio(3) interface (POSIX linked asynchronous I/O) */
561extern int libxfs_lio_ino_count;
562extern int libxfs_lio_dir_count;
563extern int libxfs_lio_aio_count;
564
565extern int libxfs_lio_init(void);
566extern void libxfs_lio_allocate(void);
567extern void *libxfs_get_lio_buffer(int type);
568extern void libxfs_put_lio_buffer(void *buffer);
569extern int libxfs_readbuf_list(dev_t dev, int nent, void *voidp, int type);
570
571typedef struct libxfs_lio_req {
572 xfs_daddr_t blkno;
573 int len; /* bbs */
574} libxfs_lio_req_t;
575
576#define LIBXFS_LIO_TYPE_INO 0x1
577#define LIBXFS_LIO_TYPE_DIR 0x2
578#define LIBXFS_LIO_TYPE_RAW 0x3
579
580#define LIBXFS_BBTOOFF64(bbs) (((xfs_off_t)(bbs)) << BBSHIFT)
3b6ac903 581extern int libxfs_nproc(void);
cb5b3ef4 582
f302e9e4
NS
583#include <xfs/xfs_ialloc.h>
584#include <xfs/xfs_rtalloc.h>
585
586#include <xfs/xfs_attr_leaf.h>
587#include <xfs/xfs_quota.h>
588#include <xfs/xfs_trans_space.h>
589#include <xfs/xfs_imap.h>
590#include <xfs/xfs_log.h>
591#include <xfs/xfs_log_priv.h>
592
2bd0ea18 593#endif /* __LIBXFS_H__ */