Changeset 76299 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Dec 19, 2018 7:10:01 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/fs/extvfs.cpp
r76294 r76299 103 103 /** Reference counter. */ 104 104 volatile uint32_t cRefs; 105 /** Block number where the inode is stored. */ 106 uint64_t iBlockInode; 107 /** Offset in bytes into block where the inode is stored. */ 108 uint32_t offInode; 109 /** Inode data size. */ 110 uint64_t cbData; 105 /** Byte offset in the backing file where the inode is stored.. */ 106 uint64_t offInode; 107 /** Inode data. */ 108 RTFSOBJINFO ObjInfo; 109 /** Inode flags (copied from the on disk inode). */ 110 uint32_t fFlags; 111 /** Copy of the block map/extent tree. */ 112 uint32_t aiBlocks[EXT_INODE_BLOCK_ENTRIES]; 111 113 } RTFSEXTINODE; 112 114 /** Pointer to an in-memory inode. */ … … 121 123 /** Volume this directory belongs to. */ 122 124 PRTFSEXTVOL pVol; 125 /** The underlying inode structure. */ 126 PRTFSEXTINODE pInode; 123 127 /** Set if we've reached the end of the directory enumeration. */ 124 128 bool fNoMoreFiles; … … 325 329 Log2(("EXT: iSnapshotListInode %#RX32\n", RT_LE2H_U32(pSb->iSnapshotListInode))); 326 330 Log2(("EXT: cErrorsSeen %#RX32\n", RT_LE2H_U32(pSb->cErrorsSeen))); 327 Log2(("EXT: [...]\n")); /** @todo :Missing fields if becoming interesting. */331 Log2(("EXT: [...]\n")); /** @todo Missing fields if becoming interesting. */ 328 332 Log2(("EXT: iInodeLostFound %#RX32\n", RT_LE2H_U32(pSb->iInodeLostFound))); 329 333 Log2(("EXT: iInodeProjQuota %#RX32\n", RT_LE2H_U32(pSb->iInodeProjQuota))); 330 334 Log2(("EXT: u32ChksumSeed %#RX32\n", RT_LE2H_U32(pSb->u32ChksumSeed))); 331 Log2(("EXT: [...]\n")); /** @todo :Missing fields if becoming interesting. */335 Log2(("EXT: [...]\n")); /** @todo Missing fields if becoming interesting. */ 332 336 Log2(("EXT: u32Chksum %#RX32\n", RT_LE2H_U32(pSb->u32Chksum))); 333 337 } … … 797 801 rtFsExtInode_Log(pThis, iInode, &Inode); 798 802 #endif 799 /** @todo Fill in data. */ 803 pInode->offInode = offRead; 804 pInode->fFlags = RT_LE2H_U32(Inode.Core.fFlags); 805 pInode->ObjInfo.cbObject = (uint64_t)RT_LE2H_U32(Inode.Core.cbSizeHigh) << 32 806 | (uint64_t)RT_LE2H_U32(Inode.Core.cbSizeLow); 807 pInode->ObjInfo.cbAllocated = ( (uint64_t)RT_LE2H_U16(Inode.Core.Osd2.Lnx.cBlocksHigh) << 32 808 | (uint64_t)RT_LE2H_U32(Inode.Core.cBlocksLow)) * pThis->cbBlock; 809 RTTimeSpecSetSeconds(&pInode->ObjInfo.AccessTime, RT_LE2H_U32(Inode.Core.u32TimeLastAccess)); 810 RTTimeSpecSetSeconds(&pInode->ObjInfo.ModificationTime, RT_LE2H_U32(Inode.Core.u32TimeLastModification)); 811 RTTimeSpecSetSeconds(&pInode->ObjInfo.ChangeTime, RT_LE2H_U32(Inode.Core.u32TimeLastChange)); 812 pInode->ObjInfo.Attr.enmAdditional = RTFSOBJATTRADD_UNIX; 813 pInode->ObjInfo.Attr.u.Unix.uid = (uint32_t)RT_LE2H_U16(Inode.Core.Osd2.Lnx.uUidHigh) << 16 814 | (uint32_t)RT_LE2H_U16(Inode.Core.uUidLow); 815 pInode->ObjInfo.Attr.u.Unix.gid = (uint32_t)RT_LE2H_U16(Inode.Core.Osd2.Lnx.uGidHigh) << 16 816 | (uint32_t)RT_LE2H_U16(Inode.Core.uGidLow); 817 pInode->ObjInfo.Attr.u.Unix.cHardlinks = RT_LE2H_U16(Inode.Core.cHardLinks); 818 pInode->ObjInfo.Attr.u.Unix.INodeIdDevice = 0; 819 pInode->ObjInfo.Attr.u.Unix.INodeId = iInode; 820 pInode->ObjInfo.Attr.u.Unix.fFlags = 0; 821 pInode->ObjInfo.Attr.u.Unix.GenerationId = RT_LE2H_U32(Inode.Core.u32Version); 822 pInode->ObjInfo.Attr.u.Unix.Device = 0; 823 if (pThis->cbInode >= sizeof(EXTINODECOMB)) 824 RTTimeSpecSetSeconds(&pInode->ObjInfo.BirthTime, RT_LE2H_U32(Inode.Extra.u32TimeCreation)); 825 else 826 RTTimeSpecSetSeconds(&pInode->ObjInfo.BirthTime, RT_LE2H_U32(Inode.Core.u32TimeLastChange)); 827 for (unsigned i = 0; i < RT_ELEMENTS(pInode->aiBlocks); i++) 828 pInode->aiBlocks[i] = RT_LE2H_U32(Inode.Core.au32Block[i]); 829 830 /* Fill in the mode. */ 831 pInode->ObjInfo.Attr.fMode = 0; 832 uint32_t fInodeMode = RT_LE2H_U32(Inode.Core.fMode); 833 switch (EXT_INODE_MODE_TYPE_GET_TYPE(fInodeMode)) 834 { 835 case EXT_INODE_MODE_TYPE_FIFO: 836 pInode->ObjInfo.Attr.fMode |= RTFS_TYPE_FIFO; 837 break; 838 case EXT_INODE_MODE_TYPE_CHAR: 839 pInode->ObjInfo.Attr.fMode |= RTFS_TYPE_DEV_CHAR; 840 break; 841 case EXT_INODE_MODE_TYPE_DIR: 842 pInode->ObjInfo.Attr.fMode |= RTFS_TYPE_DIRECTORY; 843 break; 844 case EXT_INODE_MODE_TYPE_BLOCK: 845 pInode->ObjInfo.Attr.fMode |= RTFS_TYPE_DEV_BLOCK; 846 break; 847 case EXT_INODE_MODE_TYPE_REGULAR: 848 pInode->ObjInfo.Attr.fMode |= RTFS_TYPE_FILE; 849 break; 850 case EXT_INODE_MODE_TYPE_SYMLINK: 851 pInode->ObjInfo.Attr.fMode |= RTFS_TYPE_SYMLINK; 852 break; 853 case EXT_INODE_MODE_TYPE_SOCKET: 854 pInode->ObjInfo.Attr.fMode |= RTFS_TYPE_SOCKET; 855 break; 856 default: 857 rc = VERR_VFS_BOGUS_FORMAT; 858 } 859 if (fInodeMode & EXT_INODE_MODE_EXEC_OTHER) 860 pInode->ObjInfo.Attr.fMode |= RTFS_UNIX_IXOTH; 861 if (fInodeMode & EXT_INODE_MODE_WRITE_OTHER) 862 pInode->ObjInfo.Attr.fMode |= RTFS_UNIX_IWOTH; 863 if (fInodeMode & EXT_INODE_MODE_READ_OTHER) 864 pInode->ObjInfo.Attr.fMode |= RTFS_UNIX_IROTH; 865 if (fInodeMode & EXT_INODE_MODE_EXEC_GROUP) 866 pInode->ObjInfo.Attr.fMode |= RTFS_UNIX_IXGRP; 867 if (fInodeMode & EXT_INODE_MODE_WRITE_GROUP) 868 pInode->ObjInfo.Attr.fMode |= RTFS_UNIX_IWGRP; 869 if (fInodeMode & EXT_INODE_MODE_READ_GROUP) 870 pInode->ObjInfo.Attr.fMode |= RTFS_UNIX_IRGRP; 871 if (fInodeMode & EXT_INODE_MODE_EXEC_OWNER) 872 pInode->ObjInfo.Attr.fMode |= RTFS_UNIX_IXUSR; 873 if (fInodeMode & EXT_INODE_MODE_WRITE_OWNER) 874 pInode->ObjInfo.Attr.fMode |= RTFS_UNIX_IWUSR; 875 if (fInodeMode & EXT_INODE_MODE_READ_OWNER) 876 pInode->ObjInfo.Attr.fMode |= RTFS_UNIX_IRUSR; 877 if (fInodeMode & EXT_INODE_MODE_STICKY) 878 pInode->ObjInfo.Attr.fMode |= RTFS_UNIX_ISTXT; 879 if (fInodeMode & EXT_INODE_MODE_SET_GROUP_ID) 880 pInode->ObjInfo.Attr.fMode |= RTFS_UNIX_ISGID; 881 if (fInodeMode & EXT_INODE_MODE_SET_USER_ID) 882 pInode->ObjInfo.Attr.fMode |= RTFS_UNIX_ISUID; 800 883 } 801 884 } … … 839 922 840 923 924 /** 925 * Worker for various QueryInfo methods. 926 * 927 * @returns IPRT status code. 928 * @param pInode The inode structure to return info for. 929 * @param pObjInfo Where to return object info. 930 * @param enmAddAttr What additional info to return. 931 */ 932 static int rtFsExtInode_QueryInfo(PRTFSEXTINODE pInode, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAddAttr) 933 { 934 RT_ZERO(*pObjInfo); 935 936 pObjInfo->cbObject = pInode->ObjInfo.cbObject; 937 pObjInfo->cbAllocated = pInode->ObjInfo.cbAllocated; 938 pObjInfo->AccessTime = pInode->ObjInfo.AccessTime; 939 pObjInfo->ModificationTime = pInode->ObjInfo.ModificationTime; 940 pObjInfo->ChangeTime = pInode->ObjInfo.ChangeTime; 941 pObjInfo->BirthTime = pInode->ObjInfo.BirthTime; 942 pObjInfo->Attr.fMode = pInode->ObjInfo.Attr.fMode; 943 pObjInfo->Attr.enmAdditional = enmAddAttr; 944 switch (enmAddAttr) 945 { 946 case RTFSOBJATTRADD_UNIX: 947 memcpy(&pObjInfo->Attr.u.Unix, &pInode->ObjInfo.Attr.u.Unix, sizeof(pInode->ObjInfo.Attr.u.Unix)); 948 break; 949 950 case RTFSOBJATTRADD_UNIX_OWNER: 951 pObjInfo->Attr.u.UnixOwner.uid = pInode->ObjInfo.Attr.u.Unix.uid; 952 break; 953 954 case RTFSOBJATTRADD_UNIX_GROUP: 955 pObjInfo->Attr.u.UnixGroup.gid = pInode->ObjInfo.Attr.u.Unix.gid; 956 break; 957 958 default: 959 break; 960 } 961 962 return VINF_SUCCESS; 963 } 964 965 841 966 /* 842 967 * … … 854 979 PRTFSEXTDIR pThis = (PRTFSEXTDIR)pvThis; 855 980 LogFlowFunc(("pThis=%p\n", pThis)); 856 RT_NOREF(pThis); 981 rtFsExtInodeRelease(pThis->pVol, pThis->pInode); 982 pThis->pInode = NULL; 857 983 return VINF_SUCCESS; 858 984 } … … 866 992 PRTFSEXTDIR pThis = (PRTFSEXTDIR)pvThis; 867 993 LogFlowFunc(("\n")); 868 RT_NOREF(pThis, pObjInfo, enmAddAttr); 869 return VERR_NOT_IMPLEMENTED; 994 return rtFsExtInode_QueryInfo(pThis->pInode, pObjInfo, enmAddAttr); 870 995 } 871 996 … … 1074 1199 int rc = rtFsExtInodeLoad(pThis, iInode, &pInode); 1075 1200 if (RT_SUCCESS(rc)) 1076 rtFsExtInodeRelease(pThis, pInode); 1201 { 1202 if (RTFS_IS_DIRECTORY(pInode->ObjInfo.Attr.fMode)) 1203 { 1204 PRTFSEXTDIR pNewDir; 1205 rc = RTVfsNewDir(&g_rtFsExtDirOps, sizeof(*pNewDir), 0 /*fFlags*/, pThis->hVfsSelf, NIL_RTVFSLOCK, 1206 phVfsDir, (void **)&pNewDir); 1207 if (RT_SUCCESS(rc)) 1208 { 1209 pNewDir->fNoMoreFiles = false; 1210 pNewDir->pVol = pThis; 1211 pNewDir->pInode = pInode; 1212 } 1213 } 1214 else 1215 rc = VERR_VFS_BOGUS_FORMAT; 1216 1217 if (RT_FAILURE(rc)) 1218 rtFsExtInodeRelease(pThis, pInode); 1219 } 1220 1077 1221 RT_NOREF(phVfsDir, g_rtFsExtDirOps); 1078 1222 return rc; … … 1100 1244 static bool rtFsExtIsBlockRangeInUse(PRTFSEXTBLKGRP pBlkGrpDesc, uint64_t iBlockStart, size_t cBlocks) 1101 1245 { 1102 /** @todo :Optimize with ASMBitFirstSet(). */1246 /** @todo Optimize with ASMBitFirstSet(). */ 1103 1247 while (cBlocks) 1104 1248 {
Note:
See TracChangeset
for help on using the changeset viewer.