~ubuntu-branches/ubuntu/utopic/xfsprogs/utopic-proposed

« back to all changes in this revision

Viewing changes to include/libxfs.h

  • Committer: Bazaar Package Importer
  • Author(s): Nathan Scott
  • Date: 2009-05-06 11:29:18 UTC
  • mfrom: (8.1.1 jaunty)
  • Revision ID: james.westby@ubuntu.com-20090506112918-uzoyzcp90rtr8td7
Tags: 3.0.2
New bugfix release

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 * along with this program; if not, write the Free Software Foundation,
16
16
 * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17
17
 */
 
18
 
18
19
#ifndef __LIBXFS_H__
19
20
#define __LIBXFS_H__
20
21
 
23
24
 
24
25
#include <xfs/platform_defs.h>
25
26
 
26
 
#include <pthread.h>
27
27
#include <xfs/list.h>
28
28
#include <xfs/cache.h>
 
29
#include <xfs/bitops.h>
 
30
#include <xfs/kmem.h>
 
31
#include <xfs/swab.h>
29
32
 
30
33
#include <xfs/xfs_fs.h>
31
34
#include <xfs/xfs_types.h>
49
52
#include <xfs/xfs_inode_item.h>
50
53
#include <xfs/xfs_alloc.h>
51
54
#include <xfs/xfs_btree.h>
 
55
#include <xfs/xfs_btree_trace.h>
52
56
#include <xfs/xfs_bmap.h>
53
57
 
54
58
 
69
73
        char            *rtname;        /* pathname of realtime "subvolume" */
70
74
        int             isreadonly;     /* filesystem is only read in applic */
71
75
        int             isdirect;       /* we can attempt to use direct I/O */
72
 
        int             disfile;        /* data "subvolume" is a regular file */        int             dcreat;         /* try to create data subvolume */
 
76
        int             disfile;        /* data "subvolume" is a regular file */
 
77
        int             dcreat;         /* try to create data subvolume */
73
78
        int             lisfile;        /* log "subvolume" is a regular file */
74
79
        int             lcreat;         /* try to create log subvolume */
75
 
        int             risfile;        /* realtime "subvolume" is a reg file */        int             rcreat;         /* try to create realtime subvolume */
 
80
        int             risfile;        /* realtime "subvolume" is a reg file */
 
81
        int             rcreat;         /* try to create realtime subvolume */
76
82
        int             setblksize;     /* attempt to set device blksize */
 
83
        int             usebuflock;     /* lock xfs_buf_t's - for MT usage */
77
84
                                /* output results */
78
85
        dev_t           ddev;           /* device for data subvolume */
79
86
        dev_t           logdev;         /* device for log subvolume */
122
129
 * Define a user-level mount structure with all we need
123
130
 * in order to make use of the numerous XFS_* macros.
124
131
 */
125
 
struct xfs_inode;
126
132
typedef struct xfs_mount {
127
133
        xfs_sb_t                m_sb;           /* copy of fs superblock */
128
134
        char                    *m_fsname;      /* filesystem name */
174
180
        int                     m_sinoalign;    /* stripe unit inode alignmnt */
175
181
        int                     m_attr_magicpct;/* 37% of the blocksize */
176
182
        int                     m_dir_magicpct; /* 37% of the dir blocksize */
177
 
        __uint8_t               m_dirversion;   /* 1 or 2 */
 
183
        const struct xfs_nameops *m_dirnameops; /* vector of dir name ops */
178
184
        int                     m_dirblksize;   /* directory block sz--bytes */
179
185
        int                     m_dirblkfsbs;   /* directory block sz--fsbs */
180
186
        xfs_dablk_t             m_dirdatablk;   /* blockno of dir data v2 */
181
187
        xfs_dablk_t             m_dirleafblk;   /* blockno of dir non-data v2 */
182
188
        xfs_dablk_t             m_dirfreeblk;   /* blockno of dirfreeindex v2 */
183
189
} xfs_mount_t;
184
 
#define XFS_DIR_IS_V1(mp)       ((mp)->m_dirversion == 1)
185
 
#define XFS_DIR_IS_V2(mp)       ((mp)->m_dirversion == 2)
186
190
 
