Changes in uspace/srv/fs/fat/fat_ops.c [19f857a:472c09d] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/fat/fat_ops.c
r19f857a r472c09d 45 45 #include <ipc/services.h> 46 46 #include <ipc/devmap.h> 47 #include <macros.h>48 47 #include <async.h> 49 48 #include <errno.h> 50 #include <str .h>49 #include <string.h> 51 50 #include <byteorder.h> 52 51 #include <adt/hash_table.h> … … 80 79 static int fat_has_children(bool *, fs_node_t *); 81 80 static fs_index_t fat_index_get(fs_node_t *); 82 static aoff64_t fat_size_get(fs_node_t *);81 static size_t fat_size_get(fs_node_t *); 83 82 static unsigned fat_lnkcnt_get(fs_node_t *); 84 83 static char fat_plb_get_char(unsigned); … … 723 722 fibril_mutex_lock(&childp->idx->lock); 724 723 725 if (childp->type == FAT_DIRECTORY) { 724 /* 725 * If possible, create the Sub-directory Identifier Entry and the 726 * Sub-directory Parent Pointer Entry (i.e. "." and ".."). These entries 727 * are not mandatory according to Standard ECMA-107 and HelenOS VFS does 728 * not use them anyway, so this is rather a sign of our good will. 729 */ 730 rc = fat_block_get(&b, bs, childp, 0, BLOCK_FLAGS_NONE); 731 if (rc != EOK) { 726 732 /* 727 * If possible, create the Sub-directory Identifier Entry and 728 * the Sub-directory Parent Pointer Entry (i.e. "." and ".."). 729 * These entries are not mandatory according to Standard 730 * ECMA-107 and HelenOS VFS does not use them anyway, so this is 731 * rather a sign of our good will. 733 * Rather than returning an error, simply skip the creation of 734 * these two entries. 732 735 */ 733 rc = fat_block_get(&b, bs, childp, 0, BLOCK_FLAGS_NONE); 734 if (rc != EOK) { 735 /* 736 * Rather than returning an error, simply skip the 737 * creation of these two entries. 738 */ 739 goto skip_dots; 740 } 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) { 744 memset(d, 0, sizeof(fat_dentry_t)); 745 str_cpy((char *) d->name, 8, FAT_NAME_DOT); 746 str_cpy((char *) d->ext, 3, FAT_EXT_PAD); 747 d->attr = FAT_ATTR_SUBDIR; 748 d->firstc = host2uint16_t_le(childp->firstc); 749 /* TODO: initialize also the date/time members. */ 750 } 751 d++; 752 if ((fat_classify_dentry(d) == FAT_DENTRY_LAST) || 753 (str_cmp((char *) d->name, FAT_NAME_DOT_DOT) == 0)) { 754 memset(d, 0, sizeof(fat_dentry_t)); 755 str_cpy((char *) d->name, 8, FAT_NAME_DOT_DOT); 756 str_cpy((char *) d->ext, 3, FAT_EXT_PAD); 757 d->attr = FAT_ATTR_SUBDIR; 758 d->firstc = (parentp->firstc == FAT_CLST_ROOT) ? 759 host2uint16_t_le(FAT_CLST_RES0) : 760 host2uint16_t_le(parentp->firstc); 761 /* TODO: initialize also the date/time members. */ 762 } 763 b->dirty = true; /* need to sync block */ 764 /* 765 * Ignore the return value as we would have fallen through on error 766 * anyway. 767 */ 768 (void) block_put(b); 769 } 736 goto skip_dots; 737 } 738 d = (fat_dentry_t *)b->data; 739 if (fat_classify_dentry(d) == FAT_DENTRY_LAST || 740 str_cmp(d->name, FAT_NAME_DOT) == 0) { 741 memset(d, 0, sizeof(fat_dentry_t)); 742 str_cpy(d->name, 8, FAT_NAME_DOT); 743 str_cpy(d->ext, 3, FAT_EXT_PAD); 744 d->attr = FAT_ATTR_SUBDIR; 745 d->firstc = host2uint16_t_le(childp->firstc); 746 /* TODO: initialize also the date/time members. */ 747 } 748 d++; 749 if (fat_classify_dentry(d) == FAT_DENTRY_LAST || 750 str_cmp(d->name, FAT_NAME_DOT_DOT) == 0) { 751 memset(d, 0, sizeof(fat_dentry_t)); 752 str_cpy(d->name, 8, FAT_NAME_DOT_DOT); 753 str_cpy(d->ext, 3, FAT_EXT_PAD); 754 d->attr = FAT_ATTR_SUBDIR; 755 d->firstc = (parentp->firstc == FAT_CLST_ROOT) ? 756 host2uint16_t_le(FAT_CLST_RES0) : 757 host2uint16_t_le(parentp->firstc); 758 /* TODO: initialize also the date/time members. */ 759 } 760 b->dirty = true; /* need to sync block */ 761 /* 762 * Ignore the return value as we would have fallen through on error 763 * anyway. 764 */ 765 (void) block_put(b); 770 766 skip_dots: 771 767 … … 916 912 } 917 913 918 aoff64_t fat_size_get(fs_node_t *fn)914 size_t fat_size_get(fs_node_t *fn) 919 915 { 920 916 return FAT_NODE(fn)->size; … … 981 977 /* Accept the mount options */ 982 978 char *opts; 983 int rc = async_ data_write_accept((void **) &opts, true, 0, 0, 0, NULL);979 int rc = async_string_receive(&opts, 0, NULL); 984 980 985 981 if (rc != EOK) { … … 1158 1154 void fat_read(ipc_callid_t rid, ipc_call_t *request) 1159 1155 { 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)); 1156 dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request); 1157 fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request); 1158 off_t pos = (off_t)IPC_GET_ARG3(*request); 1164 1159 fs_node_t *fn; 1165 1160 fat_node_t *nodep; … … 1225 1220 } else { 1226 1221 unsigned bnum; 1227 aoff64_t spos = pos;1222 off_t spos = pos; 1228 1223 char name[FAT_NAME_LEN + 1 + FAT_EXT_LEN + 1]; 1229 1224 fat_dentry_t *d; … … 1241 1236 bnum = (pos * sizeof(fat_dentry_t)) / bps; 1242 1237 while (bnum < nodep->size / bps) { 1243 aoff64_t o;1238 off_t o; 1244 1239 1245 1240 rc = fat_block_get(&b, bs, nodep, bnum, … … 1297 1292 void fat_write(ipc_callid_t rid, ipc_call_t *request) 1298 1293 { 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)); 1294 dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request); 1295 fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request); 1296 off_t pos = (off_t)IPC_GET_ARG3(*request); 1303 1297 fs_node_t *fn; 1304 1298 fat_node_t *nodep; … … 1309 1303 unsigned spc; 1310 1304 unsigned bpc; /* bytes per cluster */ 1311 aoff64_t boundary;1305 off_t boundary; 1312 1306 int flags = BLOCK_FLAGS_NONE; 1313 1307 int rc; … … 1455 1449 void fat_truncate(ipc_callid_t rid, ipc_call_t *request) 1456 1450 { 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)); 1451 dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request); 1452 fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request); 1453 size_t size = (off_t)IPC_GET_ARG3(*request); 1461 1454 fs_node_t *fn; 1462 1455 fat_node_t *nodep;
Note:
See TracChangeset
for help on using the changeset viewer.