Changeset 2856 in kBuild
- Timestamp:
- Sep 1, 2016 2:42:08 AM (9 years ago)
- Location:
- trunk/src
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/Makefile.kmk
r2845 r2856 221 221 commands.c \ 222 222 default.c \ 223 dir.c \224 223 expand.c \ 225 224 file.c \ … … 242 241 kbuild.c \ 243 242 kbuild-object.c 243 ifeq ($(KBUILD_TARGET),win) 244 kmk_SOURCES += dir-nt-bird.c 245 else 246 kmk_SOURCES += dir.c 247 endif 244 248 245 249 kmk_SOURCES.win = \ -
trunk/src/kmk/kmkbuiltin/kDepIDB.c
r2413 r2856 42 42 # include <io.h> 43 43 #endif 44 #include " ../../lib/k/kDefs.h"45 #include " ../../lib/k/kTypes.h"46 #include " ../../lib/kDep.h"44 #include "k/kDefs.h" 45 #include "k/kTypes.h" 46 #include "kDep.h" 47 47 #include "kmkbuiltin.h" 48 48 -
trunk/src/kmk/kmkbuiltin/kDepObj.c
r2804 r2856 44 44 # include <io.h> 45 45 #endif 46 #include " ../../lib/k/kDefs.h"47 #include " ../../lib/k/kTypes.h"48 #include " ../../lib/k/kLdrFmts/pe.h"49 #include " ../../lib/kDep.h"46 #include "k/kDefs.h" 47 #include "k/kTypes.h" 48 #include "k/kLdrFmts/pe.h" 49 #include "kDep.h" 50 50 #include "kmkbuiltin.h" 51 51 -
trunk/src/lib/Makefile.kmk
r2854 r2856 51 51 nt/ntstat.c \ 52 52 nt/ntunlink.c \ 53 nt/kFsCache.c 53 nt/kFsCache.c \ 54 kStuff/kHlp/CRT/kHlpCRTString.cpp \ 55 kStuff/kHlp/CRT/kHlpCRTAlloc.cpp 54 56 kUtil_SOURCES.solaris = \ 55 57 restartable-syscall-wrappers.c -
trunk/src/lib/nt/kFsCache.c
r2855 r2856 652 652 pCache->cbObjects += 16 * sizeof(pParent->papChildren[0]); 653 653 } 654 pParent->papChildren[pParent->cChildren++] = pChild;654 pParent->papChildren[pParent->cChildren++] = kFsCacheObjRetainInternal(pChild); 655 655 return K_TRUE; 656 656 } … … 688 688 * Allocate the object. 689 689 */ 690 KBOOL const fDirish = bObjType != KFSOBJ_TYPE_FILE && bObjType == KFSOBJ_TYPE_OTHER;691 KSIZE const cbObj = (fDirish ? sizeof(KFSDIR) : sizeof(KFSOBJ))692 +(cwcName + 1) * sizeof(wchar_t) + cchName + 1690 KBOOL const fDirish = bObjType != KFSOBJ_TYPE_FILE && bObjType != KFSOBJ_TYPE_OTHER; 691 KSIZE const cbObj = fDirish ? sizeof(KFSDIR) : sizeof(KFSOBJ); 692 KSIZE const cbNames = (cwcName + 1) * sizeof(wchar_t) + cchName + 1 693 693 #ifdef KFSCACHE_CFG_SHORT_NAMES 694 694 + (cwcShortName > 0 ? (cwcShortName + 1) * sizeof(wchar_t) + cchShortName + 1 : 0) … … 698 698 kHlpAssert(pCache->u32Magic == KFSCACHE_MAGIC); 699 699 700 pObj = (PKFSOBJ)kHlpAlloc(cbObj );700 pObj = (PKFSOBJ)kHlpAlloc(cbObj + cbNames); 701 701 if (pObj) 702 702 { 703 KU8 *pbExtra = (KU8 *) (pObj + 1);704 705 pCache->cbObjects += cbObj ;703 KU8 *pbExtra = (KU8 *)pObj + cbObj; 704 705 pCache->cbObjects += cbObj + cbNames; 706 706 pCache->cObjects++; 707 707 … … 723 723 pObj->cwcParent = pParent->Obj.cwcParent + pParent->Obj.cwcName + !!pParent->Obj.cwcName; 724 724 pObj->pwszName = (wchar_t *)kHlpMemCopy(pbExtra, pwszName, cwcName * sizeof(wchar_t)); 725 pObj->cwcName = cwcName; 725 726 pbExtra += cwcName * sizeof(wchar_t); 726 727 *pbExtra++ = '\0'; … … 731 732 { 732 733 pObj->pwszShortName = (wchar_t *)kHlpMemCopy(pbExtra, pwszShortName, cwcShortName * sizeof(wchar_t)); 734 pObj->cwcShortName = cwcShortName; 733 735 pbExtra += cwcShortName * sizeof(wchar_t); 734 736 *pbExtra++ = '\0'; … … 738 740 { 739 741 pObj->pwszShortName = pObj->pwszName; 740 pObj->cwcShortName = pObj->cwcName;742 pObj->cwcShortName = cwcName; 741 743 } 742 744 # endif … … 744 746 pObj->cchParent = pParent->Obj.cchParent + pParent->Obj.cchName + !!pParent->Obj.cchName; 745 747 pObj->pszName = (char *)kHlpMemCopy(pbExtra, pszName, cchName); 748 pObj->cchName = cchName; 746 749 pbExtra += cchName; 747 750 *pbExtra++ = '\0'; … … 751 754 { 752 755 pObj->pszShortName = (char *)kHlpMemCopy(pbExtra, pszShortName, cchShortName); 756 pObj->cchShortName = cchShortName; 753 757 pbExtra += cchShortName; 754 758 *pbExtra++ = '\0'; … … 757 761 { 758 762 pObj->pszShortName = pObj->pszName; 759 pObj->cchShortName = pObj->cchName;763 pObj->cchShortName = cchName; 760 764 } 761 765 #endif … … 1087 1091 #endif 1088 1092 pCur->Stats.st_dev = pDir->uDevNo; 1093 pCur->fHaveStats = K_TRUE; 1089 1094 1090 1095 /* … … 1137 1142 1138 1143 if (rcNt == MY_STATUS_NO_MORE_FILES) 1144 { 1145 /* 1146 * Mark the directory as fully populated and up to date. 1147 */ 1148 pDir->fPopulated = K_TRUE; 1149 if (pDir->Obj.uCacheGen != KFSOBJ_CACHE_GEN_IGNORE) 1150 pDir->Obj.uCacheGen = pCache->uGeneration; 1139 1151 return K_TRUE; 1152 } 1153 1140 1154 kHlpAssertMsgFailed(("%#x\n", rcNt)); 1141 1155 *penmError = KFSLOOKUPERROR_DIR_READ_ERROR; … … 1266 1280 pDir->hDir = hDir; 1267 1281 1268 /* Get the device number. */ 1269 rcNt = birdQueryVolumeDeviceNumber(hDir, &uBuf.VolInfo, sizeof(uBuf), &pDir->uDevNo); 1270 kHlpAssertMsg(MY_NT_SUCCESS(rcNt), ("%#x\n", rcNt)); 1282 if (birdStatHandle(hDir, &pDir->Obj.Stats, pDir->Obj.pszName) == 0) 1283 { 1284 pDir->Obj.fHaveStats = K_TRUE; 1285 pDir->uDevNo = pDir->Obj.Stats.st_dev; 1286 } 1287 else 1288 { 1289 /* Just in case. */ 1290 pDir->Obj.fHaveStats = K_FALSE; 1291 rcNt = birdQueryVolumeDeviceNumber(hDir, &uBuf.VolInfo, sizeof(uBuf), &pDir->uDevNo); 1292 kHlpAssertMsg(MY_NT_SUCCESS(rcNt), ("%#x\n", rcNt)); 1293 } 1271 1294 1272 1295 /* Get the file system. */ … … 1598 1621 1599 1622 /** 1600 * Walk the file system tree for the given absolute path, entering it into the 1601 * hash table. 1623 * Walks an full path relative to the given directory, ANSI version. 1602 1624 * 1603 1625 * This will create any missing nodes while walking. … … 1608 1630 * NULL on lookup failure, see @a penmError for details. 1609 1631 * @param pCache The cache. 1632 * @param pParent The directory to start the lookup in. 1610 1633 * @param pszPath The path to walk. 1611 1634 * @param cchPath The length of the path. … … 1613 1636 * failed. 1614 1637 */ 1615 static PKFSOBJ kFsCacheLookupAbsoluteA(PKFSCACHE pCache, const char *pszPath, KU32 cchPath, KFSLOOKUPERROR *penmError) 1616 { 1617 PKFSDIR pParent = &pCache->RootDir; 1618 PKFSOBJ pChild; 1619 KU32 off; 1620 KU32 cchSlashes; 1621 KU32 offEnd; 1622 1623 KFSCACHE_LOG(("kFsCacheLookupAbsoluteA(%s)\n", pszPath)); 1624 1625 /* 1626 * The root "directory" needs special handling, so we keep it outside the 1627 * main search loop. (Special: Cannot enumerate it, UNCs, ++.) 1628 */ 1629 cchSlashes = 0; 1630 off = 0; 1631 if ( pszPath[1] == ':' 1632 && IS_ALPHA(pszPath[0])) 1633 { 1634 /* Drive letter. */ 1635 offEnd = 2; 1636 kHlpAssert(IS_SLASH(pszPath[2])); 1637 pChild = kFswCacheLookupDrive(pCache, toupper(pszPath[0]), penmError); 1638 } 1639 else if ( IS_SLASH(pszPath[0]) 1640 && IS_SLASH(pszPath[1]) ) 1641 pChild = kFswCacheLookupUncShareA(pCache, pszPath, &offEnd, penmError); 1642 else 1643 { 1644 *penmError = KFSLOOKUPERROR_UNSUPPORTED; 1645 return NULL; 1646 } 1647 if (pChild) 1648 { /* likely */ } 1649 else 1650 return NULL; 1651 1652 /* Count slashes trailing the root spec. */ 1653 if (offEnd < cchPath) 1654 { 1655 kHlpAssert(IS_SLASH(pszPath[offEnd])); 1656 do 1657 cchSlashes++; 1658 while (IS_SLASH(pszPath[offEnd + cchSlashes])); 1659 } 1660 1661 /* Done already? */ 1662 if (offEnd >= cchPath) 1663 { 1664 if ( pChild->uCacheGen == KFSOBJ_CACHE_GEN_IGNORE 1665 || pChild->uCacheGen == (pChild->bObjType != KFSOBJ_TYPE_MISSING ? pCache->uGeneration : pCache->uGenerationMissing) 1666 || kFsCacheRefreshObj(pCache, pChild, penmError)) 1667 return kFsCacheObjRetainInternal(pChild); 1668 return NULL; 1669 } 1670 1671 /* Check that we've got a valid result and not a cached negative one. */ 1672 if (pChild->bObjType == KFSOBJ_TYPE_DIR) 1673 { /* likely */ } 1674 else 1675 { 1676 kHlpAssert(pChild->bObjType == KFSOBJ_TYPE_MISSING); 1677 kHlpAssert(pChild->uCacheGen == KFSOBJ_CACHE_GEN_IGNORE || pChild->uCacheGen == pCache->uGenerationMissing); 1678 return pChild; 1679 } 1680 1681 /* Next component. */ 1682 pParent = (PKFSDIR)pChild; 1683 off = offEnd + cchSlashes; 1684 1685 1638 PKFSOBJ kFsCacheLookupRelativeToDirA(PKFSCACHE pCache, PKFSDIR pParent, const char *pszPath, KU32 cchPath, 1639 KFSLOOKUPERROR *penmError) 1640 { 1686 1641 /* 1687 1642 * Walk loop. 1688 1643 */ 1644 KU32 off = 0; 1689 1645 for (;;) 1690 1646 { 1647 PKFSOBJ pChild; 1648 1691 1649 /* 1692 1650 * Find the end of the component, counting trailing slashes. 1693 1651 */ 1694 char ch;1695 cchSlashes = 0;1696 offEnd = off + 1;1652 char ch; 1653 KU32 cchSlashes = 0; 1654 KU32 offEnd = off + 1; 1697 1655 while ((ch = pszPath[offEnd]) != '\0') 1698 1656 { … … 1736 1694 { 1737 1695 if (pChild) 1738 return pChild;1696 return kFsCacheObjRetainInternal(pChild); 1739 1697 *penmError = KFSLOOKUPERROR_NOT_FOUND; 1740 1698 } … … 1756 1714 else 1757 1715 return NULL; 1758 return pChild;1716 return kFsCacheObjRetainInternal(pChild); 1759 1717 } 1760 1718 … … 1783 1741 1784 1742 return NULL; 1785 } 1786 1787 1788 /** 1789 * Walk the file system tree for the given absolute path, UTF-16 version. 1743 1744 } 1745 1746 1747 /** 1748 * Walks an full path relative to the given directory, UTF-16 version. 1790 1749 * 1791 1750 * This will create any missing nodes while walking. … … 1796 1755 * NULL on lookup failure, see @a penmError for details. 1797 1756 * @param pCache The cache. 1798 * @param pwszPath The path to walk. 1799 * @param cwcPath The length of the path (in wchar_t's). 1757 * @param pParent The directory to start the lookup in. 1758 * @param pszPath The path to walk. No dot-dot bits allowed! 1759 * @param cchPath The length of the path. 1800 1760 * @param penmError Where to return details as to why the lookup 1801 1761 * failed. 1802 1762 */ 1803 static PKFSOBJ kFsCacheLookupAbsoluteW(PKFSCACHE pCache, const wchar_t *pwszPath, KU32 cwcPath, KFSLOOKUPERROR *penmError) 1804 { 1805 PKFSDIR pParent = &pCache->RootDir; 1806 PKFSOBJ pChild; 1807 KU32 off; 1808 KU32 cwcSlashes; 1809 KU32 offEnd; 1810 1811 KFSCACHE_LOG(("kFsCacheLookupAbsoluteW(%ls)\n", pwszPath)); 1812 1813 /* 1814 * The root "directory" needs special handling, so we keep it outside the 1815 * main search loop. (Special: Cannot enumerate it, UNCs, ++.) 1816 */ 1817 cwcSlashes = 0; 1818 off = 0; 1819 if ( pwszPath[1] == ':' 1820 && IS_ALPHA(pwszPath[0])) 1821 { 1822 /* Drive letter. */ 1823 offEnd = 2; 1824 kHlpAssert(IS_SLASH(pwszPath[2])); 1825 pChild = kFswCacheLookupDrive(pCache, toupper(pwszPath[0]), penmError); 1826 } 1827 else if ( IS_SLASH(pwszPath[0]) 1828 && IS_SLASH(pwszPath[1]) ) 1829 pChild = kFswCacheLookupUncShareW(pCache, pwszPath, &offEnd, penmError); 1830 else 1831 { 1832 *penmError = KFSLOOKUPERROR_UNSUPPORTED; 1833 return NULL; 1834 } 1835 if (pChild) 1836 { /* likely */ } 1837 else 1838 return NULL; 1839 1840 /* Count slashes trailing the root spec. */ 1841 if (offEnd < cwcPath) 1842 { 1843 kHlpAssert(IS_SLASH(pwszPath[offEnd])); 1844 do 1845 cwcSlashes++; 1846 while (IS_SLASH(pwszPath[offEnd + cwcSlashes])); 1847 } 1848 1849 /* Done already? */ 1850 if (offEnd >= cwcPath) 1851 { 1852 if ( pChild->uCacheGen == KFSOBJ_CACHE_GEN_IGNORE 1853 || pChild->uCacheGen == (pChild->bObjType != KFSOBJ_TYPE_MISSING ? pCache->uGeneration : pCache->uGenerationMissing) 1854 || kFsCacheRefreshObj(pCache, pChild, penmError)) 1855 return kFsCacheObjRetainInternal(pChild); 1856 return NULL; 1857 } 1858 1859 /* Check that we've got a valid result and not a cached negative one. */ 1860 if (pChild->bObjType == KFSOBJ_TYPE_DIR) 1861 { /* likely */ } 1862 else 1863 { 1864 kHlpAssert(pChild->bObjType == KFSOBJ_TYPE_MISSING); 1865 kHlpAssert(pChild->uCacheGen == KFSOBJ_CACHE_GEN_IGNORE || pChild->uCacheGen == pCache->uGenerationMissing); 1866 return pChild; 1867 } 1868 1869 /* Next component. */ 1870 pParent = (PKFSDIR)pChild; 1871 off = offEnd + cwcSlashes; 1872 1873 1763 PKFSOBJ kFsCacheLookupRelativeToDirW(PKFSCACHE pCache, PKFSDIR pParent, const wchar_t *pwszPath, KU32 cwcPath, 1764 KFSLOOKUPERROR *penmError) 1765 { 1874 1766 /* 1875 1767 * Walk loop. 1876 1768 */ 1769 KU32 off = 0; 1877 1770 for (;;) 1878 1771 { 1772 PKFSOBJ pChild; 1773 1879 1774 /* 1880 1775 * Find the end of the component, counting trailing slashes. 1881 1776 */ 1882 1777 wchar_t wc; 1883 cwcSlashes = 0;1884 offEnd = off + 1;1778 KU32 cwcSlashes = 0; 1779 KU32 offEnd = off + 1; 1885 1780 while ((wc = pwszPath[offEnd]) != '\0') 1886 1781 { … … 1924 1819 { 1925 1820 if (pChild) 1926 return pChild;1821 return kFsCacheObjRetainInternal(pChild); 1927 1822 *penmError = KFSLOOKUPERROR_NOT_FOUND; 1928 1823 } … … 1944 1839 else 1945 1840 return NULL; 1946 return pChild;1841 return kFsCacheObjRetainInternal(pChild); 1947 1842 } 1948 1843 … … 1971 1866 1972 1867 return NULL; 1868 1869 } 1870 1871 /** 1872 * Walk the file system tree for the given absolute path, entering it into the 1873 * hash table. 1874 * 1875 * This will create any missing nodes while walking. 1876 * 1877 * The caller will have to do the path hash table insertion of the result. 1878 * 1879 * @returns Pointer to the tree node corresponding to @a pszPath. 1880 * NULL on lookup failure, see @a penmError for details. 1881 * @param pCache The cache. 1882 * @param pszPath The path to walk. No dot-dot bits allowed! 1883 * @param cchPath The length of the path. 1884 * @param penmError Where to return details as to why the lookup 1885 * failed. 1886 */ 1887 static PKFSOBJ kFsCacheLookupAbsoluteA(PKFSCACHE pCache, const char *pszPath, KU32 cchPath, KFSLOOKUPERROR *penmError) 1888 { 1889 PKFSOBJ pChild; 1890 KU32 cchSlashes; 1891 KU32 offEnd; 1892 1893 KFSCACHE_LOG(("kFsCacheLookupAbsoluteA(%s)\n", pszPath)); 1894 1895 /* 1896 * The root "directory" needs special handling, so we keep it outside the 1897 * main search loop. (Special: Cannot enumerate it, UNCs, ++.) 1898 */ 1899 cchSlashes = 0; 1900 if ( pszPath[1] == ':' 1901 && IS_ALPHA(pszPath[0])) 1902 { 1903 /* Drive letter. */ 1904 offEnd = 2; 1905 kHlpAssert(IS_SLASH(pszPath[2])); 1906 pChild = kFswCacheLookupDrive(pCache, toupper(pszPath[0]), penmError); 1907 } 1908 else if ( IS_SLASH(pszPath[0]) 1909 && IS_SLASH(pszPath[1]) ) 1910 pChild = kFswCacheLookupUncShareA(pCache, pszPath, &offEnd, penmError); 1911 else 1912 { 1913 *penmError = KFSLOOKUPERROR_UNSUPPORTED; 1914 return NULL; 1915 } 1916 if (pChild) 1917 { /* likely */ } 1918 else 1919 return NULL; 1920 1921 /* Count slashes trailing the root spec. */ 1922 if (offEnd < cchPath) 1923 { 1924 kHlpAssert(IS_SLASH(pszPath[offEnd])); 1925 do 1926 cchSlashes++; 1927 while (IS_SLASH(pszPath[offEnd + cchSlashes])); 1928 } 1929 1930 /* Done already? */ 1931 if (offEnd >= cchPath) 1932 { 1933 if ( pChild->uCacheGen == KFSOBJ_CACHE_GEN_IGNORE 1934 || pChild->uCacheGen == (pChild->bObjType != KFSOBJ_TYPE_MISSING ? pCache->uGeneration : pCache->uGenerationMissing) 1935 || kFsCacheRefreshObj(pCache, pChild, penmError)) 1936 return kFsCacheObjRetainInternal(pChild); 1937 return NULL; 1938 } 1939 1940 /* Check that we've got a valid result and not a cached negative one. */ 1941 if (pChild->bObjType == KFSOBJ_TYPE_DIR) 1942 { /* likely */ } 1943 else 1944 { 1945 kHlpAssert(pChild->bObjType == KFSOBJ_TYPE_MISSING); 1946 kHlpAssert(pChild->uCacheGen == KFSOBJ_CACHE_GEN_IGNORE || pChild->uCacheGen == pCache->uGenerationMissing); 1947 return pChild; 1948 } 1949 1950 /* 1951 * Now that we've found a valid root directory, lookup the 1952 * remainder of the path starting with it. 1953 */ 1954 return kFsCacheLookupRelativeToDirA(pCache, (PKFSDIR)pChild, &pszPath[offEnd + cchSlashes], 1955 cchPath - offEnd - cchSlashes, penmError); 1956 } 1957 1958 1959 /** 1960 * Walk the file system tree for the given absolute path, UTF-16 version. 1961 * 1962 * This will create any missing nodes while walking. 1963 * 1964 * The caller will have to do the path hash table insertion of the result. 1965 * 1966 * @returns Pointer to the tree node corresponding to @a pszPath. 1967 * NULL on lookup failure, see @a penmError for details. 1968 * @param pCache The cache. 1969 * @param pwszPath The path to walk. 1970 * @param cwcPath The length of the path (in wchar_t's). 1971 * @param penmError Where to return details as to why the lookup 1972 * failed. 1973 */ 1974 static PKFSOBJ kFsCacheLookupAbsoluteW(PKFSCACHE pCache, const wchar_t *pwszPath, KU32 cwcPath, KFSLOOKUPERROR *penmError) 1975 { 1976 PKFSDIR pParent = &pCache->RootDir; 1977 PKFSOBJ pChild; 1978 KU32 off; 1979 KU32 cwcSlashes; 1980 KU32 offEnd; 1981 1982 KFSCACHE_LOG(("kFsCacheLookupAbsoluteW(%ls)\n", pwszPath)); 1983 1984 /* 1985 * The root "directory" needs special handling, so we keep it outside the 1986 * main search loop. (Special: Cannot enumerate it, UNCs, ++.) 1987 */ 1988 cwcSlashes = 0; 1989 off = 0; 1990 if ( pwszPath[1] == ':' 1991 && IS_ALPHA(pwszPath[0])) 1992 { 1993 /* Drive letter. */ 1994 offEnd = 2; 1995 kHlpAssert(IS_SLASH(pwszPath[2])); 1996 pChild = kFswCacheLookupDrive(pCache, toupper(pwszPath[0]), penmError); 1997 } 1998 else if ( IS_SLASH(pwszPath[0]) 1999 && IS_SLASH(pwszPath[1]) ) 2000 pChild = kFswCacheLookupUncShareW(pCache, pwszPath, &offEnd, penmError); 2001 else 2002 { 2003 *penmError = KFSLOOKUPERROR_UNSUPPORTED; 2004 return NULL; 2005 } 2006 if (pChild) 2007 { /* likely */ } 2008 else 2009 return NULL; 2010 2011 /* Count slashes trailing the root spec. */ 2012 if (offEnd < cwcPath) 2013 { 2014 kHlpAssert(IS_SLASH(pwszPath[offEnd])); 2015 do 2016 cwcSlashes++; 2017 while (IS_SLASH(pwszPath[offEnd + cwcSlashes])); 2018 } 2019 2020 /* Done already? */ 2021 if (offEnd >= cwcPath) 2022 { 2023 if ( pChild->uCacheGen == KFSOBJ_CACHE_GEN_IGNORE 2024 || pChild->uCacheGen == (pChild->bObjType != KFSOBJ_TYPE_MISSING ? pCache->uGeneration : pCache->uGenerationMissing) 2025 || kFsCacheRefreshObj(pCache, pChild, penmError)) 2026 return kFsCacheObjRetainInternal(pChild); 2027 return NULL; 2028 } 2029 2030 /* Check that we've got a valid result and not a cached negative one. */ 2031 if (pChild->bObjType == KFSOBJ_TYPE_DIR) 2032 { /* likely */ } 2033 else 2034 { 2035 kHlpAssert(pChild->bObjType == KFSOBJ_TYPE_MISSING); 2036 kHlpAssert(pChild->uCacheGen == KFSOBJ_CACHE_GEN_IGNORE || pChild->uCacheGen == pCache->uGenerationMissing); 2037 return pChild; 2038 } 2039 2040 /* 2041 * Now that we've found a valid root directory, lookup the 2042 * remainder of the path starting with it. 2043 */ 2044 return kFsCacheLookupRelativeToDirW(pCache, (PKFSDIR)pChild, &pwszPath[offEnd + cwcSlashes], 2045 cwcPath - offEnd - cwcSlashes, penmError); 1973 2046 } 1974 2047 … … 2313 2386 PKFSUSERDATA pUserData = pObj->pUserDataHead; 2314 2387 pObj->pUserDataHead = pUserData->pNext; 2315 pUserData->pfnDestructor(pCache, pObj, pUserData); 2388 if (pUserData->pfnDestructor) 2389 pUserData->pfnDestructor(pCache, pObj, pUserData); 2316 2390 kHlpFree(pUserData); 2317 2391 } … … 2413 2487 kHlpAssert(cRefs < 16384); 2414 2488 return cRefs; 2489 } 2490 2491 2492 /** 2493 * Associates an item of user data with the given object. 2494 * 2495 * If the data needs cleaning up before being free, set the 2496 * PKFSUSERDATA::pfnDestructor member of the returned structure. 2497 * 2498 * @returns Pointer to the user data on success. 2499 * NULL if out of memory or key already in use. 2500 * 2501 * @param pCache The cache. 2502 * @param pObj The object. 2503 * @param uKey The user data key. 2504 * @param cbUserData The size of the user data. 2505 */ 2506 PKFSUSERDATA kFsCacheObjAddUserData(PKFSCACHE pCache, PKFSOBJ pObj, KUPTR uKey, KSIZE cbUserData) 2507 { 2508 kHlpAssert(cbUserData >= sizeof(*pNew)); 2509 if (kFsCacheObjGetUserData(pCache, pObj, uKey) == NULL) 2510 { 2511 PKFSUSERDATA pNew = (PKFSUSERDATA)kHlpAllocZ(cbUserData); 2512 if (pNew) 2513 { 2514 pNew->uKey = uKey; 2515 pNew->pfnDestructor = NULL; 2516 pNew->pNext = pObj->pUserDataHead; 2517 pObj->pUserDataHead = pNew; 2518 return pNew; 2519 } 2520 } 2521 2522 return NULL; 2523 } 2524 2525 2526 /** 2527 * Retrieves an item of user data associated with the given object. 2528 * 2529 * @returns Pointer to the associated user data if found, otherwise NULL. 2530 * @param pCache The cache. 2531 * @param pObj The object. 2532 * @param uKey The user data key. 2533 */ 2534 PKFSUSERDATA kFsCacheObjGetUserData(PKFSCACHE pCache, PKFSOBJ pObj, KUPTR uKey) 2535 { 2536 PKFSUSERDATA pCur; 2537 2538 kHlpAssert(pCache->u32Magic == KFSCACHE_MAGIC); 2539 kHlpAssert(pObj->u32Magic == KFSOBJ_MAGIC); 2540 2541 for (pCur = pObj->pUserDataHead; pCur; pCur = pCur->pNext) 2542 if (pCur->uKey == uKey) 2543 return pCur; 2544 return NULL; 2415 2545 } 2416 2546 -
trunk/src/lib/nt/kFsCache.h
r2855 r2856 231 231 232 232 /** Handle to the directory (we generally keep it open). */ 233 #ifndef DECLARE_HANDLE 234 KUPTR hDir; 235 #else 233 236 HANDLE hDir; 237 #endif 234 238 /** The device number we queried/inherited when opening it. */ 235 239 KU64 uDevNo; … … 418 422 PKFSOBJ kFsCacheLookupA(PKFSCACHE pCache, const char *pszPath, KFSLOOKUPERROR *penmError); 419 423 PKFSOBJ kFsCacheLookupW(PKFSCACHE pCache, const wchar_t *pwszPath, KFSLOOKUPERROR *penmError); 424 PKFSOBJ kFsCacheLookupRelativeToDirA(PKFSCACHE pCache, PKFSDIR pParent, const char *pszPath, KU32 cchPath, 425 KFSLOOKUPERROR *penmError); 426 PKFSOBJ kFsCacheLookupRelativeToDirW(PKFSCACHE pCache, PKFSDIR pParent, const wchar_t *pwszPath, KU32 cwcPath, 427 KFSLOOKUPERROR *penmError); 420 428 421 429 KU32 kFsCacheObjRelease(PKFSCACHE pCache, PKFSOBJ pObj); 422 430 KU32 kFsCacheObjRetain(PKFSOBJ pObj); 431 PKFSUSERDATA kFsCacheObjAddUserData(PKFSCACHE pCache, PKFSOBJ pPathObj, KUPTR uKey, KSIZE cbUserData); 432 PKFSUSERDATA kFsCacheObjGetUserData(PKFSCACHE pCache, PKFSOBJ pPathObj, KUPTR uKey); 423 433 424 434 PKFSCACHE kFsCacheCreate(KU32 fFlags); -
trunk/src/lib/nt/ntstat.h
r2851 r2856 81 81 int birdStatModTimeOnly(const char *pszPath, BirdTimeSpec_T *pTimeSpec, int fFollowLink); 82 82 #ifdef ___nt_ntstuff_h 83 int birdStatHandle(HANDLE hFile, BirdStat_T *pStat, const char *pszPath); 83 84 void birdStatFillFromFileIdFullDirInfo(BirdStat_T *pStat, MY_FILE_ID_FULL_DIR_INFORMATION const *pBuf, const char *pszPath); 84 85 void birdStatFillFromFileIdBothDirInfo(BirdStat_T *pStat, MY_FILE_ID_BOTH_DIR_INFORMATION const *pBuf, const char *pszPath);
Note:
See TracChangeset
for help on using the changeset viewer.