From owner-svn-src-head@freebsd.org Mon Feb 3 22:27:56 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EDB15230BC9; Mon, 3 Feb 2020 22:27:56 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48BMsS61fvz4DKb; Mon, 3 Feb 2020 22:27:56 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C930B7C21; Mon, 3 Feb 2020 22:27:56 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 013MRu8J081637; Mon, 3 Feb 2020 22:27:56 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 013MRtEl081631; Mon, 3 Feb 2020 22:27:55 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <202002032227.013MRtEl081631@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Mon, 3 Feb 2020 22:27:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r357470 - in head/sys: compat/linuxkpi/common/include/linux kern sys X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: in head/sys: compat/linuxkpi/common/include/linux kern sys X-SVN-Commit-Revision: 357470 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Feb 2020 22:27:57 -0000 Author: mjg Date: Mon Feb 3 22:27:55 2020 New Revision: 357470 URL: https://svnweb.freebsd.org/changeset/base/357470 Log: fd: remove the seq argument from fget_unlocked It is almost always NULL. Modified: head/sys/compat/linuxkpi/common/include/linux/file.h head/sys/kern/kern_descrip.c head/sys/kern/sys_generic.c head/sys/kern/tty.c head/sys/kern/vfs_syscalls.c head/sys/sys/filedesc.h Modified: head/sys/compat/linuxkpi/common/include/linux/file.h ============================================================================== --- head/sys/compat/linuxkpi/common/include/linux/file.h Mon Feb 3 22:27:03 2020 (r357469) +++ head/sys/compat/linuxkpi/common/include/linux/file.h Mon Feb 3 22:27:55 2020 (r357470) @@ -54,7 +54,7 @@ linux_fget(unsigned int fd) /* lookup file pointer by file descriptor index */ if (fget_unlocked(curthread->td_proc->p_fd, fd, - &cap_no_rights, &file, NULL) != 0) + &cap_no_rights, &file) != 0) return (NULL); /* check if file handle really belongs to us */ @@ -90,7 +90,7 @@ put_unused_fd(unsigned int fd) struct file *file; if (fget_unlocked(curthread->td_proc->p_fd, fd, - &cap_no_rights, &file, NULL) != 0) { + &cap_no_rights, &file) != 0) { return; } /* @@ -110,7 +110,7 @@ fd_install(unsigned int fd, struct linux_file *filp) struct file *file; if (fget_unlocked(curthread->td_proc->p_fd, fd, - &cap_no_rights, &file, NULL) != 0) { + &cap_no_rights, &file) != 0) { filp->_file = NULL; } else { filp->_file = file; Modified: head/sys/kern/kern_descrip.c ============================================================================== --- head/sys/kern/kern_descrip.c Mon Feb 3 22:27:03 2020 (r357469) +++ head/sys/kern/kern_descrip.c Mon Feb 3 22:27:55 2020 (r357470) @@ -619,7 +619,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_ break; } - error = fget_unlocked(fdp, fd, &cap_flock_rights, &fp, NULL); + error = fget_unlocked(fdp, fd, &cap_flock_rights, &fp); if (error != 0) break; if (fp->f_type != DTYPE_VNODE) { @@ -706,7 +706,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_ * that the closing thread was a bit slower and that the * advisory lock succeeded before the close. */ - error = fget_unlocked(fdp, fd, &cap_no_rights, &fp2, NULL); + error = fget_unlocked(fdp, fd, &cap_no_rights, &fp2); if (error != 0) { fdrop(fp, td); break; @@ -724,7 +724,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_ break; case F_GETLK: - error = fget_unlocked(fdp, fd, &cap_flock_rights, &fp, NULL); + error = fget_unlocked(fdp, fd, &cap_flock_rights, &fp); if (error != 0) break; if (fp->f_type != DTYPE_VNODE) { @@ -758,7 +758,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_ break; case F_ADD_SEALS: - error = fget_unlocked(fdp, fd, &cap_no_rights, &fp, NULL); + error = fget_unlocked(fdp, fd, &cap_no_rights, &fp); if (error != 0) break; error = fo_add_seals(fp, arg); @@ -766,7 +766,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_ break; case F_GET_SEALS: - error = fget_unlocked(fdp, fd, &cap_no_rights, &fp, NULL); + error = fget_unlocked(fdp, fd, &cap_no_rights, &fp); if (error != 0) break; if (fo_get_seals(fp, &seals) == 0) @@ -780,7 +780,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_ arg = arg ? 128 * 1024: 0; /* FALLTHROUGH */ case F_READAHEAD: - error = fget_unlocked(fdp, fd, &cap_no_rights, &fp, NULL); + error = fget_unlocked(fdp, fd, &cap_no_rights, &fp); if (error != 0) break; if (fp->f_type != DTYPE_VNODE) { @@ -831,7 +831,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_ * horrible kludge facilitates the current behavior in a much * cheaper manner until someone(tm) sorts this out. */ - error = fget_unlocked(fdp, fd, &cap_no_rights, &fp, NULL); + error = fget_unlocked(fdp, fd, &cap_no_rights, &fp); if (error != 0) break; if (fp->f_type != DTYPE_VNODE) { @@ -2644,15 +2644,15 @@ fget_cap(struct thread *td, int fd, cap_rights_t *need struct filedesc *fdp = td->td_proc->p_fd; int error; #ifndef CAPABILITIES - error = fget_unlocked(fdp, fd, needrightsp, fpp, NULL); - if (error == 0 && havecapsp != NULL) + error = fget_unlocked(fdp, fd, needrightsp, fpp); + if (havecapsp != NULL && error == 0) filecaps_fill(havecapsp); #else struct file *fp; seqc_t seq; for (;;) { - error = fget_unlocked(fdp, fd, needrightsp, &fp, &seq); + error = fget_unlocked_seq(fdp, fd, needrightsp, &fp, &seq); if (error != 0) return (error); @@ -2683,7 +2683,7 @@ get_locked: } int -fget_unlocked(struct filedesc *fdp, int fd, cap_rights_t *needrightsp, +fget_unlocked_seq(struct filedesc *fdp, int fd, cap_rights_t *needrightsp, struct file **fpp, seqc_t *seqp) { #ifdef CAPABILITIES @@ -2788,7 +2788,7 @@ _fget(struct thread *td, int fd, struct file **fpp, in *fpp = NULL; fdp = td->td_proc->p_fd; - error = fget_unlocked(fdp, fd, needrightsp, &fp, NULL); + error = fget_unlocked(fdp, fd, needrightsp, &fp); if (__predict_false(error != 0)) return (error); if (__predict_false(fp->f_ops == &badfileops)) { @@ -2850,7 +2850,7 @@ fget_mmap(struct thread *td, int fd, cap_rights_t *rig fdp = td->td_proc->p_fd; MPASS(cap_rights_is_set(rightsp, CAP_MMAP)); for (;;) { - error = fget_unlocked(fdp, fd, rightsp, fpp, &seq); + error = fget_unlocked_seq(fdp, fd, rightsp, fpp, &seq); if (__predict_false(error != 0)) return (error); if (__predict_false((*fpp)->f_ops == &badfileops)) { @@ -2893,14 +2893,14 @@ fget_fcntl(struct thread *td, int fd, cap_rights_t *ri { struct filedesc *fdp = td->td_proc->p_fd; #ifndef CAPABILITIES - return (fget_unlocked(fdp, fd, rightsp, fpp, NULL)); + return (fget_unlocked(fdp, fd, rightsp, fpp)); #else int error; seqc_t seq; MPASS(cap_rights_is_set(rightsp, CAP_FCNTL)); for (;;) { - error = fget_unlocked(fdp, fd, rightsp, fpp, &seq); + error = fget_unlocked_seq(fdp, fd, rightsp, fpp, &seq); if (error != 0) return (error); error = cap_fcntl_check(fdp, fd, needfcntl); Modified: head/sys/kern/sys_generic.c ============================================================================== --- head/sys/kern/sys_generic.c Mon Feb 3 22:27:03 2020 (r357469) +++ head/sys/kern/sys_generic.c Mon Feb 3 22:27:55 2020 (r357470) @@ -1245,7 +1245,7 @@ static __inline int getselfd_cap(struct filedesc *fdp, int fd, struct file **fpp) { - return (fget_unlocked(fdp, fd, &cap_event_rights, fpp, NULL)); + return (fget_unlocked(fdp, fd, &cap_event_rights, fpp)); } /* Modified: head/sys/kern/tty.c ============================================================================== --- head/sys/kern/tty.c Mon Feb 3 22:27:03 2020 (r357469) +++ head/sys/kern/tty.c Mon Feb 3 22:27:55 2020 (r357470) @@ -2059,7 +2059,7 @@ ttyhook_register(struct tty **rtp, struct proc *p, int /* Validate the file descriptor. */ fdp = p->p_fd; error = fget_unlocked(fdp, fd, cap_rights_init(&rights, CAP_TTYHOOK), - &fp, NULL); + &fp); if (error != 0) return (error); if (fp->f_ops == &badfileops) { Modified: head/sys/kern/vfs_syscalls.c ============================================================================== --- head/sys/kern/vfs_syscalls.c Mon Feb 3 22:27:03 2020 (r357469) +++ head/sys/kern/vfs_syscalls.c Mon Feb 3 22:27:55 2020 (r357470) @@ -4173,7 +4173,7 @@ getvnode(struct thread *td, int fd, cap_rights_t *righ struct file *fp; int error; - error = fget_unlocked(td->td_proc->p_fd, fd, rightsp, &fp, NULL); + error = fget_unlocked(td->td_proc->p_fd, fd, rightsp, &fp); if (error != 0) return (error); Modified: head/sys/sys/filedesc.h ============================================================================== --- head/sys/sys/filedesc.h Mon Feb 3 22:27:03 2020 (r357469) +++ head/sys/sys/filedesc.h Mon Feb 3 22:27:55 2020 (r357470) @@ -204,8 +204,10 @@ int fget_cap(struct thread *td, int fd, cap_rights_t * struct file **fpp, struct filecaps *havecapsp); /* Return a referenced file from an unlocked descriptor. */ -int fget_unlocked(struct filedesc *fdp, int fd, cap_rights_t *needrightsp, +int fget_unlocked_seq(struct filedesc *fdp, int fd, cap_rights_t *needrightsp, struct file **fpp, seqc_t *seqp); +#define fget_unlocked(fdp, fd, needrightsp, fpp) \ + fget_unlocked_seq(fdp, fd, needrightsp, fpp, NULL) /* Requires a FILEDESC_{S,X}LOCK held and returns without a ref. */ static __inline struct file *