From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,cc3bb2de103fc3f0 X-Google-Attributes: gidfee84,public From: mitloehn@miss.wu-wien.ac.at (PC7 root user) Subject: Re: setquota Date: 1997/10/05 Message-ID: <617pdp$dau@cantine.wu-wien.ac.at>#1/1 X-Deja-AN: 278498798 References: <612dpd$mpa@cantine.wu-wien.ac.at> Organization: University of Economics and Business Administration, Vienna, Austria Newsgroups: comp.unix.osf.osf1 PC7 root user (mitloehn@miss.wu-wien.ac.at) wrote: : Is there an easy way to set user quota from the shell : or from a C or Perl program? Something like setquota(users, MB)? : Any hints greatly appreciated* I have done some C programming, here is what I came up with, thought others might be interested. The quotactl() function is the key. Thanks for responses! Regards from Vienna Johann Mitloehner mitloehn@wu-wien.ac.at http://www.wu-wien.ac.at/usr/ai/mitloehn #include #include #include main(int argc, char *argv[]) { char us[256], fs[256]; int uid, cmd; u_int kbyte; struct passwd *pw_ent; struct dqblk dq; if (argc != 4) { printf("Usage: %s user filesys\n", argv[0]); exit(-1); } strcpy(us, argv[1]); strcpy(fs, argv[2]); kbyte = atoi(argv[3]); pw_ent = getpwnam(us); uid = pw_ent->pw_uid; cmd = QCMD(Q_GETQUOTA, USRQUOTA); quotactl(fs, cmd, uid, &dq); dq.dqb_bhardlimit = kbyte * 2; cmd = QCMD(Q_SETQUOTA, USRQUOTA); quotactl(fs, cmd, uid, &dq); }