Imported reiserfsprogs-3.6.19

This commit is contained in:
Jeff Mahoney committed 2012-10-11 11:31:31 -04:00
1 parent 3078c83c48
commit 0ed773997f
34 files changed
+724 -560

No files matched your search

+14 -7
View File
@@ -253,9 +253,13 @@ static int reiserfs_fetch_ondisk_bitmap (reiserfs_bitmap_t * bm, reiserfs_filsys
if (!bh) {
reiserfs_warning (stderr, "reiserfs_fetch_ondisk_bitmap: "
"bread failed reading bitmap (%lu)\n", block);
bh = getblk (fs->fs_dev, block, fs->fs_blocksize);
if (!bh)
reiserfs_panic ("reiserfs_fetch_ondisk_bitmap: getblk failed");
if (!bh) {
reiserfs_exit (1, "reiserfs_fetch_ondisk_bitmap: "
"getblk failed");
}
memset (bh->b_data, 0xff, bh->b_size);
mark_buffer_uptodate (bh, 1);
}
@@ -341,9 +345,10 @@ int reiserfs_flush_to_ondisk_bitmap (reiserfs_bitmap_t * bm, reiserfs_filsys_t *
while (to_copy) {
/* we bread to make sure that filesystem contains enough blocks */
bh = getblk (fs->fs_dev, block, fs->fs_blocksize);
if (!bh)
reiserfs_panic ("reiserfs_flush_to_ondisk_bitmap: "
"getblk failed for (%lu)\n", block);
if (!bh) {
reiserfs_exit (1, "Getblk failed for (%lu)\n", block);
}
memset (bh->b_data, 0xff, bh->b_size);
mark_buffer_uptodate (bh, 1);
@@ -685,7 +690,8 @@ void reiserfs_free_ondisk_bitmap (reiserfs_filsys_t * fs)
int reiserfs_open_ondisk_bitmap (reiserfs_filsys_t * fs)
{
if (fs->fs_bitmap2)
reiserfs_panic ("%s: bitmap is initiaized already", __FUNCTION__);
reiserfs_panic ("bitmap is initiaized already");
fs->fs_bitmap2 = reiserfs_create_bitmap (get_sb_block_count (fs->fs_ondisk_sb));
if (!fs->fs_bitmap2)
return -1;
@@ -705,7 +711,8 @@ int reiserfs_open_ondisk_bitmap (reiserfs_filsys_t * fs)
int reiserfs_create_ondisk_bitmap (reiserfs_filsys_t * fs)
{
if (fs->fs_bitmap2)
reiserfs_panic ("create: bitmap is initiaized already");
reiserfs_panic ("bitmap is initiaized already");
fs->fs_bitmap2 = reiserfs_create_bitmap (get_sb_block_count (fs->fs_ondisk_sb));
if (!fs->fs_bitmap2)
return 0;
+25 -11
View File
@@ -501,25 +501,37 @@ int reiserfs_open_journal (reiserfs_filsys_t * fs, char * j_filename, int flags)
"specified journal device %s.\nMust be not less than (%lu).\n",
get_jp_journal_size (sb_jp (sb)) + 1, j_filename,
JOURNAL_MIN_SIZE + 1);
close(fs->fs_journal_dev);
return 1;
}
count = count_blocks (j_filename, fs->fs_blocksize);
if (get_jp_journal_1st_block (sb_jp (sb)) + get_jp_journal_size (sb_jp (sb)) + 1 > count) {
reiserfs_warning (stderr, "Detected journal on specified device %s does not fit to "
"the device.\nStart block (%lu) + size (%lu) less than device size (%lu).\n",
j_filename, get_jp_journal_1st_block(sb_jp (sb)),
get_jp_journal_size(sb_jp (sb)) + 1, count);
if (!(count = count_blocks (j_filename, fs->fs_blocksize))) {
close(fs->fs_journal_dev);
return -1;
}
if (get_jp_journal_1st_block (sb_jp (sb)) +
get_jp_journal_size (sb_jp (sb)) + 1 > count)
{
reiserfs_warning (stderr, "Detected journal on specified device %s "
"does not fit to the device.\nStart block (%lu) + "
"size (%lu) less than device size (%lu).\n",
j_filename, get_jp_journal_1st_block(sb_jp (sb)),
get_jp_journal_size(sb_jp (sb)) + 1, count);
close(fs->fs_journal_dev);
return 1;
}
/* read journal header */
fs->fs_jh_bh = bread (fs->fs_journal_dev, get_jp_journal_1st_block (sb_jp (sb))
+ get_jp_journal_size (sb_jp (sb)), fs->fs_blocksize);
fs->fs_jh_bh = bread (fs->fs_journal_dev,
get_jp_journal_1st_block (sb_jp (sb)) +
get_jp_journal_size (sb_jp (sb)),
fs->fs_blocksize);
if (!fs->fs_jh_bh) {
reiserfs_warning (stderr, "reiserfs_open_journal: bread failed reading "
"journal header.\n");
reiserfs_warning (stderr, "reiserfs_open_journal: bread failed "
"reading journal header.\n");
close(fs->fs_journal_dev);
return -1;
}
@@ -574,7 +586,9 @@ int reiserfs_create_journal(
st.st_rdev = 0;
} else {
/* journal is to be on separate device */
blocks = count_blocks (j_device, fs->fs_blocksize);
if (!(blocks = count_blocks (j_device, fs->fs_blocksize)))
return 0;
if (!len) {
/* default size of a journal on a separate device is whole device */
if (blocks < offset) {
+9 -8
View File
@@ -528,7 +528,7 @@ int known_hashes (void)
#define good_name(hashfn,name,namelen,deh_offset) \
(GET_HASH_VALUE ((hashfn) (name, namelen)) == GET_HASH_VALUE (deh_offset))
(hash_value (hashfn, name, namelen) == GET_HASH_VALUE (deh_offset))
/* this also sets hash function */
@@ -579,7 +579,7 @@ int is_properly_hashed (reiserfs_filsys_t * fs,
}
int find_hash_in_use (char * name, int namelen, __u32 hash_value_masked, unsigned int code_to_try_first)
int find_hash_in_use (char * name, int namelen, __u32 offset, unsigned int code_to_try_first)
{
unsigned int i;
@@ -587,14 +587,14 @@ int find_hash_in_use (char * name, int namelen, __u32 hash_value_masked, unsigne
return UNSET_HASH;
if (code_to_try_first) {
if (hash_value_masked == GET_HASH_VALUE (hashes [code_to_try_first].func (name, namelen)))
if (good_name (hashes [code_to_try_first].func, name, namelen, offset))
return code_to_try_first;
}
for (i = 1; i < HASH_AMOUNT; i ++) {
if (i == code_to_try_first)
continue;
if (hash_value_masked == GET_HASH_VALUE (hashes [i].func (name, namelen)))
if (good_name (hashes [i].func, name, namelen, offset))
return i;
}
@@ -1051,17 +1051,18 @@ char * name_in_entry (struct reiserfs_de_head * deh, int pos_in_item)
int name_in_entry_length (struct item_head * ih,
struct reiserfs_de_head * deh, int pos_in_item)
{
int len;
int len, i;
char * name;
len = entry_length (ih, deh, pos_in_item);
name = name_in_entry (deh, pos_in_item);
// name might be padded with 0s
while (!name [len - 1] && len > 0)
len --;
i = 0;
while (name[i] && i < len)
i++;
return len;
return i;
}
int name_length (char * name, int key_format)
+2 -3
View File
@@ -332,8 +332,7 @@ void print_directory_item (FILE * fp, reiserfs_filsys_t * fs,
GET_HASH_VALUE (get_deh_offset (deh)),
GET_GENERATION_NUMBER (get_deh_offset (deh)),
get_deh_location (deh), get_deh_state (deh),
code2name (find_hash_in_use (name, namelen,
GET_HASH_VALUE (get_deh_offset (deh)),
code2name (find_hash_in_use (name, namelen, get_deh_offset (deh),
fs ? get_sb_hash_code (fs->fs_ondisk_sb) : UNSET_HASH)));
/*fs ? (is_properly_hashed (fs, name, namelen, deh_offset (deh)) ? "" : "(BROKEN)") : "??");*/
}
@@ -648,7 +647,7 @@ int print_super_block (FILE * fp, reiserfs_filsys_t * fs, char * file_name,
"bitmaps, data, reserved] blocks): %u\n", get_sb_free_blocks (sb));
reiserfs_warning (fp, "Root block: %u\n", get_sb_root_block (sb));
}
reiserfs_warning (fp, "Filesystem marked as %scleanly umounted\n",
reiserfs_warning (fp, "Filesystem is %sclean\n",
(get_sb_umount_state (sb) == FS_CLEANLY_UMOUNTED) ? "" : "NOT ");
if (short_print)
+14 -27
View File
@@ -52,7 +52,8 @@ int is_block_count_correct (unsigned long journal_offset, unsigned int block_siz
/* read super block. fixme: only 4k blocks, pre-journaled format
is refused. Journal and bitmap are to be opened separately.
skip_check is set to 1 if checks of openned SB should be omitted.*/
reiserfs_filsys_t * reiserfs_open (char * filename, int flags, int *error, void * vp, int check)
reiserfs_filsys_t * reiserfs_open (char * filename, int flags,
int *error, void * vp, int check)
{
reiserfs_filsys_t * fs;
struct buffer_head * bh;
@@ -838,16 +839,11 @@ void reiserfs_insert_item (reiserfs_filsys_t * fs, struct path * path,
/*===========================================================================*/
static __u32 hash_value (reiserfs_filsys_t * fs, char * name)
__u32 hash_value (hashf_t func, char * name, int namelen)
{
__u32 res;
if (!strcmp (name, "."))
return DOT_OFFSET;
if (!strcmp (name, ".."))
return DOT_DOT_OFFSET;
res = reiserfs_hash (fs) (name, strlen (name));
res = func (name, namelen);
res = GET_HASH_VALUE(res);
if (res == 0)
res = 128;
@@ -864,14 +860,12 @@ int reiserfs_locate_entry (reiserfs_filsys_t * fs, struct key * dir, char * name
struct key entry_key;
struct item_head * ih;
struct reiserfs_de_head * deh;
__u32 hash;
int i, retval;
struct key * rdkey;
set_key_dirid (&entry_key, get_key_dirid (dir));
set_key_objectid (&entry_key, get_key_objectid (dir));
hash = hash_value (fs, name);
set_key_offset_v1 (&entry_key, hash);
set_key_offset_v1 (&entry_key, 0);
set_key_uniqueness (&entry_key, DIRENTRY_UNIQUENESS);
@@ -884,12 +878,6 @@ int reiserfs_locate_entry (reiserfs_filsys_t * fs, struct key * dir, char * name
ih = get_ih (path);
deh = B_I_DEH (get_bh (path), ih) + path->pos_in_item;
for (i = path->pos_in_item; i < get_ih_entry_count (ih); i ++, deh ++) {
if (GET_HASH_VALUE (get_deh_offset (deh)) != GET_HASH_VALUE (hash)) {
/* all entries having the same hash were scanned */
pathrelse (path);
return 0;
}
/* the name in directory has the same hash as the given name */
if ((name_in_entry_length (ih, deh, i) == (int)strlen (name)) &&
!memcmp (name_in_entry (deh, i), name, strlen (name))) {
@@ -907,13 +895,6 @@ int reiserfs_locate_entry (reiserfs_filsys_t * fs, struct key * dir, char * name
if (!is_direntry_key (rdkey))
reiserfs_panic ("reiserfs_locate_entry: can not find name in broken directory yet");
/* next item is the item of the directory we are looking name in */
if (GET_HASH_VALUE (get_offset (rdkey)) != hash) {
/* but there is no names with given hash */
pathrelse (path);
return 0;
}
/* first name of that item may be a name we are looking for */
entry_key = *rdkey;
pathrelse (path);
@@ -947,7 +928,12 @@ int reiserfs_find_entry (reiserfs_filsys_t * fs, struct key * dir, char * name,
set_key_dirid (&entry_key, get_key_dirid (dir));
set_key_objectid (&entry_key, get_key_objectid (dir));
hash = hash_value (fs, name);
if (!strcmp (name, "."))
hash = DOT_OFFSET;
else if (!strcmp (name, ".."))
hash = DOT_DOT_OFFSET;
else
hash = hash_value (reiserfs_hash (fs), name, strlen (name));
set_key_offset_v1 (&entry_key, hash);
set_key_uniqueness (&entry_key, DIRENTRY_UNIQUENESS);
@@ -1059,11 +1045,12 @@ int reiserfs_add_entry (reiserfs_filsys_t * fs, struct key * dir, char * name, i
/* compose entry key to look for its place in the tree */
set_key_dirid (&(entry_ih.ih_key), get_key_dirid (dir));
set_key_objectid (&(entry_ih.ih_key), get_key_objectid (dir));
hash = hash_value (fs, name) + gen_counter;
if (!strcmp (name, "."))
hash = DOT_OFFSET;
if (!strcmp (name, ".."))
else if (!strcmp (name, ".."))
hash = DOT_DOT_OFFSET;
else
hash = hash_value (reiserfs_hash (fs), name, strlen (name)) + gen_counter;
set_key_offset_v1 (&(entry_ih.ih_key), hash);
set_key_uniqueness (&(entry_ih.ih_key), DIRENTRY_UNIQUENESS);