* quotactl [not found] <S265125AbTGBQaA/20030702163000Z+15659@vger.kernel.org> @ 2003-07-02 16:48 ` Francis Lau 2003-07-02 17:37 ` quotactl Chris Nanakos 0 siblings, 1 reply; 10+ messages in thread From: Francis Lau @ 2003-07-02 16:48 UTC (permalink / raw) To: linux-c-programming Hi, For some reason, quotactl does not work for me even though I have QUOTA turned on in the kernel. struct mem_dqblk mydq; i = quotactl (QCMD(Q_GETQUOTA,USRQUOTA), "/dev/md5", 2099, &mydq); i always returns -1 with errno = 22 (EINVAL The kernel has not been compiled with the QUOTA option. cmd is invalid.) Has anyone seen this before? Any suggestions are welcome. Thanks, Francis ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: quotactl 2003-07-02 16:48 ` quotactl Francis Lau @ 2003-07-02 17:37 ` Chris Nanakos 2003-07-02 18:04 ` quotactl Francis Lau 0 siblings, 1 reply; 10+ messages in thread From: Chris Nanakos @ 2003-07-02 17:37 UTC (permalink / raw) To: Francis Lau, linux-c-programming make a clean compilation of the kernel from the beggining.(use make clean && make mrproper).Be sure that no object files exist when you start building your new kernel.Try this....and e-mail again:) Best regards, Chris. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: quotactl 2003-07-02 17:37 ` quotactl Chris Nanakos @ 2003-07-02 18:04 ` Francis Lau 2003-07-02 18:20 ` quotactl Darío Mariani 0 siblings, 1 reply; 10+ messages in thread From: Francis Lau @ 2003-07-02 18:04 UTC (permalink / raw) To: Chris Nanakos; +Cc: linux-c-programming > make a clean compilation of the kernel from the beggining.(use make clean && > make mrproper).Be sure that no object files exist when you start building > your new kernel.Try this....and e-mail again:) > I'm running RedHat 9 with the stock 2.4.20 SMP kernel. Unfortunately, I cannot (not allowed to) recompile the kernel...Any other suggestions? Thanks Francis ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: quotactl 2003-07-02 18:04 ` quotactl Francis Lau @ 2003-07-02 18:20 ` Darío Mariani 2003-07-02 18:58 ` quotactl Francis Lau 2003-07-02 21:45 ` quotactl Glynn Clements 0 siblings, 2 replies; 10+ messages in thread From: Darío Mariani @ 2003-07-02 18:20 UTC (permalink / raw) To: Francis Lau; +Cc: linux-c-programming If you did not recompile the kernel, it has quota support. Has the FS you are quering been mounted with the usrquota option? Francis Lau wrote: >>make a clean compilation of the kernel from the beggining.(use make clean && >>make mrproper).Be sure that no object files exist when you start building >>your new kernel.Try this....and e-mail again:) >> > > I'm running RedHat 9 with the stock 2.4.20 SMP kernel. Unfortunately, I > cannot (not allowed to) recompile the kernel...Any other suggestions? > > Thanks > 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 > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: quotactl 2003-07-02 18:20 ` quotactl Darío Mariani @ 2003-07-02 18:58 ` Francis Lau 2003-07-02 23:45 ` mid file deletion John T. Williams 2003-07-02 21:45 ` quotactl Glynn Clements 1 sibling, 1 reply; 10+ messages in thread From: Francis Lau @ 2003-07-02 18:58 UTC (permalink / raw) To: Darío Mariani; +Cc: linux-c-programming On Wed, 2 Jul 2003, 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? Yes the FS is mounted with the usrqutoa option. I can use repquota, edquota, quota, quotacheck, quotaon, quotaoff...etc. with no problems. I only have problems with I use quotactl in my C code. Francis > > Francis Lau wrote: > >>make a clean compilation of the kernel from the beggining.(use make clean && > >>make mrproper).Be sure that no object files exist when you start building > >>your new kernel.Try this....and e-mail again:) > >> > > > > I'm running RedHat 9 with the stock 2.4.20 SMP kernel. Unfortunately, I > > cannot (not allowed to) recompile the kernel...Any other suggestions? > > > > Thanks > > 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 > > > > > - > 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 > - 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 ^ permalink raw reply [flat|nested] 10+ messages in thread
* mid file deletion 2003-07-02 18:58 ` quotactl Francis Lau @ 2003-07-02 23:45 ` John T. Williams 2003-07-02 22:15 ` Glynn Clements 0 siblings, 1 reply; 10+ messages in thread From: John T. Williams @ 2003-07-02 23:45 UTC (permalink / raw) To: linux-c-programming What is the best way to remove data from the middle of a file. Here is the Scenario: I have a file that is 20MB in size, about ¼ th way through it is a 1 line I want to remove. I can use lseek to bring me to the beginning of the section I want to remove, and then lseek again to bring me to the end of that section. The only thing I can think to do is load everything from the file after the point I want to delete into memory, remove the part I don't want from what is stored in memory (or simply don't load it), truncate the file at the point where the part I wanted to delete began, and re-write the rest of the file. The alternative (since 20MB is rather big for loading into memory on a multi-User multi-Media machine) is to load the bits I want to keep into a temporary file, rather into memory. However, I was thinking that for removing 20bytes of information, reading and writing 15MB to 30MB is a lot of work. Is there a better way? To give this more of a real world perspective. I'm downloading e-mails into a mbox file and I'm trying to figure out how to delete 1 email from a mbox file that could potentially store 1,000's of e-mails an any given time. - 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 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: mid file deletion 2003-07-02 23:45 ` mid file deletion John T. Williams @ 2003-07-02 22:15 ` Glynn Clements 0 siblings, 0 replies; 10+ messages in thread From: Glynn Clements @ 2003-07-02 22:15 UTC (permalink / raw) To: John T. Williams; +Cc: linux-c-programming John T. Williams wrote: > What is the best way to remove data from the middle of a file. Here is the > Scenario: I have a file that is 20MB in size, about ¼ th way through it is a > 1 line I want to remove. I can use lseek to bring me to the beginning of the > section I want to remove, and then lseek again to bring me to the end of > that section. The only thing I can think to do is load everything from the > file after the point I want to delete into memory, remove the part I don't > want from what is stored in memory (or simply don't load it), truncate the > file at the point where the part I wanted to delete began, and re-write the > rest of the file. The alternative (since 20MB is rather big for loading into > memory on a multi-User multi-Media machine) is to load the bits I want to > keep into a temporary file, rather into memory. However, I was thinking that > for removing 20bytes of information, reading and writing 15MB to 30MB is a > lot of work. Is there a better way? You can just read/write arbitrary-sized chunks in a loop, e.g. for (;;) { int n; lseek(fd, src_offset, SEEK_SET); n = read(fd, buf, sizeof(buf)); if (!n) break; lseek(fd, dst_offset, SEEK_SET); write(fd, buf, n); src_offset += n; dst_offset += n; } ftruncate(fd, dst_offset); Alternatively, you could mmap() the file and use memmove() instead of the read/write pair (but not memcpy(); that isn't guaranteed to work if source and destination overlap). That should provide better performance; however, you shouldn't assume that you can mmap() the entire file in one go, nor should you assume that both source and destination will fit within a single mmap()'d region, so you would need a pair of "scrolling windows". You would also have to deal with the page-alignment issues. BTW, if you were inserting (and hence shifting toward the end of the file), you would have to start at the end of the file then work backward. -- Glynn Clements <glynn.clements@virgin.net> - 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 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: quotactl 2003-07-02 18:20 ` quotactl Darío Mariani 2003-07-02 18:58 ` quotactl Francis Lau @ 2003-07-02 21:45 ` Glynn Clements 2003-07-03 16:24 ` quotactl Francis Lau 1 sibling, 1 reply; 10+ messages in thread From: Glynn Clements @ 2003-07-02 21:45 UTC (permalink / raw) To: linux-c-programming; +Cc: Francis Lau, Darío Mariani 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). -- Glynn Clements <glynn.clements@virgin.net> - 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 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: quotactl 2003-07-02 21:45 ` quotactl Glynn Clements @ 2003-07-03 16:24 ` Francis Lau 2003-07-03 18:48 ` quotactl Glynn Clements 0 siblings, 1 reply; 10+ messages in thread From: Francis Lau @ 2003-07-03 16:24 UTC (permalink / raw) To: Glynn Clements; +Cc: linux-c-programming, Darío Mariani > > 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 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: quotactl 2003-07-03 16:24 ` quotactl Francis Lau @ 2003-07-03 18:48 ` Glynn Clements 0 siblings, 0 replies; 10+ messages in thread From: Glynn Clements @ 2003-07-03 18:48 UTC (permalink / raw) To: Francis Lau; +Cc: linux-c-programming Francis Lau wrote: > 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 fs/quota.c? > and I think the code always gets to the 'return 0' part > in the do_quotactl function: do_quotactl? > 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; > } I don't recognise this code, but looking around on the 'net suggests that fs/quota.c and do_quotactl are from 2.5.x. I'm not using 2.5.x, and I'm not about to download a 30Mb file to look into this. Is this a vendor-modified kernel? Maybe the vendor has back-ported the 2.5.x quota code into their 2.4.x kernels for some reason (e.g. the 16-bit UID issue below)? If you're using vendor-modified code, you might need to ask on a list which is specific to that vendor's product. At the very least, you need to give people a clue about which code you are using. > 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); This won't work with the standard 2.4.x quota code; the UID has to fit into 16 bits, otherwise the call will fail with EINVAL. -- Glynn Clements <glynn.clements@virgin.net> ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2003-07-03 18:48 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[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 ` quotactl Francis Lau
2003-07-03 18:48 ` quotactl Glynn Clements
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).