Print this page
6879933 Let SMBFS support extensible attributes per. PSARC 2007/315

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/smbclnt/smbfs/smbfs_client.c
          +++ new/usr/src/uts/common/fs/smbclnt/smbfs/smbfs_client.c
↓ open down ↓ 60 lines elided ↑ open up ↑
  61   61  #include <smbfs/smbfs_subr.h>
  62   62  
  63   63  #include <vm/hat.h>
  64   64  #include <vm/as.h>
  65   65  #include <vm/page.h>
  66   66  #include <vm/pvn.h>
  67   67  #include <vm/seg.h>
  68   68  #include <vm/seg_map.h>
  69   69  #include <vm/seg_vn.h>
  70   70  
  71      -static int smbfs_getattr_cache(vnode_t *, struct smbfattr *);
  72      -static int smbfattr_to_vattr(vnode_t *, struct smbfattr *,
  73      -        struct vattr *);
       71 +static int smbfs_getattr_cache(vnode_t *, smbfattr_t *);
       72 +static void smbfattr_to_vattr(vnode_t *, smbfattr_t *, vattr_t *);
       73 +static void smbfattr_to_xvattr(vnode_t *, smbfattr_t *, vattr_t *);
  74   74  
  75   75  /*
  76   76   * The following code provide zone support in order to perform an action
  77   77   * for each smbfs mount in a zone.  This is also where we would add
  78   78   * per-zone globals and kernel threads for the smbfs module (since
  79   79   * they must be terminated by the shutdown callback).
  80   80   */
  81   81  
  82   82  struct smi_globals {
  83   83          kmutex_t        smg_lock;  /* lock protecting smg_list */
↓ open down ↓ 350 lines elided ↑ open up ↑
 434  434          /*
 435  435           * If we've got cached attributes, just use them;
 436  436           * otherwise go to the server to get attributes,
 437  437           * which will update the cache in the process.
 438  438           */
 439  439          error = smbfs_getattr_cache(vp, &fa);
 440  440          if (error)
 441  441                  error = smbfs_getattr_otw(vp, &fa, cr);
 442  442          if (error)
 443  443                  return (error);
      444 +        vap->va_mask |= mask;
 444  445  
 445  446          /*
 446  447           * Re. client's view of the file size, see:
 447  448           * smbfs_attrcache_fa, smbfs_getattr_otw
 448  449           */
 449      -
 450      -        error = smbfattr_to_vattr(vp, &fa, vap);
 451      -        vap->va_mask = mask;
 452      -
 453      -        return (error);
      450 +        smbfattr_to_vattr(vp, &fa, vap);
      451 +        if (vap->va_mask & AT_XVATTR)
      452 +                smbfattr_to_xvattr(vp, &fa, vap);
      453 +                
      454 +        return (0);
 454  455  }
 455  456  
 456  457  
 457  458  /*
 458  459   * Convert SMB over the wire attributes to vnode form.
 459  460   * Returns 0 for success, error if failed (overflow, etc).
 460  461   * From NFS: nattr_to_vattr()
 461  462   */
 462      -int
      463 +void
 463  464  smbfattr_to_vattr(vnode_t *vp, struct smbfattr *fa, struct vattr *vap)
 464  465  {
 465  466          struct smbnode *np = VTOSMB(vp);
 466  467  
 467      -        /* Set va_mask in caller */
 468      -
 469  468          /*
 470  469           * Take type, mode, uid, gid from the smbfs node,
 471  470           * which has have been updated by _getattr_otw.
 472  471           */
 473  472          vap->va_type = vp->v_type;
 474  473          vap->va_mode = np->n_mode;
 475  474  
 476  475          vap->va_uid = np->n_uid;
 477  476          vap->va_gid = np->n_gid;
 478  477  
↓ open down ↓ 20 lines elided ↑ open up ↑
 499  498          vap->va_ctime = fa->fa_ctime;
 500  499  
 501  500          /*
 502  501           * rdev, blksize, seq are made up.
 503  502           * va_nblocks is 512 byte blocks.
 504  503           */
 505  504          vap->va_rdev = vp->v_rdev;
 506  505          vap->va_blksize = MAXBSIZE;
 507  506          vap->va_nblocks = (fsblkcnt64_t)btod(np->r_attr.fa_allocsz);
 508  507          vap->va_seq = 0;
 509      -
 510      -        return (0);
 511  508  }
 512  509  
      510 +/*
      511 + * smbfattr_to_xvattr: like smbfattr_to_vattr but for
      512 + * Extensible system attributes (PSARC 2007/315)
      513 + */
      514 +static void
      515 +smbfattr_to_xvattr(vnode_t *vp, struct smbfattr *fa, struct vattr *vap)
      516 +{
      517 +        struct smbnode *np = VTOSMB(vp);
      518 +        xvattr_t *xvap = (xvattr_t *)vap;       /* *vap may be xvattr_t */
      519 +        xoptattr_t *xoap = NULL;
 513  520  
      521 +        if ((xoap = xva_getxoptattr(xvap)) == NULL)
      522 +                return;
      523 +
      524 +        if (XVA_ISSET_REQ(xvap, XAT_CREATETIME)) {
      525 +                xoap->xoa_createtime = fa->fa_createtime;
      526 +                XVA_SET_RTN(xvap, XAT_CREATETIME);
      527 +        }
      528 +
      529 +        if (XVA_ISSET_REQ(xvap, XAT_ARCHIVE)) {
      530 +                xoap->xoa_archive =
      531 +                    ((fa->fa_attr & SMB_FA_ARCHIVE) != 0);
      532 +                XVA_SET_RTN(xvap, XAT_ARCHIVE);
      533 +        }
      534 +
      535 +        if (XVA_ISSET_REQ(xvap, XAT_SYSTEM)) {
      536 +                xoap->xoa_system =
      537 +                    ((fa->fa_attr & SMB_FA_SYSTEM) != 0);
      538 +                XVA_SET_RTN(xvap, XAT_SYSTEM);
      539 +        }
      540 +
      541 +        if (XVA_ISSET_REQ(xvap, XAT_READONLY)) {
      542 +                xoap->xoa_readonly =
      543 +                    ((fa->fa_attr & SMB_FA_RDONLY) != 0);
      544 +                XVA_SET_RTN(xvap, XAT_READONLY);
      545 +        }
      546 +
      547 +        if (XVA_ISSET_REQ(xvap, XAT_HIDDEN)) {
      548 +                xoap->xoa_hidden =
      549 +                    ((fa->fa_attr & SMB_FA_HIDDEN) != 0);
      550 +                XVA_SET_RTN(xvap, XAT_HIDDEN);
      551 +        }
      552 +}
      553 +
 514  554  /*
 515  555   * SMB Client initialization and cleanup.
 516  556   * Much of it is per-zone now.
 517  557   */
 518  558  
 519  559  
 520  560  /* ARGSUSED */
 521  561  static void *
 522  562  smbfs_zone_init(zoneid_t zoneid)
 523  563  {
↓ open down ↓ 180 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX