Changeset 2048
- Timestamp:
- Jun 19, 2005, 6:10:41 AM (20 years ago)
- Location:
- trunk/src/emx
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/ChangeLog.LIBC
-
Property cvs2svn:cvs-rev
changed from
1.58
to1.59
r2047 r2048 1 1 /* $Id$ */ 2 3 2005-06-19: knut st. osmundsen <bird-gccos2-spam@anduin.net> 4 - libc: 5 o File resize optimization: The JFS, HPFS and probably NET 6 will never return space which isn't zeroed when expanding 7 a file. Associate a file system information object with the 8 filehandles to keep track of such features. This also fixes 9 the fsStatFH() implementation trouble. 10 This attribute doesn't apply to CDFS. While RAMFS fails 11 the test, it zeros at open but not at setfilesize. 12 o Fixed invalid inode and dev numbers for new files, was passing 13 the wrong path around. 2 14 3 15 2005-06-13: knut st. osmundsen <bird-gccos2-spam@anduin.net> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/386/builtin.h
-
Property cvs2svn:cvs-rev
changed from
1.11
to1.12
r2047 r2048 148 148 } 149 149 150 151 150 /** 152 151 * Atomically increments a 32-bit unsigned value. … … 164 163 * Atomically increments a 32-bit unsigned value. 165 164 * 165 * @returns The new value. 166 166 * @param pu32 Pointer to the value to increment. 167 167 */ 168 static __inline__ void __atomic_increment_u32(uint32_t __volatile__ *pu32) 169 { 170 __asm__ __volatile__("lock; incl %0" 171 : "=m" (*pu32) 172 : "m" (*pu32)); 168 static __inline__ uint32_t __atomic_increment_u32(uint32_t __volatile__ *pu32) 169 { 170 uint32_t u32; 171 __asm__ __volatile__("lock; xadd %0, %1\n\t" 172 "incl %0\n\t" 173 : "=r" (u32), 174 "=m" (*pu32) 175 : "0" (1) 176 : "memory"); 177 return u32; 178 } 179 180 /** 181 * Atomically increments a 32-bit signed value. 182 * 183 * @returns The new value. 184 * @param pi32 Pointer to the value to increment. 185 */ 186 static __inline__ uint32_t __atomic_increment_s32(int32_t __volatile__ *pi32) 187 { 188 int32_t i32; 189 __asm__ __volatile__("lock; xadd %0, %1\n\t" 190 "incl %0\n\t" 191 : "=r" (i32), 192 "=m" (*pi32) 193 : "0" (1) 194 : "memory"); 195 return i32; 173 196 } 174 197 … … 200 223 * Atomically decrements a 32-bit unsigned value. 201 224 * 202 * @param pu Pointer to the value to decrement. 203 */ 204 static __inline__ void __atomic_decrement_u32(__volatile__ uint32_t *pu32) 205 { 206 __asm__ __volatile__("lock; decl %0" 207 : "=m" (*pu32) 208 : "m" (*pu32)); 225 * @returns The new value. 226 * @param pu32 Pointer to the value to decrement. 227 */ 228 static __inline__ uint32_t __atomic_decrement_u32(__volatile__ uint32_t *pu32) 229 { 230 uint32_t u32; 231 __asm__ __volatile__("lock; xadd %0, %1\n\t" 232 "decl %0\n\t" 233 : "=r" (u32), 234 "=m" (*pu32) 235 : "0" (-1) 236 : "memory"); 237 return u32; 238 } 239 240 /** 241 * Atomically decrements a 32-bit signed value. 242 * 243 * @returns The new value. 244 * @param pi32 Pointer to the value to decrement. 245 */ 246 static __inline__ uint32_t __atomic_decrement_s32(__volatile__ int32_t *pi32) 247 { 248 int32_t i32; 249 __asm__ __volatile__("lock; xadd %0, %1\n\t" 250 "decl %0\n\t" 251 : "=r" (i32), 252 "=m" (*pi32) 253 : "0" (-1) 254 : "memory"); 255 return i32; 209 256 } 210 257 … … 212 259 * Atomically decrements a 16-bit unsigned value. 213 260 * 261 * @returns The new value. 214 262 * @param pu16 Pointer to the value to decrement. 215 263 */ -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/InnoTekLIBC/sharedpm.h
-
Property cvs2svn:cvs-rev
changed from
1.23
to1.24
r2047 r2048 163 163 #define __LIBC_SPM_INH_FHB_TYPE_END (0) 164 164 /** Standard bundle. */ 165 #define __LIBC_SPM_INH_FHB_TYPE_STANDARD (0x10 | sizeof(unsigned)) 165 #define __LIBC_SPM_INH_FHB_TYPE_STANDARD (0x10 | (sizeof(unsigned) + sizeof(ino_t) + sizeof(dev_t))) 166 /** The old standard bundle. */ 167 #define __LIBC_SPM_INH_FHB_TYPE_STANDARD_OLD (0x10 | sizeof(unsigned)) 166 168 /** Socket bundle, using the BSD 4.4 backend. */ 167 169 #define __LIBC_SPM_INH_FHB_TYPE_SOCKET_44 (0x20 | (sizeof(unsigned) + sizeof(unsigned short))) … … 199 201 /** The common bundle header. */ 200 202 __LIBC_SPMINHFHBHDR Hdr; 201 /** Array of flags of Hdr.cHandles entries. */ 202 unsigned afFlags[1]; 203 /** Array Hdr.cHandles entries. */ 204 struct 205 { 206 /** The flags */ 207 unsigned fFlags; 208 /** The inode number. */ 209 ino_t Inode; 210 /** The device number. */ 211 dev_t Dev; 212 } aHandles[1]; 203 213 } __LIBC_SPMINHFHBSTD; 204 214 #pragma pack() 205 215 /** Pointer to SPM standard filehandle inherit bundle. */ 206 216 typedef __LIBC_SPMINHFHBSTD *__LIBC_PSPMINHFHBSTD; 217 218 /** 219 * SPM standard filehandle inherit bundle 220 * This is used for OS/2 filehandles which only needs flags 221 * transfered. 222 */ 223 #pragma pack(1) 224 typedef struct __libc_SPMInhFHOld 225 { 226 /** The common bundle header. */ 227 __LIBC_SPMINHFHBHDR Hdr; 228 /** Array of flags of Hdr.cHandles entries. */ 229 unsigned afFlags[1]; 230 } __LIBC_SPMINHFHBSTDOLD; 231 #pragma pack() 232 /** Pointer to SPM standard filehandle inherit bundle. */ 233 typedef __LIBC_SPMINHFHBSTDOLD *__LIBC_PSPMINHFHBSTDOLD; 207 234 208 235 /** -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/emx/io.h
-
Property cvs2svn:cvs-rev
changed from
1.14
to1.15
r2047 r2048 225 225 226 226 /** 227 * Information struct about a mounted file system. 228 * 229 * Used to track down the filesystem of an open file handle and 230 * so we can optimize certain operations like expanding a file. 231 */ 232 typedef struct __libc_FileSystemInfo 233 { 234 /** Number of references to this file system info object. 235 * The structure can be shared by many handles. */ 236 volatile int32_t cRefs; 237 /** Does the file system automatically zero the new space when a file is extended? */ 238 unsigned fZeroNewBytes : 1; 239 /** Device number of the device the filesystem resides on. 240 * On OS/2 the device number is derived from the driveletter. */ 241 dev_t Dev; 242 /** The filesystem driver name. */ 243 char szName[16]; 244 /** The mount point - may extend beyond the 4 bytes on some OSes. */ 245 char szMountpoint[4]; 246 } __LIBC_FSINFO; 247 /** Pointer to information about an open filesystem. */ 248 typedef __LIBC_FSINFO *__LIBC_PFSINFO; 249 250 251 /** 227 252 * Filehandle type. 228 253 */ … … 381 406 * determin this at handle creation time. */ 382 407 ino_t Inode; 408 /** Pointer to the filesystem information object for the filesystem which 409 * this file resides on. This might be NULL... */ 410 __LIBC_PFSINFO pFsInfo; 383 411 } __LIBC_FH; 384 412 /** Pointer to filehandle. */ -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/__dup.c
-
Property cvs2svn:cvs-rev
changed from
1.7
to1.8
r2047 r2048 10 10 #include <emx/syscalls.h> 11 11 #include "syscalls.h" 12 #include "b_fs.h" 12 13 13 14 int __dup(int fh) … … 59 60 pFHNew->Inode = pFH->Inode; 60 61 pFHNew->Dev = pFH->Dev; 62 pFHNew->pFsInfo = __libc_back_fsInfoObjAddRef(pFH->pFsInfo); 61 63 } 62 64 else -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/__dup2.c
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r2047 r2048 9 9 #include <emx/io.h> 10 10 #include "syscalls.h" 11 #include "b_fs.h" 11 12 12 13 int __dup2(int fh, int fhNew) … … 92 93 pFHNew->Inode = pFH->Inode; 93 94 pFHNew->Dev = pFH->Dev; 95 pFHNew->pFsInfo = __libc_back_fsInfoObjAddRef(pFH->pFsInfo); 94 96 } 95 97 else -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/b_fs.h
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r2047 r2048 235 235 dev_t __libc_back_fsPathCalcInodeAndDev(const char *pszNativePath, ino_t *pInode); 236 236 237 /** 238 * Gets the fs info object for the specfied path. 239 * 240 * @returns Pointer to info object for the path, if it got one. 241 * @param Dev The device we want the file system object for. 242 */ 243 __LIBC_PFSINFO __libc_back_fsInfoObjByDev(dev_t Dev); 244 245 /** 246 * Adds a reference to an existing FS info object. 247 * 248 * The caller is responsible for making sure that the object cannot 249 * reach 0 references while inside this function. 250 * 251 * @returns pFsInfo. 252 * @param pFsInfo Pointer to the fs info object to reference. 253 */ 254 __LIBC_PFSINFO __libc_back_fsInfoObjAddRef(__LIBC_PFSINFO pFsInfo); 255 256 /** 257 * Releases the fs info object for the specfied path. 258 * 259 * @param pFsInfo Pointer to the fs info object to release a reference to. 260 */ 261 void __libc_back_fsInfoObjRelease(__LIBC_PFSINFO pFsInfo); 237 262 238 263 __END_DECLS -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/b_fsStat.c
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r2047 r2048 112 112 * pass it to the statfs() backend. 113 113 */ 114 int rc = 0; 114 115 char szFilename[PATH_MAX]; 115 int rc = __libc_Back_ioFHToPath(fh, szFilename, sizeof(szFilename)); 116 __LIBC_PFH pFH = __libc_FH(fh); 117 if (pFH && pFH->pFsInfo) 118 strcpy(szFilename, pFH->pFsInfo->szMountpoint); 119 else 120 rc = __libc_Back_ioFHToPath(fh, szFilename, sizeof(szFilename)); 116 121 if (!rc) 117 122 { -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/b_ioFileOpen.c
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r2047 r2048 182 182 if ( (ulAction == FILE_CREATED) 183 183 && !__libc_gfNoUnix) 184 __libc_back_fsUnixAttribsSet(hFile, pszFile, Mode, &Dev, &Inode);184 __libc_back_fsUnixAttribsSet(hFile, szNativePath, Mode, &Dev, &Inode); 185 185 else 186 186 Dev = __libc_back_fsPathCalcInodeAndDev(szNativePath, &Inode); … … 216 216 if (ppFH) 217 217 { 218 (*ppFH)->Inode = Inode; 218 219 (*ppFH)->Dev = Dev; 219 (*ppFH)-> Inode = Inode;220 (*ppFH)->pFsInfo = __libc_back_fsInfoObjByDev(Dev); 220 221 } 221 222 LIBCLOG_MSG("hFile=%#lx fLibc=%#x fulType=%#lx ulAction=%lu Dev=%#x Inode=%#llx\n", -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/b_ioFileSizeSet.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r2047 r2048 43 43 * Global Variables * 44 44 *******************************************************************************/ 45 /** A page of zeros. 45 /** A page of zeros. 46 46 * @todo Make this a separate segment for optimal thunking effiency! */ 47 static const char __libc_gachZeros[65536 - 4096]; 47 static const char __libc_gachZeros[65536 - 4096]; 48 48 49 49 … … 193 193 */ 194 194 off_t cbLeft = cbFile - cbCur; 195 if (cbLeft <= 0 || !fZero) 195 if ( cbLeft <= 0 196 || !fZero 197 || (pFH->pFsInfo && pFH->pFsInfo->fZeroNewBytes)) 196 198 { 197 199 FS_RESTORE(); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/filehandles.c
-
Property cvs2svn:cvs-rev
changed from
1.19
to1.20
r2047 r2048 52 52 #include <emx/umalloc.h> 53 53 #include "syscalls.h" 54 #include "b_fs.h" 54 55 55 56 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_INITTERM … … 169 170 __LIBC_PSPMINHFHBHDR pHdr; 170 171 __LIBC_PSPMINHFHBSTD pStds; 172 __LIBC_PSPMINHFHBSTDOLD pStdsOld; 171 173 __LIBC_PSPMINHFHBSOCK pSockets; 172 174 uintptr_t u; … … 184 186 for (i = 0; i < c; i++) 185 187 { 186 if (fhAllocate(iFH, u.pStds->afFlags[i], sizeof(__LIBC_FH), NULL, NULL, NULL, 0)) 188 __LIBC_PFH pFH; 189 if (fhAllocate(iFH, u.pStds->aHandles[i].fFlags, sizeof(__LIBC_FH), NULL, &pFH, NULL, 0)) 190 { 191 LIBC_ASSERTM_FAILED("Failed to allocated inherited file handle! iFH=%d\n", iFH); 192 __libc_spmInheritRelease(); 193 return -1; 194 } 195 pFH->Dev = u.pStds->aHandles[i].Inode; 196 pFH->Inode = u.pStds->aHandles[i].Dev; 197 pFH->pFsInfo = __libc_back_fsInfoObjByDev(pFH->Dev); 198 } 199 u.pv = &u.pStds->aHandles[c]; 200 break; 201 202 case __LIBC_SPM_INH_FHB_TYPE_STANDARD_OLD: 203 for (i = 0; i < c; i++) 204 { 205 if (fhAllocate(iFH, u.pStdsOld->afFlags[i], sizeof(__LIBC_FH), NULL, NULL, NULL, 0)) 187 206 { 188 207 LIBC_ASSERTM_FAILED("Failed to allocated inherited file handle! iFH=%d\n", iFH); … … 191 210 } 192 211 } 193 u.pv = &u.pStds ->afFlags[c];212 u.pv = &u.pStdsOld->afFlags[c]; 194 213 break; 195 214 … … 365 384 for (i = 0; ; ) 366 385 { 367 u.pStds->afFlags[i] = gpapFHs[iFH]->fFlags; 386 u.pStds->aHandles[i].fFlags = gpapFHs[iFH]->fFlags; 387 u.pStds->aHandles[i].Inode = gpapFHs[iFH]->Inode; 388 u.pStds->aHandles[i].Dev = gpapFHs[iFH]->Dev; 368 389 /* next */ 369 390 i++; iFH++; … … 377 398 /* commit the bundle. */ 378 399 u.pStds->Hdr.cHandles = i; 379 u.pv = &u.pStds->a fFlags[i];400 u.pv = &u.pStds->aHandles[i]; 380 401 break; 381 402 } … … 741 762 pFH->Inode = ++_sys_ino; 742 763 pFH->Dev = 0; 764 pFH->pFsInfo = NULL; 743 765 744 766 /* -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/fs.c
-
Property cvs2svn:cvs-rev
changed from
1.16
to1.17
r2047 r2048 182 182 183 183 184 /** Array of pointers to fs info objects for all 185 * possible OS/2 volumes. 186 */ 187 static __LIBC_FSINFO g_aFSInfoVolumes['Z' - 'A' + 1]; 188 /** Mutex semaphore protecting the g_aFSInfoVolumes array. */ 189 static _fmutex g_mtxFSInfoVolumes = _FMUTEX_INITIALIZER_EX(_FMC_MUST_COMPLETE, "mtxFSInfoVolumes"); 184 190 185 191 /******************************************************************************* … … 1328 1334 else 1329 1335 { 1330 /* ASSUMES that pszNativePath contains a driveletter! If not fix the resolver!!! */ 1331 if (chDrv >= 'a' && chDrv <= 'z') 1332 chDrv -= 'a' - 'A'; 1336 LIBC_ASSERT(chDrv >= 'A' && chDrv <= 'Z'); 1333 1337 Dev = makedev('V', chDrv); /* V as in Volume */ 1334 1338 } … … 1465 1469 else 1466 1470 { 1467 /* ASSUMES that pszNativePath contains a driveletter! If not fix the resolver!!! */1471 LIBC_ASSERT(chDrv >= 'A' && chDrv <= 'Z'); 1468 1472 if (chDrv >= 'a' && chDrv <= 'z') 1469 1473 chDrv -= 'a' - 'A'; … … 1479 1483 *pInode = ((uint64_t)crc32str(psz) << 32) | (uint64_t)sdbm(psz); 1480 1484 return Dev; 1485 } 1486 1487 1488 /** 1489 * Updates the FS info object. 1490 */ 1491 static void fsInfoObjUpdate(__LIBC_PFSINFO pFsInfo, dev_t Dev) 1492 { 1493 static char achBuffer[384]; /* we're protected by the mutex, don't assume too much stack! */ 1494 ULONG cb = sizeof(achBuffer); 1495 PFSQBUFFER2 pfsqb = (PFSQBUFFER2)achBuffer; 1496 1497 /* init the structure */ 1498 pFsInfo->fZeroNewBytes = 0; 1499 pFsInfo->Dev = Dev; 1500 pFsInfo->szName[0] = '\0'; 1501 pFsInfo->szMountpoint[0] = minor(Dev); 1502 pFsInfo->szMountpoint[1] = ':'; 1503 pFsInfo->szMountpoint[2] = '\0'; 1504 pFsInfo->szMountpoint[3] = '\0'; 1505 1506 /* query fs info */ 1507 FS_VAR_SAVE_LOAD(); 1508 int rc = DosQueryFSAttach((PCSZ)pFsInfo->szMountpoint, 0, FSAIL_QUERYNAME, pfsqb, &cb); 1509 LIBC_ASSERTM(!rc, "rc=%d\n", rc); 1510 if (!rc) 1511 strncat(pFsInfo->szName, (const char *)&pfsqb->szName[pfsqb->cbName + 1], sizeof(pFsInfo->szName) - 1); 1512 if ( !strcmp(pFsInfo->szName, "JFS") 1513 || !strcmp(pFsInfo->szName, "HPFS") 1514 || !strcmp(pFsInfo->szName, "FAT") 1515 || !strcmp(pFsInfo->szName, "LAN")) 1516 pFsInfo->fZeroNewBytes = 1; /* RAMFS does not do this. */ 1517 LIBCLOG_MSG2("fsInfoObjUpdate: dev:%#x mp:%s fsd:%s fZeroNewBytes=%d\n", 1518 pFsInfo->Dev, pFsInfo->szMountpoint, pFsInfo->szName, pFsInfo->fZeroNewBytes); 1519 FS_RESTORE(); 1520 } 1521 1522 1523 /** 1524 * Gets the fs info object for the specfied path. 1525 * 1526 * @returns Pointer to info object for the path, if it got one. 1527 * @param Dev The device we want the file system object for. 1528 */ 1529 __LIBC_PFSINFO __libc_back_fsInfoObjByDev(dev_t Dev) 1530 { 1531 __LIBC_PFSINFO pFsInfo = NULL; 1532 char chDrv = minor(Dev); 1533 if ( major(Dev) == 'V' 1534 && chDrv >= 'A' && chDrv <= 'Z') 1535 { 1536 pFsInfo = &g_aFSInfoVolumes[(int)chDrv]; 1537 _fmutex_request(&g_mtxFSInfoVolumes, 0); 1538 int cRefs = __atomic_increment_s32(&pFsInfo->cRefs); 1539 LIBC_ASSERT(cRefs > 0); 1540 if (cRefs <= 0) 1541 pFsInfo->cRefs = cRefs = 1; 1542 if (cRefs == 1) 1543 fsInfoObjUpdate(pFsInfo, Dev); 1544 _fmutex_release(&g_mtxFSInfoVolumes); 1545 } 1546 else 1547 LIBC_ASSERT(chDrv == '/' || chDrv == '\\'); 1548 1549 return pFsInfo; 1550 } 1551 1552 1553 #if 0 1554 /** 1555 * Gets the fs info object for the specfied path. 1556 * 1557 * @returns Pointer to info object for the path, if it got one. 1558 * @param pszNativePath The native path as returned by the resolver. 1559 */ 1560 __LIBC_PFSINFO __libc_back_fsInfoObjByPath(const char *pszNativePath) 1561 { 1562 /* 1563 * Calc device. 1564 */ 1565 dev_t Dev; 1566 char chDrv = *pszNativePath; 1567 if (chDrv == '/' || chDrv == '\\') 1568 Dev = makedev('U', 0); /* U as in UNC */ 1569 else 1570 { 1571 LIBC_ASSERT(chDrv >= 'A' && chDrv <= 'Z'); 1572 Dev = makedev('V', chDrv); /* V as in Volume */ 1573 } 1574 return __libc_back_fsInfoObjByDev(Dev); 1575 } 1576 #endif 1577 1578 1579 /** 1580 * Adds a reference to an existing FS info object. 1581 * 1582 * The caller is responsible for making sure that the object cannot 1583 * reach 0 references while inside this function. 1584 * 1585 * @returns pFsInfo. 1586 * @param pFsInfo Pointer to the fs info object to reference. 1587 */ 1588 __LIBC_PFSINFO __libc_back_fsInfoObjAddRef(__LIBC_PFSINFO pFsInfo) 1589 { 1590 if (pFsInfo) 1591 { 1592 int cRefs = __atomic_increment_s32(&pFsInfo->cRefs); 1593 LIBC_ASSERT(cRefs > 1); (void)cRefs; 1594 } 1595 return pFsInfo; 1596 } 1597 1598 1599 /** 1600 * Releases the fs info object for the specfied path. 1601 * 1602 * @param pFsInfo Pointer to the fs info object to release a reference to. 1603 */ 1604 void __libc_back_fsInfoObjRelease(__LIBC_PFSINFO pFsInfo) 1605 { 1606 if (pFsInfo) 1607 { 1608 int cRefs = __atomic_decrement_s32(&pFsInfo->cRefs); 1609 LIBC_ASSERT(cRefs > 1); (void)cRefs; 1610 } 1481 1611 } 1482 1612 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/tcpipver.c
-
Property cvs2svn:cvs-rev
changed from
1.12
to1.13
r2047 r2048 70 70 #include <InnoTekLIBC/logstrict.h> 71 71 72 #include "b_fs.h" 72 73 73 74 /******************************************************************************* … … 366 367 pFHNew->core.Inode = pFHSocket->core.Inode; 367 368 pFHNew->core.Dev = pFHSocket->core.Dev; 369 pFHNew->core.pFsInfo = pFHSocket->core.pFsInfo; 368 370 LIBCLOG_RETURN_MSG(0, "ret 0 (0x0) *pfhNew=%d\n", *pfhNew); 369 371 } -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.