[BACK]Return to quota_oldfiles.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / lib / libquota

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

Diff for /src/lib/libquota/quota_oldfiles.c between version 1.4 and 1.5

version 1.4, 2012/01/30 06:15:22 version 1.5, 2012/01/30 16:45:13
Line 237  __quota_oldfiles_infstab(const char *mou
Line 237  __quota_oldfiles_infstab(const char *mou
         return __quota_oldfiles_find_fstabentry(mountpoint) != NULL;          return __quota_oldfiles_find_fstabentry(mountpoint) != NULL;
 }  }
   
   static void
   __quota_oldfiles_defquotafile(struct quotahandle *qh, int idtype,
                                 char *buf, size_t maxlen)
   {
           static const char *const names[] = INITQFNAMES;
   
           (void)snprintf(buf, maxlen, "%s/%s.%s",
                          qh->qh_mountpoint,
                          QUOTAFILENAME, names[USRQUOTA]);
   }
   
   const char *
   __quota_oldfiles_getquotafile(struct quotahandle *qh, int idtype,
                                 char *buf, size_t maxlen)
   {
           const struct oldfiles_fstabentry *ofe;
           const char *file;
   
           ofe = __quota_oldfiles_find_fstabentry(qh->qh_mountpoint);
           if (ofe == NULL) {
                   errno = ENXIO;
                   return NULL;
           }
   
           switch (idtype) {
               case USRQUOTA:
                   if (!ofe->ofe_hasuserquota) {
                           errno = ENXIO;
                           return NULL;
                   }
                   file = ofe->ofe_userquotafile;
                   break;
               case GRPQUOTA:
                   if (!ofe->ofe_hasgroupquota) {
                           errno = ENXIO;
                           return NULL;
                   }
                   file = ofe->ofe_groupquotafile;
                   break;
               default:
                   errno = EINVAL;
                   return NULL;
           }
   
           if (file == NULL) {
                   __quota_oldfiles_defquotafile(qh, idtype, buf, maxlen);
                   file = buf;
           }
           return file;
   }
   
 static uint64_t  static uint64_t
 dqblk_getlimit(uint32_t val)  dqblk_getlimit(uint32_t val)
 {  {
Line 316  __quota_oldfiles_open(struct quotahandle
Line 367  __quota_oldfiles_open(struct quotahandle
 int  int
 __quota_oldfiles_initialize(struct quotahandle *qh)  __quota_oldfiles_initialize(struct quotahandle *qh)
 {  {
         static const char *const names[] = INITQFNAMES;  
   
         const struct oldfiles_fstabentry *ofe;          const struct oldfiles_fstabentry *ofe;
         char path[PATH_MAX];          char path[PATH_MAX];
         const char *userquotafile, *groupquotafile;          const char *userquotafile, *groupquotafile;
Line 345  __quota_oldfiles_initialize(struct quota
Line 394  __quota_oldfiles_initialize(struct quota
         if (ofe->ofe_hasuserquota) {          if (ofe->ofe_hasuserquota) {
                 userquotafile = ofe->ofe_userquotafile;                  userquotafile = ofe->ofe_userquotafile;
                 if (userquotafile == NULL) {                  if (userquotafile == NULL) {
                         (void)snprintf(path, sizeof(path), "%s/%s.%s",                          __quota_oldfiles_defquotafile(qh, USRQUOTA,
                                        qh->qh_mountpoint,                                                        path, sizeof(path));
                                        QUOTAFILENAME, names[USRQUOTA]);  
                         userquotafile = path;                          userquotafile = path;
                 }                  }
                 if (__quota_oldfiles_open(qh, userquotafile,                  if (__quota_oldfiles_open(qh, userquotafile,
Line 358  __quota_oldfiles_initialize(struct quota
Line 406  __quota_oldfiles_initialize(struct quota
         if (ofe->ofe_hasgroupquota) {          if (ofe->ofe_hasgroupquota) {
                 groupquotafile = ofe->ofe_groupquotafile;                  groupquotafile = ofe->ofe_groupquotafile;
                 if (groupquotafile == NULL) {                  if (groupquotafile == NULL) {
                         (void)snprintf(path, sizeof(path), "%s/%s.%s",                          __quota_oldfiles_defquotafile(qh, GRPQUOTA,
                                        qh->qh_mountpoint,                                                        path, sizeof(path));
                                        QUOTAFILENAME, names[GRPQUOTA]);  
                         groupquotafile = path;                          groupquotafile = path;
                 }                  }
                 if (__quota_oldfiles_open(qh, groupquotafile,                  if (__quota_oldfiles_open(qh, groupquotafile,
Line 380  __quota_oldfiles_getimplname(struct quot
Line 427  __quota_oldfiles_getimplname(struct quot
         return "ufs/ffs quota v1 file access";          return "ufs/ffs quota v1 file access";
 }  }
   
   int
   __quota_oldfiles_quotaon(struct quotahandle *qh, int idtype)
   {
           int result;
   
           /*
            * If we have the quota files open, close them.
            */
   
           if (qh->qh_oldfilesopen) {
                   if (qh->qh_userfile >= 0) {
                           close(qh->qh_userfile);
                           qh->qh_userfile = -1;
                   }
                   if (qh->qh_groupfile >= 0) {
                           close(qh->qh_groupfile);
                           qh->qh_groupfile = -1;
                   }
                   qh->qh_oldfilesopen = 0;
           }
   
           /*
            * Go over to the syscall interface.
            */
   
           result = __quota_proplib_quotaon(qh, idtype);
           if (result < 0) {
                   return -1;
           }
   
           /*
            * We succeeded, so all further access should be via the
            * kernel.
            */
   
           qh->qh_mode = QUOTA_MODE_PROPLIB;
           return 0;
   }
   
 static int  static int
 __quota_oldfiles_doget(struct quotahandle *qh, const struct quotakey *qk,  __quota_oldfiles_doget(struct quotahandle *qh, const struct quotakey *qk,
                        struct quotaval *qv, int *isallzero)                         struct quotaval *qv, int *isallzero)

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

CVSweb <webmaster@jp.NetBSD.org>