]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - include/libxfs.h
2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
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
7 * published by the Free Software Foundation.
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.
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
22 #include "xfs/libxfs_api_defs.h"
23 #include "xfs/platform_defs.h"
26 #include "xfs/hlist.h"
27 #include "xfs/cache.h"
28 #include "xfs/bitops.h"
30 #include "xfs/radix-tree.h"
32 #include "xfs/atomic.h"
34 #include "xfs/xfs_types.h"
35 #include "xfs/xfs_fs.h"
36 #include "xfs/xfs_arch.h"
38 #include "xfs/xfs_shared.h"
39 #include "xfs/xfs_format.h"
40 #include "xfs/xfs_log_format.h"
41 #include "xfs/xfs_quota_defs.h"
42 #include "xfs/xfs_trans_resv.h"
45 /* CRC stuff, buffer API dependent on it */
46 extern uint32_t crc32_le(uint32_t crc
, unsigned char const *p
, size_t len
);
47 extern uint32_t crc32c_le(uint32_t crc
, unsigned char const *p
, size_t len
);
49 #define crc32(c,p,l) crc32_le((c),(unsigned char const *)(p),(l))
50 #define crc32c(c,p,l) crc32c_le((c),(unsigned char const *)(p),(l))
52 #include "xfs/xfs_cksum.h"
55 * This mirrors the kernel include for xfs_buf.h - it's implicitly included in
56 * every files via a similar include in the kernel xfs_linux.h.
58 #include "xfs/libxfs_io.h"
60 #include "xfs/xfs_bit.h"
61 #include "xfs/xfs_sb.h"
62 #include "xfs/xfs_mount.h"
63 #include "xfs/xfs_da_format.h"
64 #include "xfs/xfs_da_btree.h"
65 #include "xfs/xfs_dir2.h"
66 #include "xfs/xfs_bmap_btree.h"
67 #include "xfs/xfs_alloc_btree.h"
68 #include "xfs/xfs_ialloc_btree.h"
69 #include "xfs/xfs_attr_sf.h"
70 #include "xfs/xfs_inode_fork.h"
71 #include "xfs/xfs_inode_buf.h"
72 #include "xfs/xfs_inode.h"
73 #include "xfs/xfs_alloc.h"
74 #include "xfs/xfs_btree.h"
75 #include "xfs/xfs_btree_trace.h"
76 #include "xfs/xfs_bmap.h"
77 #include "xfs/xfs_trace.h"
78 #include "xfs/xfs_trans.h"
81 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
84 #ifndef XFS_SUPER_MAGIC
85 #define XFS_SUPER_MAGIC 0x58465342
88 #define xfs_isset(a,i) ((a)[(i)/(sizeof((a))*NBBY)] & (1<<((i)%(sizeof((a))*NBBY))))
91 * Argument structure for libxfs_init().
94 /* input parameters */
95 char *volname
; /* pathname of volume */
96 char *dname
; /* pathname of data "subvolume" */
97 char *logname
; /* pathname of log "subvolume" */
98 char *rtname
; /* pathname of realtime "subvolume" */
99 int isreadonly
; /* filesystem is only read in applic */
100 int isdirect
; /* we can attempt to use direct I/O */
101 int disfile
; /* data "subvolume" is a regular file */
102 int dcreat
; /* try to create data subvolume */
103 int lisfile
; /* log "subvolume" is a regular file */
104 int lcreat
; /* try to create log subvolume */
105 int risfile
; /* realtime "subvolume" is a reg file */
106 int rcreat
; /* try to create realtime subvolume */
107 int setblksize
; /* attempt to set device blksize */
108 int usebuflock
; /* lock xfs_buf_t's - for MT usage */
110 dev_t ddev
; /* device for data subvolume */
111 dev_t logdev
; /* device for log subvolume */
112 dev_t rtdev
; /* device for realtime subvolume */
113 long long dsize
; /* size of data subvolume (BBs) */
114 long long logBBsize
; /* size of log subvolume (BBs) */
115 /* (blocks allocated for use as
116 * log is stored in mount structure) */
117 long long logBBstart
; /* start block of log subvolume (BBs) */
118 long long rtsize
; /* size of realtime subvolume (BBs) */
119 int dbsize
; /* data subvolume device blksize */
120 int lbsize
; /* log subvolume device blksize */
121 int rtbsize
; /* realtime subvolume device blksize */
122 int dfd
; /* data subvolume file descriptor */
123 int logfd
; /* log subvolume file descriptor */
124 int rtfd
; /* realtime subvolume file descriptor */
125 int icache_flags
; /* cache init flags */
126 int bcache_flags
; /* cache init flags */
129 #define LIBXFS_EXIT_ON_FAILURE 0x0001 /* exit the program if a call fails */
130 #define LIBXFS_ISREADONLY 0x0002 /* disallow all mounted filesystems */
131 #define LIBXFS_ISINACTIVE 0x0004 /* allow mounted only if mounted ro */
132 #define LIBXFS_DANGEROUSLY 0x0008 /* repairing a device mounted ro */
133 #define LIBXFS_EXCLUSIVELY 0x0010 /* disallow other accesses (O_EXCL) */
134 #define LIBXFS_DIRECT 0x0020 /* can use direct I/O, not buffered */
136 extern char *progname
;
137 extern int libxfs_init (libxfs_init_t
*);
138 extern void libxfs_destroy (void);
139 extern int libxfs_device_to_fd (dev_t
);
140 extern dev_t
libxfs_device_open (char *, int, int, int);
141 extern void libxfs_device_zero(struct xfs_buftarg
*, xfs_daddr_t
, uint
);
142 extern void libxfs_device_close (dev_t
);
143 extern int libxfs_device_alignment (void);
144 extern void libxfs_report(FILE *);
145 extern void platform_findsizes(char *path
, int fd
, long long *sz
, int *bsz
);
146 extern int platform_nproc(void);
148 /* check or write log footer: specify device, log size in blocks & uuid */
149 typedef xfs_caddr_t (libxfs_get_block_t
)(xfs_caddr_t
, int, void *);
151 extern int libxfs_log_clear (struct xfs_buftarg
*, xfs_daddr_t
, uint
,
152 uuid_t
*, int, int, int);
153 extern int libxfs_log_header (xfs_caddr_t
, uuid_t
*, int, int, int,
154 libxfs_get_block_t
*, void *);
157 /* Shared utility routines */
158 extern unsigned int libxfs_log2_roundup(unsigned int i
);
160 extern int libxfs_alloc_file_space (struct xfs_inode
*, xfs_off_t
,
161 xfs_off_t
, int, int);
162 extern int libxfs_bmap_finish(xfs_trans_t
**, xfs_bmap_free_t
*, int *);
164 extern void libxfs_fs_repair_cmn_err(int, struct xfs_mount
*, char *, ...);
165 extern void libxfs_fs_cmn_err(int, struct xfs_mount
*, char *, ...);
167 /* XXX: this is messy and needs fixing */
168 #ifndef __LIBXFS_INTERNAL_XFS_H__
169 extern void cmn_err(int, char *, ...);
170 enum ce
{ CE_DEBUG
, CE_CONT
, CE_NOTE
, CE_WARN
, CE_ALERT
, CE_PANIC
};
174 extern int libxfs_nproc(void);
175 extern unsigned long libxfs_physmem(void); /* in kilobytes */
177 #include "xfs/xfs_ialloc.h"
179 #include "xfs/xfs_attr_leaf.h"
180 #include "xfs/xfs_attr_remote.h"
181 #include "xfs/xfs_trans_space.h"
183 #define XFS_INOBT_IS_FREE_DISK(rp,i) \
184 ((be64_to_cpu((rp)->ir_free) & XFS_INOBT_MASK(i)) != 0)
187 libxfs_bmbt_disk_get_all(
188 struct xfs_bmbt_rec
*rp
,
189 struct xfs_bmbt_irec
*irec
)
191 struct xfs_bmbt_rec_host hrec
;
193 hrec
.l0
= be64_to_cpu(rp
->l0
);
194 hrec
.l1
= be64_to_cpu(rp
->l1
);
195 libxfs_bmbt_get_all(&hrec
, irec
);
198 /* XXX: this is clearly a bug - a shared header needs to export this */
200 int libxfs_rtfree_extent(struct xfs_trans
*, xfs_rtblock_t
, xfs_extlen_t
);
202 /* XXX: need parts of xfs_attr.h in userspace */
203 #define LIBXFS_ATTR_ROOT 0x0002 /* use attrs in root namespace */
204 #define LIBXFS_ATTR_SECURE 0x0008 /* use attrs in security namespace */
205 #define LIBXFS_ATTR_CREATE 0x0010 /* create, but fail if attr exists */
206 #define LIBXFS_ATTR_REPLACE 0x0020 /* set, but fail if attr not exists */
208 int xfs_attr_remove(struct xfs_inode
*dp
, const unsigned char *name
, int flags
);
209 int xfs_attr_set(struct xfs_inode
*dp
, const unsigned char *name
,
210 unsigned char *value
, int valuelen
, int flags
);
212 #endif /* __LIBXFS_H__ */