1997-04-29 20:15:03 +04:00
|
|
|
/*
|
|
|
|
* dir_iterate.c --- ext2fs directory iteration operations
|
2008-08-28 07:07:54 +04:00
|
|
|
*
|
1997-04-29 20:15:03 +04:00
|
|
|
* Copyright (C) 1993, 1994, 1994, 1995, 1996, 1997 Theodore Ts'o.
|
|
|
|
*
|
|
|
|
* %Begin-Header%
|
|
|
|
* This file may be redistributed under the terms of the GNU Public
|
|
|
|
* License.
|
|
|
|
* %End-Header%
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
1997-08-11 03:07:40 +04:00
|
|
|
#if HAVE_UNISTD_H
|
1997-04-29 20:15:03 +04:00
|
|
|
#include <unistd.h>
|
1997-08-11 03:07:40 +04:00
|
|
|
#endif
|
1997-04-29 20:15:03 +04:00
|
|
|
#if HAVE_ERRNO_H
|
|
|
|
#include <errno.h>
|
|
|
|
#endif
|
|
|
|
|
Many files:
inode.c (ext2fs_open_inode_scan): Initialize the group variables
so that we don't need to call get_next_blockgroup() the first
time around. Saves a bit of time, and prevents us from
needing to assign -1 to current_group (which is an unsigned
value).
icount.c (insert_icount_el): Cast the estimated number of inodes
from a float to an ino_t.
alloc.c, alloc_tables.c, badlbocks.c, bb_compat.c, bb_inode.c,
bitmaps.c, bitops.c, block.c, bmap.c, bmove.c, brel_ma.c,
check_desc.c, closefs.c, cmp_bitmaps.c, dblist.c,
dblist_dir.c, dir_iterate.c, dirblock.c, dupfs.c, expanddir.c,
ext2fs.h, fileio.c, freefs.c, get_pathname.c, getsize.c,
icount.c, initialize.c, inline.c, inode.c, irel_ma.c,
ismounted.c, link.c, lookup.c, mkdir.c, namei.c, native.c,
newdir.c, openfs.c, read_bb.c, read_bb_file.c, rs_bitmap.c,
rw_bitmaps.c, swapfs.c, test_io.c, tst_badblocks.c,
tst_getsize.c, tst_iscan.c, unix_io.c, unlink.c, valid_blk.c,
version.c: If EXT2_FLAT_INCLUDES is defined, then assume all
of the ext2-specific header files are in a flat directory.
block.c, bmove.c, dirblock.c, fileio.c: Explicitly cast
all assignments from void * to be compatible with C++.
closefs.c (ext2fs_flush): Add a call to io_channel_flush() to
make sure the contents of the disk are flushed to disk.
dblist.c (ext2fs_add_dir_block): Change new to be new_entry to
avoid C++ namespace clash.
bitmaps.c (ext2fs_copy_bitmap): Change new to be new_map to
avoid C++ namespace clash.
ext2fs.h, bb_inode.c, block.c, bmove.c, brel.h, brel_ma.c,
irel.h, irel_ma.c, dblist.c, dblist_dir.c, dir_iterate.c,
ext2fsP.h, expanddir.c, get_pathname.c, inode.c, link.c,
unlink.c: Change private to be priv_data (to avoid C++
namespace clash)
1998-01-19 17:47:53 +03:00
|
|
|
#include "ext2_fs.h"
|
1997-04-29 20:15:03 +04:00
|
|
|
#include "ext2fsP.h"
|
|
|
|
|
dir_iterate.c (ext2fs_dir_iterate2, ext2fs_process_dir_block):
Add support for a new flag, DIRENT_FLAG_INCLUDE_REMOVED,
which will return deleted directory entries.
ext2fs_dir_iterate2 takes a new callback function which
is identical with the one used by
ext2fs_dblist_dir_iterate(). If the directory entry is
deleted, the callback function will be called with the
entry paraemter set to DIRENT_DELETED_FILE.
Makefile.in, alloc_stats.c (ext2fs_inode_alloc_stats,
ext2fs_block_alloc_stats): New functions which update
block/inode allocation statistics in the bitmaps, block
group descriptors, and superblock.
mkjournal.c (mkjournal_proc), mkdir.c (ext2fs_mkdir),
expanddir.c (expand_dir_proc), bb_inode.c
(clear_bad_block_proc, set_bad_block_proc,
ext2fs_update_bb_inode), alloc.c (ext2fs_alloc_block):
Update to use new block/inode allocation statistics.
2002-01-03 11:29:19 +03:00
|
|
|
/*
|
|
|
|
* This function checks to see whether or not a potential deleted
|
|
|
|
* directory entry looks valid. What we do is check the deleted entry
|
|
|
|
* and each successive entry to make sure that they all look valid and
|
|
|
|
* that the last deleted entry ends at the beginning of the next
|
|
|
|
* undeleted entry. Returns 1 if the deleted entry looks valid, zero
|
|
|
|
* if not valid.
|
|
|
|
*/
|
2008-08-26 05:08:19 +04:00
|
|
|
static int ext2fs_validate_entry(ext2_filsys fs, char *buf, int offset,
|
|
|
|
int final_offset)
|
dir_iterate.c (ext2fs_dir_iterate2, ext2fs_process_dir_block):
Add support for a new flag, DIRENT_FLAG_INCLUDE_REMOVED,
which will return deleted directory entries.
ext2fs_dir_iterate2 takes a new callback function which
is identical with the one used by
ext2fs_dblist_dir_iterate(). If the directory entry is
deleted, the callback function will be called with the
entry paraemter set to DIRENT_DELETED_FILE.
Makefile.in, alloc_stats.c (ext2fs_inode_alloc_stats,
ext2fs_block_alloc_stats): New functions which update
block/inode allocation statistics in the bitmaps, block
group descriptors, and superblock.
mkjournal.c (mkjournal_proc), mkdir.c (ext2fs_mkdir),
expanddir.c (expand_dir_proc), bb_inode.c
(clear_bad_block_proc, set_bad_block_proc,
ext2fs_update_bb_inode), alloc.c (ext2fs_alloc_block):
Update to use new block/inode allocation statistics.
2002-01-03 11:29:19 +03:00
|
|
|
{
|
|
|
|
struct ext2_dir_entry *dirent;
|
2008-08-26 05:08:19 +04:00
|
|
|
int rec_len;
|
2008-08-28 07:07:54 +04:00
|
|
|
|
dir_iterate.c (ext2fs_dir_iterate2, ext2fs_process_dir_block):
Add support for a new flag, DIRENT_FLAG_INCLUDE_REMOVED,
which will return deleted directory entries.
ext2fs_dir_iterate2 takes a new callback function which
is identical with the one used by
ext2fs_dblist_dir_iterate(). If the directory entry is
deleted, the callback function will be called with the
entry paraemter set to DIRENT_DELETED_FILE.
Makefile.in, alloc_stats.c (ext2fs_inode_alloc_stats,
ext2fs_block_alloc_stats): New functions which update
block/inode allocation statistics in the bitmaps, block
group descriptors, and superblock.
mkjournal.c (mkjournal_proc), mkdir.c (ext2fs_mkdir),
expanddir.c (expand_dir_proc), bb_inode.c
(clear_bad_block_proc, set_bad_block_proc,
ext2fs_update_bb_inode), alloc.c (ext2fs_alloc_block):
Update to use new block/inode allocation statistics.
2002-01-03 11:29:19 +03:00
|
|
|
while (offset < final_offset) {
|
|
|
|
dirent = (struct ext2_dir_entry *)(buf + offset);
|
2008-08-26 05:08:19 +04:00
|
|
|
rec_len = (dirent->rec_len || fs->blocksize < 65536) ?
|
|
|
|
dirent->rec_len : 65536;
|
|
|
|
offset += rec_len;
|
|
|
|
if ((rec_len < 8) ||
|
|
|
|
((rec_len % 4) != 0) ||
|
|
|
|
(((dirent->name_len & 0xFF)+8) > rec_len))
|
dir_iterate.c (ext2fs_dir_iterate2, ext2fs_process_dir_block):
Add support for a new flag, DIRENT_FLAG_INCLUDE_REMOVED,
which will return deleted directory entries.
ext2fs_dir_iterate2 takes a new callback function which
is identical with the one used by
ext2fs_dblist_dir_iterate(). If the directory entry is
deleted, the callback function will be called with the
entry paraemter set to DIRENT_DELETED_FILE.
Makefile.in, alloc_stats.c (ext2fs_inode_alloc_stats,
ext2fs_block_alloc_stats): New functions which update
block/inode allocation statistics in the bitmaps, block
group descriptors, and superblock.
mkjournal.c (mkjournal_proc), mkdir.c (ext2fs_mkdir),
expanddir.c (expand_dir_proc), bb_inode.c
(clear_bad_block_proc, set_bad_block_proc,
ext2fs_update_bb_inode), alloc.c (ext2fs_alloc_block):
Update to use new block/inode allocation statistics.
2002-01-03 11:29:19 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return (offset == final_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
errcode_t ext2fs_dir_iterate2(ext2_filsys fs,
|
|
|
|
ext2_ino_t dir,
|
|
|
|
int flags,
|
|
|
|
char *block_buf,
|
|
|
|
int (*func)(ext2_ino_t dir,
|
|
|
|
int entry,
|
|
|
|
struct ext2_dir_entry *dirent,
|
|
|
|
int offset,
|
|
|
|
int blocksize,
|
|
|
|
char *buf,
|
|
|
|
void *priv_data),
|
|
|
|
void *priv_data)
|
1997-04-29 20:15:03 +04:00
|
|
|
{
|
|
|
|
struct dir_context ctx;
|
|
|
|
errcode_t retval;
|
2008-08-28 07:07:54 +04:00
|
|
|
|
1997-04-29 20:15:03 +04:00
|
|
|
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
|
|
|
|
|
|
|
|
retval = ext2fs_check_directory(fs, dir);
|
|
|
|
if (retval)
|
|
|
|
return retval;
|
2008-08-28 07:07:54 +04:00
|
|
|
|
1997-04-29 20:15:03 +04:00
|
|
|
ctx.dir = dir;
|
|
|
|
ctx.flags = flags;
|
|
|
|
if (block_buf)
|
|
|
|
ctx.buf = block_buf;
|
|
|
|
else {
|
2003-08-01 17:41:07 +04:00
|
|
|
retval = ext2fs_get_mem(fs->blocksize, &ctx.buf);
|
1997-10-26 06:41:24 +03:00
|
|
|
if (retval)
|
|
|
|
return retval;
|
1997-04-29 20:15:03 +04:00
|
|
|
}
|
|
|
|
ctx.func = func;
|
Many files:
inode.c (ext2fs_open_inode_scan): Initialize the group variables
so that we don't need to call get_next_blockgroup() the first
time around. Saves a bit of time, and prevents us from
needing to assign -1 to current_group (which is an unsigned
value).
icount.c (insert_icount_el): Cast the estimated number of inodes
from a float to an ino_t.
alloc.c, alloc_tables.c, badlbocks.c, bb_compat.c, bb_inode.c,
bitmaps.c, bitops.c, block.c, bmap.c, bmove.c, brel_ma.c,
check_desc.c, closefs.c, cmp_bitmaps.c, dblist.c,
dblist_dir.c, dir_iterate.c, dirblock.c, dupfs.c, expanddir.c,
ext2fs.h, fileio.c, freefs.c, get_pathname.c, getsize.c,
icount.c, initialize.c, inline.c, inode.c, irel_ma.c,
ismounted.c, link.c, lookup.c, mkdir.c, namei.c, native.c,
newdir.c, openfs.c, read_bb.c, read_bb_file.c, rs_bitmap.c,
rw_bitmaps.c, swapfs.c, test_io.c, tst_badblocks.c,
tst_getsize.c, tst_iscan.c, unix_io.c, unlink.c, valid_blk.c,
version.c: If EXT2_FLAT_INCLUDES is defined, then assume all
of the ext2-specific header files are in a flat directory.
block.c, bmove.c, dirblock.c, fileio.c: Explicitly cast
all assignments from void * to be compatible with C++.
closefs.c (ext2fs_flush): Add a call to io_channel_flush() to
make sure the contents of the disk are flushed to disk.
dblist.c (ext2fs_add_dir_block): Change new to be new_entry to
avoid C++ namespace clash.
bitmaps.c (ext2fs_copy_bitmap): Change new to be new_map to
avoid C++ namespace clash.
ext2fs.h, bb_inode.c, block.c, bmove.c, brel.h, brel_ma.c,
irel.h, irel_ma.c, dblist.c, dblist_dir.c, dir_iterate.c,
ext2fsP.h, expanddir.c, get_pathname.c, inode.c, link.c,
unlink.c: Change private to be priv_data (to avoid C++
namespace clash)
1998-01-19 17:47:53 +03:00
|
|
|
ctx.priv_data = priv_data;
|
1997-04-29 20:15:03 +04:00
|
|
|
ctx.errcode = 0;
|
2008-02-03 05:26:54 +03:00
|
|
|
retval = ext2fs_block_iterate2(fs, dir, BLOCK_FLAG_READ_ONLY, 0,
|
Many files:
block.c (ext2fs_block_iterate3): Make the ref_offset field contain the
offset into the inode.i_blocks array when ref_block is zero. Since we
haven't done a formal release of e2fsprogs since block_iterate2 was
first introduced, I removed block_iterate2, and renamed block_iterate3
to be block_iterate2.
bb_inode.c, bmove.c, dblist_dir.c, dir_iterate.c, expanddir.c,
ext2fs.h, ext2fsP.h, read_bb.c: Change use of block_iterate and
block_iterate2 to block_iterate2 with the new prototype for the
interator function. (using blkcnt_t forr blockcount)
ChangeLog, debugfs.c, ls.c, lsdel.c:
debugfs.c, ls.c, lsdel.c: Add support for large files. (The high 32
bits share space with the i_dir_acl field.)
1998-03-24 19:17:51 +03:00
|
|
|
ext2fs_process_dir_block, &ctx);
|
1997-04-29 20:15:03 +04:00
|
|
|
if (!block_buf)
|
2003-08-01 17:41:07 +04:00
|
|
|
ext2fs_free_mem(&ctx.buf);
|
1997-04-29 20:15:03 +04:00
|
|
|
if (retval)
|
|
|
|
return retval;
|
|
|
|
return ctx.errcode;
|
|
|
|
}
|
|
|
|
|
dir_iterate.c (ext2fs_dir_iterate2, ext2fs_process_dir_block):
Add support for a new flag, DIRENT_FLAG_INCLUDE_REMOVED,
which will return deleted directory entries.
ext2fs_dir_iterate2 takes a new callback function which
is identical with the one used by
ext2fs_dblist_dir_iterate(). If the directory entry is
deleted, the callback function will be called with the
entry paraemter set to DIRENT_DELETED_FILE.
Makefile.in, alloc_stats.c (ext2fs_inode_alloc_stats,
ext2fs_block_alloc_stats): New functions which update
block/inode allocation statistics in the bitmaps, block
group descriptors, and superblock.
mkjournal.c (mkjournal_proc), mkdir.c (ext2fs_mkdir),
expanddir.c (expand_dir_proc), bb_inode.c
(clear_bad_block_proc, set_bad_block_proc,
ext2fs_update_bb_inode), alloc.c (ext2fs_alloc_block):
Update to use new block/inode allocation statistics.
2002-01-03 11:29:19 +03:00
|
|
|
struct xlate {
|
|
|
|
int (*func)(struct ext2_dir_entry *dirent,
|
|
|
|
int offset,
|
|
|
|
int blocksize,
|
|
|
|
char *buf,
|
|
|
|
void *priv_data);
|
|
|
|
void *real_private;
|
|
|
|
};
|
|
|
|
|
2003-12-07 09:28:50 +03:00
|
|
|
static int xlate_func(ext2_ino_t dir EXT2FS_ATTR((unused)),
|
|
|
|
int entry EXT2FS_ATTR((unused)),
|
dir_iterate.c (ext2fs_dir_iterate2, ext2fs_process_dir_block):
Add support for a new flag, DIRENT_FLAG_INCLUDE_REMOVED,
which will return deleted directory entries.
ext2fs_dir_iterate2 takes a new callback function which
is identical with the one used by
ext2fs_dblist_dir_iterate(). If the directory entry is
deleted, the callback function will be called with the
entry paraemter set to DIRENT_DELETED_FILE.
Makefile.in, alloc_stats.c (ext2fs_inode_alloc_stats,
ext2fs_block_alloc_stats): New functions which update
block/inode allocation statistics in the bitmaps, block
group descriptors, and superblock.
mkjournal.c (mkjournal_proc), mkdir.c (ext2fs_mkdir),
expanddir.c (expand_dir_proc), bb_inode.c
(clear_bad_block_proc, set_bad_block_proc,
ext2fs_update_bb_inode), alloc.c (ext2fs_alloc_block):
Update to use new block/inode allocation statistics.
2002-01-03 11:29:19 +03:00
|
|
|
struct ext2_dir_entry *dirent, int offset,
|
|
|
|
int blocksize, char *buf, void *priv_data)
|
|
|
|
{
|
|
|
|
struct xlate *xl = (struct xlate *) priv_data;
|
|
|
|
|
|
|
|
return (*xl->func)(dirent, offset, blocksize, buf, xl->real_private);
|
|
|
|
}
|
|
|
|
|
2008-08-28 07:07:54 +04:00
|
|
|
extern errcode_t ext2fs_dir_iterate(ext2_filsys fs,
|
dir_iterate.c (ext2fs_dir_iterate2, ext2fs_process_dir_block):
Add support for a new flag, DIRENT_FLAG_INCLUDE_REMOVED,
which will return deleted directory entries.
ext2fs_dir_iterate2 takes a new callback function which
is identical with the one used by
ext2fs_dblist_dir_iterate(). If the directory entry is
deleted, the callback function will be called with the
entry paraemter set to DIRENT_DELETED_FILE.
Makefile.in, alloc_stats.c (ext2fs_inode_alloc_stats,
ext2fs_block_alloc_stats): New functions which update
block/inode allocation statistics in the bitmaps, block
group descriptors, and superblock.
mkjournal.c (mkjournal_proc), mkdir.c (ext2fs_mkdir),
expanddir.c (expand_dir_proc), bb_inode.c
(clear_bad_block_proc, set_bad_block_proc,
ext2fs_update_bb_inode), alloc.c (ext2fs_alloc_block):
Update to use new block/inode allocation statistics.
2002-01-03 11:29:19 +03:00
|
|
|
ext2_ino_t dir,
|
|
|
|
int flags,
|
|
|
|
char *block_buf,
|
|
|
|
int (*func)(struct ext2_dir_entry *dirent,
|
|
|
|
int offset,
|
|
|
|
int blocksize,
|
|
|
|
char *buf,
|
|
|
|
void *priv_data),
|
|
|
|
void *priv_data)
|
|
|
|
{
|
|
|
|
struct xlate xl;
|
2008-08-28 07:07:54 +04:00
|
|
|
|
dir_iterate.c (ext2fs_dir_iterate2, ext2fs_process_dir_block):
Add support for a new flag, DIRENT_FLAG_INCLUDE_REMOVED,
which will return deleted directory entries.
ext2fs_dir_iterate2 takes a new callback function which
is identical with the one used by
ext2fs_dblist_dir_iterate(). If the directory entry is
deleted, the callback function will be called with the
entry paraemter set to DIRENT_DELETED_FILE.
Makefile.in, alloc_stats.c (ext2fs_inode_alloc_stats,
ext2fs_block_alloc_stats): New functions which update
block/inode allocation statistics in the bitmaps, block
group descriptors, and superblock.
mkjournal.c (mkjournal_proc), mkdir.c (ext2fs_mkdir),
expanddir.c (expand_dir_proc), bb_inode.c
(clear_bad_block_proc, set_bad_block_proc,
ext2fs_update_bb_inode), alloc.c (ext2fs_alloc_block):
Update to use new block/inode allocation statistics.
2002-01-03 11:29:19 +03:00
|
|
|
xl.real_private = priv_data;
|
|
|
|
xl.func = func;
|
|
|
|
|
|
|
|
return ext2fs_dir_iterate2(fs, dir, flags, block_buf,
|
|
|
|
xlate_func, &xl);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1997-04-29 20:15:03 +04:00
|
|
|
/*
|
|
|
|
* Helper function which is private to this module. Used by
|
|
|
|
* ext2fs_dir_iterate() and ext2fs_dblist_dir_iterate()
|
|
|
|
*/
|
2003-12-07 09:28:50 +03:00
|
|
|
int ext2fs_process_dir_block(ext2_filsys fs,
|
|
|
|
blk_t *blocknr,
|
|
|
|
e2_blkcnt_t blockcnt,
|
|
|
|
blk_t ref_block EXT2FS_ATTR((unused)),
|
|
|
|
int ref_offset EXT2FS_ATTR((unused)),
|
|
|
|
void *priv_data)
|
1997-04-29 20:15:03 +04:00
|
|
|
{
|
Many files:
inode.c (ext2fs_open_inode_scan): Initialize the group variables
so that we don't need to call get_next_blockgroup() the first
time around. Saves a bit of time, and prevents us from
needing to assign -1 to current_group (which is an unsigned
value).
icount.c (insert_icount_el): Cast the estimated number of inodes
from a float to an ino_t.
alloc.c, alloc_tables.c, badlbocks.c, bb_compat.c, bb_inode.c,
bitmaps.c, bitops.c, block.c, bmap.c, bmove.c, brel_ma.c,
check_desc.c, closefs.c, cmp_bitmaps.c, dblist.c,
dblist_dir.c, dir_iterate.c, dirblock.c, dupfs.c, expanddir.c,
ext2fs.h, fileio.c, freefs.c, get_pathname.c, getsize.c,
icount.c, initialize.c, inline.c, inode.c, irel_ma.c,
ismounted.c, link.c, lookup.c, mkdir.c, namei.c, native.c,
newdir.c, openfs.c, read_bb.c, read_bb_file.c, rs_bitmap.c,
rw_bitmaps.c, swapfs.c, test_io.c, tst_badblocks.c,
tst_getsize.c, tst_iscan.c, unix_io.c, unlink.c, valid_blk.c,
version.c: If EXT2_FLAT_INCLUDES is defined, then assume all
of the ext2-specific header files are in a flat directory.
block.c, bmove.c, dirblock.c, fileio.c: Explicitly cast
all assignments from void * to be compatible with C++.
closefs.c (ext2fs_flush): Add a call to io_channel_flush() to
make sure the contents of the disk are flushed to disk.
dblist.c (ext2fs_add_dir_block): Change new to be new_entry to
avoid C++ namespace clash.
bitmaps.c (ext2fs_copy_bitmap): Change new to be new_map to
avoid C++ namespace clash.
ext2fs.h, bb_inode.c, block.c, bmove.c, brel.h, brel_ma.c,
irel.h, irel_ma.c, dblist.c, dblist_dir.c, dir_iterate.c,
ext2fsP.h, expanddir.c, get_pathname.c, inode.c, link.c,
unlink.c: Change private to be priv_data (to avoid C++
namespace clash)
1998-01-19 17:47:53 +03:00
|
|
|
struct dir_context *ctx = (struct dir_context *) priv_data;
|
2003-12-07 09:28:50 +03:00
|
|
|
unsigned int offset = 0;
|
|
|
|
unsigned int next_real_entry = 0;
|
1997-04-29 20:15:03 +04:00
|
|
|
int ret = 0;
|
|
|
|
int changed = 0;
|
|
|
|
int do_abort = 0;
|
2008-08-26 05:08:19 +04:00
|
|
|
int rec_len, entry, size;
|
1997-04-29 20:15:03 +04:00
|
|
|
struct ext2_dir_entry *dirent;
|
|
|
|
|
|
|
|
if (blockcnt < 0)
|
|
|
|
return 0;
|
|
|
|
|
Many files:
block.c (ext2fs_block_iterate3): Make the ref_offset field contain the
offset into the inode.i_blocks array when ref_block is zero. Since we
haven't done a formal release of e2fsprogs since block_iterate2 was
first introduced, I removed block_iterate2, and renamed block_iterate3
to be block_iterate2.
bb_inode.c, bmove.c, dblist_dir.c, dir_iterate.c, expanddir.c,
ext2fs.h, ext2fsP.h, read_bb.c: Change use of block_iterate and
block_iterate2 to block_iterate2 with the new prototype for the
interator function. (using blkcnt_t forr blockcount)
ChangeLog, debugfs.c, ls.c, lsdel.c:
debugfs.c, ls.c, lsdel.c: Add support for large files. (The high 32
bits share space with the i_dir_acl field.)
1998-03-24 19:17:51 +03:00
|
|
|
entry = blockcnt ? DIRENT_OTHER_FILE : DIRENT_DOT_FILE;
|
2008-08-28 07:07:54 +04:00
|
|
|
|
1997-04-29 20:15:03 +04:00
|
|
|
ctx->errcode = ext2fs_read_dir_block(fs, *blocknr, ctx->buf);
|
|
|
|
if (ctx->errcode)
|
|
|
|
return BLOCK_ABORT;
|
|
|
|
|
|
|
|
while (offset < fs->blocksize) {
|
|
|
|
dirent = (struct ext2_dir_entry *) (ctx->buf + offset);
|
2008-08-26 05:08:19 +04:00
|
|
|
rec_len = (dirent->rec_len || fs->blocksize < 65536) ?
|
|
|
|
dirent->rec_len : 65536;
|
|
|
|
if (((offset + rec_len) > fs->blocksize) ||
|
|
|
|
(rec_len < 8) ||
|
|
|
|
((rec_len % 4) != 0) ||
|
|
|
|
(((dirent->name_len & 0xFF)+8) > rec_len)) {
|
1999-06-22 07:17:45 +04:00
|
|
|
ctx->errcode = EXT2_ET_DIR_CORRUPTED;
|
|
|
|
return BLOCK_ABORT;
|
|
|
|
}
|
1997-04-29 20:15:03 +04:00
|
|
|
if (!dirent->inode &&
|
|
|
|
!(ctx->flags & DIRENT_FLAG_INCLUDE_EMPTY))
|
|
|
|
goto next;
|
|
|
|
|
dir_iterate.c (ext2fs_dir_iterate2, ext2fs_process_dir_block):
Add support for a new flag, DIRENT_FLAG_INCLUDE_REMOVED,
which will return deleted directory entries.
ext2fs_dir_iterate2 takes a new callback function which
is identical with the one used by
ext2fs_dblist_dir_iterate(). If the directory entry is
deleted, the callback function will be called with the
entry paraemter set to DIRENT_DELETED_FILE.
Makefile.in, alloc_stats.c (ext2fs_inode_alloc_stats,
ext2fs_block_alloc_stats): New functions which update
block/inode allocation statistics in the bitmaps, block
group descriptors, and superblock.
mkjournal.c (mkjournal_proc), mkdir.c (ext2fs_mkdir),
expanddir.c (expand_dir_proc), bb_inode.c
(clear_bad_block_proc, set_bad_block_proc,
ext2fs_update_bb_inode), alloc.c (ext2fs_alloc_block):
Update to use new block/inode allocation statistics.
2002-01-03 11:29:19 +03:00
|
|
|
ret = (ctx->func)(ctx->dir,
|
|
|
|
(next_real_entry > offset) ?
|
|
|
|
DIRENT_DELETED_FILE : entry,
|
|
|
|
dirent, offset,
|
|
|
|
fs->blocksize, ctx->buf,
|
|
|
|
ctx->priv_data);
|
|
|
|
if (entry < DIRENT_OTHER_FILE)
|
|
|
|
entry++;
|
2008-08-28 07:07:54 +04:00
|
|
|
|
2008-08-26 05:08:19 +04:00
|
|
|
if (ret & DIRENT_CHANGED) {
|
|
|
|
rec_len = (dirent->rec_len || fs->blocksize < 65536) ?
|
|
|
|
dirent->rec_len : 65536;
|
1997-04-29 20:15:03 +04:00
|
|
|
changed++;
|
2008-08-26 05:08:19 +04:00
|
|
|
}
|
1997-04-29 20:15:03 +04:00
|
|
|
if (ret & DIRENT_ABORT) {
|
|
|
|
do_abort++;
|
|
|
|
break;
|
|
|
|
}
|
2008-08-28 07:07:54 +04:00
|
|
|
next:
|
dir_iterate.c (ext2fs_dir_iterate2, ext2fs_process_dir_block):
Add support for a new flag, DIRENT_FLAG_INCLUDE_REMOVED,
which will return deleted directory entries.
ext2fs_dir_iterate2 takes a new callback function which
is identical with the one used by
ext2fs_dblist_dir_iterate(). If the directory entry is
deleted, the callback function will be called with the
entry paraemter set to DIRENT_DELETED_FILE.
Makefile.in, alloc_stats.c (ext2fs_inode_alloc_stats,
ext2fs_block_alloc_stats): New functions which update
block/inode allocation statistics in the bitmaps, block
group descriptors, and superblock.
mkjournal.c (mkjournal_proc), mkdir.c (ext2fs_mkdir),
expanddir.c (expand_dir_proc), bb_inode.c
(clear_bad_block_proc, set_bad_block_proc,
ext2fs_update_bb_inode), alloc.c (ext2fs_alloc_block):
Update to use new block/inode allocation statistics.
2002-01-03 11:29:19 +03:00
|
|
|
if (next_real_entry == offset)
|
2008-08-26 05:08:19 +04:00
|
|
|
next_real_entry += rec_len;
|
2008-08-28 07:07:54 +04:00
|
|
|
|
dir_iterate.c (ext2fs_dir_iterate2, ext2fs_process_dir_block):
Add support for a new flag, DIRENT_FLAG_INCLUDE_REMOVED,
which will return deleted directory entries.
ext2fs_dir_iterate2 takes a new callback function which
is identical with the one used by
ext2fs_dblist_dir_iterate(). If the directory entry is
deleted, the callback function will be called with the
entry paraemter set to DIRENT_DELETED_FILE.
Makefile.in, alloc_stats.c (ext2fs_inode_alloc_stats,
ext2fs_block_alloc_stats): New functions which update
block/inode allocation statistics in the bitmaps, block
group descriptors, and superblock.
mkjournal.c (mkjournal_proc), mkdir.c (ext2fs_mkdir),
expanddir.c (expand_dir_proc), bb_inode.c
(clear_bad_block_proc, set_bad_block_proc,
ext2fs_update_bb_inode), alloc.c (ext2fs_alloc_block):
Update to use new block/inode allocation statistics.
2002-01-03 11:29:19 +03:00
|
|
|
if (ctx->flags & DIRENT_FLAG_INCLUDE_REMOVED) {
|
|
|
|
size = ((dirent->name_len & 0xFF) + 11) & ~3;
|
|
|
|
|
2008-08-26 05:08:19 +04:00
|
|
|
if (rec_len != size) {
|
2003-12-07 09:28:50 +03:00
|
|
|
unsigned int final_offset;
|
|
|
|
|
2008-08-26 05:08:19 +04:00
|
|
|
final_offset = offset + rec_len;
|
dir_iterate.c (ext2fs_dir_iterate2, ext2fs_process_dir_block):
Add support for a new flag, DIRENT_FLAG_INCLUDE_REMOVED,
which will return deleted directory entries.
ext2fs_dir_iterate2 takes a new callback function which
is identical with the one used by
ext2fs_dblist_dir_iterate(). If the directory entry is
deleted, the callback function will be called with the
entry paraemter set to DIRENT_DELETED_FILE.
Makefile.in, alloc_stats.c (ext2fs_inode_alloc_stats,
ext2fs_block_alloc_stats): New functions which update
block/inode allocation statistics in the bitmaps, block
group descriptors, and superblock.
mkjournal.c (mkjournal_proc), mkdir.c (ext2fs_mkdir),
expanddir.c (expand_dir_proc), bb_inode.c
(clear_bad_block_proc, set_bad_block_proc,
ext2fs_update_bb_inode), alloc.c (ext2fs_alloc_block):
Update to use new block/inode allocation statistics.
2002-01-03 11:29:19 +03:00
|
|
|
offset += size;
|
|
|
|
while (offset < final_offset &&
|
2008-08-26 05:08:19 +04:00
|
|
|
!ext2fs_validate_entry(fs, ctx->buf,
|
dir_iterate.c (ext2fs_dir_iterate2, ext2fs_process_dir_block):
Add support for a new flag, DIRENT_FLAG_INCLUDE_REMOVED,
which will return deleted directory entries.
ext2fs_dir_iterate2 takes a new callback function which
is identical with the one used by
ext2fs_dblist_dir_iterate(). If the directory entry is
deleted, the callback function will be called with the
entry paraemter set to DIRENT_DELETED_FILE.
Makefile.in, alloc_stats.c (ext2fs_inode_alloc_stats,
ext2fs_block_alloc_stats): New functions which update
block/inode allocation statistics in the bitmaps, block
group descriptors, and superblock.
mkjournal.c (mkjournal_proc), mkdir.c (ext2fs_mkdir),
expanddir.c (expand_dir_proc), bb_inode.c
(clear_bad_block_proc, set_bad_block_proc,
ext2fs_update_bb_inode), alloc.c (ext2fs_alloc_block):
Update to use new block/inode allocation statistics.
2002-01-03 11:29:19 +03:00
|
|
|
offset,
|
|
|
|
final_offset))
|
|
|
|
offset += 4;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2008-08-26 05:08:19 +04:00
|
|
|
offset += rec_len;
|
1997-04-29 20:15:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (changed) {
|
|
|
|
ctx->errcode = ext2fs_write_dir_block(fs, *blocknr, ctx->buf);
|
|
|
|
if (ctx->errcode)
|
|
|
|
return BLOCK_ABORT;
|
|
|
|
}
|
|
|
|
if (do_abort)
|
|
|
|
return BLOCK_ABORT;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|