PERFORCE change 125976 for review
Roman Divacky
rdivacky at FreeBSD.org
Sun Sep 2 10:01:57 PDT 2007
http://perforce.freebsd.org/chv.cgi?CH=125976
Change 125976 by rdivacky at rdivacky_witten on 2007/09/02 17:00:56
Implement F_SETSIG. This is for sockets only now. The LINUX_F_SETSIG will be
moved to linux_file.h once this is created with *at patch import. This enables
user-mode linux to mount rootfs.
Tested by: "Yuriy Tsibizov" <yuriy.tsibizov at gmail.com>
Affected files ...
.. //depot/projects/soc2007/rdivacky/linux_fixes/sys/compat/linux/linux_file.c#2 edit
.. //depot/projects/soc2007/rdivacky/linux_fixes/sys/kern/kern_descrip.c#3 edit
.. //depot/projects/soc2007/rdivacky/linux_fixes/sys/kern/kern_sig.c#2 edit
.. //depot/projects/soc2007/rdivacky/linux_fixes/sys/sys/sigio.h#2 edit
Differences ...
==== //depot/projects/soc2007/rdivacky/linux_fixes/sys/compat/linux/linux_file.c#2 (text+ko) ====
@@ -47,6 +47,7 @@
#include <sys/proc.h>
#include <sys/stat.h>
#include <sys/sx.h>
+#include <sys/socketvar.h>
#include <sys/syscallsubr.h>
#include <sys/sysproto.h>
#include <sys/tty.h>
@@ -1131,8 +1132,29 @@
struct file *fp;
long arg;
int error, result;
+ struct socket *so;
switch (args->cmd) {
+#define LINUX_F_SETSIG 10
+ case LINUX_F_SETSIG:
+ error = fget(td, args->fd, &fp);
+ if (error)
+ return (error);
+ /* XXX: should be extended for non-socket files too */
+ if (fp->f_type == DTYPE_SOCKET) {
+ so = (struct socket *)fp->f_data;
+ if (so->so_sigio == NULL) {
+ error = fsetown(td->td_proc->p_pid, &so->so_sigio);
+ if (error) {
+ fdrop(fp, td);
+ return (error);
+ }
+ }
+ so->so_sigio->sig = args->arg;
+ }
+ error = EINVAL;
+ fdrop(fp, td);
+ return (error);
case LINUX_F_DUPFD:
return (kern_fcntl(td, args->fd, F_DUPFD, args->arg));
==== //depot/projects/soc2007/rdivacky/linux_fixes/sys/kern/kern_descrip.c#3 (text+ko) ====
@@ -891,6 +891,7 @@
sigio->sio_pgid = pgid;
sigio->sio_ucred = crhold(curthread->td_ucred);
sigio->sio_myref = sigiop;
+ sigio->sig = 0;
sx_slock(&proctree_lock);
if (pgid > 0) {
==== //depot/projects/soc2007/rdivacky/linux_fixes/sys/kern/kern_sig.c#2 (text+ko) ====
@@ -3187,6 +3187,9 @@
SIGIO_UNLOCK();
return;
}
+ if (sigio->sig != 0)
+ sig = sigio->sig;
+
if (sigio->sio_pgid > 0) {
PROC_LOCK(sigio->sio_proc);
if (CANSIGIO(sigio->sio_ucred, sigio->sio_proc->p_ucred))
==== //depot/projects/soc2007/rdivacky/linux_fixes/sys/sys/sigio.h#2 (text+ko) ====
@@ -53,6 +53,7 @@
* the reference to this structure */
struct ucred *sio_ucred; /* (c) current credentials */
pid_t sio_pgid; /* (c) pgid for signals */
+ int sig; /* (pg) signal to be sent */
};
#define sio_proc sio_u.siu_proc
#define sio_pgrp sio_u.siu_pgrp
More information about the p4-projects
mailing list