Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
e84f9e57
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看板
提交
e84f9e57
编写于
11年前
作者:
A
Al Viro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
consolidate the reassignments of ->f_op in ->open() instances
Signed-off-by:
N
Al Viro
<
viro@zeniv.linux.org.uk
>
上级
7b00ed6f
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
43 addition
and
77 deletion
+43
-77
drivers/char/misc.c
drivers/char/misc.c
+3
-9
drivers/gpu/drm/drm_fops.c
drivers/gpu/drm/drm_fops.c
+6
-11
drivers/media/dvb-core/dvbdev.c
drivers/media/dvb-core/dvbdev.c
+6
-13
drivers/usb/core/file.c
drivers/usb/core/file.c
+4
-12
fs/char_dev.c
fs/char_dev.c
+4
-2
include/linux/fs.h
include/linux/fs.h
+11
-0
sound/core/sound.c
sound/core/sound.c
+6
-16
sound/sound_core.c
sound/sound_core.c
+3
-14
未找到文件。
drivers/char/misc.c
浏览文件 @
e84f9e57
...
...
@@ -114,7 +114,7 @@ static int misc_open(struct inode * inode, struct file * file)
int
minor
=
iminor
(
inode
);
struct
miscdevice
*
c
;
int
err
=
-
ENODEV
;
const
struct
file_operations
*
old_fops
,
*
new_fops
=
NULL
;
const
struct
file_operations
*
new_fops
=
NULL
;
mutex_lock
(
&
misc_mtx
);
...
...
@@ -141,17 +141,11 @@ static int misc_open(struct inode * inode, struct file * file)
}
err
=
0
;
old_fops
=
file
->
f_op
;
file
->
f_op
=
new_fops
;
replace_fops
(
file
,
new_fops
);
if
(
file
->
f_op
->
open
)
{
file
->
private_data
=
c
;
err
=
file
->
f_op
->
open
(
inode
,
file
);
if
(
err
)
{
fops_put
(
file
->
f_op
);
file
->
f_op
=
fops_get
(
old_fops
);
}
err
=
file
->
f_op
->
open
(
inode
,
file
);
}
fops_put
(
old_fops
);
fail:
mutex_unlock
(
&
misc_mtx
);
return
err
;
...
...
This diff is collapsed.
Click to expand it.
drivers/gpu/drm/drm_fops.c
浏览文件 @
e84f9e57
...
...
@@ -148,7 +148,7 @@ int drm_stub_open(struct inode *inode, struct file *filp)
struct
drm_minor
*
minor
;
int
minor_id
=
iminor
(
inode
);
int
err
=
-
ENODEV
;
const
struct
file_operations
*
old
_fops
;
const
struct
file_operations
*
new
_fops
;
DRM_DEBUG
(
"
\n
"
);
...
...
@@ -163,18 +163,13 @@ int drm_stub_open(struct inode *inode, struct file *filp)
if
(
drm_device_is_unplugged
(
dev
))
goto
out
;
old_fops
=
filp
->
f_op
;
filp
->
f_op
=
fops_get
(
dev
->
driver
->
fops
);
if
(
filp
->
f_op
==
NULL
)
{
filp
->
f_op
=
old_fops
;
new_fops
=
fops_get
(
dev
->
driver
->
fops
);
if
(
!
new_fops
)
goto
out
;
}
if
(
filp
->
f_op
->
open
&&
(
err
=
filp
->
f_op
->
open
(
inode
,
filp
)))
{
fops_put
(
filp
->
f_op
);
filp
->
f_op
=
fops_get
(
old_fops
);
}
fops_put
(
old_fops
);
replace_fops
(
filp
,
new_fops
);
if
(
filp
->
f_op
->
open
)
err
=
filp
->
f_op
->
open
(
inode
,
filp
);
out:
mutex_unlock
(
&
drm_global_mutex
);
return
err
;
...
...
This diff is collapsed.
Click to expand it.
drivers/media/dvb-core/dvbdev.c
浏览文件 @
e84f9e57
...
...
@@ -74,22 +74,15 @@ static int dvb_device_open(struct inode *inode, struct file *file)
if
(
dvbdev
&&
dvbdev
->
fops
)
{
int
err
=
0
;
const
struct
file_operations
*
old
_fops
;
const
struct
file_operations
*
new
_fops
;
file
->
private_data
=
dvbdev
;
old_fops
=
file
->
f_op
;
file
->
f_op
=
fops_get
(
dvbdev
->
fops
);
if
(
file
->
f_op
==
NULL
)
{
file
->
f_op
=
old_fops
;
new_fops
=
fops_get
(
dvbdev
->
fops
);
if
(
!
new_fops
)
goto
fail
;
}
if
(
file
->
f_op
->
open
)
file
->
private_data
=
dvbdev
;
replace_fops
(
file
,
new_fops
);
if
(
file
->
f_op
->
open
)
err
=
file
->
f_op
->
open
(
inode
,
file
);
if
(
err
)
{
fops_put
(
file
->
f_op
);
file
->
f_op
=
fops_get
(
old_fops
);
}
fops_put
(
old_fops
);
up_read
(
&
minor_rwsem
);
mutex_unlock
(
&
dvbdev_mutex
);
return
err
;
...
...
This diff is collapsed.
Click to expand it.
drivers/usb/core/file.c
浏览文件 @
e84f9e57
...
...
@@ -29,27 +29,19 @@ static DECLARE_RWSEM(minor_rwsem);
static
int
usb_open
(
struct
inode
*
inode
,
struct
file
*
file
)
{
int
minor
=
iminor
(
inode
);
const
struct
file_operations
*
c
;
int
err
=
-
ENODEV
;
const
struct
file_operations
*
old_fops
,
*
new_fops
=
NULL
;
const
struct
file_operations
*
new_fops
;
down_read
(
&
minor_rwsem
);
c
=
usb_minors
[
minor
]
;
new_fops
=
fops_get
(
usb_minors
[
iminor
(
inode
)])
;
if
(
!
c
||
!
(
new_fops
=
fops_get
(
c
))
)
if
(
!
new_fops
)
goto
done
;
old_fops
=
file
->
f_op
;
file
->
f_op
=
new_fops
;
replace_fops
(
file
,
new_fops
);
/* Curiouser and curiouser... NULL ->open() as "no device" ? */
if
(
file
->
f_op
->
open
)
err
=
file
->
f_op
->
open
(
inode
,
file
);
if
(
err
)
{
fops_put
(
file
->
f_op
);
file
->
f_op
=
fops_get
(
old_fops
);
}
fops_put
(
old_fops
);
done:
up_read
(
&
minor_rwsem
);
return
err
;
...
...
This diff is collapsed.
Click to expand it.
fs/char_dev.c
浏览文件 @
e84f9e57
...
...
@@ -368,6 +368,7 @@ void cdev_put(struct cdev *p)
*/
static
int
chrdev_open
(
struct
inode
*
inode
,
struct
file
*
filp
)
{
const
struct
file_operations
*
fops
;
struct
cdev
*
p
;
struct
cdev
*
new
=
NULL
;
int
ret
=
0
;
...
...
@@ -400,10 +401,11 @@ static int chrdev_open(struct inode *inode, struct file *filp)
return
ret
;
ret
=
-
ENXIO
;
f
ilp
->
f_op
=
fops_get
(
p
->
ops
);
if
(
!
f
ilp
->
f_op
)
f
ops
=
fops_get
(
p
->
ops
);
if
(
!
f
ops
)
goto
out_cdev_put
;
replace_fops
(
filp
,
fops
);
if
(
filp
->
f_op
->
open
)
{
ret
=
filp
->
f_op
->
open
(
inode
,
filp
);
if
(
ret
)
...
...
This diff is collapsed.
Click to expand it.
include/linux/fs.h
浏览文件 @
e84f9e57
...
...
@@ -1875,6 +1875,17 @@ extern struct dentry *mount_pseudo(struct file_system_type *, char *,
(((fops) && try_module_get((fops)->owner) ? (fops) : NULL))
#define fops_put(fops) \
do { if (fops) module_put((fops)->owner); } while(0)
/*
* This one is to be used *ONLY* from ->open() instances.
* fops must be non-NULL, pinned down *and* module dependencies
* should be sufficient to pin the caller down as well.
*/
#define replace_fops(f, fops) \
do { \
struct file *__file = (f); \
fops_put(__file->f_op); \
BUG_ON(!(__file->f_op = (fops))); \
} while(0)
extern
int
register_filesystem
(
struct
file_system_type
*
);
extern
int
unregister_filesystem
(
struct
file_system_type
*
);
...
...
This diff is collapsed.
Click to expand it.
sound/core/sound.c
浏览文件 @
e84f9e57
...
...
@@ -153,7 +153,7 @@ static int snd_open(struct inode *inode, struct file *file)
{
unsigned
int
minor
=
iminor
(
inode
);
struct
snd_minor
*
mptr
=
NULL
;
const
struct
file_operations
*
old
_fops
;
const
struct
file_operations
*
new
_fops
;
int
err
=
0
;
if
(
minor
>=
ARRAY_SIZE
(
snd_minors
))
...
...
@@ -167,24 +167,14 @@ static int snd_open(struct inode *inode, struct file *file)
return
-
ENODEV
;
}
}
old_fops
=
file
->
f_op
;
file
->
f_op
=
fops_get
(
mptr
->
f_ops
);
if
(
file
->
f_op
==
NULL
)
{
file
->
f_op
=
old_fops
;
err
=
-
ENODEV
;
}
new_fops
=
fops_get
(
mptr
->
f_ops
);
mutex_unlock
(
&
sound_mutex
);
if
(
err
<
0
)
return
err
;
if
(
!
new_fops
)
return
-
ENODEV
;
replace_fops
(
file
,
new_fops
);
if
(
file
->
f_op
->
open
)
{
if
(
file
->
f_op
->
open
)
err
=
file
->
f_op
->
open
(
inode
,
file
);
if
(
err
)
{
fops_put
(
file
->
f_op
);
file
->
f_op
=
fops_get
(
old_fops
);
}
}
fops_put
(
old_fops
);
return
err
;
}
...
...
This diff is collapsed.
Click to expand it.
sound/sound_core.c
浏览文件 @
e84f9e57
...
...
@@ -626,31 +626,20 @@ static int soundcore_open(struct inode *inode, struct file *file)
if
(
s
)
new_fops
=
fops_get
(
s
->
unit_fops
);
}
spin_unlock
(
&
sound_loader_lock
);
if
(
new_fops
)
{
/*
* We rely upon the fact that we can't be unloaded while the
* subdriver is there, so if ->open() is successful we can
* safely drop the reference counter and if it is not we can
* revert to old ->f_op. Ugly, indeed, but that's the cost of
* switching ->f_op in the first place.
* subdriver is there.
*/
int
err
=
0
;
const
struct
file_operations
*
old_fops
=
file
->
f_op
;
file
->
f_op
=
new_fops
;
spin_unlock
(
&
sound_loader_lock
);
replace_fops
(
file
,
new_fops
);
if
(
file
->
f_op
->
open
)
err
=
file
->
f_op
->
open
(
inode
,
file
);
if
(
err
)
{
fops_put
(
file
->
f_op
);
file
->
f_op
=
fops_get
(
old_fops
);
}
fops_put
(
old_fops
);
return
err
;
}
spin_unlock
(
&
sound_loader_lock
);
return
-
ENODEV
;
}
...
...
This diff is collapsed.
Click to expand it.
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录
新手
引导
客服
返回
顶部