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
fb06b8ee
Commit
fb06b8ee
authored
Sep 03, 2003
by
Stephen Hemminger
Committed by
David S. Miller
Sep 03, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[NET]: Convert /proc/net/unix to seq_file.
parent
4e5f89d2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
93 additions
and
43 deletions
+93
-43
net/unix/af_unix.c
net/unix/af_unix.c
+93
-43
No files found.
net/unix/af_unix.c
View file @
fb06b8ee
...
@@ -111,6 +111,7 @@
...
@@ -111,6 +111,7 @@
#include <linux/tcp.h>
#include <linux/tcp.h>
#include <net/af_unix.h>
#include <net/af_unix.h>
#include <linux/proc_fs.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <net/scm.h>
#include <net/scm.h>
#include <linux/init.h>
#include <linux/init.h>
#include <linux/poll.h>
#include <linux/poll.h>
...
@@ -1805,25 +1806,52 @@ static unsigned int unix_poll(struct file * file, struct socket *sock, poll_tabl
...
@@ -1805,25 +1806,52 @@ static unsigned int unix_poll(struct file * file, struct socket *sock, poll_tabl
#ifdef CONFIG_PROC_FS
#ifdef CONFIG_PROC_FS
static
int
unix_read_proc
(
char
*
buffer
,
char
**
start
,
off_t
offset
,
static
struct
sock
*
unix_seq_idx
(
int
*
iter
,
loff_t
pos
)
int
length
,
int
*
eof
,
void
*
data
)
{
{
off_t
pos
=
0
;
loff_t
off
=
0
;
off_t
begin
=
0
;
int
len
=
0
;
int
i
;
struct
sock
*
s
;
struct
sock
*
s
;
len
+=
sprintf
(
buffer
,
"Num RefCount Protocol Flags Type St "
"Inode Path
\n
"
);
for
(
s
=
first_unix_socket
(
iter
);
s
;
s
=
next_unix_socket
(
iter
,
s
))
{
if
(
off
==
pos
)
return
s
;
++
off
;
}
return
NULL
;
}
static
void
*
unix_seq_start
(
struct
seq_file
*
seq
,
loff_t
*
pos
)
{
read_lock
(
&
unix_table_lock
);
read_lock
(
&
unix_table_lock
);
forall_unix_sockets
(
i
,
s
)
return
*
pos
?
unix_seq_idx
(
seq
->
private
,
*
pos
-
1
)
:
((
void
*
)
1
);
{
}
static
void
*
unix_seq_next
(
struct
seq_file
*
seq
,
void
*
v
,
loff_t
*
pos
)
{
++*
pos
;
if
(
v
==
(
void
*
)
1
)
return
first_unix_socket
(
seq
->
private
);
return
next_unix_socket
(
seq
->
private
,
v
);
}
static
void
unix_seq_stop
(
struct
seq_file
*
seq
,
void
*
v
)
{
read_unlock
(
&
unix_table_lock
);
}
static
int
unix_seq_show
(
struct
seq_file
*
seq
,
void
*
v
)
{
if
(
v
==
(
void
*
)
1
)
seq_puts
(
seq
,
"Num RefCount Protocol Flags Type St "
"Inode Path
\n
"
);
else
{
struct
sock
*
s
=
v
;
struct
unix_sock
*
u
=
unix_sk
(
s
);
struct
unix_sock
*
u
=
unix_sk
(
s
);
unix_state_rlock
(
s
);
unix_state_rlock
(
s
);
len
+=
sprintf
(
buffer
+
len
,
"%p: %08X %08X %08X %04X %02X %5lu"
,
seq_printf
(
seq
,
"%p: %08X %08X %08X %04X %02X %5lu"
,
s
,
s
,
atomic_read
(
&
s
->
sk_refcnt
),
atomic_read
(
&
s
->
sk_refcnt
),
0
,
0
,
...
@@ -1835,39 +1863,61 @@ static int unix_read_proc(char *buffer, char **start, off_t offset,
...
@@ -1835,39 +1863,61 @@ static int unix_read_proc(char *buffer, char **start, off_t offset,
sock_i_ino
(
s
));
sock_i_ino
(
s
));
if
(
u
->
addr
)
{
if
(
u
->
addr
)
{
buffer
[
len
++
]
=
' '
;
int
i
;
memcpy
(
buffer
+
len
,
u
->
addr
->
name
->
sun_path
,
seq_putc
(
seq
,
' '
);
u
->
addr
->
len
-
sizeof
(
short
));
if
(
!
UNIX_ABSTRACT
(
s
))
for
(
i
=
0
;
i
<
u
->
addr
->
len
-
sizeof
(
short
);
i
++
)
len
--
;
seq_putc
(
seq
,
u
->
addr
->
name
->
sun_path
[
i
]);
else
buffer
[
len
]
=
'@'
;
len
+=
u
->
addr
->
len
-
sizeof
(
short
);
}
unix_state_runlock
(
s
);
buffer
[
len
++
]
=
'\n'
;
if
(
UNIX_ABSTRACT
(
s
))
seq_putc
(
seq
,
'@'
);
pos
=
begin
+
len
;
if
(
pos
<
offset
)
{
len
=
0
;
begin
=
pos
;
}
}
if
(
pos
>
offset
+
length
)
unix_state_runlock
(
s
);
goto
done
;
seq_putc
(
seq
,
'\n'
)
;
}
}
*
eof
=
1
;
done:
return
0
;
read_unlock
(
&
unix_table_lock
);
}
*
start
=
buffer
+
(
offset
-
begin
);
len
-=
(
offset
-
begin
);
struct
seq_operations
unix_seq_ops
=
{
if
(
len
>
length
)
.
start
=
unix_seq_start
,
len
=
length
;
.
next
=
unix_seq_next
,
if
(
len
<
0
)
.
stop
=
unix_seq_stop
,
len
=
0
;
.
show
=
unix_seq_show
,
return
len
;
};
static
int
unix_seq_open
(
struct
inode
*
inode
,
struct
file
*
file
)
{
struct
seq_file
*
seq
;
int
rc
=
-
ENOMEM
;
int
*
iter
=
kmalloc
(
sizeof
(
int
),
GFP_KERNEL
);
if
(
!
iter
)
goto
out
;
rc
=
seq_open
(
file
,
&
unix_seq_ops
);
if
(
rc
)
goto
out_kfree
;
seq
=
file
->
private_data
;
seq
->
private
=
iter
;
*
iter
=
0
;
out:
return
rc
;
out_kfree:
kfree
(
iter
);
goto
out
;
}
}
static
struct
file_operations
unix_seq_fops
=
{
.
owner
=
THIS_MODULE
,
.
open
=
unix_seq_open
,
.
read
=
seq_read
,
.
llseek
=
seq_lseek
,
.
release
=
seq_release_private
,
};
#endif
#endif
struct
proto_ops
unix_stream_ops
=
{
struct
proto_ops
unix_stream_ops
=
{
...
@@ -1947,7 +1997,7 @@ static int __init af_unix_init(void)
...
@@ -1947,7 +1997,7 @@ static int __init af_unix_init(void)
sock_register
(
&
unix_family_ops
);
sock_register
(
&
unix_family_ops
);
#ifdef CONFIG_PROC_FS
#ifdef CONFIG_PROC_FS
create_proc_read_entry
(
"net/unix"
,
0
,
0
,
unix_read_proc
,
NULL
);
proc_net_fops_create
(
"unix"
,
0
,
&
unix_seq_fops
);
#endif
#endif
unix_sysctl_register
();
unix_sysctl_register
();
return
0
;
return
0
;
...
@@ -1957,7 +2007,7 @@ static void __exit af_unix_exit(void)
...
@@ -1957,7 +2007,7 @@ static void __exit af_unix_exit(void)
{
{
sock_unregister
(
PF_UNIX
);
sock_unregister
(
PF_UNIX
);
unix_sysctl_unregister
();
unix_sysctl_unregister
();
remove_proc_entry
(
"net/unix"
,
0
);
proc_net_remove
(
"unix"
);
kmem_cache_destroy
(
unix_sk_cachep
);
kmem_cache_destroy
(
unix_sk_cachep
);
}
}
...
...
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