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
Kirill Smelkov
linux
Commits
0dd934ee
Commit
0dd934ee
authored
Oct 02, 2002
by
Matthew Wilcox
Committed by
David S. Miller
Oct 02, 2002
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[NET]: Move common ioctl code up a layer.
parent
55067e03
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
33 additions
and
111 deletions
+33
-111
net/econet/af_econet.c
net/econet/af_econet.c
+2
-34
net/ipv4/af_inet.c
net/ipv4/af_inet.c
+0
-24
net/ipv6/af_inet6.c
net/ipv6/af_inet6.c
+0
-13
net/packet/af_packet.c
net/packet/af_packet.c
+0
-18
net/socket.c
net/socket.c
+31
-4
net/wanrouter/af_wanpipe.c
net/wanrouter/af_wanpipe.c
+0
-18
No files found.
net/econet/af_econet.c
View file @
0dd934ee
...
@@ -643,51 +643,19 @@ static int ec_dev_ioctl(struct socket *sock, unsigned int cmd, void *arg)
...
@@ -643,51 +643,19 @@ static int ec_dev_ioctl(struct socket *sock, unsigned int cmd, void *arg)
static
int
econet_ioctl
(
struct
socket
*
sock
,
unsigned
int
cmd
,
unsigned
long
arg
)
static
int
econet_ioctl
(
struct
socket
*
sock
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
{
struct
sock
*
sk
=
sock
->
sk
;
struct
sock
*
sk
=
sock
->
sk
;
int
pid
;
switch
(
cmd
)
switch
(
cmd
)
{
{
case
FIOSETOWN
:
case
SIOCSPGRP
:
if
(
get_user
(
pid
,
(
int
*
)
arg
))
return
-
EFAULT
;
return
f_setown
(
sock
->
file
,
pid
,
1
);
case
FIOGETOWN
:
case
SIOCGPGRP
:
return
put_user
(
sock
->
file
->
f_owner
.
pid
,
(
int
*
)
arg
);
case
SIOCGSTAMP
:
case
SIOCGSTAMP
:
if
(
sk
->
stamp
.
tv_sec
==
0
)
if
(
sk
->
stamp
.
tv_sec
==
0
)
return
-
ENOENT
;
return
-
ENOENT
;
return
copy_to_user
((
void
*
)
arg
,
&
sk
->
stamp
,
sizeof
(
struct
timeval
))
?
-
EFAULT
:
0
;
return
copy_to_user
((
void
*
)
arg
,
&
sk
->
stamp
,
sizeof
(
struct
timeval
))
?
-
EFAULT
:
0
;
case
SIOCGIFFLAGS
:
case
SIOCSIFFLAGS
:
case
SIOCGIFCONF
:
case
SIOCGIFMETRIC
:
case
SIOCSIFMETRIC
:
case
SIOCGIFMEM
:
case
SIOCSIFMEM
:
case
SIOCGIFMTU
:
case
SIOCSIFMTU
:
case
SIOCSIFLINK
:
case
SIOCGIFHWADDR
:
case
SIOCSIFHWADDR
:
case
SIOCSIFMAP
:
case
SIOCGIFMAP
:
case
SIOCSIFSLAVE
:
case
SIOCGIFSLAVE
:
case
SIOCGIFINDEX
:
case
SIOCGIFNAME
:
case
SIOCGIFCOUNT
:
case
SIOCSIFHWBROADCAST
:
return
(
dev_ioctl
(
cmd
,(
void
*
)
arg
));
case
SIOCSIFADDR
:
case
SIOCSIFADDR
:
case
SIOCGIFADDR
:
case
SIOCGIFADDR
:
return
ec_dev_ioctl
(
sock
,
cmd
,
(
void
*
)
arg
);
return
ec_dev_ioctl
(
sock
,
cmd
,
(
void
*
)
arg
);
break
;
break
;
default:
default:
return
(
dev_ioctl
(
cmd
,(
void
*
)
arg
)
);
return
dev_ioctl
(
cmd
,(
void
*
)
arg
);
}
}
/*NOTREACHED*/
/*NOTREACHED*/
return
0
;
return
0
;
...
...
net/ipv4/af_inet.c
View file @
0dd934ee
...
@@ -117,9 +117,6 @@
...
@@ -117,9 +117,6 @@
#ifdef CONFIG_NET_DIVERT
#ifdef CONFIG_NET_DIVERT
#include <linux/divert.h>
#include <linux/divert.h>
#endif
/* CONFIG_NET_DIVERT */
#endif
/* CONFIG_NET_DIVERT */
#if defined(CONFIG_NET_RADIO) || defined(CONFIG_NET_PCMCIA_RADIO)
#include <linux/wireless.h>
/* Note : will define WIRELESS_EXT */
#endif
/* CONFIG_NET_RADIO || CONFIG_NET_PCMCIA_RADIO */
struct
linux_mib
net_statistics
[
NR_CPUS
*
2
];
struct
linux_mib
net_statistics
[
NR_CPUS
*
2
];
...
@@ -850,20 +847,8 @@ int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
...
@@ -850,20 +847,8 @@ int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
{
{
struct
sock
*
sk
=
sock
->
sk
;
struct
sock
*
sk
=
sock
->
sk
;
int
err
=
0
;
int
err
=
0
;
int
pid
;
switch
(
cmd
)
{
switch
(
cmd
)
{
case
FIOSETOWN
:
case
SIOCSPGRP
:
if
(
get_user
(
pid
,
(
int
*
)
arg
))
err
=
-
EFAULT
;
else
err
=
f_setown
(
sock
->
file
,
pid
,
1
);
break
;
case
FIOGETOWN
:
case
SIOCGPGRP
:
err
=
put_user
(
sock
->
file
->
f_owner
.
pid
,
(
int
*
)
arg
);
break
;
case
SIOCGSTAMP
:
case
SIOCGSTAMP
:
if
(
!
sk
->
stamp
.
tv_sec
)
if
(
!
sk
->
stamp
.
tv_sec
)
err
=
-
ENOENT
;
err
=
-
ENOENT
;
...
@@ -949,15 +934,6 @@ int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
...
@@ -949,15 +934,6 @@ int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
err
=
-
ENOPKG
;
err
=
-
ENOPKG
;
break
;
break
;
default:
default:
if
(
cmd
>=
SIOCDEVPRIVATE
&&
cmd
<=
(
SIOCDEVPRIVATE
+
15
))
err
=
dev_ioctl
(
cmd
,
(
void
*
)
arg
);
else
#ifdef WIRELESS_EXT
if
(
cmd
>=
SIOCIWFIRST
&&
cmd
<=
SIOCIWLAST
)
err
=
dev_ioctl
(
cmd
,
(
void
*
)
arg
);
else
#endif
/* WIRELESS_EXT */
if
(
!
sk
->
prot
->
ioctl
||
if
(
!
sk
->
prot
->
ioctl
||
(
err
=
sk
->
prot
->
ioctl
(
sk
,
cmd
,
arg
))
==
(
err
=
sk
->
prot
->
ioctl
(
sk
,
cmd
,
arg
))
==
-
ENOIOCTLCMD
)
-
ENOIOCTLCMD
)
...
...
net/ipv6/af_inet6.c
View file @
0dd934ee
...
@@ -455,18 +455,9 @@ int inet6_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
...
@@ -455,18 +455,9 @@ int inet6_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
{
{
struct
sock
*
sk
=
sock
->
sk
;
struct
sock
*
sk
=
sock
->
sk
;
int
err
=
-
EINVAL
;
int
err
=
-
EINVAL
;
int
pid
;
switch
(
cmd
)
switch
(
cmd
)
{
{
case
FIOSETOWN
:
case
SIOCSPGRP
:
if
(
get_user
(
pid
,
(
int
*
)
arg
))
return
-
EFAULT
;
return
f_setown
(
sock
->
file
,
pid
,
1
);
case
FIOGETOWN
:
case
SIOCGPGRP
:
return
put_user
(
sock
->
file
->
f_owner
.
pid
,
(
int
*
)
arg
);
case
SIOCGSTAMP
:
case
SIOCGSTAMP
:
if
(
sk
->
stamp
.
tv_sec
==
0
)
if
(
sk
->
stamp
.
tv_sec
==
0
)
return
-
ENOENT
;
return
-
ENOENT
;
...
@@ -488,10 +479,6 @@ int inet6_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
...
@@ -488,10 +479,6 @@ int inet6_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
case
SIOCSIFDSTADDR
:
case
SIOCSIFDSTADDR
:
return
addrconf_set_dstaddr
((
void
*
)
arg
);
return
addrconf_set_dstaddr
((
void
*
)
arg
);
default:
default:
if
((
cmd
>=
SIOCDEVPRIVATE
)
&&
(
cmd
<=
(
SIOCDEVPRIVATE
+
15
)))
return
(
dev_ioctl
(
cmd
,(
void
*
)
arg
));
if
(
sk
->
prot
->
ioctl
==
0
||
(
err
=
sk
->
prot
->
ioctl
(
sk
,
cmd
,
arg
))
==-
ENOIOCTLCMD
)
if
(
sk
->
prot
->
ioctl
==
0
||
(
err
=
sk
->
prot
->
ioctl
(
sk
,
cmd
,
arg
))
==-
ENOIOCTLCMD
)
return
(
dev_ioctl
(
cmd
,(
void
*
)
arg
));
return
(
dev_ioctl
(
cmd
,(
void
*
)
arg
));
return
err
;
return
err
;
...
...
net/packet/af_packet.c
View file @
0dd934ee
...
@@ -1458,16 +1458,6 @@ static int packet_ioctl(struct socket *sock, unsigned int cmd,
...
@@ -1458,16 +1458,6 @@ static int packet_ioctl(struct socket *sock, unsigned int cmd,
spin_unlock_bh
(
&
sk
->
receive_queue
.
lock
);
spin_unlock_bh
(
&
sk
->
receive_queue
.
lock
);
return
put_user
(
amount
,
(
int
*
)
arg
);
return
put_user
(
amount
,
(
int
*
)
arg
);
}
}
case
FIOSETOWN
:
case
SIOCSPGRP
:
{
int
pid
;
if
(
get_user
(
pid
,
(
int
*
)
arg
))
return
-
EFAULT
;
return
f_setown
(
sock
->
file
,
pid
,
1
);
}
case
FIOGETOWN
:
case
SIOCGPGRP
:
return
put_user
(
sock
->
file
->
f_owner
.
pid
,
(
int
*
)
arg
);
case
SIOCGSTAMP
:
case
SIOCGSTAMP
:
if
(
sk
->
stamp
.
tv_sec
==
0
)
if
(
sk
->
stamp
.
tv_sec
==
0
)
return
-
ENOENT
;
return
-
ENOENT
;
...
@@ -1542,14 +1532,6 @@ static int packet_ioctl(struct socket *sock, unsigned int cmd,
...
@@ -1542,14 +1532,6 @@ static int packet_ioctl(struct socket *sock, unsigned int cmd,
#endif
#endif
default:
default:
if
((
cmd
>=
SIOCDEVPRIVATE
)
&&
(
cmd
<=
(
SIOCDEVPRIVATE
+
15
)))
return
(
dev_ioctl
(
cmd
,(
void
*
)
arg
));
#ifdef CONFIG_NET_RADIO
if
((
cmd
>=
SIOCIWFIRST
)
&&
(
cmd
<=
SIOCIWLAST
))
return
(
dev_ioctl
(
cmd
,(
void
*
)
arg
));
#endif
return
-
EOPNOTSUPP
;
return
-
EOPNOTSUPP
;
}
}
return
0
;
return
0
;
...
...
net/socket.c
View file @
0dd934ee
...
@@ -79,6 +79,10 @@
...
@@ -79,6 +79,10 @@
#include <linux/kmod.h>
#include <linux/kmod.h>
#endif
#endif
#if defined(CONFIG_NET_RADIO) || defined(CONFIG_NET_PCMCIA_RADIO)
#include <linux/wireless.h>
/* Note : will define WIRELESS_EXT */
#endif
/* CONFIG_NET_RADIO || CONFIG_NET_PCMCIA_RADIO */
#include <asm/uaccess.h>
#include <asm/uaccess.h>
#include <net/sock.h>
#include <net/sock.h>
...
@@ -675,19 +679,42 @@ static ssize_t sock_writev(struct file *file, const struct iovec *vector,
...
@@ -675,19 +679,42 @@ static ssize_t sock_writev(struct file *file, const struct iovec *vector,
}
}
/*
/*
* With an ioctl
arg may well be a user mode pointer, but we don't know what to do
* With an ioctl
, arg may well be a user mode pointer, but we don't know
* with it - that's up to the protocol still.
* w
hat to do w
ith it - that's up to the protocol still.
*/
*/
int
sock_ioctl
(
struct
inode
*
inode
,
struct
file
*
file
,
unsigned
int
cmd
,
int
sock_ioctl
(
struct
inode
*
inode
,
struct
file
*
file
,
unsigned
int
cmd
,
unsigned
long
arg
)
unsigned
long
arg
)
{
{
struct
socket
*
sock
;
struct
socket
*
sock
;
int
err
;
int
pid
,
err
;
unlock_kernel
();
unlock_kernel
();
sock
=
SOCKET_I
(
inode
);
sock
=
SOCKET_I
(
inode
);
err
=
sock
->
ops
->
ioctl
(
sock
,
cmd
,
arg
);
if
(
cmd
>=
SIOCDEVPRIVATE
&&
cmd
<=
(
SIOCDEVPRIVATE
+
15
))
{
err
=
dev_ioctl
(
cmd
,
(
void
*
)
arg
);
}
else
#ifdef WIRELESS_EXT
if
(
cmd
>=
SIOCIWFIRST
&&
cmd
<=
SIOCIWLAST
)
{
err
=
dev_ioctl
(
cmd
,
(
void
*
)
arg
);
}
else
#endif
/* WIRELESS_EXT */
switch
(
cmd
)
{
case
FIOSETOWN
:
case
SIOCSPGRP
:
err
=
-
EFAULT
;
if
(
get_user
(
pid
,
(
int
*
)
arg
))
break
;
err
=
f_setown
(
sock
->
file
,
pid
,
1
);
break
;
case
FIOGETOWN
:
case
SIOCGPGRP
:
err
=
put_user
(
sock
->
file
->
f_owner
.
pid
,
(
int
*
)
arg
);
break
;
default:
err
=
sock
->
ops
->
ioctl
(
sock
,
cmd
,
arg
);
break
;
}
lock_kernel
();
lock_kernel
();
return
err
;
return
err
;
...
...
net/wanrouter/af_wanpipe.c
View file @
0dd934ee
...
@@ -1867,19 +1867,9 @@ static int wanpipe_ioctl(struct socket *sock, unsigned int cmd, unsigned long ar
...
@@ -1867,19 +1867,9 @@ static int wanpipe_ioctl(struct socket *sock, unsigned int cmd, unsigned long ar
{
{
struct
sock
*
sk
=
sock
->
sk
;
struct
sock
*
sk
=
sock
->
sk
;
int
err
;
int
err
;
int
pid
;
switch
(
cmd
)
switch
(
cmd
)
{
{
case
FIOSETOWN
:
case
SIOCSPGRP
:
err
=
get_user
(
pid
,
(
int
*
)
arg
);
if
(
err
)
return
err
;
return
f_setown
(
sock
->
file
,
pid
,
1
);
case
FIOGETOWN
:
case
SIOCGPGRP
:
return
put_user
(
sock
->
file
->
f_owner
.
pid
,
(
int
*
)
arg
);
case
SIOCGSTAMP
:
case
SIOCGSTAMP
:
if
(
sk
->
stamp
.
tv_sec
==
0
)
if
(
sk
->
stamp
.
tv_sec
==
0
)
return
-
ENOENT
;
return
-
ENOENT
;
...
@@ -1979,14 +1969,6 @@ static int wanpipe_ioctl(struct socket *sock, unsigned int cmd, unsigned long ar
...
@@ -1979,14 +1969,6 @@ static int wanpipe_ioctl(struct socket *sock, unsigned int cmd, unsigned long ar
#endif
#endif
default:
default:
if
((
cmd
>=
SIOCDEVPRIVATE
)
&&
(
cmd
<=
(
SIOCDEVPRIVATE
+
15
)))
return
(
dev_ioctl
(
cmd
,(
void
*
)
arg
));
#ifdef CONFIG_NET_RADIO
if
((
cmd
>=
SIOCIWFIRST
)
&&
(
cmd
<=
SIOCIWLAST
))
return
(
dev_ioctl
(
cmd
,(
void
*
)
arg
));
#endif
return
-
EOPNOTSUPP
;
return
-
EOPNOTSUPP
;
}
}
/*NOTREACHED*/
/*NOTREACHED*/
...
...
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