projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
the window strings is NOT quoted at this point; other cleanups
[unix-history]
/
usr
/
src
/
lib
/
libc
/
gen
/
ttyname.c
diff --git
a/usr/src/lib/libc/gen/ttyname.c
b/usr/src/lib/libc/gen/ttyname.c
index
34f59f3
..
a7dabea
100644
(file)
--- a/
usr/src/lib/libc/gen/ttyname.c
+++ b/
usr/src/lib/libc/gen/ttyname.c
@@
-1,4
+1,7
@@
-/* @(#)ttyname.c 4.1 (Berkeley) %G% */
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)ttyname.c 5.2 (Berkeley) %G%";
+#endif LIBC_SCCS and not lint
+
/*
* ttyname(f): return "/dev/ttyXX" which the the name of the
* tty belonging to file f.
/*
* ttyname(f): return "/dev/ttyXX" which the the name of the
* tty belonging to file f.
@@
-6,7
+9,7
@@
*/
#define NULL 0
*/
#define NULL 0
-#include <sys/
types
.h>
+#include <sys/
param
.h>
#include <sys/dir.h>
#include <sys/stat.h>
#include <sys/dir.h>
#include <sys/stat.h>
@@
-19,9
+22,9
@@
ttyname(f)
{
struct stat fsb;
struct stat tsb;
{
struct stat fsb;
struct stat tsb;
- struct direct db;
+ register struct direct *db;
+ register DIR *df;
static char rbuf[32];
static char rbuf[32];
- register df;
if (isatty(f)==0)
return(NULL);
if (isatty(f)==0)
return(NULL);
@@
-29,22
+32,20
@@
ttyname(f)
return(NULL);
if ((fsb.st_mode&S_IFMT) != S_IFCHR)
return(NULL);
return(NULL);
if ((fsb.st_mode&S_IFMT) != S_IFCHR)
return(NULL);
- if ((df = open
(dev, 0)) < 0
)
+ if ((df = open
dir(dev)) == NULL
)
return(NULL);
return(NULL);
- while (read(df, (char *)&db, sizeof(db)) == sizeof(db)) {
- if (db.d_ino == 0)
- continue;
- if (db.d_ino != fsb.st_ino)
+ while ((db = readdir(df)) != NULL) {
+ if (db->d_ino != fsb.st_ino)
continue;
strcpy(rbuf, dev);
continue;
strcpy(rbuf, dev);
- strcat(rbuf, db
.
d_name);
+ strcat(rbuf, db
->
d_name);
if (stat(rbuf, &tsb) < 0)
continue;
if (stat(rbuf, &tsb) < 0)
continue;
- if (tsb.st_dev
==fsb.st_dev && tsb.st_ino==
fsb.st_ino) {
- close(df);
+ if (tsb.st_dev
== fsb.st_dev && tsb.st_ino ==
fsb.st_ino) {
+ close
dir
(df);
return(rbuf);
}
}
return(rbuf);
}
}
- close(df);
+ close
dir
(df);
return(NULL);
}
return(NULL);
}