Bug 174534 - sysctl() system call fails when querying kernel.shmmax
sysctl() system call fails when querying kernel.shmmax
Status: CLOSED NOTABUG
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: kernel (Show other bugs)
4.0
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jason Baron
Brian Brock
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2005-11-29 15:04 EST by Paul Moore
Modified: 2013-03-06 00:59 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2008-03-06 15:01:26 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Paul Moore 2005-11-29 15:04:19 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.0.7-1.1.fc4 Firefox/1.0.7

Description of problem:
When trying to use the sysctl() system call on i386 kernels it fails with ENOTDIR, however, the attribute does exist and reading/setting it via either the sysctl command or /proc/sys directly does work.  Below is a code snippet describing what I am trying to do:

**** CODE SNIPPET ****
#include <sys/types.h>
#include <linux/sysctl.h>
#include <linux/unistd.h>

/* declare the _sysctl() function */
_syscall1(int, _sysctl, struct __sysctl_args *, args)

int main(int argc, char *argv[])
{
  /* needed for sysctl */
  size_t old_shmmax_size = sizeof(old_shmmax);

  /* sysctl variable name */
  int sysctl_name[] = { CTL_KERN, KERN_SHMMAX };

  /* sysctl arguments for getting/setting kernel.shmmax */
  struct __sysctl_args sysctl_cmd = {
    sysctl_name,
    ARRAY_SIZE(sysctl_cmd.name),
    NULL,
    0,
    NULL,
    0
  };

  /* save the value of SHMMAX */
  sysctl_cmd.oldval = &old_shmmax;
  sysctl_cmd.oldlenp = &old_shmmax_size;
  sysctl_cmd.newval = NULL;
  sysctl_cmd.newlen = 0;
  if (_sysctl(&sysctl_cmd) == -1) {
    printf("%s: WARN unable to determine kernel.shmmax\n", __FILE__);
  }
}
**** CODE SNIPPET ****

Version-Release number of selected component (if applicable):
kernel-2.6.9-22.0.1.EL

How reproducible:
Always

Steps to Reproduce:
Use the sysctl() system call.

Additional info:
Comment 1 Jason Baron 2008-03-06 15:01:26 EST
finally, got a chance to look at this one...turns out there is a typo in the
source code:

the line:

ARRAY_SIZE(sysctl_cmd.name)

should be:

ARRAY_SIZE(sysctl_name)

Note You need to log in before you can comment on or make changes to this bug.