1 /* Created (MFS based):
2 * June 2011 (Evgeniy Ivanov)
8 #include "puffs_priv.h"
11 /*===========================================================================*
13 *===========================================================================*/
14 int fs_chmod(ino_t ino_nr
, mode_t
*mode
)
16 /* Perform the chmod(name, mode) system call. */
17 struct puffs_node
*pn
;
19 PUFFS_MAKECRED(pcr
, &global_kcred
);
21 if (global_pu
->pu_ops
.puffs_node_setattr
== NULL
)
24 if ((pn
= puffs_pn_nodewalk(global_pu
, find_inode_cb
, &ino_nr
)) == NULL
)
27 puffs_vattr_null(&va
);
28 /* Clear setgid bit if file is not in caller's grp */
29 va
.va_mode
= (pn
->pn_va
.va_mode
& ~ALL_MODES
) | (*mode
& ALL_MODES
);
30 (void)clock_time(&va
.va_ctime
);
32 if (global_pu
->pu_ops
.puffs_node_setattr(global_pu
, pn
, &va
, pcr
) != 0)
35 /* Return full new mode to caller. */
36 *mode
= pn
->pn_va
.va_mode
;
42 /*===========================================================================*
44 *===========================================================================*/
45 int fs_chown(ino_t ino_nr
, uid_t uid
, gid_t gid
, mode_t
*mode
)
47 struct puffs_node
*pn
;
49 PUFFS_MAKECRED(pcr
, &global_kcred
);
51 if ((pn
= puffs_pn_nodewalk(global_pu
, find_inode_cb
, &ino_nr
)) == NULL
)
54 puffs_vattr_null(&va
);
57 va
.va_mode
= pn
->pn_va
.va_mode
& ~(I_SET_UID_BIT
| I_SET_GID_BIT
);
58 (void)clock_time(&va
.va_ctime
);
60 if (global_pu
->pu_ops
.puffs_node_setattr(global_pu
, pn
, &va
, pcr
) != 0)
63 /* Update caller on current mode, as it may have changed. */
64 *mode
= pn
->pn_va
.va_mode
;