~ubuntu-branches/ubuntu/karmic/vzctl/karmic

« back to all changes in this revision

Viewing changes to src/lib/quota.c

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2007-04-10 18:08:16 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070410180816-0uuzj9fnna7gmzxv
Tags: 3.0.16-4
Etch has been released which means that this version can be uploaded
to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 *  Copyright (C) 2000-2006 SWsoft. All rights reserved.
 
2
 *  Copyright (C) 2000-2007 SWsoft. All rights reserved.
3
3
 *
4
4
 *  This program is free software; you can redistribute it and/or modify
5
5
 *  it under the terms of the GNU General Public License as published by
100
100
        }
101
101
        arg[i] = NULL;
102
102
        if ((ret = run_script(VZQUOTA, arg, NULL, 0))) {
103
 
                logger(0, 0, "vzquota setlimit failed [%d]", ret);
 
103
                logger(-1, 0, "vzquota setlimit failed [%d]", ret);
104
104
                ret = VZ_DQ_SET;
105
105
        }
106
106
        free_arg(arg);
150
150
        arg[i++] = strdup("-I");
151
151
        snprintf(buf, sizeof(buf), "%lu", param->diskinodes[1]);
152
152
        arg[i++] = strdup(buf);
153
 
        /* VPS private */
 
153
        /* VE private */
154
154
        arg[i++] = strdup("-p");
155
155
        arg[i++] = strdup(private);
156
156
        /* Expiration time */
171
171
                arg[i++] = strdup("0");
172
172
        arg[i] = NULL;
173
173
        if ((ret = run_script(VZQUOTA, arg, NULL, 0))) {
174
 
                logger(0, 0, "vzquota init failed [%d]", ret);
 
174
                logger(-1, 0, "vzquota init failed [%d]", ret);
175
175
                ret = VZ_DQ_INIT;
176
176
        }
177
177
        free_arg(arg);
181
181
 
182
182
/** Turn disk quota on.
183
183
 *
184
 
 * @param veid          VPS id.
185
 
 * @param private       VPS private area path.
 
184
 * @param veid          VE id.
 
185
 * @param private       VE private area path.
186
186
 * @param dq            disk quota parameters.
187
187
 * @return              0 on success.
188
188
 */
260
260
                        break;
261
261
                }
262
262
                if (ret) {
263
 
                        logger(0, 0, "vzquota on failed [%d]", ret);
 
263
                        logger(-1, 0, "vzquota on failed [%d]", ret);
264
264
                        ret = VZ_DQ_SET;
265
265
                }
266
266
        }
271
271
 
272
272
/** Turn disk quota off.
273
273
 *
274
 
 * @param veid          VPS id.
 
274
 * @param veid          VE id.
275
275
 * @param dq            disk quota parameters.
276
276
 * @return              0 on success.
277
277
 */
291
291
        arg[i] = NULL;
292
292
        if ((ret = run_script(VZQUOTA, arg, NULL, 0))) {
293
293
                if (ret != EXITCODE_QUOTANOTRUN) {
294
 
                        logger(0, 0, "vzquota off failed [%d]", ret);
 
294
                        logger(-1, 0, "vzquota off failed [%d]", ret);
295
295
                        ret = VZ_DQ_OFF;
296
296
                }
297
297
        }
302
302
 
303
303
/** Disk quota managment wraper.
304
304
 *
305
 
 * @param veid          VPS id.
 
305
 * @param veid          VE id.
306
306
 * @param cmd           quota commands (QUOTA_MARKDURTY QUOTA_DROP QUOTA_STAT)
307
307
 * @return              0 on success.
308
308
 */
353
353
                quiet = 1;
354
354
                break;
355
355
        default :
356
 
                logger(0, 0, "quota_ctl: Unknown action %d", cmd);
 
356
                logger(-1, 0, "quota_ctl: Unknown action %d", cmd);
357
357
                return VZ_SYSTEM_ERROR;
358
358
        }
359
359
        arg[i] = NULL;
368
368
 
369
369
/** Setup disk quota limits.
370
370
 *
371
 
 * @param veid          VPS id.
 
371
 * @param veid          VE id.
372
372
 * @param dq            disk quota parameters.
373
373
 * @return              0 on success.
374
374
 */
387
387
                return 0;
388
388
        }
389
389
        if (quota_ctl(veid, QUOTA_STAT)) {
390
 
                logger(0, 0, "Error: Unable to apply new quota values"
 
390
                logger(-1, 0, "Error: Unable to apply new quota values"
391
391
                        " quota not running");
392
392
                return -1;
393
393
        }
394
394
        if (dq->ugidlimit != NULL) {
395
395
                ret = quota_ctl(veid, QUOTA_STAT2);
396
396
                if (ret && *dq->ugidlimit) {
397
 
                        logger(0, 0, "Unable to apply new quota values:"
 
397
                        logger(-1, 0, "Unable to apply new quota values:"
398
398
                                " ugid quota not initialized");
399
399
                        return VZ_DQ_UGID_NOTINITIALIZED;
400
400
//                      tmp_ugidlimit = dq->ugidlimit;
401
401
//                      dq->ugidlimit = NULL;
402
402
                } else if (!ret && !*dq->ugidlimit) {
403
 
                        logger(0, 0, "WARNING: Unable to turn ugid quota"
 
403
                        logger(-1, 0, "WARNING: Unable to turn ugid quota"
404
404
                                " off. new parameters will be applyed"
405
405
                                " on next start");
406
406
                        tmp_ugidlimit = dq->ugidlimit;