lkml.org 
[lkml]   [1996]   [Jul]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: I need help
> 	if (fstat(dirp->dd_fd, &stb) < 0)

[snip]

Although it works, it is not very good to use DIRENT_ILLEGAL_ACCESS.

Patch glob.c in ~/src with the following patch. It moves some stuff around
and uses the "legal" typedef of DIR.

--------------------------------- snip ---------------------------------
--- glob.c.was Thu Jul 18 11:46:43 1996
+++ glob.c Tue Jul 23 12:07:36 1996
@@ -231,18 +231,24 @@

DIR *dirp;

- dirp = opendir(*gpath == '\0' ? "." : gpath);
- if (dirp == NULL) {
- if (globbed)
- return;
- goto patherr2;
+ if (*gpath == '\0') {
+ *gpath = '.';
+ *(gpath + 1) = '\0';
}
- if (fstat(dirp->dd_fd, &stb) < 0)
+
+ if (stat(gpath, &stb) < 0)
goto patherr1;
if (!isdir(stb)) {
errno = ENOTDIR;
goto patherr1;
}
+ dirp = opendir(gpath);
+ if (dirp == NULL) {
+ if (globbed)
+ return;
+ globerr = "Bad directory components";
+ return
+ }
while ((dp = readdir(dirp)) != NULL) {
if (dp->d_ino == 0)
continue;
@@ -251,13 +257,8 @@
globcnt++;
}
}
- closedir(dirp);
- return;
-
patherr1:
closedir(dirp);
-patherr2:
- globerr = "Bad directory components";
}

static int
----------------------------------- snip -----------------------------

Peter Kooiman | Fax : ++27-12-663-4191/2
Paradigm Systems Technology |
Pretoria, South Africa | UUCP : pko@silmaril.UUCP
Voice : ++27-12-672-5700/10 | DNS : pko@paradigm-sa.com



\
 
 \ /
  Last update: 2005-03-22 13:38    [W:0.030 / U:0.608 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site