Print this page
Try to remove assumption that zone's root vnode is marked VROOT


1286                 if (sarg->vap->va_nodeid != na->fileid)
1287                         error = -1;     /* no match */
1288                 break;
1289         case NFS4ATTR_FREEIT:
1290                 break;
1291         }
1292         return (error);
1293 }
1294 
1295 /* ARGSUSED */
1296 static int
1297 rfs4_get_mntdfileid(nfs4_attr_cmd_t cmd, struct nfs4_svgetit_arg *sarg)
1298 {
1299         int error = 0;
1300         vattr_t *vap, va;
1301         vnode_t *stubvp = NULL, *vp;
1302 
1303         vp = sarg->cs->vp;
1304         sarg->mntdfid_set = FALSE;
1305 
1306         /* VROOT object, must untraverse */
1307         if (vp->v_flag & VROOT) {
1308 
1309                 /* extra hold for vp since untraverse might rele */
1310                 VN_HOLD(vp);
1311                 stubvp = untraverse(vp);
1312 
1313                 /*
1314                  * If vp/stubvp are same, we must be at system
1315                  * root because untraverse returned same vp
1316                  * for a VROOT object.  sarg->vap was setup
1317                  * before we got here, so there's no need to do
1318                  * another getattr -- just use the one in sarg.
1319                  */
1320                 if (VN_CMP(vp, stubvp)) {
1321                         ASSERT(VN_CMP(vp, ZONE_ROOTVP()));
1322                         vap = sarg->vap;
1323                 } else {
1324                         va.va_mask = AT_NODEID;
1325                         vap = &va;
1326                         error = rfs4_vop_getattr(stubvp, vap, 0, sarg->cs->cr);
1327                 }
1328 
1329                 /*
1330                  * Done with stub, time to rele.  If vp and stubvp
1331                  * were the same, then we need to rele either vp or
1332                  * stubvp.  If they weren't the same, then untraverse()
1333                  * already took case of the extra hold on vp, and only
1334                  * the stub needs to be rele'd.  Both cases are handled


1360         return (error);
1361 }
1362 
1363 /* ARGSUSED */
1364 static int
1365 rfs4_fattr4_mounted_on_fileid(nfs4_attr_cmd_t cmd,
1366     struct nfs4_svgetit_arg *sarg, union nfs4_attr_u *na)
1367 {
1368         int     error = 0;
1369 
1370         if (RFS4_MANDATTR_ONLY)
1371                 return (ENOTSUP);
1372 
1373         switch (cmd) {
1374         case NFS4ATTR_SUPPORTED:
1375                 if (sarg->op == NFS4ATTR_SETIT)
1376                         error = EINVAL;
1377                 break;          /* this attr is supported */
1378         case NFS4ATTR_GETIT:
1379         case NFS4ATTR_VERIT:
1380                 if (! sarg->mntdfid_set)
1381                         error = rfs4_get_mntdfileid(cmd, sarg);
1382 
1383                 if (! error && sarg->mntdfid_set) {
1384                         if (cmd == NFS4ATTR_GETIT)
1385                                 na->mounted_on_fileid = sarg->mounted_on_fileid;
1386                         else
1387                                 if (na->mounted_on_fileid !=
1388                                     sarg->mounted_on_fileid)
1389                                         error = -1;
1390                 }
1391                 break;
1392         case NFS4ATTR_SETIT:
1393                 /* read-only attr */
1394                 error = EINVAL;
1395                 break;
1396         case NFS4ATTR_FREEIT:
1397                 break;
1398         }
1399         return (error);
1400 }
1401 
1402 /* ARGSUSED */
1403 static int




1286                 if (sarg->vap->va_nodeid != na->fileid)
1287                         error = -1;     /* no match */
1288                 break;
1289         case NFS4ATTR_FREEIT:
1290                 break;
1291         }
1292         return (error);
1293 }
1294 
1295 /* ARGSUSED */
1296 static int
1297 rfs4_get_mntdfileid(nfs4_attr_cmd_t cmd, struct nfs4_svgetit_arg *sarg)
1298 {
1299         int error = 0;
1300         vattr_t *vap, va;
1301         vnode_t *stubvp = NULL, *vp;
1302 
1303         vp = sarg->cs->vp;
1304         sarg->mntdfid_set = FALSE;
1305 
1306         /* VROOT object or zone's root, must untraverse */
1307         if ((vp->v_flag & VROOT) || VN_IS_CURZONEROOT(vp)) {
1308 
1309                 /* extra hold for vp since untraverse might rele */
1310                 VN_HOLD(vp);
1311                 stubvp = untraverse(vp);
1312 
1313                 /*
1314                  * If vp/stubvp are same, we must be at system-or-zone
1315                  * root because untraverse returned same vp
1316                  * for a VROOT object.  sarg->vap was setup
1317                  * before we got here, so there's no need to do
1318                  * another getattr -- just use the one in sarg.
1319                  */
1320                 if (VN_CMP(vp, stubvp)) {
1321                         ASSERT(VN_CMP(vp, ZONE_ROOTVP()));
1322                         vap = sarg->vap;
1323                 } else {
1324                         va.va_mask = AT_NODEID;
1325                         vap = &va;
1326                         error = rfs4_vop_getattr(stubvp, vap, 0, sarg->cs->cr);
1327                 }
1328 
1329                 /*
1330                  * Done with stub, time to rele.  If vp and stubvp
1331                  * were the same, then we need to rele either vp or
1332                  * stubvp.  If they weren't the same, then untraverse()
1333                  * already took case of the extra hold on vp, and only
1334                  * the stub needs to be rele'd.  Both cases are handled


1360         return (error);
1361 }
1362 
1363 /* ARGSUSED */
1364 static int
1365 rfs4_fattr4_mounted_on_fileid(nfs4_attr_cmd_t cmd,
1366     struct nfs4_svgetit_arg *sarg, union nfs4_attr_u *na)
1367 {
1368         int     error = 0;
1369 
1370         if (RFS4_MANDATTR_ONLY)
1371                 return (ENOTSUP);
1372 
1373         switch (cmd) {
1374         case NFS4ATTR_SUPPORTED:
1375                 if (sarg->op == NFS4ATTR_SETIT)
1376                         error = EINVAL;
1377                 break;          /* this attr is supported */
1378         case NFS4ATTR_GETIT:
1379         case NFS4ATTR_VERIT:
1380                 if (!sarg->mntdfid_set)
1381                         error = rfs4_get_mntdfileid(cmd, sarg);
1382 
1383                 if (!error && sarg->mntdfid_set) {
1384                         if (cmd == NFS4ATTR_GETIT)
1385                                 na->mounted_on_fileid = sarg->mounted_on_fileid;
1386                         else
1387                                 if (na->mounted_on_fileid !=
1388                                     sarg->mounted_on_fileid)
1389                                         error = -1;
1390                 }
1391                 break;
1392         case NFS4ATTR_SETIT:
1393                 /* read-only attr */
1394                 error = EINVAL;
1395                 break;
1396         case NFS4ATTR_FREEIT:
1397                 break;
1398         }
1399         return (error);
1400 }
1401 
1402 /* ARGSUSED */
1403 static int