mikaku / Fiwix

A UNIX-like kernel for the i386 architecture
https://www.fiwix.org
Other
401 stars 32 forks source link

Support syscall utimes #57

Closed rick-masters closed 7 months ago

rick-masters commented 7 months ago

The utimes syscall is needed for musl support because musl defaults to using the utimes system call rather than utime. The musl library maps utime library call to the utimes system call.

The utimes syscall uses a timeval structures which support microseconds, which is different from utime which only supports seconds.

The forthcoming PR is mostly a copy of utime with small modifications. Since the current Fiwix file systems do not support microseconds that field is currently ignored.

A test program is attached. The following output shows the file time being updated with the test program.

[(root) ~]# cc -m32 testutimes.c -o testutimes
[(root) ~]# rm testfile
rm: remove regular empty file 'testfile'? y
[(root) ~]# touch testfile;date
Tue Dec 26 19:25:43 GMT 2023
[(root) ~]# sleep 5   
[(root) ~]# date;./testutimes;stat testfile
Tue Dec 26 19:26:27 GMT 2023
  File: testfile
  Size: 0               Blocks: 1          IO Block: 1024   regular empty file
Device: 302h/770d       Inode: 17978       Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2023-12-26 19:26:27.000000000 +0000
Modify: 2023-12-26 19:26:27.000000000 +0000
Change: 2023-12-26 19:26:27.000000000 +0000
 Birth: -
[(root) ~]# 

testutimes.c.gz

mikaku commented 7 months ago

Thank you very much.