/*************************************************************************** * * Copyright (C) 2006 International Business Machines * All rights reserved. * * This file is part of the GPFS. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *************************************************************************** */ /* @(#)79 1.3 src/avs/fs/mmfs/ts/kernext/ibm-kxi/gpfs_gpl.h, mmfs, avs_rgpfs24, rgpfs24s007a 10/27/06 16:48:09 */ /* * Library calls for GPFS interfaces */ #ifndef H_GPFS_GPL #define H_GPFS_GPL #ifndef H_GPFS /* typedefs that are in gpfs.h as well */ typedef unsigned int gpfs_uid_t; typedef long long gpfs_off64_t; #ifdef __cplusplus extern "C" { #endif #endif /* Mapping of buffer for gpfs_getacl, gpfs_putacl. */ typedef struct gpfs_opaque_acl { int acl_buffer_len; /* INPUT: Total size of buffer (including this field). OUTPUT: Actual size of the ACL information. */ unsigned short acl_version; /* INPUT: Set to zero. OUTPUT: Current version of the returned ACL. */ unsigned char acl_type; /* INPUT: Type of ACL: access (1) or default (2). */ char acl_var_data[1]; /* OUTPUT: Remainder of the ACL information. */ } gpfs_opaque_acl_t; /* ACL types (acl_type field in gpfs_opaque_acl_t or gpfs_acl_t) */ #define GPFS_ACL_TYPE_ACCESS 1 #define GPFS_ACL_TYPE_DEFAULT 2 #define GPFS_ACL_TYPE_NFS4 3 /* gpfs_getacl, gpfs_putacl flag indicating structures instead of the opaque style data normally used. */ #define GPFS_GETACL_STRUCT 0x00000020 #define GPFS_PUTACL_STRUCT 0x00000020 /* gpfs_getacl, gpfs_putacl flag indicating smbd is the caller */ #define GPFS_ACL_SAMBA 0x00000040 /* Defined values for gpfs_aclVersion_t */ #define GPFS_ACL_VERSION_POSIX 1 #define GPFS_ACL_VERSION_NFS4 4 /* Values for gpfs_aceType_t (ACL_VERSION_POSIX) */ #define GPFS_ACL_USER_OBJ 1 #define GPFS_ACL_GROUP_OBJ 2 #define GPFS_ACL_OTHER 3 #define GPFS_ACL_MASK 4 #define GPFS_ACL_USER 5 #define GPFS_ACL_GROUP 6 /* Values for gpfs_acePerm_t (ACL_VERSION_POSIX) */ #define ACL_PERM_EXECUTE 001 #define ACL_PERM_WRITE 002 #define ACL_PERM_READ 004 #define ACL_PERM_CONTROL 010 /* Values for gpfs_aceType_t (ACL_VERSION_NFS4) */ #define ACE4_TYPE_ALLOW 0 #define ACE4_TYPE_DENY 1 /* Values for gpfs_aceFlags_t (ACL_VERSION_NFS4) */ #define ACE4_FLAG_FILE_INHERIT 0x00000001 #define ACE4_FLAG_DIR_INHERIT 0x00000002 #define ACE4_FLAG_INHERIT_ONLY 0x00000008 #define ACE4_FLAG_GROUP_ID 0x00000040 /* GPFS-defined flags. Placed in a seperate ACL field to avoid ever running into newly defined NFSv4 flags. */ #define ACE4_IFLAG_SPECIAL_ID 0x80000000 /* Values for gpfs_aceMask_t (ACL_VERSION_NFS4) */ #define ACE4_MASK_READ 0x00000001 #define ACE4_MASK_LIST_DIR 0x00000001 #define ACE4_MASK_WRITE 0x00000002 #define ACE4_MASK_ADD_FILE 0x00000002 #define ACE4_MASK_APPEND 0x00000004 #define ACE4_MASK_ADD_SUBDIR 0x00000004 #define ACE4_MASK_READ_NAMED 0x00000008 #define ACE4_MASK_WRITE_NAMED 0x00000010 #define ACE4_MASK_EXECUTE 0x00000020 /* The rfc doesn't provide a mask equivalent to "search" ("x" on a * directory in posix), but it also doesn't say that its EXECUTE * is to have this dual use (even though it does so for other dual * use permissions such as read/list. Going to make the assumption * here that the EXECUTE bit has this dual meaning... otherwise * we're left with no control over search. */ #define ACE4_MASK_SEARCH 0x00000020 #define ACE4_MASK_DELETE_CHILD 0x00000040 #define ACE4_MASK_READ_ATTR 0x00000080 #define ACE4_MASK_WRITE_ATTR 0x00000100 #define ACE4_MASK_DELETE 0x00010000 #define ACE4_MASK_READ_ACL 0x00020000 #define ACE4_MASK_WRITE_ACL 0x00040000 #define ACE4_MASK_WRITE_OWNER 0x00080000 #define ACE4_MASK_SYNCHRONIZE 0x00100000 #define ACE4_MASK_ALL 0x001f01ff /* Values for gpfs_uid_t (ACL_VERSION_NFS4) */ #define ACE4_SPECIAL_OWNER 1 #define ACE4_SPECIAL_GROUP 2 #define ACE4_SPECIAL_EVERYONE 3 /* Externalized ACL defintions */ typedef unsigned int gpfs_aclType_t; typedef unsigned int gpfs_aclLen_t; typedef unsigned int gpfs_aclLevel_t; typedef unsigned int gpfs_aclVersion_t; typedef unsigned int gpfs_aclCount_t; typedef unsigned int gpfs_aceType_t; typedef unsigned int gpfs_aceFlags_t; typedef unsigned int gpfs_acePerm_t; typedef unsigned int gpfs_aceMask_t; /* A POSIX ACL Entry */ typedef struct gpfs_ace_v1 { gpfs_aceType_t ace_type; /* POSIX ACE type */ gpfs_uid_t ace_who; /* uid/gid */ gpfs_acePerm_t ace_perm; /* POSIX permissions */ } gpfs_ace_v1_t; /* A NFSv4 ACL Entry */ typedef struct gpfs_ace_v4 { gpfs_aceType_t aceType; /* Allow or Deny */ gpfs_aceFlags_t aceFlags; /* Inherit specifications, etc. */ gpfs_aceFlags_t aceIFlags; /* GPFS Internal flags */ gpfs_aceMask_t aceMask; /* NFSv4 mask specification */ gpfs_uid_t aceWho; /* User/Group identification */ } gpfs_ace_v4_t; /* The GPFS ACL */ typedef struct gpfs_acl { gpfs_aclLen_t acl_len; /* Total length of this ACL in bytes */ gpfs_aclLevel_t acl_level; /* Reserved (must be zero) */ gpfs_aclVersion_t acl_version; /* POSIX or NFS4 ACL */ gpfs_aclType_t acl_type; /* Access, Default, or NFS4 */ gpfs_aclCount_t acl_nace; /* Number of Entries that follow */ union { gpfs_ace_v1_t ace_v1[1]; /* when GPFS_ACL_VERSION_POSIX */ gpfs_ace_v4_t ace_v4[1]; /* when GPFS_ACL_VERSION_NFS4 */ }; } gpfs_acl_t; /* NAME: gpfs_getacl() * * FUNCTION: Retrieves the ACL information for a file. * This function, together with gpfs_putacl, is intended * for use by a backup program to save (gpfs_getacl) and * restore (gpfs_putacl) the ACL information for a file. * The flags parameter must be zero (reserved for future use). * The aclP parameter must point to a buffer mapped by the * gpfs_opaque_acl_t structure. The first four bytes of the * buffer must contain its total size. * * Note: The use of gpfs_fgetattrs/gpfs_fputattrs is preferred. * * Returns: 0 Successful * -1 Failure * * Errno: ENOSYS function not available * ENOSPC buffer too small to return the entire ACL. * Needed size is returned in the first four * bytes of the buffer pointed to by aclP. */ int gpfs_getacl(char *pathname, int flags, void *acl); /* NAME: gpfs_putacl() * * FUNCTION: Sets the ACL information for a file. * The buffer passed in should contain the ACL data * that was obtained by a previous call to gpfs_getacl. * The flags parameter must be zero (reserved for future use). * * Note: The use of gpfs_fgetattrs/gpfs_fputattrs is preferred. * * Returns: 0 Successful * -1 Failure * * Errno: ENOSYS function not available */ int gpfs_putacl(char *pathname, int flags, void *acl); /* NAME: gpfs_prealloc() * FUNCTION: Preallocate disk storage for the file handle that has * already been opened for writing, starting at the specified * starting offset and covering at least the number of bytes * requested. Allocations are rounded to block boundaries * (block size can be found using fstat() in st_blksize.) * Any existing data already in the file will not be modified. * Any read of the preallocated blocks will return zeros. * * Returns: 0 Successful * -1 Failure * * Errno: ENOSYS No prealloc service available * EBADF Bad file desc * EINVAL Not a GPFS file * EINVAL Not a regular file * EINVAL StartOffset or BytesToPrealloc < 0 * EACCES File not opened for writing * EDQUOT Quota exceeded * ENOSPC Not enough space on disk */ int gpfs_prealloc(int fileDesc, gpfs_off64_t startOffset, gpfs_off64_t bytesToPrealloc); #ifndef H_GPFS /* NAME: gpfs_set_share() * * FUNCTION: Acquire shares for Samba * * Input: fd : file descriptor * allow : share type being requested * GPFS_SHARE_NONE, GPFS_SHARE_READ, * GPFS_SHARE_WRITE, GPFS_SHARE_BOTH * deny : share type to deny to others * GPFS_DENY_NONE, GPFS_DENY_READ, * GPFS_DENY_WRITE, GPFS_DENY_BOTH * * Returns: 0 Successful * -1 Failure * * Errno: Specific error indication * EACCES share mode not available */ /* allow/deny specifications */ #define GPFS_SHARE_NONE 0 #define GPFS_SHARE_READ 1 #define GPFS_SHARE_WRITE 2 #define GPFS_SHARE_BOTH 3 #define GPFS_DENY_NONE 0 #define GPFS_DENY_READ 1 #define GPFS_DENY_WRITE 2 #define GPFS_DENY_BOTH 3 int gpfs_set_share(int fd, unsigned int allow, unsigned int deny); /* NAME: gpfs_set_lease() * * FUNCTION: Acquire leases for Samba * * Input: fd : file descriptor * leaseType : lease type being requested * GPFS_LEASE_NONE GPFS_LEASE_READ, * GPFS_LEASE_WRITE * * Returns: 0 Successful * -1 Failure * * Errno: Specific error indication * EACCES lease not available */ /* leaseType specifications */ #define GPFS_LEASE_NONE 0 #define GPFS_LEASE_READ 1 #define GPFS_LEASE_WRITE 2 int gpfs_set_lease(int fd, unsigned int leaseType); /* NAME: gpfs_get_lease() * * FUNCTION: Returns the type of lease currently held * * Returns: GPFS_LEASE_READ * GPFS_LEASE_WRITE * GPFS_LEASE_NONE * -1 Failure * * Errno: Specific error indication * EINVAL */ int gpfs_get_lease(int fd); #endif /* included directly (not via gpfs.h) */ #ifndef H_GPFS #ifdef __cplusplus } #endif #endif #endif /* H_GPFS_GPL */