man sysctl(2) informs that this is a non-portable way to extract this
value.
> Excuse me, the suggestion was by mistake. Use sysctl(). I just had a
> look through <confname.h>, sysconf() doesn't support anything beyond
> the POSIX definitions, no SG_BIG_BUFF.
OK. I beleave it should be extractable for sysconf(), but until that
happends, we will just have to make without it.
> Anyway is this doable? I can't be the only one using a distribution
> and modifying SG_BIG_BUFF (I do it to also improve cdda audio
> ripping performance)...
I beleave it is the correct way. If the function returning the value
is written to try lots of ways to extract this value, the result
should be quite portable. Example:
/*
* return max size of file buffers(?), or -1 if not able to find the
* current value.
*/
int
get_sg_big_buff_value(void)
{
int value = -1;
FILE *procfile = NULL;
procfile = fopen("/proc/sys/kernel/sg-big-buff", "r");
if (NULL != procfile)
{
fscanf(procfile, "%d", &value);
fclose(procfile);
return value;
}
#if defined(HAVE_LINUX_SYSCTL_H) && defined(HAVE_SYSCTL)
{
int name[] = { CTL_KERN, KERN_SG_BIG_BUFF };
int namesize = sizeof(name)/sizeof(name[0]);
if (0 == sysctl(name, namesize, &value, sizeof(value), 0, 0))
return value;
}
#endif
/* ... More ways to find it ... */
return value;
}
This code is not tested. I'm not even sure if it compiles. You have
been warned. :-)
BTW: '/proc/sys/kernel/sg-big-buff' is missing on Linux 2.0.32, but
present on 2.2.0-pre5.
-- ##> Petter Reinholdtsen <## | pere@td.org.uit.no O- | http://www.hungry.com/~pere/ | Go Mozilla, go! Go!
-- Source code, list archive, and docs: http://www.mostang.com/sane/ To unsubscribe: echo unsubscribe sane-devel | mail majordomo@mostang.com