diff options
Diffstat (limited to 'e2fsprogs/ext2fs/icount.c')
-rw-r--r-- | e2fsprogs/ext2fs/icount.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/e2fsprogs/ext2fs/icount.c b/e2fsprogs/ext2fs/icount.c index 59977928b..01677775f 100644 --- a/e2fsprogs/ext2fs/icount.c +++ b/e2fsprogs/ext2fs/icount.c | |||
@@ -81,19 +81,19 @@ errcode_t ext2fs_create_icount2(ext2_filsys fs, int flags, unsigned int size, | |||
81 | if (hint->size > size) | 81 | if (hint->size > size) |
82 | size = (size_t) hint->size; | 82 | size = (size_t) hint->size; |
83 | } | 83 | } |
84 | 84 | ||
85 | retval = ext2fs_get_mem(sizeof(struct ext2_icount), &icount); | 85 | retval = ext2fs_get_mem(sizeof(struct ext2_icount), &icount); |
86 | if (retval) | 86 | if (retval) |
87 | return retval; | 87 | return retval; |
88 | memset(icount, 0, sizeof(struct ext2_icount)); | 88 | memset(icount, 0, sizeof(struct ext2_icount)); |
89 | 89 | ||
90 | retval = ext2fs_allocate_inode_bitmap(fs, 0, | 90 | retval = ext2fs_allocate_inode_bitmap(fs, 0, |
91 | &icount->single); | 91 | &icount->single); |
92 | if (retval) | 92 | if (retval) |
93 | goto errout; | 93 | goto errout; |
94 | 94 | ||
95 | if (flags & EXT2_ICOUNT_OPT_INCREMENT) { | 95 | if (flags & EXT2_ICOUNT_OPT_INCREMENT) { |
96 | retval = ext2fs_allocate_inode_bitmap(fs, 0, | 96 | retval = ext2fs_allocate_inode_bitmap(fs, 0, |
97 | &icount->multiple); | 97 | &icount->multiple); |
98 | if (retval) | 98 | if (retval) |
99 | goto errout; | 99 | goto errout; |
@@ -113,7 +113,7 @@ errcode_t ext2fs_create_icount2(ext2_filsys fs, int flags, unsigned int size, | |||
113 | goto errout; | 113 | goto errout; |
114 | icount->size += fs->super->s_inodes_count / 50; | 114 | icount->size += fs->super->s_inodes_count / 50; |
115 | } | 115 | } |
116 | 116 | ||
117 | bytes = (size_t) (icount->size * sizeof(struct ext2_icount_el)); | 117 | bytes = (size_t) (icount->size * sizeof(struct ext2_icount_el)); |
118 | #if 0 | 118 | #if 0 |
119 | printf("Icount allocated %d entries, %d bytes.\n", | 119 | printf("Icount allocated %d entries, %d bytes.\n", |
@@ -148,7 +148,7 @@ errout: | |||
148 | return(retval); | 148 | return(retval); |
149 | } | 149 | } |
150 | 150 | ||
151 | errcode_t ext2fs_create_icount(ext2_filsys fs, int flags, | 151 | errcode_t ext2fs_create_icount(ext2_filsys fs, int flags, |
152 | unsigned int size, | 152 | unsigned int size, |
153 | ext2_icount_t *ret) | 153 | ext2_icount_t *ret) |
154 | { | 154 | { |
@@ -157,12 +157,12 @@ errcode_t ext2fs_create_icount(ext2_filsys fs, int flags, | |||
157 | 157 | ||
158 | /* | 158 | /* |
159 | * insert_icount_el() --- Insert a new entry into the sorted list at a | 159 | * insert_icount_el() --- Insert a new entry into the sorted list at a |
160 | * specified position. | 160 | * specified position. |
161 | */ | 161 | */ |
162 | static struct ext2_icount_el *insert_icount_el(ext2_icount_t icount, | 162 | static struct ext2_icount_el *insert_icount_el(ext2_icount_t icount, |
163 | ext2_ino_t ino, int pos) | 163 | ext2_ino_t ino, int pos) |
164 | { | 164 | { |
165 | struct ext2_icount_el *el; | 165 | struct ext2_icount_el *el; |
166 | errcode_t retval; | 166 | errcode_t retval; |
167 | ext2_ino_t new_size = 0; | 167 | ext2_ino_t new_size = 0; |
168 | int num; | 168 | int num; |
@@ -170,14 +170,14 @@ static struct ext2_icount_el *insert_icount_el(ext2_icount_t icount, | |||
170 | if (icount->count >= icount->size) { | 170 | if (icount->count >= icount->size) { |
171 | if (icount->count) { | 171 | if (icount->count) { |
172 | new_size = icount->list[(unsigned)icount->count-1].ino; | 172 | new_size = icount->list[(unsigned)icount->count-1].ino; |
173 | new_size = (ext2_ino_t) (icount->count * | 173 | new_size = (ext2_ino_t) (icount->count * |
174 | ((float) icount->num_inodes / new_size)); | 174 | ((float) icount->num_inodes / new_size)); |
175 | } | 175 | } |
176 | if (new_size < (icount->size + 100)) | 176 | if (new_size < (icount->size + 100)) |
177 | new_size = icount->size + 100; | 177 | new_size = icount->size + 100; |
178 | #if 0 | 178 | #if 0 |
179 | printf("Reallocating icount %d entries...\n", new_size); | 179 | printf("Reallocating icount %d entries...\n", new_size); |
180 | #endif | 180 | #endif |
181 | retval = ext2fs_resize_mem((size_t) icount->size * | 181 | retval = ext2fs_resize_mem((size_t) icount->size * |
182 | sizeof(struct ext2_icount_el), | 182 | sizeof(struct ext2_icount_el), |
183 | (size_t) new_size * | 183 | (size_t) new_size * |
@@ -203,8 +203,8 @@ static struct ext2_icount_el *insert_icount_el(ext2_icount_t icount, | |||
203 | 203 | ||
204 | /* | 204 | /* |
205 | * get_icount_el() --- given an inode number, try to find icount | 205 | * get_icount_el() --- given an inode number, try to find icount |
206 | * information in the sorted list. If the create flag is set, | 206 | * information in the sorted list. If the create flag is set, |
207 | * and we can't find an entry, create one in the sorted list. | 207 | * and we can't find an entry, create one in the sorted list. |
208 | */ | 208 | */ |
209 | static struct ext2_icount_el *get_icount_el(ext2_icount_t icount, | 209 | static struct ext2_icount_el *get_icount_el(ext2_icount_t icount, |
210 | ext2_ino_t ino, int create) | 210 | ext2_ino_t ino, int create) |
@@ -222,7 +222,7 @@ static struct ext2_icount_el *get_icount_el(ext2_icount_t icount, | |||
222 | } | 222 | } |
223 | if (icount->count == 0) | 223 | if (icount->count == 0) |
224 | return 0; | 224 | return 0; |
225 | 225 | ||
226 | if (icount->cursor >= icount->count) | 226 | if (icount->cursor >= icount->count) |
227 | icount->cursor = 0; | 227 | icount->cursor = 0; |
228 | if (ino == icount->list[icount->cursor].ino) | 228 | if (ino == icount->list[icount->cursor].ino) |
@@ -247,7 +247,7 @@ static struct ext2_icount_el *get_icount_el(ext2_icount_t icount, | |||
247 | range = 0; | 247 | range = 0; |
248 | else if (ino > highval) | 248 | else if (ino > highval) |
249 | range = 1; | 249 | range = 1; |
250 | else | 250 | else |
251 | range = ((float) (ino - lowval)) / | 251 | range = ((float) (ino - lowval)) / |
252 | (highval - lowval); | 252 | (highval - lowval); |
253 | mid = low + ((int) (range * (high-low))); | 253 | mid = low + ((int) (range * (high-low))); |
@@ -276,7 +276,7 @@ errcode_t ext2fs_icount_validate(ext2_icount_t icount, FILE *out) | |||
276 | errcode_t ret = 0; | 276 | errcode_t ret = 0; |
277 | unsigned int i; | 277 | unsigned int i; |
278 | const char *bad = "bad icount"; | 278 | const char *bad = "bad icount"; |
279 | 279 | ||
280 | EXT2_CHECK_MAGIC(icount, EXT2_ET_MAGIC_ICOUNT); | 280 | EXT2_CHECK_MAGIC(icount, EXT2_ET_MAGIC_ICOUNT); |
281 | 281 | ||
282 | if (icount->count > icount->size) { | 282 | if (icount->count > icount->size) { |
@@ -297,7 +297,7 @@ errcode_t ext2fs_icount_validate(ext2_icount_t icount, FILE *out) | |||
297 | errcode_t ext2fs_icount_fetch(ext2_icount_t icount, ext2_ino_t ino, __u16 *ret) | 297 | errcode_t ext2fs_icount_fetch(ext2_icount_t icount, ext2_ino_t ino, __u16 *ret) |
298 | { | 298 | { |
299 | struct ext2_icount_el *el; | 299 | struct ext2_icount_el *el; |
300 | 300 | ||
301 | EXT2_CHECK_MAGIC(icount, EXT2_ET_MAGIC_ICOUNT); | 301 | EXT2_CHECK_MAGIC(icount, EXT2_ET_MAGIC_ICOUNT); |
302 | 302 | ||
303 | if (!ino || (ino > icount->num_inodes)) | 303 | if (!ino || (ino > icount->num_inodes)) |
@@ -413,7 +413,7 @@ errcode_t ext2fs_icount_decrement(ext2_icount_t icount, ext2_ino_t ino, | |||
413 | if (icount->multiple && | 413 | if (icount->multiple && |
414 | !ext2fs_test_inode_bitmap(icount->multiple, ino)) | 414 | !ext2fs_test_inode_bitmap(icount->multiple, ino)) |
415 | return EXT2_ET_INVALID_ARGUMENT; | 415 | return EXT2_ET_INVALID_ARGUMENT; |
416 | 416 | ||
417 | el = get_icount_el(icount, ino, 0); | 417 | el = get_icount_el(icount, ino, 0); |
418 | if (!el || el->count == 0) | 418 | if (!el || el->count == 0) |
419 | return EXT2_ET_INVALID_ARGUMENT; | 419 | return EXT2_ET_INVALID_ARGUMENT; |