View | Details | Raw Unified | Return to bug 16946
Collapse All | Expand All

(-)/usr/src/sys/i386/linux/linux_file.orig (-3 / +47 lines)
Lines 199-204 Link Here
199
    } */ fcntl_args; 
199
    } */ fcntl_args; 
200
    struct linux_flock linux_flock;
200
    struct linux_flock linux_flock;
201
    struct flock *bsd_flock;
201
    struct flock *bsd_flock;
202
    struct filedesc *fdp;
203
    struct file *fp;
204
    struct vnode *vp;
205
    long pgid;
206
    struct pgrp *pgrp;
207
    struct tty *tp;
202
    caddr_t sg;
208
    caddr_t sg;
203
    dev_t dev;
209
    dev_t dev;
204
210
Lines 283-291 Link Here
283
289
284
    case LINUX_F_SETOWN:
290
    case LINUX_F_SETOWN:
285
    case LINUX_F_GETOWN:
291
    case LINUX_F_GETOWN:
286
	fcntl_args.cmd = args->cmd == LINUX_F_SETOWN ? F_SETOWN : F_GETOWN;
292
	/*
287
	fcntl_args.arg = args->arg;
293
	 * We need to route around the normal fcntl() for these calls,
288
	return fcntl(p, &fcntl_args); 
294
	 * since it uses TIOC{G,S}PGRP, which is too restrictive for
295
	 * Linux F_{G,S}ETOWN semantics. For sockets, this problem
296
	 * does not exist.
297
	 */
298
	fdp = p->p_fd;
299
	if ((u_int)args->fd >= fdp->fd_nfiles ||
300
		(fp = fdp->fd_ofiles[args->fd]) == NULL)
301
	    return EBADF;
302
	if (fp->f_type == DTYPE_SOCKET) {
303
	    fcntl_args.cmd = args->cmd == LINUX_F_SETOWN ? F_SETOWN : F_GETOWN;
304
    	    fcntl_args.arg = args->arg;
305
	    return fcntl(p, &fcntl_args); 
306
	}
307
	vp = (struct vnode *)fp->f_data;
308
	dev = vn_todev(vp);
309
	if (dev == NODEV)
310
	    return EINVAL;
311
	if (!(devsw(dev)->d_flags & D_TTY))
312
	    return EINVAL;
313
	tp = dev->si_tty;
314
	if (!tp)
315
	    return EINVAL;
316
	if (args->cmd == LINUX_F_GETOWN) {
317
	    p->p_retval[0] = tp->t_pgrp ? tp->t_pgrp->pg_id : NO_PID;
318
	    return 0;
319
	}
320
	if ((long)args->arg <= 0) {
321
	    pgid = -(long)args->arg;
322
	} else {
323
	    struct proc *p1 = pfind((long)args->arg);
324
	    if (p1 == 0)
325
		return (ESRCH);
326
	    pgid = (long)p1->p_pgrp->pg_id;
327
	}
328
	pgrp = pgfind(pgid);
329
	if (pgrp == NULL || pgrp->pg_session != p->p_session)
330
	    return EPERM;
331
	tp->t_pgrp = pgrp;
332
	return 0;
289
    }
333
    }
290
    return EINVAL;
334
    return EINVAL;
291
}
335
}
(-)/usr/src/sys/i386/linux/linux_socket.orig (-23 / +1 lines)
Lines 441-451 Link Here
441
	caddr_t name;
441
	caddr_t name;
442
	int *anamelen;
442
	int *anamelen;
443
    } */ bsd_args;
443
    } */ bsd_args;
444
    struct fcntl_args /* {
445
    int fd;
446
    int cmd;
447
    long arg;
448
    } */ f_args;
449
    int error;
444
    int error;
450
445
451
    if ((error=copyin((caddr_t)args, (caddr_t)&linux_args, sizeof(linux_args))))
446
    if ((error=copyin((caddr_t)args, (caddr_t)&linux_args, sizeof(linux_args))))
Lines 453-476 Link Here
453
    bsd_args.s = linux_args.s;
448
    bsd_args.s = linux_args.s;
454
    bsd_args.name = (caddr_t)linux_args.addr;
449
    bsd_args.name = (caddr_t)linux_args.addr;
455
    bsd_args.anamelen = linux_args.namelen;
450
    bsd_args.anamelen = linux_args.namelen;
456
451
    return oaccept(p, &bsd_args);
457
    if (error = oaccept(p, &bsd_args))
458
	return error;
459
    /*
460
     * linux appears not to copy flags from the parent socket to the
461
     * accepted one, so we must clear the flags in the new descriptor.
462
     */
463
    f_args.fd = p->p_retval[0];
464
    f_args.cmd = F_SETFL;
465
    f_args.arg = 0;
466
   /*
467
     * we ignore errors here since otherwise we would have an open file
468
     * descriptor that wasn't returned to the user.
469
     */
470
    (void) fcntl(p, &f_args);
471
    /* put the file descriptor back as the return value */
472
    p->p_retval[0] = f_args.fd;
473
    return 0;
474
}
452
}
475
453
476
struct linux_getsockname_args {
454
struct linux_getsockname_args {

Return to bug 16946