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.
diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog
index 60086a0..7b489b4 100644
--- a/lib/ext2fs/ChangeLog
+++ b/lib/ext2fs/ChangeLog
@@ -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>
* Rename new error codes to _ET_ in them for consistency.
diff --git a/lib/ext2fs/bitops.c b/lib/ext2fs/bitops.c
index 70f4f4c..7286e7d 100644
--- a/lib/ext2fs/bitops.c
+++ b/lib/ext2fs/bitops.c
@@ -70,19 +70,23 @@
void ext2fs_warn_bitmap(errcode_t errcode, unsigned long arg,
const char *description)
{
+#ifndef OMIT_COM_ERR
if (description)
com_err(0, errcode, "#%u for %s", arg, description);
else
com_err(0, errcode, "#%u", arg);
+#endif
}
void ext2fs_warn_bitmap2(ext2fs_generic_bitmap bitmap,
int code, unsigned long arg)
{
+#ifndef OMIT_COM_ERR
if (bitmap->description)
com_err(0, bitmap->base_error_code+code,
"#%u for %s", arg, bitmap->description);
else
com_err(0, bitmap->base_error_code + code, "#%u", arg);
+#endif
}
diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h
index 41074b7..f9eb34e 100644
--- a/lib/ext2fs/ext2fs.h
+++ b/lib/ext2fs/ext2fs.h
@@ -580,13 +580,16 @@
/* fileio.c */
extern errcode_t ext2fs_file_open(ext2_filsys fs, 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_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,
- int nbytes, int *written);
+ unsigned int nbytes, unsigned int *written);
extern errcode_t ext2fs_file_llseek(ext2_file_t file, ext2_off_t offset,
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 */
extern void ext2fs_free(ext2_filsys fs);
@@ -721,9 +724,9 @@
const char **date_string);
/* 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_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_changed(ext2_filsys fs);
extern int ext2fs_test_changed(ext2_filsys fs);
@@ -754,7 +757,7 @@
/*
* 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);
if (!*ptr)
@@ -775,7 +778,7 @@
/*
* 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;
diff --git a/lib/ext2fs/fileio.c b/lib/ext2fs/fileio.c
index ffb11ef..4f34fde 100644
--- a/lib/ext2fs/fileio.c
+++ b/lib/ext2fs/fileio.c
@@ -78,6 +78,16 @@
}
/*
+ * 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
* necessary.
*/
@@ -130,12 +140,12 @@
errcode_t ext2fs_file_read(ext2_file_t file, void *buf,
- int wanted, int *got)
+ unsigned int wanted, unsigned int *got)
{
ext2_filsys fs;
errcode_t retval;
blk_t b, pb;
- int start, left, c, count = 0;
+ unsigned int start, left, c, count = 0;
char *ptr = buf;
EXT2_CHECK_MAGIC(file, EXT2_ET_MAGIC_EXT2_FILE);
@@ -200,12 +210,12 @@
errcode_t ext2fs_file_write(ext2_file_t file, void *buf,
- int nbytes, int *written)
+ unsigned int nbytes, unsigned int *written)
{
ext2_filsys fs;
errcode_t retval;
blk_t b, pb;
- int start, c, count = 0;
+ unsigned int start, c, count = 0;
char *ptr = buf;
EXT2_CHECK_MAGIC(file, EXT2_ET_MAGIC_EXT2_FILE);
@@ -282,4 +292,34 @@
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;
+}