10a586ceMark Shellenbaum/*
20a586ceMark Shellenbaum * CDDL HEADER START
30a586ceMark Shellenbaum *
40a586ceMark Shellenbaum * The contents of this file are subject to the terms of the
50a586ceMark Shellenbaum * Common Development and Distribution License (the "License").
60a586ceMark Shellenbaum * You may not use this file except in compliance with the License.
70a586ceMark Shellenbaum *
80a586ceMark Shellenbaum * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90a586ceMark Shellenbaum * or http://www.opensolaris.org/os/licensing.
100a586ceMark Shellenbaum * See the License for the specific language governing permissions
110a586ceMark Shellenbaum * and limitations under the License.
120a586ceMark Shellenbaum *
130a586ceMark Shellenbaum * When distributing Covered Code, include this CDDL HEADER in each
140a586ceMark Shellenbaum * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150a586ceMark Shellenbaum * If applicable, add the following below this CDDL HEADER, with the
160a586ceMark Shellenbaum * fields enclosed by brackets "[]" replaced with your own identifying
170a586ceMark Shellenbaum * information: Portions Copyright [yyyy] [name of copyright owner]
180a586ceMark Shellenbaum *
190a586ceMark Shellenbaum * CDDL HEADER END
200a586ceMark Shellenbaum */
210a586ceMark Shellenbaum/*
220a586ceMark Shellenbaum * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
230a586ceMark Shellenbaum * Use is subject to license terms.
240a586ceMark Shellenbaum */
250a586ceMark Shellenbaum
260a586ceMark Shellenbaum#ifndef	_SYS_ZFS_SA_H
270a586ceMark Shellenbaum#define	_SYS_ZFS_SA_H
280a586ceMark Shellenbaum
290a586ceMark Shellenbaum#ifdef _KERNEL
300a586ceMark Shellenbaum#include <sys/types32.h>
310a586ceMark Shellenbaum#include <sys/list.h>
320a586ceMark Shellenbaum#include <sys/dmu.h>
330a586ceMark Shellenbaum#include <sys/zfs_acl.h>
340a586ceMark Shellenbaum#include <sys/zfs_znode.h>
350a586ceMark Shellenbaum#include <sys/sa.h>
360a586ceMark Shellenbaum#include <sys/zil.h>
370a586ceMark Shellenbaum
380a586ceMark Shellenbaum
390a586ceMark Shellenbaum#endif
400a586ceMark Shellenbaum
410a586ceMark Shellenbaum#ifdef	__cplusplus
420a586ceMark Shellenbaumextern "C" {
430a586ceMark Shellenbaum#endif
440a586ceMark Shellenbaum
450a586ceMark Shellenbaum/*
460a586ceMark Shellenbaum * This is the list of known attributes
470a586ceMark Shellenbaum * to the ZPL.  The values of the actual
480a586ceMark Shellenbaum * attributes are not defined by the order
490a586ceMark Shellenbaum * the enums.  It is controlled by the attribute
500a586ceMark Shellenbaum * registration mechanism.  Two different file system
510a586ceMark Shellenbaum * could have different numeric values for the same
520a586ceMark Shellenbaum * attributes.  this list is only used for dereferencing
530a586ceMark Shellenbaum * into the table that will hold the actual numeric value.
540a586ceMark Shellenbaum */
550a586ceMark Shellenbaumtypedef enum zpl_attr {
560a586ceMark Shellenbaum	ZPL_ATIME,
570a586ceMark Shellenbaum	ZPL_MTIME,
580a586ceMark Shellenbaum	ZPL_CTIME,
590a586ceMark Shellenbaum	ZPL_CRTIME,
600a586ceMark Shellenbaum	ZPL_GEN,
610a586ceMark Shellenbaum	ZPL_MODE,
620a586ceMark Shellenbaum	ZPL_SIZE,
630a586ceMark Shellenbaum	ZPL_PARENT,
640a586ceMark Shellenbaum	ZPL_LINKS,
650a586ceMark Shellenbaum	ZPL_XATTR,
660a586ceMark Shellenbaum	ZPL_RDEV,
670a586ceMark Shellenbaum	ZPL_FLAGS,
680a586ceMark Shellenbaum	ZPL_UID,
690a586ceMark Shellenbaum	ZPL_GID,
700a586ceMark Shellenbaum	ZPL_PAD,
710a586ceMark Shellenbaum	ZPL_ZNODE_ACL,
720a586ceMark Shellenbaum	ZPL_DACL_COUNT,
730a586ceMark Shellenbaum	ZPL_SYMLINK,
740a586ceMark Shellenbaum	ZPL_SCANSTAMP,
750a586ceMark Shellenbaum	ZPL_DACL_ACES,
76f67950bNasf-Fan	ZPL_PROJID,
770a586ceMark Shellenbaum	ZPL_END
780a586ceMark Shellenbaum} zpl_attr_t;
790a586ceMark Shellenbaum
800a586ceMark Shellenbaum#define	ZFS_OLD_ZNODE_PHYS_SIZE	0x108
810a586ceMark Shellenbaum#define	ZFS_SA_BASE_ATTR_SIZE	(ZFS_OLD_ZNODE_PHYS_SIZE - \
820a586ceMark Shellenbaum    sizeof (zfs_acl_phys_t))
830a586ceMark Shellenbaum
840a586ceMark Shellenbaum#define	SA_MODE_OFFSET		0
850a586ceMark Shellenbaum#define	SA_SIZE_OFFSET		8
860a586ceMark Shellenbaum#define	SA_GEN_OFFSET		16
870a586ceMark Shellenbaum#define	SA_UID_OFFSET		24
880a586ceMark Shellenbaum#define	SA_GID_OFFSET		32
890a586ceMark Shellenbaum#define	SA_PARENT_OFFSET	40
90f67950bNasf-Fan#define	SA_FLAGS_OFFSET		48
91f67950bNasf-Fan#define	SA_PROJID_OFFSET	128
920a586ceMark Shellenbaum
930a586ceMark Shellenbaumextern sa_attr_reg_t zfs_attr_table[ZPL_END + 1];
940a586ceMark Shellenbaumextern sa_attr_reg_t zfs_legacy_attr_table[ZPL_END + 1];
950a586ceMark Shellenbaum
960a586ceMark Shellenbaum/*
970a586ceMark Shellenbaum * This is a deprecated data structure that only exists for
980a586ceMark Shellenbaum * dealing with file systems create prior to ZPL version 5.
990a586ceMark Shellenbaum */
1000a586ceMark Shellenbaumtypedef struct znode_phys {
1010a586ceMark Shellenbaum	uint64_t zp_atime[2];		/*  0 - last file access time */
1020a586ceMark Shellenbaum	uint64_t zp_mtime[2];		/* 16 - last file modification time */
1030a586ceMark Shellenbaum	uint64_t zp_ctime[2];		/* 32 - last file change time */
1040a586ceMark Shellenbaum	uint64_t zp_crtime[2];		/* 48 - creation time */
1050a586ceMark Shellenbaum	uint64_t zp_gen;		/* 64 - generation (txg of creation) */
1060a586ceMark Shellenbaum	uint64_t zp_mode;		/* 72 - file mode bits */
1070a586ceMark Shellenbaum	uint64_t zp_size;		/* 80 - size of file */
1080a586ceMark Shellenbaum	uint64_t zp_parent;		/* 88 - directory parent (`..') */
1090a586ceMark Shellenbaum	uint64_t zp_links;		/* 96 - number of links to file */
1100a586ceMark Shellenbaum	uint64_t zp_xattr;		/* 104 - DMU object for xattrs */
1110a586ceMark Shellenbaum	uint64_t zp_rdev;		/* 112 - dev_t for VBLK & VCHR files */
1120a586ceMark Shellenbaum	uint64_t zp_flags;		/* 120 - persistent flags */
1130a586ceMark Shellenbaum	uint64_t zp_uid;		/* 128 - file owner */
1140a586ceMark Shellenbaum	uint64_t zp_gid;		/* 136 - owning group */
1150a586ceMark Shellenbaum	uint64_t zp_zap;		/* 144 - extra attributes */
1160a586ceMark Shellenbaum	uint64_t zp_pad[3];		/* 152 - future */
1170a586ceMark Shellenbaum	zfs_acl_phys_t zp_acl;		/* 176 - 263 ACL */
1180a586ceMark Shellenbaum	/*
1190a586ceMark Shellenbaum	 * Data may pad out any remaining bytes in the znode buffer, eg:
1200a586ceMark Shellenbaum	 *
1210a586ceMark Shellenbaum	 * |<---------------------- dnode_phys (512) ------------------------>|
1220a586ceMark Shellenbaum	 * |<-- dnode (192) --->|<----------- "bonus" buffer (320) ---------->|
1230a586ceMark Shellenbaum	 *			|<---- znode (264) ---->|<---- data (56) ---->|
1240a586ceMark Shellenbaum	 *
1250a586ceMark Shellenbaum	 * At present, we use this space for the following:
1260a586ceMark Shellenbaum	 *  - symbolic links
1270a586ceMark Shellenbaum	 *  - 32-byte anti-virus scanstamp (regular files only)
1280a586ceMark Shellenbaum	 */
1290a586ceMark Shellenbaum} znode_phys_t;
1300a586ceMark Shellenbaum
1310a586ceMark Shellenbaum#ifdef _KERNEL
1320a586ceMark Shellenbaumint zfs_sa_readlink(struct znode *, uio_t *);
1330a586ceMark Shellenbaumvoid zfs_sa_symlink(struct znode *, char *link, int len, dmu_tx_t *);
1340a586ceMark Shellenbaumvoid zfs_sa_upgrade(struct sa_handle  *, dmu_tx_t *);
1350a586ceMark Shellenbaumvoid zfs_sa_get_scanstamp(struct znode *, xvattr_t *);
1360a586ceMark Shellenbaumvoid zfs_sa_set_scanstamp(struct znode *, xvattr_t *, dmu_tx_t *);
1370a586ceMark Shellenbaumvoid zfs_sa_uprade_pre(struct sa_handle *, void *, dmu_tx_t *);
1380a586ceMark Shellenbaumvoid zfs_sa_upgrade_post(struct sa_handle *, void *, dmu_tx_t *);
1390a586ceMark Shellenbaumvoid zfs_sa_upgrade_txholds(dmu_tx_t *, struct znode *);
1400a586ceMark Shellenbaum#endif
1410a586ceMark Shellenbaum
1420a586ceMark Shellenbaum#ifdef	__cplusplus
1430a586ceMark Shellenbaum}
1440a586ceMark Shellenbaum#endif
1450a586ceMark Shellenbaum
1460a586ceMark Shellenbaum#endif	/* _SYS_ZFS_SA_H */