From c555aebde40afdc0d15d674f2c81c0e05cfded3f Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Sat, 25 Oct 1997 04:16:53 +0000 Subject: Many files: alloc.c (ext2fs_alloc_block): New function which allocates a block and updates the filesystem accounting records appropriately. ext2_err.et.in: Added new error codes: EXT2_NO_MEMORY, EXT2_INVALID_ARGUMENT, EXT2_BLOCK_ALLOC_FAIL, EXT2_INODE_ALLOC_FAIL, EXT2_NOT_DIRECTORY Change various library files to use these functions instead of EINVAL, ENOENT, etc. ChangeLog, pass1.c, pass3.c: pass3.c (get_lost_and_found): Check error return of EXT2_FILE_NOT_FOUND instead of ENOTDIR pass1.c (pass1_check_directory): Return EXT2_NO_DIRECTORY instead of ENOTDIR expect.icount: Change expected error string to be "Invalid argument passed to ext2 library" instead of just "Invalid argument" --- lib/ext2fs/unix_io.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'lib/ext2fs/unix_io.c') diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c index 203ce576..f1d37b52 100644 --- a/lib/ext2fs/unix_io.c +++ b/lib/ext2fs/unix_io.c @@ -25,9 +25,6 @@ #if HAVE_SYS_TYPES_H #include #endif -#if HAVE_ERRNO_H -#include -#endif #include "et/com_err.h" #include "ext2fs/ext2_err.h" @@ -80,19 +77,19 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel) return EXT2_ET_BAD_DEVICE_NAME; io = (io_channel) malloc(sizeof(struct struct_io_channel)); if (!io) - return ENOMEM; + return EXT2_NO_MEMORY; memset(io, 0, sizeof(struct struct_io_channel)); io->magic = EXT2_ET_MAGIC_IO_CHANNEL; data = (struct unix_private_data *) malloc(sizeof(struct unix_private_data)); if (!data) { - retval = ENOMEM; + retval = EXT2_NO_MEMORY; goto cleanup; } io->manager = unix_io_manager; io->name = malloc(strlen(name)+1); if (!io->name) { - retval = ENOMEM; + retval = EXT2_NO_MEMORY; goto cleanup; } strcpy(io->name, name); @@ -107,7 +104,7 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel) data->buf = malloc(io->block_size); data->buf_block_nr = -1; if (!data->buf) { - retval = ENOMEM; + retval = EXT2_NO_MEMORY; goto cleanup; } data->dev = open(name, (flags & IO_FLAG_RW) ? O_RDWR : O_RDONLY); @@ -166,7 +163,7 @@ static errcode_t unix_set_blksize(io_channel channel, int blksize) free(data->buf); data->buf = malloc(blksize); if (!data->buf) - return ENOMEM; + return EXT2_NO_MEMORY; data->buf_block_nr = -1; } return 0; -- cgit v1.2.3