minix/servers/pfs/misc.c
Ben Gras 072d916c1c vfs: fix null deref, pfs: add fchmod()
. vfs read_only() assumes vnode->v_vmnt is non-NULL, but it can
	  be NULL sometimes
	. e.g. fchmod() on UDS triggered NULL deref; add a check and
	  add REQ_CHMOD to pfs so unix domain sockets can be fchmod()ded
	. add to test56

Change-Id: I83c840f101b647516897cc99fcf472116d762012
2013-04-19 17:06:56 +02:00

28 lines
978 B
C

#include "fs.h"
#include "inode.h"
/*===========================================================================*
* fs_sync *
*===========================================================================*/
int fs_sync(message *fs_m_in, message *fs_m_out)
{
/* Perform the sync() system call. No-op on this FS. */
return(OK); /* sync() can't fail */
}
/*===========================================================================*
* fs_chmod *
*===========================================================================*/
int fs_chmod(message *fs_m_in, message *fs_m_out)
{
struct inode *rip; /* target inode */
mode_t mode = (mode_t) fs_m_in->REQ_MODE;
if( (rip = find_inode(fs_m_in->REQ_INODE_NR)) == NULL) return(EINVAL);
get_inode(rip->i_dev, rip->i_num); /* mark inode in use */
rip->i_mode = (rip->i_mode & ~ALL_MODES) | (mode & ALL_MODES);
put_inode(rip); /* release the inode */
return OK;
}