/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1990-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* Glenn Fowler
* AT&T Research
*
* return a pointer to a pathname for an open fd
*/
#include "cslib.h"
#include <ast_dir.h>
/*
* someone thinks FIFO and SOCK are the same (bsd, eh?)
*/
#endif
/*
* scan /dev for path matching st
*/
static char*
{
char* base;
int n;
int t;
for (n = 1;;)
{
{
#ifdef D_FILENO
continue;
#endif
continue;
continue;
{
{
*base++ = '/';
}
else
{
subp = 0;
}
continue;
}
#ifndef D_FILENO
continue;
#endif
if (idevice(&tst) == idevice(st) && ((t = S_ISBLK(tst.st_mode)) || S_ISCHR(tst.st_mode)) && t == blk && (!n || tst.st_dev == st->st_dev && tst.st_ino == st->st_ino))
{
return path;
}
}
if (subp)
{
subp = 0;
}
else if (!n--) break;
}
return 0;
}
/*
* return a pointer to a pathname for an open fd
*/
char*
{
register char* s;
int typ;
#if CS_LIB_V10
#else
#if CS_LIB_SOCKET
#ifdef SO_TYPE
#endif
#endif
#endif
else if (S_ISFIFO(st.st_mode)) sfsprintf(state->path, sizeof(state->path), "/dev/pipe/%u", st.st_ino);
#if CS_LIB_V10
{
if (tcp.raddr) sfsprintf(state->path, sizeof(state->path), "/dev/tcp/%s/%d.%d", (flags & CS_PATH_NAME) ? csname(state, tcp.raddr) : csntoa(state, tcp.raddr), ntohs(tcp.rport), ntohs(tcp.lport));
else
{
sfsprintf(state->path, sizeof(state->path), "/dev/tcp/%s/%d", (flags & CS_PATH_NAME) ? csname(state, tcp.laddr) : csntoa(state, tcp.laddr), ntohs(tcp.lport));
}
}
#endif
#if CS_LIB_SOCKET
else if (!getsockname(fd, (struct sockaddr*)&lcl, &namlen) && namlen == sizeof(lcl) && lcl.sin_family == AF_INET)
{
s = "tcp";
#ifdef SO_TYPE
{
case SOCK_DGRAM:
s = "udp";
break;
case SOCK_STREAM:
break;
default:
break;
}
#endif
if (!getpeername(fd, (struct sockaddr*)&rmt, &namlen) && namlen == sizeof(rmt) && rmt.sin_family == AF_INET)
{
sfsprintf(state->path, sizeof(state->path), "/dev/%s/%s/%d.%d", s, (flags & CS_PATH_NAME) ? csname(state, (unsigned long)rmt.sin_addr.s_addr) : csntoa(state, (unsigned long)rmt.sin_addr.s_addr), ntohs((unsigned short)rmt.sin_port), ntohs((unsigned short)lcl.sin_port));
}
else
{
sfsprintf(state->path, sizeof(state->path), "/dev/%s/%s/%d", s, (flags & CS_PATH_NAME) ? csname(state, (unsigned long)lcl.sin_addr.s_addr) : csntoa(state, (unsigned long)lcl.sin_addr.s_addr), ntohs((unsigned short)lcl.sin_port));
}
}
#endif
{
return s;
sfsprintf(state->path, sizeof(state->path), "/dev/%s-%u,%u", typ ? "blk" : "chr", major(idevice(&st)), minor(idevice(&st)));
}
else
}
char*
{
}