/** @file
Implementation of the Posix access() function.
Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#include <ctype.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <sys/syslimits.h>
/** Save some typing later on. */
/** Determine accessibility of a file.
The access() function checks the file, named by the pathname pointed to by
the Path argument, for accessibility according to the bit pattern contained
in Mode.
The value of Mode is either the bitwise-inclusive OR of the access
permissions to be checked (R_OK, W_OK, X_OK) or the existence test (F_OK).
If Path ends in '/' or '\\', the target must be a directory, otherwise it doesn't matter.
A file is executable if it is NOT a directory and it ends in ".efi".
@param[in] Path Path or name of the file to be checked.
@param[in] Mode Access permissions to check for.
@retval 0 Successful completion.
@retval -1 File is not accessible with the given Mode. The error condition
is indicated by errno. Values of errno specific to the access
function include: EACCES, ENOENT, ENOTDIR, ENAMETOOLONG
**/
int
const char *Path,
int Mode
)
{
}
else {
}
else {
if(retval == 0) {
/* Path exists. FileStat now holds valid information. */
/* Test each permission individually. */
do {
if(DirMatch) { /* This is a directory or file as desired. */
retval = 0;
}
else {
/* Indicate why we failed the test. */
}
break; /* F_OK does not combine with any other tests. */
}
/* No read permissions.
For UEFI, everything should have READ permissions.
*/
break;
}
}
/* No write permissions. */
break;
}
}
/* In EDK II, executable files end in ".efi" */
/* File is not an executable. */
break;
}
}
retval = 0;
} while(FALSE);
}
else {
/* File or path does not exist. */
}
}
}
return retval;
}