]>
Commit | Line | Data |
---|---|---|
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 | 17 | */ |
5e656dbb | 18 | |
2bd0ea18 NS |
19 | #ifndef __LIBXFS_H__ |
20 | #define __LIBXFS_H__ | |
21 | ||
2b288ccf NS |
22 | #define XFS_BIG_INUMS 1 |
23 | #define XFS_BIG_BLKNOS 1 | |
24 | ||
2e542de0 | 25 | #include <xfs/platform_defs.h> |
2bd0ea18 | 26 | |
f5015c24 | 27 | #include <xfs/list.h> |
f1b058f9 | 28 | #include <xfs/cache.h> |
5e656dbb BN |
29 | #include <xfs/bitops.h> |
30 | #include <xfs/kmem.h> | |
31 | #include <xfs/swab.h> | |
f1b058f9 | 32 | |
2e542de0 NS |
33 | #include <xfs/xfs_fs.h> |
34 | #include <xfs/xfs_types.h> | |
35 | #include <xfs/xfs_arch.h> | |
2e542de0 NS |
36 | #include <xfs/xfs_bit.h> |
37 | #include <xfs/xfs_inum.h> | |
f302e9e4 | 38 | #include <xfs/xfs_sb.h> |
2e542de0 | 39 | #include <xfs/xfs_ag.h> |
f302e9e4 NS |
40 | #include <xfs/xfs_dir2.h> |
41 | #include <xfs/xfs_mount.h> | |
2e542de0 NS |
42 | #include <xfs/xfs_da_btree.h> |
43 | #include <xfs/xfs_bmap_btree.h> | |
44 | #include <xfs/xfs_alloc_btree.h> | |
45 | #include <xfs/xfs_ialloc_btree.h> | |
2e542de0 | 46 | #include <xfs/xfs_dir_sf.h> |
2e542de0 NS |
47 | #include <xfs/xfs_dir2_sf.h> |
48 | #include <xfs/xfs_attr_sf.h> | |
49 | #include <xfs/xfs_dinode.h> | |
2e542de0 NS |
50 | #include <xfs/xfs_inode.h> |
51 | #include <xfs/xfs_buf_item.h> | |
52 | #include <xfs/xfs_inode_item.h> | |
f302e9e4 NS |
53 | #include <xfs/xfs_alloc.h> |
54 | #include <xfs/xfs_btree.h> | |
b194c7d8 | 55 | #include <xfs/xfs_btree_trace.h> |
2e542de0 | 56 | #include <xfs/xfs_bmap.h> |
f302e9e4 | 57 | |
1167ddc4 AE |
58 | #ifndef ARRAY_SIZE |
59 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | |
60 | #endif | |
2bd0ea18 | 61 | |
b391b7cd NS |
62 | #ifndef XFS_SUPER_MAGIC |
63 | #define XFS_SUPER_MAGIC 0x58465342 | |
64 | #endif | |
65 | ||
a580302f ES |
66 | #define xfs_isset(a,i) ((a)[(i)/(sizeof((a))*NBBY)] & (1<<((i)%(sizeof((a))*NBBY)))) |
67 | ||
2bd0ea18 NS |
68 | /* |
69 | * Argument structure for libxfs_init(). | |
70 | */ | |
71 | typedef struct { | |
dfc130f3 RC |
72 | /* input parameters */ |
73 | char *volname; /* pathname of volume */ | |
74 | char *dname; /* pathname of data "subvolume" */ | |
75 | char *logname; /* pathname of log "subvolume" */ | |
76 | char *rtname; /* pathname of realtime "subvolume" */ | |
77 | int isreadonly; /* filesystem is only read in applic */ | |
b74a1f6a | 78 | int isdirect; /* we can attempt to use direct I/O */ |
d0572de5 BN |
79 | int disfile; /* data "subvolume" is a regular file */ |
80 | int dcreat; /* try to create data subvolume */ | |
dfc130f3 RC |
81 | int lisfile; /* log "subvolume" is a regular file */ |
82 | int lcreat; /* try to create log subvolume */ | |
d0572de5 BN |
83 | int risfile; /* realtime "subvolume" is a reg file */ |
84 | int rcreat; /* try to create realtime subvolume */ | |
74668075 | 85 | int setblksize; /* attempt to set device blksize */ |
d0572de5 | 86 | int usebuflock; /* lock xfs_buf_t's - for MT usage */ |
dfc130f3 RC |
87 | /* output results */ |
88 | dev_t ddev; /* device for data subvolume */ | |
89 | dev_t logdev; /* device for log subvolume */ | |
90 | dev_t rtdev; /* device for realtime subvolume */ | |
91 | long long dsize; /* size of data subvolume (BBs) */ | |
92 | long long logBBsize; /* size of log subvolume (BBs) */ | |
93 | /* (blocks allocated for use as | |
94 | * log is stored in mount structure) */ | |
74668075 NS |
95 | long long logBBstart; /* start block of log subvolume (BBs) */ |
96 | long long rtsize; /* size of realtime subvolume (BBs) */ | |
97 | int dbsize; /* data subvolume device blksize */ | |
98 | int lbsize; /* log subvolume device blksize */ | |
99 | int rtbsize; /* realtime subvolume device blksize */ | |
dfc130f3 RC |
100 | int dfd; /* data subvolume file descriptor */ |
101 | int logfd; /* log subvolume file descriptor */ | |
102 | int rtfd; /* realtime subvolume file descriptor */ | |
2bd0ea18 NS |
103 | } libxfs_init_t; |
104 | ||
9440d84d NS |
105 | #define LIBXFS_EXIT_ON_FAILURE 0x0001 /* exit the program if a call fails */ |
106 | #define LIBXFS_ISREADONLY 0x0002 /* disallow all mounted filesystems */ | |
107 | #define LIBXFS_ISINACTIVE 0x0004 /* allow mounted only if mounted ro */ | |
7eb6693f NS |
108 | #define LIBXFS_DANGEROUSLY 0x0008 /* repairing a device mounted ro */ |
109 | #define LIBXFS_EXCLUSIVELY 0x0010 /* disallow other accesses (O_EXCL) */ | |
b74a1f6a | 110 | #define LIBXFS_DIRECT 0x0020 /* can use direct I/O, not buffered */ |
2bd0ea18 NS |
111 | |
112 | extern char *progname; | |
113 | extern int libxfs_init (libxfs_init_t *); | |
f1b058f9 | 114 | extern void libxfs_destroy (void); |
2bd0ea18 | 115 | extern int libxfs_device_to_fd (dev_t); |
c5907b96 | 116 | extern dev_t libxfs_device_open (char *, int, int, int); |
2bd0ea18 NS |
117 | extern void libxfs_device_zero (dev_t, xfs_daddr_t, uint); |
118 | extern void libxfs_device_close (dev_t); | |
b74a1f6a | 119 | extern int libxfs_device_alignment (void); |
b6281496 | 120 | extern void libxfs_report(FILE *); |
fd5eda53 | 121 | extern void platform_findsizes(char *path, int fd, long long *sz, int *bsz); |
2bd0ea18 NS |
122 | |
123 | /* check or write log footer: specify device, log size in blocks & uuid */ | |
989b74bc NS |
124 | typedef xfs_caddr_t (libxfs_get_block_t)(xfs_caddr_t, int, void *); |
125 | ||
73bf5988 SL |
126 | extern int libxfs_log_clear (dev_t, xfs_daddr_t, uint, uuid_t *, |
127 | int, int, int); | |
989b74bc NS |
128 | extern int libxfs_log_header (xfs_caddr_t, uuid_t *, int, int, int, |
129 | libxfs_get_block_t *, void *); | |
130 | ||
2bd0ea18 | 131 | |
dfc130f3 | 132 | /* |
2bd0ea18 NS |
133 | * Define a user-level mount structure with all we need |
134 | * in order to make use of the numerous XFS_* macros. | |
135 | */ | |
2bd0ea18 NS |
136 | typedef struct xfs_mount { |
137 | xfs_sb_t m_sb; /* copy of fs superblock */ | |
062998e3 | 138 | char *m_fsname; /* filesystem name */ |
2bd0ea18 NS |
139 | int m_bsize; /* fs logical block size */ |
140 | xfs_agnumber_t m_agfrotor; /* last ag where space found */ | |
141 | xfs_agnumber_t m_agirotor; /* last ag dir inode alloced */ | |
b391b7cd | 142 | xfs_agnumber_t m_maxagi; /* highest inode alloc group */ |
2bd0ea18 NS |
143 | uint m_rsumlevels; /* rt summary levels */ |
144 | uint m_rsumsize; /* size of rt summary, bytes */ | |
145 | struct xfs_inode *m_rbmip; /* pointer to bitmap inode */ | |
146 | struct xfs_inode *m_rsumip; /* pointer to summary inode */ | |
147 | struct xfs_inode *m_rootip; /* pointer to root directory */ | |
148 | dev_t m_dev; | |
149 | dev_t m_logdev; | |
150 | dev_t m_rtdev; | |
151 | __uint8_t m_dircook_elog; /* log d-cookie entry bits */ | |
152 | __uint8_t m_blkbit_log; /* blocklog + NBBY */ | |
153 | __uint8_t m_blkbb_log; /* blocklog - BBSHIFT */ | |
9440d84d | 154 | __uint8_t m_sectbb_log; /* sectorlog - BBSHIFT */ |
2bd0ea18 NS |
155 | __uint8_t m_agno_log; /* log #ag's */ |
156 | __uint8_t m_agino_log; /* #bits for agino in inum */ | |
157 | __uint16_t m_inode_cluster_size;/* min inode buf size */ | |
158 | uint m_blockmask; /* sb_blocksize-1 */ | |
159 | uint m_blockwsize; /* sb_blocksize in words */ | |
160 | uint m_blockwmask; /* blockwsize-1 */ | |
161 | uint m_alloc_mxr[2]; /* XFS_ALLOC_BLOCK_MAXRECS */ | |
162 | uint m_alloc_mnr[2]; /* XFS_ALLOC_BLOCK_MINRECS */ | |
163 | uint m_bmap_dmxr[2]; /* XFS_BMAP_BLOCK_DMAXRECS */ | |
164 | uint m_bmap_dmnr[2]; /* XFS_BMAP_BLOCK_DMINRECS */ | |
165 | uint m_inobt_mxr[2]; /* XFS_INOBT_BLOCK_MAXRECS */ | |
166 | uint m_inobt_mnr[2]; /* XFS_INOBT_BLOCK_MINRECS */ | |
167 | uint m_ag_maxlevels; /* XFS_AG_MAXLEVELS */ | |
168 | uint m_bm_maxlevels[2]; /* XFS_BM_MAXLEVELS */ | |
169 | uint m_in_maxlevels; /* XFS_IN_MAXLEVELS */ | |
170 | xfs_perag_t *m_perag; /* per-ag accounting info */ | |
171 | uint m_flags; /* global mount flags */ | |
172 | uint m_qflags; /* quota status flags */ | |
173 | uint m_attroffset; /* inode attribute offset */ | |
6bef826c NS |
174 | uint m_dir_node_ents; /* #entries in a dir danode */ |
175 | uint m_attr_node_ents; /* #entries in attr danode */ | |
2bd0ea18 NS |
176 | int m_ialloc_inos; /* inodes in inode allocation */ |
177 | int m_ialloc_blks; /* blocks in inode allocation */ | |
178 | int m_litino; /* size of inode union area */ | |
179 | int m_inoalign_mask;/* mask sb_inoalignmt if used */ | |
180 | xfs_trans_reservations_t m_reservations;/* precomputed res values */ | |
181 | __uint64_t m_maxicount; /* maximum inode count */ | |
182 | int m_dalign; /* stripe unit */ | |
183 | int m_swidth; /* stripe width */ | |
184 | int m_sinoalign; /* stripe unit inode alignmnt */ | |
57c9fccb | 185 | int m_attr_magicpct;/* 37% of the blocksize */ |
2bd0ea18 | 186 | int m_dir_magicpct; /* 37% of the dir blocksize */ |
51ca7008 | 187 | const struct xfs_nameops *m_dirnameops; /* vector of dir name ops */ |
2bd0ea18 NS |
188 | int m_dirblksize; /* directory block sz--bytes */ |
189 | int m_dirblkfsbs; /* directory block sz--fsbs */ | |
190 | xfs_dablk_t m_dirdatablk; /* blockno of dir data v2 */ | |
191 | xfs_dablk_t m_dirleafblk; /* blockno of dir non-data v2 */ | |
192 | xfs_dablk_t m_dirfreeblk; /* blockno of dirfreeindex v2 */ | |
193 | } xfs_mount_t; | |
194 | ||
6239071d NS |
195 | #define LIBXFS_MOUNT_ROOTINOS 0x0001 |
196 | #define LIBXFS_MOUNT_DEBUGGER 0x0002 | |
197 | #define LIBXFS_MOUNT_32BITINODES 0x0004 | |
198 | #define LIBXFS_MOUNT_32BITINOOPT 0x0008 | |
199 | #define LIBXFS_MOUNT_COMPAT_ATTR 0x0010 | |
5e656dbb | 200 | #define LIBXFS_MOUNT_ATTR2 0x0020 |
2bd0ea18 | 201 | |
2556c98b BN |
202 | #define LIBXFS_IHASHSIZE(sbp) (1<<10) |
203 | #define LIBXFS_BHASHSIZE(sbp) (1<<10) | |
f1b058f9 | 204 | |
2bd0ea18 NS |
205 | extern xfs_mount_t *libxfs_mount (xfs_mount_t *, xfs_sb_t *, |
206 | dev_t, dev_t, dev_t, int); | |
2bd0ea18 | 207 | extern void libxfs_umount (xfs_mount_t *); |
f1b058f9 | 208 | extern void libxfs_rtmount_destroy (xfs_mount_t *); |
2bd0ea18 NS |
209 | |
210 | ||
211 | /* | |
212 | * Simple I/O interface | |
213 | */ | |
214 | typedef struct xfs_buf { | |
f1b058f9 NS |
215 | struct cache_node b_node; |
216 | unsigned int b_flags; | |
217 | xfs_daddr_t b_blkno; | |
218 | unsigned b_bcount; | |
219 | dev_t b_dev; | |
2556c98b | 220 | pthread_mutex_t b_lock; |
f1b058f9 NS |
221 | void *b_fsprivate; |
222 | void *b_fsprivate2; | |
223 | void *b_fsprivate3; | |
224 | char *b_addr; | |
2556c98b BN |
225 | #ifdef XFS_BUF_TRACING |
226 | struct list_head b_lock_list; | |
227 | const char *b_func; | |
228 | const char *b_file; | |
229 | int b_line; | |
230 | #endif | |
2bd0ea18 | 231 | } xfs_buf_t; |
f1b058f9 NS |
232 | |
233 | enum xfs_buf_flags_t { /* b_flags bits */ | |
234 | LIBXFS_B_EXIT = 0x0001, /* ==LIBXFS_EXIT_ON_FAILURE */ | |
235 | LIBXFS_B_DIRTY = 0x0002, /* buffer has been modified */ | |
236 | LIBXFS_B_STALE = 0x0004, /* buffer marked as invalid */ | |
9f38f08d | 237 | LIBXFS_B_UPTODATE = 0x0008 /* buffer is sync'd to disk */ |
f1b058f9 NS |
238 | }; |
239 | ||
2bd0ea18 NS |
240 | #define XFS_BUF_PTR(bp) ((bp)->b_addr) |
241 | #define xfs_buf_offset(bp, offset) (XFS_BUF_PTR(bp) + (offset)) | |
242 | #define XFS_BUF_ADDR(bp) ((bp)->b_blkno) | |
57c9fccb | 243 | #define XFS_BUF_SIZE(bp) ((bp)->b_bcount) |
2bd0ea18 NS |
244 | #define XFS_BUF_COUNT(bp) ((bp)->b_bcount) |
245 | #define XFS_BUF_TARGET(bp) ((bp)->b_dev) | |
246 | #define XFS_BUF_SET_PTR(bp,p,cnt) ((bp)->b_addr = (char *)(p)); \ | |
2aa2e7b9 | 247 | XFS_BUF_SET_COUNT(bp,cnt) |
2bd0ea18 | 248 | #define XFS_BUF_SET_ADDR(bp,blk) ((bp)->b_blkno = (blk)) |
2aa2e7b9 | 249 | #define XFS_BUF_SET_COUNT(bp,cnt) ((bp)->b_bcount = (cnt)) |
2bd0ea18 NS |
250 | |
251 | #define XFS_BUF_FSPRIVATE(bp,type) ((type)(bp)->b_fsprivate) | |
252 | #define XFS_BUF_SET_FSPRIVATE(bp,val) (bp)->b_fsprivate = (void *)(val) | |
253 | #define XFS_BUF_FSPRIVATE2(bp,type) ((type)(bp)->b_fsprivate2) | |
254 | #define XFS_BUF_SET_FSPRIVATE2(bp,val) (bp)->b_fsprivate2 = (void *)(val) | |
255 | #define XFS_BUF_FSPRIVATE3(bp,type) ((type)(bp)->b_fsprivate3) | |
256 | #define XFS_BUF_SET_FSPRIVATE3(bp,val) (bp)->b_fsprivate3 = (void *)(val) | |
257 | ||
69ec88b5 BN |
258 | #define XFS_BUF_SET_PRIORITY(bp,pri) cache_node_set_priority( \ |
259 | libxfs_bcache, \ | |
260 | (struct cache_node *)(bp), \ | |
261 | (pri)) | |
262 | #define XFS_BUF_PRIORITY(bp) (cache_node_get_priority( \ | |
263 | (struct cache_node *)(bp))) | |
264 | ||
f1b058f9 | 265 | /* Buffer Cache Interfaces */ |
2556c98b | 266 | |
f1b058f9 NS |
267 | extern struct cache *libxfs_bcache; |
268 | extern struct cache_operations libxfs_bcache_operations; | |
2556c98b BN |
269 | |
270 | #ifdef XFS_BUF_TRACING | |
271 | ||
272 | #define libxfs_readbuf(dev, daddr, len, flags) \ | |
273 | libxfs_trace_readbuf(__FUNCTION__, __FILE__, __LINE__, (dev), (daddr), (len), (flags)) | |
274 | #define libxfs_writebuf(buf, flags) \ | |
275 | libxfs_trace_writebuf(__FUNCTION__, __FILE__, __LINE__, (buf), (flags)) | |
276 | #define libxfs_getbuf(dev, daddr, len) \ | |
277 | libxfs_trace_getbuf(__FUNCTION__, __FILE__, __LINE__, (dev), (daddr), (len)) | |
278 | #define libxfs_putbuf(buf) \ | |
279 | libxfs_trace_putbuf(__FUNCTION__, __FILE__, __LINE__, (buf)) | |
280 | ||
281 | extern xfs_buf_t *libxfs_trace_readbuf(const char *, const char *, int, dev_t, xfs_daddr_t, int, int); | |
282 | extern int libxfs_trace_writebuf(const char *, const char *, int, xfs_buf_t *, int); | |
283 | extern xfs_buf_t *libxfs_trace_getbuf(const char *, const char *, int, dev_t, xfs_daddr_t, int); | |
284 | extern void libxfs_trace_putbuf (const char *, const char *, int, xfs_buf_t *); | |
285 | ||
286 | #else | |
287 | ||
288 | extern xfs_buf_t *libxfs_readbuf(dev_t, xfs_daddr_t, int, int); | |
289 | extern int libxfs_writebuf(xfs_buf_t *, int); | |
290 | extern xfs_buf_t *libxfs_getbuf(dev_t, xfs_daddr_t, int); | |
2bd0ea18 | 291 | extern void libxfs_putbuf (xfs_buf_t *); |
2556c98b BN |
292 | |
293 | #endif | |
294 | ||
295 | extern xfs_buf_t *libxfs_getsb(xfs_mount_t *, int); | |
296 | extern void libxfs_bcache_purge(void); | |
297 | extern void libxfs_bcache_flush(void); | |
298 | extern void libxfs_purgebuf(xfs_buf_t *); | |
299 | extern int libxfs_bcache_overflowed(void); | |
300 | extern int libxfs_bcache_usage(void); | |
2bd0ea18 | 301 | |
e6b359b3 | 302 | /* Buffer (Raw) Interfaces */ |
2556c98b BN |
303 | extern xfs_buf_t *libxfs_getbufr(dev_t, xfs_daddr_t, int); |
304 | extern void libxfs_putbufr(xfs_buf_t *); | |
305 | ||
306 | extern int libxfs_writebuf_int(xfs_buf_t *, int); | |
307 | extern int libxfs_readbufr(dev_t, xfs_daddr_t, xfs_buf_t *, int, int); | |
e6b359b3 | 308 | |
9f38f08d MV |
309 | extern int libxfs_bhash_size; |
310 | extern int libxfs_ihash_size; | |
311 | ||
57c9fccb NS |
312 | #define LIBXFS_BREAD 0x1 |
313 | #define LIBXFS_BWRITE 0x2 | |
314 | #define LIBXFS_BZERO 0x4 | |
315 | ||
316 | extern void libxfs_iomove (xfs_buf_t *, uint, int, void *, int); | |
317 | ||
2bd0ea18 NS |
318 | |
319 | /* | |
320 | * Transaction interface | |
321 | */ | |
322 | ||
323 | typedef struct xfs_log_item { | |
324 | struct xfs_log_item_desc *li_desc; /* ptr to current desc*/ | |
325 | struct xfs_mount *li_mountp; /* ptr to fs mount */ | |
326 | uint li_type; /* item type */ | |
327 | } xfs_log_item_t; | |
328 | ||
329 | typedef struct xfs_inode_log_item { | |
330 | xfs_log_item_t ili_item; /* common portion */ | |
331 | struct xfs_inode *ili_inode; /* inode pointer */ | |
332 | unsigned short ili_flags; /* misc flags */ | |
333 | unsigned int ili_last_fields; /* fields when flushed*/ | |
334 | xfs_inode_log_format_t ili_format; /* logged structure */ | |
335 | } xfs_inode_log_item_t; | |
336 | ||
337 | typedef struct xfs_buf_log_item { | |
338 | xfs_log_item_t bli_item; /* common item structure */ | |
339 | struct xfs_buf *bli_buf; /* real buffer pointer */ | |
340 | unsigned int bli_flags; /* misc flags */ | |
341 | unsigned int bli_recur; /* recursion count */ | |
342 | xfs_buf_log_format_t bli_format; /* in-log header */ | |
343 | } xfs_buf_log_item_t; | |
344 | ||
2e542de0 | 345 | #include <xfs/xfs_trans.h> |
2bd0ea18 NS |
346 | |
347 | typedef struct xfs_trans { | |
348 | unsigned int t_type; /* transaction type */ | |
ca86e759 NS |
349 | unsigned int t_log_res; /* amt of log space resvd */ |
350 | unsigned int t_log_count; /* count for perm log res */ | |
2bd0ea18 NS |
351 | xfs_mount_t *t_mountp; /* ptr to fs mount struct */ |
352 | unsigned int t_flags; /* misc flags */ | |
353 | long t_icount_delta; /* superblock icount change */ | |
354 | long t_ifree_delta; /* superblock ifree change */ | |
355 | long t_fdblocks_delta; /* superblock fdblocks chg */ | |
356 | long t_frextents_delta; /* superblock freextents chg */ | |
357 | unsigned int t_items_free; /* log item descs free */ | |
358 | xfs_log_item_chunk_t t_items; /* first log item desc chunk */ | |
359 | } xfs_trans_t; | |
360 | ||
361 | extern xfs_trans_t *libxfs_trans_alloc (xfs_mount_t *, int); | |
362 | extern xfs_trans_t *libxfs_trans_dup (xfs_trans_t *); | |
363 | extern int libxfs_trans_reserve (xfs_trans_t *, uint,uint,uint,uint,uint); | |
5e656dbb | 364 | extern int libxfs_trans_commit (xfs_trans_t *, uint); |
2bd0ea18 NS |
365 | extern void libxfs_trans_cancel (xfs_trans_t *, int); |
366 | extern void libxfs_mod_sb (xfs_trans_t *, __int64_t); | |
f1b058f9 | 367 | extern xfs_buf_t *libxfs_trans_getsb (xfs_trans_t *, xfs_mount_t *, int); |
2bd0ea18 NS |
368 | |
369 | extern int libxfs_trans_iget (xfs_mount_t *, xfs_trans_t *, xfs_ino_t, | |
46eca962 | 370 | uint, uint, struct xfs_inode **); |
2bd0ea18 NS |
371 | extern void libxfs_trans_iput(xfs_trans_t *, struct xfs_inode *, uint); |
372 | extern void libxfs_trans_ijoin (xfs_trans_t *, struct xfs_inode *, uint); | |
373 | extern void libxfs_trans_ihold (xfs_trans_t *, struct xfs_inode *); | |
374 | extern void libxfs_trans_log_inode (xfs_trans_t *, struct xfs_inode *, | |
375 | uint); | |
376 | ||
377 | extern void libxfs_trans_brelse (xfs_trans_t *, struct xfs_buf *); | |
378 | extern void libxfs_trans_binval (xfs_trans_t *, struct xfs_buf *); | |
379 | extern void libxfs_trans_bjoin (xfs_trans_t *, struct xfs_buf *); | |
380 | extern void libxfs_trans_bhold (xfs_trans_t *, struct xfs_buf *); | |
381 | extern void libxfs_trans_log_buf (xfs_trans_t *, struct xfs_buf *, | |
382 | uint, uint); | |
383 | extern xfs_buf_t *libxfs_trans_get_buf (xfs_trans_t *, dev_t, | |
384 | xfs_daddr_t, int, uint); | |
385 | extern int libxfs_trans_read_buf (xfs_mount_t *, xfs_trans_t *, dev_t, | |
386 | xfs_daddr_t, int, uint, struct xfs_buf **); | |
387 | ||
388 | ||
2bd0ea18 NS |
389 | /* |
390 | * Inode interface | |
391 | */ | |
2bd0ea18 | 392 | typedef struct xfs_inode { |
f1b058f9 | 393 | struct cache_node i_node; |
2bd0ea18 NS |
394 | xfs_mount_t *i_mount; /* fs mount struct ptr */ |
395 | xfs_ino_t i_ino; /* inode number (agno/agino) */ | |
396 | xfs_daddr_t i_blkno; /* blkno of inode buffer */ | |
397 | dev_t i_dev; /* dev for this inode */ | |
398 | ushort i_len; /* len of inode buffer */ | |
399 | ushort i_boffset; /* off of inode in buffer */ | |
400 | xfs_ifork_t *i_afp; /* attribute fork pointer */ | |
401 | xfs_ifork_t i_df; /* data fork */ | |
f1b058f9 NS |
402 | xfs_trans_t *i_transp; /* ptr to owning transaction */ |
403 | xfs_inode_log_item_t *i_itemp; /* logging information */ | |
2bd0ea18 | 404 | unsigned int i_delayed_blks; /* count of delay alloc blks */ |
5e656dbb BN |
405 | xfs_icdinode_t i_d; /* most of ondisk inode */ |
406 | xfs_fsize_t i_size; /* in-memory size */ | |
2bd0ea18 NS |
407 | } xfs_inode_t; |
408 | ||
57c9fccb NS |
409 | #define LIBXFS_ATTR_ROOT 0x0002 /* use attrs in root namespace */ |
410 | #define LIBXFS_ATTR_SECURE 0x0008 /* use attrs in security namespace */ | |
411 | #define LIBXFS_ATTR_CREATE 0x0010 /* create, but fail if attr exists */ | |
412 | #define LIBXFS_ATTR_REPLACE 0x0020 /* set, but fail if attr not exists */ | |
413 | ||
9f064b7e | 414 | typedef struct cred { |
14290264 NS |
415 | uid_t cr_uid; |
416 | gid_t cr_gid; | |
417 | } cred_t; | |
418 | ||
2bd0ea18 | 419 | extern int libxfs_inode_alloc (xfs_trans_t **, xfs_inode_t *, mode_t, |
9f064b7e NS |
420 | nlink_t, xfs_dev_t, struct cred *, |
421 | struct fsxattr *, xfs_inode_t **); | |
2bd0ea18 NS |
422 | extern void libxfs_trans_inode_alloc_buf (xfs_trans_t *, xfs_buf_t *); |
423 | ||
2bd0ea18 NS |
424 | extern void libxfs_ichgtime (xfs_inode_t *, int); |
425 | extern int libxfs_iflush_int (xfs_inode_t *, xfs_buf_t *); | |
f1b058f9 NS |
426 | extern int libxfs_iread (xfs_mount_t *, xfs_trans_t *, xfs_ino_t, |
427 | xfs_inode_t *, xfs_daddr_t); | |
428 | ||
429 | /* Inode Cache Interfaces */ | |
430 | extern struct cache *libxfs_icache; | |
431 | extern struct cache_operations libxfs_icache_operations; | |
432 | extern void libxfs_icache_purge (void); | |
2bd0ea18 NS |
433 | extern int libxfs_iget (xfs_mount_t *, xfs_trans_t *, xfs_ino_t, |
434 | uint, xfs_inode_t **, xfs_daddr_t); | |
435 | extern void libxfs_iput (xfs_inode_t *, uint); | |
436 | ||
5e656dbb | 437 | #include <xfs/xfs_dir_leaf.h> /* dirv1 support in db & repair */ |
f302e9e4 NS |
438 | #include <xfs/xfs_dir2_data.h> |
439 | #include <xfs/xfs_dir2_leaf.h> | |
440 | #include <xfs/xfs_dir2_block.h> | |
441 | #include <xfs/xfs_dir2_node.h> | |
442 | ||
5e656dbb BN |
443 | /* Shared utility routines */ |
444 | extern unsigned int libxfs_log2_roundup(unsigned int i); | |
2bd0ea18 | 445 | |
2bd0ea18 NS |
446 | extern int libxfs_alloc_file_space (xfs_inode_t *, xfs_off_t, |
447 | xfs_off_t, int, int); | |
5e656dbb | 448 | extern int libxfs_bmap_finish(xfs_trans_t **, xfs_bmap_free_t *, int *); |
2bd0ea18 | 449 | |
2bd0ea18 | 450 | extern void libxfs_da_bjoin (xfs_trans_t *, xfs_dabuf_t *); |
2bd0ea18 | 451 | extern void libxfs_da_bhold (xfs_trans_t *, xfs_dabuf_t *); |
5e656dbb | 452 | extern int libxfs_da_read_bufr(xfs_trans_t *, xfs_inode_t *, xfs_dablk_t, |
2bd0ea18 | 453 | xfs_daddr_t, xfs_dabuf_t **, int); |
2bd0ea18 | 454 | |
5e656dbb BN |
455 | extern void libxfs_fs_repair_cmn_err(int, struct xfs_mount *, char *, ...); |
456 | extern void libxfs_fs_cmn_err(int, struct xfs_mount *, char *, ...); | |
2bd0ea18 | 457 | |
1552a820 NS |
458 | extern void cmn_err(int, char *, ...); |
459 | enum ce { CE_DEBUG, CE_CONT, CE_NOTE, CE_WARN, CE_ALERT, CE_PANIC }; | |
f302e9e4 | 460 | |
cb5b3ef4 MV |
461 | |
462 | #define LIBXFS_BBTOOFF64(bbs) (((xfs_off_t)(bbs)) << BBSHIFT) | |
2556c98b BN |
463 | extern int libxfs_nproc(void); |
464 | extern unsigned long libxfs_physmem(void); /* in kilobytes */ | |
cb5b3ef4 | 465 | |
f302e9e4 NS |
466 | #include <xfs/xfs_ialloc.h> |
467 | #include <xfs/xfs_rtalloc.h> | |
468 | ||
469 | #include <xfs/xfs_attr_leaf.h> | |
470 | #include <xfs/xfs_quota.h> | |
471 | #include <xfs/xfs_trans_space.h> | |
472 | #include <xfs/xfs_imap.h> | |
473 | #include <xfs/xfs_log.h> | |
474 | #include <xfs/xfs_log_priv.h> | |
475 | ||
5e656dbb BN |
476 | #define XFS_INOBT_IS_FREE_DISK(rp,i) \ |
477 | ((be64_to_cpu((rp)->ir_free) & XFS_INOBT_MASK(i)) != 0) | |
478 | /* | |
479 | * public xfs kernel routines to be called as libxfs_* | |
480 | */ | |
481 | ||
482 | /* xfs_alloc.c */ | |
483 | int libxfs_alloc_fix_freelist(xfs_alloc_arg_t *, int); | |
484 | ||
485 | /* xfs_attr.c */ | |
486 | int libxfs_attr_get(struct xfs_inode *, const char *, char *, int *, int); | |
487 | int libxfs_attr_set(struct xfs_inode *, const char *, char *, int, int); | |
488 | int libxfs_attr_remove(struct xfs_inode *, const char *, int); | |
489 | ||
490 | /* xfs_bmap.c */ | |
491 | xfs_bmbt_rec_host_t *xfs_bmap_search_extents(xfs_inode_t *, xfs_fileoff_t, | |
492 | int, int *, xfs_extnum_t *, xfs_bmbt_irec_t *, | |
493 | xfs_bmbt_irec_t *); | |
494 | ||
495 | /* xfs_attr_leaf.h */ | |
496 | #define libxfs_attr_leaf_newentsize xfs_attr_leaf_newentsize | |
497 | ||
498 | /* xfs_bit.h */ | |
499 | #define libxfs_highbit32 xfs_highbit32 | |
500 | #define libxfs_highbit64 xfs_highbit64 | |
501 | ||
502 | /* xfs_bmap.h */ | |
503 | #define libxfs_bmap_cancel xfs_bmap_cancel | |
504 | #define libxfs_bmap_last_offset xfs_bmap_last_offset | |
505 | #define libxfs_bmapi xfs_bmapi | |
506 | #define libxfs_bunmapi xfs_bunmapi | |
507 | ||
508 | /* xfs_bmap_btree.h */ | |
509 | #define libxfs_bmbt_disk_get_all xfs_bmbt_disk_get_all | |
510 | ||
511 | /* xfs_da_btree.h */ | |
512 | #define libxfs_da_brelse xfs_da_brelse | |
513 | #define libxfs_da_hashname xfs_da_hashname | |
514 | #define libxfs_da_shrink_inode xfs_da_shrink_inode | |
515 | ||
516 | /* xfs_dir2.h */ | |
517 | #define libxfs_dir_createname xfs_dir_createname | |
518 | #define libxfs_dir_init xfs_dir_init | |
519 | #define libxfs_dir_lookup xfs_dir_lookup | |
520 | #define libxfs_dir_replace xfs_dir_replace | |
521 | #define libxfs_dir2_isblock xfs_dir2_isblock | |
522 | #define libxfs_dir2_isleaf xfs_dir2_isleaf | |
523 | ||
524 | /* xfs_dir2_data.h */ | |
525 | #define libxfs_dir2_data_freescan xfs_dir2_data_freescan | |
526 | #define libxfs_dir2_data_log_entry xfs_dir2_data_log_entry | |
527 | #define libxfs_dir2_data_log_header xfs_dir2_data_log_header | |
528 | #define libxfs_dir2_data_make_free xfs_dir2_data_make_free | |
529 | #define libxfs_dir2_data_use_free xfs_dir2_data_use_free | |
530 | #define libxfs_dir2_shrink_inode xfs_dir2_shrink_inode | |
531 | ||
532 | /* xfs_inode.h */ | |
533 | #define libxfs_dinode_from_disk xfs_dinode_from_disk | |
534 | #define libxfs_dinode_to_disk xfs_dinode_to_disk | |
535 | #define libxfs_idata_realloc xfs_idata_realloc | |
536 | #define libxfs_idestroy_fork xfs_idestroy_fork | |
537 | ||
538 | /* xfs_mount.h */ | |
539 | #define libxfs_mod_sb xfs_mod_sb | |
540 | #define libxfs_sb_from_disk xfs_sb_from_disk | |
541 | #define libxfs_sb_to_disk xfs_sb_to_disk | |
542 | ||
543 | /* xfs_rtalloc.c */ | |
544 | int libxfs_rtfree_extent(struct xfs_trans *, xfs_rtblock_t, xfs_extlen_t); | |
545 | ||
2bd0ea18 | 546 | #endif /* __LIBXFS_H__ */ |