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
d6b7a72c
Commit
d6b7a72c
authored
Feb 09, 2002
by
Alexander Viro
Committed by
David S. Miller
Feb 09, 2002
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PATCH] /proc/modules cleanup (seq_file, again)
/proc/modules switched to use of seq_file, cleaned up.
parent
62dfe539
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
84 deletions
+66
-84
fs/proc/proc_misc.c
fs/proc/proc_misc.c
+10
-11
kernel/module.c
kernel/module.c
+56
-73
No files found.
fs/proc/proc_misc.c
View file @
d6b7a72c
...
@@ -50,9 +50,6 @@
...
@@ -50,9 +50,6 @@
* have a way to deal with that gracefully. Right now I used straightforward
* have a way to deal with that gracefully. Right now I used straightforward
* wrappers, but this needs further analysis wrt potential overflows.
* wrappers, but this needs further analysis wrt potential overflows.
*/
*/
#ifdef CONFIG_MODULES
extern
int
get_module_list
(
char
*
);
#endif
extern
int
get_device_list
(
char
*
);
extern
int
get_device_list
(
char
*
);
extern
int
get_partition_list
(
char
*
,
char
**
,
off_t
,
int
);
extern
int
get_partition_list
(
char
*
,
char
**
,
off_t
,
int
);
extern
int
get_filesystem_list
(
char
*
);
extern
int
get_filesystem_list
(
char
*
);
...
@@ -203,13 +200,17 @@ static struct file_operations proc_cpuinfo_operations = {
...
@@ -203,13 +200,17 @@ static struct file_operations proc_cpuinfo_operations = {
};
};
#ifdef CONFIG_MODULES
#ifdef CONFIG_MODULES
static
int
modules_read_proc
(
char
*
page
,
char
**
start
,
off_t
off
,
extern
struct
seq_operations
modules_op
;
int
count
,
int
*
eof
,
void
*
data
)
static
int
modules_open
(
struct
inode
*
inode
,
struct
file
*
file
)
{
{
int
len
=
get_module_list
(
page
);
return
seq_open
(
file
,
&
modules_op
);
return
proc_calc_metrics
(
page
,
start
,
off
,
count
,
eof
,
len
);
}
}
static
struct
file_operations
proc_modules_operations
=
{
open:
modules_open
,
read:
seq_read
,
llseek:
seq_lseek
,
release:
seq_release
,
};
extern
struct
seq_operations
ksyms_op
;
extern
struct
seq_operations
ksyms_op
;
static
int
ksyms_open
(
struct
inode
*
inode
,
struct
file
*
file
)
static
int
ksyms_open
(
struct
inode
*
inode
,
struct
file
*
file
)
{
{
...
@@ -535,9 +536,6 @@ void __init proc_misc_init(void)
...
@@ -535,9 +536,6 @@ void __init proc_misc_init(void)
{
"uptime"
,
uptime_read_proc
},
{
"uptime"
,
uptime_read_proc
},
{
"meminfo"
,
meminfo_read_proc
},
{
"meminfo"
,
meminfo_read_proc
},
{
"version"
,
version_read_proc
},
{
"version"
,
version_read_proc
},
#ifdef CONFIG_MODULES
{
"modules"
,
modules_read_proc
},
#endif
{
"stat"
,
kstat_read_proc
},
{
"stat"
,
kstat_read_proc
},
{
"devices"
,
devices_read_proc
},
{
"devices"
,
devices_read_proc
},
{
"partitions"
,
partitions_read_proc
},
{
"partitions"
,
partitions_read_proc
},
...
@@ -567,6 +565,7 @@ void __init proc_misc_init(void)
...
@@ -567,6 +565,7 @@ void __init proc_misc_init(void)
create_seq_entry
(
"interrupts"
,
0
,
&
proc_interrupts_operations
);
create_seq_entry
(
"interrupts"
,
0
,
&
proc_interrupts_operations
);
create_seq_entry
(
"slabinfo"
,
S_IWUSR
|
S_IRUGO
,
&
proc_slabinfo_operations
);
create_seq_entry
(
"slabinfo"
,
S_IWUSR
|
S_IRUGO
,
&
proc_slabinfo_operations
);
#ifdef CONFIG_MODULES
#ifdef CONFIG_MODULES
create_seq_entry
(
"modules"
,
0
,
&
proc_modules_operations
);
create_seq_entry
(
"ksyms"
,
0
,
&
proc_ksyms_operations
);
create_seq_entry
(
"ksyms"
,
0
,
&
proc_ksyms_operations
);
#endif
#endif
proc_root_kcore
=
create_proc_entry
(
"kcore"
,
S_IRUSR
,
NULL
);
proc_root_kcore
=
create_proc_entry
(
"kcore"
,
S_IRUSR
,
NULL
);
...
...
kernel/module.c
View file @
d6b7a72c
...
@@ -1075,84 +1075,67 @@ free_module(struct module *mod, int tag_freed)
...
@@ -1075,84 +1075,67 @@ free_module(struct module *mod, int tag_freed)
/*
/*
* Called by the /proc file system to return a current list of modules.
* Called by the /proc file system to return a current list of modules.
*/
*/
static
void
*
m_start
(
struct
seq_file
*
m
,
loff_t
*
pos
)
int
get_module_list
(
char
*
p
)
{
{
size_t
left
=
PAGE_SIZE
;
struct
module
*
v
;
struct
module
*
mod
;
loff_t
n
=
*
pos
;
char
tmpstr
[
64
];
lock_kernel
();
struct
module_ref
*
ref
;
for
(
v
=
module_list
;
v
&&
n
--
;
v
=
v
->
next
)
;
for
(
mod
=
module_list
;
mod
!=
&
kernel_module
;
mod
=
mod
->
next
)
{
return
v
;
long
len
;
}
const
char
*
q
;
static
void
*
m_next
(
struct
seq_file
*
m
,
void
*
p
,
loff_t
*
pos
)
{
#define safe_copy_str(str, len) \
struct
module
*
v
=
p
;
do { \
(
*
pos
)
++
;
if (left < len) \
return
v
->
next
;
goto fini; \
}
memcpy(p, str, len); p += len, left -= len; \
static
void
m_stop
(
struct
seq_file
*
m
,
void
*
p
)
} while (0)
{
#define safe_copy_cstr(str) safe_copy_str(str, sizeof(str)-1)
unlock_kernel
();
}
len
=
strlen
(
mod
->
name
);
static
int
m_show
(
struct
seq_file
*
m
,
void
*
p
)
safe_copy_str
(
mod
->
name
,
len
);
{
struct
module
*
mod
=
p
;
if
((
len
=
20
-
len
)
>
0
)
{
struct
module_ref
*
ref
=
mod
->
refs
;
if
(
left
<
len
)
goto
fini
;
memset
(
p
,
' '
,
len
);
p
+=
len
;
left
-=
len
;
}
len
=
sprintf
(
tmpstr
,
"%8lu"
,
mod
->
size
);
if
(
mod
==
&
kernel_module
)
safe_copy_str
(
tmpstr
,
len
)
;
return
0
;
if
(
mod
->
flags
&
MOD_RUNNING
)
{
seq_printf
(
m
,
"%-20s%8lu"
,
mod
->
name
,
mod
->
size
);
len
=
sprintf
(
tmpstr
,
"%4ld"
,
if
(
mod
->
flags
&
MOD_RUNNING
)
seq_printf
(
m
,
"%4ld"
,
(
mod_member_present
(
mod
,
can_unload
)
(
mod_member_present
(
mod
,
can_unload
)
&&
mod
->
can_unload
&&
mod
->
can_unload
?
-
1L
:
(
long
)
atomic_read
(
&
mod
->
uc
.
usecount
)));
?
-
1L
:
(
long
)
atomic_read
(
&
mod
->
uc
.
usecount
)));
safe_copy_str
(
tmpstr
,
len
);
}
if
(
mod
->
flags
&
MOD_DELETED
)
if
(
mod
->
flags
&
MOD_DELETED
)
safe_copy_cstr
(
" (deleted)"
);
seq_puts
(
m
,
" (deleted)"
);
else
if
(
mod
->
flags
&
MOD_RUNNING
)
{
else
if
(
mod
->
flags
&
MOD_RUNNING
)
{
if
(
mod
->
flags
&
MOD_AUTOCLEAN
)
if
(
mod
->
flags
&
MOD_AUTOCLEAN
)
safe_copy_cstr
(
" (autoclean)"
);
seq_puts
(
m
,
" (autoclean)"
);
if
(
!
(
mod
->
flags
&
MOD_USED_ONCE
))
if
(
!
(
mod
->
flags
&
MOD_USED_ONCE
))
safe_copy_cstr
(
" (unused)"
);
seq_puts
(
m
,
" (unused)"
);
}
}
else
if
(
mod
->
flags
&
MOD_INITIALIZING
)
else
if
(
mod
->
flags
&
MOD_INITIALIZING
)
seq_puts
(
m
,
" (initializing)"
);
safe_copy_cstr
(
" (initializing)"
);
else
safe_copy_cstr
(
" (uninitialized)"
);
if
((
ref
=
mod
->
refs
)
!=
NULL
)
{
safe_copy_cstr
(
" ["
);
while
(
1
)
{
q
=
ref
->
ref
->
name
;
len
=
strlen
(
q
);
safe_copy_str
(
q
,
len
);
if
((
ref
=
ref
->
next_ref
)
!=
NULL
)
safe_copy_cstr
(
" "
);
else
else
break
;
seq_puts
(
m
,
" (uninitialized)"
);
}
if
(
ref
)
{
safe_copy_cstr
(
"]"
);
char
c
;
}
seq_putc
(
m
,
' '
);
safe_copy_cstr
(
"
\n
"
);
for
(
c
=
'['
;
ref
;
c
=
' '
,
ref
=
ref
->
next_ref
)
seq_printf
(
m
,
"%c%s"
,
c
,
ref
->
ref
->
name
);
#undef safe_copy_str
seq_putc
(
m
,
']'
);
#undef safe_copy_cstr
}
}
seq_putc
(
m
,
'\n'
);
return
0
;
fini:
return
PAGE_SIZE
-
left
;
}
}
struct
seq_operations
modules_op
=
{
start:
m_start
,
next:
m_next
,
stop:
m_stop
,
show:
m_show
};
/*
/*
* Called by the /proc file system to return a current list of ksyms.
* Called by the /proc file system to return a current list of ksyms.
...
...
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