bug-glibc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

hard coded path for devpts.


From: Aneesh Kumar K.V
Subject: hard coded path for devpts.
Date: 09 Jul 2003 15:39:01 +0530

Hi, 

 I was going through the code at 

http://sources.redhat.com/cgi-bin/cvsweb.cgi/~checkout~/libc/sysdeps/unix/sysv/linux/getpt.c?rev=1.10&content-type=text/plain&cvsroot=glibc

I have a strange requirement to have cluster wide ttys . That means I
need to have  libutil return me ptys at /dev/clusternodenumber/pts/0 

While looking at the above code i found that the path of pts is hard
coded as  

/* Directory containing the UNIX98 pseudo terminals.  */
#define _PATH_DEVPTS _PATH_DEV "pts"


How about finding the devpts path by using /proc/mounts and getmntent. ?
Something like below. 

#include <stdio.h>
#include <mntent.h>
int main()
{
        FILE *filep;
        struct mntent *procmount;
        if(( filep = fopen("/proc/mounts","r")) == NULL ) {
                perror("Error");
                exit(1);
        }
        while ( (procmount = getmntent(filep)) != NULL ) {
                if( ! strcmp(procmount->mnt_type,"devpts") ) {
                        printf("devpts mounted at %s\n", procmount->mnt_dir);
                        break;
                }
        }
        close(filep);
}









reply via email to

[Prev in Thread] Current Thread [Next in Thread]