2007-08-17 03:48:42

by Eric Sandeen

[permalink] [raw]
Subject: [PATCH] rename ->open and ->close ops in struct_io_manager

glibc recently added for -D_FORTIFY_SOURCE=2 error checking
open/open64/openat/openat64 macros that verify proper use, including
checking that a mode is supplied with O_CREAT.

These macros re-#define "open," which does not play nice
when that name is used elsewhere.

Renaming open (and for symmetry, close) in struct_io_manager
seems like one way to go. On the one hand I hate to have to
change code for this, but on the other hand it may not be worth
fighting. Any thoughts?

Thanks,
-Eric

----

rename struct_io_manager's ->open and ->close members so that
recent glibc's redefined "open" for -D_FORTIFY_SOURCE=2 does
not clash with it.

Signed-off-by: Eric Sandeen <[email protected]>

Index: e2fsprogs-git/debugfs/debugfs.c
===================================================================
--- e2fsprogs-git.orig/debugfs/debugfs.c
+++ e2fsprogs-git/debugfs/debugfs.c
@@ -62,7 +62,7 @@ static void open_filesystem(char *device
current_fs = NULL;
return;
}
- retval = unix_io_manager->open(data_filename, 0, &data_io);
+ retval = unix_io_manager->io_open(data_filename, 0, &data_io);
if (retval) {
com_err(data_filename, 0, "while opening data source");
current_fs = NULL;
Index: e2fsprogs-git/e2fsck/journal.c
===================================================================
--- e2fsprogs-git.orig/e2fsck/journal.c
+++ e2fsprogs-git/e2fsck/journal.c
@@ -362,7 +362,7 @@ static errcode_t e2fsck_get_journal(e2fs
#ifndef USE_INODE_IO
if (ext_journal)
#endif
- retval = io_ptr->open(journal_name, IO_FLAG_RW,
+ retval = io_ptr->io_open(journal_name, IO_FLAG_RW,
&ctx->journal_io);
if (retval)
goto errout;
Index: e2fsprogs-git/lib/ext2fs/ext2_io.h
===================================================================
--- e2fsprogs-git.orig/lib/ext2fs/ext2_io.h
+++ e2fsprogs-git/lib/ext2fs/ext2_io.h
@@ -66,8 +66,8 @@ struct struct_io_stats {
struct struct_io_manager {
errcode_t magic;
const char *name;
- errcode_t (*open)(const char *name, int flags, io_channel *channel);
- errcode_t (*close)(io_channel channel);
+ errcode_t (*io_open)(const char *name, int flags, io_channel *channel);
+ errcode_t (*io_close)(io_channel channel);
errcode_t (*set_blksize)(io_channel channel, int blksize);
errcode_t (*read_blk)(io_channel channel, unsigned long block,
int count, void *data);
@@ -88,7 +88,7 @@ struct struct_io_manager {
/*
* Convenience functions....
*/
-#define io_channel_close(c) ((c)->manager->close((c)))
+#define io_channel_close(c) ((c)->manager->io_close((c)))
#define io_channel_set_blksize(c,s) ((c)->manager->set_blksize((c),s))
#define io_channel_read_blk(c,b,n,d) ((c)->manager->read_blk((c),b,n,d))
#define io_channel_write_blk(c,b,n,d) ((c)->manager->write_blk((c),b,n,d))
Index: e2fsprogs-git/lib/ext2fs/initialize.c
===================================================================
--- e2fsprogs-git.orig/lib/ext2fs/initialize.c
+++ e2fsprogs-git/lib/ext2fs/initialize.c
@@ -124,7 +124,7 @@ errcode_t ext2fs_initialize(const char *
io_flags = IO_FLAG_RW;
if (flags & EXT2_FLAG_EXCLUSIVE)
io_flags |= IO_FLAG_EXCLUSIVE;
- retval = manager->open(name, io_flags, &fs->io);
+ retval = manager->io_open(name, io_flags, &fs->io);
if (retval)
goto cleanup;
fs->image_io = fs->io;
Index: e2fsprogs-git/lib/ext2fs/openfs.c
===================================================================
--- e2fsprogs-git.orig/lib/ext2fs/openfs.c
+++ e2fsprogs-git/lib/ext2fs/openfs.c
@@ -119,7 +119,7 @@ errcode_t ext2fs_open2(const char *name,
io_flags |= IO_FLAG_RW;
if (flags & EXT2_FLAG_EXCLUSIVE)
io_flags |= IO_FLAG_EXCLUSIVE;
- retval = manager->open(fs->device_name, io_flags, &fs->io);
+ retval = manager->io_open(fs->device_name, io_flags, &fs->io);
if (retval)
goto cleanup;
if (io_options &&
Index: e2fsprogs-git/lib/ext2fs/test_io.c
===================================================================
--- e2fsprogs-git.orig/lib/ext2fs/test_io.c
+++ e2fsprogs-git/lib/ext2fs/test_io.c
@@ -198,7 +198,7 @@ static errcode_t test_open(const char *n
memset(data, 0, sizeof(struct test_private_data));
data->magic = EXT2_ET_MAGIC_TEST_IO_CHANNEL;
if (test_io_backing_manager) {
- retval = test_io_backing_manager->open(name, flags,
+ retval = test_io_backing_manager->io_open(name, flags,
&data->real);
if (retval)
goto cleanup;
Index: e2fsprogs-git/misc/e2image.c
===================================================================
--- e2fsprogs-git.orig/misc/e2image.c
+++ e2fsprogs-git/misc/e2image.c
@@ -582,7 +582,7 @@ static void install_image(char *device,
exit(1);
}

- retval = io_ptr->open(device, IO_FLAG_RW, &io);
+ retval = io_ptr->io_open(device, IO_FLAG_RW, &io);
if (retval) {
com_err(device, 0, "while opening device file");
exit(1);