187
191
#define LIBXFS_MOUNT_ROOTINOS           0x0001
188
192
#define LIBXFS_MOUNT_DEBUGGER           0x0002
189
193
#define LIBXFS_MOUNT_32BITINODES        0x0004
190
194
#define LIBXFS_MOUNT_32BITINOOPT        0x0008
191
195
#define LIBXFS_MOUNT_COMPAT_ATTR        0x0010
 
196
#define LIBXFS_MOUNT_ATTR2              0x0020
192
197
 
193
198
#define LIBXFS_IHASHSIZE(sbp)           (1<<10)
194
199
#define LIBXFS_BHASHSIZE(sbp)           (1<<10)
195
200
 
196
201
extern xfs_mount_t      *libxfs_mount (xfs_mount_t *, xfs_sb_t *,
197
202
                                dev_t, dev_t, dev_t, int);
198
 
extern void     libxfs_mount_common (xfs_mount_t *, xfs_sb_t *);
199
 
extern xfs_agnumber_t   libxfs_initialize_perag (xfs_mount_t *, xfs_agnumber_t);
200
 
extern int      libxfs_initialize_perag_data (xfs_mount_t *, xfs_agnumber_t);
201
203
extern void     libxfs_umount (xfs_mount_t *);
202
 
extern int      libxfs_rtmount_init (xfs_mount_t *);
203
204
extern void     libxfs_rtmount_destroy (xfs_mount_t *);
204
 
extern void     libxfs_alloc_compute_maxlevels (xfs_mount_t *);
205
 
extern void     libxfs_bmap_compute_maxlevels (xfs_mount_t *, int);
206
 
extern void     libxfs_ialloc_compute_maxlevels (xfs_mount_t *);
207
 
extern void     libxfs_trans_init (xfs_mount_t *);
208
205
 
209
206
 
210
207
/*
360
357
extern xfs_trans_t      *libxfs_trans_alloc (xfs_mount_t *, int);
361
358
extern xfs_trans_t      *libxfs_trans_dup (xfs_trans_t *);
362
359
extern int      libxfs_trans_reserve (xfs_trans_t *, uint,uint,uint,uint,uint);
363
 
extern int      libxfs_trans_commit (xfs_trans_t *, uint, xfs_lsn_t *);
 
360
extern int      libxfs_trans_commit (xfs_trans_t *, uint);
364
361
extern void     libxfs_trans_cancel (xfs_trans_t *, int);
365
362
extern void     libxfs_mod_sb (xfs_trans_t *, __int64_t);
366
363
extern xfs_buf_t        *libxfs_trans_getsb (xfs_trans_t *, xfs_mount_t *, int);
386
383
 
387
384
 
388
385
/*
389
 
 * Simple memory interface
390
 
 */
391
 
typedef struct xfs_zone {
392
 
        int     zone_unitsize;  /* Size in bytes of zone unit           */
393
 
        char    *zone_name;     /* tag name                             */
394
 
        int     allocated;      /* debug: How many currently allocated  */
395
 
} xfs_zone_t;
396
 
 
397
 
extern xfs_zone_t       *libxfs_zone_init (int, char *);
398
 
extern void     *libxfs_zone_zalloc (xfs_zone_t *);
399
 
extern void     libxfs_zone_free (xfs_zone_t *, void *);
400
 
extern void     *libxfs_malloc (size_t);
401
 
extern void     libxfs_free (void *);
402
 
extern void     *libxfs_realloc (void *, size_t);
403
 
 
404
 
 
405
 
/*
406
386
 * Inode interface
407
387
 */
408
388
typedef struct xfs_inode {
418
398
        xfs_trans_t             *i_transp;      /* ptr to owning transaction */
419
399
        xfs_inode_log_item_t    *i_itemp;       /* logging information */
420
400
        unsigned int            i_delayed_blks; /* count of delay alloc blks */
421
 
        xfs_dinode_core_t       i_d;            /* most of ondisk inode */
 
401
        xfs_icdinode_t          i_d;            /* most of ondisk inode */
 
402
        xfs_fsize_t             i_size;         /* in-memory size */
422
403
} xfs_inode_t;
423
404
 
424
405
#define LIBXFS_ATTR_ROOT        0x0002  /* use attrs in root namespace */
436
417
                                struct fsxattr *, xfs_inode_t **);
