forked from grate-driver/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fs/kernel_read_file: Split into separate include file
Move kernel_read_file* out of linux/fs.h to its own linux/kernel_read_file.h include file. That header gets pulled in just about everywhere and doesn't really need functions not related to the general fs interface. Suggested-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Scott Branden <scott.branden@broadcom.com> Signed-off-by: Kees Cook <keescook@chromium.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Mimi Zohar <zohar@linux.ibm.com> Reviewed-by: Luis Chamberlain <mcgrof@kernel.org> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Acked-by: James Morris <jamorris@linux.microsoft.com> Link: https://lore.kernel.org/r/20200706232309.12010-2-scott.branden@broadcom.com Link: https://lore.kernel.org/r/20201002173828.2099543-4-keescook@chromium.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
- Loading branch information
Showing
15 changed files
with
64 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
#ifndef _LINUX_KERNEL_READ_FILE_H | ||
#define _LINUX_KERNEL_READ_FILE_H | ||
|
||
#include <linux/file.h> | ||
#include <linux/types.h> | ||
|
||
/* This is a list of *what* is being read, not *how* nor *where*. */ | ||
#define __kernel_read_file_id(id) \ | ||
id(UNKNOWN, unknown) \ | ||
id(FIRMWARE, firmware) \ | ||
id(MODULE, kernel-module) \ | ||
id(KEXEC_IMAGE, kexec-image) \ | ||
id(KEXEC_INITRAMFS, kexec-initramfs) \ | ||
id(POLICY, security-policy) \ | ||
id(X509_CERTIFICATE, x509-certificate) \ | ||
id(MAX_ID, ) | ||
|
||
#define __fid_enumify(ENUM, dummy) READING_ ## ENUM, | ||
#define __fid_stringify(dummy, str) #str, | ||
|
||
enum kernel_read_file_id { | ||
__kernel_read_file_id(__fid_enumify) | ||
}; | ||
|
||
static const char * const kernel_read_file_str[] = { | ||
__kernel_read_file_id(__fid_stringify) | ||
}; | ||
|
||
static inline const char *kernel_read_file_id_str(enum kernel_read_file_id id) | ||
{ | ||
if ((unsigned int)id >= READING_MAX_ID) | ||
return kernel_read_file_str[READING_UNKNOWN]; | ||
|
||
return kernel_read_file_str[id]; | ||
} | ||
|
||
int kernel_read_file(struct file *file, | ||
void **buf, loff_t *size, loff_t max_size, | ||
enum kernel_read_file_id id); | ||
int kernel_read_file_from_path(const char *path, | ||
void **buf, loff_t *size, loff_t max_size, | ||
enum kernel_read_file_id id); | ||
int kernel_read_file_from_path_initns(const char *path, | ||
void **buf, loff_t *size, loff_t max_size, | ||
enum kernel_read_file_id id); | ||
int kernel_read_file_from_fd(int fd, | ||
void **buf, loff_t *size, loff_t max_size, | ||
enum kernel_read_file_id id); | ||
|
||
#endif /* _LINUX_KERNEL_READ_FILE_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters