Changeset ed903174 in mainline for uspace/lib
- Timestamp:
- 2010-02-10T23:51:23Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e70edd1
- Parents:
- b32c604f
- Location:
- uspace/lib
- Files:
-
- 14 edited
-
libblock/libblock.c (modified) (16 diffs)
-
libblock/libblock.h (modified) (3 diffs)
-
libc/generic/io/io.c (modified) (2 diffs)
-
libc/generic/mman.c (modified) (1 diff)
-
libc/generic/vfs/vfs.c (modified) (4 diffs)
-
libc/include/limits.h (modified) (4 diffs)
-
libc/include/stdio.h (modified) (3 diffs)
-
libc/include/sys/mman.h (modified) (2 diffs)
-
libc/include/sys/stat.h (modified) (2 diffs)
-
libc/include/sys/typefmt.h (modified) (1 diff)
-
libc/include/sys/types.h (modified) (1 diff)
-
libc/include/unistd.h (modified) (3 diffs)
-
libfs/libfs.c (modified) (7 diffs)
-
libfs/libfs.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libblock/libblock.c
rb32c604f red903174 1 1 /* 2 * Copyright (c) 2008 Jakub Jermar 3 * Copyright (c) 2008 Martin Decky 2 * Copyright (c) 2008 Jakub Jermar 3 * Copyright (c) 2008 Martin Decky 4 4 * All rights reserved. 5 5 * … … 81 81 size_t comm_size; 82 82 void *bb_buf; 83 bn_t bb_addr;83 aoff64_t bb_addr; 84 84 size_t pblock_size; /**< Physical block size. */ 85 85 cache_t *cache; 86 86 } devcon_t; 87 87 88 static int read_blocks(devcon_t *devcon, bn_t ba, size_t cnt);89 static int write_blocks(devcon_t *devcon, bn_t ba, size_t cnt);88 static int read_blocks(devcon_t *devcon, aoff64_t ba, size_t cnt); 89 static int write_blocks(devcon_t *devcon, aoff64_t ba, size_t cnt); 90 90 static int get_block_size(int dev_phone, size_t *bsize); 91 static int get_num_blocks(int dev_phone, bn_t *nblocks);91 static int get_num_blocks(int dev_phone, aoff64_t *nblocks); 92 92 93 93 static devcon_t *devcon_search(dev_handle_t dev_handle) … … 214 214 } 215 215 216 int block_bb_read(dev_handle_t dev_handle, bn_t ba)216 int block_bb_read(dev_handle_t dev_handle, aoff64_t ba) 217 217 { 218 218 void *bb_buf; … … 334 334 } 335 335 336 long key = b->boff;336 unsigned long key = b->boff; 337 337 hash_table_remove(&cache->block_hash, &key, 1); 338 338 … … 382 382 * @return EOK on success or a negative error code. 383 383 */ 384 int block_get(block_t **block, dev_handle_t dev_handle, bn_t boff, int flags)384 int block_get(block_t **block, dev_handle_t dev_handle, aoff64_t boff, int flags) 385 385 { 386 386 devcon_t *devcon; … … 657 657 * @return EOK on success or a negative return code on failure. 658 658 */ 659 int block_seqread(dev_handle_t dev_handle, off_t *bufpos, size_t *buflen,660 off_t *pos, void *dst, size_t size)661 { 662 off_t offset = 0;659 int block_seqread(dev_handle_t dev_handle, size_t *bufpos, size_t *buflen, 660 aoff64_t *pos, void *dst, size_t size) 661 { 662 size_t offset = 0; 663 663 size_t left = size; 664 664 size_t block_size; … … 690 690 } 691 691 692 if (*bufpos == (off_t)*buflen) {692 if (*bufpos == *buflen) { 693 693 /* Refill the communication buffer with a new block. */ 694 694 int rc; … … 718 718 * @return EOK on success or negative error code on failure. 719 719 */ 720 int block_read_direct(dev_handle_t dev_handle, bn_t ba, size_t cnt, void *buf)720 int block_read_direct(dev_handle_t dev_handle, aoff64_t ba, size_t cnt, void *buf) 721 721 { 722 722 devcon_t *devcon; … … 746 746 * @return EOK on success or negative error code on failure. 747 747 */ 748 int block_write_direct(dev_handle_t dev_handle, bn_t ba, size_t cnt,748 int block_write_direct(dev_handle_t dev_handle, aoff64_t ba, size_t cnt, 749 749 const void *data) 750 750 { … … 789 789 * @return EOK on success or negative error code on failure. 790 790 */ 791 int block_get_nblocks(dev_handle_t dev_handle, bn_t *nblocks)791 int block_get_nblocks(dev_handle_t dev_handle, aoff64_t *nblocks) 792 792 { 793 793 devcon_t *devcon; … … 808 808 * @return EOK on success or negative error code on failure. 809 809 */ 810 static int read_blocks(devcon_t *devcon, bn_t ba, size_t cnt)810 static int read_blocks(devcon_t *devcon, aoff64_t ba, size_t cnt) 811 811 { 812 812 int rc; … … 816 816 UPPER32(ba), cnt); 817 817 if (rc != EOK) { 818 printf("Error %d reading %d blocks starting at block %" PRIu BN818 printf("Error %d reading %d blocks starting at block %" PRIuOFF64 819 819 " from device handle %d\n", rc, cnt, ba, 820 820 devcon->dev_handle); … … 835 835 * @return EOK on success or negative error code on failure. 836 836 */ 837 static int write_blocks(devcon_t *devcon, bn_t ba, size_t cnt)837 static int write_blocks(devcon_t *devcon, aoff64_t ba, size_t cnt) 838 838 { 839 839 int rc; … … 843 843 UPPER32(ba), cnt); 844 844 if (rc != EOK) { 845 printf("Error %d writing %d blocks starting at block %" PRIu BN845 printf("Error %d writing %d blocks starting at block %" PRIuOFF64 846 846 " to device handle %d\n", rc, cnt, ba, devcon->dev_handle); 847 847 #ifndef NDEBUG … … 866 866 867 867 /** Get total number of blocks on block device. */ 868 static int get_num_blocks(int dev_phone, bn_t *nblocks)868 static int get_num_blocks(int dev_phone, aoff64_t *nblocks) 869 869 { 870 870 ipcarg_t nb_l, nb_h; … … 873 873 rc = async_req_0_2(dev_phone, BD_GET_NUM_BLOCKS, &nb_l, &nb_h); 874 874 if (rc == EOK) { 875 *nblocks = ( bn_t) MERGE_LOUP32(nb_l, nb_h);875 *nblocks = (aoff64_t) MERGE_LOUP32(nb_l, nb_h); 876 876 } 877 877 -
uspace/lib/libblock/libblock.h
rb32c604f red903174 74 74 dev_handle_t dev_handle; 75 75 /** Block offset on the block device. Counted in 'size'-byte blocks. */ 76 bn_t boff;76 aoff64_t boff; 77 77 /** Size of the block. */ 78 78 size_t size; … … 96 96 extern void block_fini(dev_handle_t); 97 97 98 extern int block_bb_read(dev_handle_t, bn_t);98 extern int block_bb_read(dev_handle_t, aoff64_t); 99 99 extern void *block_bb_get(dev_handle_t); 100 100 … … 102 102 extern int block_cache_fini(dev_handle_t); 103 103 104 extern int block_get(block_t **, dev_handle_t, bn_t, int);104 extern int block_get(block_t **, dev_handle_t, aoff64_t, int); 105 105 extern int block_put(block_t *); 106 106 107 extern int block_seqread(dev_handle_t, off_t *, size_t *, off_t *, void *,107 extern int block_seqread(dev_handle_t, size_t *, size_t *, aoff64_t *, void *, 108 108 size_t); 109 109 110 110 extern int block_get_bsize(dev_handle_t, size_t *); 111 extern int block_get_nblocks(dev_handle_t, bn_t *);112 extern int block_read_direct(dev_handle_t, bn_t, size_t, void *);113 extern int block_write_direct(dev_handle_t, bn_t, size_t, const void *);111 extern int block_get_nblocks(dev_handle_t, aoff64_t *); 112 extern int block_read_direct(dev_handle_t, aoff64_t, size_t, void *); 113 extern int block_write_direct(dev_handle_t, aoff64_t, size_t, const void *); 114 114 115 115 #endif -
uspace/lib/libc/generic/io/io.c
rb32c604f red903174 541 541 } 542 542 543 int fseek(FILE *stream, long offset, int origin)544 { 545 off _t rc = lseek(stream->fd, offset, origin);546 if (rc == (off _t) (-1)) {547 /* errno has been set by lseek . */543 int fseek(FILE *stream, off64_t offset, int whence) 544 { 545 off64_t rc = lseek(stream->fd, offset, whence); 546 if (rc == (off64_t) (-1)) { 547 /* errno has been set by lseek64. */ 548 548 return -1; 549 549 } … … 554 554 } 555 555 556 int ftell(FILE *stream) 557 { 558 off_t rc = lseek(stream->fd, 0, SEEK_CUR); 559 if (rc == (off_t) (-1)) { 560 /* errno has been set by lseek. */ 561 return -1; 562 } 563 564 return rc; 556 off64_t ftell(FILE *stream) 557 { 558 return lseek(stream->fd, 0, SEEK_CUR); 565 559 } 566 560 -
uspace/lib/libc/generic/mman.c
rb32c604f red903174 39 39 40 40 void *mmap(void *start, size_t length, int prot, int flags, int fd, 41 off_t offset)41 aoff64_t offset) 42 42 { 43 43 if (!start) -
uspace/lib/libc/generic/vfs/vfs.c
rb32c604f red903174 35 35 #include <vfs/vfs.h> 36 36 #include <vfs/canonify.h> 37 #include <macros.h> 37 38 #include <stdlib.h> 38 39 #include <unistd.h> … … 434 435 } 435 436 436 off _t lseek(int fildes, off_t offset, int whence)437 { 438 ipcarg_t rc;439 440 futex_down(&vfs_phone_futex);441 async_serialize_start();442 vfs_connect();443 444 ipcarg_t newoffs;445 rc = async_req_3_1(vfs_phone, VFS_IN_SEEK, fildes, offset, whence,446 &newoff s);447 448 async_serialize_end(); 449 futex_up(&vfs_phone_futex); 450 437 off64_t lseek(int fildes, off64_t offset, int whence) 438 { 439 futex_down(&vfs_phone_futex); 440 async_serialize_start(); 441 vfs_connect(); 442 443 ipcarg_t newoff_lo; 444 ipcarg_t newoff_hi; 445 ipcarg_t rc = async_req_4_2(vfs_phone, VFS_IN_SEEK, fildes, 446 LOWER32(offset), UPPER32(offset), whence, 447 &newoff_lo, &newoff_hi); 448 449 async_serialize_end(); 450 futex_up(&vfs_phone_futex); 451 451 452 if (rc != EOK) 452 return (off_t) -1; 453 454 return (off_t) newoffs; 455 } 456 457 int ftruncate(int fildes, off_t length) 458 { 459 ipcarg_t rc; 460 461 futex_down(&vfs_phone_futex); 462 async_serialize_start(); 463 vfs_connect(); 464 465 rc = async_req_2_0(vfs_phone, VFS_IN_TRUNCATE, fildes, length); 466 async_serialize_end(); 467 futex_up(&vfs_phone_futex); 453 return (off64_t) -1; 454 455 return (off64_t) MERGE_LOUP32(newoff_lo, newoff_hi); 456 } 457 458 int ftruncate(int fildes, aoff64_t length) 459 { 460 ipcarg_t rc; 461 462 futex_down(&vfs_phone_futex); 463 async_serialize_start(); 464 vfs_connect(); 465 466 rc = async_req_3_0(vfs_phone, VFS_IN_TRUNCATE, fildes, 467 LOWER32(length), UPPER32(length)); 468 async_serialize_end(); 469 futex_up(&vfs_phone_futex); 470 468 471 return (int) rc; 469 472 } … … 479 482 480 483 req = async_send_1(vfs_phone, VFS_IN_FSTAT, fildes, NULL); 481 rc = async_data_read_start(vfs_phone, (void *) stat, sizeof(struct stat));484 rc = async_data_read_start(vfs_phone, (void *) stat, sizeof(struct stat)); 482 485 if (rc != EOK) { 483 486 ipcarg_t rc_orig; … … 553 556 if (!abs) { 554 557 free(dirp); 555 return ENOMEM;558 return NULL; 556 559 } 557 560 -
uspace/lib/libc/include/limits.h
rb32c604f red903174 46 46 47 47 #ifdef __CHAR_UNSIGNED__ 48 #define CHAR_MIN UCHAR_MIN49 #define CHAR_MAX UCHAR_MAX48 #define CHAR_MIN UCHAR_MIN 49 #define CHAR_MAX UCHAR_MAX 50 50 #else 51 #define CHAR_MIN SCHAR_MIN52 #define CHAR_MAX SCHAR_MAX51 #define CHAR_MIN SCHAR_MIN 52 #define CHAR_MAX SCHAR_MAX 53 53 #endif 54 54 … … 59 59 #define USHRT_MAX MAX_UINT16 60 60 61 /* int */ 61 62 #define INT_MIN MIN_INT32 62 63 #define INT_MAX MAX_INT32 … … 64 65 #define UINT_MAX MAX_UINT32 65 66 67 /* long long int */ 66 68 #define LLONG_MIN MIN_INT64 67 69 #define LLONG_MAX MAX_INT64 … … 69 71 #define ULLONG_MAX MAX_UINT64 70 72 73 /* off64_t */ 74 #define OFF64_MIN MIN_INT64 75 #define OFF64_MAX MAX_INT64 76 77 /* aoff64_t */ 78 #define AOFF64_MIN MIN_UINT64 79 #define AOFF64_MAX MAX_UINT64 80 71 81 #endif 72 82 -
uspace/lib/libc/include/stdio.h
rb32c604f red903174 46 46 #define BUFSIZ 4096 47 47 48 #define DEBUG(fmt, ...) \48 #define DEBUG(fmt, ...)se\ 49 49 { \ 50 50 char _buf[256]; \ … … 56 56 #ifndef SEEK_SET 57 57 #define SEEK_SET 0 58 #endif 59 60 #ifndef SEEK_CUR 58 61 #define SEEK_CUR 1 62 #endif 63 64 #ifndef SEEK_END 59 65 #define SEEK_END 2 60 66 #endif … … 135 141 extern size_t fwrite(const void *, size_t, size_t, FILE *); 136 142 137 extern int fseek(FILE *, long, int);143 extern int fseek(FILE *, off64_t, int); 138 144 extern void rewind(FILE *); 139 extern int ftell(FILE *);145 extern off64_t ftell(FILE *); 140 146 extern int feof(FILE *); 141 147 -
uspace/lib/libc/include/sys/mman.h
rb32c604f red903174 41 41 #define MAP_FAILED ((void *) -1) 42 42 43 #define MAP_SHARED (1 << 0)44 #define MAP_PRIVATE (1 << 1)45 #define MAP_FIXED (1 << 2)46 #define MAP_ANONYMOUS (1 << 3)43 #define MAP_SHARED (1 << 0) 44 #define MAP_PRIVATE (1 << 1) 45 #define MAP_FIXED (1 << 2) 46 #define MAP_ANONYMOUS (1 << 3) 47 47 48 48 #define PROTO_READ AS_AREA_READ … … 50 50 #define PROTO_EXEC AS_AREA_EXEC 51 51 52 extern void *mmap(void *start, size_t length, int prot, int flags, int fd,53 off_t offset);52 extern void *mmap(void *start, size_t length, int prot, int flags, int fd, 53 aoff64_t offset); 54 54 extern int munmap(void *start, size_t length); 55 55 -
uspace/lib/libc/include/sys/stat.h
rb32c604f red903174 31 31 */ 32 32 /** @file 33 */ 33 */ 34 34 35 35 #ifndef LIBC_SYS_STAT_H_ … … 48 48 bool is_file; 49 49 bool is_directory; 50 off_t size;50 aoff64_t size; 51 51 dev_handle_t device; 52 52 }; -
uspace/lib/libc/include/sys/typefmt.h
rb32c604f red903174 39 39 #include <inttypes.h> 40 40 41 /* off_t */ 42 #define PRIdOFF "ld" 43 #define PRIuOFF "lu" 44 #define PRIxOFF "lx" 45 #define PRIXOFF "lX" 46 47 /* bn_t */ 48 #define PRIdBN PRId64 49 #define PRIuBN PRIu64 50 #define PRIxBN PRIx64 51 #define PRIXBN PRIX64 41 /* off64_t */ 42 #define PRIdOFF64 PRId64 43 #define PRIuOFF64 PRIu64 44 #define PRIxOFF64 PRIx64 45 #define PRIXOFF64 PRIX64 52 46 53 47 /* (s)size_t */ -
uspace/lib/libc/include/sys/types.h
rb32c604f red903174 38 38 #include <libarch/types.h> 39 39 40 typedef long off_t; 41 typedef int mode_t; 42 typedef uint64_t bn_t; /**< Block number type. */ 40 typedef unsigned int mode_t; 43 41 42 /** Relative offset */ 43 typedef int64_t off64_t; 44 45 /** Absolute offset */ 46 typedef uint64_t aoff64_t; 47 48 /** Unicode code point */ 44 49 typedef int32_t wchar_t; 45 50 -
uspace/lib/libc/include/unistd.h
rb32c604f red903174 47 47 #ifndef SEEK_SET 48 48 #define SEEK_SET 0 49 #endif 50 51 #ifndef SEEK_CUR 49 52 #define SEEK_CUR 1 53 #endif 54 55 #ifndef SEEK_END 50 56 #define SEEK_END 2 51 57 #endif … … 58 64 extern ssize_t read(int, void *, size_t); 59 65 60 extern off _t lseek(int, off_t, int);61 extern int ftruncate(int, off_t);66 extern off64_t lseek(int, off64_t, int); 67 extern int ftruncate(int, aoff64_t); 62 68 63 69 extern int close(int); … … 69 75 extern int chdir(const char *); 70 76 71 extern void _exit(int status) __attribute__((noreturn));72 extern int usleep(useconds_t uses);73 extern unsigned int sleep(unsigned int se);77 extern void _exit(int) __attribute__((noreturn)); 78 extern int usleep(useconds_t); 79 extern unsigned int sleep(unsigned int); 74 80 75 81 #endif -
uspace/lib/libfs/libfs.c
rb32c604f red903174 37 37 #include "libfs.h" 38 38 #include "../../srv/vfs/vfs.h" 39 #include <macros.h> 39 40 #include <errno.h> 40 41 #include <async.h> … … 398 399 ipc_answer_0(rid, rc); 399 400 } else { 400 ipc_answer_5(rid, EOK, 401 fs_handle, dev_handle, 401 aoff64_t size = ops->size_get(fn); 402 ipc_answer_5(rid, fs_handle, 403 dev_handle, 402 404 ops->index_get(fn), 403 ops->size_get(fn), 405 LOWER32(size), 406 UPPER32(size), 404 407 ops->lnkcnt_get(fn)); 405 408 (void) ops->node_put(fn); … … 478 481 ipc_answer_0(rid, rc); 479 482 } else { 480 ipc_answer_5(rid, EOK, 481 fs_handle, dev_handle, 483 aoff64_t size = ops->size_get(fn); 484 ipc_answer_5(rid, fs_handle, 485 dev_handle, 482 486 ops->index_get(fn), 483 ops->size_get(fn), 487 LOWER32(size), 488 UPPER32(size), 484 489 ops->lnkcnt_get(fn)); 485 490 (void) ops->node_put(fn); … … 501 506 unsigned int old_lnkcnt = ops->lnkcnt_get(cur); 502 507 rc = ops->unlink(par, cur, component); 503 ipc_answer_5(rid, (ipcarg_t) rc, fs_handle, dev_handle, 504 ops->index_get(cur), ops->size_get(cur), old_lnkcnt); 508 509 if (rc == EOK) { 510 aoff64_t size = ops->size_get(cur); 511 ipc_answer_5(rid, fs_handle, dev_handle, 512 ops->index_get(cur), LOWER32(size), UPPER32(size), 513 old_lnkcnt); 514 } else 515 ipc_answer_0(rid, rc); 516 505 517 goto out; 506 518 } … … 533 545 rc = ops->node_open(cur); 534 546 535 ipc_answer_5(rid, rc, fs_handle, dev_handle, 536 ops->index_get(cur), ops->size_get(cur), 537 ops->lnkcnt_get(cur)); 547 if (rc == EOK) { 548 aoff64_t size = ops->size_get(cur); 549 ipc_answer_5(rid, fs_handle, dev_handle, 550 ops->index_get(cur), LOWER32(size), UPPER32(size), 551 ops->lnkcnt_get(cur)); 552 } else 553 ipc_answer_0(rid, rc); 554 538 555 } else 539 556 ipc_answer_0(rid, rc); … … 602 619 dev_handle_t dev_handle = IPC_GET_ARG1(*request); 603 620 fs_index_t index = IPC_GET_ARG2(*request); 621 604 622 fs_node_t *fn; 605 int rc; 606 607 rc = ops->node_get(&fn, dev_handle, index); 623 int rc = ops->node_get(&fn, dev_handle, index); 608 624 on_error(rc, answer_and_return(rid, rc)); 609 625 … … 614 630 615 631 rc = ops->node_open(fn); 616 ipc_answer_3(rid, rc, ops->size_get(fn), ops->lnkcnt_get(fn), 632 aoff64_t size = ops->size_get(fn); 633 ipc_answer_4(rid, rc, LOWER32(size), UPPER32(size), ops->lnkcnt_get(fn), 617 634 (ops->is_file(fn) ? L_FILE : 0) | (ops->is_directory(fn) ? L_DIRECTORY : 0)); 618 635 -
uspace/lib/libfs/libfs.h
rb32c604f red903174 76 76 */ 77 77 fs_index_t (* index_get)(fs_node_t *); 78 size_t (* size_get)(fs_node_t *);78 aoff64_t (* size_get)(fs_node_t *); 79 79 unsigned int (* lnkcnt_get)(fs_node_t *); 80 80 char (* plb_get_char)(unsigned pos);
Note:
See TracChangeset
for help on using the changeset viewer.
