Imported reiserfsprogs-3.6.2

This commit is contained in:
Jeff Mahoney committed 2012-10-11 11:27:42 -04:00
1 parent e7102bdb66
commit b69459eb80
86 files changed
+23136 -13423

No files matched your search

+1 -1
View File
@@ -1 +1 @@
noinst_HEADERS = io.h misc.h reiserfs_fs.h reiserfs_lib.h
noinst_HEADERS = io.h misc.h reiserfs_fs.h reiserfs_lib.h swab.h
+51 -17
View File
@@ -1,6 +1,6 @@
# Makefile.in generated automatically by automake 1.4 from Makefile.am
# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@@ -62,13 +62,15 @@ MAKEINFO = @MAKEINFO@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
VERSION = @VERSION@
sbindir = @sbindir@
noinst_HEADERS = io.h misc.h reiserfs_fs.h reiserfs_lib.h
noinst_HEADERS = io.h misc.h reiserfs_fs.h reiserfs_lib.h swab.h
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = config.h
CONFIG_CLEAN_FILES =
HEADERS = $(noinst_HEADERS)
DIST_COMMON = Makefile.am Makefile.in
DIST_COMMON = ./stamp-h.in Makefile.am Makefile.in config.h.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
@@ -85,6 +87,34 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
config.h: stamp-h
@if test ! -f $@; then \
rm -f stamp-h; \
$(MAKE) stamp-h; \
else :; fi
stamp-h: $(srcdir)/config.h.in $(top_builddir)/config.status
cd $(top_builddir) \
&& CONFIG_FILES= CONFIG_HEADERS=include/config.h \
$(SHELL) ./config.status
@echo timestamp > stamp-h 2> /dev/null
$(srcdir)/config.h.in: $(srcdir)/stamp-h.in
@if test ! -f $@; then \
rm -f $(srcdir)/stamp-h.in; \
$(MAKE) $(srcdir)/stamp-h.in; \
else :; fi
$(srcdir)/stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOHEADER)
@echo timestamp > $(srcdir)/stamp-h.in 2> /dev/null
mostlyclean-hdr:
clean-hdr:
distclean-hdr:
-rm -f config.h
maintainer-clean-hdr:
tags: TAGS
ID: $(HEADERS) $(SOURCES) $(LISP)
@@ -95,15 +125,15 @@ ID: $(HEADERS) $(SOURCES) $(LISP)
here=`pwd` && cd $(srcdir) \
&& mkid -f$$here/ID $$unique $(LISP)
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
test -z "$(ETAGS_ARGS)config.h.in$$unique$(LISP)$$tags" \
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags config.h.in $$unique $(LISP) -o $$here/TAGS)
mostlyclean-tags:
@@ -122,7 +152,7 @@ distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pr $$/$$file $(distdir)/$$file; \
cp -pr $$d/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
@@ -137,6 +167,9 @@ check-am: all-am
check: check-am
installcheck-am:
installcheck: installcheck-am
all-recursive-am: config.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive
install-exec-am:
install-exec: install-exec-am
@@ -148,7 +181,7 @@ install-am: all-am
install: install-am
uninstall-am:
uninstall: uninstall-am
all-am: Makefile $(HEADERS)
all-am: Makefile $(HEADERS) config.h
all-redirect: all-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
@@ -164,28 +197,29 @@ distclean-generic:
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
maintainer-clean-generic:
mostlyclean-am: mostlyclean-tags mostlyclean-generic
mostlyclean-am: mostlyclean-hdr mostlyclean-tags mostlyclean-generic
mostlyclean: mostlyclean-am
clean-am: clean-tags clean-generic mostlyclean-am
clean-am: clean-hdr clean-tags clean-generic mostlyclean-am
clean: clean-am
distclean-am: distclean-tags distclean-generic clean-am
distclean-am: distclean-hdr distclean-tags distclean-generic clean-am
distclean: distclean-am
maintainer-clean-am: maintainer-clean-tags maintainer-clean-generic \
distclean-am
maintainer-clean-am: maintainer-clean-hdr maintainer-clean-tags \
maintainer-clean-generic distclean-am
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
maintainer-clean: maintainer-clean-am
.PHONY: tags mostlyclean-tags distclean-tags clean-tags \
maintainer-clean-tags distdir info-am info dvi-am dvi check check-am \
installcheck-am installcheck install-exec-am install-exec \
.PHONY: mostlyclean-hdr distclean-hdr clean-hdr maintainer-clean-hdr \
tags mostlyclean-tags distclean-tags clean-tags maintainer-clean-tags \
distdir info-am info dvi-am dvi check check-am installcheck-am \
installcheck all-recursive-am install-exec-am install-exec \
install-data-am install-data install-am install uninstall-am uninstall \
all-redirect all-am all installdirs mostlyclean-generic \
distclean-generic clean-generic maintainer-clean-generic clean \
+90
View File
@@ -0,0 +1,90 @@
/* include/config.h.in. Generated automatically from configure.in by autoheader. */
/*
* Copyright 1996, 1997 Hans Reiser, see reiserfs/README for licensing and copyright details
*/
/* Define if you don't have `vprintf' but do have `_doprnt.' */
#undef HAVE_DOPRNT
/* Define if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
/* Define if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define if you have the <limits.h> header file. */
#undef HAVE_LIMITS_H
/* Define if you have the <malloc.h> header file. */
#undef HAVE_MALLOC_H
/* Define if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define if you have the `strerror' function. */
#undef HAVE_STRERROR
/* Define if you have the `strftime' function. */
#undef HAVE_STRFTIME
/* Define if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define if you have the `strstr' function. */
#undef HAVE_STRSTR
/* Define if you have the `strtol' function. */
#undef HAVE_STRTOL
/* Define if `st_rdev' is member of `struct stat'. */
#undef HAVE_STRUCT_STAT_ST_RDEV
/* Define if your `struct stat' has `st_rdev'. Deprecated, use
`HAVE_STRUCT_STAT_ST_RDEV' instead. */
#undef HAVE_ST_RDEV
/* Define if you have the <sys/ioctl.h> header file. */
#undef HAVE_SYS_IOCTL_H
/* Define if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define if you have the `vprintf' function. */
#undef HAVE_VPRINTF
/* gets set when configure --enable-io-failure-emulation */
#undef IO_FAILURE_EMULATION
/* Name of package */
#undef PACKAGE
/* Define if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Version number of package */
#undef VERSION
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
/* Define as `__inline' if that's what the C compiler calls it, or to nothing
if it is not supported. */
#undef inline
/* Define to `unsigned' if <sys/types.h> does not define. */
#undef size_t
+38 -22
View File
@@ -1,29 +1,42 @@
struct buffer_head {
unsigned long b_blocknr;
unsigned short b_dev;
unsigned long b_size;
char * b_data;
unsigned long b_state;
unsigned int b_count;
unsigned int b_list ;
void (*b_end_io)(struct buffer_head *bh, int uptodate);
/*
* Copyright 1996-2002 Hans Reiser
*/
struct buffer_head * b_next;
struct buffer_head * b_prev;
struct buffer_head * b_hash_next;
struct buffer_head * b_hash_prev;
struct buffer_head {
unsigned long b_blocknr;
unsigned short b_dev;
unsigned long b_size;
char * b_data;
unsigned long b_state;
unsigned int b_count;
unsigned int b_list ;
void (*b_start_io) (unsigned long);
void (*b_end_io)(struct buffer_head *bh, int uptodate);
struct buffer_head * b_next;
struct buffer_head * b_prev;
struct buffer_head * b_hash_next;
struct buffer_head * b_hash_prev;
};
#define BH_Uptodate 0
#define BH_Dirty 1
#define BH_Lock 2
#define BH_Do_not_flush 3
#define buffer_uptodate(bh) test_bit(BH_Uptodate, &(bh)->b_state)
#define buffer_dirty(bh) test_bit(BH_Dirty, &(bh)->b_state)
#define buffer_locked(bh) test_bit(BH_Lock, &(bh)->b_state)
#define buffer_clean(bh) !test_bit(BH_Dirty, &(bh)->b_state)
#define buffer_do_not_flush(bh) test_bit(BH_Do_not_flush, &(bh)->b_state)
#define mark_buffer_dirty(bh) set_bit(BH_Dirty, &(bh)->b_state)
#define mark_buffer_uptodate(bh,i) set_bit(BH_Uptodate, &(bh)->b_state)
#define mark_buffer_clean(bh) clear_bit(BH_Dirty, &(bh)->b_state)
#define mark_buffer_do_not_flush(bh) set_bit(BH_Do_not_flush, &(bh)->b_state)
#define clear_buffer_do_not_flush(bh) clear_bit(BH_Do_not_flush, &(bh)->b_state)
/*
printf ("%s:%s:%u %p %p %p\n",
__FILE__, __FUNCTION__, __LINE__,
@@ -32,26 +45,29 @@ __FILE__, __FUNCTION__, __LINE__,
__builtin_return_address (2));
*/
#define mark_buffer_uptodate(bh,i) set_bit(BH_Uptodate, &(bh)->b_state)
#define mark_buffer_clean(bh) clear_bit(BH_Dirty, &(bh)->b_state)
void __wait_on_buffer (struct buffer_head * bh);
struct buffer_head * getblk (int dev, int block, int size);
struct buffer_head * reiserfs_getblk (int dev, int block, int size, int *repeat);
struct buffer_head * getblk (int dev, unsigned long block, int size);
struct buffer_head * reiserfs_getblk (int dev, unsigned long block, int size, int *repeat);
struct buffer_head * find_buffer (int dev, int block, int size);
struct buffer_head * get_hash_table(dev_t dev, int block, int size);
struct buffer_head * find_buffer (int dev, unsigned long block, int size);
struct buffer_head * get_hash_table(dev_t dev, unsigned long block, int size);
struct buffer_head * bread (int dev, unsigned long block, size_t size);
struct buffer_head * reiserfs_bread (int dev, int block, int size, int *repeat);
struct buffer_head * reiserfs_bread (int dev, unsigned long block, int size, int *repeat);
int valid_offset (int fd, loff_t offset);
int bwrite (struct buffer_head * bh);
void brelse (struct buffer_head * bh);
void bforget (struct buffer_head * bh);
void check_and_free_buffer_mem (void);
void init_rollback_file (char * rollback_file, int *bloksize, FILE * log);
int open_rollback_file (char * rollback_file, FILE * log);
void close_rollback_file ();
void do_fsck_rollback (int fd_device, int fd_journal_device, FILE * log);
void flush_buffers (void);
void flush_buffers (dev_t);
void free_buffers (void);
void invalidate_buffers (dev_t dev);
loff_t reiserfs_llseek (unsigned int fd, loff_t offset, unsigned int origin);
int user_confirmed (FILE * fp, char * q, char * yes);
+116 -22
View File
@@ -1,42 +1,136 @@
/*
* Copyright 1996-2000 Hans Reiser
* Copyright 1996-2002 Hans Reiser
*/
/* nothing abount reiserfs here */
#include <endian.h>
#include "swab.h"
void die (char * fmt, ...);
#define POSITION_FOUND 8
#define POSITION_NOT_FOUND 9
void die (char * fmt, ...) __attribute__ ((format (printf, 1, 2)));
void * getmem (int size);
void freemem (void * p);
void checkmem (char * p, int size);
void * expandmem (void * p, int size, int by);
int get_mem_size (char * p);
int is_mounted (char * device_name);
int is_mounted_read_only (char * device_name);
void check_and_free_mem (void);
char * kdevname (int dev);
int set_bit (int nr, void * addr);
int clear_bit (int nr, void * addr);
int test_bit(int nr, const void * addr);
int find_first_zero_bit (const void *vaddr, unsigned size);
int find_next_zero_bit (const void *vaddr, unsigned size, unsigned offset);
void print_how_far (unsigned long * passed, unsigned long total, int inc, int quiet);
void print_how_far (FILE * fp, unsigned long * passed, unsigned long total, int inc, int quiet);
void print_how_fast (unsigned long total,
unsigned long passed, int cursor_pos);
int user_confirmed (char * q, char * yes);
unsigned long passed, int cursor_pos, int reset_time);
__u32 get_random (void);
int uuid_is_null(unsigned char * uuid);
int generate_random_uuid (unsigned char * uuid);
int uuid_is_correct (unsigned char * uuid);
int set_uuid (const unsigned char * text, unsigned char * UUID);
#if __BYTE_ORDER == __LITTLE_ENDIAN
int le_set_bit (int nr, void * addr);
int le_clear_bit (int nr, void * addr);
int le_test_bit(int nr, const void * addr);
int le_find_first_zero_bit (const void *vaddr, unsigned size);
int le_find_next_zero_bit (const void *vaddr, unsigned size, unsigned offset);
# define cpu_to_le16(val) (val)
# define le16_to_cpu(val) (val)
# define cpu_to_le32(val) (val)
# define le32_to_cpu(val) (val)
# define cpu_to_le64(val) (val)
# define le64_to_cpu(val) (val)
# define set_bit(nr, addr) le_set_bit(nr, addr)
# define clear_bit(nr, addr) le_clear_bit(nr, addr)
# define test_bit(nr, addr) le_test_bit(nr, addr)
# define find_first_zero_bit(vaddr, size) le_find_first_zero_bit(vaddr, size)
# define find_next_zero_bit(vaddr, size, off) \
le_find_next_zero_bit(vaddr, size, off)
#elif __BYTE_ORDER == __BIG_ENDIAN
int be_set_bit (int nr, void * addr);
int be_clear_bit (int nr, void * addr);
int be_test_bit(int nr, const void * addr);
int be_find_first_zero_bit (const void *vaddr, unsigned size);
int be_find_next_zero_bit (const void *vaddr, unsigned size, unsigned offset);
# define cpu_to_le16(val) swab16(val)
# define le16_to_cpu(val) swab16(val)
# define cpu_to_le32(val) swab32(val)
# define le32_to_cpu(val) swab32(val)
# define cpu_to_le64(val) swab64(val)
# define le64_to_cpu(val) swab64(val)
# define set_bit(nr, addr) be_set_bit(nr, addr)
# define clear_bit(nr, addr) be_clear_bit(nr, addr)
# define test_bit(nr, addr) be_test_bit(nr, addr)
# define find_first_zero_bit(vaddr, size) be_find_first_zero_bit(vaddr, size)
# define find_next_zero_bit(vaddr, size, off) \
be_find_next_zero_bit(vaddr, size, off)
#else
# error "nuxi/pdp-endian archs are not supported"
#endif
/*
int test_and_set_bit (int nr, void * addr);
int test_and_clear_bit (int nr, void * addr);
*/
inline __u32 cpu_to_le32 (__u32 val);
inline __u32 le32_to_cpu (__u32 val);
inline __u16 cpu_to_le16 (__u16 val);
inline __u16 le16_to_cpu (__u16 val);
inline __u64 cpu_to_le64 (__u64 val);
inline __u64 le64_to_cpu (__u64 val);
unsigned long count_blocks (char * filename, int blocksize, int fd);
unsigned long count_blocks (char * filename, int blocksize);
mode_t get_st_mode (char * file_name);
dev_t get_st_rdev (char * file_name);
off64_t get_st_size (char * file_name);
blkcnt64_t get_st_blocks (char * file_name);
/* these are to access bitfield in endian safe manner */
__u16 mask16 (int from, int count);
__u32 mask32 (int from, int count);
__u64 mask64 (int from, int count);
int reiserfs_bin_search (void * key, void * base, __u32 num, int width,
__u32 *ppos, comparison_fn_t comp_func);
struct block_handler {
__u32 blocknr;
dev_t device;
};
int blocklist__is_block_saved (struct block_handler ** base, __u32 * count, __u32 blocknr, dev_t device, __u32 * position);
void blocklist__insert_in_position (void ** base, __u32 * count, void * block_h, int elem_size, __u32 * position);
int blockdev_list_compare (const void * block1, const void * block2);
#define set_bit_field_XX(XX,vp,val,from,count) \
{\
__u##XX * p, tmp;\
\
/* make sure that given value can be put in 'count' bits */\
if (val > (1 << count))\
die ("set_bit_field: val %d is too big for %d bits", val, count);\
\
p = (__u##XX *)vp;\
tmp = le##XX##_to_cpu (*p);\
\
/* clear 'count' bits starting from 'from'-th one */\
tmp &= ~mask##XX (from, count);\
\
/* put given value in proper bits */\
tmp |= (val << from);\
\
*p = cpu_to_le##XX (tmp);\
}
#define get_bit_field_XX(XX,vp,from,count) \
\
__u##XX * p, tmp;\
\
p = (__u##XX *)vp;\
tmp = le##XX##_to_cpu (*p);\
\
/* clear all bits but 'count' bits starting from 'from'-th one */\
tmp &= mask##XX (from, count);\
\
/* get value written in specified bits */\
tmp >>= from;\
return tmp;
+615 -456
View File
File diff suppressed because it is too large. Load diff
+285 -82
View File
@@ -1,11 +1,13 @@
/*
* Copyright 2000 by Hans Reiser, licensing governed by reiserfs/README
* Copyright 2000-2002 by Hans Reiser, licensing governed by reiserfs/README
*/
#ifndef REISERFS_LIB_H
#define REISERFS_LIB_H
typedef struct super_block * reiserfs_filsys_t;
typedef struct reiserfs_filsys reiserfs_filsys_t;
#include "reiserfs_fs.h"
@@ -14,98 +16,187 @@ struct _bitmap {
unsigned long bm_bit_size;
char * bm_map;
unsigned long bm_set_bits;
int bm_dirty; /* used for fetched bitmap */
};
typedef struct _bitmap * reiserfs_bitmap_t;
typedef struct _bitmap reiserfs_bitmap_t;
struct super_block {
int s_version; /* on-disk format version */
reiserfs_bitmap_t bitmap; /* copy of reiserfs on-disk bitmap */
typedef __u32 (*hashf_t) (const char *, int);
struct reiserfs_filsys {
int fs_blocksize;
int fs_format; /* on-disk format version */
hashf_t fs_hash_function; /* pointer to function which is used to sort
names in directory. It is set by
reiserfs_open if it is set in the super
block, otherwise it is set by first
is_properly_hashed */
int s_dev; /* descriptor of opened block device file */
int s_blocksize;
struct buffer_head ** s_ap_bitmap; /* array of buffers containing bitmap
blocks */
struct buffer_head * s_sbh; /* buffer containing super block */
struct reiserfs_super_block * s_rs; /* pointer to its b_data */
int s_dirt;
hashf_t s_hash_function; /* pointer to function which is used to sort
names in directory. It is set by reiserfs_open
if it is set in the super block, otherwise it
is set by first is_properly_hashed */
char * file_name; /* file name of underlying device */
int s_flags;
void * s_vp;
int (*block_allocator) (reiserfs_filsys_t fs,
char * fs_file_name; /* file name of underlying device */
int fs_dev; /* descriptor of opened block device file */
struct buffer_head * fs_super_bh; /* buffer containing super block */
struct reiserfs_super_block * fs_ondisk_sb; /* pointer to its b_data */
reiserfs_bitmap_t * fs_bitmap2; /* ondisk bitmap after
reiserfs_open_ondisk_bitmap */
/* opened journal fields */
char * fs_j_file_name; /* file name of relocated journal device */
int fs_journal_dev; /* descriptor of opened journal device */
struct buffer_head * fs_jh_bh; /* buffer containing journal header */
/* badblocks */
reiserfs_bitmap_t * fs_badblocks_bm;
int fs_dirt;
int fs_flags;
void * fs_vp;
int (*block_allocator) (reiserfs_filsys_t * fs,
unsigned long * free_blocknrs,
unsigned long start, int amount_needed);
int (*block_deallocator) (reiserfs_filsys_t fs, unsigned long block);
int (*block_deallocator) (reiserfs_filsys_t * fs, unsigned long block);
};
struct _transaction {
unsigned long mount_id;
unsigned long trans_id;
unsigned long desc_blocknr;
unsigned long trans_len;
unsigned long commit_blocknr;
unsigned long next_trans_offset;
};
typedef struct _transaction reiserfs_trans_t;
/* reiserfslib.c */
reiserfs_filsys_t reiserfs_open (char * filename, int flags, int * error, void * vp);
void reiserfs_read_bitmap_blocks (reiserfs_filsys_t);
void reiserfs_free_bitmap_blocks (reiserfs_filsys_t);
int no_reiserfs_found (reiserfs_filsys_t fs);
void reiserfs_reopen (reiserfs_filsys_t fs, int flags);
void reiserfs_flush (reiserfs_filsys_t fs);
void reiserfs_free (reiserfs_filsys_t fs);
void reiserfs_close (reiserfs_filsys_t fs);
int reiserfs_new_blocknrs (reiserfs_filsys_t fs,
void init_tb_struct (struct tree_balance * tb, reiserfs_filsys_t *, struct path * path, int size);
reiserfs_filsys_t * reiserfs_open (char * filename, int flags, int * error, void * vp);
reiserfs_filsys_t * reiserfs_create (char * filename, int version, unsigned long block_count,
int block_size, int default_journal, int new_format);
void reiserfs_flush (reiserfs_filsys_t *);
void reiserfs_free (reiserfs_filsys_t *);
void reiserfs_close (reiserfs_filsys_t *);
void reiserfs_reopen (reiserfs_filsys_t *, int flags);
int is_opened_rw (reiserfs_filsys_t * fs);
struct key * get_next_key_2 (struct path * path);
/*
void reiserfs_read_bitmap_blocks (reiserfs_filsys_t *);
void reiserfs_free_bitmap_blocks (reiserfs_filsys_t *);
*/
int no_reiserfs_found (reiserfs_filsys_t *);
int is_block_count_correct (unsigned long block_of_super_block, int block_size,
unsigned long block_count, unsigned long journal_size);
//unsigned long min_block_amount (int block_size, unsigned long journal_size);
unsigned long get_size_of_journal_or_reserved_area (struct reiserfs_super_block * sb);
int reiserfs_new_blocknrs (reiserfs_filsys_t *,
unsigned long * free_blocknrs, unsigned long start,
int amount_needed);
int reiserfs_free_block (reiserfs_filsys_t fs, unsigned long block);
int spread_bitmaps (reiserfs_filsys_t fs);
int filesystem_dirty (reiserfs_filsys_t fs);
void mark_filesystem_dirty (reiserfs_filsys_t fs);
int reiserfs_free_block (reiserfs_filsys_t *, unsigned long block);
int spread_bitmaps (reiserfs_filsys_t *);
int filesystem_dirty (reiserfs_filsys_t *);
void mark_filesystem_dirty (reiserfs_filsys_t *);
void reiserfs_paste_into_item (reiserfs_filsys_t fs, struct path * path,
void reiserfs_paste_into_item (reiserfs_filsys_t *, struct path * path,
const void * body, int size);
void reiserfs_insert_item (reiserfs_filsys_t fs, struct path * path,
void reiserfs_insert_item (reiserfs_filsys_t *, struct path * path,
struct item_head * ih, const void * body);
int reiserfs_find_entry (reiserfs_filsys_t fs, struct key * dir, char * name,
int * min_gen_counter);
int reiserfs_add_entry (reiserfs_filsys_t fs, struct key * dir, char * name,
int reiserfs_locate_entry (reiserfs_filsys_t *, struct key * dir, char * name,
struct path * path);
int reiserfs_find_entry (reiserfs_filsys_t *, struct key * dir, char * name,
int * min_gen_counter, struct key * key);
int reiserfs_add_entry (reiserfs_filsys_t *, struct key * dir, char * name, int name_len,
struct key * key, int fsck_need);
int _search_by_entry_key (reiserfs_filsys_t fs, struct key * key,
struct path * path);
/*int reiserfs_bin_search (void * key, void * base, int num, int width,
int *ppos, comparison_fn_t comp_func);*/
struct key * uget_lkey (struct path * path);
struct key * uget_rkey (struct path * path);
int reiserfs_search_by_key_3 (reiserfs_filsys_t *, struct key * key,
struct path * path);
int reiserfs_search_by_key_4 (reiserfs_filsys_t *, struct key * key,
struct path * path);
int reiserfs_search_by_entry_key (reiserfs_filsys_t *, struct key * key,
struct path * path);
int usearch_by_position (reiserfs_filsys_t *, struct key * key, int version, struct path * path);
struct key * reiserfs_next_key (struct path * path);
void copy_key (void * to, void * from);
void copy_short_key (void * to, void * from);
void copy_item_head(void * p_v_to, void * p_v_from);
int comp_keys (void * k1, void * k2);
int comp_short_keys (void * p_s_key1, void * p_s_key2);
int comp_keys (const void * k1, const void * k2);
int comp_keys_3 (const void * k1, const void * k2);
int comp_short_keys (const void * p_s_key1, const void * p_s_key2);
int comp_items (struct item_head * p_s_ih, struct path * p_s_path);
int create_dir_sd (reiserfs_filsys_t * fs,
struct path * path, struct key * key,
void (*modify_item)(struct item_head *, void *));
void make_sure_root_dir_exists (reiserfs_filsys_t * fs,
void (*modyfy_item)(struct item_head *, void *),
int ih_flags);
int create_badblock_bitmap (reiserfs_filsys_t * fs, char * badblocks_file);
void add_badblock_list (reiserfs_filsys_t * fs, int no_badblock_in_tree_yet);
extern struct key root_dir_key;
extern struct key parent_root_dir_key;
extern struct key lost_found_dir_key;
extern __u16 root_dir_format;
extern __u16 lost_found_dir_format;
/* bitmap.c */
int reiserfs_open_ondisk_bitmap (reiserfs_filsys_t *);
int reiserfs_create_ondisk_bitmap (reiserfs_filsys_t *);
void reiserfs_free_ondisk_bitmap (reiserfs_filsys_t *);
void reiserfs_close_ondisk_bitmap (reiserfs_filsys_t *);
int reiserfs_flush_to_ondisk_bitmap (reiserfs_bitmap_t * bm, reiserfs_filsys_t * fs);
reiserfs_bitmap_t reiserfs_create_bitmap (unsigned int bit_count);
int reiserfs_expand_bitmap (reiserfs_bitmap_t bm, unsigned int bit_count);
void reiserfs_delete_bitmap (reiserfs_bitmap_t bm);
void reiserfs_bitmap_copy (reiserfs_bitmap_t to, reiserfs_bitmap_t from);
int reiserfs_bitmap_compare (reiserfs_bitmap_t bm1, reiserfs_bitmap_t bm2);
void reiserfs_bitmap_set_bit (reiserfs_bitmap_t bm, unsigned int bit_number);
void reiserfs_bitmap_clear_bit (reiserfs_bitmap_t bm, unsigned int bit_number);
reiserfs_bitmap_t * reiserfs_create_bitmap (unsigned int bit_count);
int reiserfs_expand_bitmap (reiserfs_bitmap_t * bm, unsigned int bit_count);
void reiserfs_shrink_bitmap (reiserfs_bitmap_t * bm, unsigned int bit_count);
void reiserfs_delete_bitmap (reiserfs_bitmap_t * bm);
void reiserfs_bitmap_copy (reiserfs_bitmap_t * to, reiserfs_bitmap_t * from);
int reiserfs_bitmap_compare (reiserfs_bitmap_t * bm1, reiserfs_bitmap_t * bm2);
void reiserfs_bitmap_disjunction (reiserfs_bitmap_t * disk, reiserfs_bitmap_t * cont);
void reiserfs_bitmap_set_bit (reiserfs_bitmap_t * bm, unsigned int bit_number);
void reiserfs_bitmap_clear_bit (reiserfs_bitmap_t * bm, unsigned int bit_number);
int reiserfs_bitmap_test_bit (reiserfs_bitmap_t bm, unsigned int bit_number);
int reiserfs_bitmap_find_zero_bit (reiserfs_bitmap_t bm, unsigned long * start);
int reiserfs_fetch_disk_bitmap (reiserfs_bitmap_t bm, reiserfs_filsys_t fs);
int reiserfs_flush_bitmap (reiserfs_bitmap_t bm, reiserfs_filsys_t fs);
void reiserfs_bitmap_zero (reiserfs_bitmap_t bm);
void reiserfs_bitmap_fill (reiserfs_bitmap_t bm);
int reiserfs_bitmap_ones (reiserfs_bitmap_t bm);
int reiserfs_bitmap_zeros (reiserfs_bitmap_t bm);
int reiserfs_bitmap_test_bit (reiserfs_bitmap_t * bm, unsigned int bit_number);
int reiserfs_bitmap_find_zero_bit (reiserfs_bitmap_t * bm, unsigned long * start);
/*int reiserfs_fetch_ondisk_bitmap (reiserfs_bitmap_t * bm, reiserfs_filsys_t *);*/
/*int reiserfs_flush_bitmap (reiserfs_bitmap_t * bm, reiserfs_filsys_t *);*/
void reiserfs_bitmap_zero (reiserfs_bitmap_t * bm);
void reiserfs_bitmap_fill (reiserfs_bitmap_t * bm);
int reiserfs_bitmap_ones (reiserfs_bitmap_t * bm);
int reiserfs_bitmap_zeros (reiserfs_bitmap_t * bm);
void reiserfs_bitmap_save (char * filename, reiserfs_bitmap_t bm);
reiserfs_bitmap_t reiserfs_bitmap_load (char * filename);
void reiserfs_bitmap_invert (reiserfs_bitmap_t bm);
FILE * open_file(char * filename, char * option);
void close_file(FILE * fp);
void reiserfs_bitmap_save (FILE * fp, reiserfs_bitmap_t * bm);
/* this probably should be in fsck */
void reiserfs_begin_stage_info_save(FILE * file, unsigned long stage);
void reiserfs_end_stage_info_save(FILE * file);
int is_stage_magic_correct (FILE * fp);
//void reiserfs_stage_info_save(struct fsck_data *, FILE * file);
reiserfs_bitmap_t * reiserfs_bitmap_load (FILE * fp);
void reiserfs_bitmap_invert (reiserfs_bitmap_t * bm);
int reiserfs_remove_entry (reiserfs_filsys_t fs, struct key * key);
int reiserfs_remove_entry (reiserfs_filsys_t *, struct key * key);
@@ -115,21 +206,29 @@ int reiserfs_remove_entry (reiserfs_filsys_t fs, struct key * key);
#define THE_INTERNAL 2
#define THE_SUPER 3
#define THE_JDESC 4
#define THE_UNKNOWN 5
#define HAS_IH_ARRAY 5
#define THE_UNKNOWN 6
int is_reiserfs_magic_string (struct reiserfs_super_block * rs);
int is_reiser2fs_magic_string (struct reiserfs_super_block * rs);
int correct_direct_item_offset (__u64 offset, int format);
int is_blocksize_correct (int blocksize);
int is_reiserfs_3_5_magic_string (struct reiserfs_super_block * rs);
int is_reiserfs_3_6_magic_string (struct reiserfs_super_block * rs);
int is_reiserfs_jr_magic_string (struct reiserfs_super_block * rs);
int does_look_like_super_block (struct reiserfs_super_block * rs, int blocksize);
int is_any_reiserfs_magic_string (struct reiserfs_super_block * rs);
int get_reiserfs_format (struct reiserfs_super_block * sb);
int reiserfs_super_block_size (struct reiserfs_super_block * rs);
/*int magic_2_version (struct reiserfs_super_block * rs);*/
int is_prejournaled_reiserfs (struct reiserfs_super_block * rs);
int does_desc_match_commit (struct reiserfs_journal_desc *desc,
struct reiserfs_journal_commit *commit);
int who_is_this (char * buf, int blocksize);
int journal_size (struct super_block * s);
int not_data_block (struct super_block * s, unsigned long block);
int not_journalable (reiserfs_filsys_t fs, unsigned long block);
int block_of_bitmap (reiserfs_filsys_t fs, unsigned long block);
int block_of_journal (reiserfs_filsys_t fs, unsigned long block);
char * which_block (int code);
int get_journal_size (reiserfs_filsys_t *);
int not_data_block (reiserfs_filsys_t *, unsigned long block);
int not_journalable (reiserfs_filsys_t *, unsigned long block);
int block_of_bitmap (reiserfs_filsys_t *, unsigned long block);
int block_of_journal (reiserfs_filsys_t *, unsigned long block);
int is_tree_node (struct buffer_head * bh, int level);
int is_properly_hashed (reiserfs_filsys_t fs,
int is_properly_hashed (reiserfs_filsys_t *,
char * name, int namelen, __u32 offset);
int dir_entry_bad_location (struct reiserfs_de_head * deh,
struct item_head * ih, int first);
@@ -140,6 +239,7 @@ void make_empty_dir_item_v1 (char * body, __u32 dirid, __u32 objid,
__u32 par_dirid, __u32 par_objid);
void make_empty_dir_item (char * body, __u32 dirid, __u32 objid,
__u32 par_dirid, __u32 par_objid);
int reiserfs_is_fs_consistent (reiserfs_filsys_t * fs);
typedef void (*item_action_t) (struct buffer_head * bh, struct item_head * ih);
@@ -159,41 +259,144 @@ void set_offset (int format, struct key * key, loff_t offset);
void set_type_and_offset (int format, struct key * key, loff_t offset, int type);
typedef int (*check_unfm_func_t) (reiserfs_filsys_t fs, __u32);
int is_it_bad_item (reiserfs_filsys_t, struct item_head *, char *,
typedef int (*check_unfm_func_t) (reiserfs_filsys_t *, __u32);
int is_it_bad_item (reiserfs_filsys_t *, struct item_head *, char *,
check_unfm_func_t, int bad_dir);
int does_node_have_ih_array (char * buf, int blocksize);
#define hash_func_is_unknown(fs) ((fs)->s_hash_function == 0)
#define reiserfs_hash(fs) ((fs)->s_hash_function)
#define hash_func_is_unknown(fs) ((fs)->fs_hash_function == 0)
#define reiserfs_hash(fs) ((fs)->fs_hash_function)
int known_hashes (void);
char * code2name (int code);
int func2code (hashf_t func);
hashf_t code2func (int code);
hashf_t name2func (char * hash);
int find_hash_in_use (char * name, int namelen, __u32 hash_value_masked, int code_to_try_first);
int entry_length (struct item_head * ih, struct reiserfs_de_head * deh,
int pos_in_item);
char * name_in_entry (struct reiserfs_de_head * deh, int pos_in_item);
int name_length (struct item_head * ih,
int name_in_entry_length (struct item_head * ih,
struct reiserfs_de_head * deh, int pos_in_item);
int name_length (char * name, int key_format);
/* access to stat data fields */
void get_set_sd_field (int field, struct item_head * ih, void * sd,
void * value, int set);
#define GET_SD_MODE 0
#define GET_SD_SIZE 1
#define GET_SD_NLINK 2
#define GET_SD_BLOCKS 3
#define GET_SD_FIRST_DIRECT_BYTE 4
#define get_sd_mode(ih,sd,pmode) get_set_sd_field (GET_SD_MODE, ih, sd, pmode, 0/*get*/)
#define set_sd_mode(ih,sd,pmode) get_set_sd_field (GET_SD_MODE, ih, sd, pmode, 1/*set*/)
#define get_sd_size(ih,sd,psize) get_set_sd_field (GET_SD_SIZE, ih, sd, psize, 0/*get*/)
#define set_sd_size(ih,sd,psize) get_set_sd_field (GET_SD_SIZE, ih, sd, psize, 1/*set*/)
#define get_sd_blocks(ih,sd,pblocks) get_set_sd_field (GET_SD_BLOCKS, ih, sd, pblocks, 0/*get*/)
#define set_sd_blocks(ih,sd,pblocks) get_set_sd_field (GET_SD_BLOCKS, ih, sd, pblocks, 1/*set*/)
//#define get_sd_rdev(ih,sd,pblocks) get_set_sd_field (GET_SD_RDEV, ih, sd, pblocks, 0/*get*/)
//#define set_sd_rdev(ih,sd,pblocks) get_set_sd_field (GET_SD_RDEV, ih, sd, pblocks, 1/*set*/)
//#define get_sd_generation(ih,sd,pblocks) get_set_sd_field (GET_SD_GENER, ih, sd, pblocks, 0/*get*/)
//#define set_sd_generation(ih,sd,pblocks) get_set_sd_field (GET_SD_GENER, ih, sd, pblocks, 1/*set*/)
#define get_sd_nlink(ih,sd,pnlink) get_set_sd_field (GET_SD_NLINK, ih, sd, pnlink, 0/*get*/)
#define set_sd_nlink(ih,sd,pnlink) get_set_sd_field (GET_SD_NLINK, ih, sd, pnlink, 1/*set*/)
#define get_sd_first_direct_byte(ih,sd,pfdb) get_set_sd_field (GET_SD_FIRST_DIRECT_BYTE, ih, sd, pfdb, 0/*get*/)
#define set_sd_first_direct_byte(ih,sd,pfdb) get_set_sd_field (GET_SD_FIRST_DIRECT_BYTE, ih, sd, pfdb, 1/*set*/)
int is_objectid_used (reiserfs_filsys_t * fs, __u32 objectid);
void mark_objectid_used (reiserfs_filsys_t * fs, __u32 objectid);
/* journal.c */
int get_boundary_transactions (reiserfs_filsys_t *, reiserfs_trans_t *,
reiserfs_trans_t *);
int next_transaction (reiserfs_filsys_t *, reiserfs_trans_t *, reiserfs_trans_t);
int replay_one_transaction (reiserfs_filsys_t *, reiserfs_trans_t *);
typedef void (*action_on_trans_t) (reiserfs_filsys_t *, reiserfs_trans_t *);
void for_each_transaction (reiserfs_filsys_t *, action_on_trans_t);
typedef void (*action_on_block_t) (reiserfs_filsys_t *, reiserfs_trans_t *,
int index,
unsigned long in_journal,
unsigned long in_place);
void for_each_block (reiserfs_filsys_t * fs, reiserfs_trans_t * trans,
action_on_block_t action);
void reiserfs_only_reopen (reiserfs_filsys_t * fs, int flag);
int reiserfs_open_journal (reiserfs_filsys_t *, char *, int flags);
int reiserfs_create_journal (reiserfs_filsys_t * fs, char * j_filename,
unsigned long offset, unsigned long len,
int transaction_max_size);
int reiserfs_journal_opened (reiserfs_filsys_t *);
void reiserfs_flush_journal (reiserfs_filsys_t * fs);
void reiserfs_free_journal (reiserfs_filsys_t * fs);
void reiserfs_close_journal (reiserfs_filsys_t *);
void reiserfs_reopen_journal (reiserfs_filsys_t * fs, int flag);
__u32 advise_journal_max_trans_age (void);
__u32 advise_journal_max_commit_age (void);
__u32 advise_journal_max_batch (unsigned long journal_trans_max);
__u32 advise_journal_max_trans_len (__u32 desired, __u32 journal_size, int blocksize);
/* prints.c */
void print_indirect_item (FILE * fp, struct buffer_head * bh, int item_num);
void print_block (FILE * fp, reiserfs_filsys_t, struct buffer_head * bh, ...);//int print_mode, int first, int last);
void print_block (FILE * fp, reiserfs_filsys_t *, struct buffer_head * bh, ...);//int print_mode, int first, int last);
int print_super_block (FILE * fp, reiserfs_filsys_t *, char * file_name, struct buffer_head * bh, int short_print);
void print_journal (reiserfs_filsys_t *);
void print_journal_header (reiserfs_filsys_t * fs);
void reiserfs_warning (FILE * fp, const char * fmt, ...);
char ftypelet (mode_t mode);
void reiserfs_print_item (FILE * fp, struct buffer_head * bh,
struct item_head * ih);
void print_filesystem_state (FILE * fp, reiserfs_filsys_t * fs);
void print_one_transaction (reiserfs_filsys_t * fs, reiserfs_trans_t * trans);
void print_journal_params (FILE * fp, struct journal_params * jp);
char * get_reiserfs_version (__u16 version);
int can_we_format_it (char * device_name, int force);
#define reiserfs_panic(fmt, list...) \
{\
fflush (stdout);\
fprintf (stderr, "%s %d %s\n", __FILE__, __LINE__, __FUNCTION__);\
reiserfs_warning (stderr, fmt, ## list);\
exit(4);\
reiserfs_warning (stderr, (const char *)fmt, ## list);\
reiserfs_warning (stderr, "\n" );\
abort ();\
}
#define reiserfs_exit(val, fmt, list...) \
{\
fflush (stdout);\
fprintf (stderr, "%s %d %s\n", __FILE__, __LINE__, __FUNCTION__);\
reiserfs_warning (stderr, (const char *)fmt, ## list);\
reiserfs_warning (stderr, "\n" );\
exit (val);\
}
#define check_forcing_ask_confirmation(force) \
if (force < 1) {\
/* avoid formatting it without being forced */\
reiserfs_warning (stderr, "Use -f to force over\n");\
return 0;\
}\
if (force < 2) {\
if (!user_confirmed (stderr, "Continue (y/n):", "y\n"))\
return 0;\
}\
#endif /* REISERFS_LIB_H */
View File
Whitespace-only changes.
+25
View File
@@ -0,0 +1,25 @@
#ifndef _REISERFS_SWAB_H_
#define _REISERFS_SWAB_H_
/* Stolen from linux/include/linux/byteorder/swab.h */
#define swab16(x) \
((__u16)( \
(((__u16)(x) & (__u16)0x00ffU) << 8) | \
(((__u16)(x) & (__u16)0xff00U) >> 8) ))
#define swab32(x) \
((__u32)( \
(((__u32)(x) & (__u32)0x000000ffUL) << 24) | \
(((__u32)(x) & (__u32)0x0000ff00UL) << 8) | \
(((__u32)(x) & (__u32)0x00ff0000UL) >> 8) | \
(((__u32)(x) & (__u32)0xff000000UL) >> 24) ))
#define swab64(x) \
((__u64)( \
(__u64)(((__u64)(x) & (__u64)0x00000000000000ffULL) << 56) | \
(__u64)(((__u64)(x) & (__u64)0x000000000000ff00ULL) << 40) | \
(__u64)(((__u64)(x) & (__u64)0x0000000000ff0000ULL) << 24) | \
(__u64)(((__u64)(x) & (__u64)0x00000000ff000000ULL) << 8) | \
(__u64)(((__u64)(x) & (__u64)0x000000ff00000000ULL) >> 8) | \
(__u64)(((__u64)(x) & (__u64)0x0000ff0000000000ULL) >> 24) | \
(__u64)(((__u64)(x) & (__u64)0x00ff000000000000ULL) >> 40) | \
(__u64)(((__u64)(x) & (__u64)0xff00000000000000ULL) >> 56) ))
#endif /* _REISERFS_SWAB_H_ */