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

Conference turris::digital_unix

Title:DIGITAL UNIX(FORMERLY KNOWN AS DEC OSF/1)
Notice:Welcome to the Digital UNIX Conference
Moderator:SMURF::DENHAM
Created:Thu Mar 16 1995
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:10068
Total number of notes:35879

9649.0. "EACCES returned by PIOCGETU ioctl" by RDGENG::ddors.reo.dec.com::readings_r () Tue Apr 29 1997 08:05

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. This is the same under DUNIX 3.2 and 4.0.
        
Other ioctls (PIOCCRED and PIOCPSINFO) have no problems.  
        
-----
.
.
        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 Solaris 2.4, 
which also supports /proc file system.

Richard
T.RTitleUserPersonal
Name
DateLines
9649.1SMURF::DENHAMDigital UNIX KernelTue Apr 29 1997 10:142
    Well, sorry to say, but that's what PIOCGETU returns. It's simply
    not implemented before our "Steel" release.
9649.2table(TBL_UAREA..) as an alternative?RDGENG::READINGS_RRichard ReadingsFri May 02 1997 11:3268
Re .1,

>    Well, sorry to say, but that's what PIOCGETU returns. It's simply
>    not implemented before our "Steel" release.

As an alternative the customer has been 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.  For example 
the following program always returns DataLimCur and DataLimMAX as zero. Is this 
correct?

Richard

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

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

#include <signal.h>
#include <sys/errno.h>
#include <sys/resource.h>


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

	fprintf(stdout, "PLEASE REMEMBER TO RUN THIS PROGRAM AS SUPER-USER\n\n");

	/* 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 ;
	}

	fprintf(stdout, "\n TBL_UAREA Sucess:Current PID: %ld\n", cur_proc);
	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 u_outime = %d\n", userinfo.u_outime);	
	fprintf(stdout, "\t r_usage vol ctx = %d\n", userinfo.u_ru.ru_nvcsw);	

	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() */