[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference hydra::axp-developer

Title:Alpha Developer Support
Notice:[email protected], 800-332-4786
Moderator:HYDRA::SYSTEM
Created:Mon Jun 06 1994
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:3722
Total number of notes:11359

3558.0. "Landmark Systems Corporation" by HYDRA::AXPDEVELOPER (Alpha Developer support) Tue Apr 29 1997 04:24

    Company Name :  Landmark Systems Corporation
    Contact Name :  Shyam R. Harohalli
    Phone        :  (703) 902 8124
    Fax          :  
    Email        :  [email protected]
    Date/Time in :  29-APR-1997 02:56:47
    Entered by   :  Richard Readings
    SPE center   :  MRO

    Category     :  unix
    OS Version   :  v4
    System H/W   :  


    Brief Description of Problem:
    -----------------------------

From:	SMTP%"[email protected]" 28-APR-1997 18:04:24.86
To:	[email protected]
CC:	[email protected] (Craig E Despeaux ext 8299)
Subj:	Error Using PIOCGETU ioctl.

Return-Path: [email protected]
Received: by vaxsim.mro.dec.com (UCX V4.1-12, OpenVMS V6.2 VAX);
	Mon, 28 Apr 1997 18:04:14 -0400
Received: from fwout.landmark.com by mail12.digital.com (8.7.5/UNX 1.5/1.0/WV)
	id RAA25609; Mon, 28 Apr 1997 17:58:29 -0400 (EDT)
Received: by fwout.landmark.com; id RAA26361; Mon, 28 Apr 1997 17:57:44 -0400 (EDT)
Received: from saturn.landmark.com(192.246.113.34) by fw.landmark.com via smap (3.2)
	id xma026349; Mon, 28 Apr 97 17:57:28 -0400
Received: from proda.landmark.com (proda.landmark.com [199.100.108.22]) by Landmark.Com (Howdy Partner/nope) with ESMTP id RAA24140; Mon, 28 Apr 1997 17:48:10 -0400 (EDT)
From: Shyam Harahalli <[email protected]>
Received: (from shyamh@localhost)
          by proda.landmark.com (8.8.4/8.8.4)
	  id RAA15950; Mon, 28 Apr 1997 17:48:10 -0400
Message-Id: <[email protected]>
Subject: Error Using PIOCGETU ioctl.
To: [email protected]
Date: Mon, 28 Apr 1997 17:48:10 -0400 (EDT)
Cc: [email protected] (Craig E Despeaux ext 8299)
In-Reply-To: <[email protected]> from "[email protected]" at Apr 14, 97 02:58:29 pm
X-Mailer: ELM [version 2.4 PL23]
Content-Type: text


	Hello,
	In the following fragment of code, I am getting
	EACCES (errno = 13) when I try to obtain the user
	struct using ioctl PIOCGETU, in spite of running the
	program as a super-user.  
	Other ioctls (PIOCCRED and PIOCPSINFO) have no problems.  
	They return succesfully.
	I noticed the same behaiour both on OSF1/V4.0 and OSF1/V3.2.
-----
.
.
	if ((fd = open (filename, O_RDONLY)) < 0)
    	{
        	printf("Error Opening PROCFS\n");
        	goto LOOP;
    	}
/* filename is a process-entry in /proc, such as "/proc/07960" */
 

   if (ioctl (fd, PIOCCRED, &creds) < 0)
   {
      printf("Error ioctl PIOCCRED:Error %d\n", errno);
      close(fd);
      return;
   }
   if (ioctl (fd, PIOCPSINFO, &p) < 0)
   {
	   printf("Error ioctl PIOCPSINFO: Error %d\n", errno);
	   close (fd);
	   return;
   }
   if (ioctl (fd, PIOCGETU, &userstruct) < 0)
   {
	printf("Error ioctl PIOCGETU, Error is %d\n", errno);
       close(fd);
       return;
   }
.
.
-----
	Do I have to call any other ioctls, (to set the permissions if any) 
	before calling the PIOCGETU ioctl?
	(The same program works well on Solaris2.4, which also
	supports /proc file system.)

	Thanks,

	Shyam
---------------------------------------------------------
Shyam R. Harohalli
Landmark Systems Corporation
8000 Towers Crescent Drive
Vienna, Virginia 22182-2700
Telephone:	(703) 902 8124 (Work)
---------------------------------------------------------

T.RTitleUserPersonal
Name
DateLines
3558.1AcknowledgedRDGENG::ddors.reo.dec.com::readings_rTue Apr 29 1997 07:383
I'm trying to determine the cause of the problem you report and hope to get back to you 
soon.

3558.1In "Steel"RDGENG::ddors.reo.dec.com::readings_rWed Apr 30 1997 06:373
PIOCGETU is not currently implemented in Digital UNIX. It will appear in the next 
major functional release, code name "Steel", scheduled for early 1998.

3558.2Trying to use table(TBL_UAREA..)RDGENG::READINGS_RRichard ReadingsFri May 02 1997 11:1035
Thanks for your reply.  Meanwhile, I was able to get some of the data (from
user-structure) that I was looking for, using the 'table(TBL_UAREA..)'
interface.  However, the 'u_rlimit[RLIM_NLIMITS]' field of user structure
does not seem to contain any relevant data on resource limits.  I am getting
zeroes for both the maximum and current values.(program is run with
super-user privileges)  

Here is a fragment of my program. 
        .
        .
        .
(index is a valid pid)
        retvalue = table(TBL_UAREA, index, &userinfo, 1, sizeof(userinfo));
        if (retvalue < 0)
        {
                fprintf(stderr, "UAREA table x-face failed: Er= %d\n", errno);
                return ;
        }
        fprintf(stdout, "User Area Sucess\n");
        fprintf(stdout, "\t u_logname = %s\n", userinfo.u_logname);
        fprintf(stdout, "\t u_ssize = %d\n", userinfo.u_ssize);
        fprintf(stdout, "\t u_tsize = %d\n", userinfo.u_tsize);
        fprintf(stdout, "\t u_dsize = %d\n", userinfo.u_dsize);
        fprintf(stdout, "\t Vol ctxsw = %d\n", userinfo.u_ru.ru_nvcsw);
        
        fprintf(stdout, "\t DataLimCur = %ld\n", userinfo.u_rlimit[RLIMIT_DATA].
rlim_cur);
        fprintf(stdout, "\t DataLimMAX = %ld\n", userinfo.u_rlimit[RLIMIT_DATA].
rlim_max);
        .
        .
        .
DataLimCur and DataLimMAX are always zeroes.  These fields (of user
structure, holding info on resource controls) are identical on Solaris where
we are able to get these resource limit values. 
3558.3table(TBL_UAREA...) fails to return resource limitsRDGENG::ddors.reo.dec.com::readings_rThu May 08 1997 10:0752
Thanks for your reply.  Meanwhile, I was able to get some of the data (from 
user-structure) that I was looking for, using the 'table(TBL_UAREA..)' 
interface.  However, the 'u_rlimit[RLIM_NLIMITS]' field of user structure 
does not seem to contain any relevant data on resource limits.  I am getting 
zeroes for both the maximum and current values.(program is run with 
super-user privileges). getrlimit returns the correct values.

-------------------------------- example.c ---------------------------------

#include <stdio.h>
#include <sys/table.h>
#include <sys/user.h>

main()
{
        int retvalue;
        long  cur_proc;
        struct rlimit  stddata; 
        struct user userinfo;

        /* Get Current Process ID */
        cur_proc = getpid(); 

        /* Get UAREA for Current Process */
        retvalue = table(TBL_UAREA, cur_proc, &userinfo, 1, 
sizeof(userinfo));
        if (retvalue < 0)
        {
                fprintf(stderr, "UAREA interface failed: Error = %d\n", 
errno);
                return ;
        }

        /* Limits using TBL_UAREA */
        fprintf(stdout, " Limits Using TBL_UAREA For current Process\n");
        fprintf(stdout, "\t DataLimCur = %ld",
userinfo.u_rlimit[RLIMIT_DATA].rlim_cur);
        fprintf(stdout, "\t DataLimMAX = %ld\n",
userinfo.u_rlimit[RLIMIT_DATA].rlim_max);

        /* Limits using getrlimit */
        if (getrlimit(RLIMIT_DATA, &stddata) < 0) 
        {
                fprintf(stdout, "\n getrlimit fails: Error is %d\n", errno);
                return;
        }
        fprintf(stdout, "\n Limits Using getrlimit For current Process\n");
        fprintf(stdout, "\t Cur = %lu, Max = %lu\n",
stddata.rlim_cur,stddata.rlim_max);
} /* end of main() */


3558.4QAR # 52918RDGENG::ddors.reo.dec.com::readings_rThu May 08 1997 10:0812
The "user" structure doesn't really exist in the kernel.  It is 
really spread over 3 different structures, uthread, utask and 
np_uthread.  The routine that pieces this together to create the 
"user" structure isn't filling the structure out completely. Looks 
like you've found a bug, but fortunately getrlimit provides an 
alternative. 

Thanks for pointing out the problem and providing a reproducer. I've 
QAR'd it with engineering.

QAR # 52918

3558.5NNTPD::&quot;[email protected]&quot;Gerrit SaylorThu May 29 1997 17:2047
Date: Thu, 29 May 1997 12:43:13 -0400
To: [email protected]
From: Shyam Harohalli <[email protected]>
Subject: Re: Error Using PIOCGETU ioctl
Cc: [email protected]

Hello Richard,
I think, I have bumped into another problem, this time in proc structure.
My program uses ioctl(fd, PIOCPSINFO, &procstruc) to get info on a
particular process.  'fd' is got from /proc file.  3rd argument 'procstruc'
is structure 'prpsinfo', defined in <sys/procfs.h>. 
The controlling terminal for this process, will be "procstruc.pr_ttydev".
I always get this value as "??".  Even for processes which have a valid
controling terminal (such as /dev/ttyp4) the value in this field is "??".
Please let me know, if this is an existing problem in prpsinfo.pr_tty
(sys/procfs.h).

Thanks,

Shyam   
At 01:56 PM 5/8/97 +0100, you wrote:
>The "user" structure doesn't really exist in the kernel.  It is really
>spread over 3 different structures, uthread, utask and np_uthread.  The
>routine that pieces this together to create the "user" structure isn't
>filling the structure out completely. Looks like you've found a bug, but
>fortunately getrlimit provides an alternative. 
>
>Thanks for pointing out the problem and providing a reproducer. I've
>QAR'd it with engineering.
>
>Richard
>-- 
>Richard Readings                        email:  [email protected]
>Digital Equipment Co Ltd.               tel:    +44 (0)118 920 4101
>Reading RG2 0TE				fax:    +44 (0)118 920 4146
>ENGLAND
>
>
--
	Shyam Harohalli
	Landmark Systems Corp.
	(703) 902 8124
	(703) 893-1422 (fax)
	[email protected]


[Posted by WWW Notes gateway]
3558.6closedRDGENG::newdial_p1.reo.dec.com::readings_rFri Jun 06 1997 05:404
I first noticed this problem on 3.2.  Later, I figured out a mistake in my
program, while getting the device-number from proc table. Now, I am able to
get it succesfully on 4.0.  You may go ahead and close this problem.  I
appreciate your help.