diff options
author | gleb <gleb@FreeBSD.org> | 2012-05-19 12:44:27 +0000 |
---|---|---|
committer | gleb <gleb@FreeBSD.org> | 2012-05-19 12:44:27 +0000 |
commit | 53af2dbdcaab2b0af0595c7972b876b8ef9e9ae6 (patch) | |
tree | 52b234943a3ae78c62d839ca39a00589e970906a /usr.sbin | |
parent | 9409c11a935c0490bedd5a31b003a34bb8caea1f (diff) | |
download | FreeBSD-src-53af2dbdcaab2b0af0595c7972b876b8ef9e9ae6.zip FreeBSD-src-53af2dbdcaab2b0af0595c7972b876b8ef9e9ae6.tar.gz |
Hide DIR definition by making it an opaque struct typedef.
Introduce dirfd() libc exported symbol replacing macro with same name,
preserve _dirfd() macro for internal use.
Replace dirp->dd_fd with dirfd() call. Avoid using dirfd as variable
name to prevent shadowing global symbol.
Sponsored by: Google Summer Of Code 2011
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/cpucontrol/cpucontrol.c | 10 | ||||
-rw-r--r-- | usr.sbin/lpr/common_source/common.c | 2 | ||||
-rw-r--r-- | usr.sbin/newsyslog/newsyslog.c | 6 |
3 files changed, 9 insertions, 9 deletions
diff --git a/usr.sbin/cpucontrol/cpucontrol.c b/usr.sbin/cpucontrol/cpucontrol.c index 7477007..8738612 100644 --- a/usr.sbin/cpucontrol/cpucontrol.c +++ b/usr.sbin/cpucontrol/cpucontrol.c @@ -292,7 +292,7 @@ do_update(const char *dev) int error; struct ucode_handler *handler; struct datadir *dir; - DIR *dirfd; + DIR *dirp; struct dirent *direntry; char buf[MAXPATHLEN]; @@ -321,12 +321,12 @@ do_update(const char *dev) * Process every image in specified data directories. */ SLIST_FOREACH(dir, &datadirs, next) { - dirfd = opendir(dir->path); - if (dirfd == NULL) { + dirp = opendir(dir->path); + if (dirp == NULL) { WARNX(1, "skipping directory %s: not accessible", dir->path); continue; } - while ((direntry = readdir(dirfd)) != NULL) { + while ((direntry = readdir(dirp)) != NULL) { if (direntry->d_namlen == 0) continue; error = snprintf(buf, sizeof(buf), "%s/%s", dir->path, @@ -340,7 +340,7 @@ do_update(const char *dev) } handler->update(dev, buf); } - error = closedir(dirfd); + error = closedir(dirp); if (error != 0) WARN(0, "closedir(%s)", dir->path); } diff --git a/usr.sbin/lpr/common_source/common.c b/usr.sbin/lpr/common_source/common.c index d28ac1f..819d7dd 100644 --- a/usr.sbin/lpr/common_source/common.c +++ b/usr.sbin/lpr/common_source/common.c @@ -130,7 +130,7 @@ getq(const struct printer *pp, struct jobqueue *(*namelist[])) seteuid(uid); return (-1); } - if (fstat(dirp->dd_fd, &stbuf) < 0) + if (fstat(dirfd(dirp), &stbuf) < 0) goto errdone; seteuid(uid); diff --git a/usr.sbin/newsyslog/newsyslog.c b/usr.sbin/newsyslog/newsyslog.c index 7ebdddc..227ea00 100644 --- a/usr.sbin/newsyslog/newsyslog.c +++ b/usr.sbin/newsyslog/newsyslog.c @@ -1451,7 +1451,7 @@ static void delete_oldest_timelog(const struct conf_entry *ent, const char *archive_dir) { char *logfname, *s, *dir, errbuf[80]; - int dirfd, i, logcnt, max_logcnt, valid; + int dir_fd, i, logcnt, max_logcnt, valid; struct oldlog_entry *oldlogs; size_t logfname_len; struct dirent *dp; @@ -1486,7 +1486,7 @@ delete_oldest_timelog(const struct conf_entry *ent, const char *archive_dir) /* First we create a 'list' of all archived logfiles */ if ((dirp = opendir(dir)) == NULL) err(1, "Cannot open log directory '%s'", dir); - dirfd = dirfd(dirp); + dir_fd = dirfd(dirp); while ((dp = readdir(dirp)) != NULL) { if (dp->d_type != DT_REG) continue; @@ -1578,7 +1578,7 @@ delete_oldest_timelog(const struct conf_entry *ent, const char *archive_dir) if (noaction) printf("\trm -f %s/%s\n", dir, oldlogs[i].fname); - else if (unlinkat(dirfd, oldlogs[i].fname, 0) != 0) { + else if (unlinkat(dir_fd, oldlogs[i].fname, 0) != 0) { snprintf(errbuf, sizeof(errbuf), "Could not delet old logfile '%s'", oldlogs[i].fname); |