* [gentoo-user] _syscallX isn't in linux-headers-2.6.20 ??
@ 2007-02-08 0:53 Iain Buchanan
2007-02-08 5:10 ` [gentoo-user] " Christian Marie
2007-02-08 10:40 ` [gentoo-user] " Boyd Stephen Smith Jr.
0 siblings, 2 replies; 4+ messages in thread
From: Iain Buchanan @ 2007-02-08 0:53 UTC (permalink / raw
To: gentoo-user
Hi all,
I'm trying to use:
_syscall3(int, ioprio_set, int, which, int, who, int, ioprio);
_syscall2(int, ioprio_get, int, which, int, who);
and supposedly I just
#include <linux/unistd.h>
but I'm getting these error from gcc:
error: syntax error before "ioprio_set"
warning: data definition has no type or storage class
error: syntax error before "ioprio_get"
warning: data definition has no type or storage class
so I had a look in /usr/include/linux/unistd.h and it doesn't even have
_syscall in there!! It's in /usr/src/linux though...
Am I doing something wrong? I'm following
http://www.die.net/doc/linux/man/man2/ioprio_set.2.html
I know this is a C-ish question, only loosely related to gentoo but I'd
really appreciate any help!!
TIA,
--
Iain Buchanan <iaindb at netspace dot net dot au>
The groundhog is like most other prophets; it delivers its message and then
disappears.
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 4+ messages in thread
* [gentoo-user] Re: _syscallX isn't in linux-headers-2.6.20 ??
2007-02-08 0:53 [gentoo-user] _syscallX isn't in linux-headers-2.6.20 ?? Iain Buchanan
@ 2007-02-08 5:10 ` Christian Marie
2007-02-08 7:01 ` Iain Buchanan
2007-02-08 10:40 ` [gentoo-user] " Boyd Stephen Smith Jr.
1 sibling, 1 reply; 4+ messages in thread
From: Christian Marie @ 2007-02-08 5:10 UTC (permalink / raw
To: gentoo-user
On Thu, Feb 08, 2007 at 10:23:09AM +0930, Iain Buchanan wrote:
> Hi all,
>
> I'm trying to use:
>
> _syscall3(int, ioprio_set, int, which, int, who, int, ioprio);
> _syscall2(int, ioprio_get, int, which, int, who);
>
> and supposedly I just
>
> #include <linux/unistd.h>
>
> but I'm getting these error from gcc:
>
> error: syntax error before "ioprio_set"
> warning: data definition has no type or storage class
> error: syntax error before "ioprio_get"
> warning: data definition has no type or storage class
Hi,
It would be helpful to provide us with the failing code as we have no
clue what you could be doing wrong.
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-user] Re: _syscallX isn't in linux-headers-2.6.20 ??
2007-02-08 5:10 ` [gentoo-user] " Christian Marie
@ 2007-02-08 7:01 ` Iain Buchanan
0 siblings, 0 replies; 4+ messages in thread
From: Iain Buchanan @ 2007-02-08 7:01 UTC (permalink / raw
To: gentoo-user
On Thu, 2007-02-08 at 16:10 +1100, Christian Marie wrote:
> On Thu, Feb 08, 2007 at 10:23:09AM +0930, Iain Buchanan wrote:
> > Hi all,
> >
> > I'm trying to use:
> >
> > _syscall3(int, ioprio_set, int, which, int, who, int, ioprio);
> > _syscall2(int, ioprio_get, int, which, int, who);
> >
> > and supposedly I just
> >
> > #include <linux/unistd.h>
> >
> > but I'm getting these error from gcc:
> >
> > error: syntax error before "ioprio_set"
> > warning: data definition has no type or storage class
> > error: syntax error before "ioprio_get"
> > warning: data definition has no type or storage class
>
> Hi,
>
> It would be helpful to provide us with the failing code as we have no
> clue what you could be doing wrong.
sure - my question was more "where has the define for _syscall2 gone?",
but here is the code. It comes
from /usr/src/linux/Documentation/block/ioprio.txt. I compile it with:
$ gcc -o ionice ionice.c
ionice.c:36: error: syntax error before "ioprio_set"
ionice.c:36: warning: data definition has no type or storage class
ionice.c:37: error: syntax error before "ioprio_get"
ionice.c:37: warning: data definition has no type or storage class
------begin ionice.c------
//
// Sample ionice utility copied from
// /usr/src/linux/Documentation/block/ioprio.txt from gentoo kernel version
// 2.6.19-suspend2-r1. Probably (C) Jens Axboe <axboe@suse.de> and GPL'd?
//
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <getopt.h>
#include <unistd.h>
#include <sys/ptrace.h>
extern int sys_ioprio_set(int, int, int);
extern int sys_ioprio_get(int, int);
#if defined(__i386__)
#define __NR_ioprio_set 289
#define __NR_ioprio_get 290
#elif defined(__ppc__)
#define __NR_ioprio_set 273
#define __NR_ioprio_get 274
#elif defined(__x86_64__)
#define __NR_ioprio_set 251
#define __NR_ioprio_get 252
#elif defined(__ia64__)
#define __NR_ioprio_set 1274
#define __NR_ioprio_get 1275
#else
#error "Unsupported arch"
#endif
int ioprio_get(int which, int who);
int ioprio_set(int which, int who, int ioprio);
_syscall3(int, ioprio_set, int, which, int, who, int, ioprio);
_syscall2(int, ioprio_get, int, which, int, who);
enum {
IOPRIO_CLASS_NONE,
IOPRIO_CLASS_RT,
IOPRIO_CLASS_BE,
IOPRIO_CLASS_IDLE,
};
enum {
IOPRIO_WHO_PROCESS = 1,
IOPRIO_WHO_PGRP,
IOPRIO_WHO_USER,
};
#define IOPRIO_CLASS_SHIFT 13
const char *to_prio[] = { "none", "realtime", "best-effort", "idle", };
int main(int argc, char *argv[])
{
int ioprio = 4, set = 0, ioprio_class = IOPRIO_CLASS_BE;
int c, pid = 0;
while ((c = getopt(argc, argv, "+n:c:p:")) != EOF) {
switch (c) {
case 'n':
ioprio = strtol(optarg, NULL, 10);
set = 1;
break;
case 'c':
ioprio_class = strtol(optarg, NULL, 10);
set = 1;
break;
case 'p':
pid = strtol(optarg, NULL, 10);
break;
}
}
switch (ioprio_class) {
case IOPRIO_CLASS_NONE:
ioprio_class = IOPRIO_CLASS_BE;
break;
case IOPRIO_CLASS_RT:
case IOPRIO_CLASS_BE:
break;
case IOPRIO_CLASS_IDLE:
ioprio = 7;
break;
default:
printf("bad prio class %d\n", ioprio_class);
return 1;
}
if (!set) {
if (!pid && argv[optind])
pid = strtol(argv[optind], NULL, 10);
ioprio = ioprio_get(IOPRIO_WHO_PROCESS, pid);
printf("pid=%d, %d\n", pid, ioprio);
if (ioprio == -1)
perror("ioprio_get");
else {
ioprio_class = ioprio >> IOPRIO_CLASS_SHIFT;
ioprio = ioprio & 0xff;
printf("%s: prio %d\n", to_prio[ioprio_class], ioprio);
}
} else {
if (ioprio_set(IOPRIO_WHO_PROCESS, pid, ioprio | ioprio_class << IOPRIO_CLASS_SHIFT) == -1) {
perror("ioprio_set");
return 1;
}
if (argv[optind])
execvp(argv[optind], &argv[optind]);
}
return 0;
}
------end ionice.c------
thanks,
--
Iain Buchanan <iaindb at netspace dot net dot au>
Progress might have been all right once, but it's gone on too long.
-- Ogden Nash
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-user] _syscallX isn't in linux-headers-2.6.20 ??
2007-02-08 0:53 [gentoo-user] _syscallX isn't in linux-headers-2.6.20 ?? Iain Buchanan
2007-02-08 5:10 ` [gentoo-user] " Christian Marie
@ 2007-02-08 10:40 ` Boyd Stephen Smith Jr.
1 sibling, 0 replies; 4+ messages in thread
From: Boyd Stephen Smith Jr. @ 2007-02-08 10:40 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 1836 bytes --]
On Wednesday 07 February 2007 18:53, Iain Buchanan wrote:
> Hi all,
>
> I'm trying to use:
>
> _syscall3(int, ioprio_set, int, which, int, who, int, ioprio);
> _syscall2(int, ioprio_get, int, which, int, who);
>
> and supposedly I just
>
> #include <linux/unistd.h>
>
> but I'm getting these error from gcc:
>
> error: syntax error before "ioprio_set"
> warning: data definition has no type or storage class
> error: syntax error before "ioprio_get"
> warning: data definition has no type or storage class
>
> so I had a look in /usr/include/linux/unistd.h and it doesn't even have
> _syscall in there!! It's in /usr/src/linux though...
That means that the kernel devs have decided that API is not userland safe.
In recent kernels, there's a specific 'headers' (or somesuch) make target,
that generates .h files that are appropriate to use in userland.
If you need access to APIs that aren't in those headers, you should be
writing
a kernel module, or convincing the kernel developers to expose these APIs
to
userland. Your kernel module may need be only a tiny stub, just something
to
go between your userland and the non-userland-safe APIs.
> Am I doing something wrong?
It's possible you just need another header. It also possible that there's
a
different entry point now. I seem to remember the location of the syscall
table is recently changed to something like randomized per-process at some
point in the 2.6.1x line. That may have changed how you need to be calling
things.
--
Boyd Stephen Smith Jr. ,= ,-_-. =.
bss03@volumehost.net ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-'
http://iguanasuicide.org/ \_/
New GPG Key! Old key expires 2007-03-25. Upgrade NOW!
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-02-08 10:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-08 0:53 [gentoo-user] _syscallX isn't in linux-headers-2.6.20 ?? Iain Buchanan
2007-02-08 5:10 ` [gentoo-user] " Christian Marie
2007-02-08 7:01 ` Iain Buchanan
2007-02-08 10:40 ` [gentoo-user] " Boyd Stephen Smith Jr.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox