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