diff options
author | Tim Riker <tim@rikers.org> | 2006-01-25 00:08:53 +0000 |
---|---|---|
committer | Tim Riker <tim@rikers.org> | 2006-01-25 00:08:53 +0000 |
commit | c1ef7bdd8d002ae0889efcf883d0e1b7faa938d4 (patch) | |
tree | 5f329b7d0c7f20ecced0dc7581a9ba6dc720d965 /e2fsprogs/ext2fs/unix_io.c | |
parent | f64ff682a3d58dbb627e760e6fe1ec21d9ccdf61 (diff) | |
download | busybox-w32-c1ef7bdd8d002ae0889efcf883d0e1b7faa938d4.tar.gz busybox-w32-c1ef7bdd8d002ae0889efcf883d0e1b7faa938d4.tar.bz2 busybox-w32-c1ef7bdd8d002ae0889efcf883d0e1b7faa938d4.zip |
just whitespace
Diffstat (limited to 'e2fsprogs/ext2fs/unix_io.c')
-rw-r--r-- | e2fsprogs/ext2fs/unix_io.c | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/e2fsprogs/ext2fs/unix_io.c b/e2fsprogs/ext2fs/unix_io.c index 5bc7a6abe..36b222577 100644 --- a/e2fsprogs/ext2fs/unix_io.c +++ b/e2fsprogs/ext2fs/unix_io.c | |||
@@ -1,13 +1,13 @@ | |||
1 | /* | 1 | /* |
2 | * unix_io.c --- This is the Unix (well, really POSIX) implementation | 2 | * unix_io.c --- This is the Unix (well, really POSIX) implementation |
3 | * of the I/O manager. | 3 | * of the I/O manager. |
4 | * | 4 | * |
5 | * Implements a one-block write-through cache. | 5 | * Implements a one-block write-through cache. |
6 | * | 6 | * |
7 | * Includes support for Windows NT support under Cygwin. | 7 | * Includes support for Windows NT support under Cygwin. |
8 | * | 8 | * |
9 | * Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, | 9 | * Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, |
10 | * 2002 by Theodore Ts'o. | 10 | * 2002 by Theodore Ts'o. |
11 | * | 11 | * |
12 | * %Begin-Header% | 12 | * %Begin-Header% |
13 | * This file may be redistributed under the terms of the GNU Public | 13 | * This file may be redistributed under the terms of the GNU Public |
@@ -79,7 +79,7 @@ static errcode_t unix_write_blk(io_channel channel, unsigned long block, | |||
79 | static errcode_t unix_flush(io_channel channel); | 79 | static errcode_t unix_flush(io_channel channel); |
80 | static errcode_t unix_write_byte(io_channel channel, unsigned long offset, | 80 | static errcode_t unix_write_byte(io_channel channel, unsigned long offset, |
81 | int size, const void *data); | 81 | int size, const void *data); |
82 | static errcode_t unix_set_option(io_channel channel, const char *option, | 82 | static errcode_t unix_set_option(io_channel channel, const char *option, |
83 | const char *arg); | 83 | const char *arg); |
84 | 84 | ||
85 | static void reuse_cache(io_channel channel, struct unix_private_data *data, | 85 | static void reuse_cache(io_channel channel, struct unix_private_data *data, |
@@ -140,7 +140,7 @@ static errcode_t raw_read_blk(io_channel channel, | |||
140 | goto error_out; | 140 | goto error_out; |
141 | } | 141 | } |
142 | return 0; | 142 | return 0; |
143 | 143 | ||
144 | error_out: | 144 | error_out: |
145 | memset((char *) buf+actual, 0, size-actual); | 145 | memset((char *) buf+actual, 0, size-actual); |
146 | if (channel->read_error) | 146 | if (channel->read_error) |
@@ -168,7 +168,7 @@ static errcode_t raw_read_blk(io_channel channel, | |||
168 | location = ((ext2_loff_t) block * channel->block_size) + data->offset; | 168 | location = ((ext2_loff_t) block * channel->block_size) + data->offset; |
169 | #ifdef DEBUG | 169 | #ifdef DEBUG |
170 | printf("count=%d, size=%d, block=%d, blk_size=%d, location=%lx\n", | 170 | printf("count=%d, size=%d, block=%d, blk_size=%d, location=%lx\n", |
171 | count, size, block, channel->block_size, location); | 171 | count, size, block, channel->block_size, location); |
172 | #endif | 172 | #endif |
173 | if (ext2fs_llseek(data->dev, location, SEEK_SET) != location) { | 173 | if (ext2fs_llseek(data->dev, location, SEEK_SET) != location) { |
174 | retval = errno ? errno : EXT2_ET_LLSEEK_FAILED; | 174 | retval = errno ? errno : EXT2_ET_LLSEEK_FAILED; |
@@ -227,14 +227,14 @@ static errcode_t raw_write_blk(io_channel channel, | |||
227 | retval = errno ? errno : EXT2_ET_LLSEEK_FAILED; | 227 | retval = errno ? errno : EXT2_ET_LLSEEK_FAILED; |
228 | goto error_out; | 228 | goto error_out; |
229 | } | 229 | } |
230 | 230 | ||
231 | actual = write(data->dev, buf, size); | 231 | actual = write(data->dev, buf, size); |
232 | if (actual != size) { | 232 | if (actual != size) { |
233 | retval = EXT2_ET_SHORT_WRITE; | 233 | retval = EXT2_ET_SHORT_WRITE; |
234 | goto error_out; | 234 | goto error_out; |
235 | } | 235 | } |
236 | return 0; | 236 | return 0; |
237 | 237 | ||
238 | error_out: | 238 | error_out: |
239 | if (channel->write_error) | 239 | if (channel->write_error) |
240 | retval = (channel->write_error)(channel, block, count, buf, | 240 | retval = (channel->write_error)(channel, block, count, buf, |
@@ -254,7 +254,7 @@ static errcode_t alloc_cache(io_channel channel, | |||
254 | errcode_t retval; | 254 | errcode_t retval; |
255 | struct unix_cache *cache; | 255 | struct unix_cache *cache; |
256 | int i; | 256 | int i; |
257 | 257 | ||
258 | data->access_time = 0; | 258 | data->access_time = 0; |
259 | for (i=0, cache = data->cache; i < CACHE_SIZE; i++, cache++) { | 259 | for (i=0, cache = data->cache; i < CACHE_SIZE; i++, cache++) { |
260 | cache->block = 0; | 260 | cache->block = 0; |
@@ -273,7 +273,7 @@ static void free_cache(struct unix_private_data *data) | |||
273 | { | 273 | { |
274 | struct unix_cache *cache; | 274 | struct unix_cache *cache; |
275 | int i; | 275 | int i; |
276 | 276 | ||
277 | data->access_time = 0; | 277 | data->access_time = 0; |
278 | for (i=0, cache = data->cache; i < CACHE_SIZE; i++, cache++) { | 278 | for (i=0, cache = data->cache; i < CACHE_SIZE; i++, cache++) { |
279 | cache->block = 0; | 279 | cache->block = 0; |
@@ -298,7 +298,7 @@ static struct unix_cache *find_cached_block(struct unix_private_data *data, | |||
298 | { | 298 | { |
299 | struct unix_cache *cache, *unused_cache, *oldest_cache; | 299 | struct unix_cache *cache, *unused_cache, *oldest_cache; |
300 | int i; | 300 | int i; |
301 | 301 | ||
302 | unused_cache = oldest_cache = 0; | 302 | unused_cache = oldest_cache = 0; |
303 | for (i=0, cache = data->cache; i < CACHE_SIZE; i++, cache++) { | 303 | for (i=0, cache = data->cache; i < CACHE_SIZE; i++, cache++) { |
304 | if (!cache->in_use) { | 304 | if (!cache->in_use) { |
@@ -345,18 +345,18 @@ static errcode_t flush_cached_blocks(io_channel channel, | |||
345 | struct unix_cache *cache; | 345 | struct unix_cache *cache; |
346 | errcode_t retval, retval2; | 346 | errcode_t retval, retval2; |
347 | int i; | 347 | int i; |
348 | 348 | ||
349 | retval2 = 0; | 349 | retval2 = 0; |
350 | for (i=0, cache = data->cache; i < CACHE_SIZE; i++, cache++) { | 350 | for (i=0, cache = data->cache; i < CACHE_SIZE; i++, cache++) { |
351 | if (!cache->in_use) | 351 | if (!cache->in_use) |
352 | continue; | 352 | continue; |
353 | 353 | ||
354 | if (invalidate) | 354 | if (invalidate) |
355 | cache->in_use = 0; | 355 | cache->in_use = 0; |
356 | 356 | ||
357 | if (!cache->dirty) | 357 | if (!cache->dirty) |
358 | continue; | 358 | continue; |
359 | 359 | ||
360 | retval = raw_write_blk(channel, data, | 360 | retval = raw_write_blk(channel, data, |
361 | cache->block, 1, cache->buf); | 361 | cache->block, 1, cache->buf); |
362 | if (retval) | 362 | if (retval) |
@@ -376,7 +376,7 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel) | |||
376 | int open_flags; | 376 | int open_flags; |
377 | struct stat st; | 377 | struct stat st; |
378 | #ifdef __linux__ | 378 | #ifdef __linux__ |
379 | struct utsname ut; | 379 | struct utsname ut; |
380 | #endif | 380 | #endif |
381 | 381 | ||
382 | if (name == 0) | 382 | if (name == 0) |
@@ -431,7 +431,7 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel) | |||
431 | * block devices are wrongly getting hit by the filesize | 431 | * block devices are wrongly getting hit by the filesize |
432 | * limit. This workaround isn't perfect, since it won't work | 432 | * limit. This workaround isn't perfect, since it won't work |
433 | * if glibc wasn't built against 2.2 header files. (Sigh.) | 433 | * if glibc wasn't built against 2.2 header files. (Sigh.) |
434 | * | 434 | * |
435 | */ | 435 | */ |
436 | if ((flags & IO_FLAG_RW) && | 436 | if ((flags & IO_FLAG_RW) && |
437 | (uname(&ut) == 0) && | 437 | (uname(&ut) == 0) && |
@@ -442,7 +442,7 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel) | |||
442 | (fstat(data->dev, &st) == 0) && | 442 | (fstat(data->dev, &st) == 0) && |
443 | (S_ISBLK(st.st_mode))) { | 443 | (S_ISBLK(st.st_mode))) { |
444 | struct rlimit rlim; | 444 | struct rlimit rlim; |
445 | 445 | ||
446 | rlim.rlim_cur = rlim.rlim_max = (unsigned long) RLIM_INFINITY; | 446 | rlim.rlim_cur = rlim.rlim_max = (unsigned long) RLIM_INFINITY; |
447 | setrlimit(RLIMIT_FSIZE, &rlim); | 447 | setrlimit(RLIMIT_FSIZE, &rlim); |
448 | getrlimit(RLIMIT_FSIZE, &rlim); | 448 | getrlimit(RLIMIT_FSIZE, &rlim); |
@@ -507,7 +507,7 @@ static errcode_t unix_set_blksize(io_channel channel, int blksize) | |||
507 | if ((retval = flush_cached_blocks(channel, data, 0))) | 507 | if ((retval = flush_cached_blocks(channel, data, 0))) |
508 | return retval; | 508 | return retval; |
509 | #endif | 509 | #endif |
510 | 510 | ||
511 | channel->block_size = blksize; | 511 | channel->block_size = blksize; |
512 | free_cache(data); | 512 | free_cache(data); |
513 | if ((retval = alloc_cache(channel, data))) | 513 | if ((retval = alloc_cache(channel, data))) |
@@ -568,7 +568,7 @@ static errcode_t unix_read_blk(io_channel channel, unsigned long block, | |||
568 | #endif | 568 | #endif |
569 | if ((retval = raw_read_blk(channel, data, block, i, cp))) | 569 | if ((retval = raw_read_blk(channel, data, block, i, cp))) |
570 | return retval; | 570 | return retval; |
571 | 571 | ||
572 | /* Save the results in the cache */ | 572 | /* Save the results in the cache */ |
573 | for (j=0; j < i; j++) { | 573 | for (j=0; j < i; j++) { |
574 | count--; | 574 | count--; |
@@ -597,7 +597,7 @@ static errcode_t unix_write_blk(io_channel channel, unsigned long block, | |||
597 | 597 | ||
598 | #ifdef NO_IO_CACHE | 598 | #ifdef NO_IO_CACHE |
599 | return raw_write_blk(channel, data, block, count, buf); | 599 | return raw_write_blk(channel, data, block, count, buf); |
600 | #else | 600 | #else |
601 | /* | 601 | /* |
602 | * If we're doing an odd-sized write or a very large write, | 602 | * If we're doing an odd-sized write or a very large write, |
603 | * flush out the cache completely and then do a direct write. | 603 | * flush out the cache completely and then do a direct write. |
@@ -616,7 +616,7 @@ static errcode_t unix_write_blk(io_channel channel, unsigned long block, | |||
616 | writethrough = channel->flags & CHANNEL_FLAGS_WRITETHROUGH; | 616 | writethrough = channel->flags & CHANNEL_FLAGS_WRITETHROUGH; |
617 | if (writethrough) | 617 | if (writethrough) |
618 | retval = raw_write_blk(channel, data, block, count, buf); | 618 | retval = raw_write_blk(channel, data, block, count, buf); |
619 | 619 | ||
620 | cp = buf; | 620 | cp = buf; |
621 | while (count > 0) { | 621 | while (count > 0) { |
622 | cache = find_cached_block(data, block, &reuse); | 622 | cache = find_cached_block(data, block, &reuse); |
@@ -655,7 +655,7 @@ static errcode_t unix_write_byte(io_channel channel, unsigned long offset, | |||
655 | 655 | ||
656 | if (lseek(data->dev, offset + data->offset, SEEK_SET) < 0) | 656 | if (lseek(data->dev, offset + data->offset, SEEK_SET) < 0) |
657 | return errno; | 657 | return errno; |
658 | 658 | ||
659 | actual = write(data->dev, buf, size); | 659 | actual = write(data->dev, buf, size); |
660 | if (actual != size) | 660 | if (actual != size) |
661 | return EXT2_ET_SHORT_WRITE; | 661 | return EXT2_ET_SHORT_WRITE; |
@@ -664,13 +664,13 @@ static errcode_t unix_write_byte(io_channel channel, unsigned long offset, | |||
664 | } | 664 | } |
665 | 665 | ||
666 | /* | 666 | /* |
667 | * Flush data buffers to disk. | 667 | * Flush data buffers to disk. |
668 | */ | 668 | */ |
669 | static errcode_t unix_flush(io_channel channel) | 669 | static errcode_t unix_flush(io_channel channel) |
670 | { | 670 | { |
671 | struct unix_private_data *data; | 671 | struct unix_private_data *data; |
672 | errcode_t retval = 0; | 672 | errcode_t retval = 0; |
673 | 673 | ||
674 | EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL); | 674 | EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL); |
675 | data = (struct unix_private_data *) channel->private_data; | 675 | data = (struct unix_private_data *) channel->private_data; |
676 | EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_UNIX_IO_CHANNEL); | 676 | EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_UNIX_IO_CHANNEL); |
@@ -682,7 +682,7 @@ static errcode_t unix_flush(io_channel channel) | |||
682 | return retval; | 682 | return retval; |
683 | } | 683 | } |
684 | 684 | ||
685 | static errcode_t unix_set_option(io_channel channel, const char *option, | 685 | static errcode_t unix_set_option(io_channel channel, const char *option, |
686 | const char *arg) | 686 | const char *arg) |
687 | { | 687 | { |
688 | struct unix_private_data *data; | 688 | struct unix_private_data *data; |