437
418
extern void     libxfs_trans_inode_alloc_buf (xfs_trans_t *, xfs_buf_t *);
438
419
 
439
 
extern void     libxfs_idata_realloc (xfs_inode_t *, int, int);
440
 
extern void     libxfs_idestroy_fork (xfs_inode_t *, int);
441
 
extern int      libxfs_iformat (xfs_inode_t *, xfs_dinode_t *);
442
420
extern void     libxfs_ichgtime (xfs_inode_t *, int);
443
421
extern int      libxfs_iflush_int (xfs_inode_t *, xfs_buf_t *);
444
 
extern int      libxfs_itobp (xfs_mount_t *, xfs_trans_t *, xfs_inode_t *,
445
 
                                xfs_dinode_t **, xfs_buf_t **, xfs_daddr_t);
446
422
extern int      libxfs_iread (xfs_mount_t *, xfs_trans_t *, xfs_ino_t,
447
423
                                xfs_inode_t *, xfs_daddr_t);
448
424
 
454
430
                                uint, xfs_inode_t **, xfs_daddr_t);
455
431
extern void     libxfs_iput (xfs_inode_t *, uint);
456
432
 
457
 
 
458
 
/*
459
 
 * Directory interface
460
 
 */
461
 
#include <xfs/xfs_dir_leaf.h>
 
433
#include <xfs/xfs_dir_leaf.h>   /* dirv1 support in db & repair */ 
462
434
#include <xfs/xfs_dir2_data.h>
463
435
#include <xfs/xfs_dir2_leaf.h>
464
436
#include <xfs/xfs_dir2_block.h>
465
437
#include <xfs/xfs_dir2_node.h>
466
438
 
467
 
extern void     libxfs_dir_mount (xfs_mount_t *);
468
 
extern void     libxfs_dir2_mount (xfs_mount_t *);
469
 
extern int      libxfs_dir_init (xfs_trans_t *, xfs_inode_t *, xfs_inode_t *);
470
 
extern int      libxfs_dir2_init (xfs_trans_t *, xfs_inode_t *, xfs_inode_t *);
471
 
extern int      libxfs_dir_createname (xfs_trans_t *, xfs_inode_t *, uchar_t *,
472
 
                                int, xfs_ino_t, xfs_fsblock_t *,
473
 
                                xfs_bmap_free_t *, xfs_extlen_t);
474
 
extern int      libxfs_dir2_createname (xfs_trans_t *, xfs_inode_t *, uchar_t *,
475
 
                                int, xfs_ino_t, xfs_fsblock_t *,
476
 
                                xfs_bmap_free_t *, xfs_extlen_t);
477
 
extern int      libxfs_dir_lookup (xfs_trans_t *, xfs_inode_t *,
478
 
                                uchar_t *, int, xfs_ino_t *);
479
 
extern int      libxfs_dir2_lookup (xfs_trans_t *, xfs_inode_t *,
480
 
                                uchar_t *, int, xfs_ino_t *);
481
 
extern int      libxfs_dir_replace (xfs_trans_t *, xfs_inode_t *,
482
 
                                uchar_t *, int, xfs_ino_t, xfs_fsblock_t *,
483
 
                                xfs_bmap_free_t *, xfs_extlen_t);
484
 
extern int      libxfs_dir2_replace (xfs_trans_t *, xfs_inode_t *,
485
 
                                uchar_t *, int, xfs_ino_t, xfs_fsblock_t *,
486
 
                                xfs_bmap_free_t *, xfs_extlen_t);
487
 
extern int      libxfs_dir_removename (xfs_trans_t *, xfs_inode_t *,
488
 
                                uchar_t *, int, xfs_ino_t, xfs_fsblock_t *,
489
 
                                xfs_bmap_free_t *, xfs_extlen_t);
490
 
extern int      libxfs_dir2_removename (xfs_trans_t *, xfs_inode_t *,
491
 
                                uchar_t *, int, xfs_ino_t, xfs_fsblock_t *,
492
 
                                xfs_bmap_free_t *, xfs_extlen_t);
493
 
