summaryrefslogtreecommitdiffstats
path: root/fs/pstore
diff options
context:
space:
mode:
authorWeiXiong Liao <liaoweixiong@allwinnertech.com>2020-03-25 16:55:04 +0800
committerKees Cook <keescook@chromium.org>2020-05-31 19:49:00 -0700
commit1525fb3bb6d69028b3941d34363397c28345ffab (patch)
treef4ee0dffa6988f2d261d271babf6baa631e9b3b2 /fs/pstore
parent335426c6dcdd338d6b7c939c2da15fc9c5dd4959 (diff)
downloadlinux-1525fb3bb6d69028b3941d34363397c28345ffab.tar.bz2
pstore/blk: Provide way to query pstore configuration
In order to configure itself, the MTD backend needs to be able to query the current pstore configuration. Introduce pstore_blk_get_config() for this purpose. Signed-off-by: WeiXiong Liao <liaoweixiong@allwinnertech.com> Link: https://lore.kernel.org/lkml/20200511233229.27745-9-keescook@chromium.org/ Co-developed-by: Kees Cook <keescook@chromium.org> Signed-off-by: Kees Cook <keescook@chromium.org>
Diffstat (limited to 'fs/pstore')
-rw-r--r--fs/pstore/blk.c37
1 files changed, 30 insertions, 7 deletions
diff --git a/fs/pstore/blk.c b/fs/pstore/blk.c
index 67343d6aa27a..631bc27c8661 100644
--- a/fs/pstore/blk.c
+++ b/fs/pstore/blk.c
@@ -94,6 +94,17 @@ struct bdev_info {
sector_t start_sect;
};
+#define check_size(name, alignsize) ({ \
+ long _##name_ = (name); \
+ _##name_ = _##name_ <= 0 ? 0 : (_##name_ * 1024); \
+ if (_##name_ & ((alignsize) - 1)) { \
+ pr_info(#name " must align to %d\n", \
+ (alignsize)); \
+ _##name_ = ALIGN(name, (alignsize)); \
+ } \
+ _##name_; \
+})
+
/**
* struct pstore_device_info - back-end pstore/blk driver structure.
*
@@ -149,13 +160,11 @@ static int psblk_register_do(struct pstore_device_info *dev)
dev->flags = UINT_MAX;
#define verify_size(name, alignsize, enabled) { \
- long _##name_ = (enabled) ? (name) : 0; \
- _##name_ = _##name_ <= 0 ? 0 : (_##name_ * 1024); \
- if (_##name_ & ((alignsize) - 1)) { \
- pr_info(#name " must align to %d\n", \
- (alignsize)); \
- _##name_ = ALIGN(name, (alignsize)); \
- } \
+ long _##name_; \
+ if (enabled) \
+ _##name_ = check_size(name, alignsize); \
+ else \
+ _##name_ = 0; \
name = _##name_ / 1024; \
pstore_zone_info->name = _##name_; \
}
@@ -453,6 +462,20 @@ void unregister_pstore_blk(unsigned int major)
}
EXPORT_SYMBOL_GPL(unregister_pstore_blk);
+/* get information of pstore/blk */
+int pstore_blk_get_config(struct pstore_blk_config *info)
+{
+ strncpy(info->device, blkdev, 80);
+ info->max_reason = max_reason;
+ info->kmsg_size = check_size(kmsg_size, 4096);
+ info->pmsg_size = check_size(pmsg_size, 4096);
+ info->ftrace_size = check_size(ftrace_size, 4096);
+ info->console_size = check_size(console_size, 4096);
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(pstore_blk_get_config);
+
static void __exit pstore_blk_exit(void)
{
mutex_lock(&pstore_blk_lock);