1*9984Ssam /* vfs_xxx.c 4.3 82/12/28 */ 28720Sroot 38720Sroot #include "../h/param.h" 48720Sroot #include "../h/systm.h" 58720Sroot #include "../h/inode.h" 68720Sroot #include "../h/fs.h" 78720Sroot #include "../h/mount.h" 88720Sroot #include "../h/dir.h" 98720Sroot #include "../h/user.h" 108720Sroot #include "../h/buf.h" 118720Sroot #include "../h/conf.h" 128720Sroot 138720Sroot /* 148720Sroot * Return the next character fromt the 158720Sroot * kernel string pointed at by dirp. 168720Sroot */ 178720Sroot schar() 188720Sroot { 198720Sroot return (*u.u_dirp++ & 0377); 208720Sroot } 218720Sroot 228720Sroot /* 238720Sroot * Return the next character from the 248720Sroot * user string pointed at by dirp. 258720Sroot */ 268720Sroot uchar() 278720Sroot { 288720Sroot register c; 298720Sroot 308720Sroot c = fubyte(u.u_dirp++); 318720Sroot if (c == -1) { 328720Sroot u.u_error = EFAULT; 338720Sroot c = 0; 348720Sroot } 358720Sroot return (c); 368720Sroot } 379880Ssam 389880Ssam #ifndef NOCOMPAT 399880Ssam #include "../h/file.h" 409880Ssam #include "../h/nami.h" 419880Ssam #include "../h/descrip.h" 429880Ssam #include "../h/kernel.h" 439880Ssam 449880Ssam /* 459880Ssam * Oh, how backwards compatibility is ugly!!! 469880Ssam */ 479880Ssam struct ostat { 489880Ssam dev_t ost_dev; 49*9984Ssam u_short ost_ino; 509880Ssam u_short ost_mode; 519880Ssam short ost_nlink; 529880Ssam short ost_uid; 539880Ssam short ost_gid; 549880Ssam dev_t ost_rdev; 559880Ssam int ost_size; 569880Ssam int ost_atime; 579880Ssam int ost_mtime; 589880Ssam int ost_ctime; 599880Ssam }; 609880Ssam 619880Ssam /* 629880Ssam * The old fstat system call. 639880Ssam */ 649880Ssam ofstat() 659880Ssam { 669880Ssam register struct file *fp; 679880Ssam register struct a { 689880Ssam int fd; 699880Ssam struct ostat *sb; 709880Ssam } *uap; 719880Ssam 729880Ssam uap = (struct a *)u.u_ap; 739880Ssam fp = getf(uap->fd); 749880Ssam if (fp == NULL) 759880Ssam return; 769880Ssam if (fp->f_type == DTYPE_SOCKET) { 779880Ssam struct ostat ub; 789880Ssam 799880Ssam bzero((caddr_t)&ub, sizeof (ub)); 809880Ssam (void) copyout((caddr_t)&ub, (caddr_t)uap->sb, sizeof (ub)); 819880Ssam } else 829880Ssam ostat1(fp->f_inode, uap->sb); 839880Ssam } 849880Ssam 859880Ssam /* 869880Ssam * Old stat system call. This version follows links. 879880Ssam */ 889880Ssam ostat() 899880Ssam { 909880Ssam register struct inode *ip; 919880Ssam register struct a { 929880Ssam char *fname; 939880Ssam struct ostat *sb; 949880Ssam } *uap; 959880Ssam 969880Ssam uap = (struct a *)u.u_ap; 979880Ssam ip = namei(uchar, LOOKUP, 1); 989880Ssam if (ip == NULL) 999880Ssam return; 1009880Ssam ostat1(ip, uap->sb); 1019880Ssam iput(ip); 1029880Ssam } 1039880Ssam 1049880Ssam ostat1(ip, ub) 1059880Ssam register struct inode *ip; 1069880Ssam struct ostat *ub; 1079880Ssam { 1089880Ssam struct ostat ds; 1099880Ssam 1109880Ssam IUPDAT(ip, &time, &time, 0); 1119880Ssam /* 1129880Ssam * Copy from inode table 1139880Ssam */ 1149880Ssam ds.ost_dev = ip->i_dev; 1159880Ssam ds.ost_ino = (short)ip->i_number; 1169880Ssam ds.ost_mode = (u_short)ip->i_mode; 1179880Ssam ds.ost_nlink = ip->i_nlink; 1189880Ssam ds.ost_uid = (short)ip->i_uid; 1199880Ssam ds.ost_gid = (short)ip->i_gid; 1209880Ssam ds.ost_rdev = (dev_t)ip->i_rdev; 1219880Ssam ds.ost_size = (int)ip->i_size; 1229880Ssam ds.ost_atime = (int)ip->i_atime; 1239880Ssam ds.ost_mtime = (int)ip->i_mtime; 1249880Ssam ds.ost_ctime = (int)ip->i_ctime; 1259880Ssam if (copyout((caddr_t)&ds, (caddr_t)ub, sizeof(ds)) < 0) 1269880Ssam u.u_error = EFAULT; 1279880Ssam } 1289880Ssam #endif 129