linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Francis Lau <fkwlau@utcc.utoronto.ca>
To: Glynn Clements <glynn.clements@virgin.net>
Cc: linux-c-programming@vger.kernel.org, "Darío Mariani" <dmarian@fi.uba.ar>
Subject: Re: quotactl
Date: Thu, 3 Jul 2003 12:24:09 -0400	[thread overview]
Message-ID: <Pine.LNX.4.44.0307031212050.11040-100000@gpu.utcc> (raw)
In-Reply-To: <16131.21093.151750.179494@cerise.nosuchdomain.co.uk>


> 
> Darío Mariani wrote:
> 
> >    If you did not recompile the kernel, it has quota support. Has the FS 
> > you are quering been mounted with the usrquota option?
> 
> The mount(8) manpage says (in regard of ext2):
> 
>        grpquota / noquota / quota / usrquota
>               These options are accepted but ignored.
> 
> Examination of the kernel source code (fs/ext2/super.c) confirms this:
> 
> 		/* Silently ignore the quota options */
> 		else if (!strcmp (this_char, "grpquota")
> 		         || !strcmp (this_char, "noquota")
> 		         || !strcmp (this_char, "quota")
> 		         || !strcmp (this_char, "usrquota"))
> 			/* Don't do anything ;-) */ ;
> 
> Also, if quota support is disabled (i.e. "!defined(CONFIG_QUOTA)"),
> quotactl() will fail with ENOSYS rather than EINVAL (at least in
> 2.4.x).
> 
> 
I have tried everything you guys suggested but am still unable to get 
quotactl to work.  For some reason, quotactl always returns a 0.  I have 
traced through fs/quota.c and I think the code always gets to the 'return 0' part 
in the do_quotactl function:

case Q_GETQUOTA: {
             struct if_dqblk idq;

            if ((ret = sb->s_qcop->get_dqblk(sb, type, id, &idq)))
                      return ret;
            if (copy_to_user(addr, &idq, sizeof(idq)))
                      return -EFAULT;
            return 0;
}

-----------------------------------
This is the kernel I am using:

[root@setup5 fs]# uname -a
Linux setup5 2.4.20-18.9smp #1 SMP Thu May 29 06:55:05 EDT 2003 i686 i686 
i386 GNU/Linux

----------------------------------
This is the test code I am using:

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <linux/quota.h>

main ()
{
	int i, cmd;
	struct mem_dqblk mydq;

	cmd = QCMD(Q_GETQUOTA,USRQUOTA);
	i=quotactl (cmd, "/dev/md5", 70557, &mydq);

	printf ("curspace is %i\n", mydq.dqb_curspace);
}

----------------------------------
I made sure that CONFIG_QUOTA=y too.

[root@setup5 configs]# pwd
/usr/src/linux-2.4/configs
[root@setup5 configs]# grep CONFIG_QUOTA *
kernel-2.4.20-athlon.config:CONFIG_QUOTA=y
kernel-2.4.20-athlon-smp.config:CONFIG_QUOTA=y
kernel-2.4.20-i386-BOOT.config:# CONFIG_QUOTA is not set
kernel-2.4.20-i386-BOOT.config:# CONFIG_QUOTA is not set
kernel-2.4.20-i386.config:CONFIG_QUOTA=y
kernel-2.4.20-i386-smp.config:CONFIG_QUOTA=y
kernel-2.4.20-i586.config:CONFIG_QUOTA=y
kernel-2.4.20-i586-smp.config:CONFIG_QUOTA=y
kernel-2.4.20-i686-bigmem.config:CONFIG_QUOTA=y
kernel-2.4.20-i686.config:CONFIG_QUOTA=y
kernel-2.4.20-i686-smp.config:CONFIG_QUOTA=y
kernel-2.4.20-x86_64.config:CONFIG_QUOTA=y
kernel-2.4.20-x86_64-smp.config:CONFIG_QUOTA=y

---------------------------------
I ran a strace on the binary and this is what I got:

[root@setup5 C]# strace -f ./test
execve("./test", ["./test"], [/* 21 vars */]) = 0
uname({sys="Linux", node="setup5", ...}) = 0
brk(0)                                  = 0x8049628
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 
0) = 0x40016000
open("/etc/ld.so.preload", O_RDONLY)    = -1 ENOENT (No such file or 
directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=59724, ...}) = 0
old_mmap(NULL, 59724, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40017000
close(3)                                = 0
open("/lib/tls/libc.so.6", O_RDONLY)    = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0`V\1B4\0"..., 512)
= 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=1531064, ...}) = 0
old_mmap(0x42000000, 1257224, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 
0x42000000
old_mmap(0x4212e000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 
3, 0x12e000) = 0x4212e000
old_mmap(0x42131000, 7944, PROT_READ|PROT_WRITE, 
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x42131000
close(3)                                = 0
set_thread_area({entry_number:-1 -> 6, base_addr:0x400169e0, 
limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, 
limit_in_pages:1, seg_not_present:0, useable:1}) = 0
munmap(0x40017000, 59724)               = 0
quotactl(0xd00 /* Q_??? */|USRQUOTA, "/dev/md5", 70557, {3221224176, 
1073790467, 1073830868, 1073832832, 1, 0, 1107383425, 134513434}) = -1 
EINVAL (Invalid argument)
fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 3), ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) 
= 0x40017000
write(1, "cmd is 851968\n", 14cmd is 851968
)         = 14
write(1, "i is -1\n", 8i is -1
)                = 8
write(1, "errno is 22\n", 12errno is 22
)           = 12
write(1, "curspace is 0\n", 14curspace is 0
)         = 14
munmap(0x40017000, 4096)                = 0
exit_group(14)



Thanks again.  I really appreciate it.

Francis

-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2003-07-03 16:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <S265125AbTGBQaA/20030702163000Z+15659@vger.kernel.org>
2003-07-02 16:48 ` quotactl Francis Lau
2003-07-02 17:37   ` quotactl Chris Nanakos
2003-07-02 18:04     ` quotactl Francis Lau
2003-07-02 18:20       ` quotactl Darío Mariani
2003-07-02 18:58         ` quotactl Francis Lau
2003-07-02 23:45           ` mid file deletion John T. Williams
2003-07-02 22:15             ` Glynn Clements
2003-07-02 21:45         ` quotactl Glynn Clements
2003-07-03 16:24           ` Francis Lau [this message]
2003-07-03 18:48             ` quotactl Glynn Clements

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.44.0307031212050.11040-100000@gpu.utcc \
    --to=fkwlau@utcc.utoronto.ca \
    --cc=dmarian@fi.uba.ar \
    --cc=glynn.clements@virgin.net \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).