* Problem with quotactl
@ 1997-05-04 4:00 Mark Nelson
1997-05-05 4:00 ` Bob Harris
0 siblings, 1 reply; 2+ messages in thread
From: Mark Nelson @ 1997-05-04 4:00 UTC (permalink / 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,"a);
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,"a);
*/
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,"a);
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Problem with quotactl
1997-05-04 4:00 Problem with quotactl Mark Nelson
@ 1997-05-05 4:00 ` Bob Harris
0 siblings, 0 replies; 2+ messages in thread
From: Bob Harris @ 1997-05-05 4:00 UTC (permalink / raw)
In article <336D0DD3.28551810@ramius.demon.co.uk>, Mark Nelson
<mark@ramius.demon.co.uk> wrote:
>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,"a);
>
>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)
You are going to kick yourself.
The man page says
path Specifies the pathname of any file within the mounted file sys-
tem.
You specified the device, _NOT_ a file _WITHIN_ the mounted file system.
Change your command line to
./a.out /usr cmt17 1 3
and you should make forward progress in debugging your program.
I have not looked at your code, so I don't know if there are any other
problems or if you are all set now.
--
Bob Harris
"I don't get to tell me what to do, I only get to tell me how to do it."
Comments expressed here are my own and _NOT_ those of my employer.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1997-05-05 4:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1997-05-04 4:00 Problem with quotactl Mark Nelson
1997-05-05 4:00 ` Bob Harris
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox