[BACK]Return to ufs_vnops.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / ufs / ufs

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/sys/ufs/ufs/ufs_vnops.c between version 1.14 and 1.15

version 1.14, 1996/02/09 14:46:08 version 1.15, 1996/02/09 22:36:13
Line 59 
Line 59 
 #include <vm/vm.h>  #include <vm/vm.h>
   
 #include <miscfs/specfs/specdev.h>  #include <miscfs/specfs/specdev.h>
   #include <miscfs/fifofs/fifo.h>
   
 #include <ufs/ufs/quota.h>  #include <ufs/ufs/quota.h>
 #include <ufs/ufs/inode.h>  #include <ufs/ufs/inode.h>
Line 91  union _qcvt {
Line 92  union _qcvt {
  * Create a regular file   * Create a regular file
  */   */
 int  int
 ufs_create(ap)  ufs_create(v)
           void *v;
   {
         struct vop_create_args /* {          struct vop_create_args /* {
                 struct vnode *a_dvp;                  struct vnode *a_dvp;
                 struct vnode **a_vpp;                  struct vnode **a_vpp;
                 struct componentname *a_cnp;                  struct componentname *a_cnp;
                 struct vattr *a_vap;                  struct vattr *a_vap;
         } */ *ap;          } */ *ap = v;
 {          return
         int error;  
   
         if (error =  
             ufs_makeinode(MAKEIMODE(ap->a_vap->va_type, ap->a_vap->va_mode),              ufs_makeinode(MAKEIMODE(ap->a_vap->va_type, ap->a_vap->va_mode),
             ap->a_dvp, ap->a_vpp, ap->a_cnp))                            ap->a_dvp, ap->a_vpp, ap->a_cnp);
                 return (error);  
         return (0);  
 }  }
   
 /*  /*
Line 113  ufs_create(ap)
Line 111  ufs_create(ap)
  */   */
 /* ARGSUSED */  /* ARGSUSED */
 int  int
 ufs_mknod(ap)  ufs_mknod(v)
           void *v;
   {
         struct vop_mknod_args /* {          struct vop_mknod_args /* {
                 struct vnode *a_dvp;                  struct vnode *a_dvp;
                 struct vnode **a_vpp;                  struct vnode **a_vpp;
                 struct componentname *a_cnp;                  struct componentname *a_cnp;
                 struct vattr *a_vap;                  struct vattr *a_vap;
         } */ *ap;          } */ *ap = v;
 {  
         register struct vattr *vap = ap->a_vap;          register struct vattr *vap = ap->a_vap;
         register struct vnode **vpp = ap->a_vpp;          register struct vnode **vpp = ap->a_vpp;
         register struct inode *ip;          register struct inode *ip;
         int error;          int error;
   
         if (error =          if ((error =
             ufs_makeinode(MAKEIMODE(vap->va_type, vap->va_mode),              ufs_makeinode(MAKEIMODE(vap->va_type, vap->va_mode),
             ap->a_dvp, vpp, ap->a_cnp))              ap->a_dvp, vpp, ap->a_cnp)) != 0)
                 return (error);                  return (error);
         ip = VTOI(*vpp);          ip = VTOI(*vpp);
         ip->i_flag |= IN_ACCESS | IN_CHANGE | IN_UPDATE;          ip->i_flag |= IN_ACCESS | IN_CHANGE | IN_UPDATE;
Line 158  ufs_mknod(ap)
Line 157  ufs_mknod(ap)
  */   */
 /* ARGSUSED */  /* ARGSUSED */
 int  int
 ufs_open(ap)  ufs_open(v)
           void *v;
   {
         struct vop_open_args /* {          struct vop_open_args /* {
                 struct vnode *a_vp;                  struct vnode *a_vp;
                 int  a_mode;                  int  a_mode;
                 struct ucred *a_cred;                  struct ucred *a_cred;
                 struct proc *a_p;                  struct proc *a_p;
         } */ *ap;          } */ *ap = v;
 {  
   
         /*          /*
          * Files marked append-only must be opened for appending.           * Files marked append-only must be opened for appending.
Line 183  ufs_open(ap)
Line 183  ufs_open(ap)
  */   */
 /* ARGSUSED */  /* ARGSUSED */
 int  int
 ufs_close(ap)  ufs_close(v)
           void *v;
   {
         struct vop_close_args /* {          struct vop_close_args /* {
                 struct vnode *a_vp;                  struct vnode *a_vp;
                 int  a_fflag;                  int  a_fflag;
                 struct ucred *a_cred;                  struct ucred *a_cred;
                 struct proc *a_p;                  struct proc *a_p;
         } */ *ap;          } */ *ap = v;
 {  
         register struct vnode *vp = ap->a_vp;          register struct vnode *vp = ap->a_vp;
         register struct inode *ip = VTOI(vp);          register struct inode *ip = VTOI(vp);
   
Line 200  ufs_close(ap)
Line 201  ufs_close(ap)
 }  }
   
 int  int
 ufs_access(ap)  ufs_access(v)
           void *v;
   {
         struct vop_access_args /* {          struct vop_access_args /* {
                 struct vnode *a_vp;                  struct vnode *a_vp;
                 int  a_mode;                  int  a_mode;
                 struct ucred *a_cred;                  struct ucred *a_cred;
                 struct proc *a_p;                  struct proc *a_p;
         } */ *ap;          } */ *ap = v;
 {  
         register struct vnode *vp = ap->a_vp;          register struct vnode *vp = ap->a_vp;
         register struct inode *ip = VTOI(vp);          register struct inode *ip = VTOI(vp);
         mode_t mode = ap->a_mode;          mode_t mode = ap->a_mode;
         int error;  
   
 #ifdef DIAGNOSTIC  #ifdef DIAGNOSTIC
         if (!VOP_ISLOCKED(vp)) {          if (!VOP_ISLOCKED(vp)) {
Line 222  ufs_access(ap)
Line 223  ufs_access(ap)
 #ifdef QUOTA  #ifdef QUOTA
         if (mode & VWRITE)          if (mode & VWRITE)
                 switch (vp->v_type) {                  switch (vp->v_type) {
                           int error;
                 case VDIR:                  case VDIR:
                 case VLNK:                  case VLNK:
                 case VREG:                  case VREG:
                         if (error = getinoquota(ip))                          if ((error = getinoquota(ip)) != 0)
                                 return (error);                                  return (error);
                         break;                          break;
                   case VBAD:
                   case VBLK:
                   case VCHR:
                   case VSOCK:
                   case VFIFO:
                   case VNON:
                           break;
                 }                  }
 #endif  #endif
   
Line 240  ufs_access(ap)
Line 249  ufs_access(ap)
   
 /* ARGSUSED */  /* ARGSUSED */
 int  int
 ufs_getattr(ap)  ufs_getattr(v)
           void *v;
   {
         struct vop_getattr_args /* {          struct vop_getattr_args /* {
                 struct vnode *a_vp;                  struct vnode *a_vp;
                 struct vattr *a_vap;                  struct vattr *a_vap;
                 struct ucred *a_cred;                  struct ucred *a_cred;
                 struct proc *a_p;                  struct proc *a_p;
         } */ *ap;          } */ *ap = v;
 {  
         register struct vnode *vp = ap->a_vp;          register struct vnode *vp = ap->a_vp;
         register struct inode *ip = VTOI(vp);          register struct inode *ip = VTOI(vp);
         register struct vattr *vap = ap->a_vap;          register struct vattr *vap = ap->a_vap;
Line 289  ufs_getattr(ap)
Line 299  ufs_getattr(ap)
  * Set attribute vnode op. called from several syscalls   * Set attribute vnode op. called from several syscalls
  */   */
 int  int
 ufs_setattr(ap)  ufs_setattr(v)
           void *v;
   {
         struct vop_setattr_args /* {          struct vop_setattr_args /* {
                 struct vnode *a_vp;                  struct vnode *a_vp;
                 struct vattr *a_vap;                  struct vattr *a_vap;
                 struct ucred *a_cred;                  struct ucred *a_cred;
                 struct proc *a_p;                  struct proc *a_p;
         } */ *ap;          } */ *ap = v;
 {  
         register struct vattr *vap = ap->a_vap;          register struct vattr *vap = ap->a_vap;
         register struct vnode *vp = ap->a_vp;          register struct vnode *vp = ap->a_vp;
         register struct inode *ip = VTOI(vp);          register struct inode *ip = VTOI(vp);
Line 338  ufs_setattr(ap)
Line 349  ufs_setattr(ap)
         /*          /*
          * Go through the fields and update iff not VNOVAL.           * Go through the fields and update iff not VNOVAL.
          */           */
         if (vap->va_uid != (uid_t)VNOVAL || vap->va_gid != (gid_t)VNOVAL)          if (vap->va_uid != (uid_t)VNOVAL || vap->va_gid != (gid_t)VNOVAL) {
                 if (error = ufs_chown(vp, vap->va_uid, vap->va_gid, cred, p))                  error = ufs_chown(vp, vap->va_uid, vap->va_gid, cred, p);
                   if (error)
                         return (error);                          return (error);
           }
         if (vap->va_size != VNOVAL) {          if (vap->va_size != VNOVAL) {
                 if (vp->v_type == VDIR)                  if (vp->v_type == VDIR)
                         return (EISDIR);                          return (EISDIR);
                 if (error = VOP_TRUNCATE(vp, vap->va_size, 0, cred, p))                  error = VOP_TRUNCATE(vp, vap->va_size, 0, cred, p);
                   if (error)
                         return (error);                          return (error);
         }          }
         ip = VTOI(vp);          ip = VTOI(vp);
Line 362  ufs_setattr(ap)
Line 376  ufs_setattr(ap)
                 atimeval.tv_usec = vap->va_atime.tv_nsec / 1000;                  atimeval.tv_usec = vap->va_atime.tv_nsec / 1000;
                 mtimeval.tv_sec = vap->va_mtime.tv_sec;                  mtimeval.tv_sec = vap->va_mtime.tv_sec;
                 mtimeval.tv_usec = vap->va_mtime.tv_nsec / 1000;                  mtimeval.tv_usec = vap->va_mtime.tv_nsec / 1000;
                 if (error = VOP_UPDATE(vp, &atimeval, &mtimeval, 1))                  error = VOP_UPDATE(vp, &atimeval, &mtimeval, 1);
                   if (error)
                         return (error);                          return (error);
         }          }
         error = 0;          error = 0;
Line 439  ufs_chown(vp, uid, gid, cred, p)
Line 454  ufs_chown(vp, uid, gid, cred, p)
         ogid = ip->i_gid;          ogid = ip->i_gid;
         ouid = ip->i_uid;          ouid = ip->i_uid;
 #ifdef QUOTA  #ifdef QUOTA
         if (error = getinoquota(ip))          if ((error = getinoquota(ip)) != 0)
                 return (error);                  return (error);
         if (ouid == uid) {          if (ouid == uid) {
                 dqrele(vp, ip->i_dquot[USRQUOTA]);                  dqrele(vp, ip->i_dquot[USRQUOTA]);
Line 511  good:
Line 526  good:
   
 /* ARGSUSED */  /* ARGSUSED */
 int  int
 ufs_ioctl(ap)  ufs_ioctl(v)
           void *v;
   {
   #if 0
         struct vop_ioctl_args /* {          struct vop_ioctl_args /* {
                 struct vnode *a_vp;                  struct vnode *a_vp;
                 u_long a_command;                  u_long a_command;
Line 519  ufs_ioctl(ap)
Line 537  ufs_ioctl(ap)
                 int  a_fflag;                  int  a_fflag;
                 struct ucred *a_cred;                  struct ucred *a_cred;
                 struct proc *a_p;                  struct proc *a_p;
         } */ *ap;          } */ *ap = v;
 {  #endif
   
         return (ENOTTY);          return (ENOTTY);
 }  }
   
 /* ARGSUSED */  /* ARGSUSED */
 int  int
 ufs_select(ap)  ufs_select(v)
           void *v;
   {
   #if 0
         struct vop_select_args /* {          struct vop_select_args /* {
                 struct vnode *a_vp;                  struct vnode *a_vp;
                 int  a_which;                  int  a_which;
                 int  a_fflags;                  int  a_fflags;
                 struct ucred *a_cred;                  struct ucred *a_cred;
                 struct proc *a_p;                  struct proc *a_p;
         } */ *ap;          } */ *ap = v;
 {  #endif
   
         /*          /*
          * We should really check to see if I/O is possible.           * We should really check to see if I/O is possible.
Line 550  ufs_select(ap)
Line 570  ufs_select(ap)
  */   */
 /* ARGSUSED */  /* ARGSUSED */
 int  int
 ufs_mmap(ap)  ufs_mmap(v)
           void *v;
   {
   #if 0
         struct vop_mmap_args /* {          struct vop_mmap_args /* {
                 struct vnode *a_vp;                  struct vnode *a_vp;
                 int  a_fflags;                  int  a_fflags;
                 struct ucred *a_cred;                  struct ucred *a_cred;
                 struct proc *a_p;                  struct proc *a_p;
         } */ *ap;          } */ *ap = v;
 {  #endif
   
         return (EINVAL);          return (EINVAL);
 }  }
Line 569  ufs_mmap(ap)
Line 592  ufs_mmap(ap)
  */   */
 /* ARGSUSED */  /* ARGSUSED */
 int  int
 ufs_seek(ap)  ufs_seek(v)
           void *v;
   {
   #if 0
         struct vop_seek_args /* {          struct vop_seek_args /* {
                 struct vnode *a_vp;                  struct vnode *a_vp;
                 off_t  a_oldoff;                  off_t  a_oldoff;
                 off_t  a_newoff;                  off_t  a_newoff;
                 struct ucred *a_cred;                  struct ucred *a_cred;
         } */ *ap;          } */ *ap = v;
 {  #endif
   
         return (0);          return (0);
 }  }
   
 int  int
 ufs_remove(ap)  ufs_remove(v)
           void *v;
   {
         struct vop_remove_args /* {          struct vop_remove_args /* {
                 struct vnode *a_dvp;                  struct vnode *a_dvp;
                 struct vnode *a_vp;                  struct vnode *a_vp;
                 struct componentname *a_cnp;                  struct componentname *a_cnp;
         } */ *ap;          } */ *ap = v;
 {  
         register struct inode *ip;          register struct inode *ip;
         register struct vnode *vp = ap->a_vp;          register struct vnode *vp = ap->a_vp;
         register struct vnode *dvp = ap->a_dvp;          register struct vnode *dvp = ap->a_dvp;
Line 621  out:
Line 648  out:
  * link vnode call   * link vnode call
  */   */
 int  int
 ufs_link(ap)  ufs_link(v)
           void *v;
   {
         struct vop_link_args /* {          struct vop_link_args /* {
                 struct vnode *a_dvp;                  struct vnode *a_dvp;
                 struct vnode *a_vp;                  struct vnode *a_vp;
                 struct componentname *a_cnp;                  struct componentname *a_cnp;
         } */ *ap;          } */ *ap = v;
 {          register struct vnode *tdvp = ap->a_dvp;
         register struct vnode *dvp = ap->a_dvp;  
         register struct vnode *vp = ap->a_vp;          register struct vnode *vp = ap->a_vp;
         register struct componentname *cnp = ap->a_cnp;          register struct componentname *cnp = ap->a_cnp;
         register struct inode *ip;          register struct inode *ip;
Line 687  out2:
Line 715  out2:
  * whiteout vnode call   * whiteout vnode call
  */   */
 int  int
 ufs_whiteout(ap)  ufs_whiteout(v)
           void *v;
   {
         struct vop_whiteout_args /* {          struct vop_whiteout_args /* {
                 struct vnode *a_dvp;                  struct vnode *a_dvp;
                 struct componentname *a_cnp;                  struct componentname *a_cnp;
                 int a_flags;                  int a_flags;
         } */ *ap;          } */ *ap = v;
 {  
         struct vnode *dvp = ap->a_dvp;          struct vnode *dvp = ap->a_dvp;
         struct componentname *cnp = ap->a_cnp;          struct componentname *cnp = ap->a_cnp;
         struct direct newdir;          struct direct newdir;
         int error;          int error = 0;
   
         switch (ap->a_flags) {          switch (ap->a_flags) {
         case LOOKUP:          case LOOKUP:
Line 766  ufs_whiteout(ap)
Line 795  ufs_whiteout(ap)
  *    directory.   *    directory.
  */   */
 int  int
 ufs_rename(ap)  ufs_rename(v)
           void *v;
   {
         struct vop_rename_args  /* {          struct vop_rename_args  /* {
                 struct vnode *a_fdvp;                  struct vnode *a_fdvp;
                 struct vnode *a_fvp;                  struct vnode *a_fvp;
Line 774  ufs_rename(ap)
Line 805  ufs_rename(ap)
                 struct vnode *a_tdvp;                  struct vnode *a_tdvp;
                 struct vnode *a_tvp;                  struct vnode *a_tvp;
                 struct componentname *a_tcnp;                  struct componentname *a_tcnp;
         } */ *ap;          } */ *ap = v;
 {  
         struct vnode *tvp = ap->a_tvp;          struct vnode *tvp = ap->a_tvp;
         register struct vnode *tdvp = ap->a_tdvp;          register struct vnode *tdvp = ap->a_tdvp;
         struct vnode *fvp = ap->a_fvp;          struct vnode *fvp = ap->a_fvp;
Line 844  abortit:
Line 874  abortit:
                 (void) relookup(fdvp, &fvp, fcnp);                  (void) relookup(fdvp, &fvp, fcnp);
                 return (VOP_REMOVE(fdvp, fvp, fcnp));                  return (VOP_REMOVE(fdvp, fvp, fcnp));
         }          }
         if (error = VOP_LOCK(fvp))          if ((error = VOP_LOCK(fvp)) != 0)
                 goto abortit;                  goto abortit;
         dp = VTOI(fdvp);          dp = VTOI(fdvp);
         ip = VTOI(fvp);          ip = VTOI(fvp);
Line 888  abortit:
Line 918  abortit:
         ip->i_nlink++;          ip->i_nlink++;
         ip->i_flag |= IN_CHANGE;          ip->i_flag |= IN_CHANGE;
         tv = time;          tv = time;
         if (error = VOP_UPDATE(fvp, &tv, &tv, 1)) {          if ((error = VOP_UPDATE(fvp, &tv, &tv, 1)) != 0) {
                 VOP_UNLOCK(fvp);                  VOP_UNLOCK(fvp);
                 goto bad;                  goto bad;
         }          }
Line 912  abortit:
Line 942  abortit:
                         goto bad;                          goto bad;
                 if (xp != NULL)                  if (xp != NULL)
                         vput(tvp);                          vput(tvp);
                 if (error = ufs_checkpath(ip, dp, tcnp->cn_cred))                  if ((error = ufs_checkpath(ip, dp, tcnp->cn_cred)) != 0)
                         goto out;                          goto out;
                 if ((tcnp->cn_flags & SAVESTART) == 0)                  if ((tcnp->cn_flags & SAVESTART) == 0)
                         panic("ufs_rename: lost to startdir");                          panic("ufs_rename: lost to startdir");
                 if (error = relookup(tdvp, &tvp, tcnp))                  if ((error = relookup(tdvp, &tvp, tcnp)) != 0)
                         goto out;                          goto out;
                 dp = VTOI(tdvp);                  dp = VTOI(tdvp);
                 xp = NULL;                  xp = NULL;
Line 945  abortit:
Line 975  abortit:
                         }                          }
                         dp->i_nlink++;                          dp->i_nlink++;
                         dp->i_flag |= IN_CHANGE;                          dp->i_flag |= IN_CHANGE;
                         if (error = VOP_UPDATE(tdvp, &tv, &tv, 1))                          if ((error = VOP_UPDATE(tdvp, &tv, &tv, 1)) != 0)
                                 goto bad;                                  goto bad;
                 }                  }
                 if (error = ufs_direnter(ip, tdvp, tcnp)) {                  if ((error = ufs_direnter(ip, tdvp, tcnp)) != 0) {
                         if (doingdirectory && newparent) {                          if (doingdirectory && newparent) {
                                 dp->i_nlink--;                                  dp->i_nlink--;
                                 dp->i_flag |= IN_CHANGE;                                  dp->i_flag |= IN_CHANGE;
Line 997  abortit:
Line 1027  abortit:
                         error = EISDIR;                          error = EISDIR;
                         goto bad;                          goto bad;
                 }                  }
                 if (error = ufs_dirrewrite(dp, ip, tcnp))                  if ((error = ufs_dirrewrite(dp, ip, tcnp)) != 0)
                         goto bad;                          goto bad;
                 /*                  /*
                  * If the target directory is in the same                   * If the target directory is in the same
Line 1152  static struct odirtemplate omastertempla
Line 1182  static struct odirtemplate omastertempla
  * Mkdir system call   * Mkdir system call
  */   */
 int  int
 ufs_mkdir(ap)  ufs_mkdir(v)
           void *v;
   {
         struct vop_mkdir_args /* {          struct vop_mkdir_args /* {
                 struct vnode *a_dvp;                  struct vnode *a_dvp;
                 struct vnode **a_vpp;                  struct vnode **a_vpp;
                 struct componentname *a_cnp;                  struct componentname *a_cnp;
                 struct vattr *a_vap;                  struct vattr *a_vap;
         } */ *ap;          } */ *ap = v;
 {  
         register struct vnode *dvp = ap->a_dvp;          register struct vnode *dvp = ap->a_dvp;
         register struct vattr *vap = ap->a_vap;          register struct vattr *vap = ap->a_vap;
         register struct componentname *cnp = ap->a_cnp;          register struct componentname *cnp = ap->a_cnp;
Line 1185  ufs_mkdir(ap)
Line 1216  ufs_mkdir(ap)
          * but not have it entered in the parent directory. The entry is           * but not have it entered in the parent directory. The entry is
          * made later after writing "." and ".." entries.           * made later after writing "." and ".." entries.
          */           */
         if (error = VOP_VALLOC(dvp, dmode, cnp->cn_cred, &tvp))          if ((error = VOP_VALLOC(dvp, dmode, cnp->cn_cred, &tvp)) != 0)
                 goto out;                  goto out;
         ip = VTOI(tvp);          ip = VTOI(tvp);
         ip->i_uid = cnp->cn_cred->cr_uid;          ip->i_uid = cnp->cn_cred->cr_uid;
Line 1217  ufs_mkdir(ap)
Line 1248  ufs_mkdir(ap)
          */           */
         dp->i_nlink++;          dp->i_nlink++;
         dp->i_flag |= IN_CHANGE;          dp->i_flag |= IN_CHANGE;
         if (error = VOP_UPDATE(dvp, &tv, &tv, 1))          if ((error = VOP_UPDATE(dvp, &tv, &tv, 1)) != 0)
                 goto bad;                  goto bad;
   
         /* Initialize directory with "." and ".." from static template. */          /* Initialize directory with "." and ".." from static template. */
Line 1244  ufs_mkdir(ap)
Line 1275  ufs_mkdir(ap)
         }          }
   
         /* Directory set up, now install it's entry in the parent directory. */          /* Directory set up, now install it's entry in the parent directory. */
         if (error = ufs_direnter(ip, dvp, cnp)) {          if ((error = ufs_direnter(ip, dvp, cnp)) != 0) {
                 dp->i_nlink--;                  dp->i_nlink--;
                 dp->i_flag |= IN_CHANGE;                  dp->i_flag |= IN_CHANGE;
         }          }
Line 1269  out:
Line 1300  out:
  * Rmdir system call.   * Rmdir system call.
  */   */
 int  int
 ufs_rmdir(ap)  ufs_rmdir(v)
           void *v;
   {
         struct vop_rmdir_args /* {          struct vop_rmdir_args /* {
                 struct vnode *a_dvp;                  struct vnode *a_dvp;
                 struct vnode *a_vp;                  struct vnode *a_vp;
                 struct componentname *a_cnp;                  struct componentname *a_cnp;
         } */ *ap;          } */ *ap = v;
 {  
         register struct vnode *vp = ap->a_vp;          register struct vnode *vp = ap->a_vp;
         register struct vnode *dvp = ap->a_dvp;          register struct vnode *dvp = ap->a_dvp;
         register struct componentname *cnp = ap->a_cnp;          register struct componentname *cnp = ap->a_cnp;
Line 1314  ufs_rmdir(ap)
Line 1346  ufs_rmdir(ap)
          * inode.  If we crash in between, the directory           * inode.  If we crash in between, the directory
          * will be reattached to lost+found,           * will be reattached to lost+found,
          */           */
         if (error = ufs_dirremove(dvp, cnp))          if ((error = ufs_dirremove(dvp, cnp)) != 0)
                 goto out;                  goto out;
         dp->i_nlink--;          dp->i_nlink--;
         dp->i_flag |= IN_CHANGE;          dp->i_flag |= IN_CHANGE;
Line 1347  out:
Line 1379  out:
  * symlink -- make a symbolic link   * symlink -- make a symbolic link
  */   */
 int  int
 ufs_symlink(ap)  ufs_symlink(v)
           void *v;
   {
         struct vop_symlink_args /* {          struct vop_symlink_args /* {
                 struct vnode *a_dvp;                  struct vnode *a_dvp;
                 struct vnode **a_vpp;                  struct vnode **a_vpp;
                 struct componentname *a_cnp;                  struct componentname *a_cnp;
                 struct vattr *a_vap;                  struct vattr *a_vap;
                 char *a_target;                  char *a_target;
         } */ *ap;          } */ *ap = v;
 {  
         register struct vnode *vp, **vpp = ap->a_vpp;          register struct vnode *vp, **vpp = ap->a_vpp;
         register struct inode *ip;          register struct inode *ip;
         int len, error;          int len, error;
   
         if (error = ufs_makeinode(IFLNK | ap->a_vap->va_mode, ap->a_dvp,          error = ufs_makeinode(IFLNK | ap->a_vap->va_mode, ap->a_dvp,
             vpp, ap->a_cnp))                                vpp, ap->a_cnp);
           if (error)
                 return (error);                  return (error);
         vp = *vpp;          vp = *vpp;
         len = strlen(ap->a_target);          len = strlen(ap->a_target);
Line 1388  ufs_symlink(ap)
Line 1422  ufs_symlink(ap)
  * by <sys/dirent.h>.   * by <sys/dirent.h>.
  */   */
 int  int
 ufs_readdir(ap)  ufs_readdir(v)
           void *v;
   {
         struct vop_readdir_args /* {          struct vop_readdir_args /* {
                 struct vnode *a_vp;                  struct vnode *a_vp;
                 struct uio *a_uio;                  struct uio *a_uio;
Line 1396  ufs_readdir(ap)
Line 1432  ufs_readdir(ap)
                 int *a_eofflag;                  int *a_eofflag;
                 u_long *a_cookies;                  u_long *a_cookies;
                 int ncookies;                  int ncookies;
         } */ *ap;          } */ *ap = v;
 {  
         register struct uio *uio = ap->a_uio;          register struct uio *uio = ap->a_uio;
         int error;          int error;
         size_t count, lost;          size_t count, lost;
Line 1486  ufs_readdir(ap)
Line 1521  ufs_readdir(ap)
  * Return target name of a symbolic link   * Return target name of a symbolic link
  */   */
 int  int
 ufs_readlink(ap)  ufs_readlink(v)
           void *v;
   {
         struct vop_readlink_args /* {          struct vop_readlink_args /* {
                 struct vnode *a_vp;                  struct vnode *a_vp;
                 struct uio *a_uio;                  struct uio *a_uio;
                 struct ucred *a_cred;                  struct ucred *a_cred;
         } */ *ap;          } */ *ap = v;
 {  
         register struct vnode *vp = ap->a_vp;          register struct vnode *vp = ap->a_vp;
         register struct inode *ip = VTOI(vp);          register struct inode *ip = VTOI(vp);
         int isize;          int isize;
Line 1512  ufs_readlink(ap)
Line 1548  ufs_readlink(ap)
  */   */
 /* ARGSUSED */  /* ARGSUSED */
 int  int
 ufs_abortop(ap)  ufs_abortop(v)
           void *v;
   {
         struct vop_abortop_args /* {          struct vop_abortop_args /* {
                 struct vnode *a_dvp;                  struct vnode *a_dvp;
                 struct componentname *a_cnp;                  struct componentname *a_cnp;
         } */ *ap;          } */ *ap = v;
 {  
         if ((ap->a_cnp->cn_flags & (HASBUF | SAVESTART)) == HASBUF)          if ((ap->a_cnp->cn_flags & (HASBUF | SAVESTART)) == HASBUF)
                 FREE(ap->a_cnp->cn_pnbuf, M_NAMEI);                  FREE(ap->a_cnp->cn_pnbuf, M_NAMEI);
         return (0);          return (0);
Line 1527  ufs_abortop(ap)
Line 1564  ufs_abortop(ap)
  * Lock an inode. If its already locked, set the WANT bit and sleep.   * Lock an inode. If its already locked, set the WANT bit and sleep.
  */   */
 int  int
 ufs_lock(ap)  ufs_lock(v)
           void *v;
   {
         struct vop_lock_args /* {          struct vop_lock_args /* {
                 struct vnode *a_vp;                  struct vnode *a_vp;
         } */ *ap;          } */ *ap = v;
 {  
         register struct vnode *vp = ap->a_vp;          register struct vnode *vp = ap->a_vp;
         register struct inode *ip;          register struct inode *ip;
   #ifdef DIAGNOSTIC
         struct proc *p = curproc;       /* XXX */          struct proc *p = curproc;       /* XXX */
   #endif
   
 start:  start:
         while (vp->v_flag & VXLOCK) {          while (vp->v_flag & VXLOCK) {
Line 1577  start:
Line 1617  start:
  */   */
 int lockcount = 90;  int lockcount = 90;
 int  int
 ufs_unlock(ap)  ufs_unlock(v)
           void *v;
   {
         struct vop_unlock_args /* {          struct vop_unlock_args /* {
                 struct vnode *a_vp;                  struct vnode *a_vp;
         } */ *ap;          } */ *ap = v;
 {  
         register struct inode *ip = VTOI(ap->a_vp);          register struct inode *ip = VTOI(ap->a_vp);
   #ifdef DIAGNOSTIC
         struct proc *p = curproc;       /* XXX */          struct proc *p = curproc;       /* XXX */
   #endif
   
 #ifdef DIAGNOSTIC  #ifdef DIAGNOSTIC
         if ((ip->i_flag & IN_LOCKED) == 0) {          if ((ip->i_flag & IN_LOCKED) == 0) {
Line 1608  ufs_unlock(ap)
Line 1651  ufs_unlock(ap)
  * Check for a locked inode.   * Check for a locked inode.
  */   */
 int  int
 ufs_islocked(ap)  ufs_islocked(v)
           void *v;
   {
         struct vop_islocked_args /* {          struct vop_islocked_args /* {
                 struct vnode *a_vp;                  struct vnode *a_vp;
         } */ *ap;          } */ *ap = v;
 {  
   
         if (VTOI(ap->a_vp)->i_flag & IN_LOCKED)          if (VTOI(ap->a_vp)->i_flag & IN_LOCKED)
                 return (1);                  return (1);
Line 1624  ufs_islocked(ap)
Line 1668  ufs_islocked(ap)
  * then call the device strategy routine.   * then call the device strategy routine.
  */   */
 int  int
 ufs_strategy(ap)  ufs_strategy(v)
           void *v;
   {
         struct vop_strategy_args /* {          struct vop_strategy_args /* {
                 struct buf *a_bp;                  struct buf *a_bp;
         } */ *ap;          } */ *ap = v;
 {  
         register struct buf *bp = ap->a_bp;          register struct buf *bp = ap->a_bp;
         register struct vnode *vp = bp->b_vp;          register struct vnode *vp = bp->b_vp;
         register struct inode *ip;          register struct inode *ip;
Line 1638  ufs_strategy(ap)
Line 1683  ufs_strategy(ap)
         if (vp->v_type == VBLK || vp->v_type == VCHR)          if (vp->v_type == VBLK || vp->v_type == VCHR)
                 panic("ufs_strategy: spec");                  panic("ufs_strategy: spec");
         if (bp->b_blkno == bp->b_lblkno) {          if (bp->b_blkno == bp->b_lblkno) {
                 if (error =                  error = VOP_BMAP(vp, bp->b_lblkno, NULL, &bp->b_blkno,
                     VOP_BMAP(vp, bp->b_lblkno, NULL, &bp->b_blkno, NULL)) {                                   NULL);
                   if (error) {
                         bp->b_error = error;                          bp->b_error = error;
                         bp->b_flags |= B_ERROR;                          bp->b_flags |= B_ERROR;
                         biodone(bp);                          biodone(bp);
Line 1662  ufs_strategy(ap)
Line 1708  ufs_strategy(ap)
  * Print out the contents of an inode.   * Print out the contents of an inode.
  */   */
 int  int
 ufs_print(ap)  ufs_print(v)
           void *v;
   {
         struct vop_print_args /* {          struct vop_print_args /* {
                 struct vnode *a_vp;                  struct vnode *a_vp;
         } */ *ap;          } */ *ap = v;
 {  
         register struct vnode *vp = ap->a_vp;          register struct vnode *vp = ap->a_vp;
         register struct inode *ip = VTOI(vp);          register struct inode *ip = VTOI(vp);
   
Line 1690  ufs_print(ap)
Line 1737  ufs_print(ap)
  * Read wrapper for special devices.   * Read wrapper for special devices.
  */   */
 int  int
 ufsspec_read(ap)  ufsspec_read(v)
           void *v;
   {
         struct vop_read_args /* {          struct vop_read_args /* {
                 struct vnode *a_vp;                  struct vnode *a_vp;
                 struct uio *a_uio;                  struct uio *a_uio;
                 int  a_ioflag;                  int  a_ioflag;
                 struct ucred *a_cred;                  struct ucred *a_cred;
         } */ *ap;          } */ *ap = v;
 {  
   
         /*          /*
          * Set access flag.           * Set access flag.
Line 1710  ufsspec_read(ap)
Line 1758  ufsspec_read(ap)
  * Write wrapper for special devices.   * Write wrapper for special devices.
  */   */
 int  int
 ufsspec_write(ap)  ufsspec_write(v)
           void *v;
   {
         struct vop_write_args /* {          struct vop_write_args /* {
                 struct vnode *a_vp;                  struct vnode *a_vp;
                 struct uio *a_uio;                  struct uio *a_uio;
                 int  a_ioflag;                  int  a_ioflag;
                 struct ucred *a_cred;                  struct ucred *a_cred;
         } */ *ap;          } */ *ap = v;
 {  
   
         /*          /*
          * Set update and change flags.           * Set update and change flags.
Line 1732  ufsspec_write(ap)
Line 1781  ufsspec_write(ap)
  * Update the times on the inode then do device close.   * Update the times on the inode then do device close.
  */   */
 int  int
 ufsspec_close(ap)  ufsspec_close(v)
           void *v;
   {
         struct vop_close_args /* {          struct vop_close_args /* {
                 struct vnode *a_vp;                  struct vnode *a_vp;
                 int  a_fflag;                  int  a_fflag;
                 struct ucred *a_cred;                  struct ucred *a_cred;
                 struct proc *a_p;                  struct proc *a_p;
         } */ *ap;          } */ *ap = v;
 {  
         register struct inode *ip = VTOI(ap->a_vp);          register struct inode *ip = VTOI(ap->a_vp);
   
         if (ap->a_vp->v_usecount > 1 && !(ip->i_flag & IN_LOCKED))          if (ap->a_vp->v_usecount > 1 && !(ip->i_flag & IN_LOCKED))
Line 1752  ufsspec_close(ap)
Line 1802  ufsspec_close(ap)
  * Read wrapper for fifo's   * Read wrapper for fifo's
  */   */
 int  int
 ufsfifo_read(ap)  ufsfifo_read(v)
           void *v;
   {
         struct vop_read_args /* {          struct vop_read_args /* {
                 struct vnode *a_vp;                  struct vnode *a_vp;
                 struct uio *a_uio;                  struct uio *a_uio;
                 int  a_ioflag;                  int  a_ioflag;
                 struct ucred *a_cred;                  struct ucred *a_cred;
         } */ *ap;          } */ *ap = v;
 {          extern int (**fifo_vnodeop_p) __P((void *));
         extern int (**fifo_vnodeop_p)();  
   
         /*          /*
          * Set access flag.           * Set access flag.
Line 1773  ufsfifo_read(ap)
Line 1824  ufsfifo_read(ap)
  * Write wrapper for fifo's.   * Write wrapper for fifo's.
  */   */
 int  int
 ufsfifo_write(ap)  ufsfifo_write(v)
           void *v;
   {
         struct vop_write_args /* {          struct vop_write_args /* {
                 struct vnode *a_vp;                  struct vnode *a_vp;
                 struct uio *a_uio;                  struct uio *a_uio;
                 int  a_ioflag;                  int  a_ioflag;
                 struct ucred *a_cred;                  struct ucred *a_cred;
         } */ *ap;          } */ *ap = v;
 {          extern int (**fifo_vnodeop_p) __P((void *));
         extern int (**fifo_vnodeop_p)();  
   
         /*          /*
          * Set update and change flags.           * Set update and change flags.
Line 1795  ufsfifo_write(ap)
Line 1847  ufsfifo_write(ap)
  *   *
  * Update the times on the inode then do device close.   * Update the times on the inode then do device close.
  */   */
 ufsfifo_close(ap)  int
   ufsfifo_close(v)
           void *v;
   {
         struct vop_close_args /* {          struct vop_close_args /* {
                 struct vnode *a_vp;                  struct vnode *a_vp;
                 int  a_fflag;                  int  a_fflag;
                 struct ucred *a_cred;                  struct ucred *a_cred;
                 struct proc *a_p;                  struct proc *a_p;
         } */ *ap;          } */ *ap = v;
 {          extern int (**fifo_vnodeop_p) __P((void *));
         extern int (**fifo_vnodeop_p)();  
         register struct inode *ip = VTOI(ap->a_vp);          register struct inode *ip = VTOI(ap->a_vp);
   
         if (ap->a_vp->v_usecount > 1 && !(ip->i_flag & IN_LOCKED))          if (ap->a_vp->v_usecount > 1 && !(ip->i_flag & IN_LOCKED))
Line 1815  ufsfifo_close(ap)
Line 1869  ufsfifo_close(ap)
 /*  /*
  * Return POSIX pathconf information applicable to ufs filesystems.   * Return POSIX pathconf information applicable to ufs filesystems.
  */   */
 ufs_pathconf(ap)  int
   ufs_pathconf(v)
           void *v;
   {
         struct vop_pathconf_args /* {          struct vop_pathconf_args /* {
                 struct vnode *a_vp;                  struct vnode *a_vp;
                 int a_name;                  int a_name;
                 register_t *a_retval;                  register_t *a_retval;
         } */ *ap;          } */ *ap = v;
 {  
   
         switch (ap->a_name) {          switch (ap->a_name) {
         case _PC_LINK_MAX:          case _PC_LINK_MAX:
Line 1852  ufs_pathconf(ap)
Line 1908  ufs_pathconf(ap)
  * Advisory record locking support   * Advisory record locking support
  */   */
 int  int
 ufs_advlock(ap)  ufs_advlock(v)
           void *v;
   {
         struct vop_advlock_args /* {          struct vop_advlock_args /* {
                 struct vnode *a_vp;                  struct vnode *a_vp;
                 caddr_t  a_id;                  caddr_t  a_id;
                 int  a_op;                  int  a_op;
                 struct flock *a_fl;                  struct flock *a_fl;
                 int  a_flags;                  int  a_flags;
         } */ *ap;          } */ *ap = v;
 {  
         register struct inode *ip = VTOI(ap->a_vp);          register struct inode *ip = VTOI(ap->a_vp);
   
         return (lf_advlock(&ip->i_lockf, ip->i_size, ap->a_id, ap->a_op,          return (lf_advlock(&ip->i_lockf, ip->i_size, ap->a_id, ap->a_op,
Line 1874  ufs_advlock(ap)
Line 1931  ufs_advlock(ap)
 int  int
 ufs_vinit(mntp, specops, fifoops, vpp)  ufs_vinit(mntp, specops, fifoops, vpp)
         struct mount *mntp;          struct mount *mntp;
         int (**specops)();          int (**specops) __P((void *));
         int (**fifoops)();          int (**fifoops) __P((void *));
         struct vnode **vpp;          struct vnode **vpp;
 {  {
         struct inode *ip;          struct inode *ip;
Line 1887  ufs_vinit(mntp, specops, fifoops, vpp)
Line 1944  ufs_vinit(mntp, specops, fifoops, vpp)
         case VCHR:          case VCHR:
         case VBLK:          case VBLK:
                 vp->v_op = specops;                  vp->v_op = specops;
                 if (nvp = checkalias(vp, ip->i_rdev, mntp)) {                  if ((nvp = checkalias(vp, ip->i_rdev, mntp)) != NULL) {
                         /*                          /*
                          * Discard unneeded vnode, but save its inode.                           * Discard unneeded vnode, but save its inode.
                          */                           */
Line 1913  ufs_vinit(mntp, specops, fifoops, vpp)
Line 1970  ufs_vinit(mntp, specops, fifoops, vpp)
 #else  #else
                 return (EOPNOTSUPP);                  return (EOPNOTSUPP);
 #endif  #endif
           case VNON:
           case VBAD:
           case VSOCK:
           case VLNK:
           case VDIR:
           case VREG:
                   break;
         }          }
         if (ip->i_number == ROOTINO)          if (ip->i_number == ROOTINO)
                 vp->v_flag |= VROOT;                  vp->v_flag |= VROOT;
Line 1949  ufs_makeinode(mode, dvp, vpp, cnp)
Line 2013  ufs_makeinode(mode, dvp, vpp, cnp)
         if ((mode & IFMT) == 0)          if ((mode & IFMT) == 0)
                 mode |= IFREG;                  mode |= IFREG;
   
         if (error = VOP_VALLOC(dvp, mode, cnp->cn_cred, &tvp)) {          if ((error = VOP_VALLOC(dvp, mode, cnp->cn_cred, &tvp)) != 0) {
                 free(cnp->cn_pnbuf, M_NAMEI);                  free(cnp->cn_pnbuf, M_NAMEI);
                 vput(dvp);                  vput(dvp);
                 return (error);                  return (error);
         }          }
         ip = VTOI(tvp);          ip = VTOI(tvp);
         ip->i_gid = pdir->i_gid;          ip->i_gid = pdir->i_gid;
         ip->i_uid = cnp->cn_cred->cr_uid;          if ((mode & IFMT) == IFLNK)
                   ip->i_uid = pdir->i_uid;
           else
                   ip->i_uid = cnp->cn_cred->cr_uid;
 #ifdef QUOTA  #ifdef QUOTA
         if ((error = getinoquota(ip)) ||          if ((error = getinoquota(ip)) ||
             (error = chkiq(ip, 1, cnp->cn_cred, 0))) {              (error = chkiq(ip, 1, cnp->cn_cred, 0))) {
Line 1982  ufs_makeinode(mode, dvp, vpp, cnp)
Line 2049  ufs_makeinode(mode, dvp, vpp, cnp)
          * Make sure inode goes to disk before directory entry.           * Make sure inode goes to disk before directory entry.
          */           */
         tv = time;          tv = time;
         if (error = VOP_UPDATE(tvp, &tv, &tv, 1))          if ((error = VOP_UPDATE(tvp, &tv, &tv, 1)) != 0)
                 goto bad;                  goto bad;
         if (error = ufs_direnter(ip, dvp, cnp))          if ((error = ufs_direnter(ip, dvp, cnp)) != 0)
                 goto bad;                  goto bad;
         if ((cnp->cn_flags & SAVESTART) == 0)          if ((cnp->cn_flags & SAVESTART) == 0)
                 FREE(cnp->cn_pnbuf, M_NAMEI);                  FREE(cnp->cn_pnbuf, M_NAMEI);

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15

CVSweb <webmaster@jp.NetBSD.org>