Bug 174534

Summary: sysctl() system call fails when querying kernel.shmmax
Product: Red Hat Enterprise Linux 4 Reporter: Paul Moore <paul.moore>
Component: kernelAssignee: Jason Baron <jbaron>
Status: CLOSED NOTABUG QA Contact: Brian Brock <bbrock>
Severity: medium Docs Contact:
Priority: medium    
Version: 4.0CC: knoel
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-03-06 20:01:26 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Paul Moore 2005-11-29 20:04:19 UTC
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 20:01:26 UTC
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)