Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: mitloehn@miss.wu-wien.ac.at (PC7 root user)
Subject: Re: setquota
Date: 1997/10/05	[thread overview]
Message-ID: <617pdp$dau@cantine.wu-wien.ac.at> (raw)
In-Reply-To: 612dpd$mpa@cantine.wu-wien.ac.at


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 <ufs/quota.h>
#include <pwd.h>
#include <ufs/quota.h>

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);
}



  parent reply	other threads:[~1997-10-05  4:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-10-03  4:00 setquota PC7 root user
1997-10-04  4:00 ` setquota Jay Hennessey
1997-10-05  4:00 ` PC7 root user [this message]
     [not found] ` <343C83B7.A464D936@kudonet.com>
1997-10-09  4:00   ` setquota Seppo Routimo
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox