Ejemplo n.º 1
0
/**
 * FSAL_get_quota :
 * Gets the quota for a given path.
 *
 * \param  pfsal_path
 *        path to the filesystem whose quota are requested
 * \param quota_type
 *         the kind of requested quota (user or group)
 * \param  fsal_uid
 * 	  uid for the user whose quota are requested
 * \param pquota (input):
 *        Parameter to the structure containing the requested quotas
 *
 * \return Major error codes :
 *        - ERR_FSAL_NO_ERROR     (no error)
 *        - Another error code if an error occured.
 */
fsal_status_t COMMON_get_quota(fsal_path_t * pfsal_path,       /* IN */
                                int quota_type, /* IN */
                                fsal_uid_t fsal_uid,    /* IN */
                                fsal_quota_t * pquota)  /* OUT */
{
  struct dqblk fs_quota;
  char fs_spec[MAXPATHLEN];

  if(!pfsal_path || !pquota)
    ReturnCode(ERR_FSAL_FAULT, 0);

  if(fsal_internal_path2fsname(pfsal_path->path, fs_spec) == -1)
    ReturnCode(ERR_FSAL_INVAL, 0);

  memset((char *)&fs_quota, 0, sizeof(struct dqblk));

  if(quotactl(FSAL_QCMD(Q_GETQUOTA, quota_type), fs_spec, fsal_uid, (caddr_t) & fs_quota)
     < 0)
    ReturnCode(posix2fsal_error(errno), errno);

  /* Convert XFS structure to FSAL one */
  pquota->bhardlimit = fs_quota.dqb_bhardlimit;
  pquota->bsoftlimit = fs_quota.dqb_bsoftlimit;
  pquota->curblocks = fs_quota.dqb_curspace;
  pquota->fhardlimit = fs_quota.dqb_ihardlimit;
  pquota->curfiles = fs_quota.dqb_curinodes;
  pquota->btimeleft = fs_quota.dqb_btime;
  pquota->ftimeleft = fs_quota.dqb_itime;
  pquota->bsize = DEV_BSIZE;

  ReturnCode(ERR_FSAL_NO_ERROR, 0);
}                               /*  FSAL_get_quota */
Ejemplo n.º 2
0
fsal_status_t XFSFSAL_check_quota( char              * path,  /* IN */
                                   fsal_quota_type_t   quota_type,
                                   fsal_uid_t          fsal_uid)      /* IN */
{
  struct dqblk fs_quota;
  char fs_spec[MAXPATHLEN];
  
  if(!path )
    ReturnCode(ERR_FSAL_FAULT, 0);

  if(fsal_internal_path2fsname( path, fs_spec) == -1)
    ReturnCode(ERR_FSAL_INVAL, 0);

  if( fsal_uid == 0 ) /* No quota for root */
    ReturnCode(ERR_FSAL_NO_ERROR, 0) ;
  
  memset((char *)&fs_quota, 0, sizeof(struct dqblk));

  if(quotactl(FSAL_QCMD(Q_GETQUOTA, USRQUOTA), fs_spec, fsal_uid, (caddr_t) & fs_quota) < 0 )
    ReturnCode(posix2fsal_error(errno), errno);
  
  switch( quota_type )
   {
        case FSAL_QUOTA_BLOCKS:
          if( fs_quota.dqb_curspace > fs_quota.dqb_bhardlimit )
            ReturnCode( ERR_FSAL_DQUOT, EDQUOT ) ;
          
          break ;

        case FSAL_QUOTA_INODES:
          if( fs_quota.dqb_curinodes > fs_quota.dqb_ihardlimit )
            ReturnCode( ERR_FSAL_DQUOT, EDQUOT ) ;
          
          break ;
   } /* switch( quota_type ) */
 
  ReturnCode(ERR_FSAL_NO_ERROR, 0) ;
} /* XFSFSAL_check_quota */
Ejemplo n.º 3
0
fsal_status_t COMMON_set_quota(fsal_path_t * pfsal_path,       /* IN */
                                int quota_type, /* IN */
                                fsal_uid_t fsal_uid,    /* IN */
                                fsal_quota_t * pquota,  /* IN */
                                fsal_quota_t * presquota)       /* OUT */
{
  struct dqblk fs_quota;
  fsal_status_t fsal_status;
  char fs_spec[MAXPATHLEN];

  if(!pfsal_path || !pquota)
    ReturnCode(ERR_FSAL_FAULT, 0);

  if(fsal_internal_path2fsname(pfsal_path->path, fs_spec) == -1)
    ReturnCode(ERR_FSAL_INVAL, 0);

  memset((char *)&fs_quota, 0, sizeof(struct dqblk));

  /* Convert FSAL structure to XFS one */
  if(pquota->bhardlimit != 0)
    {
      fs_quota.dqb_bhardlimit = pquota->bhardlimit;
      fs_quota.dqb_valid |= QIF_BLIMITS;
    }

  if(pquota->bsoftlimit != 0)
    {
      fs_quota.dqb_bsoftlimit = pquota->bsoftlimit;
      fs_quota.dqb_valid |= QIF_BLIMITS;
    }

  if(pquota->fhardlimit != 0)
    {
      fs_quota.dqb_ihardlimit = pquota->fhardlimit;
      fs_quota.dqb_valid |= QIF_ILIMITS;
    }

  if(pquota->btimeleft != 0)
    {
      fs_quota.dqb_btime = pquota->btimeleft;
      fs_quota.dqb_valid |= QIF_BTIME;
    }

  if(pquota->ftimeleft != 0)
    {
      fs_quota.dqb_itime = pquota->ftimeleft;
      fs_quota.dqb_valid |= QIF_ITIME;
    }

  if(quotactl(FSAL_QCMD(Q_SETQUOTA, quota_type), fs_spec, fsal_uid, (caddr_t) & fs_quota)
     < 0)
    ReturnCode(posix2fsal_error(errno), errno);

  if(presquota != NULL)
    {
      fsal_status = FSAL_get_quota(pfsal_path, quota_type, fsal_uid, presquota);

      if(FSAL_IS_ERROR(fsal_status))
        return fsal_status;
    }

  ReturnCode(ERR_FSAL_NO_ERROR, 0);
}                               /*  FSAL_set_quota */