Quotactl with ioctl.

Salvador Ramirez (sram@inf.UDEC.CL)
Mon, 12 May 1997 23:12:33 -0400 (CST)

Hi managers,

(I'm working on a Sun Sparc Station Station 10 with Solaris2.4)

- I have problems trying to do a program that put quota to a user.
I know that with ioctl(2) with Q_QUOTACTL as request and a pointer to
"struct quotctl" as arg i can do it. The quotctl structure is defined
(in /usr/include/sys/fs/ufs_quota.h) as:

struct quotctl {
int op; /* operation to do .. */
uid_t uid; /* UID of the user .. */
caddr_t addr;
};

Now if i want to get the disk quotas information of a user wich uid is
<uid> i must to to use op = Q_GETQUOTA and addr must to point to a
dqblk structure (also defined in /usr/include/sys/fs/ufs_quota.h), here
is my problem!!, how i can to do that addr point to a dqblk structure??!
I thought that the following would work :

struct quotctl *qctl;
struct dqblk *dq;
int fd;

fp = open("/fs/quotas", O_RDWR);
qctl = (struct quotctl *)malloc(sizeof(struct quotctl));
qctl->op = Q_GETQUOTA;
qctl->uid = <uid>;
qctl->addr = (caddr *)dq;

ioctl(fd, Q_QUOTACTL, qctl);

But this do that ioctl returns (througt perror(3C)) "Invalid argument".
So, i think that addr field of quotctl structure is wrong, how i must
to set it??

Any help will be very appreciated,

Very thanks in advance..

-- 
++ Salvador Ramirez Flandes                   mailto:sram@inf.UDEC.CL ++
++ Unix/Internet System Administrator     http://www.inf.udec.cl/sram ++
++ DIICC, UDEC - CHILE                    Voice: +56 (41) 234985-2315 ++