mirror of https://github.com/vitalif/e2fsprogs
ChangeLog, bitops.c, ext2fs.h, fileio.c:
ext2fs.h: Make ext2fs_get_mem take an unsigned argument. fileio.c (ext2fs_file_get_size, ext2fs_file_set_size, ext2fs_file_get_fs): New functions added. bitops.c (ext2fs_warn_bitmap, ext2fs_warn_bitmap2): Don't call com_err if OMIT_COM_ERR is defined.bitmap-optimize
parent
3b12bf9469
commit
79a90bdad0
|
@ -1,3 +1,16 @@
|
||||||
|
Sun Nov 2 20:36:13 1997 Theodore Ts'o <tytso@rsts-11.mit.edu>
|
||||||
|
|
||||||
|
* ext2fs.h: Make ext2fs_get_mem take an unsigned argument.
|
||||||
|
|
||||||
|
* fileio.c (ext2fs_file_get_size, ext2fs_file_set_size,
|
||||||
|
ext2fs_file_get_fs): New functions added.
|
||||||
|
|
||||||
|
|
||||||
|
Fri Oct 31 12:16:52 1997 <tytso@EDT.MIT.EDU>
|
||||||
|
|
||||||
|
* bitops.c (ext2fs_warn_bitmap, ext2fs_warn_bitmap2): Don't call
|
||||||
|
com_err if OMIT_COM_ERR is defined.
|
||||||
|
|
||||||
Thu Oct 30 11:33:57 1997 Theodore Ts'o <tytso@rsts-11.mit.edu>
|
Thu Oct 30 11:33:57 1997 Theodore Ts'o <tytso@rsts-11.mit.edu>
|
||||||
|
|
||||||
* Rename new error codes to _ET_ in them for consistency.
|
* Rename new error codes to _ET_ in them for consistency.
|
||||||
|
|
|
@ -70,19 +70,23 @@ int ext2fs_test_bit(int nr, const void * addr)
|
||||||
void ext2fs_warn_bitmap(errcode_t errcode, unsigned long arg,
|
void ext2fs_warn_bitmap(errcode_t errcode, unsigned long arg,
|
||||||
const char *description)
|
const char *description)
|
||||||
{
|
{
|
||||||
|
#ifndef OMIT_COM_ERR
|
||||||
if (description)
|
if (description)
|
||||||
com_err(0, errcode, "#%u for %s", arg, description);
|
com_err(0, errcode, "#%u for %s", arg, description);
|
||||||
else
|
else
|
||||||
com_err(0, errcode, "#%u", arg);
|
com_err(0, errcode, "#%u", arg);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ext2fs_warn_bitmap2(ext2fs_generic_bitmap bitmap,
|
void ext2fs_warn_bitmap2(ext2fs_generic_bitmap bitmap,
|
||||||
int code, unsigned long arg)
|
int code, unsigned long arg)
|
||||||
{
|
{
|
||||||
|
#ifndef OMIT_COM_ERR
|
||||||
if (bitmap->description)
|
if (bitmap->description)
|
||||||
com_err(0, bitmap->base_error_code+code,
|
com_err(0, bitmap->base_error_code+code,
|
||||||
"#%u for %s", arg, bitmap->description);
|
"#%u for %s", arg, bitmap->description);
|
||||||
else
|
else
|
||||||
com_err(0, bitmap->base_error_code + code, "#%u", arg);
|
com_err(0, bitmap->base_error_code + code, "#%u", arg);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -580,13 +580,16 @@ extern errcode_t ext2fs_expand_dir(ext2_filsys fs, ino_t dir);
|
||||||
/* fileio.c */
|
/* fileio.c */
|
||||||
extern errcode_t ext2fs_file_open(ext2_filsys fs, ino_t ino,
|
extern errcode_t ext2fs_file_open(ext2_filsys fs, ino_t ino,
|
||||||
int flags, ext2_file_t *ret);
|
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_file_close(ext2_file_t file);
|
||||||
extern errcode_t ext2fs_file_read(ext2_file_t file, void *buf,
|
extern errcode_t ext2fs_file_read(ext2_file_t file, void *buf,
|
||||||
int wanted, int *got);
|
unsigned int wanted, unsigned int *got);
|
||||||
extern errcode_t ext2fs_file_write(ext2_file_t file, void *buf,
|
extern errcode_t ext2fs_file_write(ext2_file_t file, void *buf,
|
||||||
int nbytes, int *written);
|
unsigned int nbytes, unsigned int *written);
|
||||||
extern errcode_t ext2fs_file_llseek(ext2_file_t file, ext2_off_t offset,
|
extern errcode_t ext2fs_file_llseek(ext2_file_t file, ext2_off_t offset,
|
||||||
int whence, ext2_off_t *ret_pos);
|
int whence, ext2_off_t *ret_pos);
|
||||||
|
extern ext2_off_t ext2fs_file_get_size(ext2_file_t file);
|
||||||
|
extern errcode_t ext2fs_file_set_size(ext2_file_t file, ext2_off_t size);
|
||||||
|
|
||||||
/* freefs.c */
|
/* freefs.c */
|
||||||
extern void ext2fs_free(ext2_filsys fs);
|
extern void ext2fs_free(ext2_filsys fs);
|
||||||
|
@ -721,9 +724,9 @@ extern int ext2fs_get_library_version(const char **ver_string,
|
||||||
const char **date_string);
|
const char **date_string);
|
||||||
|
|
||||||
/* inline functions */
|
/* inline functions */
|
||||||
extern errcode_t ext2fs_get_mem(long size, void **ptr);
|
extern errcode_t ext2fs_get_mem(unsigned long size, void **ptr);
|
||||||
extern errcode_t ext2fs_free_mem(void **ptr);
|
extern errcode_t ext2fs_free_mem(void **ptr);
|
||||||
extern errcode_t ext2fs_resize_mem(long size, void **ptr);
|
extern errcode_t ext2fs_resize_mem(unsigned long size, void **ptr);
|
||||||
extern void ext2fs_mark_super_dirty(ext2_filsys fs);
|
extern void ext2fs_mark_super_dirty(ext2_filsys fs);
|
||||||
extern void ext2fs_mark_changed(ext2_filsys fs);
|
extern void ext2fs_mark_changed(ext2_filsys fs);
|
||||||
extern int ext2fs_test_changed(ext2_filsys fs);
|
extern int ext2fs_test_changed(ext2_filsys fs);
|
||||||
|
@ -754,7 +757,7 @@ extern int ext2fs_group_of_ino(ext2_filsys fs, ino_t ino);
|
||||||
/*
|
/*
|
||||||
* Allocate memory
|
* Allocate memory
|
||||||
*/
|
*/
|
||||||
_INLINE_ errcode_t ext2fs_get_mem(long size, void **ptr)
|
_INLINE_ errcode_t ext2fs_get_mem(unsigned long size, void **ptr)
|
||||||
{
|
{
|
||||||
*ptr = malloc(size);
|
*ptr = malloc(size);
|
||||||
if (!*ptr)
|
if (!*ptr)
|
||||||
|
@ -775,7 +778,7 @@ _INLINE_ errcode_t ext2fs_free_mem(void **ptr)
|
||||||
/*
|
/*
|
||||||
* Resize memory
|
* Resize memory
|
||||||
*/
|
*/
|
||||||
_INLINE_ errcode_t ext2fs_resize_mem(long size, void **ptr)
|
_INLINE_ errcode_t ext2fs_resize_mem(unsigned long size, void **ptr)
|
||||||
{
|
{
|
||||||
void *p;
|
void *p;
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,16 @@ fail:
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This function returns the filesystem handle of a file from the structure
|
||||||
|
*/
|
||||||
|
ext2_filsys ext2fs_file_get_fs(ext2_file_t file)
|
||||||
|
{
|
||||||
|
if (file->magic != EXT2_ET_MAGIC_EXT2_FILE)
|
||||||
|
return 0;
|
||||||
|
return file->fs;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function flushes the dirty block buffer out to disk if
|
* This function flushes the dirty block buffer out to disk if
|
||||||
* necessary.
|
* necessary.
|
||||||
|
@ -130,12 +140,12 @@ errcode_t ext2fs_file_close(ext2_file_t file)
|
||||||
|
|
||||||
|
|
||||||
errcode_t ext2fs_file_read(ext2_file_t file, void *buf,
|
errcode_t ext2fs_file_read(ext2_file_t file, void *buf,
|
||||||
int wanted, int *got)
|
unsigned int wanted, unsigned int *got)
|
||||||
{
|
{
|
||||||
ext2_filsys fs;
|
ext2_filsys fs;
|
||||||
errcode_t retval;
|
errcode_t retval;
|
||||||
blk_t b, pb;
|
blk_t b, pb;
|
||||||
int start, left, c, count = 0;
|
unsigned int start, left, c, count = 0;
|
||||||
char *ptr = buf;
|
char *ptr = buf;
|
||||||
|
|
||||||
EXT2_CHECK_MAGIC(file, EXT2_ET_MAGIC_EXT2_FILE);
|
EXT2_CHECK_MAGIC(file, EXT2_ET_MAGIC_EXT2_FILE);
|
||||||
|
@ -200,12 +210,12 @@ fail:
|
||||||
|
|
||||||
|
|
||||||
errcode_t ext2fs_file_write(ext2_file_t file, void *buf,
|
errcode_t ext2fs_file_write(ext2_file_t file, void *buf,
|
||||||
int nbytes, int *written)
|
unsigned int nbytes, unsigned int *written)
|
||||||
{
|
{
|
||||||
ext2_filsys fs;
|
ext2_filsys fs;
|
||||||
errcode_t retval;
|
errcode_t retval;
|
||||||
blk_t b, pb;
|
blk_t b, pb;
|
||||||
int start, c, count = 0;
|
unsigned int start, c, count = 0;
|
||||||
char *ptr = buf;
|
char *ptr = buf;
|
||||||
|
|
||||||
EXT2_CHECK_MAGIC(file, EXT2_ET_MAGIC_EXT2_FILE);
|
EXT2_CHECK_MAGIC(file, EXT2_ET_MAGIC_EXT2_FILE);
|
||||||
|
@ -282,4 +292,34 @@ errcode_t ext2fs_file_llseek(ext2_file_t file, ext2_off_t offset,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This function returns the size of the file, according to the inode
|
||||||
|
*/
|
||||||
|
ext2_off_t ext2fs_file_get_size(ext2_file_t file)
|
||||||
|
{
|
||||||
|
if (file->magic != EXT2_ET_MAGIC_EXT2_FILE)
|
||||||
|
return 0;
|
||||||
|
return file->inode.i_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This function sets the size of the file, truncating it if necessary
|
||||||
|
*
|
||||||
|
* XXX still need to call truncate
|
||||||
|
*/
|
||||||
|
extern errcode_t ext2fs_file_set_size(ext2_file_t file, ext2_off_t size)
|
||||||
|
{
|
||||||
|
errcode_t retval;
|
||||||
|
EXT2_CHECK_MAGIC(file, EXT2_ET_MAGIC_EXT2_FILE);
|
||||||
|
|
||||||
|
file->inode.i_size = size;
|
||||||
|
retval = ext2fs_write_inode(file->fs, file->ino, &file->inode);
|
||||||
|
if (retval)
|
||||||
|
return retval;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* XXX truncate inode if necessary
|
||||||
|
*/
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue