6 #include <rpmio_internal.h>
15 extern int _rpmio_debug;
18 /* =============================================================== */
19 static int ftpMkdir(const char * path, /*@unused@*/ mode_t mode)
20 /*@globals fileSystem @*/
21 /*@modifies fileSystem @*/
24 if ((rc = ftpCmd("MKD", path, NULL)) != 0)
28 sprintf(buf, " 0%o", mode);
29 (void) ftpCmd("SITE CHMOD", path, buf);
35 static int ftpChdir(const char * path)
36 /*@globals fileSystem @*/
37 /*@modifies fileSystem @*/
39 return ftpCmd("CWD", path, NULL);
42 static int ftpRmdir(const char * path)
43 /*@globals fileSystem @*/
44 /*@modifies fileSystem @*/
46 return ftpCmd("RMD", path, NULL);
49 static int ftpRename(const char * oldpath, const char * newpath)
50 /*@globals fileSystem @*/
51 /*@modifies fileSystem @*/
54 if ((rc = ftpCmd("RNFR", oldpath, NULL)) != 0)
56 return ftpCmd("RNTO", newpath, NULL);
59 static int ftpUnlink(const char * path)
60 /*@globals fileSystem @*/
61 /*@modifies fileSystem @*/
63 return ftpCmd("DELE", path, NULL);
66 /* =============================================================== */
67 /* XXX rebuilddb.c: analogues to mkdir(2)/rmdir(2). */
68 int Mkdir (const char * path, mode_t mode)
71 int ut = urlPath(path, &lpath);
75 return ftpMkdir(path, mode);
76 /*@notreached@*/ break;
77 case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
86 /*@notreached@*/ break;
88 return mkdir(path, mode);
91 int Chdir (const char * path)
94 int ut = urlPath(path, &lpath);
98 return ftpChdir(path);
99 /*@notreached@*/ break;
100 case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
109 /*@notreached@*/ break;
114 int Rmdir (const char * path)
117 int ut = urlPath(path, &lpath);
121 return ftpRmdir(path);
122 /*@notreached@*/ break;
123 case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
132 /*@notreached@*/ break;
137 /* XXX rpmdb.c: analogue to rename(2). */
139 int Rename (const char * oldpath, const char * newpath)
141 const char *oe = NULL;
142 const char *ne = NULL;
145 /* XXX lib/install.c used to rely on this behavior. */
146 if (!strcmp(oldpath, newpath)) return 0;
148 oldut = urlPath(oldpath, &oe);
150 case URL_IS_FTP: /* XXX WRONG WRONG WRONG */
151 case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
158 /*@notreached@*/ break;
161 newut = urlPath(newpath, &ne);
165 fprintf(stderr, "*** rename old %*s new %*s\n", (int)(oe - oldpath), oldpath, (int)(ne - newpath), newpath);
166 if (!(oldut == newut && oe && ne && (oe - oldpath) == (ne - newpath) &&
167 !xstrncasecmp(oldpath, newpath, (oe - oldpath))))
169 return ftpRename(oldpath, newpath);
170 /*@notreached@*/ break;
171 case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
181 /*@notreached@*/ break;
183 return rename(oldpath, newpath);
186 int Link (const char * oldpath, const char * newpath)
188 const char *oe = NULL;
189 const char *ne = NULL;
192 oldut = urlPath(oldpath, &oe);
194 case URL_IS_FTP: /* XXX WRONG WRONG WRONG */
195 case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
202 /*@notreached@*/ break;
205 newut = urlPath(newpath, &ne);
207 case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
208 case URL_IS_FTP: /* XXX WRONG WRONG WRONG */
211 fprintf(stderr, "*** link old %*s new %*s\n", (int)(oe - oldpath), oldpath, (int)(ne - newpath), newpath);
212 if (!(oldut == newut && oe && ne && (oe - oldpath) == (ne - newpath) &&
213 !xstrncasecmp(oldpath, newpath, (oe - oldpath))))
223 /*@notreached@*/ break;
225 return link(oldpath, newpath);
228 /* XXX build/build.c: analogue to unlink(2). */
230 int Unlink(const char * path) {
232 int ut = urlPath(path, &lpath);
236 return ftpUnlink(path);
237 /*@notreached@*/ break;
238 case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
247 /*@notreached@*/ break;
252 /* XXX swiped from mc-4.5.39-pre9 vfs/ftpfs.c */
254 #define g_strdup xstrdup
258 * FIXME: this is broken. It depends on mc not crossing border on month!
261 static int current_mday;
263 static int current_mon;
265 static int current_year;
267 /* Following stuff (parse_ls_lga) is used by ftpfs and extfs */
271 static char *columns [MAXCOLS]; /* Points to the string in column n */
273 static int column_ptr [MAXCOLS]; /* Index from 0 to the starting positions of the columns */
276 vfs_split_text (char *p)
277 /*@globals columns, column_ptr @*/
278 /*@modifies *p, columns, column_ptr @*/
284 for (numcols = 0; *p && numcols < MAXCOLS; numcols++){
285 while (*p == ' ' || *p == '\r' || *p == '\n'){
289 columns [numcols] = p;
290 column_ptr [numcols] = p - original;
291 while (*p && *p != ' ' && *p != '\r' && *p != '\n')
301 if (!columns [idx] || columns [idx][0] < '0' || columns [idx][0] > '9')
307 is_dos_date(/*@null@*/ const char *str)
310 if (str != NULL && strlen(str) == 8 &&
311 str[2] == str[5] && strchr("\\-/", (int)str[2]) != NULL)
317 is_week (/*@null@*/ const char * str, /*@out@*/ struct tm * tim)
320 /*@observer@*/ static const char * week = "SunMonTueWedThuFriSat";
323 /*@-observertrans -mayaliasunique@*/
324 if (str != NULL && (pos=strstr(week, str)) != NULL) {
325 /*@=observertrans =mayaliasunique@*/
327 tim->tm_wday = (pos - week)/3;
334 is_month (/*@null@*/ const char * str, /*@out@*/ struct tm * tim)
337 /*@observer@*/ static const char * month = "JanFebMarAprMayJunJulAugSepOctNovDec";
340 /*@-observertrans -mayaliasunique@*/
341 if (str != NULL && (pos = strstr(month, str)) != NULL) {
342 /*@=observertrans -mayaliasunique@*/
344 tim->tm_mon = (pos - month)/3;
351 is_time (/*@null@*/ const char * str, /*@out@*/ struct tm * tim)
354 const char * p, * p2;
356 if (str != NULL && (p = strchr(str, ':')) && (p2 = strrchr(str, ':'))) {
358 if (sscanf (str, "%2d:%2d:%2d", &tim->tm_hour, &tim->tm_min, &tim->tm_sec) != 3)
361 if (sscanf (str, "%2d:%2d", &tim->tm_hour, &tim->tm_min) != 2)
370 static int is_year(/*@null@*/ const char * str, /*@out@*/ struct tm * tim)
381 if (strlen(str) != 4)
384 if (sscanf(str, "%ld", &year) != 1)
387 if (year < 1900 || year > 3000)
390 tim->tm_year = (int) (year - 1900);
396 * FIXME: this is broken. Consider following entry:
397 * -rwx------ 1 root root 1 Aug 31 10:04 2904 1234
398 * where "2904 1234" is filename. Well, this code decodes it as year :-(.
402 vfs_parse_filetype (char c)
406 case 'd': return S_IFDIR;
407 case 'b': return S_IFBLK;
408 case 'c': return S_IFCHR;
409 case 'l': return S_IFLNK;
411 #ifdef IS_IFSOCK /* And if not, we fall through to IFIFO, which is pretty close */
414 case 'p': return S_IFIFO;
415 case 'm': case 'n': /* Don't know what these are :-) */
416 case '-': case '?': return S_IFREG;
421 static int vfs_parse_filemode (const char *p)
423 { /* converts rw-rw-rw- into 0666 */
426 case 'r': res |= 0400; break;
431 case 'w': res |= 0200; break;
436 case 'x': res |= 0100; break;
437 case 's': res |= 0100 | S_ISUID; break;
438 case 'S': res |= S_ISUID; break;
443 case 'r': res |= 0040; break;
448 case 'w': res |= 0020; break;
453 case 'x': res |= 0010; break;
454 case 's': res |= 0010 | S_ISGID; break;
455 case 'l': /* Solaris produces these */
456 case 'S': res |= S_ISGID; break;
461 case 'r': res |= 0004; break;
466 case 'w': res |= 0002; break;
471 case 'x': res |= 0001; break;
472 case 't': res |= 0001 | S_ISVTX; break;
473 case 'T': res |= S_ISVTX; break;
480 static int vfs_parse_filedate(int idx, /*@out@*/ time_t *t)
482 { /* This thing parses from idx in columns[] array */
489 /* Let's setup default time values */
490 tim.tm_year = current_year;
491 tim.tm_mon = current_mon;
492 tim.tm_mday = current_mday;
496 tim.tm_isdst = -1; /* Let mktime() try to guess correct dst offset */
500 /* We eat weekday name in case of extfs */
505 if(is_month(p, &tim)){
506 /* And we expect, it followed by day number */
508 tim.tm_mday = (int)atol (columns [idx++]);
510 return 0; /* No day */
513 /* We usually expect:
516 But in case of extfs we allow these date formats:
519 Wek Mon DD hh:mm:ss YYYY
521 where Mon is Jan-Dec, DD, MM, YY two digit day, month, year,
522 YYYY four digit year, hh, mm, ss two digit hour, minute or second. */
524 /* Here just this special case with MM-DD-YY */
528 memset(d, 0, sizeof(d));
529 if (sscanf(p, "%2d-%2d-%2d", &d[0], &d[1], &d[2]) == 3){
536 /* Hmm... maybe, next time :)*/
538 /* At last, MM-DD-YY */
539 d[0]--; /* Months are zerobased */
549 return 0; /* sscanf failed */
551 return 0; /* unsupported format */
554 /* Here we expect to find time and/or year */
557 if(is_time(columns[idx], &tim) || (got_year = is_year(columns[idx], &tim))) {
560 /* This is a special case for ctime() or Mon DD YYYY hh:mm */
562 ((got_year = is_year(columns[idx], &tim)) || is_time(columns[idx], &tim)))
563 idx++; /* time & year or reverse */
564 } /* only time or date */
567 return 0; /* Nor time or date */
570 * If the date is less than 6 months in the past, it is shown without year
571 * other dates in the past or future are shown with year but without time
572 * This does not check for years before 1900 ... I don't know, how
573 * to represent them at all
576 current_mon < 6 && current_mon < tim.tm_mon &&
577 tim.tm_mon - current_mon >= 6)
581 if ((*t = mktime(&tim)) < 0)
587 vfs_parse_ls_lga (char * p, /*@out@*/ struct stat * st,
588 /*@out@*/ const char ** filename,
589 /*@out@*/ const char ** linkname)
590 /*@modifies *st, *filename, *linkname @*/
592 int idx, idx2, num_cols;
596 if (strncmp (p, "total", 5) == 0)
599 p_copy = g_strdup(p);
600 /* XXX FIXME: parse out inode number from "NLST -lai ." */
601 /* XXX FIXME: parse out sizein blocks from "NLST -lais ." */
603 if ((i = vfs_parse_filetype(*(p++))) == -1)
607 if (*p == ' ') /* Notwell 4 */
610 if (strlen (p) <= 8 || p [8] != ']')
612 /* Should parse here the Notwell permissions :) */
614 if (S_ISDIR (st->st_mode))
615 st->st_mode |= (S_IRUSR | S_IRGRP | S_IROTH | S_IWUSR | S_IXUSR | S_IXGRP | S_IXOTH);
617 st->st_mode |= (S_IRUSR | S_IRGRP | S_IROTH | S_IWUSR);
621 if ((i = vfs_parse_filemode(p)) == -1)
626 /* This is for an extra ACL attribute (HP-UX) */
632 p_copy = g_strdup(p);
633 num_cols = vfs_split_text (p);
635 st->st_nlink = atol (columns [0]);
636 if (st->st_nlink < 0)
641 st->st_uid = finduid (columns [1]);
643 (void) unameToUid (columns [1], &st->st_uid);
646 st->st_uid = (uid_t) atol (columns [1]);
648 /* Mhm, the ls -lg did not produce a group field */
649 for (idx = 3; idx <= 5; idx++)
650 if (is_month(columns [idx], NULL) || is_week(columns [idx], NULL) || is_dos_date(columns[idx]))
653 if (idx == 6 || (idx == 5 && !S_ISCHR (st->st_mode) && !S_ISBLK (st->st_mode)))
656 /* We don't have gid */
657 if (idx == 3 || (idx == 4 && (S_ISCHR(st->st_mode) || S_ISBLK (st->st_mode))))
660 /* We have gid field */
662 st->st_gid = (gid_t) atol (columns [2]);
665 st->st_gid = findgid (columns [2]);
667 (void) gnameToGid (columns [1], &st->st_gid);
673 if (S_ISCHR (st->st_mode) || S_ISBLK (st->st_mode)){
676 if (!is_num (idx2) || sscanf(columns [idx2], " %d,", &maj) != 1)
679 if (!is_num (++idx2) || sscanf(columns [idx2], " %d", &min) != 1)
683 st->st_rdev = ((maj & 0xff) << 8) | (min & 0xffff00ff);
688 /* Common file size */
692 st->st_size = (size_t) atol (columns [idx2]);
698 idx = vfs_parse_filedate(idx, &st->st_mtime);
701 /* Use resulting time value */
702 st->st_atime = st->st_ctime = st->st_mtime;
705 #ifdef HAVE_ST_BLKSIZE
706 st->st_blksize = 512;
708 #ifdef HAVE_ST_BLOCKS
709 st->st_blocks = (st->st_size + 511) / 512;
712 for (i = idx + 1, idx2 = 0; i < num_cols; i++ )
713 if (strcmp (columns [i], "->") == 0){
718 if (((S_ISLNK (st->st_mode) ||
719 (num_cols == idx + 3 && st->st_nlink > 1))) /* Maybe a hardlink? (in extfs) */
726 t = g_strndup (p_copy + column_ptr [idx], column_ptr [idx2] - column_ptr [idx] - 1);
728 int nb = column_ptr [idx2] - column_ptr [idx] - 1;
730 strncpy(t, p_copy + column_ptr [idx], nb);
735 t = g_strdup (p_copy + column_ptr [idx2+1]);
737 if (t [tlen-1] == '\r' || t [tlen-1] == '\n')
739 if (t [tlen-2] == '\r' || t [tlen-2] == '\n')
745 /* Extract the filename from the string copy, not from the columns
746 * this way we have a chance of entering hidden directories like ". ."
750 *filename = g_strdup (columns [idx++]);
755 t = g_strdup (p_copy + column_ptr [idx++]);
758 if (t [tlen-1] == '\r' || t [tlen-1] == '\n')
760 if (t [tlen-2] == '\r' || t [tlen-2] == '\n')
774 static int errorcount = 0;
776 if (++errorcount < 5) {
777 message_1s (1, "Could not parse:", p_copy);
778 } else if (errorcount == 5)
779 message_1s (1, "More parsing errors will be ignored.", "(sorry)" );
784 if (p_copy != p) /* Carefull! */
801 static size_t ftpBufAlloced = 0;
806 static /*@only@*/ char * ftpBuf = NULL;
808 #define alloca_strdup(_s) strcpy(alloca(strlen(_s)+1), (_s))
810 static int ftpNLST(const char * url, ftpSysCall_t ftpSysCall,
811 /*@out@*/ /*@null@*/ struct stat * st,
812 /*@out@*/ /*@null@*/ char * rlbuf, size_t rlbufsiz)
813 /*@globals fileSystem @*/
814 /*@modifies *st, *rlbuf, fileSystem @*/
818 int bufLength, moretodo;
819 const char *n, *ne, *o, *oe;
828 n = ne = o = oe = NULL;
829 (void) urlPath(url, &path);
833 switch (ftpSysCall) {
835 fd = ftpOpen(url, 0, 0, &u);
836 if (fd == NULL || u == NULL)
839 u->openError = ftpReq(fd, "NLST", path);
842 urldn = alloca_strdup(url);
844 if ((bn = strrchr(urldn, '/')) == NULL)
853 rc = ftpChdir(urldn); /* XXX don't care about CWD */
857 fd = ftpOpen(url, 0, 0, &u);
858 if (fd == NULL || u == NULL)
861 /* XXX possibly should do "NLST -lais" to get st_ino/st_blocks also */
862 u->openError = ftpReq(fd, "NLST", "-la");
864 if (bn == NULL || nbn <= 0) {
871 if (u->openError < 0) {
872 fd = fdLink(fd, "error data (ftpStat)");
877 if (ftpBufAlloced == 0 || ftpBuf == NULL) {
878 ftpBufAlloced = url_iobuf_size;
879 ftpBuf = xcalloc(ftpBufAlloced, sizeof(ftpBuf[0]));
888 /* XXX FIXME: realloc ftpBuf is < ~128 chars remain */
889 if ((ftpBufAlloced - bufLength) < (1024+80)) {
891 ftpBuf = xrealloc(ftpBuf, ftpBufAlloced);
893 s = se = ftpBuf + bufLength;
896 rc = fdFgets(fd, se, (ftpBufAlloced - bufLength));
901 if (ftpSysCall == DO_FTP_GLOB) { /* XXX HACK */
902 bufLength += strlen(se);
906 for (s = se; *s != '\0'; s = se) {
909 while (*se && *se != '\n') se++;
910 if (se > s && se[-1] == '\r') se[-1] = '\0';
912 /*@innerbreak@*/ break;
915 if (!strncmp(s, "total ", sizeof("total ")-1))
916 /*@innercontinue@*/ continue;
919 for (bingo = 0, n = se; n >= s; n--) {
923 /*@switchbreak@*/ break;
925 if (o || !(n[-3] == ' ' && n[-2] == '-' && n[-1] == '>')) {
926 while (*(++n) == ' ')
929 /*@switchbreak@*/ break;
931 for (o = n + 1; *o == ' '; o++)
935 /*@switchbreak@*/ break;
937 /*@switchbreak@*/ break;
940 /*@innerbreak@*/ break;
943 if (nbn != (ne - n)) /* Same name length? */
944 /*@innercontinue@*/ continue;
945 if (strncmp(n, bn, nbn)) /* Same name? */
946 /*@innercontinue@*/ continue;
949 /*@innerbreak@*/ break;
952 if (moretodo && se > s) {
953 bufLength = se - s - 1;
955 memmove(ftpBuf, s, bufLength);
961 switch (ftpSysCall) {
964 /* XXX FIXME: symlink, replace urldn/bn from [o,oe) and restart */
968 if (st == NULL || !(n && ne)) {
971 rc = ((vfs_parse_ls_lga(s, st, NULL, NULL) > 0) ? 0 : -1);
974 case DO_FTP_READLINK:
975 if (rlbuf == NULL || !(o && oe)) {
981 memcpy(rlbuf, o, rc);
987 rc = 0; /* XXX WRONG WRONG WRONG */
990 rc = 0; /* XXX WRONG WRONG WRONG */
999 static int ftpStat(const char * path, /*@out@*/ struct stat *st)
1000 /*@globals fileSystem @*/
1001 /*@modifies *st, fileSystem @*/
1003 return ftpNLST(path, DO_FTP_STAT, st, NULL, 0);
1006 static int ftpLstat(const char * path, /*@out@*/ struct stat *st)
1007 /*@globals fileSystem @*/
1008 /*@modifies *st, fileSystem @*/
1011 rc = ftpNLST(path, DO_FTP_LSTAT, st, NULL, 0);
1013 fprintf(stderr, "*** ftpLstat(%s) rc %d\n", path, rc);
1017 static int ftpReadlink(const char * path, /*@out@*/ char * buf, size_t bufsiz)
1018 /*@globals fileSystem @*/
1019 /*@modifies *buf, fileSystem @*/
1021 return ftpNLST(path, DO_FTP_READLINK, NULL, buf, bufsiz);
1024 static int ftpGlob(const char * path, int flags,
1025 int errfunc(const char * epath, int eerno),
1026 /*@out@*/ glob_t * pglob)
1027 /*@globals fileSystem @*/
1028 /*@modifies *pglob, fileSystem @*/
1034 rc = ftpNLST(path, DO_FTP_GLOB, NULL, NULL, 0);
1037 fprintf(stderr, "*** ftpGlob(%s,0x%x,%p,%p) ftpNLST rc %d\n", path, (unsigned)flags, (void *)errfunc, pglob, rc);
1041 rc = poptParseArgvString(ftpBuf, &pglob->gl_pathc, (const char ***)&pglob->gl_pathv);
1042 pglob->gl_offs = -1; /* XXX HACK HACK HACK */
1046 static void ftpGlobfree(glob_t * pglob)
1047 /*@modifies *pglob @*/
1051 fprintf(stderr, "*** ftpGlobfree(%p)\n", pglob);
1053 if (pglob->gl_offs == -1) { /* XXX HACK HACK HACK */
1054 free((void *)pglob->gl_pathv);
1055 pglob->gl_pathv = NULL;
1059 int Stat(const char * path, struct stat * st)
1062 int ut = urlPath(path, &lpath);
1065 fprintf(stderr, "*** Stat(%s,%p)\n", path, st);
1068 return ftpStat(path, st);
1069 /*@notreached@*/ break;
1070 case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
1074 case URL_IS_UNKNOWN:
1079 /*@notreached@*/ break;
1081 return stat(path, st);
1084 int Lstat(const char * path, struct stat * st)
1087 int ut = urlPath(path, &lpath);
1090 fprintf(stderr, "*** Lstat(%s,%p)\n", path, st);
1093 return ftpLstat(path, st);
1094 /*@notreached@*/ break;
1095 case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
1099 case URL_IS_UNKNOWN:
1104 /*@notreached@*/ break;
1106 return lstat(path, st);
1109 int Readlink(const char * path, char * buf, size_t bufsiz)
1112 int ut = urlPath(path, &lpath);
1116 return ftpReadlink(path, buf, bufsiz);
1117 /*@notreached@*/ break;
1118 case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
1122 case URL_IS_UNKNOWN:
1127 /*@notreached@*/ break;
1129 return readlink(path, buf, bufsiz);
1132 int Access(const char * path, int amode)
1135 int ut = urlPath(path, &lpath);
1138 fprintf(stderr, "*** Access(%s,%d)\n", path, amode);
1140 case URL_IS_FTP: /* XXX WRONG WRONG WRONG */
1141 case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
1145 case URL_IS_UNKNOWN:
1150 /*@notreached@*/ break;
1152 return access(path, amode);
1155 int Glob(const char *pattern, int flags,
1156 int errfunc(const char * epath, int eerrno), glob_t *pglob)
1159 int ut = urlPath(pattern, &lpath);
1163 fprintf(stderr, "*** Glob(%s,0x%x,%p,%p)\n", pattern, (unsigned)flags, (void *)errfunc, pglob);
1166 case URL_IS_FTP: /* XXX WRONG WRONG WRONG */
1167 return ftpGlob(pattern, flags, errfunc, pglob);
1168 /*@notreached@*/ break;
1169 case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
1173 case URL_IS_UNKNOWN:
1178 /*@notreached@*/ break;
1180 return glob(pattern, flags, errfunc, pglob);
1183 void Globfree(glob_t *pglob)
1186 fprintf(stderr, "*** Globfree(%p)\n", pglob);
1188 if (pglob->gl_offs == -1) /* XXX HACK HACK HACK */
1195 DIR * Opendir(const char * path)
1198 int ut = urlPath(path, &lpath);
1201 fprintf(stderr, "*** Opendir(%s)\n", path);
1203 case URL_IS_FTP: /* XXX WRONG WRONG WRONG */
1204 case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
1208 case URL_IS_UNKNOWN:
1213 /*@notreached@*/ break;
1215 return opendir(path);
1219 struct dirent * Readdir(DIR * dir)
1222 fprintf(stderr, "*** Readdir(%p)\n", (void *)dir);
1223 return readdir(dir);
1226 int Closedir(DIR * dir)
1229 fprintf(stderr, "*** Closedir(%p)\n", (void *)dir);
1230 return closedir(dir);