aboutsummaryrefslogtreecommitdiff
path: root/e2fsprogs/ext2fs/openfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'e2fsprogs/ext2fs/openfs.c')
-rw-r--r--e2fsprogs/ext2fs/openfs.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/e2fsprogs/ext2fs/openfs.c b/e2fsprogs/ext2fs/openfs.c
index e8f16495d..aa603337d 100644
--- a/e2fsprogs/ext2fs/openfs.c
+++ b/e2fsprogs/ext2fs/openfs.c
@@ -1,8 +1,8 @@
1/* 1/*
2 * openfs.c --- open an ext2 filesystem 2 * openfs.c --- open an ext2 filesystem
3 * 3 *
4 * Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o. 4 * Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o.
5 * 5 *
6 * %Begin-Header% 6 * %Begin-Header%
7 * This file may be redistributed under the terms of the GNU Public 7 * This file may be redistributed under the terms of the GNU Public
8 * License. 8 * License.
@@ -42,7 +42,7 @@ blk_t ext2fs_descriptor_block_loc(ext2_filsys fs, blk_t group_block, dgrp_t i)
42 bg = (fs->blocksize / sizeof (struct ext2_group_desc)) * i; 42 bg = (fs->blocksize / sizeof (struct ext2_group_desc)) * i;
43 if (ext2fs_bg_has_super(fs, bg)) 43 if (ext2fs_bg_has_super(fs, bg))
44 has_super = 1; 44 has_super = 1;
45 ret_blk = (fs->super->s_first_data_block + has_super + 45 ret_blk = (fs->super->s_first_data_block + has_super +
46 (bg * fs->super->s_blocks_per_group)); 46 (bg * fs->super->s_blocks_per_group));
47 /* 47 /*
48 * If group_block is not the normal value, we're trying to use 48 * If group_block is not the normal value, we're trying to use
@@ -60,27 +60,27 @@ blk_t ext2fs_descriptor_block_loc(ext2_filsys fs, blk_t group_block, dgrp_t i)
60} 60}
61 61
62errcode_t ext2fs_open(const char *name, int flags, int superblock, 62errcode_t ext2fs_open(const char *name, int flags, int superblock,
63 unsigned int block_size, io_manager manager, 63 unsigned int block_size, io_manager manager,
64 ext2_filsys *ret_fs) 64 ext2_filsys *ret_fs)
65{ 65{
66 return ext2fs_open2(name, 0, flags, superblock, block_size, 66 return ext2fs_open2(name, 0, flags, superblock, block_size,
67 manager, ret_fs); 67 manager, ret_fs);
68} 68}
69 69
70/* 70/*
71 * Note: if superblock is non-zero, block-size must also be non-zero. 71 * Note: if superblock is non-zero, block-size must also be non-zero.
72 * Superblock and block_size can be zero to use the default size. 72 * Superblock and block_size can be zero to use the default size.
73 * 73 *
74 * Valid flags for ext2fs_open() 74 * Valid flags for ext2fs_open()
75 * 75 *
76 * EXT2_FLAG_RW - Open the filesystem for read/write. 76 * EXT2_FLAG_RW - Open the filesystem for read/write.
77 * EXT2_FLAG_FORCE - Open the filesystem even if some of the 77 * EXT2_FLAG_FORCE - Open the filesystem even if some of the
78 * features aren't supported. 78 * features aren't supported.
79 * EXT2_FLAG_JOURNAL_DEV_OK - Open an ext3 journal device 79 * EXT2_FLAG_JOURNAL_DEV_OK - Open an ext3 journal device
80 */ 80 */
81errcode_t ext2fs_open2(const char *name, const char *io_options, 81errcode_t ext2fs_open2(const char *name, const char *io_options,
82 int flags, int superblock, 82 int flags, int superblock,
83 unsigned int block_size, io_manager manager, 83 unsigned int block_size, io_manager manager,
84 ext2_filsys *ret_fs) 84 ext2_filsys *ret_fs)
85{ 85{
86 ext2_filsys fs; 86 ext2_filsys fs;
@@ -93,13 +93,13 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
93 int j; 93 int j;
94 struct ext2_group_desc *gdp; 94 struct ext2_group_desc *gdp;
95#endif 95#endif
96 96
97 EXT2_CHECK_MAGIC(manager, EXT2_ET_MAGIC_IO_MANAGER); 97 EXT2_CHECK_MAGIC(manager, EXT2_ET_MAGIC_IO_MANAGER);
98 98
99 retval = ext2fs_get_mem(sizeof(struct struct_ext2_filsys), &fs); 99 retval = ext2fs_get_mem(sizeof(struct struct_ext2_filsys), &fs);
100 if (retval) 100 if (retval)
101 return retval; 101 return retval;
102 102
103 memset(fs, 0, sizeof(struct struct_ext2_filsys)); 103 memset(fs, 0, sizeof(struct struct_ext2_filsys));
104 fs->magic = EXT2_ET_MAGIC_EXT2FS_FILSYS; 104 fs->magic = EXT2_ET_MAGIC_EXT2FS_FILSYS;
105 fs->flags = flags; 105 fs->flags = flags;
@@ -113,13 +113,13 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
113 *cp++ = 0; 113 *cp++ = 0;
114 io_options = cp; 114 io_options = cp;
115 } 115 }
116 116
117 retval = manager->open(fs->device_name, 117 retval = manager->open(fs->device_name,
118 (flags & EXT2_FLAG_RW) ? IO_FLAG_RW : 0, 118 (flags & EXT2_FLAG_RW) ? IO_FLAG_RW : 0,
119 &fs->io); 119 &fs->io);
120 if (retval) 120 if (retval)
121 goto cleanup; 121 goto cleanup;
122 if (io_options && 122 if (io_options &&
123 (retval = io_channel_set_options(fs->io, io_options))) 123 (retval = io_channel_set_options(fs->io, io_options)))
124 goto cleanup; 124 goto cleanup;
125 fs->image_io = fs->io; 125 fs->image_io = fs->io;
@@ -183,7 +183,7 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
183 ext2fs_swap_super(fs->super); 183 ext2fs_swap_super(fs->super);
184 } 184 }
185#endif 185#endif
186 186
187 if (fs->super->s_magic != EXT2_SUPER_MAGIC) { 187 if (fs->super->s_magic != EXT2_SUPER_MAGIC) {
188 retval = EXT2_ET_BAD_MAGIC; 188 retval = EXT2_ET_BAD_MAGIC;
189 goto cleanup; 189 goto cleanup;
@@ -215,7 +215,7 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
215 goto cleanup; 215 goto cleanup;
216 } 216 }
217 } 217 }
218 218
219 fs->blocksize = EXT2_BLOCK_SIZE(fs->super); 219 fs->blocksize = EXT2_BLOCK_SIZE(fs->super);
220 if (fs->blocksize == 0) { 220 if (fs->blocksize == 0) {
221 retval = EXT2_ET_CORRUPT_SUPERBLOCK; 221 retval = EXT2_ET_CORRUPT_SUPERBLOCK;
@@ -247,7 +247,7 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
247 *ret_fs = fs; 247 *ret_fs = fs;
248 return 0; 248 return 0;
249 } 249 }
250 250
251 /* 251 /*
252 * Read group descriptors 252 * Read group descriptors
253 */ 253 */
@@ -296,7 +296,7 @@ cleanup:
296 296
297/* 297/*
298 * Set/get the filesystem data I/O channel. 298 * Set/get the filesystem data I/O channel.
299 * 299 *
300 * These functions are only valid if EXT2_FLAG_IMAGE_FILE is true. 300 * These functions are only valid if EXT2_FLAG_IMAGE_FILE is true.
301 */ 301 */
302errcode_t ext2fs_get_data_io(ext2_filsys fs, io_channel *old_io) 302errcode_t ext2fs_get_data_io(ext2_filsys fs, io_channel *old_io)
@@ -322,7 +322,7 @@ errcode_t ext2fs_rewrite_to_io(ext2_filsys fs, io_channel new_io)
322 if ((fs->flags & EXT2_FLAG_IMAGE_FILE) == 0) 322 if ((fs->flags & EXT2_FLAG_IMAGE_FILE) == 0)
323 return EXT2_ET_NOT_IMAGE_FILE; 323 return EXT2_ET_NOT_IMAGE_FILE;
324 fs->io = fs->image_io = new_io; 324 fs->io = fs->image_io = new_io;
325 fs->flags |= EXT2_FLAG_DIRTY | EXT2_FLAG_RW | 325 fs->flags |= EXT2_FLAG_DIRTY | EXT2_FLAG_RW |
326 EXT2_FLAG_BB_DIRTY | EXT2_FLAG_IB_DIRTY; 326 EXT2_FLAG_BB_DIRTY | EXT2_FLAG_IB_DIRTY;
327 fs->flags &= ~EXT2_FLAG_IMAGE_FILE; 327 fs->flags &= ~EXT2_FLAG_IMAGE_FILE;
328 return 0; 328 return 0;