2 Proprietary Rand Corporation
, 1981.
3 Further distribution of
this software
4 subject to the terms of the Rand
9 #include "../h/dirent.h"
35 static char wdbuf
[128];
37 register char *wp
, *cp
, **cpp
;
39 char *savewp
, *markwp
;
47 wp
= prepend(str
, wp
);
48 if (*wp
== '/') return(wp
);
55 wp
= scandir(&d
, fino
, wp
);
56 if (d
.dotino
!= d
.dotdotino
) {
62 if (d
.dotino
!= ROOTINO
) break; /* error */
65 for (cpp
= rootlist
; cp
= *cpp
++; ) {
66 if (stat(cp
, &statb
) < 0) continue;
67 if (statb
.i_dev
== dotdev
) {
75 if (markwp
) *markwp
= '/';
79 scandir(dp
, fileino
, endwhere
)
83 register struct dirinfo
*d
;
84 register char *cp
, *wp
;
90 if (fileino
== 0) wp
= endwhere
;
93 if (fh
< 0) return(wp
);
94 while ((!d
->dotino
|| !d
->dotdotino
|| !wp
) &&
95 read(fh
, &d
->dir
, sizeof d
->dir
) == sizeof d
->dir
) {
96 if (d
->dir
.d_ino
== NULLINO
) continue;
97 if (!d
->dotino
&& equal(d
->dir
.d_name
, "."))
98 d
->dotino
= d
->dir
.d_ino
;
99 else if (!d
->dotdotino
&& equal(d
->dir
.d_name
, ".."))
100 d
->dotdotino
= d
->dir
.d_ino
;
101 else if (!wp
&& d
->dir
.d_ino
== fileino
) {
102 /* ensure name is null term'd */
105 /* separate with '/' */
106 if (*wp
) *--wp
= '/';
107 wp
= prepend(d
->dir
.d_name
, wp
);
114 prepend(prefix
, endwhere
)
115 char *prefix
, *endwhere
;
117 register char *cp
, *wp
;
119 for (cp
= prefix
; *cp
++; );
121 for (wp
= endwhere
; cp
> prefix
; *--wp
= *--cp
);