add ufs_pathconf
[unix-history] / usr / src / sys / ufs / ffs / ufs_vnops.c
index 8549c8f..d5bc891 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)ufs_vnops.c 7.115 (Berkeley) %G%
+ *     @(#)ufs_vnops.c 7.120 (Berkeley) %G%
  */
 
 #include <sys/param.h>
  */
 
 #include <sys/param.h>
@@ -312,8 +312,8 @@ ufs_setattr(ap)
                } else {
                        if (ip->i_flags & (SF_IMMUTABLE | SF_APPEND))
                                return (EPERM);
                } else {
                        if (ip->i_flags & (SF_IMMUTABLE | SF_APPEND))
                                return (EPERM);
-                       ip->i_flags &= 0xffff0000;
-                       ip->i_flags |= (vap->va_flags & 0xffff);
+                       ip->i_flags &= SF_SETTABLE;
+                       ip->i_flags |= (vap->va_flags & UF_SETTABLE);
                }
                ip->i_flag |= ICHG;
                if (vap->va_flags & (IMMUTABLE | APPEND))
                }
                ip->i_flag |= ICHG;
                if (vap->va_flags & (IMMUTABLE | APPEND))
@@ -337,7 +337,7 @@ ufs_setattr(ap)
        if (vap->va_atime.ts_sec != VNOVAL || vap->va_mtime.ts_sec != VNOVAL) {
                if (cred->cr_uid != ip->i_uid &&
                    (error = suser(cred, &p->p_acflag)) &&
        if (vap->va_atime.ts_sec != VNOVAL || vap->va_mtime.ts_sec != VNOVAL) {
                if (cred->cr_uid != ip->i_uid &&
                    (error = suser(cred, &p->p_acflag)) &&
-                   ((vap->va_cflags & VA_UTIMES_NULL) != 0 || 
+                   ((vap->va_vaflags & VA_UTIMES_NULL) == 0 || 
                    (error = VOP_ACCESS(vp, VWRITE, cred, p))))
                        return (error);
                if (vap->va_atime.ts_sec != VNOVAL)
                    (error = VOP_ACCESS(vp, VWRITE, cred, p))))
                        return (error);
                if (vap->va_atime.ts_sec != VNOVAL)
@@ -1258,9 +1258,9 @@ ufs_mkdir(ap)
        dmode = vap->va_mode & 0777;
        dmode |= IFDIR;
        /*
        dmode = vap->va_mode & 0777;
        dmode |= IFDIR;
        /*
-        * Must simulate part of maknode here to acquire the inode, but
-        * not have it entered in the parent directory. The entry is made
-        * later after writing "." and ".." entries.
+        * Must simulate part of ufs_makeinode here to acquire the inode,
+        * but not have it entered in the parent directory. The entry is
+        * made later after writing "." and ".." entries.
         */
        if (error = VOP_VALLOC(dvp, dmode, cnp->cn_cred, &tvp))
                goto out;
         */
        if (error = VOP_VALLOC(dvp, dmode, cnp->cn_cred, &tvp))
                goto out;
@@ -1666,7 +1666,9 @@ ufs_islocked(ap)
  * Calculate the logical to physical mapping if not done already,
  * then call the device strategy routine.
  */
  * Calculate the logical to physical mapping if not done already,
  * then call the device strategy routine.
  */
-int checkblk = 0;
+#include <sys/sysctl.h>
+int checkblk = 1;
+struct ctldebug debug10 = { "checkblk", &checkblk };
 int
 ufs_strategy(ap)
        struct vop_strategy_args /* {
 int
 ufs_strategy(ap)
        struct vop_strategy_args /* {
@@ -1698,9 +1700,11 @@ ufs_strategy(ap)
                /* If this is a clustered block, check sub-blocks as well */
                if (bp->b_saveaddr) {
                        struct buf *tbp;
                /* If this is a clustered block, check sub-blocks as well */
                if (bp->b_saveaddr) {
                        struct buf *tbp;
-                       struct cluster_save *b_save = bp->b_saveaddr;
+                       struct cluster_save *b_save;
                        int i;
                        daddr_t bn;
                        int i;
                        daddr_t bn;
+
+                       b_save = (struct cluster_save *)bp->b_saveaddr;
                        for (i = 0; i < b_save->bs_nchildren; i++) {
                                tbp = b_save->bs_children[i];
                                if ((tbp->b_flags & B_XXX) == 0 &&
                        for (i = 0; i < b_save->bs_nchildren; i++) {
                                tbp = b_save->bs_children[i];
                                if ((tbp->b_flags & B_XXX) == 0 &&
@@ -1882,6 +1886,42 @@ ufsfifo_close(ap)
 }
 #endif /* FIFO */
 
 }
 #endif /* FIFO */
 
+/*
+ * Return POSIX pathconf information applicable to ufs filesystems.
+ */
+ufs_pathconf(ap)
+       struct vop_pathconf_args /* {
+               struct vnode *a_vp;
+               int a_name;
+               int *a_retval;
+       } */ *ap;
+{
+
+       switch (ap->a_name) {
+       case _PC_LINK_MAX:
+               *ap->a_retval = LINK_MAX;
+               return (0);
+       case _PC_NAME_MAX:
+               *ap->a_retval = NAME_MAX;
+               return (0);
+       case _PC_PATH_MAX:
+               *ap->a_retval = PATH_MAX;
+               return (0);
+       case _PC_PIPE_BUF:
+               *ap->a_retval = PIPE_BUF;
+               return (0);
+       case _PC_CHOWN_RESTRICTED:
+               *ap->a_retval = 1;
+               return (0);
+       case _PC_NO_TRUNC:
+               *ap->a_retval = 1;
+               return (0);
+       default:
+               return (EINVAL);
+       }
+       /* NOTREACHED */
+}
+
 /*
  * Advisory record locking support
  */
 /*
  * Advisory record locking support
  */
@@ -2061,8 +2101,11 @@ ufs_makeinode(mode, dvp, vpp, cnp)
                return (error);
        }
        ip = VTOI(tvp);
                return (error);
        }
        ip = VTOI(tvp);
-       ip->i_uid = cnp->cn_cred->cr_uid;
        ip->i_gid = pdir->i_gid;
        ip->i_gid = pdir->i_gid;
+       if ((mode & IFMT) == IFLNK)
+               ip->i_uid = pdir->i_uid;
+       else
+               ip->i_uid = cnp->cn_cred->cr_uid;
 #ifdef QUOTA
        if ((error = getinoquota(ip)) ||
            (error = chkiq(ip, 1, cnp->cn_cred, 0))) {
 #ifdef QUOTA
        if ((error = getinoquota(ip)) ||
            (error = chkiq(ip, 1, cnp->cn_cred, 0))) {