New stat structure.

* VFS and installed MFSes must be in sync before and after this change *

Use struct stat from NetBSD. It requires adding new STAT, FSTAT and LSTAT
syscalls. Libc modification is both backward and forward compatible.

Also new struct stat uses modern field sizes to avoid ABI
incompatibility, when we update uid_t, gid_t and company.
Exceptions are ino_t and off_t in old libc (though paddings added).
This commit is contained in:
Evgeniy Ivanov
2011-07-01 23:35:54 +04:00
committed by Ben Gras
parent 48331843ea
commit ef0a265086
34 changed files with 533 additions and 417 deletions

View File

@@ -151,10 +151,15 @@ fseeko(FILE *fp, off_t offset, int whence)
goto dumb;
}
#ifdef __minix
fp->_blksize = MINIX_ST_BLKSIZE;
#else
fp->_blksize = st.st_blksize;
if (st.st_blksize == 0) {
/* 0 in 2 cases: upgrade from old to new struct stat or
* there is a bug in underlying fs.
*/
fp->_blksize = MINIX_ST_BLKSIZE;
} else
#endif
fp->_blksize = st.st_blksize;
fp->_flags |= __SOPT;
}

View File

@@ -114,12 +114,6 @@ __swhatbuf(fp, bufsize, couldbetty)
/* could be a tty iff it is a character device */
*couldbetty = S_ISCHR(st.st_mode);
#ifndef __minix
if (st.st_blksize == 0) {
*bufsize = BUFSIZ;
return (__SNPT);
}
#endif
/*
* Optimise fseek() only if it is a regular file. (The test for
@@ -127,12 +121,15 @@ __swhatbuf(fp, bufsize, couldbetty)
* unconditionally; it will only be used if __SOPT is also set.
*/
#ifdef __minix
*bufsize = MINIX_ST_BLKSIZE;
fp->_blksize = MINIX_ST_BLKSIZE;
#else
*bufsize = st.st_blksize;
fp->_blksize = st.st_blksize;
if (st.st_blksize == 0) {
/* 0 in 2 cases: upgrade from old to new struct stat or
* there is a bug in underlying fs.
*/
*bufsize = fp->_blksize = MINIX_ST_BLKSIZE;
} else
#endif
*bufsize = fp->_blksize = st.st_blksize;
return ((st.st_mode & S_IFMT) == S_IFREG && fp->_seek == __sseek ?
__SOPT : __SNPT);
}