extern int      libxfs_dir_bogus_removename (xfs_trans_t *, xfs_inode_t *,
494
 
                                uchar_t *, xfs_fsblock_t *, xfs_bmap_free_t *,
495
 
                                xfs_extlen_t, xfs_dahash_t, int);
496
 
extern int      libxfs_dir2_bogus_removename (xfs_trans_t *, xfs_inode_t *,
497
 
                                uchar_t *, xfs_fsblock_t *, xfs_bmap_free_t *,
498
 
                                xfs_extlen_t, xfs_dahash_t, int);
499
 
 
500
 
 
501
 
/*
502
 
 * Block map interface
503
 
 */
504
 
extern int      libxfs_bmapi (xfs_trans_t *, xfs_inode_t *, xfs_fileoff_t,
505
 
                                xfs_filblks_t, int, xfs_fsblock_t *,
506
 
                                xfs_extlen_t, xfs_bmbt_irec_t *, int *,
507
 
                                xfs_bmap_free_t *);
508
 
extern int      libxfs_bmapi_single(xfs_trans_t *, xfs_inode_t *, int,
509
 
                                xfs_fsblock_t *, xfs_fileoff_t);
510
 
extern int      libxfs_bmap_finish (xfs_trans_t **, xfs_bmap_free_t *,
511
 
                                xfs_fsblock_t, int *);
512
 
extern void     libxfs_bmap_cancel(xfs_bmap_free_t *);
513
 
extern int      libxfs_bmap_next_offset (xfs_trans_t *, xfs_inode_t *,
514
 
                                xfs_fileoff_t *, int);
515
 
extern int      libxfs_bmap_last_offset(xfs_trans_t *, xfs_inode_t *,
516
 
                                xfs_fileoff_t *, int);
517
 
extern int      libxfs_bunmapi (xfs_trans_t *, xfs_inode_t *, xfs_fileoff_t,
518
 
                                xfs_filblks_t, int, xfs_extnum_t,
519
 
                                xfs_fsblock_t *, xfs_bmap_free_t *, int *);
520
 
extern void     libxfs_bmap_del_free (xfs_bmap_free_t *,
521
 
                                xfs_bmap_free_item_t *, xfs_bmap_free_item_t *);
522
 
 
523
 
 
524
 
/*
525
 
 * All other routines we want to keep common...
526
 
 */
527
 
 
528
 
extern int      libxfs_highbit32 (__uint32_t);
529
 
extern int      libxfs_highbit64 (__uint64_t);
530
 
extern uint     libxfs_da_log2_roundup (uint);
531
 
 
532
 
extern void     libxfs_xlate_sb (void *, xfs_sb_t *, int, __int64_t);
533
 
extern void     libxfs_xlate_dinode_core (xfs_caddr_t buf,
534
 
                                xfs_dinode_core_t *, int);
535
 
 
536
 
extern int      libxfs_alloc_fix_freelist (xfs_alloc_arg_t *, int);
 
439
/* Shared utility routines */
 
440
extern unsigned int     libxfs_log2_roundup(unsigned int i);
 
441
 
537
442
extern int      libxfs_alloc_file_space (xfs_inode_t *, xfs_off_t,
538
443
                                xfs_off_t, int, int);
539
 
 
540
 
extern xfs_dahash_t     libxfs_da_hashname (const uchar_t *, int);
541
 
extern int      libxfs_attr_leaf_newentsize (int, int, int, int *);
542
 
extern int      libxfs_attr_set_int (xfs_inode_t*, const char *, int, char *,
543
 
                                int, int);
544
 
extern int      libxfs_attr_remove_int (xfs_inode_t *, const char *, int, int);
545
 
 
546
 
 
547
 
extern void     libxfs_bmbt_get_all (xfs_bmbt_rec_t *, xfs_bmbt_irec_t *);
548
 
#if __BYTE_ORDER != __BIG_ENDIAN
549
 
extern void     libxfs_bmbt_disk_get_all (xfs_bmbt_rec_t *, xfs_bmbt_irec_t *);
550
 
#else
551
 
# define libxfs_bmbt_disk_get_all(r,s)  libxfs_bmbt_get_all(r,s)
552
 
#endif
553
 
 
554
 
extern int      libxfs_free_extent (xfs_trans_t *, xfs_fsblock_t, xfs_extlen_t);
555
 
