Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
f805442e
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看板
提交
f805442e
编写于
4月 06, 2013
作者:
A
Al Viro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
vt6655: slightly clean reading config file
Signed-off-by:
N
Al Viro
<
viro@zeniv.linux.org.uk
>
上级
7c51d177
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
40 addition
and
75 deletion
+40
-75
drivers/staging/vt6655/device_main.c
drivers/staging/vt6655/device_main.c
+40
-75
未找到文件。
drivers/staging/vt6655/device_main.c
浏览文件 @
f805442e
...
...
@@ -60,6 +60,7 @@
*/
#undef __NO_VERSION__
#include <linux/file.h>
#include "device.h"
#include "card.h"
#include "channel.h"
...
...
@@ -2946,87 +2947,51 @@ static int Config_FileGetParameter(unsigned char *string,
return
true
;
}
int
Config_FileOperation
(
PSDevice
pDevice
,
bool
fwrite
,
unsigned
char
*
Parameter
)
{
unsigned
char
*
config_path
=
CONFIG_PATH
;
unsigned
char
*
buffer
=
NULL
;
unsigned
char
tmpbuffer
[
20
];
struct
file
*
filp
=
NULL
;
mm_segment_t
old_fs
=
get_fs
();
//int oldfsuid=0,oldfsgid=0;
int
result
=
0
;
set_fs
(
KERNEL_DS
);
/* Can't do this anymore, so we rely on correct filesystem permissions:
//Make sure a caller can read or write power as root
oldfsuid=current->cred->fsuid;
oldfsgid=current->cred->fsgid;
current->cred->fsuid = 0;
current->cred->fsgid = 0;
*/
//open file
filp
=
filp_open
(
config_path
,
O_RDWR
,
0
);
if
(
IS_ERR
(
filp
))
{
printk
(
"Config_FileOperation:open file fail?
\n
"
);
result
=-
1
;
goto
error2
;
}
int
Config_FileOperation
(
PSDevice
pDevice
,
bool
fwrite
,
unsigned
char
*
Parameter
)
{
unsigned
char
*
buffer
=
kmalloc
(
1024
,
GFP_KERNEL
);
unsigned
char
tmpbuffer
[
20
];
struct
file
*
file
;
int
result
=
0
;
if
(
!
(
filp
->
f_op
)
||
!
(
filp
->
f_op
->
read
)
||!
(
filp
->
f_op
->
write
))
{
printk
(
"file %s cann't readable or writable?
\n
"
,
config_path
);
result
=
-
1
;
goto
error1
;
}
buffer
=
kmalloc
(
1024
,
GFP_KERNEL
);
if
(
buffer
==
NULL
)
{
printk
(
"allocate mem for file fail?
\n
"
);
result
=
-
1
;
goto
error1
;
}
if
(
!
buffer
)
{
printk
(
"allocate mem for file fail?
\n
"
);
return
-
1
;
}
file
=
filp_open
(
CONFIG_PATH
,
O_RDONLY
,
0
);
if
(
IS_ERR
(
file
))
{
kfree
(
buffer
);
printk
(
"Config_FileOperation:open file fail?
\n
"
);
return
-
1
;
}
if
(
filp
->
f_op
->
read
(
filp
,
buffer
,
1024
,
&
filp
->
f_pos
)
<
0
)
{
printk
(
"read file error?
\n
"
);
result
=
-
1
;
goto
error1
;
}
if
(
kernel_read
(
file
,
0
,
buffer
,
1024
)
<
0
)
{
printk
(
"read file error?
\n
"
);
result
=
-
1
;
goto
error1
;
}
if
(
Config_FileGetParameter
(
"ZONETYPE"
,
tmpbuffer
,
buffer
)
!=
true
)
{
printk
(
"get parameter error?
\n
"
);
result
=
-
1
;
goto
error1
;
}
if
(
Config_FileGetParameter
(
"ZONETYPE"
,
tmpbuffer
,
buffer
)
!=
true
)
{
printk
(
"get parameter error?
\n
"
);
result
=
-
1
;
goto
error1
;
}
if
(
memcmp
(
tmpbuffer
,
"USA"
,
3
)
==
0
)
{
result
=
ZoneType_USA
;
}
else
if
(
memcmp
(
tmpbuffer
,
"JAPAN"
,
5
)
==
0
)
{
result
=
ZoneType_Japan
;
}
else
if
(
memcmp
(
tmpbuffer
,
"EUROPE"
,
5
)
==
0
)
{
result
=
ZoneType_Europe
;
}
else
{
result
=
-
1
;
printk
(
"Unknown Zonetype[%s]?
\n
"
,
tmpbuffer
);
}
if
(
memcmp
(
tmpbuffer
,
"USA"
,
3
)
==
0
)
{
result
=
ZoneType_USA
;
}
else
if
(
memcmp
(
tmpbuffer
,
"JAPAN"
,
5
)
==
0
)
{
result
=
ZoneType_Japan
;
}
else
if
(
memcmp
(
tmpbuffer
,
"EUROPE"
,
5
)
==
0
)
{
result
=
ZoneType_Europe
;
}
else
{
result
=
-
1
;
printk
(
"Unknown Zonetype[%s]?
\n
"
,
tmpbuffer
);
}
error1:
kfree
(
buffer
);
if
(
filp_close
(
filp
,
NULL
))
printk
(
"Config_FileOperation:close file fail
\n
"
);
error2:
set_fs
(
old_fs
);
/*
current->cred->fsuid=oldfsuid;
current->cred->fsgid=oldfsgid;
*/
return
result
;
kfree
(
buffer
);
fput
(
file
);
return
result
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录