[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Programming file quota functions



I have been having some problems trying to program file system quotas on
Redhat5.1 kernel 2.0.35

The code that I orignally found that I tried to hack for my own use is
inserted at the bottom of this mail.

On compiling I get the following problem:

warning: passing arg 4 of `quotactl' from incompatible pointer type

Does anyone know what is wrong with the code? According to the man page I
have used the right structure. Is there are linker input file that I need
to specify when compliling?

regards and thanks,


Abdul-Wahid Paterson


>>>CODE HERE<<<

#include <errno.h>
#include <time.h>
#include <sys/types.h>
#include <sys/quota.h>

extern int errno;

void main(int argc,char *argv[])
{
  int retvalue;
  struct dqblk* quota;

  if (argc!=4)
    printf("Syntax: %s <device> <uid> <space in Mbs>\n",argv[0]);
  else {
    quota=(struct dqblk*)malloc(sizeof(struct dqblk));
    quota->dqb_bhardlimit=atoi(argv[3])*1024;
    quota->dqb_bsoftlimit=atoi(argv[3])*1024;
    quota->dqb_ihardlimit=atoi(argv[3])*512;
    quota->dqb_isoftlimit=atoi(argv[3])*512;
    
    retvalue=quotactl(QCMD(Q_SETQLIM,USRQUOTA),argv[1],atoi(argv[2]),quota);

    if (retvalue==0) {
      printf("Success\n");
    }
    else {
      printf("Failure\n");
      switch (errno) {
      case EFAULT:
	printf("1\n");
	break;
      case EINVAL:
	printf("2\n");
	break;
      case ENOENT:
	printf("3\n");
	break;
      case ENOTBLK:
	printf("4\n");
	break;
      case EPERM:
	printf("5\n");
	break;
      case ESRCH:
	printf("6\n");
	break;
      case EUSERS:
	printf("7\n");
	break;
      case EACCES:
	printf("8\n");
	break;
      case EBUSY:
	printf("9\n");
	break;
      }
    }
  }
}






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]