Changeset 8973acd in buchla-68k for libcio/filesys.c
- Timestamp:
- 07/15/2017 03:12:10 PM (7 years ago)
- Branches:
- master
- Children:
- ea232f9
- Parents:
- 7d0d347
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcio/filesys.c
r7d0d347 r8973acd 30 30 struct dirent *_dptr; /* internal directory pointer */ 31 31 32 uint 16_t _thefat[MAXFAT * WDPSEC]; /* file allocation table */32 uint8_t _thefat[MAXFAT * BPSEC]; /* file allocation table */ 33 33 34 34 int16_t _fatin; /* FAT has been read */ … … 47 47 */ 48 48 49 uint16_t _cl2lsn(struct bpb *bpp, uint16_t clnum)49 int16_t _cl2lsn(struct bpb *bpp, int16_t clnum) 50 50 { 51 51 return(bpp->datrec + (bpp->clsiz * (clnum - 2)) ); … … 59 59 */ 60 60 61 uint16_t _gtcl12(int8_t *fat, uint16_t cl) 62 { 63 register uint16_t cla, clt; 61 int16_t _gtcl12(uint8_t *fat, int16_t cl) 62 { 63 int16_t cla; 64 uint16_t clt; 64 65 65 66 cla = cl + (cl >> 1); 66 clt = ( (uint16_t)0xFF00 & (fat[cla+1] << 8))67 | ( (uint16_t)0x00FF& fat[cla]);67 clt = (0xFF00u & ((uint16_t)fat[cla + 1] << 8)) 68 | (0x00FFu & fat[cla]); 68 69 69 70 if (cl & 1) 70 71 clt >>= 4; 71 72 72 clt &= (uint16_t)0x0FFF;73 return( clt);73 clt &= 0x0FFFu; 74 return((int16_t)clt); 74 75 } 75 76 … … 81 82 */ 82 83 83 uint16_t _getfat(uint16_t *bufad, struct bpb *bpp, uint16_t nfat)84 { 85 uint16_t fatsec;84 int32_t _getfat(uint8_t *bufad, struct bpb *bpp, int16_t nfat) 85 { 86 int16_t fatsec; 86 87 87 88 fatsec = nfat ? bpp->fatrec : (bpp->fatrec - bpp->fsiz); 88 return(BIOS(B_RDWR, 0, (int8_t *)bufad, bpp->fsiz, fatsec, 0));89 return(BIOS(B_RDWR, 0, bufad, bpp->fsiz, fatsec, 0)); 89 90 } 90 91 … … 96 97 */ 97 98 98 int16_t _rdfat(uint 16_t *bufad, struct bpb *bpp)99 int16_t _rdfat(uint8_t *bufad, struct bpb *bpp) 99 100 { 100 101 if (_getfat(bufad, bpp, 0)) { … … 116 117 */ 117 118 118 int 16_t _rdroot(uint16_t *buf, struct bpb *bpp)119 { 120 return(BIOS(B_RDWR, 0, (int8_t *)buf, bpp->rdlen,119 int32_t _rdroot(struct dirent *buf, struct bpb *bpp) 120 { 121 return(BIOS(B_RDWR, 0, buf, bpp->rdlen, 121 122 (bpp->fatrec + bpp->fsiz), 0)); 122 123 } … … 131 132 */ 132 133 133 int16_t _nsic(struct fcb *fcp, struct bpb *bpp, int8_t *fp)134 { 135 register uint16_t tfe;134 int16_t _nsic(struct fcb *fcp, struct bpb *bpp, uint8_t *fp) 135 { 136 register int16_t tfe; 136 137 137 138 /* check the FCB flags */ … … 220 221 struct dirent *_dsrch(struct dirent *de) 221 222 { 222 uint16_t i, dl;223 int16_t i, dl; 223 224 register struct dirent *dp; 224 225 225 226 dp = _thedir; 226 dl = _thebpb->rdlen * (_thebpb->recsiz / DENTSIZE);227 dl = _thebpb->rdlen * (_thebpb->recsiz / (int16_t)DENTSIZE); 227 228 228 229 for (i = 0; i < dl; i++) { /* check each entry */ … … 253 254 struct dirent *_dsnew(void) 254 255 { 255 uint16_t i, dl;256 int16_t i, dl; 256 257 register struct dirent *dp; 257 258 258 259 dp = _thedir; 259 dl = _thebpb->rdlen * (_thebpb->recsiz / DENTSIZE);260 dl = _thebpb->rdlen * (_thebpb->recsiz / (int16_t)DENTSIZE); 260 261 261 262 for (i = 0; i < dl; i++) { /* check each entry */ … … 304 305 int16_t _seek(struct fcb *fcp) 305 306 { 306 register uint16_t acls, rcls, nc;307 uint16_t sic, spc;307 register int16_t acls, rcls, nc; 308 int16_t sic, spc; 308 309 309 310 if (!(fcp->modefl & FC_OPN)) { /* file must be open */ … … 328 329 rcls = fcp->curlsn / spc; /* calculate relative cluster */ 329 330 sic = fcp->curlsn - (rcls * spc); /* calculate sector in cluster */ 330 acls = micons(fcp->de.bclust);/* get first cluster */331 acls = (int16_t)micon16(fcp->de.bclust); /* get first cluster */ 331 332 fcp->modefl &= ~FC_EOF; /* turn off the EOF flag */ 332 333 … … 400 401 int16_t _ftrnc(struct dirent *dp) 401 402 { 402 register uint16_t acls, ncls;403 register int16_t acls, ncls; 403 404 404 405 #if DEBUGIT … … 408 409 #endif 409 410 410 acls = micons(dp->bclust);/* get first cluster number */411 acls = (int16_t)micon16(dp->bclust); /* get first cluster number */ 411 412 412 413 /* zap entries until EOF or bad cluster */ … … 481 482 #endif 482 483 483 if ( nc = _newcls()) { /* get a new cluster */484 if ((nc = _newcls())) { /* get a new cluster */ 484 485 485 486 #if DEBUGIT … … 488 489 489 490 _ptcl12(_thefat, nc, FAT_EOF); /* mark new cluster as EOF */ 490 pc = micons(fcp->de.bclust); /* get first cluster */491 pc = (int16_t)micon16(fcp->de.bclust); /* get first cluster */ 491 492 492 493 #if DEBUGIT … … 689 690 /* create the file */ 690 691 691 if (rc = _fmake(fcp)) {692 if ((rc = _fmake(fcp))) { 692 693 693 694 _deadio(fcp, EIO); /* couldn't create the file */ … … 758 759 memcpy(&fcp->de, _dptr, DENTSIZE); 759 760 fcp->clsec = 0; 760 fcp->curcls = micons(fcp->de.bclust);761 fcp->curcls = (int16_t)micon16(fcp->de.bclust); 761 762 fcp->offset = 0; 762 763 fcp->curlsn = 0L; 763 764 fcp->curdsn = fcp->de.bclust ? _cl2lsn(_thebpb, fcp->curcls) : 0; 764 fcp->curlen = miconl(fcp->de.flen);765 766 fcp->asects = (( fcp->curlen / _thebpb->clsizb)765 fcp->curlen = (int32_t)micon32(fcp->de.flen); 766 767 fcp->asects = ((int16_t)(fcp->curlen / _thebpb->clsizb) 767 768 + ((fcp->curlen & (_thebpb->clsizb - 1)) ? 1 : 0)) 768 769 * _thebpb->clsiz; … … 787 788 */ 788 789 789 int16_t _inifcb(struct fcb *fcp, int8_t *name, int8_t *ext, int16_t mode)790 int16_t _inifcb(struct fcb *fcp, int8_t *name, int8_t *ext, uint16_t mode) 790 791 { 791 792 int16_t fl; … … 923 924 if (fcp->modefl & (FC_CR | FC_AP | FC_WR)) { /* writing ? */ 924 925 925 if ( dp = _dsrch(&fcp->de)) { /* locate the dirent */926 if ((dp = _dsrch(&fcp->de))) { /* locate the dirent */ 926 927 927 928 /* update the directory entry if it changed */ … … 1050 1051 return(FAILURE); 1051 1052 1052 _dptr->fname[0] = 0xE5;/* mark directory entry as free */1053 _dptr->fname[0] = (int8_t)0xE5; /* mark directory entry as free */ 1053 1054 1054 1055 #if DEBUGIT
Note:
See TracChangeset
for help on using the changeset viewer.