source: gpfs_3.1_ker2.6.20/lpp/mmfs/include/gpfs_gpl.h @ 16

Last change on this file since 16 was 16, checked in by rock, 16 years ago
File size: 11.6 KB
Line 
1/***************************************************************************
2 *
3 * Copyright (C) 2006 International Business Machines
4 * All rights reserved.
5 *
6 * This file is part of the GPFS.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 *  1. Redistributions of source code must retain the above copyright notice,
13 *     this list of conditions and the following disclaimer.
14 *  2. Redistributions in binary form must reproduce the above copyright
15 *     notice, this list of conditions and the following disclaimer in the
16 *     documentation and/or other materials provided with the distribution.
17 *  3. The name of the author may not be used to endorse or promote products
18 *     derived from this software without specific prior written
19 *     permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
30 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 *************************************************************************** */
33/* @(#)79 1.3  src/avs/fs/mmfs/ts/kernext/ibm-kxi/gpfs_gpl.h, mmfs, avs_rgpfs24, rgpfs24s007a 10/27/06 16:48:09 */
34/*
35 *  Library calls for GPFS interfaces
36 */
37
38
39#ifndef H_GPFS_GPL
40#define H_GPFS_GPL
41#ifndef H_GPFS
42/* typedefs that are in gpfs.h as well */
43typedef unsigned int gpfs_uid_t;
44typedef long long gpfs_off64_t;
45#ifdef __cplusplus
46extern "C" {
47#endif
48#endif
49
50
51
52/* Mapping of buffer for gpfs_getacl, gpfs_putacl. */
53typedef struct gpfs_opaque_acl
54{
55  int            acl_buffer_len;  /* INPUT:  Total size of buffer (including this field).
56                                     OUTPUT: Actual size of the ACL information.  */
57  unsigned short acl_version;     /* INPUT:  Set to zero.
58                                     OUTPUT: Current version of the returned ACL. */
59  unsigned char  acl_type;        /* INPUT:  Type of ACL: access (1) or default (2). */
60  char           acl_var_data[1]; /* OUTPUT: Remainder of the ACL information. */
61} gpfs_opaque_acl_t;
62
63/* ACL types (acl_type field in gpfs_opaque_acl_t or gpfs_acl_t) */
64#define GPFS_ACL_TYPE_ACCESS  1
65#define GPFS_ACL_TYPE_DEFAULT 2
66#define GPFS_ACL_TYPE_NFS4    3
67
68/* gpfs_getacl, gpfs_putacl flag indicating structures instead of the
69   opaque style data normally used.  */
70#define GPFS_GETACL_STRUCT 0x00000020
71#define GPFS_PUTACL_STRUCT 0x00000020
72
73/* gpfs_getacl, gpfs_putacl flag indicating smbd is the caller */
74#define GPFS_ACL_SAMBA     0x00000040
75
76/* Defined values for gpfs_aclVersion_t */
77#define GPFS_ACL_VERSION_POSIX 1
78#define GPFS_ACL_VERSION_NFS4  4
79
80/* Values for gpfs_aceType_t (ACL_VERSION_POSIX) */
81#define GPFS_ACL_USER_OBJ  1
82#define GPFS_ACL_GROUP_OBJ 2
83#define GPFS_ACL_OTHER     3
84#define GPFS_ACL_MASK      4
85#define GPFS_ACL_USER      5
86#define GPFS_ACL_GROUP     6
87
88/* Values for gpfs_acePerm_t (ACL_VERSION_POSIX) */
89#define ACL_PERM_EXECUTE 001
90#define ACL_PERM_WRITE   002
91#define ACL_PERM_READ    004
92#define ACL_PERM_CONTROL 010
93
94/* Values for gpfs_aceType_t (ACL_VERSION_NFS4) */
95#define ACE4_TYPE_ALLOW 0
96#define ACE4_TYPE_DENY  1
97
98/* Values for gpfs_aceFlags_t (ACL_VERSION_NFS4) */
99#define ACE4_FLAG_FILE_INHERIT    0x00000001
100#define ACE4_FLAG_DIR_INHERIT     0x00000002
101#define ACE4_FLAG_INHERIT_ONLY    0x00000008
102#define ACE4_FLAG_GROUP_ID        0x00000040
103
104/* GPFS-defined flags.  Placed in a seperate ACL field to avoid
105   ever running into newly defined NFSv4 flags. */
106#define ACE4_IFLAG_SPECIAL_ID     0x80000000
107
108/* Values for gpfs_aceMask_t (ACL_VERSION_NFS4) */
109#define ACE4_MASK_READ         0x00000001
110#define ACE4_MASK_LIST_DIR     0x00000001
111#define ACE4_MASK_WRITE        0x00000002
112#define ACE4_MASK_ADD_FILE     0x00000002
113#define ACE4_MASK_APPEND       0x00000004
114#define ACE4_MASK_ADD_SUBDIR   0x00000004
115#define ACE4_MASK_READ_NAMED   0x00000008
116#define ACE4_MASK_WRITE_NAMED  0x00000010
117#define ACE4_MASK_EXECUTE      0x00000020
118
119/* The rfc doesn't provide a mask equivalent to "search" ("x" on a
120 * directory in posix), but it also doesn't say that its EXECUTE
121 * is to have this dual use (even though it does so for other dual
122 * use permissions such as read/list.  Going to make the assumption
123 * here that the EXECUTE bit has this dual meaning... otherwise
124 * we're left with no control over search.
125 */
126#define ACE4_MASK_SEARCH       0x00000020
127
128#define ACE4_MASK_DELETE_CHILD 0x00000040
129#define ACE4_MASK_READ_ATTR    0x00000080
130#define ACE4_MASK_WRITE_ATTR   0x00000100
131#define ACE4_MASK_DELETE       0x00010000
132#define ACE4_MASK_READ_ACL     0x00020000
133#define ACE4_MASK_WRITE_ACL    0x00040000
134#define ACE4_MASK_WRITE_OWNER  0x00080000
135#define ACE4_MASK_SYNCHRONIZE  0x00100000
136#define ACE4_MASK_ALL          0x001f01ff
137
138/* Values for gpfs_uid_t (ACL_VERSION_NFS4) */
139#define ACE4_SPECIAL_OWNER              1
140#define ACE4_SPECIAL_GROUP              2
141#define ACE4_SPECIAL_EVERYONE           3
142
143
144/* Externalized ACL defintions */
145typedef unsigned int gpfs_aclType_t;
146typedef unsigned int gpfs_aclLen_t;
147typedef unsigned int gpfs_aclLevel_t;
148typedef unsigned int gpfs_aclVersion_t;
149typedef unsigned int gpfs_aclCount_t;
150
151typedef unsigned int gpfs_aceType_t;
152typedef unsigned int gpfs_aceFlags_t;
153typedef unsigned int gpfs_acePerm_t;
154typedef unsigned int gpfs_aceMask_t;
155
156/* A POSIX ACL Entry */
157typedef struct gpfs_ace_v1
158{
159  gpfs_aceType_t  ace_type; /* POSIX ACE type */
160  gpfs_uid_t      ace_who;  /* uid/gid */
161  gpfs_acePerm_t  ace_perm; /* POSIX permissions */
162} gpfs_ace_v1_t;
163
164/* A NFSv4 ACL Entry */
165typedef struct gpfs_ace_v4
166{
167  gpfs_aceType_t  aceType;   /* Allow or Deny */
168  gpfs_aceFlags_t aceFlags;  /* Inherit specifications, etc. */
169  gpfs_aceFlags_t aceIFlags; /* GPFS Internal flags */
170  gpfs_aceMask_t  aceMask;   /* NFSv4 mask specification */
171  gpfs_uid_t      aceWho;    /* User/Group identification */
172} gpfs_ace_v4_t;
173
174/* The GPFS ACL */
175typedef struct gpfs_acl
176{
177  gpfs_aclLen_t     acl_len;     /* Total length of this ACL in bytes */
178  gpfs_aclLevel_t   acl_level;   /* Reserved (must be zero) */
179  gpfs_aclVersion_t acl_version; /* POSIX or NFS4 ACL */
180  gpfs_aclType_t    acl_type;    /* Access, Default, or NFS4 */
181  gpfs_aclCount_t   acl_nace;    /* Number of Entries that follow */
182  union
183  {
184    gpfs_ace_v1_t  ace_v1[1]; /* when GPFS_ACL_VERSION_POSIX */
185    gpfs_ace_v4_t  ace_v4[1]; /* when GPFS_ACL_VERSION_NFS4  */
186  };
187} gpfs_acl_t;
188
189
190
191/* NAME:        gpfs_getacl()
192 *
193 * FUNCTION:    Retrieves the ACL information for a file.
194 *              This function, together with gpfs_putacl, is intended
195 *              for use by a backup program to save (gpfs_getacl) and
196 *              restore (gpfs_putacl) the ACL information for a file.
197 *              The flags parameter must be zero (reserved for future use).
198 *              The aclP parameter must point to a buffer mapped by the
199 *              gpfs_opaque_acl_t structure. The first four bytes of the
200 *              buffer must contain its total size.
201 *
202 *              Note: The use of gpfs_fgetattrs/gpfs_fputattrs is preferred.
203 *
204 * Returns:      0      Successful
205 *              -1      Failure
206 *
207 * Errno:       ENOSYS  function not available
208 *              ENOSPC  buffer too small to return the entire ACL.
209 *                      Needed size is returned in the first four
210 *                      bytes of the buffer pointed to by aclP.
211 */
212int 
213gpfs_getacl(char *pathname,
214            int   flags,
215            void *acl);
216
217
218/* NAME:        gpfs_putacl()
219 *
220 * FUNCTION:    Sets the ACL information for a file.
221 *              The buffer passed in should contain the ACL data
222 *              that was obtained by a previous call to gpfs_getacl.
223 *              The flags parameter must be zero (reserved for future use).
224 *
225 *              Note: The use of gpfs_fgetattrs/gpfs_fputattrs is preferred.
226 *
227 * Returns:      0      Successful
228 *              -1      Failure
229 *
230 * Errno:       ENOSYS  function not available
231 */
232int 
233gpfs_putacl(char *pathname,
234            int   flags,
235            void *acl);
236
237
238/* NAME:        gpfs_prealloc()
239 * FUNCTION:    Preallocate disk storage for the file handle that has
240 *              already been opened for writing, starting at the specified
241 *              starting offset and covering at least the number of bytes
242 *              requested. Allocations are rounded to block boundaries
243 *              (block size can be found using fstat() in st_blksize.)
244 *              Any existing data already in the file will not be modified.
245 *              Any read of the preallocated blocks will return zeros.
246 *
247 * Returns:      0      Successful
248 *              -1      Failure
249 *
250 * Errno:       ENOSYS  No prealloc service available
251 *              EBADF   Bad file desc
252 *              EINVAL  Not a GPFS file
253 *              EINVAL  Not a regular file
254 *              EINVAL  StartOffset or BytesToPrealloc < 0
255 *              EACCES  File not opened for writing
256 *              EDQUOT  Quota exceeded
257 *              ENOSPC  Not enough space on disk
258 */
259int
260gpfs_prealloc(int fileDesc,
261              gpfs_off64_t startOffset,
262              gpfs_off64_t bytesToPrealloc);
263
264
265#ifndef H_GPFS
266/* NAME:        gpfs_set_share()
267 *
268 * FUNCTION:    Acquire shares for Samba
269 *
270 * Input:       fd    : file descriptor
271 *              allow : share type being requested
272 *                      GPFS_SHARE_NONE, GPFS_SHARE_READ,
273 *                      GPFS_SHARE_WRITE, GPFS_SHARE_BOTH
274 *              deny  : share type to deny to others
275 *                      GPFS_DENY_NONE, GPFS_DENY_READ,
276 *                      GPFS_DENY_WRITE, GPFS_DENY_BOTH
277 *
278 * Returns:      0      Successful
279 *              -1      Failure
280 *
281 * Errno:       Specific error indication
282 *              EACCES  share mode not available
283 */
284
285/* allow/deny specifications */
286#define GPFS_SHARE_NONE   0
287#define GPFS_SHARE_READ   1
288#define GPFS_SHARE_WRITE  2
289#define GPFS_SHARE_BOTH   3
290#define GPFS_DENY_NONE    0
291#define GPFS_DENY_READ    1
292#define GPFS_DENY_WRITE   2
293#define GPFS_DENY_BOTH    3
294
295int 
296gpfs_set_share(int fd,
297               unsigned int allow,
298               unsigned int deny);
299
300
301/* NAME:        gpfs_set_lease()
302 *
303 * FUNCTION:    Acquire leases for Samba
304 *
305 * Input:       fd        : file descriptor
306 *              leaseType : lease type being requested
307 *                          GPFS_LEASE_NONE GPFS_LEASE_READ,
308 *                          GPFS_LEASE_WRITE
309 *
310 * Returns:      0      Successful
311 *              -1      Failure
312 *
313 * Errno:       Specific error indication
314 *              EACCES  lease not available
315 */
316
317/* leaseType specifications */
318#define GPFS_LEASE_NONE    0
319#define GPFS_LEASE_READ    1
320#define GPFS_LEASE_WRITE   2
321
322int 
323gpfs_set_lease(int fd,
324               unsigned int leaseType);
325
326
327/* NAME:        gpfs_get_lease()
328 *
329 * FUNCTION:    Returns the type of lease currently held
330 *
331 * Returns:      GPFS_LEASE_READ   
332 *               GPFS_LEASE_WRITE   
333 *               GPFS_LEASE_NONE   
334 *              -1      Failure
335 *
336 * Errno:       Specific error indication
337 *              EINVAL 
338 */
339int
340gpfs_get_lease(int fd);
341#endif /* included directly (not via gpfs.h) */
342
343
344#ifndef H_GPFS
345#ifdef __cplusplus
346}
347#endif
348#endif
349#endif /* H_GPFS_GPL */
Note: See TracBrowser for help on using the repository browser.