 ef0a265086
			
		
	
	
		ef0a265086
		
	
	
	
	
		
			
			* 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).
		
			
				
	
	
		
			38 lines
		
	
	
		
			780 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			38 lines
		
	
	
		
			780 B
		
	
	
	
		
			C
		
	
	
	
	
	
| #include <lib.h>
 | |
| #define lstat	_lstat
 | |
| #include <sys/stat.h>
 | |
| #include <string.h>
 | |
| 
 | |
| PUBLIC int lstat(name, buffer)
 | |
| _CONST char *name;
 | |
| struct stat *buffer;
 | |
| {
 | |
|   message m;
 | |
|   int r;
 | |
|   struct minix_prev_stat old_sb;
 | |
| 
 | |
|   m.m1_i1 = strlen(name) + 1;
 | |
|   m.m1_p1 = (char *) name;
 | |
|   m.m1_p2 = (char *) buffer;
 | |
| 
 | |
|   if((r = _syscall(VFS_PROC_NR, LSTAT, &m)) >= 0 || errno != ENOSYS)
 | |
| 	return r;
 | |
| 
 | |
|   errno = 0;
 | |
| 
 | |
|   /* ENOSYS: new binary and old VFS, fallback to PREV_STAT.
 | |
|    * User has struct stat (buffer), VFS still fills minix_prev_stat.
 | |
|    */
 | |
|   m.m1_i1 = strlen(name) + 1;
 | |
|   m.m1_p1 = (char *) name;
 | |
|   m.m1_p2 = (char *) &old_sb;
 | |
| 
 | |
|   if((r = _syscall(VFS_PROC_NR, PREV_LSTAT, &m)) < 0)
 | |
| 	return r;
 | |
| 
 | |
|   memset(buffer, 0, sizeof(struct stat));
 | |
|   COPY_PREV_STAT_TO_NEW(buffer, &old_sb);
 | |
| 
 | |
|   return r;
 | |
| }
 |