Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
f805442e
Commit
f805442e
authored
Apr 06, 2013
by
Al Viro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vt6655: slightly clean reading config file
Signed-off-by:
Al Viro
<
viro@zeniv.linux.org.uk
>
parent
7c51d177
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
75 deletions
+40
-75
drivers/staging/vt6655/device_main.c
drivers/staging/vt6655/device_main.c
+40
-75
No files found.
drivers/staging/vt6655/device_main.c
View file @
f805442e
...
@@ -60,6 +60,7 @@
...
@@ -60,6 +60,7 @@
*/
*/
#undef __NO_VERSION__
#undef __NO_VERSION__
#include <linux/file.h>
#include "device.h"
#include "device.h"
#include "card.h"
#include "card.h"
#include "channel.h"
#include "channel.h"
...
@@ -2946,87 +2947,51 @@ static int Config_FileGetParameter(unsigned char *string,
...
@@ -2946,87 +2947,51 @@ static int Config_FileGetParameter(unsigned char *string,
return
true
;
return
true
;
}
}
int
Config_FileOperation
(
PSDevice
pDevice
,
bool
fwrite
,
unsigned
char
*
Parameter
)
{
int
Config_FileOperation
(
PSDevice
pDevice
,
bool
fwrite
,
unsigned
char
*
Parameter
)
unsigned
char
*
config_path
=
CONFIG_PATH
;
{
unsigned
char
*
buffer
=
NULL
;
unsigned
char
*
buffer
=
kmalloc
(
1024
,
GFP_KERNEL
);
unsigned
char
tmpbuffer
[
20
];
unsigned
char
tmpbuffer
[
20
];
struct
file
*
filp
=
NULL
;
struct
file
*
file
;
mm_segment_t
old_fs
=
get_fs
();
int
result
=
0
;
//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
;
}
if
(
!
(
filp
->
f_op
)
||
!
(
filp
->
f_op
->
read
)
||!
(
filp
->
f_op
->
write
))
{
if
(
!
buffer
)
{
printk
(
"file %s cann't readable or writable?
\n
"
,
config_path
);
printk
(
"allocate mem for file fail?
\n
"
);
result
=
-
1
;
return
-
1
;
goto
error1
;
}
}
file
=
filp_open
(
CONFIG_PATH
,
O_RDONLY
,
0
);
if
(
IS_ERR
(
file
))
{
buffer
=
kmalloc
(
1024
,
GFP_KERNEL
);
kfree
(
buffer
);
if
(
buffer
==
NULL
)
{
printk
(
"Config_FileOperation:open file fail?
\n
"
);
printk
(
"allocate mem for file fail?
\n
"
);
return
-
1
;
result
=
-
1
;
}
goto
error1
;
}
if
(
filp
->
f_op
->
read
(
filp
,
buffer
,
1024
,
&
filp
->
f_pos
)
<
0
)
{
if
(
kernel_read
(
file
,
0
,
buffer
,
1024
)
<
0
)
{
printk
(
"read file error?
\n
"
);
printk
(
"read file error?
\n
"
);
result
=
-
1
;
result
=
-
1
;
goto
error1
;
goto
error1
;
}
}
if
(
Config_FileGetParameter
(
"ZONETYPE"
,
tmpbuffer
,
buffer
)
!=
true
)
{
if
(
Config_FileGetParameter
(
"ZONETYPE"
,
tmpbuffer
,
buffer
)
!=
true
)
{
printk
(
"get parameter error?
\n
"
);
printk
(
"get parameter error?
\n
"
);
result
=
-
1
;
result
=
-
1
;
goto
error1
;
goto
error1
;
}
}
if
(
memcmp
(
tmpbuffer
,
"USA"
,
3
)
==
0
)
{
if
(
memcmp
(
tmpbuffer
,
"USA"
,
3
)
==
0
)
{
result
=
ZoneType_USA
;
result
=
ZoneType_USA
;
}
}
else
if
(
memcmp
(
tmpbuffer
,
"JAPAN"
,
5
)
==
0
)
{
else
if
(
memcmp
(
tmpbuffer
,
"JAPAN"
,
5
)
==
0
)
{
result
=
ZoneType_Japan
;
result
=
ZoneType_Japan
;
}
else
if
(
memcmp
(
tmpbuffer
,
"EUROPE"
,
5
)
==
0
)
{
}
result
=
ZoneType_Europe
;
else
if
(
memcmp
(
tmpbuffer
,
"EUROPE"
,
5
)
==
0
)
{
}
else
{
result
=
ZoneType_Europe
;
result
=
-
1
;
}
printk
(
"Unknown Zonetype[%s]?
\n
"
,
tmpbuffer
);
else
{
}
result
=
-
1
;
printk
(
"Unknown Zonetype[%s]?
\n
"
,
tmpbuffer
);
}
error1:
error1:
kfree
(
buffer
);
kfree
(
buffer
);
fput
(
file
);
if
(
filp_close
(
filp
,
NULL
))
return
result
;
printk
(
"Config_FileOperation:close file fail
\n
"
);
error2:
set_fs
(
old_fs
);
/*
current->cred->fsuid=oldfsuid;
current->cred->fsgid=oldfsgid;
*/
return
result
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment