Files

321 lines
9.1 KiB
C
Raw Permalink Normal View History

Use LF line endings in the repository Convert the line endings stored for all text files in the repository to LF. The majority previously used DOS-style CRLF line endings. Add a .gitattributes file to enforce this and treat certain extensions as never being text files. Update PatchCheck.py to insist on LF line endings rather than CRLF. However, its other checks fail on this commit due to lots of pre-existing complaints that it only notices because the line endings have changed. Silicon/QemuSocPkg/FspBin/Patches/0001-Build-QEMU-FSP-2.0-binaries.patch needs to be treated as binary since it contains a mixture of line endings. This change has implications depending on the client platform you are using the repository from: * Windows The usual configuration for Git on Windows means that text files will be checked out to the work tree with DOS-style CRLF line endings. If that's not the case then you can configure Git to do so for the entire machine with: git config --global core.autocrlf true or for just the repository with: git config core.autocrlf true Line endings will be normalised to LF when they are committed to the repository. If you commit a text file with only LF line endings then it will be converted to CRLF line endings in your work tree. * Linux, MacOS and other Unices The usual configuration for Git on such platforms is to check files out of the repository with LF line endings. This is probably the right thing for you. In the unlikely even that you are using Git on Unix but editing or compiling on Windows for some reason then you may need to tweak your configuration to force the use of CRLF line endings as described above. * General For more information see https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings . Fixes: https://github.com/slimbootloader/slimbootloader/issues/1400 Signed-off-by: Mike Crowe <mac@mcrowe.com>
2021-11-10 11:36:23 +00:00
/** @file
File system level API library interface prototypes
Copyright (c) 2017 - 2020, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#ifndef _FILE_SYSTEM_LIB_H_
#define _FILE_SYSTEM_LIB_H_
#include <Library/PartitionLib.h>
#include <Guid/OsBootOptionGuid.h>
/**
Initialize file systems.
@param[in] SwPart Software partition index.
@param[in] PartHandle Partition handle.
@param[out] FsHandle file system handle.
@retval EFI_SUCCESS The file system was initialized successfully.
@retval EFI_INVALID_PARAMETER Parameter is not valid.
@retval EFI_NOT_FOUND file system was not detected on this partition.
@retval EFI_OUT_OF_RESOURCES Insufficant memory resource pool.
**/
typedef
EFI_STATUS
(EFIAPI *FS_INIT_FILE_SYSTEM) (
IN UINT32 SwPart,
IN EFI_HANDLE PartHandle,
OUT EFI_HANDLE *FsHandle
);
/**
Clean-up allocated memory/etc. for file system
@param[in] FsHandle File system handle to clean-up.
@retval none
**/
typedef
VOID
(EFIAPI *FS_CLOSE_FILE_SYSTEM) (
IN EFI_HANDLE FsHandle
);
/**
Open a file by its name and return its file handle.
@param[in] FsHandle file system handle.
@param[in] FileName The file name to get.
@param[out] FileHandle file handle
@retval EFI_SUCCESS The file opened correctly.
@retval EFI_INVALID_PARAMETER Parameter is not valid.
@retval EFI_DEVICE_ERROR A device error occurred.
@retval EFI_NOT_FOUND A requested file cannot be found.
@retval EFI_OUT_OF_RESOURCES Insufficant memory resource pool.
**/
typedef
EFI_STATUS
(EFIAPI *FS_OPEN_FILE) (
IN EFI_HANDLE FsHandle,
IN CHAR16 *FileName,
OUT EFI_HANDLE *FileHandle
);
/**
Get file size by opened file handle.
@param[in] FileHandle file handle
@param[out] FileSize Pointer to file buffer size.
@retval EFI_SUCCESS The file was loaded correctly.
@retval EFI_INVALID_PARAMETER Parameter is not valid.
**/
typedef
EFI_STATUS
(EFIAPI *FS_GET_FILE_SIZE) (
IN EFI_HANDLE FileHandle,
OUT UINTN *FileSize
);
/**
Read file into memory by opened file handle.
@param[in] FsHandle file system handle.
@param[in] FileHandle file handle
@param[out] FileBufferPtr Allocated file buffer pointer.
@param[out] FileSize Pointer to file buffer size.
@retval EFI_SUCCESS The file was loaded correctly.
@retval EFI_INVALID_PARAMETER Parameter is not valid.
@retval EFI_DEVICE_ERROR A device error occurred.
@retval EFI_NOT_FOUND A requested file cannot be found.
@retval EFI_OUT_OF_RESOURCES Insufficant memory resource pool.
@retval EFI_BUFFER_TOO_SMALL Buffer size is too small.
**/
typedef
EFI_STATUS
(EFIAPI *FS_READ_FILE) (
IN EFI_HANDLE FsHandle,
IN EFI_HANDLE FileHandle,
OUT VOID *FileBuffer,
Use LF line endings in the repository Convert the line endings stored for all text files in the repository to LF. The majority previously used DOS-style CRLF line endings. Add a .gitattributes file to enforce this and treat certain extensions as never being text files. Update PatchCheck.py to insist on LF line endings rather than CRLF. However, its other checks fail on this commit due to lots of pre-existing complaints that it only notices because the line endings have changed. Silicon/QemuSocPkg/FspBin/Patches/0001-Build-QEMU-FSP-2.0-binaries.patch needs to be treated as binary since it contains a mixture of line endings. This change has implications depending on the client platform you are using the repository from: * Windows The usual configuration for Git on Windows means that text files will be checked out to the work tree with DOS-style CRLF line endings. If that's not the case then you can configure Git to do so for the entire machine with: git config --global core.autocrlf true or for just the repository with: git config core.autocrlf true Line endings will be normalised to LF when they are committed to the repository. If you commit a text file with only LF line endings then it will be converted to CRLF line endings in your work tree. * Linux, MacOS and other Unices The usual configuration for Git on such platforms is to check files out of the repository with LF line endings. This is probably the right thing for you. In the unlikely even that you are using Git on Unix but editing or compiling on Windows for some reason then you may need to tweak your configuration to force the use of CRLF line endings as described above. * General For more information see https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings . Fixes: https://github.com/slimbootloader/slimbootloader/issues/1400 Signed-off-by: Mike Crowe <mac@mcrowe.com>
2021-11-10 11:36:23 +00:00
OUT UINTN *FileSize
);
/**
Close a file by opened file handle
@param[in] FsHandle file system handle.
@param[in] FileHandle file handle
@retval none
**/
typedef
VOID
(EFIAPI *FS_CLOSE_FILE) (
IN EFI_HANDLE FileHandle
);
/**
List directories or files
@param[in] FsHandle file system handle.
@param[in] DirFilePath directory or file path
@retval EFI_SUCCESS list directories of files successfully
@retval EFI_UNSUPPORTED this api is not supported
@retval Others an error occurs
**/
typedef
EFI_STATUS
(EFIAPI *FS_LIST_DIR) (
IN EFI_HANDLE FsHandle,
IN CHAR16 *DirFilePath
);
/**
Get SW partition no. of detected file system
@param[in] FsHandle file system handle.
@param[out] SwPartNo sw part no.
@retval EFI_SUCCESS found sw part no.
@retval EFI_INVALID_PARAMETER Invalid FsHandle
**/
EFI_STATUS
EFIAPI
GetFileSystemCurrentPartNo (
IN EFI_HANDLE FsHandle,
OUT UINT32 *SwPartNo
);
/**
Get detected file system type
@param[in] FsHandle file system handle.
@retval OS_FILE_SYSTEM_TYPE file system type enum
**/
OS_FILE_SYSTEM_TYPE
EFIAPI
GetFileSystemType (
IN EFI_HANDLE FsHandle
);
/**
Initialize file systems.
@param[in] SwPart Software partition index.
@param[in] FsType Filesystem type.
@param[in] PartHandle Partition handle.
@param[out] FsHandle file system handle.
@retval EFI_SUCCESS The file system was initialized successfully.
@retval EFI_INVALID_PARAMETER Parameter is not valid.
@retval EFI_NOT_FOUND file system was not detected on this partition.
@retval EFI_OUT_OF_RESOURCES Insufficant memory resource pool.
**/
EFI_STATUS
EFIAPI
InitFileSystem (
IN UINT32 SwPart,
IN UINT32 FsType,
IN EFI_HANDLE PartHandle,
OUT EFI_HANDLE *FsHandle
);
/**
Clean-up allocated memory/etc. for file system
@param[in] FsHandle File system handle to clean-up.
@retval none
**/
VOID
EFIAPI
CloseFileSystem (
IN EFI_HANDLE FsHandle
);
/**
Open a file by its name and return its file handle.
@param[in] FsHandle file system handle.
@param[in] FileName The file name to get.
@param[out] FileHandle file handle
@retval EFI_SUCCESS The file opened correctly.
@retval EFI_INVALID_PARAMETER Parameter is not valid.
@retval EFI_DEVICE_ERROR A device error occurred.
@retval EFI_NOT_FOUND A requested file cannot be found.
@retval EFI_OUT_OF_RESOURCES Insufficant memory resource pool.
**/
EFI_STATUS
EFIAPI
OpenFile (
IN EFI_HANDLE FsHandle,
IN CHAR16 *FileName,
OUT EFI_HANDLE *FileHandle
);
/**
Get file size by opened file handle.
@param[in] FileHandle file handle
@param[out] FileSize Pointer to file buffer size.
@retval EFI_SUCCESS The file was loaded correctly.
@retval EFI_INVALID_PARAMETER Parameter is not valid.
**/
EFI_STATUS
EFIAPI
GetFileSize (
IN EFI_HANDLE FileHandle,
OUT UINTN *FileSize
);
/**
Read file into memory by opened file handle.
@param[in] FileHandle file handle
@param[out] FileBufferPtr Allocated file buffer pointer.
@param[out] FileSize Pointer to file buffer size.
@retval EFI_SUCCESS The file was loaded correctly.
@retval EFI_INVALID_PARAMETER Parameter is not valid.
@retval EFI_DEVICE_ERROR A device error occurred.
@retval EFI_NOT_FOUND A requested file cannot be found.
@retval EFI_OUT_OF_RESOURCES Insufficant memory resource pool.
@retval EFI_BUFFER_TOO_SMALL Buffer size is too small.
**/
EFI_STATUS
EFIAPI
ReadFile (
IN EFI_HANDLE FileHandle,
OUT VOID *FileBuffer,
Use LF line endings in the repository Convert the line endings stored for all text files in the repository to LF. The majority previously used DOS-style CRLF line endings. Add a .gitattributes file to enforce this and treat certain extensions as never being text files. Update PatchCheck.py to insist on LF line endings rather than CRLF. However, its other checks fail on this commit due to lots of pre-existing complaints that it only notices because the line endings have changed. Silicon/QemuSocPkg/FspBin/Patches/0001-Build-QEMU-FSP-2.0-binaries.patch needs to be treated as binary since it contains a mixture of line endings. This change has implications depending on the client platform you are using the repository from: * Windows The usual configuration for Git on Windows means that text files will be checked out to the work tree with DOS-style CRLF line endings. If that's not the case then you can configure Git to do so for the entire machine with: git config --global core.autocrlf true or for just the repository with: git config core.autocrlf true Line endings will be normalised to LF when they are committed to the repository. If you commit a text file with only LF line endings then it will be converted to CRLF line endings in your work tree. * Linux, MacOS and other Unices The usual configuration for Git on such platforms is to check files out of the repository with LF line endings. This is probably the right thing for you. In the unlikely even that you are using Git on Unix but editing or compiling on Windows for some reason then you may need to tweak your configuration to force the use of CRLF line endings as described above. * General For more information see https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings . Fixes: https://github.com/slimbootloader/slimbootloader/issues/1400 Signed-off-by: Mike Crowe <mac@mcrowe.com>
2021-11-10 11:36:23 +00:00
OUT UINTN *FileSize
);
/**
Close a file by opened file handle
@param[in] FileHandle file handle
@retval none
**/
VOID
EFIAPI
CloseFile (
IN EFI_HANDLE FileHandle
);
/**
List directories or files
@param[in] FsHandle file system handle.
@param[in] DirFilePath directory or file path
@retval EFI_SUCCESS list directories of files successfully
@retval EFI_UNSUPPORTED this api is not supported
@retval Others an error occurs
**/
EFI_STATUS
EFIAPI
ListDir (
IN EFI_HANDLE FsHandle,
IN CHAR16 *DirFilePath
);
typedef struct {
FS_INIT_FILE_SYSTEM InitFileSystem;
FS_CLOSE_FILE_SYSTEM CloseFileSystem;
FS_OPEN_FILE OpenFile;
FS_GET_FILE_SIZE GetFileSize;
FS_READ_FILE ReadFile;
FS_CLOSE_FILE CloseFile;
FS_LIST_DIR ListDir;
} FILE_SYSTEM_FUNC;
#endif // _FAT_PEIM_H_