extern int      libxfs_rtfree_extent (xfs_trans_t *, xfs_rtblock_t,
556
 
                                xfs_extlen_t);
557
 
 
558
 
/* Directory/Attribute routines used by xfs_repair */
 
444
extern int      libxfs_bmap_finish(xfs_trans_t **, xfs_bmap_free_t *, int *);
 
445
 
559
446
extern void     libxfs_da_bjoin (xfs_trans_t *, xfs_dabuf_t *);
560
 
extern int      libxfs_da_shrink_inode (xfs_da_args_t *, xfs_dablk_t,
561
 
                                xfs_dabuf_t *);
562
 
extern int      libxfs_da_grow_inode (xfs_da_args_t *, xfs_dablk_t *);
563
447
extern void     libxfs_da_bhold (xfs_trans_t *, xfs_dabuf_t *);
564
 
extern void     libxfs_da_brelse (xfs_trans_t *, xfs_dabuf_t *);
565
 
extern int      libxfs_da_read_bufr (xfs_trans_t *, xfs_inode_t *, xfs_dablk_t,
 
448
extern int      libxfs_da_read_bufr(xfs_trans_t *, xfs_inode_t *, xfs_dablk_t,
566
449
                                xfs_daddr_t, xfs_dabuf_t **, int);
567
 
extern int      libxfs_da_read_buf (xfs_trans_t *, xfs_inode_t *,
568
 
                                xfs_dablk_t, xfs_daddr_t, xfs_dabuf_t **, int);
569
 
extern int      libxfs_da_get_buf (xfs_trans_t *, xfs_inode_t *,
570
 
                                xfs_dablk_t, xfs_daddr_t, xfs_dabuf_t **, int);
571
 
extern void     libxfs_da_log_buf (xfs_trans_t *, xfs_dabuf_t *, uint, uint);
572
 
extern int      libxfs_dir2_shrink_inode (xfs_da_args_t *, xfs_dir2_db_t,
573
 
                                xfs_dabuf_t *);
574
 
extern int      libxfs_dir2_grow_inode (xfs_da_args_t *, int, xfs_dir2_db_t *);
575
 
extern int      libxfs_dir2_isleaf (xfs_trans_t *, xfs_inode_t *, int *);
576
 
extern int      libxfs_dir2_isblock (xfs_trans_t *, xfs_inode_t *, int *);
577
 
extern void     libxfs_dir2_data_use_free (xfs_trans_t *, xfs_dabuf_t *,
578
 
                                xfs_dir2_data_unused_t *, xfs_dir2_data_aoff_t,
579
 
                                xfs_dir2_data_aoff_t, int *, int *);
580
 
extern void     libxfs_dir2_data_make_free (xfs_trans_t *, xfs_dabuf_t *,
581
 
                                xfs_dir2_data_aoff_t, xfs_dir2_data_aoff_t,
582
 
                                int *, int *);
583
 
extern void     libxfs_dir2_data_log_entry (xfs_trans_t *, xfs_dabuf_t *,
584
 
                                xfs_dir2_data_entry_t *);
585
 
extern void     libxfs_dir2_data_log_header (xfs_trans_t *, xfs_dabuf_t *);
586
 
extern void     libxfs_dir2_data_freescan (xfs_mount_t *, xfs_dir2_data_t *,
587
 
                                int *, char *);
588
 
extern void     libxfs_dir2_free_log_bests (xfs_trans_t *, xfs_dabuf_t *,
589
 
                                int, int);
590
450
 
591
 
/* Shared utility routines */
592
 
extern unsigned int     libxfs_log2_roundup(unsigned int i);
 
451
extern void     libxfs_fs_repair_cmn_err(int, struct xfs_mount *, char *, ...);
 
452
extern void     libxfs_fs_cmn_err(int, struct xfs_mount *, char *, ...);
593
453
 
594
454
extern void cmn_err(int, char *, ...);
595
455
enum ce { CE_DEBUG, CE_CONT, CE_NOTE, CE_WARN, CE_ALERT, CE_PANIC };
609
469
#include <xfs/xfs_log.h>
610
470
#include <xfs/xfs_log_priv.h>
611
471
 
 
472
#define XFS_INOBT_IS_FREE_DISK(rp,i)            \
 
473
                        ((be64_to_cpu((rp)->ir_free) & XFS_INOBT_MASK(i)) != 0)
 
474
/*
 
475
 * public xfs kernel routines to be called as libxfs_*
 
476
 */
 
477
 
 
478
/* xfs_alloc.c */
 
479
int libxfs_alloc_fix_freelist(xfs_alloc_arg_t *, int);
 
480
 
 
481
/* xfs_attr.c */
 
482
int libxfs_attr_get(struct xfs_inode *, const char *, char *, int *, int);
 
483
int libxfs_attr_set(struct xfs_inode *, const char *, char *, int, int);
 
484
int libxfs_attr_remove(struct xfs_inode *, const char *, int);
 
485
 
 
486
/* xfs_bmap.c */
 
487
xfs_bmbt_rec_host_t *xfs_bmap_search_extents(xfs_inode_t *, xfs_fileoff_t,
 
488
                                int, int *, xfs_extnum_t *, xfs_bmbt_irec_t *,
 
489
                                xfs_bmbt_irec_t *);
 
490
 
 
491
/* xfs_attr_leaf.h */
 
492
#define libxfs_attr_leaf_newentsize     xfs_attr_leaf_newentsize
 
493
 
 
494
/* xfs_bit.h */
 
495
#define libxfs_highbit32                xfs_highbit32
 
496
#define libxfs_highbit64                xfs_highbit64
 
497
 
 
498
/* xfs_bmap.h */
 
499
#define libxfs_bmap_cancel              xfs_bmap_cancel
 
500
#define libxfs_bmap_last_offset         xfs_bmap_last_offset
 
501
#define libxfs_bmapi                    xfs_bmapi
 
502
#define libxfs_bunmapi                  xfs_bunmapi
 
503
 
 
504
/* xfs_bmap_btree.h */
 
505
#define libxfs_bmbt_disk_get_all        xfs_bmbt_disk_get_all
 
506
 
 
507
/* xfs_da_btree.h */
 
508
#define libxfs_da_brelse                xfs_da_brelse
 
509
#define libxfs_da_hashname              xfs_da_hashname
 
510
#define libxfs_da_shrink_inode          xfs_da_shrink_inode
 
511
 
 
512
/* xfs_dir2.h */
 
513
#define libxfs_dir_createname           xfs_dir_createname
 
514
#define libxfs_dir_init                 xfs_dir_init
 
515
#define libxfs_dir_lookup               xfs_dir_lookup
 
516
#define libxfs_dir_replace              xfs_dir_replace
 
517
#define libxfs_dir2_isblock             xfs_dir2_isblock
 
518
#define libxfs_dir2_isleaf              xfs_dir2_isleaf
 
519
 
 
520
/* xfs_dir2_data.h */
 
521
#define libxfs_dir2_data_freescan       xfs_dir2_data_freescan
 
522
#define libxfs_dir2_data_log_entry      xfs_dir2_data_log_entry
 
523
#define libxfs_dir2_data_log_header     xfs_dir2_data_log_header
 
524
#define libxfs_dir2_data_make_free      xfs_dir2_data_make_free
 
525
#define libxfs_dir2_data_use_free       xfs_dir2_data_use_free
 
526
#define libxfs_dir2_shrink_inode        xfs_dir2_shrink_inode
 
527
 
 
528
/* xfs_inode.h */
 
529
#define libxfs_dinode_from_disk         xfs_dinode_from_disk
 
530
#define libxfs_dinode_to_disk           xfs_dinode_to_disk
 
531
#define libxfs_idata_realloc            xfs_idata_realloc
 
532
#define libxfs_idestroy_fork            xfs_idestroy_fork
 
533
 
 
534
/* xfs_mount.h */
 
535
#define libxfs_mod_sb                   xfs_mod_sb
 
536
#define libxfs_sb_from_disk             xfs_sb_from_disk
 
537
#define libxfs_sb_to_disk               xfs_sb_to_disk
 
538
 
 
539
/* xfs_rtalloc.c */
 
540
int libxfs_rtfree_extent(struct xfs_trans *, xfs_rtblock_t, xfs_extlen_t);
 
541
 
612
542
#endif  /* __LIBXFS_H__ */