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:
@@ -62,6 +62,8 @@ PUBLIC int do_stat()
|
||||
if ((r = verify_inode(ino, path, &attr)) != OK)
|
||||
return r;
|
||||
|
||||
memset(&stat, 0, sizeof(struct stat));
|
||||
|
||||
stat.st_dev = state.dev;
|
||||
stat.st_ino = ino_nr;
|
||||
stat.st_mode = get_mode(ino, attr.a_mode);
|
||||
@@ -76,6 +78,12 @@ PUBLIC int do_stat()
|
||||
stat.st_mtime = attr.a_mtime;
|
||||
stat.st_ctime = attr.a_ctime;
|
||||
|
||||
stat.st_blocks = stat.st_size / S_BLKSIZE;
|
||||
if (stat.st_size % S_BLKSIZE != 0)
|
||||
stat.st_blocks += 1;
|
||||
|
||||
stat.st_blksize = BLOCK_SIZE;
|
||||
|
||||
/* We could make this more accurate by iterating over directory inodes'
|
||||
* children, counting how many of those are directories as well.
|
||||
* It's just not worth it.
|
||||
|
||||
Reference in New Issue
Block a user