1 #include "fs.h" 2 #include "inode.h" 3 #include "super.h" 4 5 6 /*===========================================================================* 7 * fs_chmod * 8 *===========================================================================*/ 9 int fs_chmod(ino_t ino_nr, mode_t *mode) 10 { 11 /* Perform the chmod(name, mode) system call. */ 12 register struct inode *rip; 13 14 /* Temporarily open the file. */ 15 if( (rip = get_inode(fs_dev, ino_nr)) == NULL) 16 return(EINVAL); 17 18 if(rip->i_sp->s_rd_only) { 19 put_inode(rip); 20 return EROFS; 21 } 22 23 /* Now make the change. Clear setgid bit if file is not in caller's grp */ 24 rip->i_mode = (rip->i_mode & ~ALL_MODES) | (*mode & ALL_MODES); 25 rip->i_update |= CTIME; 26 IN_MARKDIRTY(rip); 27 28 /* Return full new mode to caller. */ 29 *mode = rip->i_mode; 30 31 put_inode(rip); 32 return(OK); 33 } 34 35 36 /*===========================================================================* 37 * fs_chown * 38 *===========================================================================*/ 39 int fs_chown(ino_t ino_nr, uid_t uid, gid_t gid, mode_t *mode) 40 { 41 register struct inode *rip; 42 43 /* Temporarily open the file. */ 44 if( (rip = get_inode(fs_dev, ino_nr)) == NULL) 45 return(EINVAL); 46 47 rip->i_uid = uid; 48 rip->i_gid = gid; 49 rip->i_mode &= ~(I_SET_UID_BIT | I_SET_GID_BIT); 50 rip->i_update |= CTIME; 51 IN_MARKDIRTY(rip); 52 53 /* Update caller on current mode, as it may have changed. */ 54 *mode = rip->i_mode; 55 put_inode(rip); 56 57 return(OK); 58 } 59