mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 19:12:43 +00:00 
			
		
		
		
	 9a6bd85924
			
		
	
	
		9a6bd85924
		
	
	
	
	
		
			
			Create POSIX utimensat() library call and corresponding system call to update file access and modification times.
		
			
				
	
	
		
			78 lines
		
	
	
	
		
			2.1 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			78 lines
		
	
	
	
		
			2.1 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <Kernel/API/POSIX/sys/types.h>
 | |
| #include <Kernel/API/POSIX/time.h>
 | |
| 
 | |
| #ifdef __cplusplus
 | |
| extern "C" {
 | |
| #endif
 | |
| 
 | |
| #define S_IFMT 0170000
 | |
| #define S_IFDIR 0040000
 | |
| #define S_IFCHR 0020000
 | |
| #define S_IFBLK 0060000
 | |
| #define S_IFREG 0100000
 | |
| #define S_IFIFO 0010000
 | |
| #define S_IFLNK 0120000
 | |
| #define S_IFSOCK 0140000
 | |
| 
 | |
| #define S_ISUID 04000
 | |
| #define S_ISGID 02000
 | |
| #define S_ISVTX 01000
 | |
| #define S_IRUSR 0400
 | |
| #define S_IWUSR 0200
 | |
| #define S_IXUSR 0100
 | |
| #define S_IREAD S_IRUSR
 | |
| #define S_IWRITE S_IWUSR
 | |
| #define S_IEXEC S_IXUSR
 | |
| #define S_IRGRP 0040
 | |
| #define S_IWGRP 0020
 | |
| #define S_IXGRP 0010
 | |
| #define S_IROTH 0004
 | |
| #define S_IWOTH 0002
 | |
| #define S_IXOTH 0001
 | |
| 
 | |
| #define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
 | |
| 
 | |
| #define S_IRWXG (S_IRWXU >> 3)
 | |
| #define S_IRWXO (S_IRWXG >> 3)
 | |
| #define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
 | |
| #define S_ISCHR(m) (((m)&S_IFMT) == S_IFCHR)
 | |
| #define S_ISBLK(m) (((m)&S_IFMT) == S_IFBLK)
 | |
| #define S_ISREG(m) (((m)&S_IFMT) == S_IFREG)
 | |
| #define S_ISFIFO(m) (((m)&S_IFMT) == S_IFIFO)
 | |
| #define S_ISLNK(m) (((m)&S_IFMT) == S_IFLNK)
 | |
| #define S_ISSOCK(m) (((m)&S_IFMT) == S_IFSOCK)
 | |
| 
 | |
| struct stat {
 | |
|     dev_t st_dev;            /* ID of device containing file */
 | |
|     ino_t st_ino;            /* inode number */
 | |
|     mode_t st_mode;          /* protection */
 | |
|     nlink_t st_nlink;        /* number of hard links */
 | |
|     uid_t st_uid;            /* user ID of owner */
 | |
|     gid_t st_gid;            /* group ID of owner */
 | |
|     dev_t st_rdev;           /* device ID (if special file) */
 | |
|     off_t st_size;           /* total size, in bytes */
 | |
|     blksize_t st_blksize;    /* block size for file system I/O */
 | |
|     blkcnt_t st_blocks;      /* number of 512-byte blocks allocated */
 | |
|     struct timespec st_atim; /* time of last access */
 | |
|     struct timespec st_mtim; /* time of last modification */
 | |
|     struct timespec st_ctim; /* time of last status change */
 | |
| };
 | |
| 
 | |
| #define st_atime st_atim.tv_sec
 | |
| #define st_mtime st_mtim.tv_sec
 | |
| #define st_ctime st_ctim.tv_sec
 | |
| 
 | |
| #define UTIME_OMIT -1
 | |
| #define UTIME_NOW -2
 | |
| 
 | |
| #ifdef __cplusplus
 | |
| }
 | |
| #endif
 |