Author: mjg
Date: Fri Sep 23 23:08:23 2016
New Revision: 306282
URL: https://svnweb.freebsd.org/changeset/base/306282

Log:
  cloudabi: use fget_cap instead of hand-rolling capability read
  
  This has a side effect of unbreaking the build after r306272.
  
  Discussed with:               ed

Modified:
  head/sys/compat/cloudabi/cloudabi_fd.c

Modified: head/sys/compat/cloudabi/cloudabi_fd.c
==============================================================================
--- head/sys/compat/cloudabi/cloudabi_fd.c      Fri Sep 23 22:46:19 2016        
(r306281)
+++ head/sys/compat/cloudabi/cloudabi_fd.c      Fri Sep 23 23:08:23 2016        
(r306282)
@@ -456,32 +456,19 @@ cloudabi_sys_fd_stat_get(struct thread *
     struct cloudabi_sys_fd_stat_get_args *uap)
 {
        cloudabi_fdstat_t fsb = {};
-       struct filedesc *fdp;
        struct file *fp;
-       seq_t seq;
        cap_rights_t rights;
+       struct filecaps fcaps;
        int error, oflags;
-       bool modified;
 
        /* Obtain file descriptor properties. */
-       fdp = td->td_proc->p_fd;
-       do {
-               error = fget_unlocked(fdp, uap->fd, cap_rights_init(&rights),
-                   &fp, &seq);
-               if (error != 0)
-                       return (error);
-               if (fp->f_ops == &badfileops) {
-                       fdrop(fp, td);
-                       return (EBADF);
-               }
-
-               rights = *cap_rights(fdp, uap->fd);
-               oflags = OFLAGS(fp->f_flag);
-               fsb.fs_filetype = cloudabi_convert_filetype(fp);
-
-               modified = fd_modified(fdp, uap->fd, seq);
-               fdrop(fp, td);
-       } while (modified);
+       error = fget_cap(td, uap->fd, cap_rights_init(&rights), &fp,
+           &fcaps);
+       if (error != 0)
+               return (error);
+       oflags = OFLAGS(fp->f_flag);
+       fsb.fs_filetype = cloudabi_convert_filetype(fp);
+       fdrop(fp, td);
 
        /* Convert file descriptor flags. */
        if (oflags & O_APPEND)
@@ -492,8 +479,9 @@ cloudabi_sys_fd_stat_get(struct thread *
                fsb.fs_flags |= CLOUDABI_FDFLAG_SYNC;
 
        /* Convert capabilities to CloudABI rights. */
-       convert_capabilities(&rights, fsb.fs_filetype,
+       convert_capabilities(&fcaps.fc_rights, fsb.fs_filetype,
            &fsb.fs_rights_base, &fsb.fs_rights_inheriting);
+       filecaps_free(&fcaps);
        return (copyout(&fsb, (void *)uap->buf, sizeof(fsb)));
 }
 
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to