summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2021-06-29 14:52:29 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2021-06-29 14:52:29 (GMT)
commitf0048561b7c9f59ae0be8140bbbdc277ed1fb95e (patch)
tree08945f2604742f7be84f9a2c8ef9ce4fa707db43
parent75738205252e3a1805dea171f451ee60691a8b65 (diff)
downloadtcl-f0048561b7c9f59ae0be8140bbbdc277ed1fb95e.zip
tcl-f0048561b7c9f59ae0be8140bbbdc277ed1fb95e.tar.gz
tcl-f0048561b7c9f59ae0be8140bbbdc277ed1fb95e.tar.bz2
Use fstat64() in stead of fstat() on platforms which support it.
-rw-r--r--unix/tclEpollNotfy.c4
-rw-r--r--unix/tclKqueueNotfy.c4
-rw-r--r--unix/tclUnixFCmd.c6
-rw-r--r--unix/tclUnixFile.c23
-rw-r--r--unix/tclUnixPort.h3
5 files changed, 33 insertions, 7 deletions
diff --git a/unix/tclEpollNotfy.c b/unix/tclEpollNotfy.c
index 287dfe2..4be1439 100644
--- a/unix/tclEpollNotfy.c
+++ b/unix/tclEpollNotfy.c
@@ -196,7 +196,7 @@ PlatformEventsControl(
{
struct epoll_event newEvent;
struct PlatformEventData *newPedPtr;
- struct stat fdStat;
+ Tcl_StatBuf fdStat;
newEvent.events = 0;
if (filePtr->mask & (TCL_READABLE | TCL_EXCEPTION)) {
@@ -221,7 +221,7 @@ PlatformEventsControl(
* files belonging to tsdPtr.
*/
- if (fstat(filePtr->fd, &fdStat) == -1) {
+ if (TclOSfstat(filePtr->fd, &fdStat) == -1) {
Tcl_Panic("fstat: %s", strerror(errno));
}
diff --git a/unix/tclKqueueNotfy.c b/unix/tclKqueueNotfy.c
index 6606c8c..c0b9f6f 100644
--- a/unix/tclKqueueNotfy.c
+++ b/unix/tclKqueueNotfy.c
@@ -162,7 +162,7 @@ PlatformEventsControl(
int numChanges;
struct kevent changeList[2];
struct PlatformEventData *newPedPtr;
- struct stat fdStat;
+ Tcl_StatBuf fdStat;
if (isNew) {
newPedPtr = (struct PlatformEventData *)
@@ -180,7 +180,7 @@ PlatformEventsControl(
* with regular files belonging to tsdPtr.
*/
- if (fstat(filePtr->fd, &fdStat) == -1) {
+ if (TclOSfstat(filePtr->fd, &fdStat) == -1) {
Tcl_Panic("fstat: %s", strerror(errno));
} else if ((fdStat.st_mode & S_IFMT) == S_IFREG
|| (fdStat.st_mode & S_IFMT) == S_IFDIR
diff --git a/unix/tclUnixFCmd.c b/unix/tclUnixFCmd.c
index 9e9a493..9f7a2ba 100644
--- a/unix/tclUnixFCmd.c
+++ b/unix/tclUnixFCmd.c
@@ -2239,17 +2239,17 @@ static const char *
DefaultTempDir(void)
{
const char *dir;
- struct stat buf;
+ Tcl_StatBuf buf;
dir = getenv("TMPDIR");
- if (dir && dir[0] && stat(dir, &buf) == 0 && S_ISDIR(buf.st_mode)
+ if (dir && dir[0] && TclOSstat(dir, &buf) == 0 && S_ISDIR(buf.st_mode)
&& access(dir, W_OK) == 0) {
return dir;
}
#ifdef P_tmpdir
dir = P_tmpdir;
- if (stat(dir, &buf)==0 && S_ISDIR(buf.st_mode) && access(dir, W_OK)==0) {
+ if (TclOSstat(dir, &buf)==0 && S_ISDIR(buf.st_mode) && access(dir, W_OK)==0) {
return dir;
}
#endif
diff --git a/unix/tclUnixFile.c b/unix/tclUnixFile.c
index 1ab5d14..6cbdec9 100644
--- a/unix/tclUnixFile.c
+++ b/unix/tclUnixFile.c
@@ -1198,6 +1198,29 @@ TclpUtime(
#ifdef __CYGWIN__
int
+TclOSfstat(
+ int fd,
+ void *cygstat)
+{
+ struct stat buf;
+ Tcl_StatBuf *statBuf = (Tcl_StatBuf *)cygstat;
+ int result = fstat(fd, &buf);
+
+ statBuf->st_mode = buf.st_mode;
+ statBuf->st_ino = buf.st_ino;
+ statBuf->st_dev = buf.st_dev;
+ statBuf->st_rdev = buf.st_rdev;
+ statBuf->st_nlink = buf.st_nlink;
+ statBuf->st_uid = buf.st_uid;
+ statBuf->st_gid = buf.st_gid;
+ statBuf->st_size = buf.st_size;
+ statBuf->st_atime = buf.st_atime;
+ statBuf->st_mtime = buf.st_mtime;
+ statBuf->st_ctime = buf.st_ctime;
+ return result;
+}
+
+int
TclOSstat(
const char *name,
void *cygstat)
diff --git a/unix/tclUnixPort.h b/unix/tclUnixPort.h
index ece0202..791c2a3 100644
--- a/unix/tclUnixPort.h
+++ b/unix/tclUnixPort.h
@@ -120,15 +120,18 @@ extern "C" {
#pragma clang diagnostic pop
#endif
# define timezone _timezone
+ extern int TclOSfstat(int fd, void *statBuf);
extern int TclOSstat(const char *name, void *statBuf);
extern int TclOSlstat(const char *name, void *statBuf);
#ifdef __cplusplus
}
#endif
#elif defined(HAVE_STRUCT_STAT64) && !defined(__APPLE__)
+# define TclOSfstat(fd, buf) fstat64(fd, (struct stat64 *)buf)
# define TclOSstat(name, buf) stat64(name, (struct stat64 *)buf)
# define TclOSlstat(name,buf) lstat64(name, (struct stat64 *)buf)
#else
+# define TclOSfstat(fd, buf) fstat(fd, (struct stat *)buf)
# define TclOSstat(name, buf) stat(name, (struct stat *)buf)
# define TclOSlstat(name, buf) lstat(name, (struct stat *)buf)
#endif