summaryrefslogtreecommitdiff
path: root/fs/xfs/libxfs/xfs_inode_util.h
blob: a38999109c5334ca533ca9bdf681c36b9ddd53dc (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
58
59
60
61
62
63
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
 * All Rights Reserved.
 */
#ifndef	__XFS_INODE_UTIL_H__
#define	__XFS_INODE_UTIL_H__

uint16_t	xfs_flags2diflags(struct xfs_inode *ip, unsigned int xflags);
uint64_t	xfs_flags2diflags2(struct xfs_inode *ip, unsigned int xflags);
uint32_t	xfs_dic2xflags(struct xfs_inode *ip);

prid_t		xfs_get_initial_prid(struct xfs_inode *dp);

/*
 * Initial ids, link count, device number, and mode of a new inode.
 *
 * Due to our only partial reliance on the VFS to propagate uid and gid values
 * according to accepted Unix behaviors, callers must initialize mnt_userns to
 * the appropriate namespace, uid to fsuid_into_mnt(), and gid to
 * fsgid_into_mnt() to get the correct inheritance behaviors when
 * XFS_MOUNT_GRPID is set.  Use the xfs_ialloc_inherit_args() helper.
 *
 * To override the default ids, use the FORCE flags defined below.
 */
struct xfs_icreate_args {
	struct user_namespace	*mnt_userns;
	struct xfs_inode	*pip;	/* parent inode or null */

	kuid_t			uid;
	kgid_t			gid;
	prid_t			prid;

	xfs_nlink_t		nlink;
	dev_t			rdev;

	umode_t			mode;

#define XFS_ICREATE_ARGS_FORCE_UID	(1 << 0)
#define XFS_ICREATE_ARGS_FORCE_GID	(1 << 1)
#define XFS_ICREATE_ARGS_FORCE_MODE	(1 << 2)
#define XFS_ICREATE_ARGS_INIT_XATTRS	(1 << 3)
	uint16_t		flags;
};

/*
 * Flags for xfs_trans_ichgtime().
 */
#define	XFS_ICHGTIME_MOD	0x1	/* data fork modification timestamp */
#define	XFS_ICHGTIME_CHG	0x2	/* inode field change timestamp */
#define	XFS_ICHGTIME_CREATE	0x4	/* inode create timestamp */
#define	XFS_ICHGTIME_ACCESS	0x8	/* last access timestamp */
void xfs_trans_ichgtime(struct xfs_trans *tp, struct xfs_inode *ip, int flags);

void xfs_inode_init(struct xfs_trans *tp, const struct xfs_icreate_args *args,
		struct xfs_inode *ip);

/* The libxfs client must provide this group of helper functions. */

/* Initialize the incore inode. */
void xfs_setup_inode(struct xfs_inode *ip);

#endif /* __XFS_INODE_UTIL_H__ */