- Remove socket file operations declaration from sys/file.h.
- Make them static in sys_socket.c. - Provide generic invfo_truncate() instead of soo_truncate(). Sponsored by: Netflix Sponsored by: Nginx, Inc.
This commit is contained in:
parent
44418c8be9
commit
e86447ca44
@ -87,20 +87,8 @@ enum {
|
||||
static struct cdev *dt_ptm, *dt_arp, *dt_icmp, *dt_ip, *dt_tcp, *dt_udp,
|
||||
*dt_rawip, *dt_unix_dgram, *dt_unix_stream, *dt_unix_ord_stream;
|
||||
|
||||
static struct fileops svr4_netops = {
|
||||
.fo_read = soo_read,
|
||||
.fo_write = soo_write,
|
||||
.fo_truncate = soo_truncate,
|
||||
.fo_ioctl = soo_ioctl,
|
||||
.fo_poll = soo_poll,
|
||||
.fo_kqfilter = soo_kqfilter,
|
||||
.fo_stat = soo_stat,
|
||||
.fo_close = svr4_soo_close,
|
||||
.fo_chmod = invfo_chmod,
|
||||
.fo_chown = invfo_chown,
|
||||
.fo_sendfile = invfo_sendfile,
|
||||
};
|
||||
|
||||
static struct fileops svr4_netops;
|
||||
|
||||
static struct cdevsw streams_cdevsw = {
|
||||
.d_version = D_VERSION,
|
||||
.d_open = streamsopen,
|
||||
@ -147,6 +135,11 @@ streams_modevent(module_t mod, int type, void *unused)
|
||||
printf("WARNING: device config for STREAMS failed\n");
|
||||
printf("Suggest unloading streams KLD\n");
|
||||
}
|
||||
|
||||
/* Inherit generic socket file operations, except close(2). */
|
||||
bcopy(&socketops, &svr4_netops, sizeof(struct fileops));
|
||||
svr4_netops.fo_close = svr4_soo_close;
|
||||
|
||||
return 0;
|
||||
case MOD_UNLOAD:
|
||||
/* XXX should check to see if it's busy first */
|
||||
@ -345,11 +338,15 @@ svr4_stream_get(fp)
|
||||
static int
|
||||
svr4_soo_close(struct file *fp, struct thread *td)
|
||||
{
|
||||
struct socket *so = fp->f_data;
|
||||
struct socket *so = fp->f_data;
|
||||
|
||||
/* CHECKUNIT_DIAG(ENXIO);*/
|
||||
|
||||
svr4_delete_socket(td->td_proc, fp);
|
||||
free(so->so_emuldata, M_TEMP);
|
||||
return soo_close(fp, td);
|
||||
|
||||
fp->f_ops = &badfileops;
|
||||
fp->f_data = NULL;
|
||||
|
||||
return soclose(so);
|
||||
}
|
||||
|
@ -3943,6 +3943,14 @@ struct fileops badfileops = {
|
||||
.fo_sendfile = badfo_sendfile,
|
||||
};
|
||||
|
||||
int
|
||||
invfo_truncate(struct file *fp, off_t length, struct ucred *active_cred,
|
||||
struct thread *td)
|
||||
{
|
||||
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
int
|
||||
invfo_chmod(struct file *fp, mode_t mode, struct ucred *active_cred,
|
||||
struct thread *td)
|
||||
|
@ -56,10 +56,18 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include <security/mac/mac_framework.h>
|
||||
|
||||
static fo_rdwr_t soo_read;
|
||||
static fo_rdwr_t soo_write;
|
||||
static fo_ioctl_t soo_ioctl;
|
||||
static fo_poll_t soo_poll;
|
||||
extern fo_kqfilter_t soo_kqfilter;
|
||||
static fo_stat_t soo_stat;
|
||||
static fo_close_t soo_close;
|
||||
|
||||
struct fileops socketops = {
|
||||
.fo_read = soo_read,
|
||||
.fo_write = soo_write,
|
||||
.fo_truncate = soo_truncate,
|
||||
.fo_truncate = invfo_truncate,
|
||||
.fo_ioctl = soo_ioctl,
|
||||
.fo_poll = soo_poll,
|
||||
.fo_kqfilter = soo_kqfilter,
|
||||
@ -71,8 +79,7 @@ struct fileops socketops = {
|
||||
.fo_flags = DFLAG_PASSABLE
|
||||
};
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
static int
|
||||
soo_read(struct file *fp, struct uio *uio, struct ucred *active_cred,
|
||||
int flags, struct thread *td)
|
||||
{
|
||||
@ -88,8 +95,7 @@ soo_read(struct file *fp, struct uio *uio, struct ucred *active_cred,
|
||||
return (error);
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
static int
|
||||
soo_write(struct file *fp, struct uio *uio, struct ucred *active_cred,
|
||||
int flags, struct thread *td)
|
||||
{
|
||||
@ -110,15 +116,7 @@ soo_write(struct file *fp, struct uio *uio, struct ucred *active_cred,
|
||||
return (error);
|
||||
}
|
||||
|
||||
int
|
||||
soo_truncate(struct file *fp, off_t length, struct ucred *active_cred,
|
||||
struct thread *td)
|
||||
{
|
||||
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
soo_ioctl(struct file *fp, u_long cmd, void *data, struct ucred *active_cred,
|
||||
struct thread *td)
|
||||
{
|
||||
@ -226,7 +224,7 @@ soo_ioctl(struct file *fp, u_long cmd, void *data, struct ucred *active_cred,
|
||||
return (error);
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
soo_poll(struct file *fp, int events, struct ucred *active_cred,
|
||||
struct thread *td)
|
||||
{
|
||||
@ -241,7 +239,7 @@ soo_poll(struct file *fp, int events, struct ucred *active_cred,
|
||||
return (sopoll(so, events, fp->f_cred, td));
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
soo_stat(struct file *fp, struct stat *ub, struct ucred *active_cred,
|
||||
struct thread *td)
|
||||
{
|
||||
@ -281,8 +279,7 @@ soo_stat(struct file *fp, struct stat *ub, struct ucred *active_cred,
|
||||
* file reference but the actual socket will not go away until the socket's
|
||||
* ref count hits 0.
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
int
|
||||
static int
|
||||
soo_close(struct file *fp, struct thread *td)
|
||||
{
|
||||
int error = 0;
|
||||
|
@ -160,6 +160,7 @@ static void filt_sowdetach(struct knote *kn);
|
||||
static int filt_sowrite(struct knote *kn, long hint);
|
||||
static int filt_solisten(struct knote *kn, long hint);
|
||||
static int inline hhook_run_socket(struct socket *so, void *hctx, int32_t h_id);
|
||||
fo_kqfilter_t soo_kqfilter;
|
||||
|
||||
static struct filterops solisten_filtops = {
|
||||
.f_isfd = 1,
|
||||
|
@ -231,23 +231,10 @@ int fget_write(struct thread *td, int fd, cap_rights_t *rightsp,
|
||||
struct file **fpp);
|
||||
int _fdrop(struct file *fp, struct thread *td);
|
||||
|
||||
/*
|
||||
* The socket operations are used a couple of places.
|
||||
* XXX: This is wrong, they should go through the operations vector for
|
||||
* XXX: sockets instead of going directly for the individual functions. /phk
|
||||
*/
|
||||
fo_rdwr_t soo_read;
|
||||
fo_rdwr_t soo_write;
|
||||
fo_truncate_t soo_truncate;
|
||||
fo_ioctl_t soo_ioctl;
|
||||
fo_poll_t soo_poll;
|
||||
fo_kqfilter_t soo_kqfilter;
|
||||
fo_stat_t soo_stat;
|
||||
fo_close_t soo_close;
|
||||
|
||||
fo_chmod_t invfo_chmod;
|
||||
fo_chown_t invfo_chown;
|
||||
fo_sendfile_t invfo_sendfile;
|
||||
fo_truncate_t invfo_truncate;
|
||||
|
||||
fo_sendfile_t vn_sendfile;
|
||||
fo_seek_t vn_seek;
|
||||
|
Loading…
x
Reference in New Issue
Block a user