+2001-01-10 <tytso@snap.thunk.org>
+
+ * alloc.c, bb_inode.c, bitmaps.c, bitops.h, block.c, bmap.c,
+ bmove.c, brel.h, cmp_bitmaps.c, dblist.c, dblist_dir.c,
+ dir_iterate.c, expanddir.c, ext2fs.h, ext2fsP.h, fileio.c,
+ finddev.c, get_pathname.c, icount.c, inode.c, irel.h,
+ irel_ma.c, ismounted.c, link.c, lookup.c, mkdir.c,
+ mkjournal.c, namei.c, newdir.c, read_bb_file.c, test_io.c,
+ tst_iscan.c, unix_io.c, unlink.c: Change use of ino_t to
+ ext2_ino_t, to protect applications that attempt to
+ compile -D_FILE_OFFSET_BITS=64, since this inexplicably
+ changes ino_t(!?). So we use ext2_ino_t to avoid an
+ unexpected ABI change.
+
2001-01-05 <tytso@snap.thunk.org>
* dirblock.c (ext2fs_read_dir_block): Fix a potential case where
*
* Should have a special policy for directories.
*/
-errcode_t ext2fs_new_inode(ext2_filsys fs, ino_t dir, int mode,
- ext2fs_inode_bitmap map, ino_t *ret)
+errcode_t ext2fs_new_inode(ext2_filsys fs, ext2_ino_t dir, int mode,
+ ext2fs_inode_bitmap map, ext2_ino_t *ret)
{
- ino_t dir_group = 0;
- ino_t i;
- ino_t start_inode;
+ ext2_ino_t dir_group = 0;
+ ext2_ino_t i;
+ ext2_ino_t start_inode;
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
* indirect blocks.
*/
#ifdef __TURBOC__
-#pragma argsused
+ #pragma argsused
#endif
static int clear_bad_block_proc(ext2_filsys fs, blk_t *block_nr,
e2_blkcnt_t blockcnt,
* Set the block list in the bad block inode, using the supplied bitmap.
*/
#ifdef __TURBOC__
-#pragma argsused
+ #pragma argsused
#endif
static int set_bad_block_proc(ext2_filsys fs, blk_t *block_nr,
e2_blkcnt_t blockcnt, blk_t ref_block,
}
errcode_t ext2fs_fudge_inode_bitmap_end(ext2fs_inode_bitmap bitmap,
- ino_t end, ino_t *oend)
+ ext2_ino_t end, ext2_ino_t *oend)
{
EXT2_CHECK_MAGIC(bitmap, EXT2_ET_MAGIC_INODE_BITMAP);
blk_t block);
extern int ext2fs_test_block_bitmap(ext2fs_block_bitmap bitmap, blk_t block);
-extern int ext2fs_mark_inode_bitmap(ext2fs_inode_bitmap bitmap, ino_t inode);
+extern int ext2fs_mark_inode_bitmap(ext2fs_inode_bitmap bitmap, ext2_ino_t inode);
extern int ext2fs_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap,
- ino_t inode);
-extern int ext2fs_test_inode_bitmap(ext2fs_inode_bitmap bitmap, ino_t inode);
+ ext2_ino_t inode);
+extern int ext2fs_test_inode_bitmap(ext2fs_inode_bitmap bitmap, ext2_ino_t inode);
extern void ext2fs_fast_mark_block_bitmap(ext2fs_block_bitmap bitmap,
blk_t block);
blk_t block);
extern void ext2fs_fast_mark_inode_bitmap(ext2fs_inode_bitmap bitmap,
- ino_t inode);
+ ext2_ino_t inode);
extern void ext2fs_fast_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap,
- ino_t inode);
+ ext2_ino_t inode);
extern int ext2fs_fast_test_inode_bitmap(ext2fs_inode_bitmap bitmap,
- ino_t inode);
+ ext2_ino_t inode);
extern blk_t ext2fs_get_block_bitmap_start(ext2fs_block_bitmap bitmap);
-extern ino_t ext2fs_get_inode_bitmap_start(ext2fs_inode_bitmap bitmap);
+extern ext2_ino_t ext2fs_get_inode_bitmap_start(ext2fs_inode_bitmap bitmap);
extern blk_t ext2fs_get_block_bitmap_end(ext2fs_block_bitmap bitmap);
-extern ino_t ext2fs_get_inode_bitmap_end(ext2fs_inode_bitmap bitmap);
+extern ext2_ino_t ext2fs_get_inode_bitmap_end(ext2fs_inode_bitmap bitmap);
extern void ext2fs_mark_block_bitmap_range(ext2fs_block_bitmap bitmap,
blk_t block, int num);
}
_INLINE_ int ext2fs_mark_inode_bitmap(ext2fs_inode_bitmap bitmap,
- ino_t inode)
+ ext2_ino_t inode)
{
return ext2fs_mark_generic_bitmap((ext2fs_generic_bitmap) bitmap,
inode);
}
_INLINE_ int ext2fs_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap,
- ino_t inode)
+ ext2_ino_t inode)
{
return ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap,
inode);
}
_INLINE_ int ext2fs_test_inode_bitmap(ext2fs_inode_bitmap bitmap,
- ino_t inode)
+ ext2_ino_t inode)
{
return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap,
inode);
}
_INLINE_ void ext2fs_fast_mark_inode_bitmap(ext2fs_inode_bitmap bitmap,
- ino_t inode)
+ ext2_ino_t inode)
{
#ifdef EXT2FS_DEBUG_FAST_OPS
if ((inode < bitmap->start) || (inode > bitmap->end)) {
}
_INLINE_ void ext2fs_fast_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap,
- ino_t inode)
+ ext2_ino_t inode)
{
#ifdef EXT2FS_DEBUG_FAST_OPS
if ((inode < bitmap->start) || (inode > bitmap->end)) {
}
_INLINE_ int ext2fs_fast_test_inode_bitmap(ext2fs_inode_bitmap bitmap,
- ino_t inode)
+ ext2_ino_t inode)
{
#ifdef EXT2FS_DEBUG_FAST_OPS
if ((inode < bitmap->start) || (inode > bitmap->end)) {
return bitmap->start;
}
-_INLINE_ ino_t ext2fs_get_inode_bitmap_start(ext2fs_inode_bitmap bitmap)
+_INLINE_ ext2_ino_t ext2fs_get_inode_bitmap_start(ext2fs_inode_bitmap bitmap)
{
return bitmap->start;
}
return bitmap->end;
}
-_INLINE_ ino_t ext2fs_get_inode_bitmap_end(ext2fs_inode_bitmap bitmap)
+_INLINE_ ext2_ino_t ext2fs_get_inode_bitmap_end(ext2fs_inode_bitmap bitmap)
{
return bitmap->end;
}
}
errcode_t ext2fs_block_iterate2(ext2_filsys fs,
- ino_t ino,
+ ext2_ino_t ino,
int flags,
char *block_buf,
int (*func)(ext2_filsys fs,
!(flags & BLOCK_FLAG_DATA_ONLY)) {
ctx.errcode = ext2fs_read_inode(fs, ino, &inode);
if (ctx.errcode)
- goto abort;
+ goto abort_exit;
got_inode = 1;
if (inode.osd1.hurd1.h_i_translator) {
ret |= (*ctx.func)(fs,
BLOCK_COUNT_TRANSLATOR,
0, 0, priv_data);
if (ret & BLOCK_ABORT)
- goto abort;
+ goto abort_exit;
}
}
ret |= (*ctx.func)(fs, &blocks[i],
ctx.bcount, 0, i, priv_data);
if (ret & BLOCK_ABORT)
- goto abort;
+ goto abort_exit;
}
}
if (*(blocks + EXT2_IND_BLOCK) || (flags & BLOCK_FLAG_APPEND)) {
ret |= block_iterate_ind(blocks + EXT2_IND_BLOCK,
0, EXT2_IND_BLOCK, &ctx);
if (ret & BLOCK_ABORT)
- goto abort;
+ goto abort_exit;
} else
ctx.bcount += limit;
if (*(blocks + EXT2_DIND_BLOCK) || (flags & BLOCK_FLAG_APPEND)) {
ret |= block_iterate_dind(blocks + EXT2_DIND_BLOCK,
0, EXT2_DIND_BLOCK, &ctx);
if (ret & BLOCK_ABORT)
- goto abort;
+ goto abort_exit;
} else
ctx.bcount += limit * limit;
if (*(blocks + EXT2_TIND_BLOCK) || (flags & BLOCK_FLAG_APPEND)) {
ret |= block_iterate_tind(blocks + EXT2_TIND_BLOCK,
0, EXT2_TIND_BLOCK, &ctx);
if (ret & BLOCK_ABORT)
- goto abort;
+ goto abort_exit;
}
-abort:
+abort_exit:
if (ret & BLOCK_CHANGED) {
if (!got_inode) {
retval = ext2fs_read_inode(fs, ino, &inode);
};
#ifdef __TURBOC__
-#pragma argsused
+ #pragma argsused
#endif
static int xlate_func(ext2_filsys fs, blk_t *blocknr, e2_blkcnt_t blockcnt,
blk_t ref_block, int ref_offset, void *priv_data)
}
errcode_t ext2fs_block_iterate(ext2_filsys fs,
- ino_t ino,
+ ext2_ino_t ino,
int flags,
char *block_buf,
int (*func)(ext2_filsys fs,
#define _BMAP_INLINE_
#endif
-extern errcode_t ext2fs_bmap(ext2_filsys fs, ino_t ino,
+extern errcode_t ext2fs_bmap(ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode *inode,
char *block_buf, int bmap_flags,
blk_t block, blk_t *phys_blk);
return retval;
}
-errcode_t ext2fs_bmap(ext2_filsys fs, ino_t ino, struct ext2_inode *inode,
+errcode_t ext2fs_bmap(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode *inode,
char *block_buf, int bmap_flags, blk_t block,
blk_t *phys_blk)
{
#include "ext2fsP.h"
struct process_block_struct {
- ino_t ino;
+ ext2_ino_t ino;
struct ext2_inode * inode;
ext2fs_block_bitmap reserve;
ext2fs_block_bitmap alloc_map;
ext2fs_block_bitmap alloc_map,
int flags)
{
- ino_t ino;
+ ext2_ino_t ino;
struct ext2_inode inode;
errcode_t retval;
struct process_block_struct pb;
__s16 offset;
__u16 flags;
union {
- blk_t block_ref;
- ino_t inode_ref;
+ blk_t block_ref;
+ ext2_ino_t inode_ref;
} owner;
};
errcode_t ext2fs_compare_inode_bitmap(ext2fs_inode_bitmap bm1,
ext2fs_inode_bitmap bm2)
{
- ino_t i;
+ ext2_ino_t i;
EXT2_CHECK_MAGIC(bm1, EXT2_ET_MAGIC_INODE_BITMAP);
EXT2_CHECK_MAGIC(bm2, EXT2_ET_MAGIC_INODE_BITMAP);
* the group descriptors. Of course, the group descriptors could be
* wrong!
*/
-errcode_t ext2fs_get_num_dirs(ext2_filsys fs, ino_t *ret_num_dirs)
+errcode_t ext2fs_get_num_dirs(ext2_filsys fs, ext2_ino_t *ret_num_dirs)
{
dgrp_t i;
- ino_t num_dirs, max_dirs;
+ ext2_ino_t num_dirs, max_dirs;
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
* helper function for making a new directory block list (for
* initialize and copy).
*/
-static errcode_t make_dblist(ext2_filsys fs, ino_t size, ino_t count,
+static errcode_t make_dblist(ext2_filsys fs, ext2_ino_t size, ext2_ino_t count,
struct ext2_db_entry *list,
ext2_dblist *ret_dblist)
{
/*
* Add a directory block to the directory block list
*/
-errcode_t ext2fs_add_dir_block(ext2_dblist dblist, ino_t ino, blk_t blk,
+errcode_t ext2fs_add_dir_block(ext2_dblist dblist, ext2_ino_t ino, blk_t blk,
int blockcnt)
{
struct ext2_db_entry *new_entry;
/*
* Change the directory block to the directory block list
*/
-errcode_t ext2fs_set_dir_block(ext2_dblist dblist, ino_t ino, blk_t blk,
+errcode_t ext2fs_set_dir_block(ext2_dblist dblist, ext2_ino_t ino, blk_t blk,
int blockcnt)
{
dgrp_t i;
void *priv_data),
void *priv_data)
{
- ino_t i;
- int ret;
+ ext2_ino_t i;
+ int ret;
EXT2_CHECK_MAGIC(dblist, EXT2_ET_MAGIC_DBLIST);
errcode_t ext2fs_dblist_dir_iterate(ext2_dblist dblist,
int flags,
char *block_buf,
- int (*func)(ino_t dir,
+ int (*func)(ext2_ino_t dir,
int entry,
struct ext2_dir_entry *dirent,
int offset,
#include "ext2fsP.h"
errcode_t ext2fs_dir_iterate(ext2_filsys fs,
- ino_t dir,
+ ext2_ino_t dir,
int flags,
char *block_buf,
int (*func)(struct ext2_dir_entry *dirent,
return BLOCK_CHANGED;
}
-errcode_t ext2fs_expand_dir(ext2_filsys fs, ino_t dir)
+errcode_t ext2fs_expand_dir(ext2_filsys fs, ext2_ino_t dir)
{
errcode_t retval;
struct expand_dir_struct es;
#endif
#endif /* EXT2_FLAT_INCLUDES */
+typedef __u32 ext2_ino_t;
typedef __u32 blk_t;
typedef __u32 dgrp_t;
typedef __u32 ext2_off_t;
* ext2_dblist structure and abstractions (see dblist.c)
*/
struct ext2_db_entry {
- ino_t ino;
+ ext2_ino_t ino;
blk_t blk;
int blockcnt;
};
int inode_blocks_per_group;
ext2fs_inode_bitmap inode_map;
ext2fs_block_bitmap block_map;
- errcode_t (*get_blocks)(ext2_filsys fs, ino_t ino, blk_t *blocks);
- errcode_t (*check_directory)(ext2_filsys fs, ino_t ino);
+ errcode_t (*get_blocks)(ext2_filsys fs, ext2_ino_t ino, blk_t *blocks);
+ errcode_t (*check_directory)(ext2_filsys fs, ext2_ino_t ino);
errcode_t (*write_bitmaps)(ext2_filsys fs);
- errcode_t (*read_inode)(ext2_filsys fs, ino_t ino,
+ errcode_t (*read_inode)(ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode *inode);
- errcode_t (*write_inode)(ext2_filsys fs, ino_t ino,
+ errcode_t (*write_inode)(ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode *inode);
badblocks_list badblocks;
ext2_dblist dblist;
*/
/* alloc.c */
-extern errcode_t ext2fs_new_inode(ext2_filsys fs, ino_t dir, int mode,
- ext2fs_inode_bitmap map, ino_t *ret);
+extern errcode_t ext2fs_new_inode(ext2_filsys fs, ext2_ino_t dir, int mode,
+ ext2fs_inode_bitmap map, ext2_ino_t *ret);
extern errcode_t ext2fs_new_block(ext2_filsys fs, blk_t goal,
ext2fs_block_bitmap map, blk_t *ret);
extern errcode_t ext2fs_get_free_blocks(ext2_filsys fs, blk_t start,
const char *descr,
ext2fs_inode_bitmap *ret);
extern errcode_t ext2fs_fudge_inode_bitmap_end(ext2fs_inode_bitmap bitmap,
- ino_t end, ino_t *oend);
+ ext2_ino_t end, ext2_ino_t *oend);
extern errcode_t ext2fs_fudge_block_bitmap_end(ext2fs_block_bitmap bitmap,
blk_t end, blk_t *oend);
extern void ext2fs_clear_inode_bitmap(ext2fs_inode_bitmap bitmap);
/* block.c */
extern errcode_t ext2fs_block_iterate(ext2_filsys fs,
- ino_t ino,
+ ext2_ino_t ino,
int flags,
char *block_buf,
int (*func)(ext2_filsys fs,
void *priv_data),
void *priv_data);
errcode_t ext2fs_block_iterate2(ext2_filsys fs,
- ino_t ino,
+ ext2_ino_t ino,
int flags,
char *block_buf,
int (*func)(ext2_filsys fs,
void *priv_data);
/* bmap.c */
-extern errcode_t ext2fs_bmap(ext2_filsys fs, ino_t ino,
+extern errcode_t ext2fs_bmap(ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode *inode,
char *block_buf, int bmap_flags,
blk_t block, blk_t *phys_blk);
/* dblist.c */
-extern errcode_t ext2fs_get_num_dirs(ext2_filsys fs, ino_t *ret_num_dirs);
+extern errcode_t ext2fs_get_num_dirs(ext2_filsys fs, ext2_ino_t *ret_num_dirs);
extern errcode_t ext2fs_init_dblist(ext2_filsys fs, ext2_dblist *ret_dblist);
-extern errcode_t ext2fs_add_dir_block(ext2_dblist dblist, ino_t ino,
+extern errcode_t ext2fs_add_dir_block(ext2_dblist dblist, ext2_ino_t ino,
blk_t blk, int blockcnt);
extern errcode_t ext2fs_dblist_iterate(ext2_dblist dblist,
int (*func)(ext2_filsys fs, struct ext2_db_entry *db_info,
void *priv_data),
void *priv_data);
-extern errcode_t ext2fs_set_dir_block(ext2_dblist dblist, ino_t ino,
+extern errcode_t ext2fs_set_dir_block(ext2_dblist dblist, ext2_ino_t ino,
blk_t blk, int blockcnt);
extern errcode_t ext2fs_copy_dblist(ext2_dblist src,
ext2_dblist *dest);
ext2fs_dblist_dir_iterate(ext2_dblist dblist,
int flags,
char *block_buf,
- int (*func)(ino_t dir,
+ int (*func)(ext2_ino_t dir,
int entry,
struct ext2_dir_entry *dirent,
int offset,
/* dir_iterate.c */
extern errcode_t ext2fs_dir_iterate(ext2_filsys fs,
- ino_t dir,
+ ext2_ino_t dir,
int flags,
char *block_buf,
int (*func)(struct ext2_dir_entry *dirent,
extern errcode_t ext2fs_dup_handle(ext2_filsys src, ext2_filsys *dest);
/* expanddir.c */
-extern errcode_t ext2fs_expand_dir(ext2_filsys fs, ino_t dir);
+extern errcode_t ext2fs_expand_dir(ext2_filsys fs, ext2_ino_t dir);
/* fileio.c */
-extern errcode_t ext2fs_file_open(ext2_filsys fs, ino_t ino,
+extern errcode_t ext2fs_file_open(ext2_filsys fs, ext2_ino_t ino,
int flags, ext2_file_t *ret);
extern ext2_filsys ext2fs_file_get_fs(ext2_file_t file);
extern errcode_t ext2fs_file_close(ext2_file_t file);
extern errcode_t ext2fs_open_inode_scan(ext2_filsys fs, int buffer_blocks,
ext2_inode_scan *ret_scan);
extern void ext2fs_close_inode_scan(ext2_inode_scan scan);
-extern errcode_t ext2fs_get_next_inode(ext2_inode_scan scan, ino_t *ino,
+extern errcode_t ext2fs_get_next_inode(ext2_inode_scan scan, ext2_ino_t *ino,
struct ext2_inode *inode);
extern errcode_t ext2fs_inode_scan_goto_blockgroup(ext2_inode_scan scan,
int group);
void *done_group_data);
extern int ext2fs_inode_scan_flags(ext2_inode_scan scan, int set_flags,
int clear_flags);
-extern errcode_t ext2fs_read_inode (ext2_filsys fs, ino_t ino,
+extern errcode_t ext2fs_read_inode (ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode * inode);
-extern errcode_t ext2fs_write_inode(ext2_filsys fs, ino_t ino,
+extern errcode_t ext2fs_write_inode(ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode * inode);
-extern errcode_t ext2fs_get_blocks(ext2_filsys fs, ino_t ino, blk_t *blocks);
-extern errcode_t ext2fs_check_directory(ext2_filsys fs, ino_t ino);
+extern errcode_t ext2fs_get_blocks(ext2_filsys fs, ext2_ino_t ino, blk_t *blocks);
+extern errcode_t ext2fs_check_directory(ext2_filsys fs, ext2_ino_t ino);
/* icount.c */
extern void ext2fs_free_icount(ext2_icount_t icount);
ext2_icount_t hint, ext2_icount_t *ret);
extern errcode_t ext2fs_create_icount(ext2_filsys fs, int flags, int size,
ext2_icount_t *ret);
-extern errcode_t ext2fs_icount_fetch(ext2_icount_t icount, ino_t ino,
+extern errcode_t ext2fs_icount_fetch(ext2_icount_t icount, ext2_ino_t ino,
__u16 *ret);
-extern errcode_t ext2fs_icount_increment(ext2_icount_t icount, ino_t ino,
+extern errcode_t ext2fs_icount_increment(ext2_icount_t icount, ext2_ino_t ino,
__u16 *ret);
-extern errcode_t ext2fs_icount_decrement(ext2_icount_t icount, ino_t ino,
+extern errcode_t ext2fs_icount_decrement(ext2_icount_t icount, ext2_ino_t ino,
__u16 *ret);
-extern errcode_t ext2fs_icount_store(ext2_icount_t icount, ino_t ino,
+extern errcode_t ext2fs_icount_store(ext2_icount_t icount, ext2_ino_t ino,
__u16 count);
-extern ino_t ext2fs_get_icount_size(ext2_icount_t icount);
+extern ext2_ino_t ext2fs_get_icount_size(ext2_icount_t icount);
errcode_t ext2fs_icount_validate(ext2_icount_t icount, FILE *);
/* ismounted.c */
char *mtpt, int mtlen);
/* namei.c */
-extern errcode_t ext2fs_lookup(ext2_filsys fs, ino_t dir, const char *name,
- int namelen, char *buf, ino_t *inode);
-extern errcode_t ext2fs_namei(ext2_filsys fs, ino_t root, ino_t cwd,
- const char *name, ino_t *inode);
-errcode_t ext2fs_namei_follow(ext2_filsys fs, ino_t root, ino_t cwd,
- const char *name, ino_t *inode);
-extern errcode_t ext2fs_follow_link(ext2_filsys fs, ino_t root, ino_t cwd,
- ino_t inode, ino_t *res_inode);
+extern errcode_t ext2fs_lookup(ext2_filsys fs, ext2_ino_t dir, const char *name,
+ int namelen, char *buf, ext2_ino_t *inode);
+extern errcode_t ext2fs_namei(ext2_filsys fs, ext2_ino_t root, ext2_ino_t cwd,
+ const char *name, ext2_ino_t *inode);
+errcode_t ext2fs_namei_follow(ext2_filsys fs, ext2_ino_t root, ext2_ino_t cwd,
+ const char *name, ext2_ino_t *inode);
+extern errcode_t ext2fs_follow_link(ext2_filsys fs, ext2_ino_t root, ext2_ino_t cwd,
+ ext2_ino_t inode, ext2_ino_t *res_inode);
/* native.c */
int ext2fs_native_flag(void);
/* newdir.c */
-extern errcode_t ext2fs_new_dir_block(ext2_filsys fs, ino_t dir_ino,
- ino_t parent_ino, char **block);
+extern errcode_t ext2fs_new_dir_block(ext2_filsys fs, ext2_ino_t dir_ino,
+ ext2_ino_t parent_ino, char **block);
/* mkdir.c */
-extern errcode_t ext2fs_mkdir(ext2_filsys fs, ino_t parent, ino_t inum,
+extern errcode_t ext2fs_mkdir(ext2_filsys fs, ext2_ino_t parent, ext2_ino_t inum,
const char *name);
/* mkjournal.c */
ext2_filsys *ret_fs);
/* get_pathname.c */
-extern errcode_t ext2fs_get_pathname(ext2_filsys fs, ino_t dir, ino_t ino,
+extern errcode_t ext2fs_get_pathname(ext2_filsys fs, ext2_ino_t dir, ext2_ino_t ino,
char **name);
/* link.c */
-errcode_t ext2fs_link(ext2_filsys fs, ino_t dir, const char *name,
- ino_t ino, int flags);
-errcode_t ext2fs_unlink(ext2_filsys fs, ino_t dir, const char *name,
- ino_t ino, int flags);
+errcode_t ext2fs_link(ext2_filsys fs, ext2_ino_t dir, const char *name,
+ ext2_ino_t ino, int flags);
+errcode_t ext2fs_unlink(ext2_filsys fs, ext2_ino_t dir, const char *name,
+ ext2_ino_t ino, int flags);
/* read_bb.c */
extern errcode_t ext2fs_read_bb_inode(ext2_filsys fs,
extern int ext2fs_get_library_version(const char **ver_string,
const char **date_string);
+/* write_bb_file.c */
+extern errcode_t ext2fs_write_bb_FILE(ext2_badblocks_list bb_list,
+ unsigned int flags,
+ FILE *f);
+
+
/* inline functions */
extern errcode_t ext2fs_get_mem(unsigned long size, void **ptr);
extern errcode_t ext2fs_free_mem(void **ptr);
extern int ext2fs_test_ib_dirty(ext2_filsys fs);
extern int ext2fs_test_bb_dirty(ext2_filsys fs);
extern int ext2fs_group_of_blk(ext2_filsys fs, blk_t blk);
-extern int ext2fs_group_of_ino(ext2_filsys fs, ino_t ino);
+extern int ext2fs_group_of_ino(ext2_filsys fs, ext2_ino_t ino);
/*
* The actual inlined functions definitions themselves...
/*
* Return the group # of an inode number
*/
-_INLINE_ int ext2fs_group_of_ino(ext2_filsys fs, ino_t ino)
+_INLINE_ int ext2fs_group_of_ino(ext2_filsys fs, ext2_ino_t ino)
{
return (ino - 1) / fs->super->s_inodes_per_group;
}
struct ext2_struct_dblist {
int magic;
ext2_filsys fs;
- ino_t size;
- ino_t count;
+ ext2_ino_t size;
+ ext2_ino_t count;
int sorted;
struct ext2_db_entry * list;
};
* For directory iterators
*/
struct dir_context {
- ino_t dir;
+ ext2_ino_t dir;
int flags;
char *buf;
int (*func)(struct ext2_dir_entry *dirent,
int blocksize,
char *buf,
void *priv_data);
- int (*func2)(ino_t dir,
+ int (*func2)(ext2_ino_t dir,
int entry,
struct ext2_dir_entry *dirent,
int offset,
};
struct ext2_inode_cache_ent {
- ino_t ino;
- struct ext2_inode inode;
+ ext2_ino_t ino;
+ struct ext2_inode inode;
};
/* Function prototypes */
struct ext2_file {
errcode_t magic;
ext2_filsys fs;
- ino_t ino;
+ ext2_ino_t ino;
struct ext2_inode inode;
int flags;
ext2_off_t pos;
char *buf;
};
-errcode_t ext2fs_file_open(ext2_filsys fs, ino_t ino,
+errcode_t ext2fs_file_open(ext2_filsys fs, ext2_ino_t ino,
int flags, ext2_file_t *ret)
{
ext2_file_t file;
#include <sys/mkdev.h>
#endif
+#if EXT2_FLAT_INCLUDES
+#include "ext2_fs.h"
+#else
+#include <linux/ext2_fs.h>
+#endif
+
+#include "ext2fs.h"
+
struct dir_list {
char *name;
struct dir_list *next;
/*
* This function adds an entry to the directory list
*/
-static void add_to_dirlist(char *name, struct dir_list **list)
+static void add_to_dirlist(const char *name, struct dir_list **list)
{
struct dir_list *dp;
goto skip_to_next;
if (dp->d_name[0] == '.' &&
((dp->d_name[1] == 0) ||
- (dp->d_name[1] == '.') && (dp->d_name[2] == 0)))
+ ((dp->d_name[1] == '.') && (dp->d_name[2] == 0))))
goto skip_to_next;
sprintf(path, "%s/%s", dirname, dp->d_name);
if (stat(path, &st) < 0)
new_list = 0;
}
}
-found_it:
free_dirlist(&list);
free_dirlist(&new_list);
return ret_path;
#include "ext2fs.h"
struct get_pathname_struct {
- ino_t search_ino;
- ino_t parent;
+ ext2_ino_t search_ino;
+ ext2_ino_t parent;
char *name;
errcode_t errcode;
};
#ifdef __TURBOC__
-#pragma argsused
+ #pragma argsused
#endif
static int get_pathname_proc(struct ext2_dir_entry *dirent,
int offset,
return 0;
}
-static errcode_t ext2fs_get_pathname_int(ext2_filsys fs, ino_t dir, ino_t ino,
- int maxdepth, char *buf, char **name)
+static errcode_t ext2fs_get_pathname_int(ext2_filsys fs, ext2_ino_t dir,
+ ext2_ino_t ino, int maxdepth,
+ char *buf, char **name)
{
struct get_pathname_struct gp;
char *parent_name, *ret;
return retval;
}
-errcode_t ext2fs_get_pathname(ext2_filsys fs, ino_t dir, ino_t ino,
+errcode_t ext2fs_get_pathname(ext2_filsys fs, ext2_ino_t dir, ext2_ino_t ino,
char **name)
{
char *buf;
*/
struct ext2_icount_el {
- ino_t ino;
+ ext2_ino_t ino;
__u16 count;
};
errcode_t magic;
ext2fs_inode_bitmap single;
ext2fs_inode_bitmap multiple;
- ino_t count;
- ino_t size;
- ino_t num_inodes;
+ ext2_ino_t count;
+ ext2_ino_t size;
+ ext2_ino_t num_inodes;
int cursor;
struct ext2_icount_el *list;
};
* specified position.
*/
static struct ext2_icount_el *insert_icount_el(ext2_icount_t icount,
- ino_t ino, int pos)
+ ext2_ino_t ino, int pos)
{
struct ext2_icount_el *el;
errcode_t retval;
- ino_t new_size = 0;
+ ext2_ino_t new_size = 0;
int num;
if (icount->count >= icount->size) {
if (icount->count) {
new_size = icount->list[(unsigned)icount->count-1].ino;
- new_size = (ino_t) (icount->count *
+ new_size = (ext2_ino_t) (icount->count *
((float) new_size / icount->num_inodes));
}
if (new_size < (icount->size + 100))
* and we can't find an entry, create one in the sorted list.
*/
static struct ext2_icount_el *get_icount_el(ext2_icount_t icount,
- ino_t ino, int create)
+ ext2_ino_t ino, int create)
{
float range;
int low, high, mid;
- ino_t lowval, highval;
+ ext2_ino_t lowval, highval;
if (!icount || !icount->list)
return 0;
}
for (i=1; i < icount->count; i++) {
if (icount->list[i-1].ino >= icount->list[i].ino) {
- fprintf(out, "%s: list[%d].ino=%ld, list[%d].ino=%ld\n",
+ fprintf(out, "%s: list[%d].ino=%u, list[%d].ino=%u\n",
bad, i-1, icount->list[i-1].ino,
i, icount->list[i].ino);
ret = EXT2_ET_INVALID_ARGUMENT;
return ret;
}
-errcode_t ext2fs_icount_fetch(ext2_icount_t icount, ino_t ino, __u16 *ret)
+errcode_t ext2fs_icount_fetch(ext2_icount_t icount, ext2_ino_t ino, __u16 *ret)
{
struct ext2_icount_el *el;
return 0;
}
-errcode_t ext2fs_icount_increment(ext2_icount_t icount, ino_t ino,
+errcode_t ext2fs_icount_increment(ext2_icount_t icount, ext2_ino_t ino,
__u16 *ret)
{
struct ext2_icount_el *el;
return 0;
}
-errcode_t ext2fs_icount_decrement(ext2_icount_t icount, ino_t ino,
+errcode_t ext2fs_icount_decrement(ext2_icount_t icount, ext2_ino_t ino,
__u16 *ret)
{
struct ext2_icount_el *el;
return 0;
}
-errcode_t ext2fs_icount_store(ext2_icount_t icount, ino_t ino,
+errcode_t ext2fs_icount_store(ext2_icount_t icount, ext2_ino_t ino,
__u16 count)
{
struct ext2_icount_el *el;
return 0;
}
-ino_t ext2fs_get_icount_size(ext2_icount_t icount)
+ext2_ino_t ext2fs_get_icount_size(ext2_icount_t icount)
{
if (!icount || icount->magic != EXT2_ET_MAGIC_ICOUNT)
return 0;
struct ext2_struct_inode_scan {
errcode_t magic;
ext2_filsys fs;
- ino_t current_inode;
+ ext2_ino_t current_inode;
blk_t current_block;
dgrp_t current_group;
- ino_t inodes_left;
+ ext2_ino_t inodes_left;
blk_t blocks_left;
dgrp_t groups_left;
blk_t inode_buffer_blocks;
{
ext2_inode_scan scan;
errcode_t retval;
- errcode_t (*save_get_blocks)(ext2_filsys f, ino_t ino, blk_t *blocks);
+ errcode_t (*save_get_blocks)(ext2_filsys f, ext2_ino_t ino, blk_t *blocks);
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
}
#endif
-errcode_t ext2fs_get_next_inode(ext2_inode_scan scan, ino_t *ino,
+errcode_t ext2fs_get_next_inode(ext2_inode_scan scan, ext2_ino_t *ino,
struct ext2_inode *inode)
{
errcode_t retval;
/*
* Functions to read and write a single inode.
*/
-errcode_t ext2fs_read_inode (ext2_filsys fs, ino_t ino,
+errcode_t ext2fs_read_inode (ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode * inode)
{
unsigned long group, block, block_nr, offset;
return 0;
}
-errcode_t ext2fs_write_inode(ext2_filsys fs, ino_t ino,
+errcode_t ext2fs_write_inode(ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode * inode)
{
unsigned long group, block, block_nr, offset;
return 0;
}
-errcode_t ext2fs_get_blocks(ext2_filsys fs, ino_t ino, blk_t *blocks)
+errcode_t ext2fs_get_blocks(ext2_filsys fs, ext2_ino_t ino, blk_t *blocks)
{
struct ext2_inode inode;
int i;
return 0;
}
-errcode_t ext2fs_check_directory(ext2_filsys fs, ino_t ino)
+errcode_t ext2fs_check_directory(ext2_filsys fs, ext2_ino_t ino)
{
struct ext2_inode inode;
errcode_t retval;
};
struct ext2_inode_relocate_entry {
- ino_t new;
- ino_t orig;
- __u16 flags;
- __u16 max_refs;
+ ext2_ino_t new;
+ ext2_ino_t orig;
+ __u16 flags;
+ __u16 max_refs;
};
typedef struct ext2_inode_relocation_table *ext2_irel;
struct ext2_inode_relocation_table {
__u32 magic;
char *name;
- ino_t current;
+ ext2_ino_t current;
void *priv_data;
/*
* Add an inode relocation entry.
*/
- errcode_t (*put)(ext2_irel irel, ino_t old,
+ errcode_t (*put)(ext2_irel irel, ext2_ino_t old,
struct ext2_inode_relocate_entry *ent);
/*
* Get an inode relocation entry.
*/
- errcode_t (*get)(ext2_irel irel, ino_t old,
+ errcode_t (*get)(ext2_irel irel, ext2_ino_t old,
struct ext2_inode_relocate_entry *ent);
/*
* Get an inode relocation entry by its original inode number
*/
- errcode_t (*get_by_orig)(ext2_irel irel, ino_t orig, ino_t *old,
+ errcode_t (*get_by_orig)(ext2_irel irel, ext2_ino_t orig, ext2_ino_t *old,
struct ext2_inode_relocate_entry *ent);
/*
* The iterator function for the inode relocation entries.
* Returns an inode number of 0 when out of entries.
*/
- errcode_t (*next)(ext2_irel irel, ino_t *old,
+ errcode_t (*next)(ext2_irel irel, ext2_ino_t *old,
struct ext2_inode_relocate_entry *ent);
/*
* Add an inode reference (i.e., note the fact that a
* particular block/offset contains a reference to an inode)
*/
- errcode_t (*add_ref)(ext2_irel irel, ino_t ino,
+ errcode_t (*add_ref)(ext2_irel irel, ext2_ino_t ino,
struct ext2_inode_reference *ref);
/*
* Initialize for iterating over the inode references for a
* particular inode.
*/
- errcode_t (*start_iter_ref)(ext2_irel irel, ino_t ino);
+ errcode_t (*start_iter_ref)(ext2_irel irel, ext2_ino_t ino);
/*
* The iterator function for the inode references for an
* Move the inode relocation table from one inode number to
* another. Note that the inode references also must move.
*/
- errcode_t (*move)(ext2_irel irel, ino_t old, ino_t new);
+ errcode_t (*move)(ext2_irel irel, ext2_ino_t old, ext2_ino_t new);
/*
* Remove an inode relocation entry, along with all of the
* inode references.
*/
- errcode_t (*delete)(ext2_irel irel, ino_t old);
+ errcode_t (*delete)(ext2_irel irel, ext2_ino_t old);
/*
* Free the inode relocation table.
errcode_t (*free)(ext2_irel irel);
};
-errcode_t ext2fs_irel_memarray_create(char *name, ino_t max_inode,
+errcode_t ext2fs_irel_memarray_create(char *name, ext2_ino_t max_inode,
ext2_irel *irel);
#define ext2fs_irel_put(irel, old, ent) ((irel)->put((irel), old, ent))
#include "ext2fs.h"
#include "irel.h"
-static errcode_t ima_put(ext2_irel irel, ino_t old,
+static errcode_t ima_put(ext2_irel irel, ext2_ino_t old,
struct ext2_inode_relocate_entry *ent);
-static errcode_t ima_get(ext2_irel irel, ino_t old,
+static errcode_t ima_get(ext2_irel irel, ext2_ino_t old,
struct ext2_inode_relocate_entry *ent);
-static errcode_t ima_get_by_orig(ext2_irel irel, ino_t orig, ino_t *old,
+static errcode_t ima_get_by_orig(ext2_irel irel, ext2_ino_t orig, ext2_ino_t *old,
struct ext2_inode_relocate_entry *ent);
static errcode_t ima_start_iter(ext2_irel irel);
-static errcode_t ima_next(ext2_irel irel, ino_t *old,
+static errcode_t ima_next(ext2_irel irel, ext2_ino_t *old,
struct ext2_inode_relocate_entry *ent);
-static errcode_t ima_add_ref(ext2_irel irel, ino_t ino,
+static errcode_t ima_add_ref(ext2_irel irel, ext2_ino_t ino,
struct ext2_inode_reference *ref);
-static errcode_t ima_start_iter_ref(ext2_irel irel, ino_t ino);
+static errcode_t ima_start_iter_ref(ext2_irel irel, ext2_ino_t ino);
static errcode_t ima_next_ref(ext2_irel irel, struct ext2_inode_reference *ref);
-static errcode_t ima_move(ext2_irel irel, ino_t old, ino_t new);
-static errcode_t ima_delete(ext2_irel irel, ino_t old);
+static errcode_t ima_move(ext2_irel irel, ext2_ino_t old, ext2_ino_t new);
+static errcode_t ima_delete(ext2_irel irel, ext2_ino_t old);
static errcode_t ima_free(ext2_irel irel);
/*
struct irel_ma {
__u32 magic;
- ino_t max_inode;
- ino_t ref_current;
+ ext2_ino_t max_inode;
+ ext2_ino_t ref_current;
int ref_iter;
- ino_t *orig_map;
+ ext2_ino_t *orig_map;
struct ext2_inode_relocate_entry *entries;
struct inode_reference_entry *ref_entries;
};
-errcode_t ext2fs_irel_memarray_create(char *name, ino_t max_inode,
+errcode_t ext2fs_irel_memarray_create(char *name, ext2_ino_t max_inode,
ext2_irel *new_irel)
{
ext2_irel irel = 0;
memset(ma, 0, sizeof(struct irel_ma));
irel->priv_data = ma;
- size = (size_t) (sizeof(ino_t) * (max_inode+1));
+ size = (size_t) (sizeof(ext2_ino_t) * (max_inode+1));
retval = ext2fs_get_mem(size, (void **) &ma->orig_map);
if (retval)
goto errout;
return retval;
}
-static errcode_t ima_put(ext2_irel irel, ino_t old,
+static errcode_t ima_put(ext2_irel irel, ext2_ino_t old,
struct ext2_inode_relocate_entry *ent)
{
struct inode_reference_entry *ref_ent;
return 0;
}
-static errcode_t ima_get(ext2_irel irel, ino_t old,
+static errcode_t ima_get(ext2_irel irel, ext2_ino_t old,
struct ext2_inode_relocate_entry *ent)
{
struct irel_ma *ma;
return 0;
}
-static errcode_t ima_get_by_orig(ext2_irel irel, ino_t orig, ino_t *old,
+static errcode_t ima_get_by_orig(ext2_irel irel, ext2_ino_t orig, ext2_ino_t *old,
struct ext2_inode_relocate_entry *ent)
{
struct irel_ma *ma;
- ino_t ino;
+ ext2_ino_t ino;
ma = irel->priv_data;
if (orig > ma->max_inode)
return 0;
}
-static errcode_t ima_next(ext2_irel irel, ino_t *old,
+static errcode_t ima_next(ext2_irel irel, ext2_ino_t *old,
struct ext2_inode_relocate_entry *ent)
{
struct irel_ma *ma;
return 0;
}
-static errcode_t ima_add_ref(ext2_irel irel, ino_t ino,
+static errcode_t ima_add_ref(ext2_irel irel, ext2_ino_t ino,
struct ext2_inode_reference *ref)
{
struct irel_ma *ma;
return 0;
}
-static errcode_t ima_start_iter_ref(ext2_irel irel, ino_t ino)
+static errcode_t ima_start_iter_ref(ext2_irel irel, ext2_ino_t ino)
{
struct irel_ma *ma;
}
-static errcode_t ima_move(ext2_irel irel, ino_t old, ino_t new)
+static errcode_t ima_move(ext2_irel irel, ext2_ino_t old, ext2_ino_t new)
{
struct irel_ma *ma;
return 0;
}
-static errcode_t ima_delete(ext2_irel irel, ino_t old)
+static errcode_t ima_delete(ext2_irel irel, ext2_ino_t old)
{
struct irel_ma *ma;
static errcode_t ima_free(ext2_irel irel)
{
struct irel_ma *ma;
- ino_t ino;
+ ext2_ino_t ino;
if (!irel)
return 0;
#include <sys/param.h>
#include <sys/mount.h>
#endif /* HAVE_GETMNTINFO */
+#include <string.h>
#if EXT2_FLAT_INCLUDES
#include "ext2_fs.h"
* characters.
*/
#ifdef __TURBOC__
-#pragma argsused
+ #pragma argsused
#endif
errcode_t ext2fs_check_mount_point(const char *device, int *mount_flags,
char *mtpt, int mtlen)
*
*/
#ifdef __TURBOC__
-#pragma argsused
+ #pragma argsused
#endif
errcode_t ext2fs_check_if_mounted(const char *file, int *mount_flags)
{
struct link_struct {
const char *name;
int namelen;
- ino_t inode;
+ ext2_ino_t inode;
int flags;
int done;
struct ext2_super_block *sb;
* entry filetype.
*/
#ifdef __TURBOC__
-#pragma argsused
+ #pragma argsused
#endif
-errcode_t ext2fs_link(ext2_filsys fs, ino_t dir, const char *name, ino_t ino,
- int flags)
+errcode_t ext2fs_link(ext2_filsys fs, ext2_ino_t dir, const char *name,
+ ext2_ino_t ino, int flags)
{
errcode_t retval;
struct link_struct ls;
struct lookup_struct {
const char *name;
int len;
- ino_t *inode;
+ ext2_ino_t *inode;
int found;
};
}
-errcode_t ext2fs_lookup(ext2_filsys fs, ino_t dir, const char *name,
- int namelen, char *buf, ino_t *inode)
+errcode_t ext2fs_lookup(ext2_filsys fs, ext2_ino_t dir, const char *name,
+ int namelen, char *buf, ext2_ino_t *inode)
{
errcode_t retval;
struct lookup_struct ls;
#define EXT2_FT_DIR 2
#endif
-errcode_t ext2fs_mkdir(ext2_filsys fs, ino_t parent, ino_t inum,
+errcode_t ext2fs_mkdir(ext2_filsys fs, ext2_ino_t parent, ext2_ino_t inum,
const char *name)
{
errcode_t retval;
struct ext2_inode parent_inode, inode;
- ino_t ino = inum;
- ino_t scratch_ino;
+ ext2_ino_t ino = inum;
+ ext2_ino_t scratch_ino;
blk_t blk;
char *block = 0;
int group;
/*
* This function creates a journal using direct I/O routines.
*/
-static errcode_t write_journal_inode(ext2_filsys fs, ino_t journal_ino,
+static errcode_t write_journal_inode(ext2_filsys fs, ext2_ino_t journal_ino,
blk_t size, int flags)
{
journal_superblock_t jsb;
errcode_t ext2fs_add_journal_inode(ext2_filsys fs, blk_t size, int flags)
{
errcode_t retval;
- ino_t journal_ino;
+ ext2_ino_t journal_ino;
struct stat st;
char jfile[1024];
int fd, mount_flags;
#include "ext2fs.h"
-static errcode_t open_namei(ext2_filsys fs, ino_t root, ino_t base,
+static errcode_t open_namei(ext2_filsys fs, ext2_ino_t root, ext2_ino_t base,
const char *pathname, size_t pathlen, int follow,
- int link_count, char *buf, ino_t *res_inode);
+ int link_count, char *buf, ext2_ino_t *res_inode);
-static errcode_t follow_link(ext2_filsys fs, ino_t root, ino_t dir,
- ino_t inode, int link_count,
- char *buf, ino_t *res_inode)
+static errcode_t follow_link(ext2_filsys fs, ext2_ino_t root, ext2_ino_t dir,
+ ext2_ino_t inode, int link_count,
+ char *buf, ext2_ino_t *res_inode)
{
char *pathname;
char *buffer = 0;
* containing directory, and a pointer to the filename of the file
* (pointing into the pathname) and the length of the filename.
*/
-static errcode_t dir_namei(ext2_filsys fs, ino_t root, ino_t dir,
+static errcode_t dir_namei(ext2_filsys fs, ext2_ino_t root, ext2_ino_t dir,
const char *pathname, int pathlen,
int link_count, char *buf,
- const char **name, int *namelen, ino_t *res_inode)
+ const char **name, int *namelen,
+ ext2_ino_t *res_inode)
{
char c;
const char *thisname;
int len;
- ino_t inode;
+ ext2_ino_t inode;
errcode_t retval;
if ((c = *pathname) == '/') {
return 0;
}
-static errcode_t open_namei(ext2_filsys fs, ino_t root, ino_t base,
+static errcode_t open_namei(ext2_filsys fs, ext2_ino_t root, ext2_ino_t base,
const char *pathname, size_t pathlen, int follow,
- int link_count, char *buf, ino_t *res_inode)
+ int link_count, char *buf, ext2_ino_t *res_inode)
{
const char *basename;
int namelen;
- ino_t dir, inode;
+ ext2_ino_t dir, inode;
errcode_t retval;
#ifdef NAMEI_DEBUG
return 0;
}
-errcode_t ext2fs_namei(ext2_filsys fs, ino_t root, ino_t cwd,
- const char *name, ino_t *inode)
+errcode_t ext2fs_namei(ext2_filsys fs, ext2_ino_t root, ext2_ino_t cwd,
+ const char *name, ext2_ino_t *inode)
{
char *buf;
errcode_t retval;
return retval;
}
-errcode_t ext2fs_namei_follow(ext2_filsys fs, ino_t root, ino_t cwd,
- const char *name, ino_t *inode)
+errcode_t ext2fs_namei_follow(ext2_filsys fs, ext2_ino_t root, ext2_ino_t cwd,
+ const char *name, ext2_ino_t *inode)
{
char *buf;
errcode_t retval;
return retval;
}
-errcode_t ext2fs_follow_link(ext2_filsys fs, ino_t root, ino_t cwd,
- ino_t inode, ino_t *res_inode)
+errcode_t ext2fs_follow_link(ext2_filsys fs, ext2_ino_t root, ext2_ino_t cwd,
+ ext2_ino_t inode, ext2_ino_t *res_inode)
{
char *buf;
errcode_t retval;
/*
* Create new directory block
*/
-errcode_t ext2fs_new_dir_block(ext2_filsys fs, ino_t dir_ino, ino_t parent_ino,
- char **block)
+errcode_t ext2fs_new_dir_block(ext2_filsys fs, ext2_ino_t dir_ino,
+ ext2_ino_t parent_ino, char **block)
{
struct ext2_dir_entry *dir = NULL;
errcode_t retval;
static void call_compat_invalid(ext2_filsys fs, blk_t blk,
char *badstr, void *private)
{
- void (*invalid)(ext2_filsys fs, blk_t blk);
+ void (*invalid)(ext2_filsys, blk_t);
invalid = (void (*)(ext2_filsys, blk_t)) private;
if (invalid)
ext2_badblocks_list *bb_list,
void (*invalid)(ext2_filsys fs, blk_t blk))
{
- return ext2fs_read_bb_FILE2(fs, f, bb_list, invalid,
+ return ext2fs_read_bb_FILE2(fs, f, bb_list, (void *) invalid,
call_compat_invalid);
}
static errcode_t test_write_blk(io_channel channel, unsigned long block,
int count, const void *data);
static errcode_t test_flush(io_channel channel);
+static errcode_t test_write_byte(io_channel channel, unsigned long offset,
+ int count, const void *buf);
static struct struct_io_manager struct_test_manager = {
EXT2_ET_MAGIC_IO_MANAGER,
test_set_blksize,
test_read_blk,
test_write_blk,
- test_flush
+ test_flush,
+ test_write_byte
+
};
io_manager test_io_manager = &struct_test_manager;
struct ext2_inode inode;
ext2_inode_scan scan;
errcode_t retval;
- ino_t ino;
+ ext2_ino_t ino;
retval = ext2fs_open_inode_scan(test_fs, 8, &scan);
if (retval) {
* if the block isn't in the cache, evict the oldest block in the
* cache and create a new cache entry for the requested block.
*/
-struct unix_cache *find_cached_block(io_channel channel,
- struct unix_private_data *data,
- unsigned long block,
- int get_cache)
+static struct unix_cache *find_cached_block(io_channel channel,
+ struct unix_private_data *data,
+ unsigned long block,
+ int get_cache)
{
- struct unix_cache *cache, *free_cache, *oldest_cache;
+ struct unix_cache *cache, *unused_cache, *oldest_cache;
int i;
- free_cache = oldest_cache = 0;
+ unused_cache = oldest_cache = 0;
for (i=0, cache = data->cache; i < CACHE_SIZE; i++, cache++) {
if (!cache->in_use) {
- free_cache = cache;
+ unused_cache = cache;
continue;
}
if (cache->block == block) {
/*
* Try to allocate cache slot.
*/
- if (free_cache)
- cache = free_cache;
+ if (unused_cache)
+ cache = unused_cache;
else {
cache = oldest_cache;
if (cache->dirty)
struct unix_private_data *data;
struct unix_cache *cache;
errcode_t retval;
+ char *cp;
int i, j;
EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
return raw_read_blk(channel, data, block, count, buf);
}
+ cp = buf;
while (count > 0) {
/* If it's in the cache, use it! */
if ((cache = find_cached_block(channel, data, block, 0))) {
#ifdef DEBUG
printf("Using cached block %d\n", block);
#endif
- memcpy(buf, cache->buf, channel->block_size);
+ memcpy(cp, cache->buf, channel->block_size);
count--;
block++;
- buf += channel->block_size;
+ cp += channel->block_size;
continue;
}
/*
#ifdef DEBUG
printf("Reading %d blocks starting at %d\n", i, block);
#endif
- if ((retval = raw_read_blk(channel, data, block, i, buf)))
+ if ((retval = raw_read_blk(channel, data, block, i, cp)))
return retval;
/* Save the results in the cache */
count--;
cache = find_cached_block(channel, data, block++, 1);
if (cache)
- memcpy(cache->buf, buf, channel->block_size);
- buf += channel->block_size;
+ memcpy(cache->buf, cp, channel->block_size);
+ cp += channel->block_size;
}
}
return 0;
struct unix_private_data *data;
struct unix_cache *cache;
errcode_t retval = 0, retval2;
- char *cp;
- int i, writethrough;
+ const char *cp;
+ int writethrough;
EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
data = (struct unix_private_data *) channel->private_data;
if (writethrough)
retval = raw_write_blk(channel, data, block, count, buf);
+ cp = buf;
while (count > 0) {
cache = find_cached_block(channel, data, block, 1);
if (!cache) {
* Force the write directly.
*/
if ((retval2 = raw_write_blk(channel, data, block,
- 1, buf)))
+ 1, cp)))
retval = retval2;
} else {
- memcpy(cache->buf, buf, channel->block_size);
+ memcpy(cache->buf, cp, channel->block_size);
cache->dirty = !writethrough;
}
count--;
block++;
- buf += channel->block_size;
+ cp += channel->block_size;
}
return retval;
}
int size, const void *buf)
{
struct unix_private_data *data;
- struct unix_cache *cache;
- errcode_t retval = 0, retval2;
- char *cp;
- int i, writethrough;
+ errcode_t retval = 0;
size_t actual;
EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
struct link_struct {
const char *name;
int namelen;
- ino_t inode;
+ ext2_ino_t inode;
int flags;
int done;
};
#ifdef __TURBOC__
-#pragma argsused
+ #pragma argsused
#endif
static int unlink_proc(struct ext2_dir_entry *dirent,
int offset,
}
#ifdef __TURBOC__
-#pragma argsused
+ #pragma argsused
#endif
-errcode_t ext2fs_unlink(ext2_filsys fs, ino_t dir, const char *name, ino_t ino,
+errcode_t ext2fs_unlink(ext2_filsys fs, ext2_ino_t dir,
+ const char *name, ext2_ino_t ino,
int flags)
{
errcode_t retval;