Changeset ed903174 in mainline for uspace/srv
- Timestamp:
- 2010-02-10T23:51:23Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e70edd1
- Parents:
- b32c604f
- Location:
- uspace/srv
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/bd/file_bd/file_bd.c
rb32c604f red903174 57 57 58 58 static const size_t block_size = 512; 59 static bn_t num_blocks;59 static aoff64_t num_blocks; 60 60 static FILE *img; 61 61 … … 210 210 /* Check whether access is within device address bounds. */ 211 211 if (ba + cnt > num_blocks) { 212 printf(NAME ": Accessed blocks %" PRIu BN "-%" PRIuBN", while "213 "max block number is %" PRIu BN".\n", ba, ba + cnt - 1,212 printf(NAME ": Accessed blocks %" PRIuOFF64 "-%" PRIuOFF64 ", while " 213 "max block number is %" PRIuOFF64 ".\n", ba, ba + cnt - 1, 214 214 num_blocks - 1); 215 215 return ELIMIT; … … 248 248 /* Check whether access is within device address bounds. */ 249 249 if (ba + cnt > num_blocks) { 250 printf(NAME ": Accessed blocks %" PRIu BN "-%" PRIuBN", while "251 "max block number is %" PRIu BN".\n", ba, ba + cnt - 1,250 printf(NAME ": Accessed blocks %" PRIuOFF64 "-%" PRIuOFF64 ", while " 251 "max block number is %" PRIuOFF64 ".\n", ba, ba + cnt - 1, 252 252 num_blocks - 1); 253 253 return ELIMIT; -
uspace/srv/bd/part/guid_part/guid_part.c
rb32c604f red903174 79 79 bool present; 80 80 /** Address of first block */ 81 bn_t start_addr;81 aoff64_t start_addr; 82 82 /** Number of blocks */ 83 bn_t length;83 aoff64_t length; 84 84 /** Device representing the partition (outbound device) */ 85 85 dev_handle_t dev; … … 101 101 static void gpt_pte_to_part(const gpt_entry_t *pte, part_t *part); 102 102 static void gpt_connection(ipc_callid_t iid, ipc_call_t *icall); 103 static int gpt_bd_read(part_t *p, bn_t ba, size_t cnt, void *buf);104 static int gpt_bd_write(part_t *p, bn_t ba, size_t cnt, const void *buf);105 static int gpt_bsa_translate(part_t *p, bn_t ba, size_t cnt, bn_t *gba);103 static int gpt_bd_read(part_t *p, aoff64_t ba, size_t cnt, void *buf); 104 static int gpt_bd_write(part_t *p, aoff64_t ba, size_t cnt, const void *buf); 105 static int gpt_bsa_translate(part_t *p, aoff64_t ba, size_t cnt, aoff64_t *gba); 106 106 107 107 int main(int argc, char **argv) … … 199 199 / (1024 * 1024); 200 200 printf(NAME ": Registered device %s: %" PRIu64 " blocks " 201 "%" PRIu BN" MB.\n", name, part->length, size_mb);201 "%" PRIuOFF64 " MB.\n", name, part->length, size_mb); 202 202 203 203 part->dev = dev; … … 319 319 int flags; 320 320 int retval; 321 bn_t ba;321 aoff64_t ba; 322 322 size_t cnt; 323 323 part_t *part; … … 402 402 403 403 /** Read blocks from partition. */ 404 static int gpt_bd_read(part_t *p, bn_t ba, size_t cnt, void *buf)405 { 406 bn_t gba;404 static int gpt_bd_read(part_t *p, aoff64_t ba, size_t cnt, void *buf) 405 { 406 aoff64_t gba; 407 407 408 408 if (gpt_bsa_translate(p, ba, cnt, &gba) != EOK) … … 413 413 414 414 /** Write blocks to partition. */ 415 static int gpt_bd_write(part_t *p, bn_t ba, size_t cnt, const void *buf)416 { 417 bn_t gba;415 static int gpt_bd_write(part_t *p, aoff64_t ba, size_t cnt, const void *buf) 416 { 417 aoff64_t gba; 418 418 419 419 if (gpt_bsa_translate(p, ba, cnt, &gba) != EOK) … … 424 424 425 425 /** Translate block segment address with range checking. */ 426 static int gpt_bsa_translate(part_t *p, bn_t ba, size_t cnt, bn_t *gba)426 static int gpt_bsa_translate(part_t *p, aoff64_t ba, size_t cnt, aoff64_t *gba) 427 427 { 428 428 if (ba + cnt > p->length) -
uspace/srv/bd/part/mbr_part/mbr_part.c
rb32c604f red903174 97 97 bool present; 98 98 /** Address of first block */ 99 bn_t start_addr;99 aoff64_t start_addr; 100 100 /** Number of blocks */ 101 bn_t length;101 aoff64_t length; 102 102 /** Device representing the partition (outbound device) */ 103 103 dev_handle_t dev; … … 249 249 size_mb = (part->length * block_size + 1024 * 1024 - 1) 250 250 / (1024 * 1024); 251 printf(NAME ": Registered device %s: %" PRIu BN" blocks "251 printf(NAME ": Registered device %s: %" PRIuOFF64 " blocks " 252 252 "%" PRIu64 " MB.\n", name, part->length, size_mb); 253 253 -
uspace/srv/clip/clip.c
rb32c604f red903174 145 145 146 146 fibril_mutex_unlock(&clip_mtx); 147 ipc_answer_2(rid, EOK, (ipcarg_t) size, (ipcarg_t) clip_tag);147 ipc_answer_2(rid, EOK, (ipcarg_t) size, (ipcarg_t) tag); 148 148 } 149 149 -
uspace/srv/fs/devfs/devfs_ops.c
rb32c604f red903174 37 37 38 38 #include <ipc/ipc.h> 39 #include <macros.h> 39 40 #include <bool.h> 40 41 #include <errno.h> … … 337 338 } 338 339 339 static size_t devfs_size_get(fs_node_t *fn)340 static aoff64_t devfs_size_get(fs_node_t *fn) 340 341 { 341 342 return 0; … … 463 464 { 464 465 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request); 465 off_t pos = (off_t) IPC_GET_ARG3(*request); 466 aoff64_t pos = 467 (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request), IPC_GET_ARG4(*request)); 466 468 467 469 if (index == 0) { … … 597 599 { 598 600 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request); 599 off_t pos = (off_t) IPC_GET_ARG3(*request);600 601 601 if (index == 0) { 602 602 ipc_answer_0(rid, ENOTSUP); -
uspace/srv/fs/fat/fat.h
rb32c604f red903174 89 89 uint16_t signature; 90 90 } __attribute__ ((packed)); 91 struct fat32{91 struct { 92 92 /* FAT32 only */ 93 93 /** Sectors per FAT. */ … … 119 119 /** Signature. */ 120 120 uint16_t signature; 121 } __attribute__ ((packed));122 }; 121 } fat32 __attribute__ ((packed)); 122 }; 123 123 } __attribute__ ((packed)) fat_bs_t; 124 124 … … 194 194 /** FAT in-core node free list link. */ 195 195 link_t ffn_link; 196 size_tsize;196 aoff64_t size; 197 197 unsigned lnkcnt; 198 198 unsigned refcnt; -
uspace/srv/fs/fat/fat_dentry.c
rb32c604f red903174 82 82 bool fat_dentry_name_verify(const char *name) 83 83 { 84 unsigned i, dot; 84 unsigned int i; 85 unsigned int dot = 0; 85 86 bool dot_found = false; 86 87 -
uspace/srv/fs/fat/fat_fat.c
rb32c604f red903174 93 93 94 94 while (clst < FAT_CLST_LAST1 && clusters < max_clusters) { 95 bn_t fsec; /* sector offset relative to FAT1 */95 aoff64_t fsec; /* sector offset relative to FAT1 */ 96 96 unsigned fidx; /* FAT1 entry index */ 97 97 … … 135 135 int 136 136 _fat_block_get(block_t **block, fat_bs_t *bs, dev_handle_t dev_handle, 137 fat_cluster_t firstc, bn_t bn, int flags)137 fat_cluster_t firstc, aoff64_t bn, int flags) 138 138 { 139 139 unsigned bps; … … 196 196 * @return EOK on success or a negative error code. 197 197 */ 198 int fat_fill_gap(fat_bs_t *bs, fat_node_t *nodep, fat_cluster_t mcl, off_t pos)198 int fat_fill_gap(fat_bs_t *bs, fat_node_t *nodep, fat_cluster_t mcl, aoff64_t pos) 199 199 { 200 200 uint16_t bps; 201 201 unsigned spc; 202 202 block_t *b; 203 off_t o, boundary;203 aoff64_t o, boundary; 204 204 int rc; 205 205 -
uspace/srv/fs/fat/fat_fat.h
rb32c604f red903174 69 69 70 70 extern int _fat_block_get(block_t **, struct fat_bs *, dev_handle_t, 71 fat_cluster_t, bn_t, int);72 71 fat_cluster_t, aoff64_t, int); 72 73 73 extern int fat_append_clusters(struct fat_bs *, struct fat_node *, 74 74 fat_cluster_t); … … 85 85 fat_cluster_t, fat_cluster_t); 86 86 extern int fat_fill_gap(struct fat_bs *, struct fat_node *, fat_cluster_t, 87 off_t);87 aoff64_t); 88 88 extern int fat_zero_cluster(struct fat_bs *, dev_handle_t, fat_cluster_t); 89 89 extern int fat_sanity_check(struct fat_bs *, dev_handle_t); -
uspace/srv/fs/fat/fat_ops.c
rb32c604f red903174 45 45 #include <ipc/services.h> 46 46 #include <ipc/devmap.h> 47 #include <macros.h> 47 48 #include <async.h> 48 49 #include <errno.h> … … 79 80 static int fat_has_children(bool *, fs_node_t *); 80 81 static fs_index_t fat_index_get(fs_node_t *); 81 static size_t fat_size_get(fs_node_t *);82 static aoff64_t fat_size_get(fs_node_t *); 82 83 static unsigned fat_lnkcnt_get(fs_node_t *); 83 84 static char fat_plb_get_char(unsigned); … … 738 739 goto skip_dots; 739 740 } 740 d = (fat_dentry_t *) b->data;741 if ( fat_classify_dentry(d) == FAT_DENTRY_LAST||742 str_cmp(d->name, FAT_NAME_DOT) == 0) {741 d = (fat_dentry_t *) b->data; 742 if ((fat_classify_dentry(d) == FAT_DENTRY_LAST) || 743 (str_cmp((char *) d->name, FAT_NAME_DOT)) == 0) { 743 744 memset(d, 0, sizeof(fat_dentry_t)); 744 str_cpy( d->name, 8, FAT_NAME_DOT);745 str_cpy( d->ext, 3, FAT_EXT_PAD);745 str_cpy((char *) d->name, 8, FAT_NAME_DOT); 746 str_cpy((char *) d->ext, 3, FAT_EXT_PAD); 746 747 d->attr = FAT_ATTR_SUBDIR; 747 748 d->firstc = host2uint16_t_le(childp->firstc); … … 749 750 } 750 751 d++; 751 if ( fat_classify_dentry(d) == FAT_DENTRY_LAST||752 str_cmp(d->name, FAT_NAME_DOT_DOT) == 0) {752 if ((fat_classify_dentry(d) == FAT_DENTRY_LAST) || 753 (str_cmp((char *) d->name, FAT_NAME_DOT_DOT) == 0)) { 753 754 memset(d, 0, sizeof(fat_dentry_t)); 754 str_cpy( d->name, 8, FAT_NAME_DOT_DOT);755 str_cpy( d->ext, 3, FAT_EXT_PAD);755 str_cpy((char *) d->name, 8, FAT_NAME_DOT_DOT); 756 str_cpy((char *) d->ext, 3, FAT_EXT_PAD); 756 757 d->attr = FAT_ATTR_SUBDIR; 757 758 d->firstc = (parentp->firstc == FAT_CLST_ROOT) ? … … 915 916 } 916 917 917 size_t fat_size_get(fs_node_t *fn)918 aoff64_t fat_size_get(fs_node_t *fn) 918 919 { 919 920 return FAT_NODE(fn)->size; … … 1157 1158 void fat_read(ipc_callid_t rid, ipc_call_t *request) 1158 1159 { 1159 dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request); 1160 fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request); 1161 off_t pos = (off_t)IPC_GET_ARG3(*request); 1160 dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request); 1161 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request); 1162 aoff64_t pos = 1163 (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request), IPC_GET_ARG4(*request)); 1162 1164 fs_node_t *fn; 1163 1165 fat_node_t *nodep; … … 1223 1225 } else { 1224 1226 unsigned bnum; 1225 off_t spos = pos;1227 aoff64_t spos = pos; 1226 1228 char name[FAT_NAME_LEN + 1 + FAT_EXT_LEN + 1]; 1227 1229 fat_dentry_t *d; … … 1239 1241 bnum = (pos * sizeof(fat_dentry_t)) / bps; 1240 1242 while (bnum < nodep->size / bps) { 1241 off_t o;1243 aoff64_t o; 1242 1244 1243 1245 rc = fat_block_get(&b, bs, nodep, bnum, … … 1295 1297 void fat_write(ipc_callid_t rid, ipc_call_t *request) 1296 1298 { 1297 dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request); 1298 fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request); 1299 off_t pos = (off_t)IPC_GET_ARG3(*request); 1299 dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request); 1300 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request); 1301 aoff64_t pos = 1302 (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request), IPC_GET_ARG4(*request)); 1300 1303 fs_node_t *fn; 1301 1304 fat_node_t *nodep; … … 1306 1309 unsigned spc; 1307 1310 unsigned bpc; /* bytes per cluster */ 1308 off_t boundary;1311 aoff64_t boundary; 1309 1312 int flags = BLOCK_FLAGS_NONE; 1310 1313 int rc; … … 1452 1455 void fat_truncate(ipc_callid_t rid, ipc_call_t *request) 1453 1456 { 1454 dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request); 1455 fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request); 1456 size_t size = (off_t)IPC_GET_ARG3(*request); 1457 dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request); 1458 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request); 1459 aoff64_t size = 1460 (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request), IPC_GET_ARG4(*request)); 1457 1461 fs_node_t *fn; 1458 1462 fat_node_t *nodep; -
uspace/srv/fs/tmpfs/tmpfs.h
rb32c604f red903174 29 29 /** @addtogroup fs 30 30 * @{ 31 */ 31 */ 32 32 33 33 #ifndef TMPFS_TMPFS_H_ … … 40 40 #include <bool.h> 41 41 #include <adt/hash_table.h> 42 43 #ifndef dprintf44 #define dprintf(...) printf(__VA_ARGS__)45 #endif46 42 47 43 #define TMPFS_NODE(node) ((node) ? (tmpfs_node_t *)(node)->data : NULL) -
uspace/srv/fs/tmpfs/tmpfs_dump.c
rb32c604f red903174 55 55 56 56 static bool 57 tmpfs_restore_recursion(dev_handle_t dev, off_t *bufpos, size_t *buflen,58 off_t *pos, fs_node_t *pfn)57 tmpfs_restore_recursion(dev_handle_t dev, size_t *bufpos, size_t *buflen, 58 aoff64_t *pos, fs_node_t *pfn) 59 59 { 60 60 struct rdentry entry; … … 171 171 return false; 172 172 173 off_t bufpos = 0;173 size_t bufpos = 0; 174 174 size_t buflen = 0; 175 off_t pos = 0;175 aoff64_t pos = 0; 176 176 177 177 char tag[6]; -
uspace/srv/fs/tmpfs/tmpfs_ops.c
rb32c604f red903174 29 29 /** @addtogroup fs 30 30 * @{ 31 */ 31 */ 32 32 33 33 /** … … 40 40 #include "../../vfs/vfs.h" 41 41 #include <ipc/ipc.h> 42 #include <macros.h> 43 #include <limits.h> 42 44 #include <async.h> 43 45 #include <errno.h> … … 93 95 } 94 96 95 static size_t tmpfs_size_get(fs_node_t *fn)97 static aoff64_t tmpfs_size_get(fs_node_t *fn) 96 98 { 97 99 return TMPFS_NODE(fn)->size; … … 509 511 void tmpfs_read(ipc_callid_t rid, ipc_call_t *request) 510 512 { 511 dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request); 512 fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request); 513 off_t pos = (off_t)IPC_GET_ARG3(*request); 514 513 dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request); 514 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request); 515 aoff64_t pos = 516 (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request), IPC_GET_ARG4(*request)); 517 515 518 /* 516 519 * Lookup the respective TMPFS node. … … 528 531 tmpfs_node_t *nodep = hash_table_get_instance(hlp, tmpfs_node_t, 529 532 nh_link); 530 533 531 534 /* 532 535 * Receive the read request. … … 535 538 size_t size; 536 539 if (!async_data_read_receive(&callid, &size)) { 537 ipc_answer_0(callid, EINVAL); 540 ipc_answer_0(callid, EINVAL); 538 541 ipc_answer_0(rid, EINVAL); 539 542 return; … … 542 545 size_t bytes; 543 546 if (nodep->type == TMPFS_FILE) { 544 bytes = m ax(0, min(nodep->size - pos, size));547 bytes = min(nodep->size - pos, size); 545 548 (void) async_data_read_finalize(callid, nodep->data + pos, 546 549 bytes); … … 548 551 tmpfs_dentry_t *dentryp; 549 552 link_t *lnk; 550 int i;553 aoff64_t i; 551 554 552 555 assert(nodep->type == TMPFS_DIRECTORY); … … 558 561 */ 559 562 for (i = 0, lnk = nodep->cs_head.next; 560 i < pos && lnk != &nodep->cs_head;563 (i < pos) && (lnk != &nodep->cs_head); 561 564 i++, lnk = lnk->next) 562 565 ; … … 583 586 void tmpfs_write(ipc_callid_t rid, ipc_call_t *request) 584 587 { 585 dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request); 586 fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request); 587 off_t pos = (off_t)IPC_GET_ARG3(*request); 588 588 dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request); 589 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request); 590 aoff64_t pos = 591 (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request), IPC_GET_ARG4(*request)); 592 589 593 /* 590 594 * Lookup the respective TMPFS node. … … 647 651 void tmpfs_truncate(ipc_callid_t rid, ipc_call_t *request) 648 652 { 653 dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request); 654 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request); 655 aoff64_t size = 656 (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request), IPC_GET_ARG4(*request)); 657 658 /* 659 * Lookup the respective TMPFS node. 660 */ 661 unsigned long key[] = { 662 [NODES_KEY_DEV] = dev_handle, 663 [NODES_KEY_INDEX] = index 664 }; 665 link_t *hlp = hash_table_find(&nodes, key); 666 if (!hlp) { 667 ipc_answer_0(rid, ENOENT); 668 return; 669 } 670 tmpfs_node_t *nodep = hash_table_get_instance(hlp, tmpfs_node_t, 671 nh_link); 672 673 if (size == nodep->size) { 674 ipc_answer_0(rid, EOK); 675 return; 676 } 677 678 if (size > SIZE_MAX) { 679 ipc_answer_0(rid, ENOMEM); 680 return; 681 } 682 683 void *newdata = realloc(nodep->data, size); 684 if (!newdata) { 685 ipc_answer_0(rid, ENOMEM); 686 return; 687 } 688 689 if (size > nodep->size) { 690 size_t delta = size - nodep->size; 691 memset(newdata + nodep->size, 0, delta); 692 } 693 694 nodep->size = size; 695 nodep->data = newdata; 696 ipc_answer_0(rid, EOK); 697 } 698 699 void tmpfs_close(ipc_callid_t rid, ipc_call_t *request) 700 { 701 ipc_answer_0(rid, EOK); 702 } 703 704 void tmpfs_destroy(ipc_callid_t rid, ipc_call_t *request) 705 { 649 706 dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request); 650 707 fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request); 651 size_t size = (off_t)IPC_GET_ARG3(*request); 652 653 /* 654 * Lookup the respective TMPFS node. 655 */ 708 int rc; 709 656 710 link_t *hlp; 657 711 unsigned long key[] = { … … 666 720 tmpfs_node_t *nodep = hash_table_get_instance(hlp, tmpfs_node_t, 667 721 nh_link); 668 669 if (size == nodep->size) {670 ipc_answer_0(rid, EOK);671 return;672 }673 674 void *newdata = realloc(nodep->data, size);675 if (!newdata) {676 ipc_answer_0(rid, ENOMEM);677 return;678 }679 if (size > nodep->size) {680 size_t delta = size - nodep->size;681 memset(newdata + nodep->size, 0, delta);682 }683 nodep->size = size;684 nodep->data = newdata;685 ipc_answer_0(rid, EOK);686 }687 688 void tmpfs_close(ipc_callid_t rid, ipc_call_t *request)689 {690 ipc_answer_0(rid, EOK);691 }692 693 void tmpfs_destroy(ipc_callid_t rid, ipc_call_t *request)694 {695 dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request);696 fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);697 int rc;698 699 link_t *hlp;700 unsigned long key[] = {701 [NODES_KEY_DEV] = dev_handle,702 [NODES_KEY_INDEX] = index703 };704 hlp = hash_table_find(&nodes, key);705 if (!hlp) {706 ipc_answer_0(rid, ENOENT);707 return;708 }709 tmpfs_node_t *nodep = hash_table_get_instance(hlp, tmpfs_node_t,710 nh_link);711 722 rc = tmpfs_destroy_node(FS_NODE(nodep)); 712 723 ipc_answer_0(rid, rc); -
uspace/srv/vfs/vfs.h
rb32c604f red903174 42 42 #include <ipc/vfs.h> 43 43 44 // FIXME: according to CONFIG_DEBUG 45 // #define dprintf(...) printf(__VA_ARGS__) 46 47 #define dprintf(...) 44 #ifndef dprintf 45 #define dprintf(...) 46 #endif 48 47 49 48 /** … … 93 92 vfs_triplet_t triplet; 94 93 vfs_node_type_t type; 95 size_t size;96 unsigned lnkcnt;94 aoff64_t size; 95 unsigned int lnkcnt; 97 96 } vfs_lookup_res_t; 98 97 … … 117 116 vfs_node_type_t type; /**< Partial info about the node type. */ 118 117 119 size_t size; /**< Cached size if the node is a file. */118 aoff64_t size; /**< Cached size if the node is a file. */ 120 119 121 120 /** … … 141 140 bool append; 142 141 143 /** Current position in the file. */144 off_t pos;142 /** Current absolute position in the file. */ 143 aoff64_t pos; 145 144 } vfs_file_t; 146 145 … … 214 213 extern void vfs_truncate(ipc_callid_t, ipc_call_t *); 215 214 extern void vfs_fstat(ipc_callid_t, ipc_call_t *); 216 extern void vfs_fstat(ipc_callid_t, ipc_call_t *);217 215 extern void vfs_stat(ipc_callid_t, ipc_call_t *); 218 216 extern void vfs_mkdir(ipc_callid_t, ipc_call_t *); -
uspace/srv/vfs/vfs_lookup.c
rb32c604f red903174 38 38 #include "vfs.h" 39 39 #include <ipc/ipc.h> 40 #include <macros.h> 40 41 #include <async.h> 41 42 #include <errno.h> … … 99 100 entry.len = len; 100 101 101 off_t first; /* the first free index */102 off_t last; /* the last free index */102 size_t first; /* the first free index */ 103 size_t last; /* the last free index */ 103 104 104 105 if (list_empty(&plb_head)) { … … 177 178 memset(plb, 0, cnt2); 178 179 fibril_mutex_unlock(&plb_mutex); 179 180 if ((rc == EOK) && (result)) { 181 result->triplet.fs_handle = (fs_handle_t) IPC_GET_ARG1(answer); 182 result->triplet.dev_handle = (dev_handle_t) IPC_GET_ARG2(answer); 183 result->triplet.index = (fs_index_t) IPC_GET_ARG3(answer); 184 result->size = (size_t) IPC_GET_ARG4(answer); 185 result->lnkcnt = (unsigned) IPC_GET_ARG5(answer); 186 if (lflag & L_FILE) 187 result->type = VFS_NODE_FILE; 188 else if (lflag & L_DIRECTORY) 189 result->type = VFS_NODE_DIRECTORY; 190 else 191 result->type = VFS_NODE_UNKNOWN; 192 } 193 194 return rc; 180 181 if (((int) rc < EOK) || (!result)) 182 return (int) rc; 183 184 result->triplet.fs_handle = (fs_handle_t) rc; 185 result->triplet.dev_handle = (dev_handle_t) IPC_GET_ARG1(answer); 186 result->triplet.index = (fs_index_t) IPC_GET_ARG2(answer); 187 result->size = 188 (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(answer), IPC_GET_ARG4(answer)); 189 result->lnkcnt = (unsigned int) IPC_GET_ARG5(answer); 190 191 if (lflag & L_FILE) 192 result->type = VFS_NODE_FILE; 193 else if (lflag & L_DIRECTORY) 194 result->type = VFS_NODE_DIRECTORY; 195 else 196 result->type = VFS_NODE_UNKNOWN; 197 198 return EOK; 195 199 } 196 200 … … 214 218 215 219 if (rc == EOK) { 216 result->size = (size_t) IPC_GET_ARG1(answer); 217 result->lnkcnt = (unsigned) IPC_GET_ARG2(answer); 218 if (IPC_GET_ARG3(answer) & L_FILE) 220 result->size = 221 MERGE_LOUP32(IPC_GET_ARG1(answer), IPC_GET_ARG2(answer)); 222 result->lnkcnt = (unsigned int) IPC_GET_ARG3(answer); 223 if (IPC_GET_ARG4(answer) & L_FILE) 219 224 result->type = VFS_NODE_FILE; 220 else if (IPC_GET_ARG 3(answer) & L_DIRECTORY)225 else if (IPC_GET_ARG4(answer) & L_DIRECTORY) 221 226 result->type = VFS_NODE_DIRECTORY; 222 227 else -
uspace/srv/vfs/vfs_node.c
rb32c604f red903174 242 242 { 243 243 vfs_node_t *node = hash_table_get_instance(item, vfs_node_t, nh_link); 244 return (node->fs_handle == key[KEY_FS_HANDLE]) &&244 return (node->fs_handle == (fs_handle_t) key[KEY_FS_HANDLE]) && 245 245 (node->dev_handle == key[KEY_DEV_HANDLE]) && 246 246 (node->index == key[KEY_INDEX]); -
uspace/srv/vfs/vfs_ops.c
rb32c604f red903174 38 38 #include "vfs.h" 39 39 #include <ipc/ipc.h> 40 #include <macros.h> 41 #include <limits.h> 40 42 #include <async.h> 41 43 #include <errno.h> … … 53 55 54 56 /* Forward declarations of static functions. */ 55 static int vfs_truncate_internal(fs_handle_t, dev_handle_t, fs_index_t, size_t);57 static int vfs_truncate_internal(fs_handle_t, dev_handle_t, fs_index_t, aoff64_t); 56 58 57 59 /** … … 353 355 vfs_lookup_res_t mp_res; 354 356 vfs_lookup_res_t mr_res; 355 vfs_node_t *mp_node;356 357 vfs_node_t *mr_node; 357 358 int phone; … … 503 504 int oflag = IPC_GET_ARG2(*request); 504 505 int mode = IPC_GET_ARG3(*request); 505 size_t len;506 506 507 507 /* Ignore mode for now. */ … … 887 887 { 888 888 int fd = (int) IPC_GET_ARG1(*request); 889 off _t off = (off_t) IPC_GET_ARG2(*request);890 int whence = (int) IPC_GET_ARG3(*request);891 892 889 off64_t off = 890 (off64_t) MERGE_LOUP32(IPC_GET_ARG2(*request), IPC_GET_ARG3(*request)); 891 int whence = (int) IPC_GET_ARG4(*request); 892 893 893 /* Lookup the file structure corresponding to the file descriptor. */ 894 894 vfs_file_t *file = vfs_file_get(fd); … … 897 897 return; 898 898 } 899 900 off_t newpos; 899 901 900 fibril_mutex_lock(&file->lock); 902 if (whence == SEEK_SET) { 903 file->pos = off; 904 fibril_mutex_unlock(&file->lock); 905 ipc_answer_1(rid, EOK, off); 906 return; 907 } 908 if (whence == SEEK_CUR) { 909 if (file->pos + off < file->pos) { 901 902 off64_t newoff; 903 switch (whence) { 904 case SEEK_SET: 905 if (off >= 0) { 906 file->pos = (aoff64_t) off; 907 fibril_mutex_unlock(&file->lock); 908 ipc_answer_1(rid, EOK, off); 909 return; 910 } 911 break; 912 case SEEK_CUR: 913 if ((off >= 0) && (file->pos + off < file->pos)) { 914 fibril_mutex_unlock(&file->lock); 915 ipc_answer_0(rid, EOVERFLOW); 916 return; 917 } 918 919 if ((off < 0) && (file->pos < (aoff64_t) -off)) { 920 fibril_mutex_unlock(&file->lock); 921 ipc_answer_0(rid, EOVERFLOW); 922 return; 923 } 924 925 file->pos += off; 926 newoff = (file->pos > OFF64_MAX) ? OFF64_MAX : file->pos; 927 910 928 fibril_mutex_unlock(&file->lock); 911 ipc_answer_ 0(rid, EOVERFLOW);929 ipc_answer_2(rid, EOK, LOWER32(newoff), UPPER32(newoff)); 912 930 return; 913 } 914 file->pos += off; 915 newpos = file->pos; 916 fibril_mutex_unlock(&file->lock); 917 ipc_answer_1(rid, EOK, newpos); 918 return; 919 } 920 if (whence == SEEK_END) { 921 fibril_rwlock_read_lock(&file->node->contents_rwlock); 922 size_t size = file->node->size; 923 fibril_rwlock_read_unlock(&file->node->contents_rwlock); 924 if (size + off < size) { 931 case SEEK_END: 932 fibril_rwlock_read_lock(&file->node->contents_rwlock); 933 aoff64_t size = file->node->size; 934 935 if ((off >= 0) && (size + off < size)) { 936 fibril_rwlock_read_unlock(&file->node->contents_rwlock); 937 fibril_mutex_unlock(&file->lock); 938 ipc_answer_0(rid, EOVERFLOW); 939 return; 940 } 941 942 if ((off < 0) && (size < (aoff64_t) -off)) { 943 fibril_rwlock_read_unlock(&file->node->contents_rwlock); 944 fibril_mutex_unlock(&file->lock); 945 ipc_answer_0(rid, EOVERFLOW); 946 return; 947 } 948 949 file->pos = size + off; 950 newoff = (file->pos > OFF64_MAX) ? OFF64_MAX : file->pos; 951 952 fibril_rwlock_read_unlock(&file->node->contents_rwlock); 925 953 fibril_mutex_unlock(&file->lock); 926 ipc_answer_ 0(rid, EOVERFLOW);954 ipc_answer_2(rid, EOK, LOWER32(newoff), UPPER32(newoff)); 927 955 return; 928 } 929 newpos = size + off; 930 file->pos = newpos; 931 fibril_mutex_unlock(&file->lock); 932 ipc_answer_1(rid, EOK, newpos); 933 return; 934 } 956 } 957 935 958 fibril_mutex_unlock(&file->lock); 936 959 ipc_answer_0(rid, EINVAL); 937 960 } 938 961 939 int 940 vfs_truncate_internal(fs_handle_t fs_handle, dev_handle_t dev_handle, 941 fs_index_t index, size_t size) 962 int vfs_truncate_internal(fs_handle_t fs_handle, dev_handle_t dev_handle, 963 fs_index_t index, aoff64_t size) 942 964 { 943 965 ipcarg_t rc; … … 945 967 946 968 fs_phone = vfs_grab_phone(fs_handle); 947 rc = async_req_ 3_0(fs_phone, VFS_OUT_TRUNCATE, (ipcarg_t)dev_handle,948 (ipcarg_t) index, (ipcarg_t)size);969 rc = async_req_4_0(fs_phone, VFS_OUT_TRUNCATE, (ipcarg_t) dev_handle, 970 (ipcarg_t) index, LOWER32(size), UPPER32(size)); 949 971 vfs_release_phone(fs_phone); 950 972 return (int)rc; … … 954 976 { 955 977 int fd = IPC_GET_ARG1(*request); 956 size_t size = IPC_GET_ARG2(*request); 978 aoff64_t size = 979 (aoff64_t) MERGE_LOUP32(IPC_GET_ARG2(*request), IPC_GET_ARG3(*request)); 957 980 int rc; 958 981
Note:
See TracChangeset
for help on using the changeset viewer.