Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
9f09f649
K
Kernel
项目概览
openeuler
/
Kernel
1 年多 前同步成功
通知
8
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
9f09f649
编写于
12月 20, 2019
作者:
A
Al Viro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
teach logfc() to handle prefices, give it saner calling conventions
Signed-off-by:
N
Al Viro
<
viro@zeniv.linux.org.uk
>
上级
fbc2d168
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
27 addition
and
52 deletion
+27
-52
fs/fs_context.c
fs/fs_context.c
+17
-46
include/linux/fs_context.h
include/linux/fs_context.h
+10
-6
未找到文件。
fs/fs_context.c
浏览文件 @
9f09f649
...
...
@@ -388,64 +388,33 @@ EXPORT_SYMBOL(vfs_dup_fs_context);
* @fc: The filesystem context to log to.
* @fmt: The format of the buffer.
*/
void
logfc
(
struct
f
s_context
*
fc
,
const
char
*
fmt
,
...)
void
logfc
(
struct
f
c_log
*
log
,
const
char
*
prefix
,
char
level
,
const
char
*
fmt
,
...)
{
static
const
char
store_failure
[]
=
"OOM: Can't store error string"
;
struct
fc_log
*
log
=
fc
?
fc
->
log
:
NULL
;
const
char
*
p
;
va_list
va
;
char
*
q
;
u8
freeable
;
struct
va_format
vaf
=
{.
fmt
=
fmt
,
.
va
=
&
va
};
va_start
(
va
,
fmt
);
if
(
!
strchr
(
fmt
,
'%'
))
{
p
=
fmt
;
goto
unformatted_string
;
}
if
(
strcmp
(
fmt
,
"%s"
)
==
0
)
{
p
=
va_arg
(
va
,
const
char
*
);
goto
unformatted_string
;
}
q
=
kvasprintf
(
GFP_KERNEL
,
fmt
,
va
);
copied_string:
if
(
!
q
)
goto
store_failure
;
freeable
=
1
;
goto
store_string
;
unformatted_string:
if
((
unsigned
long
)
p
>=
(
unsigned
long
)
__start_rodata
&&
(
unsigned
long
)
p
<
(
unsigned
long
)
__end_rodata
)
goto
const_string
;
if
(
log
&&
within_module_core
((
unsigned
long
)
p
,
log
->
owner
))
goto
const_string
;
q
=
kstrdup
(
p
,
GFP_KERNEL
);
goto
copied_string
;
store_failure:
p
=
store_failure
;
const_string:
q
=
(
char
*
)
p
;
freeable
=
0
;
store_string:
if
(
!
log
)
{
switch
(
fmt
[
0
]
)
{
switch
(
level
)
{
case
'w'
:
printk
(
KERN_WARNING
"%s
\n
"
,
q
+
2
);
printk
(
KERN_WARNING
"%s%s%pV
\n
"
,
prefix
?
prefix
:
""
,
prefix
?
": "
:
""
,
&
vaf
);
break
;
case
'e'
:
printk
(
KERN_ERR
"%s
\n
"
,
q
+
2
);
printk
(
KERN_ERR
"%s%s%pV
\n
"
,
prefix
?
prefix
:
""
,
prefix
?
": "
:
""
,
&
vaf
);
break
;
default:
printk
(
KERN_NOTICE
"%s
\n
"
,
q
+
2
);
printk
(
KERN_NOTICE
"%s%s%pV
\n
"
,
prefix
?
prefix
:
""
,
prefix
?
": "
:
""
,
&
vaf
);
break
;
}
if
(
freeable
)
kfree
(
q
);
}
else
{
unsigned
int
logsize
=
ARRAY_SIZE
(
log
->
buffer
);
u8
index
;
char
*
q
=
kasprintf
(
GFP_KERNEL
,
"%c %s%s%pV
\n
"
,
level
,
prefix
?
prefix
:
""
,
prefix
?
": "
:
""
,
&
vaf
);
index
=
log
->
head
&
(
logsize
-
1
);
BUILD_BUG_ON
(
sizeof
(
log
->
head
)
!=
sizeof
(
u8
)
||
...
...
@@ -457,9 +426,11 @@ void logfc(struct fs_context *fc, const char *fmt, ...)
log
->
tail
++
;
}
log
->
buffer
[
index
]
=
q
;
log
->
need_free
&=
~
(
1
<<
index
);
log
->
need_free
|=
freeable
<<
index
;
log
->
buffer
[
index
]
=
q
?
q
:
"OOM: Can't store error string"
;
if
(
q
)
log
->
need_free
|=
1
<<
index
;
else
log
->
need_free
&=
~
(
1
<<
index
);
log
->
head
++
;
}
va_end
(
va
);
...
...
include/linux/fs_context.h
浏览文件 @
9f09f649
...
...
@@ -181,9 +181,13 @@ struct fc_log {
char
*
buffer
[
8
];
};
extern
__attribute__
((
format
(
printf
,
2
,
3
)))
void
logfc
(
struct
f
s_context
*
fc
,
const
char
*
fmt
,
...);
extern
__attribute__
((
format
(
printf
,
4
,
5
)))
void
logfc
(
struct
f
c_log
*
log
,
const
char
*
prefix
,
char
level
,
const
char
*
fmt
,
...);
#define __logfc(fc, l, fmt, ...) ({ \
struct fs_context *__fc = (fc); \
logfc(__fc ? __fc->log : NULL, NULL, \
l, fmt, ## __VA_ARGS__);})
/**
* infof - Store supplementary informational message
* @fc: The context in which to log the informational message
...
...
@@ -192,7 +196,7 @@ void logfc(struct fs_context *fc, const char *fmt, ...);
* Store the supplementary informational message for the process if the process
* has enabled the facility.
*/
#define infof(fc, fmt, ...)
({ logfc(fc, "i "fmt, ## __VA_ARGS__); }
)
#define infof(fc, fmt, ...)
__logfc(fc, 'i', fmt, ## __VA_ARGS__
)
/**
* warnf - Store supplementary warning message
...
...
@@ -202,7 +206,7 @@ void logfc(struct fs_context *fc, const char *fmt, ...);
* Store the supplementary warning message for the process if the process has
* enabled the facility.
*/
#define warnf(fc, fmt, ...)
({ logfc(fc, "w "fmt, ## __VA_ARGS__); }
)
#define warnf(fc, fmt, ...)
__logfc(fc, 'w', fmt, ## __VA_ARGS__
)
/**
* errorf - Store supplementary error message
...
...
@@ -212,7 +216,7 @@ void logfc(struct fs_context *fc, const char *fmt, ...);
* Store the supplementary error message for the process if the process has
* enabled the facility.
*/
#define errorf(fc, fmt, ...)
({ logfc(fc, "e "fmt, ## __VA_ARGS__); }
)
#define errorf(fc, fmt, ...)
__logfc(fc, 'e', fmt, ## __VA_ARGS__
)
/**
* invalf - Store supplementary invalid argument error message
...
...
@@ -222,6 +226,6 @@ void logfc(struct fs_context *fc, const char *fmt, ...);
* Store the supplementary error message for the process if the process has
* enabled the facility and return -EINVAL.
*/
#define invalf(fc, fmt, ...) (
{ errorf(fc, fmt, ## __VA_ARGS__); -EINVAL; }
)
#define invalf(fc, fmt, ...) (
errorf(fc, fmt, ## __VA_ARGS__), -EINVAL
)
#endif
/* _LINUX_FS_CONTEXT_H */
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录