Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: Mark Nelson <mark@ramius.demon.co.uk>
Subject: Problem with quotactl
Date: 1997/05/04	[thread overview]
Message-ID: <336D0DD3.28551810@ramius.demon.co.uk> (raw)



Hi 

I'm trying to port a program from a sun running 4.1.3 to OSF1, the 
uname output of the development machine is OSF1 leo V3.2 41 alpha and 
the output of the uname command machine on which the program will
eventually
run is OSF1 scorpio.tees.ac.uk V3.2 148 alpha.

To access the quota information I am using the quotactl system call,
which 
according to the man page it takes the following parameters - 

quotactl(device,QCMD(GETQUOTA,USRQUOTA),uid,&quota);

Unfortunatly when I run the program I get error 22 returned when I 
try to do a getquota call.  Below is the output of program -

# df /usr
Filesystem   512-blocks        Used       Avail Capacity  Mounted on
/dev/rz0g       1603526     1126522      316650    78%    /usr
# ./a.out /dev/rz0g cmt17 1 3
417
-2147404728 1023
3 1
setting Quota
error 22 returned from quotactl(Q_SETQUOTA)



Below is the source code, any help is greatfully received 

Can anyoue replying mail me at work on Mark.Nelson@tees.ac.uk

Thanks 
/* * *
 *
 *  change_quota
 *
 *  Based loosly on the forcequota written by Gary Quinn, this version
has 
 *  been modified to work on all SCM supported machines, currently
Sun's,
 *  Alpha's and SG's
 *
 *  (c) Mark Nelson - 18-April-1997
 *
 * * */

#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <ufs/quota.h>
#include <pwd.h>

#define TRUE 1
#define FALSE 0

int main(int argc, char *argvstruct dqblk quota;
struct passwd *passwd_details;

int  result,uid,loop,len;
 
  /* * *
   *
   *   Validate the parameters, check to see if the user exists 
   *   and the hard and soft limits are numeric.
   *
   * * */

  if (argc!=5)
  {
    fprintf(stderr,"Usage : %s directory userid soft hard\n",argv[0]);
    return(0);
  }
 
 len=strlen(argv[3]);
 for(loop=0;loop<len;loop++)
 {
    if (!isdigit(argv[3][loop]))
 {  
      fprintf(stderr,"\nUsage :%s directory userid soft
hard\n",argv[0]);
      fprintf(stderr,"soft limit must be numeric\n");
      return(0);
    }
 }

 len=strlen(argv[4]);
 for(loop=0;loop<len;loop++)
 {
    if (!isdigit(argv[4][loop]))
    {  
      fprintf(stderr,"\nUsage :%s directory userid soft
hard\n",argv[0]);
      fprintf(stderr,"hard limit must be numeric\n");
      return(0);
    }
 }

 if ((passwd_details=getpwnam(argv[2]))==NULL)
 { 
    fprintf(stderr,"\nError: User %s does not exist\n",argv[2]);
    return -1;
 }
 else
 {
   printf("%d\n",passwd_details->pw_uid);
  result =
quotactl(argv[1],QCMD(Q_GETQUOTA,USRQUOTA),passwd_details->pw_uid,&qu
ota);

   uid=passwd_details->pw_uid;
   /* sun code  result = quotactl(Q_GETQUOTA,argv[1],(int)uid,&quota);
*/
   printf("%d %d\n",quota.dqb_bhardlimit,quota.dqb_bsoftlimit);
   if (result == -1) /* error */
   {
      printf("error %d returned from quotactl(Q_GETQUOTA)\n",errno);
      return -2;
    }
    else 
    {
      quota.dqb_bhardlimit = atoi(argv[4]); /* 1 block = 1K */
      quota.dqb_bsoftlimit = atoi(argv[3]);
      printf("%d %d\n",quota.dqb_bhardlimit,quota.dqb_bsoftlimit);

      puts("setting Quota");
       result =
quotactl(argv[1],QCMD(Q_SETQUOTA,USRQUOTA),passwd_details->pw_ui
d,&quota); 

  if (result == -1) /* error */
      {
        fprintf(stderr,"error %d returned from
quotactl(Q_SETQUOTA)\n",errno);
        return -3;
      }
    }
  }

Mark.

Mark Nelson - mark@ramius.demon.co.uk



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

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-05-04  4:00 Mark Nelson [this message]
1997-05-05  4:00 ` Problem with quotactl Bob Harris
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