Changeset 3485 for trunk/src/lib


Ignore:
Timestamp:
Sep 21, 2020, 2:25:08 PM (5 years ago)
Author:
bird
Message:

lib/nt/ntstat.h|c: Forgot to commit birdStatModeOnly the other day.

Location:
trunk/src/lib/nt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/nt/ntstat.c

    r3223 r3485  
    10041004}
    10051005
    1006 
    1007 
     1006/**
     1007 * Special function for getting the file mode.
     1008 */
     1009int birdStatModeOnly(const char *pszPath, unsigned __int16 *pMode, int fFollowLink)
     1010{
     1011    /*
     1012     * Convert the path and call NtQueryFullAttributesFile.
     1013     */
     1014    MY_UNICODE_STRING  NtPath;
     1015
     1016    birdResolveImports();
     1017    if (birdDosToNtPath(pszPath, &NtPath) == 0)
     1018    {
     1019        MY_OBJECT_ATTRIBUTES                ObjAttr;
     1020        MY_FILE_BASIC_INFORMATION           Info;
     1021        MY_NTSTATUS                         rcNt;
     1022
     1023        memset(&Info, 0xfe, sizeof(Info));
     1024
     1025        MyInitializeObjectAttributes(&ObjAttr, &NtPath, OBJ_CASE_INSENSITIVE, NULL /*hRoot*/, NULL /*pSecAttr*/);
     1026        rcNt = g_pfnNtQueryAttributesFile(&ObjAttr, &Info);
     1027
     1028        if (MY_NT_SUCCESS(rcNt))
     1029        {
     1030            unsigned __int8 isdirsymlink = 0;
     1031            unsigned __int8 ismountpoint = 0;
     1032            *pMode = birdFileInfoToMode(Info.FileAttributes, 0, pszPath, NtPath.Buffer, NtPath.Length,
     1033                                        &isdirsymlink, &ismountpoint);
     1034
     1035            /* Do the trailing slash check. */
     1036            if (   (Info.FileAttributes & FILE_ATTRIBUTE_DIRECTORY)
     1037                || !birdIsPathDirSpec(pszPath))
     1038            {
     1039                if (   !(Info.FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
     1040                    || !fFollowLink)
     1041                {
     1042                    birdFreeNtPath(&NtPath);
     1043                    return 0;
     1044                }
     1045
     1046                /* Fallback on birdStatOnlyInternal to follow the reparse point.  */
     1047                if (!birdStatOnlyInternal(pszPath, fFollowLink, &Info))
     1048                {
     1049                    *pMode = birdFileInfoToMode(Info.FileAttributes, 0, pszPath, NtPath.Buffer, NtPath.Length,
     1050                                                &isdirsymlink, &ismountpoint);
     1051                    birdFreeNtPath(&NtPath);
     1052                    return 0;
     1053                }
     1054            }
     1055            else
     1056                errno = ENOTDIR;
     1057        }
     1058        else
     1059            birdSetErrnoFromNt(rcNt);
     1060        birdFreeNtPath(&NtPath);
     1061    }
     1062    return -1;
     1063}
     1064
     1065
  • trunk/src/lib/nt/ntstat.h

    r3007 r3485  
    8686int birdStatOnFdJustSize(int fd, __int64 *pcbFile);
    8787int birdStatModTimeOnly(const char *pszPath, BirdTimeSpec_T *pTimeSpec, int fFollowLink);
     88int birdStatModeOnly(const char *pszPath, unsigned __int16 *pMode, int fFollowLink);
    8889#ifdef ___nt_ntstuff_h
    8990int  birdStatHandle(HANDLE hFile, BirdStat_T *pStat, const char *pszPath);
Note: See TracChangeset for help on using the changeset viewer.