summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2010-03-28 13:13:22 +0000
committered <ed@FreeBSD.org>2010-03-28 13:13:22 +0000
commit4f08ecd7ed8b39a0e0cd094967835fa85d105793 (patch)
tree303a032d575560ac8850d94e75f68865c40f1161 /sys
parent9eaa28fa3641501bd3b827e9b55aa8240713c80d (diff)
downloadFreeBSD-src-4f08ecd7ed8b39a0e0cd094967835fa85d105793.zip
FreeBSD-src-4f08ecd7ed8b39a0e0cd094967835fa85d105793.tar.gz
Rename st_*timespec fields to st_*tim for POSIX 2008 compliance.
A nice thing about POSIX 2008 is that it finally standardizes a way to obtain file access/modification/change times in sub-second precision, namely using struct timespec, which we already have for a very long time. Unfortunately POSIX uses different names. This commit adds compatibility macros, so existing code should still build properly. Also change all source code in the kernel to work without any of the compatibility macros. This makes it all a less ambiguous. I am also renaming st_birthtime to st_birthtim, even though it was a local extension anyway. It seems Cygwin also has a st_birthtim.
Diffstat (limited to 'sys')
-rw-r--r--sys/amd64/linux32/linux.h18
-rw-r--r--sys/compat/freebsd32/freebsd32.h8
-rw-r--r--sys/compat/freebsd32/freebsd32_misc.c6
-rw-r--r--sys/compat/linux/linux_stats.c27
-rw-r--r--sys/compat/svr4/svr4_stat.c18
-rw-r--r--sys/i386/ibcs2/ibcs2_stat.c6
-rw-r--r--sys/i386/linux/linux.h18
-rw-r--r--sys/kern/sys_pipe.c6
-rw-r--r--sys/kern/tty_pts.c6
-rw-r--r--sys/kern/uipc_mqueue.c8
-rw-r--r--sys/kern/uipc_sem.c8
-rw-r--r--sys/kern/uipc_shm.c8
-rw-r--r--sys/kern/vfs_syscalls.c14
-rw-r--r--sys/kern/vfs_vnops.c8
-rw-r--r--sys/sys/_timespec.h26
-rw-r--r--sys/sys/stat.h71
-rw-r--r--sys/sys/timespec.h15
17 files changed, 123 insertions, 148 deletions
diff --git a/sys/amd64/linux32/linux.h b/sys/amd64/linux32/linux.h
index 350e773..239412c 100644
--- a/sys/amd64/linux32/linux.h
+++ b/sys/amd64/linux32/linux.h
@@ -203,9 +203,9 @@ struct l_newstat {
l_ulong st_size;
l_ulong st_blksize;
l_ulong st_blocks;
- struct l_timespec st_atimespec;
- struct l_timespec st_mtimespec;
- struct l_timespec st_ctimespec;
+ struct l_timespec st_atim;
+ struct l_timespec st_mtim;
+ struct l_timespec st_ctim;
l_ulong __unused4;
l_ulong __unused5;
} __packed;
@@ -219,9 +219,9 @@ struct l_stat {
l_ushort st_gid;
l_ushort st_rdev;
l_long st_size;
- struct l_timespec st_atimespec;
- struct l_timespec st_mtimespec;
- struct l_timespec st_ctimespec;
+ struct l_timespec st_atim;
+ struct l_timespec st_mtim;
+ struct l_timespec st_ctim;
l_long st_blksize;
l_long st_blocks;
l_ulong st_flags;
@@ -242,9 +242,9 @@ struct l_stat64 {
l_ulong st_blksize;
l_ulong st_blocks;
l_ulong __pad4;
- struct l_timespec st_atimespec;
- struct l_timespec st_mtimespec;
- struct l_timespec st_ctimespec;
+ struct l_timespec st_atim;
+ struct l_timespec st_mtim;
+ struct l_timespec st_ctim;
l_ulonglong st_ino;
} __packed;
diff --git a/sys/compat/freebsd32/freebsd32.h b/sys/compat/freebsd32/freebsd32.h
index b68f8fb..e74da64 100644
--- a/sys/compat/freebsd32/freebsd32.h
+++ b/sys/compat/freebsd32/freebsd32.h
@@ -143,15 +143,15 @@ struct stat32 {
uid_t st_uid;
gid_t st_gid;
dev_t st_rdev;
- struct timespec32 st_atimespec;
- struct timespec32 st_mtimespec;
- struct timespec32 st_ctimespec;
+ struct timespec32 st_atim;
+ struct timespec32 st_mtim;
+ struct timespec32 st_ctim;
off_t st_size;
int64_t st_blocks;
u_int32_t st_blksize;
u_int32_t st_flags;
u_int32_t st_gen;
- struct timespec32 st_birthtimespec;
+ struct timespec32 st_birthtim;
unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec32));
unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec32));
};
diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c
index 1284e38..7cc27be 100644
--- a/sys/compat/freebsd32/freebsd32_misc.c
+++ b/sys/compat/freebsd32/freebsd32_misc.c
@@ -1634,9 +1634,9 @@ copy_stat( struct stat *in, struct stat32 *out)
CP(*in, *out, st_uid);
CP(*in, *out, st_gid);
CP(*in, *out, st_rdev);
- TS_CP(*in, *out, st_atimespec);
- TS_CP(*in, *out, st_mtimespec);
- TS_CP(*in, *out, st_ctimespec);
+ TS_CP(*in, *out, st_atim);
+ TS_CP(*in, *out, st_mtim);
+ TS_CP(*in, *out, st_ctim);
CP(*in, *out, st_size);
CP(*in, *out, st_blocks);
CP(*in, *out, st_blksize);
diff --git a/sys/compat/linux/linux_stats.c b/sys/compat/linux/linux_stats.c
index 8e8936c..907d201 100644
--- a/sys/compat/linux/linux_stats.c
+++ b/sys/compat/linux/linux_stats.c
@@ -173,9 +173,12 @@ newstat_copyout(struct stat *buf, void *ubuf)
tbuf.st_gid = buf->st_gid;
tbuf.st_rdev = buf->st_rdev;
tbuf.st_size = buf->st_size;
- tbuf.st_atime = buf->st_atime;
- tbuf.st_mtime = buf->st_mtime;
- tbuf.st_ctime = buf->st_ctime;
+ tbuf.st_atim.tv_sec = buf->st_atim.tv_sec;
+ tbuf.st_atim.tv_nsec = buf->st_atim.tv_nsec;
+ tbuf.st_mtim.tv_sec = buf->st_mtim.tv_sec;
+ tbuf.st_mtim.tv_nsec = buf->st_mtim.tv_nsec;
+ tbuf.st_ctim.tv_sec = buf->st_ctim.tv_sec;
+ tbuf.st_ctim.tv_nsec = buf->st_ctim.tv_nsec;
tbuf.st_blksize = buf->st_blksize;
tbuf.st_blocks = buf->st_blocks;
@@ -260,9 +263,12 @@ stat_copyout(struct stat *buf, void *ubuf)
lbuf.st_size = buf->st_size;
else
lbuf.st_size = -2;
- lbuf.st_atime = buf->st_atime;
- lbuf.st_mtime = buf->st_mtime;
- lbuf.st_ctime = buf->st_ctime;
+ lbuf.st_atim.tv_sec = buf->st_atim.tv_sec;
+ lbuf.st_atim.tv_nsec = buf->st_atim.tv_nsec;
+ lbuf.st_mtim.tv_sec = buf->st_mtim.tv_sec;
+ lbuf.st_mtim.tv_nsec = buf->st_mtim.tv_nsec;
+ lbuf.st_ctim.tv_sec = buf->st_ctim.tv_sec;
+ lbuf.st_ctim.tv_nsec = buf->st_ctim.tv_nsec;
lbuf.st_blksize = buf->st_blksize;
lbuf.st_blocks = buf->st_blocks;
lbuf.st_flags = buf->st_flags;
@@ -498,9 +504,12 @@ stat64_copyout(struct stat *buf, void *ubuf)
lbuf.st_gid = buf->st_gid;
lbuf.st_rdev = buf->st_rdev;
lbuf.st_size = buf->st_size;
- lbuf.st_atime = buf->st_atime;
- lbuf.st_mtime = buf->st_mtime;
- lbuf.st_ctime = buf->st_ctime;
+ lbuf.st_atim.tv_sec = buf->st_atim.tv_sec;
+ lbuf.st_atim.tv_nsec = buf->st_atim.tv_nsec;
+ lbuf.st_mtim.tv_sec = buf->st_mtim.tv_sec;
+ lbuf.st_mtim.tv_nsec = buf->st_mtim.tv_nsec;
+ lbuf.st_ctim.tv_sec = buf->st_ctim.tv_sec;
+ lbuf.st_ctim.tv_nsec = buf->st_ctim.tv_nsec;
lbuf.st_blksize = buf->st_blksize;
lbuf.st_blocks = buf->st_blocks;
diff --git a/sys/compat/svr4/svr4_stat.c b/sys/compat/svr4/svr4_stat.c
index cfb8276..cc84396 100644
--- a/sys/compat/svr4/svr4_stat.c
+++ b/sys/compat/svr4/svr4_stat.c
@@ -106,9 +106,9 @@ bsd_to_svr4_stat(st, st4)
st4->st_gid = st->st_gid;
st4->st_rdev = bsd_to_svr4_odev_t(st->st_rdev);
st4->st_size = st->st_size;
- st4->st_atim = st->st_atimespec.tv_sec;
- st4->st_mtim = st->st_mtimespec.tv_sec;
- st4->st_ctim = st->st_ctimespec.tv_sec;
+ st4->st_atim = st->st_atim.tv_sec;
+ st4->st_mtim = st->st_mtim.tv_sec;
+ st4->st_ctim = st->st_ctim.tv_sec;
}
#endif
@@ -127,9 +127,9 @@ bsd_to_svr4_xstat(st, st4)
st4->st_gid = st->st_gid;
st4->st_rdev = bsd_to_svr4_dev_t(st->st_rdev);
st4->st_size = st->st_size;
- st4->st_atim = st->st_atimespec;
- st4->st_mtim = st->st_mtimespec;
- st4->st_ctim = st->st_ctimespec;
+ st4->st_atim = st->st_atim;
+ st4->st_mtim = st->st_mtim;
+ st4->st_ctim = st->st_ctim;
st4->st_blksize = st->st_blksize;
st4->st_blocks = st->st_blocks;
strcpy(st4->st_fstype, "unknown");
@@ -150,9 +150,9 @@ bsd_to_svr4_stat64(st, st4)
st4->st_gid = st->st_gid;
st4->st_rdev = bsd_to_svr4_dev_t(st->st_rdev);
st4->st_size = st->st_size;
- st4->st_atim = st->st_atimespec;
- st4->st_mtim = st->st_mtimespec;
- st4->st_ctim = st->st_ctimespec;
+ st4->st_atim = st->st_atim;
+ st4->st_mtim = st->st_mtim;
+ st4->st_ctim = st->st_ctim;
st4->st_blksize = st->st_blksize;
st4->st_blocks = st->st_blocks;
strcpy(st4->st_fstype, "unknown");
diff --git a/sys/i386/ibcs2/ibcs2_stat.c b/sys/i386/ibcs2/ibcs2_stat.c
index 9253071..b61e45e 100644
--- a/sys/i386/ibcs2/ibcs2_stat.c
+++ b/sys/i386/ibcs2/ibcs2_stat.c
@@ -72,9 +72,9 @@ bsd_stat2ibcs_stat(st, st4)
st4->st_size = (ibcs2_off_t)st->st_size;
else
st4->st_size = -2;
- st4->st_atim = (ibcs2_time_t)st->st_atime;
- st4->st_mtim = (ibcs2_time_t)st->st_mtime;
- st4->st_ctim = (ibcs2_time_t)st->st_ctime;
+ st4->st_atim = (ibcs2_time_t)st->st_atim.tv_sec;
+ st4->st_mtim = (ibcs2_time_t)st->st_mtim.tv_sec;
+ st4->st_ctim = (ibcs2_time_t)st->st_ctim.tv_sec;
}
static int
diff --git a/sys/i386/linux/linux.h b/sys/i386/linux/linux.h
index d614716..fe84c06 100644
--- a/sys/i386/linux/linux.h
+++ b/sys/i386/linux/linux.h
@@ -178,9 +178,9 @@ struct l_newstat {
l_ulong st_size;
l_ulong st_blksize;
l_ulong st_blocks;
- struct l_timespec st_atimespec;
- struct l_timespec st_mtimespec;
- struct l_timespec st_ctimespec;
+ struct l_timespec st_atim;
+ struct l_timespec st_mtim;
+ struct l_timespec st_ctim;
l_ulong __unused4;
l_ulong __unused5;
};
@@ -194,9 +194,9 @@ struct l_stat {
l_ushort st_gid;
l_ushort st_rdev;
l_long st_size;
- struct l_timespec st_atimespec;
- struct l_timespec st_mtimespec;
- struct l_timespec st_ctimespec;
+ struct l_timespec st_atim;
+ struct l_timespec st_mtim;
+ struct l_timespec st_ctim;
l_long st_blksize;
l_long st_blocks;
l_ulong st_flags;
@@ -217,9 +217,9 @@ struct l_stat64 {
l_ulong st_blksize;
l_ulong st_blocks;
l_ulong __pad4;
- struct l_timespec st_atimespec;
- struct l_timespec st_mtimespec;
- struct l_timespec st_ctimespec;
+ struct l_timespec st_atim;
+ struct l_timespec st_mtim;
+ struct l_timespec st_ctim;
l_ulonglong st_ino;
};
diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c
index fcfb226..e098648 100644
--- a/sys/kern/sys_pipe.c
+++ b/sys/kern/sys_pipe.c
@@ -1428,9 +1428,9 @@ pipe_stat(fp, ub, active_cred, td)
else
ub->st_size = pipe->pipe_buffer.cnt;
ub->st_blocks = (ub->st_size + ub->st_blksize - 1) / ub->st_blksize;
- ub->st_atimespec = pipe->pipe_atime;
- ub->st_mtimespec = pipe->pipe_mtime;
- ub->st_ctimespec = pipe->pipe_ctime;
+ ub->st_atim = pipe->pipe_atime;
+ ub->st_mtim = pipe->pipe_mtime;
+ ub->st_ctim = pipe->pipe_ctime;
ub->st_uid = fp->f_cred->cr_uid;
ub->st_gid = fp->f_cred->cr_gid;
/*
diff --git a/sys/kern/tty_pts.c b/sys/kern/tty_pts.c
index 290fdc2..5cfbc71 100644
--- a/sys/kern/tty_pts.c
+++ b/sys/kern/tty_pts.c
@@ -556,9 +556,9 @@ ptsdev_stat(struct file *fp, struct stat *sb, struct ucred *active_cred,
#endif /* PTS_EXTERNAL */
sb->st_ino = sb->st_rdev = tty_udev(tp);
- sb->st_atimespec = dev->si_atime;
- sb->st_ctimespec = dev->si_ctime;
- sb->st_mtimespec = dev->si_mtime;
+ sb->st_atim = dev->si_atime;
+ sb->st_ctim = dev->si_ctime;
+ sb->st_mtim = dev->si_mtime;
sb->st_uid = dev->si_uid;
sb->st_gid = dev->si_gid;
sb->st_mode = dev->si_mode | S_IFCHR;
diff --git a/sys/kern/uipc_mqueue.c b/sys/kern/uipc_mqueue.c
index a34c228..1319666 100644
--- a/sys/kern/uipc_mqueue.c
+++ b/sys/kern/uipc_mqueue.c
@@ -2447,10 +2447,10 @@ mqf_stat(struct file *fp, struct stat *st, struct ucred *active_cred,
struct mqfs_node *pn = fp->f_data;
bzero(st, sizeof *st);
- st->st_atimespec = pn->mn_atime;
- st->st_mtimespec = pn->mn_mtime;
- st->st_ctimespec = pn->mn_ctime;
- st->st_birthtimespec = pn->mn_birth;
+ st->st_atim = pn->mn_atime;
+ st->st_mtim = pn->mn_mtime;
+ st->st_ctim = pn->mn_ctime;
+ st->st_birthtim = pn->mn_birth;
st->st_uid = pn->mn_uid;
st->st_gid = pn->mn_gid;
st->st_mode = S_IFIFO | pn->mn_mode;
diff --git a/sys/kern/uipc_sem.c b/sys/kern/uipc_sem.c
index a6b2f75..d9229ea 100644
--- a/sys/kern/uipc_sem.c
+++ b/sys/kern/uipc_sem.c
@@ -219,10 +219,10 @@ ksem_stat(struct file *fp, struct stat *sb, struct ucred *active_cred,
bzero(sb, sizeof(*sb));
sb->st_mode = S_IFREG | ks->ks_mode; /* XXX */
- sb->st_atimespec = ks->ks_atime;
- sb->st_ctimespec = ks->ks_ctime;
- sb->st_mtimespec = ks->ks_mtime;
- sb->st_birthtimespec = ks->ks_birthtime;
+ sb->st_atim = ks->ks_atime;
+ sb->st_ctim = ks->ks_ctime;
+ sb->st_mtim = ks->ks_mtime;
+ sb->st_birthtim = ks->ks_birthtime;
sb->st_uid = ks->ks_uid;
sb->st_gid = ks->ks_gid;
diff --git a/sys/kern/uipc_shm.c b/sys/kern/uipc_shm.c
index 32bfd2d..fe1a224 100644
--- a/sys/kern/uipc_shm.c
+++ b/sys/kern/uipc_shm.c
@@ -219,10 +219,10 @@ shm_stat(struct file *fp, struct stat *sb, struct ucred *active_cred,
sb->st_blksize = PAGE_SIZE;
sb->st_size = shmfd->shm_size;
sb->st_blocks = (sb->st_size + sb->st_blksize - 1) / sb->st_blksize;
- sb->st_atimespec = shmfd->shm_atime;
- sb->st_ctimespec = shmfd->shm_ctime;
- sb->st_mtimespec = shmfd->shm_mtime;
- sb->st_birthtimespec = shmfd->shm_birthtime;
+ sb->st_atim = shmfd->shm_atime;
+ sb->st_ctim = shmfd->shm_ctime;
+ sb->st_mtim = shmfd->shm_mtime;
+ sb->st_birthtim = shmfd->shm_birthtime;
sb->st_uid = shmfd->shm_uid;
sb->st_gid = shmfd->shm_gid;
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index bcc3cbb..c329adc 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -2269,9 +2269,9 @@ cvtstat(st, ost)
ost->st_size = st->st_size;
else
ost->st_size = -2;
- ost->st_atime = st->st_atime;
- ost->st_mtime = st->st_mtime;
- ost->st_ctime = st->st_ctime;
+ ost->st_atim = st->st_atim;
+ ost->st_mtim = st->st_mtim;
+ ost->st_ctim = st->st_ctim;
ost->st_blksize = st->st_blksize;
ost->st_blocks = st->st_blocks;
ost->st_flags = st->st_flags;
@@ -2431,15 +2431,15 @@ cvtnstat(sb, nsb)
nsb->st_uid = sb->st_uid;
nsb->st_gid = sb->st_gid;
nsb->st_rdev = sb->st_rdev;
- nsb->st_atimespec = sb->st_atimespec;
- nsb->st_mtimespec = sb->st_mtimespec;
- nsb->st_ctimespec = sb->st_ctimespec;
+ nsb->st_atim = sb->st_atim;
+ nsb->st_mtim = sb->st_mtim;
+ nsb->st_ctim = sb->st_ctim;
nsb->st_size = sb->st_size;
nsb->st_blocks = sb->st_blocks;
nsb->st_blksize = sb->st_blksize;
nsb->st_flags = sb->st_flags;
nsb->st_gen = sb->st_gen;
- nsb->st_birthtimespec = sb->st_birthtimespec;
+ nsb->st_birthtim = sb->st_birthtim;
}
#ifndef _SYS_SYSPROTO_H_
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index a16fa67..74e6c02 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -782,10 +782,10 @@ vn_stat(vp, sb, active_cred, file_cred, td)
if (vap->va_size > OFF_MAX)
return (EOVERFLOW);
sb->st_size = vap->va_size;
- sb->st_atimespec = vap->va_atime;
- sb->st_mtimespec = vap->va_mtime;
- sb->st_ctimespec = vap->va_ctime;
- sb->st_birthtimespec = vap->va_birthtime;
+ sb->st_atim = vap->va_atime;
+ sb->st_mtim = vap->va_mtime;
+ sb->st_ctim = vap->va_ctime;
+ sb->st_birthtim = vap->va_birthtime;
/*
* According to www.opengroup.org, the meaning of st_blksize is
diff --git a/sys/sys/_timespec.h b/sys/sys/_timespec.h
index 9dcd5f8..d51559c 100644
--- a/sys/sys/_timespec.h
+++ b/sys/sys/_timespec.h
@@ -31,26 +31,18 @@
* $FreeBSD$
*/
-/*
- * Prerequisite: <sys/_types.h>
- *
- * This file must be kept synchronized with <sys/timespec.h>.
- * It defines a structure which must be a type pun for
- * `struct timespec'; this structure is used in header files where
- * the ABI uses a `struct timespec' but standards prohibit its
- * definition. (Currently only <sys/stat.h>.)
- *
- * XXX should just declare struct __timespec as necessary. It's simple,
- * so is easy to keep synchronized, and hopefully not needed in as many
- * places as struct timespec, so we don't need this extra header.
- * Perhaps we don't need timespec.h either.
- */
-
#ifndef _SYS__TIMESPEC_H_
#define _SYS__TIMESPEC_H_
-struct __timespec {
- __time_t tv_sec; /* seconds */
+#include <sys/_types.h>
+
+#ifndef _TIME_T_DECLARED
+typedef __time_t time_t;
+#define _TIME_T_DECLARED
+#endif
+
+struct timespec {
+ time_t tv_sec; /* seconds */
long tv_nsec; /* and nanoseconds */
};
diff --git a/sys/sys/stat.h b/sys/sys/stat.h
index 856d674..1b03bd2 100644
--- a/sys/sys/stat.h
+++ b/sys/sys/stat.h
@@ -39,6 +39,7 @@
#define _SYS_STAT_H_
#include <sys/cdefs.h>
+#include <sys/_timespec.h>
#include <sys/_types.h>
#ifndef _BLKSIZE_T_DECLARED
@@ -86,11 +87,6 @@ typedef __off_t off_t;
#define _OFF_T_DECLARED
#endif
-#ifndef _TIME_T_DECLARED
-typedef __time_t time_t;
-#define _TIME_T_DECLARED
-#endif
-
#ifndef _UID_T_DECLARED
typedef __uid_t uid_t;
#define _UID_T_DECLARED
@@ -98,16 +94,11 @@ typedef __uid_t uid_t;
#if !defined(_KERNEL) && __BSD_VISIBLE
/*
- * XXX we need this for struct timespec. We get miscellaneous namespace
- * pollution with it.
+ * XXX We get miscellaneous namespace pollution with this.
*/
#include <sys/time.h>
#endif
-#if !__BSD_VISIBLE
-#include <sys/_timespec.h>
-#endif
-
#if __BSD_VISIBLE
struct ostat {
__uint16_t st_dev; /* inode's device */
@@ -118,9 +109,9 @@ struct ostat {
__uint16_t st_gid; /* group ID of the file's group */
__uint16_t st_rdev; /* device type */
__int32_t st_size; /* file size, in bytes */
- struct timespec st_atimespec; /* time of last access */
- struct timespec st_mtimespec; /* time of last data modification */
- struct timespec st_ctimespec; /* time of last file status change */
+ struct timespec st_atim; /* time of last access */
+ struct timespec st_mtim; /* time of last data modification */
+ struct timespec st_ctim; /* time of last file status change */
__int32_t st_blksize; /* optimal blocksize for I/O */
__int32_t st_blocks; /* blocks allocated for file */
fflags_t st_flags; /* user defined flags for file */
@@ -136,28 +127,18 @@ struct stat {
uid_t st_uid; /* user ID of the file's owner */
gid_t st_gid; /* group ID of the file's group */
__dev_t st_rdev; /* device type */
-#if __BSD_VISIBLE
- struct timespec st_atimespec; /* time of last access */
- struct timespec st_mtimespec; /* time of last data modification */
- struct timespec st_ctimespec; /* time of last file status change */
-#else
- time_t st_atime; /* time of last access */
- long __st_atimensec; /* nsec of last access */
- time_t st_mtime; /* time of last data modification */
- long __st_mtimensec; /* nsec of last data modification */
- time_t st_ctime; /* time of last file status change */
- long __st_ctimensec; /* nsec of last file status change */
-#endif
+ struct timespec st_atim; /* time of last access */
+ struct timespec st_mtim; /* time of last data modification */
+ struct timespec st_ctim; /* time of last file status change */
off_t st_size; /* file size, in bytes */
blkcnt_t st_blocks; /* blocks allocated for file */
blksize_t st_blksize; /* optimal blocksize for I/O */
fflags_t st_flags; /* user defined flags for file */
__uint32_t st_gen; /* file generation number */
__int32_t st_lspare;
-#if __BSD_VISIBLE
- struct timespec st_birthtimespec; /* time of file creation */
+ struct timespec st_birthtim; /* time of file creation */
/*
- * Explicitly pad st_birthtimespec to 16 bytes so that the size of
+ * Explicitly pad st_birthtim to 16 bytes so that the size of
* struct stat is backwards compatible. We use bitfields instead
* of an array of chars so that this doesn't require a C99 compiler
* to compile if the size of the padding is 0. We use 2 bitfields
@@ -166,12 +147,6 @@ struct stat {
*/
unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
-#else
- time_t st_birthtime; /* time of file creation */
- long st_birthtimensec; /* nsec of file creation */
- unsigned int :(8 / 2) * (16 - (int)sizeof(struct __timespec));
- unsigned int :(8 / 2) * (16 - (int)sizeof(struct __timespec));
-#endif
};
#if __BSD_VISIBLE
@@ -183,15 +158,15 @@ struct nstat {
uid_t st_uid; /* user ID of the file's owner */
gid_t st_gid; /* group ID of the file's group */
__dev_t st_rdev; /* device type */
- struct timespec st_atimespec; /* time of last access */
- struct timespec st_mtimespec; /* time of last data modification */
- struct timespec st_ctimespec; /* time of last file status change */
+ struct timespec st_atim; /* time of last access */
+ struct timespec st_mtim; /* time of last data modification */
+ struct timespec st_ctim; /* time of last file status change */
off_t st_size; /* file size, in bytes */
blkcnt_t st_blocks; /* blocks allocated for file */
blksize_t st_blksize; /* optimal blocksize for I/O */
fflags_t st_flags; /* user defined flags for file */
__uint32_t st_gen; /* file generation number */
- struct timespec st_birthtimespec; /* time of file creation */
+ struct timespec st_birthtim; /* time of file creation */
/*
* See above about the following padding.
*/
@@ -200,13 +175,23 @@ struct nstat {
};
#endif
+#ifndef _KERNEL
+#define st_atime st_atim.tv_sec
+#define st_mtime st_mtim.tv_sec
+#define st_ctime st_ctim.tv_sec
#if __BSD_VISIBLE
-#define st_atime st_atimespec.tv_sec
-#define st_mtime st_mtimespec.tv_sec
-#define st_ctime st_ctimespec.tv_sec
-#define st_birthtime st_birthtimespec.tv_sec
+#define st_birthtime st_birthtim.tv_sec
#endif
+/* For compatibility. */
+#if __BSD_VISIBLE
+#define st_atimespec st_atim
+#define st_mtimespec st_mtim
+#define st_ctimespec st_ctim
+#define st_birthtimespec st_birthtim
+#endif
+#endif /* !_KERNEL */
+
#define S_ISUID 0004000 /* set user id on execution */
#define S_ISGID 0002000 /* set group id on execution */
#if __BSD_VISIBLE
diff --git a/sys/sys/timespec.h b/sys/sys/timespec.h
index 8986c09..2505cef 100644
--- a/sys/sys/timespec.h
+++ b/sys/sys/timespec.h
@@ -31,22 +31,11 @@
* $FreeBSD$
*/
-/*
- * Prerequisites: <sys/cdefs.h>, <sys/_types.h>
- */
-
#ifndef _SYS_TIMESPEC_H_
#define _SYS_TIMESPEC_H_
-#ifndef _TIME_T_DECLARED
-typedef __time_t time_t;
-#define _TIME_T_DECLARED
-#endif
-
-struct timespec {
- time_t tv_sec; /* seconds */
- long tv_nsec; /* and nanoseconds */
-};
+#include <sys/cdefs.h>
+#include <sys/_timespec.h>
#if __BSD_VISIBLE
#define TIMEVAL_TO_TIMESPEC(tv, ts) \
OpenPOWER on IntegriCloud