2 /* Copyright (C) 2001 International Business Machines */
3 /* All rights reserved. */
5 /* This file is part of the GPFS user library. */
7 /* Redistribution and use in source and binary forms, with or without */
8 /* modification, are permitted provided that the following conditions */
11 /* 1. Redistributions of source code must retain the above copyright notice, */
12 /* this list of conditions and the following disclaimer. */
13 /* 2. Redistributions in binary form must reproduce the above copyright */
14 /* notice, this list of conditions and the following disclaimer in the */
15 /* documentation and/or other materials provided with the distribution. */
16 /* 3. The name of the author may not be used to endorse or promote products */
17 /* derived from this software without specific prior written */
20 /* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR */
21 /* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES */
22 /* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. */
23 /* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
24 /* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, */
25 /* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; */
26 /* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, */
27 /* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR */
28 /* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF */
29 /* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
31 /* @(#)42 1.1.15.1 src/avs/fs/mmfs/ts/util/gpfs.h, mmfs, avs_rtac505, rtac5052017d.b 4/7/20 08:36:44 */
33 * Library calls for GPFS interfaces
40 /* Define GPFS_64BIT_INODES to map the default interface definitions
41 to 64-bit interfaces. Without this define, the 32-bit interface
42 is the default. Both interfaces are always present, but the
43 define sets the default. The actual mapping can be found near the
44 end of this header. */
45 /* #define GPFS_64BIT_INODES 1 */
47 #define NFS_IP_SIZE 46
53 #if defined(WIN32) && defined(GPFSDLL)
55 /* The following errno values either are missing from Windows errno.h or
56 have a conflicting value. Other errno values (e.g. EPERM) are okay. */
57 #define GPFS_EALREADY 37 /* Operation already in progress */
58 #define GPFS_EOPNOTSUPP 45 /* Operation not supported */
59 #define GPFS_EDQUOT 69 /* Disk quota exceeded */
60 #define GPFS_ESTALE 9 /* No file system (mapped to EBADF) */
61 #define GPFS_EFORMAT 19 /* Unformatted media (mapped to ENODEV) */
63 /* specify the library calling convention */
64 #define GPFS_API __stdcall
66 /* On Windows, this is a HANDLE as returned by CreateFile() */
67 typedef void* gpfs_file_t
;
69 #else /* not gpfs.dll on Windows */
72 /* On UNIX systems, this is a file descriptor as returned by open() */
73 typedef int gpfs_file_t
;
78 typedef unsigned int gpfs_uid_t
;
79 typedef long long gpfs_off64_t
;
80 typedef unsigned long long gpfs_uid64_t
;
82 typedef struct gpfs_timestruc
88 typedef struct gpfs_timestruc64
94 #define GPFS_SLITE_SIZE_BIT 0x00000001
95 #define GPFS_SLITE_BLKSIZE_BIT 0x00000002
96 #define GPFS_SLITE_BLOCKS_BIT 0x00000004
97 #define GPFS_SLITE_ATIME_BIT 0x00000010
98 #define GPFS_SLITE_MTIME_BIT 0x00000020
99 #define GPFS_SLITE_CTIME_BIT 0x00000040
100 #define GPFS_SLITE_EXACT_BITS 0x00000077
102 /* Returns "1" if the attribute is requested to be accurate.
103 (On output, indicates the value returned in statbufP is accurate). */
104 #define GPFS_SLITE(m) (0 == (m))
105 #define GPFS_SLITE_SIZET(m) (0 != ((m) & GPFS_SLITE_SIZE_BIT))
106 #define GPFS_SLITE_BLKSIZE(m) (0 != ((m) & GPFS_SLITE_BLKSIZE_BIT))
107 #define GPFS_SLITE_BLOCKS(m) (0 != ((m) & GPFS_SLITE_BLOCKS_BIT))
108 #define GPFS_SLITE_ATIME(m) (0 != ((m) & GPFS_SLITE_ATIME_BIT))
109 #define GPFS_SLITE_MTIME(m) (0 != ((m) & GPFS_SLITE_MTIME_BIT))
110 #define GPFS_SLITE_CTIME(m) (0 != ((m) & GPFS_SLITE_CTIME_BIT))
111 #define GPFS_SLITE_EXACT(m) (GPFS_SLITE_EXACT_BITS == (m))
113 /* Sets the litemask bit indicating that the attribute should be accurate */
114 #define GPFS_S_SLITE(m) (m) = 0
115 #define GPFS_S_SLITE_SIZET(m) (m) |= GPFS_SLITE_SIZE_BIT
116 #define GPFS_S_SLITE_BLKSIZE(m) (m) |= GPFS_SLITE_BLKSIZE_BIT
117 #define GPFS_S_SLITE_BLOCKS(m) (m) |= GPFS_SLITE_BLOCKS_BIT
118 #define GPFS_S_SLITE_ATIME(m) (m) |= GPFS_SLITE_ATIME_BIT
119 #define GPFS_S_SLITE_MTIME(m) (m) |= GPFS_SLITE_MTIME_BIT
120 #define GPFS_S_SLITE_CTIME(m) (m) |= GPFS_SLITE_CTIME_BIT
121 #define GPFS_S_SLITE_EXACT(m) (m) |= GPFS_SLITE_EXACT_BITS
123 #define GPFS_STATLITE 0
124 #define GPFS_NOFOLLOW 1
126 /* Mapping of buffer for gpfs_getacl, gpfs_putacl. */
127 typedef struct gpfs_opaque_acl
129 int acl_buffer_len
; /* INPUT: Total size of buffer (including this field).
130 OUTPUT: Actual size of the ACL information. */
131 unsigned short acl_version
; /* INPUT: Set to zero.
132 OUTPUT: Current version of the returned ACL. */
133 unsigned char acl_type
; /* INPUT: Type of ACL: access (1) or default (2). */
134 char acl_var_data
[1]; /* OUTPUT: Remainder of the ACL information. */
137 /* ACL types (acl_type field in gpfs_opaque_acl_t or gpfs_acl_t) */
138 #define GPFS_ACL_TYPE_ACCESS 1
139 #define GPFS_ACL_TYPE_DEFAULT 2
140 #define GPFS_ACL_TYPE_NFS4 3
142 /* gpfs_getacl, gpfs_putacl flag indicating structures instead of the
143 opaque style data normally used. */
144 #define GPFS_GETACL_STRUCT 0x00000020
145 #define GPFS_PUTACL_STRUCT 0x00000020
147 /* gpfs_getacl, gpfs_putacl flag indicating smbd is the caller */
148 #define GPFS_ACL_SAMBA 0x00000040
150 /* Defined values for gpfs_aclVersion_t */
151 #define GPFS_ACL_VERSION_POSIX 1
152 #define GPFS_ACL_VERSION_NFS4F 3 /* GPFS_ACL_VERSION_NFS4 plus V4FLAGS */
153 #define GPFS_ACL_VERSION_NFS4 4
155 /* Values for gpfs_aclLevel_t */
156 #define GPFS_ACL_LEVEL_BASE 0 /* compatible with all acl_version values */
157 #define GPFS_ACL_LEVEL_V4FLAGS 1 /* requires GPFS_ACL_VERSION_NFS4 */
159 /* Values for gpfs_aceType_t (ACL_VERSION_POSIX) */
160 #define GPFS_ACL_USER_OBJ 1
161 #define GPFS_ACL_GROUP_OBJ 2
162 #define GPFS_ACL_OTHER 3
163 #define GPFS_ACL_MASK 4
164 #define GPFS_ACL_USER 5
165 #define GPFS_ACL_GROUP 6
167 /* Values for gpfs_acePerm_t (ACL_VERSION_POSIX) */
168 #define ACL_PERM_EXECUTE 001
169 #define ACL_PERM_WRITE 002
170 #define ACL_PERM_READ 004
171 #define ACL_PERM_CONTROL 010
173 /* Values for gpfs_aceType_t (ACL_VERSION_NFS4) */
174 #define ACE4_TYPE_ALLOW 0
175 #define ACE4_TYPE_DENY 1
176 #define ACE4_TYPE_AUDIT 2
177 #define ACE4_TYPE_ALARM 3
179 /* Values for gpfs_aceFlags_t (ACL_VERSION_NFS4) */
180 #define ACE4_FLAG_FILE_INHERIT 0x00000001
181 #define ACE4_FLAG_DIR_INHERIT 0x00000002
182 #define ACE4_FLAG_NO_PROPAGATE 0x00000004
183 #define ACE4_FLAG_INHERIT_ONLY 0x00000008
184 #define ACE4_FLAG_SUCCESSFUL 0x00000010
185 #define ACE4_FLAG_FAILED 0x00000020
186 #define ACE4_FLAG_GROUP_ID 0x00000040
187 #define ACE4_FLAG_INHERITED 0x00000080
189 /* GPFS-defined flags. Placed in a separate ACL field to avoid
190 ever running into newly defined NFSv4 flags. */
191 #define ACE4_IFLAG_SPECIAL_ID 0x80000000
193 /* Values for gpfs_aceMask_t (ACL_VERSION_NFS4) */
194 #define ACE4_MASK_READ 0x00000001
195 #define ACE4_MASK_LIST_DIR 0x00000001
196 #define ACE4_MASK_WRITE 0x00000002
197 #define ACE4_MASK_ADD_FILE 0x00000002
198 #define ACE4_MASK_APPEND 0x00000004
199 #define ACE4_MASK_ADD_SUBDIR 0x00000004
200 #define ACE4_MASK_READ_NAMED 0x00000008
201 #define ACE4_MASK_WRITE_NAMED 0x00000010
202 #define ACE4_MASK_EXECUTE 0x00000020
204 /* The rfc doesn't provide a mask equivalent to "search" ("x" on a
205 * directory in posix), but it also doesn't say that its EXECUTE
206 * is to have this dual use (even though it does so for other dual
207 * use permissions such as read/list. Going to make the assumption
208 * here that the EXECUTE bit has this dual meaning... otherwise
209 * we're left with no control over search.
211 #define ACE4_MASK_SEARCH 0x00000020
213 #define ACE4_MASK_DELETE_CHILD 0x00000040
214 #define ACE4_MASK_READ_ATTR 0x00000080
215 #define ACE4_MASK_WRITE_ATTR 0x00000100
216 #define ACE4_MASK_DELETE 0x00010000
217 #define ACE4_MASK_READ_ACL 0x00020000
218 #define ACE4_MASK_WRITE_ACL 0x00040000
219 #define ACE4_MASK_WRITE_OWNER 0x00080000
220 #define ACE4_MASK_SYNCHRONIZE 0x00100000
221 #define ACE4_MASK_ALL 0x001f01ff
223 /* Values for gpfs_uid_t (ACL_VERSION_NFS4) */
224 #define ACE4_SPECIAL_OWNER 1
225 #define ACE4_SPECIAL_GROUP 2
226 #define ACE4_SPECIAL_EVERYONE 3
228 /* per-ACL flags imported from a Windows security descriptor object */
229 #define ACL4_FLAG_OWNER_DEFAULTED 0x00000100
230 #define ACL4_FLAG_GROUP_DEFAULTED 0x00000200
231 #define ACL4_FLAG_DACL_PRESENT 0x00000400
232 #define ACL4_FLAG_DACL_DEFAULTED 0x00000800
233 #define ACL4_FLAG_SACL_PRESENT 0x00001000
234 #define ACL4_FLAG_SACL_DEFAULTED 0x00002000
235 #define ACL4_FLAG_DACL_UNTRUSTED 0x00004000
236 #define ACL4_FLAG_SERVER_SECURITY 0x00008000
237 #define ACL4_FLAG_DACL_AUTO_INHERIT_REQ 0x00010000
238 #define ACL4_FLAG_SACL_AUTO_INHERIT_REQ 0x00020000
239 #define ACL4_FLAG_DACL_AUTO_INHERITED 0x00040000
240 #define ACL4_FLAG_SACL_AUTO_INHERITED 0x00080000
241 #define ACL4_FLAG_DACL_PROTECTED 0x00100000
242 #define ACL4_FLAG_SACL_PROTECTED 0x00200000
243 #define ACL4_FLAG_RM_CONTROL_VALID 0x00400000
244 #define ACL4_FLAG_NULL_DACL 0x00800000
245 #define ACL4_FLAG_NULL_SACL 0x01000000
246 #define ACL4_FLAG_VALID_FLAGS 0x01ffff00
249 /* Externalized ACL defintions */
250 typedef unsigned int gpfs_aclType_t
;
251 typedef unsigned int gpfs_aclLen_t
;
252 typedef unsigned int gpfs_aclLevel_t
;
253 typedef unsigned int gpfs_aclVersion_t
;
254 typedef unsigned int gpfs_aclCount_t
;
255 typedef unsigned int gpfs_aclFlag_t
;
257 typedef unsigned int gpfs_aceType_t
;
258 typedef unsigned int gpfs_aceFlags_t
;
259 typedef unsigned int gpfs_acePerm_t
;
260 typedef unsigned int gpfs_aceMask_t
;
262 /* A POSIX ACL Entry */
263 typedef struct gpfs_ace_v1
265 gpfs_aceType_t ace_type
; /* POSIX ACE type */
266 gpfs_uid_t ace_who
; /* uid/gid */
267 gpfs_acePerm_t ace_perm
; /* POSIX permissions */
270 /* An NFSv4 ACL Entry */
271 typedef struct gpfs_ace_v4
273 gpfs_aceType_t aceType
; /* Allow or Deny */
274 gpfs_aceFlags_t aceFlags
; /* Inherit specifications, etc. */
275 gpfs_aceFlags_t aceIFlags
; /* GPFS Internal flags */
276 gpfs_aceMask_t aceMask
; /* NFSv4 mask specification */
277 gpfs_uid_t aceWho
; /* User/Group identification */
280 /* when GPFS_ACL_VERSION_NFS4, and GPFS_ACL_LEVEL_V4FLAGS */
281 typedef struct v4Level1_ext
/* ACL extension */
283 gpfs_aclFlag_t acl_flags
; /* per-ACL flags */
284 gpfs_ace_v4_t ace_v4
[1];
288 typedef struct gpfs_acl
290 gpfs_aclLen_t acl_len
; /* Total length of this ACL in bytes */
291 gpfs_aclLevel_t acl_level
; /* Reserved (must be zero) */
292 gpfs_aclVersion_t acl_version
; /* POSIX or NFS4 ACL */
293 gpfs_aclType_t acl_type
; /* Access, Default, or NFS4 */
294 gpfs_aclCount_t acl_nace
; /* Number of Entries that follow */
297 gpfs_ace_v1_t ace_v1
[1]; /* when GPFS_ACL_VERSION_POSIX */
298 gpfs_ace_v4_t ace_v4
[1]; /* when GPFS_ACL_VERSION_NFS4 */
299 v4Level1_t v4Level1
; /* when GPFS_ACL_LEVEL_V4FLAGS */
304 /* NAME: gpfs_getacl()
306 * FUNCTION: Retrieves the ACL information for a file.
308 * The aclP parameter must point to a buffer mapped by either:
309 * - gpfs_opaque_acl_t (when flags are zero). In this case,
310 * the opaque data that is intended to be used by a backup
311 * program (restoreed by passing this data back on a subsequent
312 * call to gpfs_putacl).
313 * - gpfs_acl_t (when GPFS_GETACL_STRUCT is specified). In this
314 * case, the data can be interpreted by the calling application
315 * (and may be modified and applied to the file by passing it
316 * to gpfs_putacl...along with the GPFS_PUTACL_STRUCT flag).
318 * On input, the first four bytes of the buffer must contain its
321 * Returns: 0 Successful
324 * Errno: ENOSYS function not available
325 * ENOSPC buffer too small to return the entire ACL.
326 * Needed size is returned in the first four
327 * bytes of the buffer pointed to by aclP.
328 * EINVAL Invalid arguments
329 * ENOTDIR Not on directory
330 * ENOMEM Out of memory
333 gpfs_getacl(const char *pathname
,
338 gpfs_getacl_fd(gpfs_file_t fileDesc
,
343 /* NAME: gpfs_putacl()
345 * FUNCTION: Sets the ACL information for a file.
346 * The buffer passed in should contain the ACL data
347 * that was obtained by a previous call to gpfs_getacl.
349 * Returns: 0 Successful
352 * Errno: ENOSYS function not available
353 * EINVAL Invalid arguments
354 * ENOTDIR Not on directory
355 * ENOMEM Out of memory
356 * EPERM Caller does not hold appropriate privilege
359 gpfs_putacl(const char *pathname
,
364 gpfs_putacl_fd(gpfs_file_t fileDesc
,
369 /* NAME: gpfs_prealloc()
371 * FUNCTION: Preallocate disk storage for a file or directory, starting
372 * at the specified startOffset and covering at least the number
373 * of bytes requested by bytesToPrealloc. Allocations are rounded
374 * to block boundaries (block size can be found in st_blksize
375 * returned by fstat()), or possibly larger sizes. For files, the
376 * file descriptor must be open for write, but any existing data
377 * already present will not be modified. Reading the preallocated
378 * blocks will return zeros. For directories, the file descriptor
379 * may be open for read but the caller must have write permission,
380 * and existing entries are unaffected; startOffset must be zero.
382 * This function implements the behavior of mmchattr when invoked
383 * with --compact[=minimumEntries]. The minimumEntries value
384 * specifies both the lower bound on automatic compaction and the
385 * desired size for pre-allocation. It defaults to zero, meaning
386 * no pre-allocation and compact the directory as much as
387 * possible. The mapping between minimumEntries and the
388 * bytesToPrealloc is given by GPFS_PREALLOC_DIR_SLOT_SIZE, see
391 * Directory compaction (zero bytesToPrealloc) requires a file
392 * system supporting V2 directories (format version 1400, v4.1).
393 * Directories created before upgrading the file system to version
394 * 4.1, are upgraded from V1 to V2 by this operation even if no
395 * other change is made. Since v4.2.2, bytesToPrealloc may be
396 * nonzero effecting pre-allocation by setting a minimum
397 * compaction size. Prior to v4.2.2 the minimum size of any
403 * Errno: ENOSYS No prealloc service available
404 * EBADF Bad file descriptor
405 * EINVAL Not a GPFS file
406 * EINVAL Not a regular file or directory
407 * EINVAL Directory pre-allocation not supported
408 * EINVAL startOffset or bytesToPrealloc < 0
409 * EACCES File not opened for writing
410 * EACCES Caller does not have write access to directory.
411 * EDQUOT Quota exceeded
412 * ENOSPC Not enough space on disk
413 * EPERM File is in a snapshot
416 gpfs_prealloc(gpfs_file_t fileDesc
,
417 gpfs_off64_t startOffset
,
418 gpfs_off64_t bytesToPrealloc
);
420 /* Directory entries are nominally (assuming compact names of 19 bytes or less)
421 32 bytes in size. This conversion factor is used in mapping between a
422 number of entries (for mmchattr) and a size when calling gpfs_prealloc. */
423 #define GPFS_PREALLOC_DIR_SLOT_SIZE 32 /* for size => bytes per entry */
426 typedef struct gpfs_winattr
428 gpfs_timestruc_t creationTime
;
429 unsigned int winAttrs
; /* values as defined below */
432 /* winAttrs values */
433 #define GPFS_WINATTR_ARCHIVE 0x0001
434 #define GPFS_WINATTR_COMPRESSED 0x0002
435 #define GPFS_WINATTR_DEVICE 0x0004
436 #define GPFS_WINATTR_DIRECTORY 0x0008
437 #define GPFS_WINATTR_ENCRYPTED 0x0010
438 #define GPFS_WINATTR_HIDDEN 0x0020
439 #define GPFS_WINATTR_NORMAL 0x0040
440 #define GPFS_WINATTR_NOT_CONTENT_INDEXED 0x0080
441 #define GPFS_WINATTR_OFFLINE 0x0100
442 #define GPFS_WINATTR_READONLY 0x0200
443 #define GPFS_WINATTR_REPARSE_POINT 0x0400
444 #define GPFS_WINATTR_SPARSE_FILE 0x0800
445 #define GPFS_WINATTR_SYSTEM 0x1000
446 #define GPFS_WINATTR_TEMPORARY 0x2000
447 #define GPFS_WINATTR_HAS_STREAMS 0x4000
450 /* NAME: gpfs_get_winattrs()
451 * gpfs_get_winattrs_path()
453 * FUNCTION: Returns gpfs_winattr_t attributes
458 * Errno: ENOENT file not found
459 * EBADF Bad file handle, not a GPFS file
460 * ENOMEM Memory allocation failed
461 * EACCESS Permission denied
462 * EFAULT Bad address provided
463 * EINVAL Not a regular file
464 * ENOSYS function not available
467 gpfs_get_winattrs(gpfs_file_t fileDesc
, gpfs_winattr_t
*attrP
);
470 gpfs_get_winattrs_path(const char *pathname
, gpfs_winattr_t
*attrP
);
473 /* NAME: gpfs_set_winattrs()
474 * gpfs_set_winattrs_path()
476 * FUNCTION: Sets gpfs_winattr_t attributes (as specified by
482 * Errno: ENOENT file not found
483 * EBADF Bad file handle, not a GPFS file
484 * ENOMEM Memory allocation failed
485 * EACCESS Permission denied
486 * EFAULT Bad address provided
487 * EINVAL Not a regular file
488 * ENOSYS function not available
491 gpfs_set_winattrs(gpfs_file_t fileDesc
, int flags
, gpfs_winattr_t
*attrP
);
494 gpfs_set_winattrs_path(const char *pathname
, int flags
, gpfs_winattr_t
*attrP
);
496 /* gpfs_set_winattr flag values */
497 #define GPFS_WINATTR_SET_CREATION_TIME 0x08
498 #define GPFS_WINATTR_SET_ATTRS 0x10
501 * NAME: gpfs_set_times(), gpfs_set_times_path()
503 * FUNCTION: Sets file access time, modified time, change time,
504 * and/or creation time (as specified by the flags).
506 * Input: flagsfileDesc : file descriptor of the object to set
507 * pathname : path to a file or directory
508 * flag : define time value to set
509 * GPFS_SET_ATIME - set access time
510 * GPFS_SET_MTIME - set mod. time
511 * GPFS_SET_CTIME - set change time
512 * GPFS_SET_CREATION_TIME - set creation time
513 * GPFS_SET_TIME_NO_FOLLOW - don't follow links
514 * times : array to times
516 * Returns: 0 Successful
519 * Errno: ENOSYS function not available
520 * EBADF Not a GPFS File
521 * EINVAL invalid argument
522 * EACCES Permission denied
523 * EROFS Filesystem is read only
524 * ENOENT No such file or directory
526 typedef gpfs_timestruc_t gpfs_times_vector_t
[4];
529 gpfs_set_times(gpfs_file_t fileDesc
, int flags
, gpfs_times_vector_t times
);
532 gpfs_set_times_path(char *pathname
, int flags
, gpfs_times_vector_t times
);
534 /* gpfs_set_times flag values */
535 #define GPFS_SET_ATIME 0x01
536 #define GPFS_SET_MTIME 0x02
537 #define GPFS_SET_CTIME 0x04
538 #define GPFS_SET_CREATION_TIME 0x08
539 #define GPFS_SET_TIME_NO_FOLLOW 0x10
542 /* NAME: gpfs_set_share()
544 * FUNCTION: Acquire shares
546 * Input: fileDesc : file descriptor
547 * allow : share type being requested
548 * GPFS_SHARE_NONE, GPFS_SHARE_READ,
549 * GPFS_SHARE_WRITE, GPFS_SHARE_BOTH
550 * deny : share type to deny to others
551 * GPFS_DENY_NONE, GPFS_DENY_READ,
552 * GPFS_DENY_WRITE, GPFS_DENY_BOTH
557 * Errno: EBADF Bad file handle
558 * EINVAL Bad argument given
559 * EFAULT Bad address provided
560 * ENOMEM Memory allocation failed
561 * EACCES share mode not available
562 * ENOSYS function not available
565 /* allow/deny specifications */
566 #define GPFS_SHARE_NONE 0
567 #define GPFS_SHARE_READ 1
568 #define GPFS_SHARE_WRITE 2
569 #define GPFS_SHARE_BOTH 3
570 #define GPFS_SHARE_ALL 3
571 #define GPFS_DENY_NONE 0
572 #define GPFS_DENY_READ 1
573 #define GPFS_DENY_WRITE 2
574 #define GPFS_DENY_BOTH 3
575 #define GPFS_DENY_DELETE 4
576 #define GPFS_DENY_ALL 7
579 gpfs_set_share(gpfs_file_t fileDesc
,
584 /* NAME: gpfs_set_lease()
586 * FUNCTION: Acquire leases for Samba
588 * Input: fileDesc : file descriptor
589 * leaseType : lease type being requested
590 * GPFS_LEASE_NONE GPFS_LEASE_READ,
596 * Errno: EBADF Bad file handle
597 * EINVAL Bad argument given
598 * EFAULT Bad address provided
599 * ENOMEM Memory allocation failed
600 * EAGAIN lease not available
601 * EACCES permission denied
602 * EOPNOTSUPP unsupported leaseType
603 * ESTALE unmounted file system
604 * ENOSYS function not available
607 /* leaseType specifications */
608 #define GPFS_LEASE_NONE 0
609 #define GPFS_LEASE_READ 1
610 #define GPFS_LEASE_WRITE 2
613 gpfs_set_lease(gpfs_file_t fileDesc
,
614 unsigned int leaseType
);
617 /* NAME: gpfs_get_lease()
619 * FUNCTION: Returns the type of lease currently held
621 * Returns: GPFS_LEASE_READ
625 * Returns: >= 0 Success
631 gpfs_get_lease(gpfs_file_t fileDesc
);
634 /* NAME: gpfs_get_realfilename(), gpfs_get_realfilename_path()
636 * FUNCTION: Interface to get real name of a file.
638 * INPUT: File descriptor, pathname, buffer, bufferlength
639 * OUTPUT: Real file name stored in file system
644 * Errno: EBADF Bad file handle
645 * EINVAL Not a regular file
646 * EFAULT Bad address provided
647 * ENOSPC buffer too small to return the real file name.
648 * Needed size is returned in buflen parameter.
649 * ENOENT File does not exist
650 * ENOMEM Memory allocation failed
651 * EACCESS Permission denied
652 * ENOSYS function not available
655 gpfs_get_realfilename(gpfs_file_t fileDesc
,
660 gpfs_get_realfilename_path(const char *pathname
,
664 /* NAME: gpfs_ftruncate()
666 * FUNCTION: Interface to truncate a file.
668 * INPUT: File descriptor
670 * Returns: 0 Successful
673 * Errno: ENOSYS function not available
674 * EBADF Bad file handle
675 * EBADF Not a GPFS file
676 * EINVAL Not a regular file
677 * ENOENT File does not exist
678 * ENOMEM Memory allocation failed
680 * EACCESS Permission denied
683 gpfs_ftruncate(gpfs_file_t fileDesc
, gpfs_off64_t length
);
685 #define GPFS_WIN_CIFS_REGISTERED 0x02000000
686 typedef struct cifsThreadData_t
688 unsigned int dataLength
; /* Total buffer length */
689 unsigned int share
; /* gpfs_set_share declaration */
690 unsigned int deny
; /* gpfs_set_share specification */
691 unsigned int lease
; /* gpfs_set_lease lease type */
692 unsigned int secInfoFlags
; /* Future use. Must be zero */
693 gpfs_uid_t sdUID
; /* Owning user */
694 gpfs_uid_t sdGID
; /* Owning group */
695 int shareLocked_fd
; /* file descriptor with share locks */
696 unsigned int aclLength
; /* Length of the following ACL */
697 gpfs_acl_t acl
; /* The initial ACL for create/mkdir */
700 /* NAME: gpfs_register_cifs_export()
702 * FUNCTION: Register a CIFS export process.
704 * INPUT: implicit use of the process ids
706 * Returns: 0 Successful
707 * ENOSYS function not available
708 * EACCES cannot establish credentials
709 * ENOMEM temporary shortage of memory
710 * EINVAL prior process/thread registrations exist
711 * EBADF unable to allocate a file descriptor
714 gpfs_register_cifs_export(void);
716 /* NAME: gpfs_unregister_cifs_export()
718 * FUNCTION: remove a registration for a CIFS export
720 * INPUT: implicit use of the process ids
722 * Returns: 0 Successful
723 * ENOSYS function not available
724 * EACCES cannot establish credentials
725 * ENOMEM temporary shortage of memory
728 gpfs_unregister_cifs_export(void);
730 /* NAME: gpfs_register_cifs_buffer()
732 * FUNCTION: Register a CIFS thread/buffer combination
734 * INPUT: implicit use of the process and thread ids
735 * Address of a cifsThreadData_t structure that will include
736 * a GPFS ACL (GPFS_ACL_VERSION_NFS4/GPFS_ACL_LEVEL_V4FLAGS)
737 * that can be applied at file/dir creation.
739 * Returns: 0 Successful
740 * ENOSYS function not available
741 * EACCES cannot establish credentials
742 * ENOMEM unable to allocate required memory
743 * EINVAL no associated process registrion exists
744 * bad dataLength in buffer.
747 gpfs_register_cifs_buffer(cifsThreadData_t
*bufP
);
749 /* NAME: gpfs_unregister_cifs_buffer()
751 * FUNCTION: remove a CIFS thread/buffer registration
753 * INPUT: implicit use of the process and thread ids
755 * Returns: 0 Successful
756 * ENOSYS function not available
757 * EACCES cannot establish credentials
758 * ENOMEM unable to allocate required memory
759 * EINVAL no associated process registrion exists
762 gpfs_unregister_cifs_buffer(void);
764 /* NAME: gpfs_lib_init()
766 * FUNCTION: Open GPFS main module device file
769 * Returns: 0 Successful
772 * Errno: ENOSYS Function not available
775 gpfs_lib_init(int flags
);
777 /* NAME: gpfs_lib_term()
779 * FUNCTION: Close GPFS main module device file
782 * Returns: 0 Successful
785 * Errno: ENOSYS Function not available
788 gpfs_lib_term(int flags
);
790 /* Define maximum length of the name for a GPFS named object, such
791 as a snapshot, storage pool or fileset. The name is a null-terminated
792 character string, which is not include in the max length */
793 #define GPFS_MAXNAMLEN 255
795 /* Define maximum length of the path to a GPFS named object
796 such as a snapshot or fileset. If the absolute path name exceeds
797 this limit, then use a relative path name. The path is a null-terminated
798 character string, which is not included in the max length */
799 #define GPFS_MAXPATHLEN 1023
801 /* ASCII code for "GPFS" in the struct statfs f_type field */
802 #define GPFS_SUPER_MAGIC 0x47504653
804 /* GPFS inode attributes
805 gpfs_uid_t - defined above
806 gpfs_uid64_t - defined above
807 gpfs_off64_t - defined above
809 gpfs_mode_t may include gpfs specific values including 0x02000000
810 To have a gpfs_mode_t be equivalent to a mode_t mask that value out.
812 typedef unsigned int gpfs_mode_t
;
813 typedef unsigned int gpfs_gid_t
;
814 typedef unsigned long long gpfs_gid64_t
;
815 typedef unsigned int gpfs_ino_t
;
816 typedef unsigned long long gpfs_ino64_t
;
817 typedef unsigned int gpfs_gen_t
;
818 typedef unsigned long long gpfs_gen64_t
;
819 typedef unsigned int gpfs_dev_t
;
820 typedef unsigned int gpfs_mask_t
;
821 typedef unsigned int gpfs_pool_t
;
822 typedef unsigned int gpfs_snapid_t
;
823 typedef unsigned long long gpfs_snapid64_t
;
824 typedef unsigned long long gpfs_fsid64_t
[2];
825 typedef short gpfs_nlink_t
;
826 typedef long long gpfs_nlink64_t
;
829 #if defined(WIN32) || defined(_MS_SUA_)
830 typedef struct gpfs_stat64
832 gpfs_dev_t st_dev
; /* id of device containing file */
833 gpfs_ino64_t st_ino
; /* file inode number */
834 gpfs_mode_t st_mode
; /* access mode */
835 gpfs_nlink64_t st_nlink
; /* number of links */
836 unsigned int st_flags
; /* flag word */
837 gpfs_uid64_t st_uid
; /* owner uid */
838 gpfs_gid64_t st_gid
; /* owner gid */
839 gpfs_dev_t st_rdev
; /* device id (if special file) */
840 gpfs_off64_t st_size
; /* file size in bytes */
841 gpfs_timestruc64_t st_atime
; /* time of last access */
842 gpfs_timestruc64_t st_mtime
; /* time of last data modification */
843 gpfs_timestruc64_t st_ctime
; /* time of last status change */
844 int st_blksize
; /* preferred block size for io */
845 gpfs_off64_t st_blocks
; /* 512 byte blocks of disk held by file */
846 long long st_fsid
; /* file system id */
847 unsigned int st_type
; /* file type */
848 gpfs_gen64_t st_gen
; /* inode generation number */
849 gpfs_timestruc64_t st_createtime
; /* time of creation */
850 unsigned int st_attrs
; /* Windows flags */
853 typedef struct stat64 gpfs_stat64_t
;
856 #if defined(WIN32) || defined(_MS_SUA_)
857 typedef struct gpfs_statfs64
859 gpfs_off64_t f_blocks
; /* total data blocks in file system */
860 gpfs_off64_t f_bfree
; /* free block in fs */
861 gpfs_off64_t f_bavail
; /* free blocks avail to non-superuser */
862 int f_bsize
; /* optimal file system block size */
863 gpfs_ino64_t f_files
; /* total file nodes in file system */
864 gpfs_ino64_t f_ffree
; /* free file nodes in fs */
865 gpfs_fsid64_t f_fsid
; /* file system id */
866 int f_fsize
; /* fundamental file system block size */
867 int f_sector_size
; /* logical disk sector size */
868 char f_fname
[32]; /* file system name (usually mount pt.) */
869 char f_fpack
[32]; /* file system pack name */
870 int f_name_max
; /* maximum component name length for posix */
873 typedef struct statfs64 gpfs_statfs64_t
;
876 /* Declarations for backwards compatibility. */
877 typedef gpfs_stat64_t stat64_t
;
878 typedef gpfs_statfs64_t statfs64_t
;
881 /* Define a version number for the directory entry data to allow
882 future changes in this structure. Careful callers should also use
883 the d_reclen field for the size of the structure rather than sizeof,
884 to allow some degree of forward compatibility */
885 #define GPFS_D_VERSION 1
887 typedef struct gpfs_direntx
889 int d_version
; /* this struct's version */
890 unsigned short d_reclen
; /* actual size of this struct including
891 null terminated variable length d_name */
892 unsigned short d_type
; /* Types are defined below */
893 gpfs_ino_t d_ino
; /* File inode number */
894 gpfs_gen_t d_gen
; /* Generation number for the inode */
895 char d_name
[256]; /* null terminated variable length name */
899 #define GPFS_D64_VERSION 2
901 typedef struct gpfs_direntx64
903 int d_version
; /* this struct's version */
904 unsigned short d_reclen
; /* actual size of this struct including
905 null terminated variable length d_name */
906 unsigned short d_type
; /* Types are defined below */
907 gpfs_ino64_t d_ino
; /* File inode number */
908 gpfs_gen64_t d_gen
; /* Generation number for the inode */
909 unsigned int d_flags
; /* Flags are defined below */
910 char d_name
[1028]; /* null terminated variable length name */
911 /* (1020+null+7 byte pad to double word) */
912 /* to handle up to 255 UTF-8 chars */
915 /* File types for d_type field in gpfs_direntx_t */
916 #define GPFS_DE_OTHER 0
917 #define GPFS_DE_FIFO 1
918 #define GPFS_DE_CHR 2
919 #define GPFS_DE_DIR 4
920 #define GPFS_DE_BLK 6
921 #define GPFS_DE_REG 8
922 #define GPFS_DE_LNK 10
923 #define GPFS_DE_SOCK 12
924 #define GPFS_DE_DEL 16
926 /* Define flags for gpfs_direntx64_t */
927 #define GPFS_DEFLAG_NONE 0x0000 /* Default value, no flags set */
928 #define GPFS_DEFLAG_JUNCTION 0x0001 /* DirEnt is a fileset junction */
929 #define GPFS_DEFLAG_IJUNCTION 0x0002 /* DirEnt is a inode space junction */
930 #define GPFS_DEFLAG_ORPHAN 0x0004 /* DirEnt is an orphan (pcache) */
931 #define GPFS_DEFLAG_CLONE 0x0008 /* DirEnt is a clone child */
932 #define GPFS_DEFLAG_OBJECT 0x0010 /* DirEnt is for an AFM Object */
933 #define GPFS_DEFLAG_OBJECT_DIR 0x0020 /* DirEnt is for an AFM Object directory */
935 /* Define a version number for the iattr data to allow future changes
936 in this structure. Careful callers should also use the ia_reclen field
937 for the size of the structure rather than sizeof, to allow some degree
938 of forward compatibility */
939 #define GPFS_IA_VERSION 1
940 #define GPFS_IA64_VERSION 3 /* ver 3 adds ia_repl_xxxx bytes instead of ia_pad2 */
941 #define GPFS_IA64_RESERVED 4
942 #define GPFS_IA64_UNUSED 8
944 typedef struct gpfs_iattr
946 int ia_version
; /* this struct version */
947 int ia_reclen
; /* sizeof this structure */
948 int ia_checksum
; /* validity check on iattr struct */
949 gpfs_mode_t ia_mode
; /* access mode; see gpfs_mode_t comment */
950 gpfs_uid_t ia_uid
; /* owner uid */
951 gpfs_gid_t ia_gid
; /* owner gid */
952 gpfs_ino_t ia_inode
; /* file inode number */
953 gpfs_gen_t ia_gen
; /* inode generation number */
954 gpfs_nlink_t ia_nlink
; /* number of links */
955 short ia_flags
; /* Flags (defined below) */
956 int ia_blocksize
; /* preferred block size for io */
957 gpfs_mask_t ia_mask
; /* Initial attribute mask (not used) */
958 unsigned int ia_pad1
; /* reserved space */
959 gpfs_off64_t ia_size
; /* file size in bytes */
960 gpfs_off64_t ia_blocks
; /* 512 byte blocks of disk held by file */
961 gpfs_timestruc_t ia_atime
; /* time of last access */
962 gpfs_timestruc_t ia_mtime
; /* time of last data modification */
963 gpfs_timestruc_t ia_ctime
; /* time of last status change */
964 gpfs_dev_t ia_rdev
; /* id of device */
965 unsigned int ia_xperm
; /* extended attributes (defined below) */
966 unsigned int ia_modsnapid
; /* snapshot id of last modification */
967 unsigned int ia_filesetid
; /* fileset ID */
968 unsigned int ia_datapoolid
; /* storage pool ID for data */
969 unsigned int ia_pad2
; /* reserved space */
973 typedef struct gpfs_iattr64
975 int ia_version
; /* this struct version */
976 int ia_reclen
; /* sizeof this structure */
977 int ia_checksum
; /* validity check on iattr struct */
978 gpfs_mode_t ia_mode
; /* access mode; see gpfs_mode_t comment */
979 gpfs_uid64_t ia_uid
; /* owner uid */
980 gpfs_gid64_t ia_gid
; /* owner gid */
981 gpfs_ino64_t ia_inode
; /* file inode number */
982 gpfs_gen64_t ia_gen
; /* inode generation number */
983 gpfs_nlink64_t ia_nlink
; /* number of links */
984 gpfs_off64_t ia_size
; /* file size in bytes */
985 gpfs_off64_t ia_blocks
; /* 512 byte blocks of disk held by file */
986 gpfs_timestruc64_t ia_atime
; /* time of last access */
987 unsigned int ia_winflags
; /* windows flags (defined below) */
988 unsigned int ia_pad1
; /* reserved space */
989 gpfs_timestruc64_t ia_mtime
; /* time of last data modification */
990 unsigned int ia_flags
; /* flags (defined below) */
991 /* next four bytes were ia_pad2 */
992 unsigned char ia_repl_data
; /* data replication factor */
993 unsigned char ia_repl_data_max
; /* data replication max factor */
994 unsigned char ia_repl_meta
; /* meta data replication factor */
995 unsigned char ia_repl_meta_max
; /* meta data replication max factor */
996 gpfs_timestruc64_t ia_ctime
; /* time of last status change */
997 int ia_blocksize
; /* preferred block size for io */
998 unsigned int ia_pad3
; /* reserved space */
999 gpfs_timestruc64_t ia_createtime
; /* creation time */
1000 gpfs_mask_t ia_mask
; /* initial attribute mask (not used) */
1001 int ia_pad4
; /* reserved space */
1002 unsigned int ia_reserved
[GPFS_IA64_RESERVED
]; /* reserved space */
1003 unsigned int ia_xperm
; /* extended attributes (defined below) */
1004 gpfs_dev_t ia_dev
; /* id of device containing file */
1005 gpfs_dev_t ia_rdev
; /* device id (if special file) */
1006 unsigned int ia_pcacheflags
; /* pcache inode bits */
1007 gpfs_snapid64_t ia_modsnapid
; /* snapshot id of last modification */
1008 unsigned int ia_filesetid
; /* fileset ID */
1009 unsigned int ia_datapoolid
; /* storage pool ID for data */
1010 gpfs_ino64_t ia_inode_space_mask
; /* inode space mask of this file system */
1011 /* This value is saved in the iattr structure
1012 during backup and used during restore */
1013 gpfs_off64_t ia_dirminsize
; /* dir pre-allocation size in bytes */
1014 unsigned int ia_unused
[GPFS_IA64_UNUSED
]; /* reserved space */
1017 /* Define flags for inode attributes */
1018 #define GPFS_IAFLAG_SNAPDIR 0x0001 /* (obsolete) */
1019 #define GPFS_IAFLAG_USRQUOTA 0x0002 /* inode is a user quota file */
1020 #define GPFS_IAFLAG_GRPQUOTA 0x0004 /* inode is a group quota file */
1021 #define GPFS_IAFLAG_ERROR 0x0008 /* error reading inode */
1022 /* Define flags for inode replication attributes */
1023 #define GPFS_IAFLAG_FILESET_ROOT 0x0010 /* root dir of a fileset */
1024 #define GPFS_IAFLAG_NO_SNAP_RESTORE 0x0020 /* don't restore from snapshots */
1025 #define GPFS_IAFLAG_FILESETQUOTA 0x0040 /* inode is a fileset quota file */
1026 #define GPFS_IAFLAG_COMANAGED 0x0080 /* file data is co-managed */
1027 #define GPFS_IAFLAG_ILLPLACED 0x0100 /* may not be properly placed */
1028 #define GPFS_IAFLAG_REPLMETA 0x0200 /* metadata replication set */
1029 #define GPFS_IAFLAG_REPLDATA 0x0400 /* data replication set */
1030 #define GPFS_IAFLAG_EXPOSED 0x0800 /* may have data on suspended disks */
1031 #define GPFS_IAFLAG_ILLREPLICATED 0x1000 /* may not be properly replicated */
1032 #define GPFS_IAFLAG_UNBALANCED 0x2000 /* may not be properly balanced */
1033 #define GPFS_IAFLAG_DATAUPDATEMISS 0x4000 /* has stale data blocks on
1035 #define GPFS_IAFLAG_METAUPDATEMISS 0x8000 /* has stale metadata on
1038 #define GPFS_IAFLAG_IMMUTABLE 0x00010000 /* Immutability */
1039 #define GPFS_IAFLAG_INDEFRETENT 0x00020000 /* Indefinite retention */
1040 #define GPFS_IAFLAG_SECUREDELETE 0x00040000 /* Secure deletion */
1042 #define GPFS_IAFLAG_TRUNCMANAGED 0x00080000 /* dmapi truncate event enabled */
1043 #define GPFS_IAFLAG_READMANAGED 0x00100000 /* dmapi read event enabled */
1044 #define GPFS_IAFLAG_WRITEMANAGED 0x00200000 /* dmapi write event enabled */
1046 #define GPFS_IAFLAG_APPENDONLY 0x00400000 /* AppendOnly only */
1047 #define GPFS_IAFLAG_DELETED 0x00800000 /* inode has been deleted */
1048 #define GPFS_IAFLAG_ILLCOMPRESSED 0x01000000 /* may not be properly compressed */
1049 #define GPFS_IAFLAG_FPOILLPLACED 0x02000000 /* may not be properly placed per
1050 FPO attributes (bgf, wad, wadfg) */
1051 #define GPFS_IAFLAG_OBJECT 0x04000000 /* Object directory entry */
1052 #define GPFS_IAFLAG_OBJECT_DIR 0x08000000 /* Object directory */
1054 /* Define flags for window's attributes */
1055 #define GPFS_IWINFLAG_ARCHIVE 0x0001 /* Archive */
1056 #define GPFS_IWINFLAG_HIDDEN 0x0002 /* Hidden */
1057 #define GPFS_IWINFLAG_NOTINDEXED 0x0004 /* Not content indexed */
1058 #define GPFS_IWINFLAG_OFFLINE 0x0008 /* Off-line */
1059 #define GPFS_IWINFLAG_READONLY 0x0010 /* Read-only */
1060 #define GPFS_IWINFLAG_REPARSE 0x0020 /* Reparse point */
1061 #define GPFS_IWINFLAG_SYSTEM 0x0040 /* System */
1062 #define GPFS_IWINFLAG_TEMPORARY 0x0080 /* Temporary */
1063 #define GPFS_IWINFLAG_COMPRESSED 0x0100 /* Compressed */
1064 #define GPFS_IWINFLAG_ENCRYPTED 0x0200 /* Encrypted */
1065 #define GPFS_IWINFLAG_SPARSE 0x0400 /* Sparse file */
1066 #define GPFS_IWINFLAG_HASSTREAMS 0x0800 /* Has streams */
1068 /* Define flags for extended attributes */
1069 #define GPFS_IAXPERM_ACL 0x0001 /* file has acls */
1070 #define GPFS_IAXPERM_XATTR 0x0002 /* file has extended attributes */
1071 #define GPFS_IAXPERM_DMATTR 0x0004 /* file has dm attributes */
1072 #define GPFS_IAXPERM_DOSATTR 0x0008 /* file has non-default dos attrs */
1073 #define GPFS_IAXPERM_RPATTR 0x0010 /* file has restore policy attrs */
1075 /* Define flags for pcache bits defined in the inode */
1076 #define GPFS_ICAFLAG_CACHED 0x0001 /* "cached complete" */
1077 #define GPFS_ICAFLAG_CREATE 0x0002 /* "created" */
1078 #define GPFS_ICAFLAG_DIRTY 0x0004 /* "data dirty" */
1079 #define GPFS_ICAFLAG_LINK 0x0008 /* "hard linked" */
1080 #define GPFS_ICAFLAG_SETATTR 0x0010 /* "attr changed" */
1081 #define GPFS_ICAFLAG_LOCAL 0x0020 /* "local" */
1082 #define GPFS_ICAFLAG_APPEND 0x0040 /* "append" */
1083 #define GPFS_ICAFLAG_STATE 0x0080 /* "has remote state" */
1085 /* Define pointers to interface types */
1086 typedef struct gpfs_fssnap_handle gpfs_fssnap_handle_t
;
1087 typedef struct gpfs_iscan gpfs_iscan_t
;
1088 typedef struct gpfs_ifile gpfs_ifile_t
;
1089 typedef struct gpfs_restore gpfs_restore_t
;
1091 typedef struct gpfs_fssnap_id
1097 /* Define extended return codes for gpfs backup & restore
1098 calls without an explicit return code will return the value in errno */
1099 #define GPFS_NEW_ERRNO_BASE 185
1100 #define GPFS_E_INVAL_INUM (GPFS_NEW_ERRNO_BASE+0) /* invalid inode number */
1102 #define GPFS_ERRNO_BASE 190
1103 #define GPFS_E_INVAL_FSSNAPID (GPFS_ERRNO_BASE+0) /* invalid fssnap id */
1104 #define GPFS_E_INVAL_ISCAN (GPFS_ERRNO_BASE+1) /* invalid iscan pointer */
1105 #define GPFS_E_INVAL_IFILE (GPFS_ERRNO_BASE+2) /* invalid ifile pointer */
1106 #define GPFS_E_INVAL_IATTR (GPFS_ERRNO_BASE+3) /* invalid iattr structure */
1107 #define GPFS_E_INVAL_RESTORE (GPFS_ERRNO_BASE+4) /* invalid restore pointer */
1108 #define GPFS_E_INVAL_FSSNAPHANDLE (GPFS_ERRNO_BASE+5) /* invalid fssnap handle */
1109 #define GPFS_E_INVAL_SNAPNAME (GPFS_ERRNO_BASE+6) /* invalid snapshot name */
1110 #define GPFS_E_FS_NOT_RESTORABLE (GPFS_ERRNO_BASE+7) /* FS is not clean */
1111 #define GPFS_E_RESTORE_NOT_ENABLED (GPFS_ERRNO_BASE+8) /* Restore was not enabled */
1112 #define GPFS_E_RESTORE_STARTED (GPFS_ERRNO_BASE+9) /* Restore is running */
1113 #define GPFS_E_INVAL_XATTR (GPFS_ERRNO_BASE+10) /* invalid extended
1114 attribute pointer */
1116 /* Define flags parameter for get/put file attributes.
1117 Used by gpfs_fgetattr, gpfs_fputattr, gpfs_fputattrwithpath
1118 gpfs_igetattrsx, gpfs_iputattrsx
1119 and gpfs_lwe_getattrs, gpfs_lwe_putattrs
1121 #define GPFS_ATTRFLAG_DEFAULT 0x0000 /* default behavior */
1122 #define GPFS_ATTRFLAG_NO_PLACEMENT 0x0001 /* exclude file placement attributes */
1123 #define GPFS_ATTRFLAG_IGNORE_POOL 0x0002 /* saved poolid is not valid */
1124 #define GPFS_ATTRFLAG_USE_POLICY 0x0004 /* use restore policy rules to
1126 #define GPFS_ATTRFLAG_INCL_DMAPI 0x0008 /* Include dmapi attributes */
1127 #define GPFS_ATTRFLAG_FINALIZE_ATTRS 0x0010 /* Finalize immutability attributes */
1128 #define GPFS_ATTRFLAG_SKIP_IMMUTABLE 0x0020 /* Skip immutable attributes */
1129 #define GPFS_ATTRFLAG_INCL_ENCR 0x0040 /* Include encryption attributes */
1130 #define GPFS_ATTRFLAG_SKIP_CLONE 0x0080 /* Skip clone attributes */
1131 #define GPFS_ATTRFLAG_MODIFY_CLONEPARENT 0x0100 /* Allow modification on clone parent */
1132 #define GPFS_ATTRFLAG_NO_COMPRESSED 0x0200 /* exclude "compressed" attribute */
1133 #define GPFS_ATTRFLAG_SKIP_COMPRESSION 0x0400 /* Skip compression attribute */
1135 /* Define structure used by gpfs_statfspool */
1136 typedef struct gpfs_statfspool_s
1138 gpfs_off64_t f_blocks
; /* total data blocks in pool */
1139 gpfs_off64_t f_bfree
; /* free blocks in pool */
1140 gpfs_off64_t f_bavail
; /* free blocks avail to non-superuser */
1141 gpfs_off64_t f_mblocks
; /* total metadata blocks in pool */
1142 gpfs_off64_t f_mfree
; /* free blocks avail for system metadata */
1143 int f_bsize
; /* optimal storage pool block size */
1144 int f_files
; /* total file nodes assigned to pool */
1145 gpfs_pool_t f_poolid
; /* storage pool id */
1146 int f_fsize
; /* fundamental file system block size */
1147 unsigned int f_usage
; /* data and/or metadata stored in pool */
1148 int f_replica
; /* replica */
1149 int f_bgf
; /* block group factor */
1150 int f_wad
; /* write affinity depth */
1151 int f_allowWriteAffinity
; /* allow write affinity depth. 1 means yes */
1152 int f_reserved
[3];/* Current unused and set to zero */
1153 } gpfs_statfspool_t
;
1155 #define STATFSPOOL_USAGE_DATA 0x0001 /* Pool stores user data */
1156 #define STATFSPOOL_USAGE_METADATA 0x0002 /* Pool stores system metadata */
1159 /* NAME: gpfs_fstat(), gpfs_stat()
1161 * FUNCTION: Get exact stat information for a file descriptor (or filename).
1162 * Forces all other nodes to flush dirty data and metadata to disk.
1163 * Returns: 0 Successful
1166 * Errno: ENOSYS The gpfs_fstat() (or) gpfs_stat() subroutine is not supported
1167 * under the current file system format
1168 * EBADF The file descriptor is not valid.
1169 * EINVAL The file descriptor does not refer to a GPFS file or a
1171 * ESTALE The cached file system information was not valid.
1174 gpfs_fstat(gpfs_file_t fileDesc
,
1175 gpfs_stat64_t
*buffer
);
1178 gpfs_stat(const char *pathname
, /* File pathname */
1179 gpfs_stat64_t
*buffer
);
1181 /* NAME: gpfs_fstat_x(), gpfs_stat_x()
1183 * FUNCTION: Returns extended stat() information with specified accuracy
1184 * for a file descriptor (or filename)
1186 * Input: fileDesc : file descriptor or handle
1187 * pathname : path to a file or directory
1188 * iattrBufLen : length of iattr buffer
1190 * In/Out: st_litemaskP: bitmask specification of required accuracy
1191 * iattr : buffer for returned stat information
1193 * Returns: 0 Successful
1196 * Errno: ENOSYS function not available
1197 * ENOENT invalid pathname
1198 * EBADF Bad file desc
1199 * EINVAL Not a GPFS file
1200 * ESTALE cached fs information was invalid
1203 gpfs_fstat_x(gpfs_file_t fileDesc
,
1204 unsigned int *st_litemaskP
,
1205 gpfs_iattr64_t
*iattr
,
1206 size_t iattrBufLen
);
1209 gpfs_stat_x(const char *pathname
, /* File pathname */
1210 unsigned int *st_litemaskP
,
1211 gpfs_iattr64_t
*iattr
,
1212 size_t iattrBufLen
);
1214 /* NAME: gpfs_statfs64()
1216 * FUNCTION: Get information about the file system.
1218 * Returns: 0 Successful
1221 * Errno: ENOSYS function not available
1222 * EBADF Bad file desc
1223 * EINVAL Not a GPFS file
1224 * ESTALE cached fs information was invalid
1227 gpfs_statfs64(const char *pathname
, /* File pathname */
1228 gpfs_statfs64_t
*buffer
);
1230 /* NAME: gpfs_statlite()
1231 * gpfs_lstatlite() - do not follow a symlink at the end of the path
1233 * FUNCTION: Returns stat() information with specified accuracy
1235 * Input: pathname : path to a file or directory
1237 * In/Out: st_litemaskP: bitmask specification of required accuracy
1238 * statbufP : buffer for returned stat information
1240 * Returns: 0 Successful
1243 * Errno: Specific error indication
1248 gpfs_statlite(const char *pathname
,
1249 unsigned int *st_litemaskP
,
1250 gpfs_stat64_t
*statbufP
);
1253 gpfs_lstatlite(const char *pathname
,
1254 unsigned int *st_litemaskP
,
1255 gpfs_stat64_t
*statbufP
);
1258 /* NAME: gpfs_fgetattrs()
1260 * FUNCTION: Retrieves all extended file attributes in opaque format.
1261 * This function together with gpfs_fputattrs is intended for
1262 * use by a backup program to save (gpfs_fgetattrs) and
1263 * restore (gpfs_fputattrs) all extended file attributes
1264 * (ACLs, user attributes, ...) in one call.
1266 * NOTE: This call does not return extended attributes used for
1267 * the Data Storage Management (XDSM) API (aka DMAPI).
1269 * Input: flags Define behavior of get attributes
1270 * GPFS_ATTRFLAG_NO_PLACEMENT - file attributes for placement
1271 * are not saved, neither is the current storage pool.
1272 * GPFS_ATTRFLAG_IGNORE_POOL - file attributes for placement
1273 * are saved, but the current storage pool is not.
1275 * Returns: 0 Successful
1278 * Errno: ENOSYS function not available
1279 * EINVAL Not a GPFS file
1280 * EINVAL invalid flags provided
1281 * ENOSPC buffer too small to return all attributes
1282 * *attrSizeP will be set to the size necessary
1285 gpfs_fgetattrs(gpfs_file_t fileDesc
,
1292 /* NAME: gpfs_fputattrs()
1294 * FUNCTION: Sets all extended file attributes of a file
1295 * and sets the file's storage pool and data replication
1296 * to the values saved in the extended attributes.
1298 * If the saved storage pool is not valid or if the IGNORE_POOL
1299 * flag is set, then it will select the storage pool by matching
1300 * a PLACEMENT rule using the saved file attributes.
1301 * If it fails to match a placement rule or if there are
1302 * no placement rules installed it will assign the file
1303 * to the "system" storage pool.
1305 * The buffer passed in should contain extended attribute data
1306 * that was obtained by a previous call to gpfs_fgetattrs.
1308 * Input: flags Define behavior of put attributes
1309 * GPFS_ATTRFLAG_NO_PLACEMENT - file attributes are restored
1310 * but the storage pool and data replication are unchanged
1311 * GPFS_ATTRFLAG_IGNORE_POOL - file attributes are restored
1312 * but the storage pool and data replication are selected
1313 * by matching the saved attributes to a placement rule
1314 * instead of restoring the saved storage pool.
1316 * Returns: 0 Successful
1319 * Errno: ENOSYS function not available
1320 * EINVAL Not a GPFS file
1321 * EINVAL the buffer does not contain valid attribute data
1322 * EINVAL invalid flags provided
1325 gpfs_fputattrs(gpfs_file_t fileDesc
,
1330 /* NAME: gpfs_fputattrswithpathname()
1332 * FUNCTION: Sets all extended file attributes of a file and invokes
1333 * the policy engine to match a RESTORE rule using the file's
1334 * attributes saved in the extended attributes to set the
1335 * file's storage pool and data replication. The caller should
1336 * include the full path to the file, including the file name,
1337 * to allow rule selection based on file name or path.
1339 * If the file fails to match a RESTORE rule, or if there are
1340 * no RESTORE rules installed, then the storage pool and data
1341 * replication are selected as when calling gpfs_fputattrs().
1343 * The buffer passed in should contain extended attribute data
1344 * that was obtained by a previous call to gpfs_fgetattrs.
1346 * pathName is a UTF-8 encoded string. On Windows, applications
1347 * can convert UTF-16 ("Unicode") to UTF-8 using the platforms
1348 * WideCharToMultiByte function.
1351 * Input: flags Define behavior of put attributes
1352 * GPFS_ATTRFLAG_NO_PLACEMENT - file attributes are restored
1353 * but the storage pool and data replication are unchanged
1354 * GPFS_ATTRFLAG_IGNORE_POOL - file attributes are restored
1355 * but if the file fails to match a RESTORE rule, it
1356 * ignore the saved storage pool and select a pool
1357 * by matching the saved attributes to a PLACEMENT rule.
1358 * GPFS_ATTRFLAG_SKIP_IMMUTABLE - Skip immutable/appendOnly flags
1359 * before restoring file data. Then use GPFS_ATTRFLAG_FINALIZE_ATTRS
1360 * to restore immutable/appendOnly flags after data is restored.
1361 * GPFS_ATTRFLAG_FINALIZE_ATTRS - file attributes that are restored
1362 * after data is retored. If file is immutable/appendOnly
1363 * call without this flag before restoring data
1364 * then call with this flag after restoring data
1366 * Returns: 0 Successful
1369 * Errno: ENOSYS function not available
1370 * EINVAL Not a GPFS file
1371 * EINVAL the buffer does not contain valid attribute data
1372 * ENOENT invalid pathname
1373 * EINVAL invalid flags provided
1376 gpfs_fputattrswithpathname(gpfs_file_t fileDesc
,
1379 const char *pathName
);
1382 /* NAME: gpfs_get_fssnaphandle_by_path()
1384 * FUNCTION: Get a volatile handle to uniquely identify a file system
1385 * and snapshot by the path to the file system and snapshot
1387 * Input: pathName: path to a file or directory in a gpfs file system
1388 * or to one of its snapshots
1390 * Returns: pointer to gpfs_fssnap_handle_t (Successful)
1391 * NULL and errno is set (Failure)
1393 * Errno: ENOSYS function not available
1394 * EINVAL Not a GPFS file
1395 * ENOENT invalid pathname
1396 * see system calls open(), fstatfs(), and malloc() ERRORS
1398 gpfs_fssnap_handle_t
* GPFS_API
1399 gpfs_get_fssnaphandle_by_path(const char *pathName
);
1402 /* NAME: gpfs_get_fssnaphandle_by_name()
1404 * FUNCTION: Get a volatile handle to uniquely identify a file system
1405 * and snapshot by the file system name and snapshot name.
1407 * Input: fsName: unique name for gpfs file system (may be specified
1408 * as fsName or /dev/fsName)
1409 * snapName: name for snapshot within that file system
1410 * or NULL to access the active file system rather
1411 * than a snapshot within the file system.
1413 * Returns: pointer to gpfs_fssnap_handle_t (Successful)
1414 * NULL and errno is set (Failure)
1416 * Errno: ENOSYS function not available
1417 * ENOENT invalid file system name
1418 * GPFS_E_INVAL_SNAPNAME invalid snapshot name
1419 * see system calls open(), fstatfs(), and malloc() ERRORS
1421 gpfs_fssnap_handle_t
* GPFS_API
1422 gpfs_get_fssnaphandle_by_name(const char *fsName
,
1423 const char *snapName
);
1426 /* NAME: gpfs_get_fssnaphandle_by_fssnapid()
1428 * FUNCTION: Get a volatile handle to uniquely identify a file system
1429 * and snapshot by a fssnapId created from a previous handle.
1431 * Input: fssnapId: unique id for a file system and snapshot
1433 * Returns: pointer to gpfs_fssnap_handle_t (Successful)
1434 * NULL and errno is set (Failure)
1436 * Errno: ENOSYS function not available
1437 * GPFS_E_INVAL_FSSNAPID invalid snapshot id
1438 * see system calls open(), fstatfs(), and malloc() ERRORS
1440 gpfs_fssnap_handle_t
* GPFS_API
1441 gpfs_get_fssnaphandle_by_fssnapid(const gpfs_fssnap_id_t
*fssnapId
);
1443 /* NAME: gpfs_get_fset_snaphandle_by_path()
1445 * FUNCTION: Get a volatile handle to uniquely identify an inode space within a
1446 * filesyetsm and snapshot by the path to the file system and snapshot.
1448 * Input: pathName: path to a file or directory in a gpfs file system
1449 * or to one of its snapshots
1451 * Returns: pointer to gpfs_fssnap_handle_t (Successful)
1452 * NULL and errno is set (Failure)
1454 * Errno: ENOSYS function not available
1455 * EINVAL Not a GPFS file
1456 * ENOENT invalid pathname
1457 * see system calls open(), fstatfs(), and malloc() ERRORS
1459 gpfs_fssnap_handle_t
* GPFS_API
1460 gpfs_get_fset_snaphandle_by_path(const char *pathName
);
1462 /* NAME: gpfs_get_fset_snaphandle_by_name()
1464 * FUNCTION: Get a volatile handle to uniquely identify an inode space within a
1465 * file system and snapshot by the independent fileset name, file system
1466 * name and snapshot name.
1468 * Input: fsName: unique name for gpfs file system (may be specified
1469 * as fsName or /dev/fsName)
1470 * fsetName name of the independent fileset that owns the inode space
1471 * snapName: name for snapshot within that file system
1472 * or NULL to access the active file system rather
1473 * than a snapshot within the file system.
1475 * Returns: pointer to gpfs_fssnap_handle_t (Successful)
1476 * NULL and errno is set (Failure)
1478 * Errno: ENOSYS function not available
1479 * ENOENT invalid file system name
1480 * GPFS_E_INVAL_FSETNAME invalid fset nsmae
1481 * GPFS_E_INVAL_SNAPNAME invalid snapshot name
1482 * see system calls open(), fstatfs(), and malloc() ERRORS
1484 gpfs_fssnap_handle_t
* GPFS_API
1485 gpfs_get_fset_snaphandle_by_name(const char *fsName
,
1486 const char *fsetName
,
1487 const char *snapName
);
1489 /* NAME: gpfs_get_fset_snaphandle_by_fset_snapid()
1491 * FUNCTION: Get a volatile handle to uniquely identify a file system
1492 * and snapshot by a fssnapId created from a previous handle.
1494 * Input: fssnapId: unique id for a file system and snapshot
1496 * Returns: pointer to gpfs_fssnap_handle_t (Successful)
1497 * NULL and errno is set (Failure)
1499 * Errno: ENOSYS function not available
1500 * GPFS_E_INVAL_FSSNAPID invalid snapshot id
1501 * see system calls open(), fstatfs(), and malloc() ERRORS
1503 gpfs_fssnap_handle_t
* GPFS_API
1504 gpfs_get_fset_snaphandle_by_fset_snapid(const gpfs_fssnap_id_t
*fsetsnapId
);
1506 /* NAME: gpfs_get_pathname_from_fssnaphandle()
1508 * FUNCTION: Get the mountpoint and path to a file system
1509 * and snapshot identified by a fssnapHandle
1511 * Input: fssnapHandle: ptr to file system & snapshot handle
1513 * Returns: ptr to path name to the file system (Successful)
1514 * NULL and errno is set (Failure)
1516 * Errno: ENOSYS function not available
1517 * GPFS_E_INVAL_FSSNAPHANDLE invalid fssnapHandle
1519 const char * GPFS_API
1520 gpfs_get_pathname_from_fssnaphandle(gpfs_fssnap_handle_t
*fssnapHandle
);
1523 /* NAME: gpfs_get_fsname_from_fssnaphandle()
1525 * FUNCTION: Get the unique name for the file system
1526 * identified by a fssnapHandle
1528 * Input: fssnapHandle: ptr to file system & snapshot handle
1530 * Returns: ptr to name of the file system (Successful)
1531 * NULL and errno is set (Failure)
1533 * Errno: ENOSYS function not available
1534 * GPFS_E_INVAL_FSSNAPHANDLE invalid fssnapHandle
1536 const char * GPFS_API
1537 gpfs_get_fsname_from_fssnaphandle(gpfs_fssnap_handle_t
*fssnapHandle
);
1540 /* NAME: gpfs_get_snapname_from_fssnaphandle()
1542 * FUNCTION: Get the name for the snapshot
1543 * uniquely identified by a fssnapHandle
1545 * Input: fssnapHandle: ptr to file system & snapshot handle
1547 * Returns: ptr to name assigned to the snapshot (Successful)
1548 * NULL and errno is set (Failure)
1550 * Errno: ENOSYS function not available
1551 * GPFS_E_INVAL_FSSNAPHANDLE invalid fssnaphandle
1552 * GPFS_E_INVAL_SNAPNAME snapshot has been deleted
1554 * Notes: If the snapshot has been deleted from the file system
1555 * the snapId may still be valid, but the call will fail
1556 * with errno set to GPFS_E_INVAL_SNAPNAME.
1558 const char * GPFS_API
1559 gpfs_get_snapname_from_fssnaphandle(gpfs_fssnap_handle_t
*fssnapHandle
);
1562 /* NAME: gpfs_get_snapid_from_fssnaphandle()
1564 * FUNCTION: Get the numeric id for the snapshot identified
1565 * by a fssnapHandle. The snapshots define an ordered
1566 * sequence of changes to each file. The file's iattr
1567 * structure defines the snapshot id in which the file
1568 * was last modified (ia_modsnapid). This numeric value
1569 * can be compared to the numeric snapid from a fssnaphandle
1570 * to determine if the file changed before or after the
1571 * snapshot identified by the fssnaphandle.
1573 * Input: fssnapHandle: ptr to file system & snapshot handle
1575 * Returns: Numeric id for the snapshot referred to by the fssnaphandle
1576 * 0 if the fssnaphandle does not refer to a snapshot
1577 * -1 and errno is set (Failure)
1579 * Errno: ENOSYS function not available
1580 * GPFS_E_INVAL_FSSNAPHANDLE invalid fssnaphandle
1582 * Notes: The snapshot need not be on-line to determine the
1583 * snapshot's numeric id.
1585 gpfs_snapid_t GPFS_API
1586 gpfs_get_snapid_from_fssnaphandle(gpfs_fssnap_handle_t
*fssnapHandle
);
1588 gpfs_snapid64_t GPFS_API
1589 gpfs_get_snapid_from_fssnaphandle64(gpfs_fssnap_handle_t
*fssnapHandle
);
1592 /* NAME: gpfs_get_fssnapid_from_fssnaphandle()
1594 * FUNCTION: Get a unique, non-volatile file system and snapshot id
1595 * for the file system and snapshot identified by a
1596 * volatile fssnap handle.
1598 * Input: fssnapHandle: ptr to file system & snapshot handle
1599 * fssnapId: returned fssnapId uniquely identifying the
1600 * file system and snapshot being scanned
1602 * Returns: 0 and fssnapId is set with id (Successful)
1603 * -1 and errno is set (Failure)
1605 * Errno: GPFS_E_INVAL_FSSNAPHANDLE invalid fssnaphandle
1606 * EINVAL null ptr given for returned fssnapId
1607 * EFAULT size mismatch for fssnapId
1610 gpfs_get_fssnapid_from_fssnaphandle(gpfs_fssnap_handle_t
*fssnapHandle
,
1611 gpfs_fssnap_id_t
*fssnapId
);
1614 /* NAME: gpfs_get_restore_fssnapid_from_fssnaphandle()
1616 * FUNCTION: Get the unique, non-volatile file system and snapshot id
1617 * used for the last complete restore of a mirrored file
1618 * system. The file system must been a previous restore
1619 * target and ready for additional incremental restore.
1621 * Input: fssnapHandle: ptr to file system & snapshot handle
1622 * fssnapId: returned fssnapId uniquely identifying the
1623 * last complete restored file system.
1625 * Returns: 0 and fssnapId is set with id (Successful)
1626 * -1 and errno is set (Failure)
1628 * Errno: GPFS_E_INVAL_FSSNAPHANDLE invalid fssnaphandle
1629 * EINVAL null ptr given for returned fssnapId
1630 * EFAULT size mismatch for fssnapId
1631 * EPERM caller must have superuser privilege
1632 * ENOMEM unable to allocate memory for request
1633 * GPFS_E_FS_NOT_RESTORABLE fs is not clean for restore
1636 gpfs_get_restore_fssnapid_from_fssnaphandle(gpfs_fssnap_handle_t
*fssnapHandle
,
1637 gpfs_fssnap_id_t
*fssnapId
);
1639 /* NAME: gpfs_free_fssnaphandle()
1641 * FUNCTION: Free a fssnapHandle
1643 * Input: fssnapHandle: ptr to file system & snapshot handle
1650 gpfs_free_fssnaphandle(gpfs_fssnap_handle_t
*fssnapHandle
);
1652 /* NAME: gpfs_get_snapdirname()
1654 * FUNCTION: Get the name of the directory containing snapshots.
1656 * Input: fssnapHandle: handle for the file system
1657 * snapdirName: buffer into which the name of the snapshot
1658 * directory will be copied
1659 * bufLen: the size of the provided buffer
1661 * Returns: 0 (Successful)
1662 * -1 and errno is set (Failure)
1664 * Errno: ENOSYS function not available
1665 * EPERM caller must have superuser privilege
1666 * ESTALE cached fs information was invalid
1667 * ENOMEM unable to allocate memory for request
1668 * GPFS_E_INVAL_FSSNAPHANDLE fssnapHandle is invalid
1669 * E2BIG buffer too small to return the snapshot directory name
1672 gpfs_get_snapdirname(gpfs_fssnap_handle_t
*fssnapHandle
,
1677 /* NAME: gpfs_open_inodescan()
1679 * FUNCTION: Open inode file for inode scan.
1681 * Input: fssnapHandle: handle for file system and snapshot
1684 * if NULL, all inodes of existing file will be returned;
1685 * if non-null, only returns inodes of files that have changed
1686 * since the specified previous snapshot;
1687 * if specifies the same snapshot as the one referred by
1688 * fssnapHandle, only the snapshot inodes that have been
1689 * copied into this snap inode file are returned;
1690 * maxIno: if non-null, returns the maximum inode number
1691 * available in the inode file being scanned.
1693 * Returns: pointer to gpfs_iscan_t (Successful)
1694 * NULL and errno is set (Failure)
1696 * Errno: ENOSYS function not available
1697 * EINVAL bad parameters
1698 * EPERM caller must have superuser privilege
1699 * ESTALE cached fs information was invalid
1700 * ENOMEM unable to allocate memory for request
1701 * GPFS_E_INVAL_FSSNAPHANDLE fssnapHandle is invalid
1702 * GPFS_E_INVAL_FSSNAPID prev_fssnapId is invalid
1703 * EDOM prev_fssnapId is from a different fs
1704 * ERANGE prev_fssnapId is more recent than snapId
1706 * see system calls dup() and malloc() ERRORS
1708 gpfs_iscan_t
* GPFS_API
1709 gpfs_open_inodescan(gpfs_fssnap_handle_t
*fssnapHandle
,
1710 const gpfs_fssnap_id_t
*prev_fssnapId
,
1711 gpfs_ino_t
*maxIno
);
1713 gpfs_iscan_t
* GPFS_API
1714 gpfs_open_inodescan64(gpfs_fssnap_handle_t
*fssnapHandle
,
1715 const gpfs_fssnap_id_t
*prev_fssnapId
,
1716 gpfs_ino64_t
*maxIno
);
1719 /* NAME: gpfs_open_inodescan_with_xattrs()
1721 * FUNCTION: Open inode file and extended attributes for an inode scan
1723 * Input: fssnapHandle: handle for file system and snapshot
1725 * prev_fssnapId: if NULL, all inodes of existing file will
1726 * be returned; if non-null, only returns inodes of files
1727 * that have changed since the specified previous snapshot;
1728 * if specifies the same snapshot as the one referred by
1729 * fssnapHandle, only the snapshot inodes that have been
1730 * copied into this snap inode file are returned;
1731 * nxAttrs: count of extended attributes to be returned.
1732 * if nxAttrs is set to 0, call returns no extended
1733 * attributes, like gpfs_open_inodescan.
1734 * if nxAttrs is set to -1, call returns all extended attributes
1735 * xAttrList: pointer to array of pointers to names of extended
1736 * attribute to be returned. nxAttrList may be null if nxAttrs
1737 * is set to 0 or -1.
1738 * maxIno: if non-null, returns the maximum inode number
1739 * available in the inode file being scanned.
1741 * Returns: pointer to gpfs_iscan_t (Successful)
1742 * NULL and errno is set (Failure)
1744 * Errno: ENOSYS function not available
1745 * EINVAL bad parameters
1746 * EPERM caller must have superuser privilege
1747 * ESTALE cached fs information was invalid
1748 * ENOMEM unable to allocate memory for request
1749 * GPFS_E_INVAL_FSSNAPHANDLE fssnapHandle is invalid
1750 * GPFS_E_INVAL_FSSNAPID prev_fssnapId is invalid
1751 * EDOM prev_fssnapId is from a different fs
1752 * ERANGE prev_fssnapId is more recent than snapId
1754 * see system calls dup() and malloc() ERRORS
1756 gpfs_iscan_t
* GPFS_API
1757 gpfs_open_inodescan_with_xattrs(gpfs_fssnap_handle_t
*fssnapHandle
,
1758 const gpfs_fssnap_id_t
*prev_fssnapId
,
1760 const char *xattrsList
[],
1761 gpfs_ino_t
*maxIno
);
1763 gpfs_iscan_t
* GPFS_API
1764 gpfs_open_inodescan_with_xattrs64(gpfs_fssnap_handle_t
*fssnapHandle
,
1765 const gpfs_fssnap_id_t
*prev_fssnapId
,
1767 const char *xattrList
[],
1768 gpfs_ino64_t
*maxIno
);
1771 /* NAME: gpfs_next_inode()
1773 * FUNCTION: Get next inode from inode scan. Scan terminates before
1774 * the last inode specified or the last inode in the
1775 * inode file being scanned.
1777 * If the inode scan was opened to expressly look for inodes
1778 * in a snapshot, and not dittos, gets the next inode skipping
1781 * Input: iscan: ptr to inode scan descriptor
1782 * termIno: scan terminates before this inode number
1783 * caller may specify maxIno from gpfs_open_inodescan()
1784 * or 0 to scan the entire inode file.
1785 * iattr: pointer to returned pointer to file's iattr.
1787 * Returns: 0 and *iattr set to point to gpfs_iattr_t (Successful)
1788 * 0 and *iattr set to NULL for no more inodes before termIno
1789 * -1 and errno is set (Failure)
1791 * Errno: ENOSYS function not available
1792 * EPERM caller must have superuser privilege
1793 * ESTALE cached fs information was invalid
1794 * ENOMEM buffer too small
1795 * GPFS_E_INVAL_ISCAN bad parameters
1796 * GPFS_E_INVAL_FSSNAPID the snapshot id provided in the
1797 * gpfs iscan is not valid
1799 * Notes: The data returned by gpfs_next_inode() is overwritten by
1800 * subsequent calls to gpfs_next_inode() or gpfs_seek_inode().
1802 * The termIno parameter provides a means to partition an
1803 * inode scan such that it may be executed on more than one node.
1806 gpfs_next_inode(gpfs_iscan_t
*iscan
,
1808 const gpfs_iattr_t
**iattr
);
1811 gpfs_next_inode64(gpfs_iscan_t
*iscan
,
1812 gpfs_ino64_t termIno
,
1813 const gpfs_iattr64_t
**iattr
);
1816 /* NAME: gpfs_next_inode_with_xattrs()
1818 * FUNCTION: Get next inode and its extended attributes from the inode scan.
1819 * The set of extended attributes returned were defined when
1820 * the inode scan was opened. The scan terminates before the last
1821 * inode specified or the last inode in the inode file being
1824 * If the inode scan was opened to expressly look for inodes
1825 * in a snapshot, and not dittos, gets the next inode skipping
1828 * Input: iscan: ptr to inode scan descriptor
1829 * termIno: scan terminates before this inode number
1830 * caller may specify maxIno from gpfs_open_inodescan()
1831 * or 0 to scan the entire inode file.
1832 * iattr: pointer to returned pointer to file's iattr.
1833 * xattrBuf: pointer to returned pointer to xattr buffer
1834 * xattrBufLen: returned length of xattr buffer
1837 * Returns: 0 and *iattr set to point to gpfs_iattr_t (Successful)
1838 * 0 and *iattr set to NULL for no more inodes before termIno
1839 * -1 and errno is set (Failure)
1841 * Errno: ENOSYS function not available
1842 * EPERM caller must have superuser privilege
1843 * ESTALE cached fs information was invalid
1844 * EFAULT buffer data was overwritten
1845 * ENOMEM buffer too small
1846 * GPFS_E_INVAL_ISCAN bad parameters
1847 * GPFS_E_INVAL_XATTR bad parameters
1849 * Notes: The data returned by gpfs_next_inode() is overwritten by
1850 * subsequent calls to gpfs_next_inode(), gpfs_seek_inode()
1851 * or gpfs_stat_inode().
1853 * The termIno parameter provides a means to partition an
1854 * inode scan such that it may be executed on more than one node.
1856 * The returned values for xattrBuf and xattrBufLen must be
1857 * provided to gpfs_next_xattr() to obtain the extended attribute
1858 * names and values. The buffer used for the extended attributes
1859 * is overwritten by subsequent calls to gpfs_next_inode(),
1860 * gpfs_seek_inode() or gpfs_stat_inode();
1862 * The returned pointers to the extended attribute name and value
1863 * will be aligned to a double-word boundary.
1866 gpfs_next_inode_with_xattrs(gpfs_iscan_t
*iscan
,
1868 const gpfs_iattr_t
**iattr
,
1869 const char **xattrBuf
,
1870 unsigned int *xattrBufLen
);
1873 gpfs_next_inode_with_xattrs64(gpfs_iscan_t
*iscan
,
1874 gpfs_ino64_t termIno
,
1875 const gpfs_iattr64_t
**iattr
,
1876 const char **xattrBuf
,
1877 unsigned int *xattrBufLen
);
1880 /* NAME: gpfs_next_xattr()
1882 * FUNCTION: Iterate over the extended attributes buffer returned
1883 * by get_next_inode_with_xattrs to return the individual
1884 * attributes and their values. Note that the attribute names
1885 * are null-terminated strings, whereas the atttribute value
1886 * contains binary data.
1888 * Input: iscan: ptr to inode scan descriptor
1889 * xattrBufLen: ptr to attribute buffer length
1890 * xattrBuf: ptr to the ptr to the attribute buffer
1892 * Returns: 0 and *name set to point attribue name (Successful)
1893 * also sets: *valueLen to length of attribute value
1894 * *value to point to attribute value
1895 * *xattrBufLen to remaining length of buffer
1896 * **xattrBuf to index next attribute in buffer
1897 * 0 and *name set to NULL for no more attributes in buffer
1898 * also sets: *valueLen to 0
1901 * **xattrBuf to NULL
1902 * -1 and errno is set (Failure)
1904 * Errno: ENOSYS function not available
1905 * GPFS_E_INVAL_ISCAN invalid iscan parameter
1906 * GPFS_E_INVAL_XATTR invalid xattr parameters
1908 * Notes: The caller is not allowed to modify the returned attribute
1909 * names or values. The data returned by gpfs_next_attribute()
1910 * may be overwritten by subsequent calls to gpfs_next_attribute()
1911 * or other gpfs library calls.
1914 gpfs_next_xattr(gpfs_iscan_t
*iscan
,
1915 const char **xattrBuf
,
1916 unsigned int *xattrBufLen
,
1918 unsigned int *valueLen
,
1919 const char **value
);
1923 /* NAME: gpfs_seek_inode()
1925 * FUNCTION: Seek to a given inode number.
1927 * Input: iscan: ptr to inode scan descriptor
1928 * ino: next inode number to be scanned
1930 * Returns: 0 Successful
1931 * -1 Failure and errno is set
1933 * Errno: ENOSYS function not available
1934 * GPFS_E_INVAL_ISCAN bad parameters
1937 gpfs_seek_inode(gpfs_iscan_t
*iscan
,
1941 gpfs_seek_inode64(gpfs_iscan_t
*iscan
,
1947 /* define GPFS generated errno */
1948 #define GPFS_E_HOLE_IN_IFILE 238 /* hole in inode file */
1951 /* NAME: gpfs_stat_inode()
1952 * NAME: gpfs_stat_inode_with_xattrs()
1954 * FUNCTION: Seek to the specified inode and get that inode and
1955 * its extended attributes from the inode scan. This is
1956 * simply a combination of gpfs_seek_inode and get_next_inode
1957 * but will only return the specified inode.
1959 * Input: iscan: ptr to inode scan descriptor
1960 * ino: inode number to be returned
1961 * termIno: prefetch inodes up to this inode
1962 * caller may specify maxIno from gpfs_open_inodescan()
1963 * or 0 to allow prefetching over the entire inode file.
1964 * iattr: pointer to returned pointer to file's iattr.
1965 * xattrBuf: pointer to returned pointer to xattr buffer
1966 * xattrBufLen: returned length of xattr buffer
1968 * Returns: 0 and *iattr set to point to gpfs_iattr_t (Successful)
1969 * 0 and *iattr set to NULL for no more inodes before termIno
1970 * or if requested inode does not exist.
1971 * -1 and errno is set (Failure)
1973 * Errno: ENOSYS function not available
1974 * EPERM caller must have superuser privilege
1975 * ESTALE cached fs information was invalid
1976 * ENOMEM buffer too small
1977 * GPFS_E_INVAL_ISCAN bad parameters
1978 * GPFS_E_HOLE_IN_IFILE if we are expressly looking for inodes in
1979 * the snapshot file and this one has yet not
1980 * been copied into snapshot.
1982 * Notes: The data returned by gpfs_next_inode() is overwritten by
1983 * subsequent calls to gpfs_next_inode(), gpfs_seek_inode()
1984 * or gpfs_stat_inode().
1986 * The termIno parameter provides a means to partition an
1987 * inode scan such that it may be executed on more than one node.
1988 * It is only used by this call to control prefetching.
1990 * The returned values for xattrBuf and xattrBufLen must be
1991 * provided to gpfs_next_xattr() to obtain the extended attribute
1992 * names and values. The buffer used for the extended attributes
1993 * is overwritten by subsequent calls to gpfs_next_inode(),
1994 * gpfs_seek_inode() or gpfs_stat_inode();
1997 gpfs_stat_inode(gpfs_iscan_t
*iscan
,
2000 const gpfs_iattr_t
**iattr
);
2003 gpfs_stat_inode64(gpfs_iscan_t
*iscan
,
2005 gpfs_ino64_t termIno
,
2006 const gpfs_iattr64_t
**iattr
);
2009 gpfs_stat_inode_with_xattrs(gpfs_iscan_t
*iscan
,
2012 const gpfs_iattr_t
**iattr
,
2013 const char **xattrBuf
,
2014 unsigned int *xattrBufLen
);
2017 gpfs_stat_inode_with_xattrs64(gpfs_iscan_t
*iscan
,
2019 gpfs_ino64_t termIno
,
2020 const gpfs_iattr64_t
**iattr
,
2021 const char **xattrBuf
,
2022 unsigned int *xattrBufLen
);
2025 /* NAME: gpfs_close_inodescan()
2027 * FUNCTION: Close inode file.
2029 * Input: iscan: ptr to inode scan descriptor
2036 gpfs_close_inodescan(gpfs_iscan_t
*iscan
);
2039 /* NAME: gpfs_cmp_fssnapid()
2041 * FUNCTION: Compare two fssnapIds for the same file system to
2042 * determine the order in which the two snapshots were taken.
2043 * The 'result' variable will be set as follows:
2044 * *result < 0: snapshot 1 was taken before snapshot 2
2045 * *result == 0: snapshot 1 and 2 are the same
2046 * *result > 0: snapshot 1 was taken after snapshot 2
2048 * Input: fssnapId1: ptr to fssnapId 1
2049 * fssnapId2: ptr to fssnapId id 2
2050 * result: ptr to returned results
2052 * Returns: 0 and *result is set as described above (Successful)
2053 * -1 and errno is set (Failure)
2055 * Errno: ENOSYS function not available
2056 * GPFS_E_INVAL_FSSNAPID fssnapid1 or fssnapid2 is not a
2058 * EDOM the two snapshots cannot be compared because
2059 * they were taken from two different file systems.
2062 gpfs_cmp_fssnapid(const gpfs_fssnap_id_t
*fssnapId1
,
2063 const gpfs_fssnap_id_t
*fssnapId2
,
2067 /* NAME: gpfs_iopen()
2069 * FUNCTION: Open a file or directory by inode number.
2071 * Input: fssnapHandle: handle for file system and snapshot
2074 * open_flags: O_RDONLY for gpfs_iread()
2075 * O_WRONLY for gpfs_iwrite()
2076 * O_CREAT create the file if it doesn't exist
2077 * O_TRUNC if the inode already exists delete it
2078 * caller may use GPFS_O_BACKUP to read files for backup
2079 * and GPFS_O_RESTORE to write files for restore
2080 * statxbuf: used only with O_CREAT/GPFS_O_BACKUP
2081 * all other cases set to NULL
2082 * symLink: used only with O_CREAT/GPFS_O_BACKUP for a symbolic link
2083 * all other cases set to NULL
2085 * Returns: pointer to gpfs_ifile_t (Successful)
2086 * NULL and errno is set (Failure)
2088 * Errno: ENOSYS function not available
2089 * ENOENT file not existed
2090 * EINVAL missing or bad parameter
2091 * EPERM caller must have superuser privilege
2092 * ESTALE cached fs information was invalid
2093 * ENOMEM unable to allocate memory for request
2094 * EFORMAT invalid fs version number
2095 * EIO error reading original inode
2096 * ERANGE error ino is out of range, should use gpfs_iopen64
2097 * GPFS_E_INVAL_INUM reserved inode is not allowed to open
2098 * GPFS_E_INVAL_IATTR iattr structure was corrupted
2099 * see dup() and malloc() ERRORS
2101 gpfs_ifile_t
* GPFS_API
2102 gpfs_iopen(gpfs_fssnap_handle_t
*fssnapHandle
,
2105 const gpfs_iattr_t
*statxbuf
,
2106 const char *symLink
);
2108 gpfs_ifile_t
* GPFS_API
2109 gpfs_iopen64(gpfs_fssnap_handle_t
*fssnapHandle
,
2112 const gpfs_iattr64_t
*statxbuf
,
2113 const char *symLink
);
2116 /* Define gpfs_iopen flags as used by the backup & restore by inode.
2117 The backup code will only read the source files.
2118 The restore code writes the target files & creates them if they
2119 don't already exist. The file length is set by the inode attributes.
2120 Consequently, to restore a user file it is unnecessary to include
2121 the O_TRUNC flag. */
2122 #define GPFS_O_BACKUP (O_RDONLY)
2123 #define GPFS_O_RESTORE (O_WRONLY | O_CREAT)
2126 /* NAME: gpfs_iread()
2128 * FUNCTION: Read file opened by gpfs_iopen.
2130 * Input: ifile: pointer to gpfs_ifile_t from gpfs_iopen
2131 * buffer: buffer for data to be read
2132 * bufferSize: size of buffer (ie amount of data to be read)
2133 * In/Out offset: offset of where within the file to read
2134 * if successful, offset will be updated to the
2135 * next byte after the last one that was read
2137 * Returns: number of bytes read (Successful)
2138 * -1 and errno is set (Failure)
2140 * Errno: ENOSYS function not available
2141 * EISDIR file is a directory
2142 * EPERM caller must have superuser privilege
2143 * ESTALE cached fs information was invalid
2144 * GPFS_E_INVAL_IFILE bad ifile parameters
2145 * see system call read() ERRORS
2148 gpfs_iread(gpfs_ifile_t
*ifile
,
2151 gpfs_off64_t
*offset
);
2154 /* NAME: gpfs_iwrite()
2156 * FUNCTION: Write file opened by gpfs_iopen.
2158 * Input: ifile: pointer to gpfs_ifile_t from gpfs_iopen
2159 * buffer: the data to be written
2160 * writeLen: how much to write
2161 * In/Out offset: offset of where within the file to write
2162 * if successful, offset will be updated to the
2163 * next byte after the last one that was written
2165 * Returns: number of bytes written (Successful)
2166 * -1 and errno is set (Failure)
2168 * Errno: ENOSYS function not available
2169 * EISDIR file is a directory
2170 * EPERM caller must have superuser privilege
2171 * ESTALE cached fs information was invalid
2172 * GPFS_E_INVAL_IFILE bad ifile parameters
2173 * see system call write() ERRORS
2176 gpfs_iwrite(gpfs_ifile_t
*ifile
,
2179 gpfs_off64_t
*offset
);
2182 /* NAME: gpfs_ireaddir()
2184 * FUNCTION: Get next directory entry.
2186 * Input: idir: pointer to gpfs_ifile_t from gpfs_iopen
2187 * dirent: pointer to returned pointer to directory entry
2189 * Returns: 0 and pointer to gpfs_direntx set (Successful)
2190 * 0 and pointer to gpfs_direntx set to NULL (End of directory)
2191 * -1 and errno is set (Failure)
2193 * Errno: ENOSYS function not available
2194 * ENOTDIR file is not a directory
2195 * EPERM caller must have superuser privilege
2196 * ESTALE cached fs information was invalid
2197 * GPFS_E_INVAL_IFILE bad ifile parameter
2198 * ENOMEM unable to allocate memory for request
2200 * Notes: The data returned by gpfs_ireaddir() is overwritten by
2201 * subsequent calls to gpfs_ireaddir().
2204 gpfs_ireaddir(gpfs_ifile_t
*idir
,
2205 const gpfs_direntx_t
**dirent
);
2208 gpfs_ireaddir64(gpfs_ifile_t
*idir
,
2209 const gpfs_direntx64_t
**dirent
);
2213 gpfs_ireaddirx(gpfs_ifile_t
*idir
,
2214 gpfs_iscan_t
*iscan
, /* in only */
2215 const gpfs_direntx_t
**dirent
);
2218 gpfs_ireaddirx64(gpfs_ifile_t
*idir
,
2219 gpfs_iscan_t
*iscan
, /* in only */
2220 const gpfs_direntx64_t
**dirent
);
2223 /* NAME: gpfs_iwritedir()
2225 * FUNCTION: Create a directory entry in a directory opened by gpfs_iopen.
2227 * Input: idir: pointer to gpfs_ifile_t from gpfs_iopen
2228 * dirent: directory entry to be written
2230 * Returns: 0 (Successful)
2231 * -1 and errno is set (Failure)
2233 * Errno: ENOSYS function not available
2234 * GPFS_E_INVAL_IFILE bad file pointer
2235 * ENOTDIR file is not a directory
2236 * EPERM caller must have superuser privilege
2237 * ESTALE cached fs information was invalid
2238 * ENOMEM unable to allocate memory for request
2239 * EFORMAT invalid dirent version number
2240 * see system call write() ERRORS
2243 gpfs_iwritedir(gpfs_ifile_t
*idir
,
2244 const gpfs_direntx_t
*dirent
);
2247 gpfs_iwritedir64(gpfs_ifile_t
*idir
,
2248 const gpfs_direntx64_t
*dirent
);
2251 /* NAME: gpfs_igetattrs()
2253 * FUNCTION: Retrieves all extended file attributes in opaque format.
2254 * This function together with gpfs_iputattrs is intended for
2255 * use by a backup program to save (gpfs_igetattrs) and
2256 * restore (gpfs_iputattrs) all extended file attributes
2257 * (ACLs, user attributes, ...) in one call.
2259 * NOTE: This call does not return extended attributes used for
2260 * the Data Storage Management (XDSM) API (aka DMAPI).
2262 * Input: ifile: pointer to gpfs_ifile_t from gpfs_iopen
2263 * buffer: pointer to buffer for returned attributes
2264 * bufferSize: size of buffer
2265 * attrSize: ptr to returned size of attributes
2267 * Returns: 0 Successful
2268 * -1 Failure and errno is set
2270 * Errno: ENOSYS function not available
2271 * EPERM caller must have superuser privilege
2272 * ESTALE cached fs information was invalid
2273 * ENOSPC buffer too small to return all attributes
2274 * *attrSizeP will be set to the size necessary
2275 * GPFS_E_INVAL_IFILE bad ifile parameters
2278 gpfs_igetattrs(gpfs_ifile_t
*ifile
,
2283 /* NAME: gpfs_igetattrsx()
2285 * FUNCTION: Retrieves all extended file attributes in opaque format.
2286 * This function together with gpfs_iputattrsx is intended for
2287 * use by a backup program to save (gpfs_igetattrsx) and
2288 * restore (gpfs_iputattrsx) all extended file attributes
2289 * (ACLs, user attributes, ...) in one call.
2291 * NOTE: This call can optionally return extended attributes
2292 * used for the Data Storage Management (XDSM) API
2295 * Input: ifile: pointer to gpfs_ifile_t from gpfs_iopen
2296 * flags Define behavior of get attributes
2297 * GPFS_ATTRFLAG_NO_PLACEMENT - file attributes for placement
2298 * are not saved, neither is the current storage pool.
2299 * GPFS_ATTRFLAG_IGNORE_POOL - file attributes for placement
2300 * are saved, but the current storage pool is not.
2301 * GPFS_ATTRFLAG_INCL_DMAPI - file attributes for dmapi are
2302 * included in the returned buffer
2303 * GPFS_ATTRFLAG_INCL_ENCR - file attributes for encryption
2304 * are included in the returned buffer
2306 * buffer: pointer to buffer for returned attributes
2307 * bufferSize: size of buffer
2308 * attrSize: ptr to returned size of attributes
2310 * Returns: 0 Successful
2313 * Errno: ENOSYS function not available
2314 * EINVAL Not a GPFS file
2315 * EINVAL invalid flags provided
2316 * ENOSPC buffer too small to return all attributes
2317 * *attrSizeP will be set to the size necessary
2320 gpfs_igetattrsx(gpfs_ifile_t
*ifile
,
2327 /* NAME: gpfs_igetxattr()
2329 * FUNCTION: Retrieves an extended file attributes from ifile which has been open
2332 * NOTE: This call does not return extended attributes used for
2333 * the Data Storage Management (XDSM) API (aka DMAPI).
2335 * Input: ifile: pointer to gpfs_ifile_t from gpfs_iopen
2336 * buffer: pointer to buffer for key and returned extended
2338 * bufferSize: size of buffer, should be enough to save attribute value
2339 * attrSize: ptr to key length as input and ptr to the returned
2340 * size of attributes as putput.
2342 * Returns: 0 Successful
2343 * -1 Failure and errno is set
2345 * Errno: ENOSYS function not available
2346 * EPERM caller must have superuser priviledges
2347 * ESTALE cached fs information was invalid
2348 * ENOSPC buffer too small to return all attributes
2349 * *attrSize will be set to the size necessary
2350 * GPFS_E_INVAL_IFILE bad ifile parameters
2353 gpfs_igetxattr(gpfs_ifile_t
*ifile
,
2359 /* NAME: gpfs_iputattrs()
2361 * FUNCTION: Sets all extended file attributes of a file.
2362 * The buffer passed in should contain extended attribute data
2363 * that was obtained by a previous call to gpfs_igetattrs.
2365 * NOTE: This call will not restore extended attributes
2366 * used for the Data Storage Management (XDSM) API
2367 * (aka DMAPI). They will be silently ignored.
2369 * Input: ifile: pointer to gpfs_ifile_t from gpfs_iopen
2370 * buffer: pointer to buffer for returned attributes
2372 * Returns: 0 Successful
2373 * -1 Failure and errno is set
2375 * Errno: ENOSYS function not available
2376 * EINVAL the buffer does not contain valid attribute data
2377 * EPERM caller must have superuser privilege
2378 * ESTALE cached fs information was invalid
2379 * GPFS_E_INVAL_IFILE bad ifile parameters
2382 gpfs_iputattrs(gpfs_ifile_t
*ifile
,
2386 /* NAME: gpfs_iputattrsx()
2388 * FUNCTION: Sets all extended file attributes of a file.
2390 * This routine can optionally invoke the policy engine
2391 * to match a RESTORE rule using the file's attributes saved
2392 * in the extended attributes to set the file's storage pool and
2393 * data replication as when calling gpfs_fputattrswithpathname.
2394 * When used with the policy the caller should include the
2395 * full path to the file, including the file name, to allow
2396 * rule selection based on file name or path.
2398 * By default, the routine will not use RESTORE policy rules
2399 * for data placement. The pathName parameter will be ignored
2400 * and may be set to NULL.
2402 * If the call does not use RESTORE policy rules, or if the
2403 * file fails to match a RESTORE rule, or if there are no
2404 * RESTORE rules installed, then the storage pool and data
2405 * replication are selected as when calling gpfs_fputattrs().
2407 * The buffer passed in should contain extended attribute data
2408 * that was obtained by a previous call to gpfs_fgetattrs.
2410 * pathName is a UTF-8 encoded string. On Windows, applications
2411 * can convert UTF-16 ("Unicode") to UTF-8 using the platforms
2412 * WideCharToMultiByte function.
2414 * NOTE: This call will restore extended attributes
2415 * used for the Data Storage Management (XDSM) API
2416 * (aka DMAPI) if they are present in the buffer.
2418 * Input: ifile: pointer to gpfs_ifile_t from gpfs_iopen
2419 * flags Define behavior of put attributes
2420 * GPFS_ATTRFLAG_NO_PLACEMENT - file attributes are restored
2421 * but the storage pool and data replication are unchanged
2422 * GPFS_ATTRFLAG_IGNORE_POOL - file attributes are restored
2423 * but the storage pool and data replication are selected
2424 * by matching the saved attributes to a placement rule
2425 * instead of restoring the saved storage pool.
2426 * GPFS_ATTRFLAG_USE_POLICY - file attributes are restored
2427 * but the storage pool and data replication are selected
2428 * by matching the saved attributes to a RESTORE rule
2429 * instead of restoring the saved storage pool.
2430 * GPFS_ATTRFLAG_FINALIZE_ATTRS - file attributes that are restored
2431 * after data is retored. If file is immutable/appendOnly
2432 * call without this flag before restoring data
2433 * then call with this flag after restoring data
2434 * GPFS_ATTRFLAG_INCL_ENCR - file attributes for encryption
2435 * are restored. Note that this may result in the file's
2436 * File Encryption Key (FEK) being changed, and in this
2437 * case any prior content in the file is effectively lost.
2438 * This option should only be used when the entire file
2439 * content is restored after the attributes are restored.
2441 * buffer: pointer to buffer for returned attributes
2442 * pathName: pointer to file path and file name for file
2443 * May be set to NULL.
2445 * Returns: 0 Successful
2446 * -1 Failure and errno is set
2448 * Errno: ENOSYS function not available
2449 * EINVAL the buffer does not contain valid attribute data
2450 * EINVAL invalid flags provided
2451 * EPERM caller must have superuser privilege
2452 * ESTALE cached fs information was invalid
2453 * GPFS_E_INVAL_IFILE bad ifile parameters
2456 gpfs_iputattrsx(gpfs_ifile_t
*ifile
,
2459 const char *pathName
);
2461 /* NAME: gpfs_igetcompressionlib()
2463 * FUNCTION: Retrieves the selected compression library from ifile which has been
2464 * open by gpfs_iopen().
2466 * Input: ifile: pointer to gpfs_ifile_t from gpfs_iopen
2467 * buffer: pointer to buffer for key and returned extended
2469 * bufferSize: size of buffer, should be enough to save attribute value
2470 * attrSize: ptr to key length as input and ptr to the returned
2471 * size of attributes as putput.
2473 * Returns: 0 Successful
2474 * -1 Failure and errno is set
2476 * Errno: ENOSYS function not available
2477 * EPERM caller must have superuser priviledges
2478 * ESTALE cached fs information was invalid
2479 * ENOSPC buffer too small to return all attributes
2480 * *attrSize will be set to the size necessary
2481 * EINVAL buffer is NULL
2482 * EIO selected compression library is corrupted or not available
2483 * GPFS_E_INVAL_IFILE bad ifile parameters
2486 gpfs_igetcompressionlib(gpfs_ifile_t
*ifile
,
2491 /* NAME: gpfs_igetfilesetname()
2493 * FUNCTION: Retrieves the name of the fileset which contains this file.
2494 * The fileset name is a null-terminated string, with a
2495 * a maximum length of GPFS_MAXNAMLEN.
2497 * Input: iscan: ptr to gpfs_iscan_t from gpfs_open_inodescan()
2498 * filesetId: ia_filesetId returned in an iattr from the iscan
2499 * buffer: pointer to buffer for returned fileset name
2500 * bufferSize: size of buffer
2502 * Returns: 0 Successful
2503 * -1 Failure and errno is set
2505 * Errno: ENOSYS function not available
2506 * EPERM caller must have superuser privilege
2507 * ESTALE cached fs information was invalid
2508 * ENOSPC buffer too small to return fileset name
2509 * GPFS_E_INVAL_ISCAN bad iscan parameter
2512 gpfs_igetfilesetname(gpfs_iscan_t
*iscan
,
2513 unsigned int filesetId
,
2518 /* NAME: gpfs_igetstoragepool()
2520 * FUNCTION: Retrieves the name of the storage pool assigned for
2521 * this file's data. The storage pool name is a null-terminated
2522 * string, with a maximum length of GPFS_MAXNAMLEN.
2524 * Input: iscan: ptr to gpfs_iscan_t from gpfs_open_inodescan()
2525 * dataPoolId: ia_dataPoolId returned in an iattr from the iscan
2526 * buffer: pointer to buffer for returned attributes
2527 * bufferSize: size of buffer
2529 * Returns: 0 Successful
2530 * -1 Failure and errno is set
2532 * Errno: ENOSYS function not available
2533 * EPERM caller must have superuser privilege
2534 * ESTALE cached fs information was invalid
2535 * ENOSPC buffer too small to return all storage pool name
2536 * GPFS_E_INVAL_ISCAN bad iscan parameters
2539 gpfs_igetstoragepool(gpfs_iscan_t
*iscan
,
2540 unsigned int dataPoolId
,
2545 /* NAME: gpfs_iclose()
2547 * FUNCTION: Close file opened by inode and update dates.
2549 * Input: ifile: pointer to gpfs_ifile_t from gpfs_iopen
2554 gpfs_iclose(gpfs_ifile_t
*ifile
);
2557 /* NAME: gpfs_ireadlink()
2559 * FUNCTION: Read symbolic link by inode number.
2561 * Input: fssnapHandle: handle for file system & snapshot being scanned
2562 * ino: inode number of link file to read
2563 * buffer: pointer to buffer for returned link data
2564 * bufferSize: size of the buffer
2566 * Returns: number of bytes read (Successful)
2567 * -1 and errno is set (Failure)
2569 * Errno: ENOSYS function not available
2570 * EPERM caller must have superuser privilege
2571 * ESTALE cached fs information was invalid
2572 * GPFS_E_INVAL_FSSNAPHANDLE invalid fssnap handle
2573 * see system call readlink() ERRORS
2576 gpfs_ireadlink(gpfs_fssnap_handle_t
*fssnapHandle
,
2582 gpfs_ireadlink64(gpfs_fssnap_handle_t
*fssnapHandle
,
2588 /* NAME: gpfs_sync_fs()
2590 * FUNCTION: sync file system.
2592 * Input: fssnapHandle: handle for file system being restored
2594 * Returns: 0 all data flushed to disk (Successful)
2595 * -1 and errno is set (Failure)
2597 * Errno: ENOSYS function not available
2598 * ENOMEM unable to allocate memory for request
2599 * EPERM caller must have superuser privilege
2600 * ESTALE cached fs information was invalid
2601 * GPFS_E_INVAL_FSSNAPHANDLE invalid fssnapHandle
2604 gpfs_sync_fs(gpfs_fssnap_handle_t
*fssnapHandle
);
2607 /* NAME: gpfs_enable_restore()
2609 * FUNCTION: Mark file system as enabled for restore on/off
2611 * Input: fssnapHandle: handle for file system to be enabled
2612 * or disabled for restore
2613 * on_off: flag set to 1 to enable restore
2614 * 0 to disable restore
2616 * Returns: 0 (Successful)
2617 * -1 and errno is set (Failure)
2619 * Errno: ENOSYS function not available
2620 * EINVAL bad parameters
2621 * GPFS_E_INVAL_FSSNAPHANDLE invalid fssnapHandle
2622 * EPERM caller must have superuser privilege
2623 * ESTALE cached fs information was invalid
2624 * ENOMEM unable to allocate memory for request
2625 * E_FS_NOT_RESTORABLE fs is not clean
2626 * EALREADY fs already marked as requested
2627 * E_RESTORE_STARTED restore in progress
2629 * Notes: EALREADY indicates enable/disable restore was already called
2630 * for this fs. The caller must decide if EALREADY represents an
2634 gpfs_enable_restore(gpfs_fssnap_handle_t
*fssnapHandle
,
2638 /* NAME: gpfs_start_restore()
2640 * FUNCTION: Start a restore session.
2642 * Input: fssnapHandle: handle for file system to be restored
2643 * restore_flags: Flag to indicate the restore should be started
2644 * even if a prior restore has not completed.
2645 * old_fssnapId: fssnapId of last restored snapshot
2646 * new_fssnapId: fssnapId of snapshot being restored
2648 * Returns: pointer to gpfs_restore_t (Successful)
2649 * NULL and errno is set (Failure)
2651 * Errno: ENOSYS function not available
2652 * ENOMEM unable to allocate memory for request
2653 * EINVAL missing parameter
2654 * EPERM caller must have superuser privilege
2655 * ESTALE cached fs information was invalid
2656 * EDOM restore fs does not match existing fs
2657 * ERANGE restore is missing updates
2658 * EFORMAT invalid fs version number
2659 * GPFS_E_INVAL_FSSNAPHANDLE invalid fssnaphandle
2660 * GPFS_E_INVAL_FSSNAPID bad fssnapId parameter
2661 * E_FS_NOT_RESTORABLE fs is not clean for restore
2662 * E_RESTORE_NOT_ENABLED fs is not enabled for restore
2663 * EALREADY Restore already in progress
2665 * Note: EALREADY indicates start restore was already called for
2666 * this fs. This could be due to a prior restore process that failed
2667 * or it could be due to a concurrent restore process still running.
2668 * The caller must decide if EALREADY represents an error condition.
2670 gpfs_restore_t
* GPFS_API
2671 gpfs_start_restore(gpfs_fssnap_handle_t
*fssnapHandle
,
2673 const gpfs_fssnap_id_t
*old_fssnapId
,
2674 const gpfs_fssnap_id_t
*new_fssnapId
);
2676 #define GPFS_RESTORE_NORMAL 0 /* Restore not started if prior restore
2677 has not completed. */
2678 #define GPFS_RESTORE_FORCED 1 /* Restore starts even if prior restore
2679 has not completed. */
2682 /* NAME: gpfs_end_restore()
2684 * FUNCTION: End a restore session.
2686 * Input: restoreId: ptr to gpfs_restore_t
2688 * Returns: 0 (Successful)
2689 * -1 and errno is set (Failure)
2691 * Errno: ENOSYS function not available
2692 * EINVAL bad parameters
2693 * EPERM caller must have superuser privilege
2694 * ESTALE cached fs information was invalid
2695 * GPFS_E_INVAL_RESTORE bad restoreId parameter
2696 * GPFS_E_FS_NOT_RESTORABLE fs is not clean for restore
2697 * GPFS_E_RESTORE_NOT_ENABLED fs is not enabled for restore
2698 * EALREADY Restore already ended
2700 * Note: EALREADY indicates end restore was already called for
2701 * this fs. This could be due to a concurrent restore process that
2702 * already completed. The caller must decide if EALREADY represents
2703 * an error condition.
2706 gpfs_end_restore(gpfs_restore_t
*restoreId
);
2709 /* NAME: gpfs_ireadx()
2711 * FUNCTION: Block level incremental read on a file opened by gpfs_iopen
2712 * with a given incremental scan opened via gpfs_open_inodescan.
2714 * Input: ifile: ptr to gpfs_ifile_t returned from gpfs_iopen()
2715 * iscan: ptr to gpfs_iscan_t from gpfs_open_inodescan()
2716 * buffer: ptr to buffer for returned data
2717 * bufferSize: size of buffer for returned data
2718 * offset: ptr to offset value
2719 * termOffset: read terminates before reading this offset
2720 * caller may specify ia_size for the file's
2721 * gpfs_iattr_t or 0 to scan the entire file.
2722 * hole: ptr to returned flag to indicate a hole in the file
2724 * Returns: number of bytes read and returned in buffer
2725 * or size of hole encountered in the file. (Success)
2726 * -1 and errno is set (Failure)
2728 * On input, *offset contains the offset in the file
2729 * at which to begin reading to find a difference same file
2730 * in a previous snapshot specified when the inodescan was opened.
2731 * On return, *offset contains the offset of the first
2734 * On return, *hole indicates if the change in the file
2735 * was data (*hole == 0) and the data is returned in the
2736 * buffer provided. The function's value is the amount of data
2737 * returned. If the change is a hole in the file,
2738 * *hole != 0 and the size of the changed hole is returned
2739 * as the function value.
2741 * A call with a NULL buffer pointer will query the next increment
2742 * to be read from the current offset. The *offset, *hole and
2743 * returned length will be set for the next increment to be read,
2744 * but no data will be returned. The bufferSize parameter is
2745 * ignored, but the termOffset parameter will limit the
2746 * increment returned.
2748 * Errno: ENOSYS function not available
2749 * EINVAL missing or bad parameter
2750 * EISDIR file is a directory
2751 * EPERM caller must have superuser privilege
2752 * ESTALE cached fs information was invalid
2753 * ENOMEM unable to allocate memory for request
2754 * EDOM fs snapId does match local fs
2755 * ERANGE previous snapId is more recent than scanned snapId
2756 * GPFS_E_INVAL_IFILE bad ifile parameter
2757 * GPFS_E_INVAL_ISCAN bad iscan parameter
2758 * see system call read() ERRORS
2760 * Notes: The termOffset parameter provides a means to partition a
2761 * file's data such that it may be read on more than one node.
2763 gpfs_off64_t GPFS_API
2764 gpfs_ireadx(gpfs_ifile_t
*ifile
, /* in only */
2765 gpfs_iscan_t
*iscan
, /* in only */
2766 void *buffer
, /* in only */
2767 int bufferSize
, /* in only */
2768 gpfs_off64_t
*offset
, /* in/out */
2769 gpfs_off64_t termOffset
, /* in only */
2770 int *hole
); /* out only */
2773 /* NAME: gpfs_ireadx_ext
2775 * FUNCTION: gpfs_ireadx_ext is used to find different blocks between clone
2776 * child and parent files. Input and output are the same as
2779 * Returns: See gpfs_ireadx()
2781 gpfs_off64_t GPFS_API
2782 gpfs_ireadx_ext(gpfs_ifile_t
*ifile
, /* in only */
2783 gpfs_iscan_t
*iscan
, /* in only */
2784 void *buffer
, /* in only */
2785 int bufferSize
, /* in only */
2786 gpfs_off64_t
*offset
, /* in/out */
2787 gpfs_off64_t termOffset
, /* in only */
2791 /* NAME: gpfs_iwritex()
2793 * FUNCTION: Write file opened by gpfs_iopen.
2794 * If parameter hole == 0, then write data
2795 * addressed by buffer to the given offset for the
2796 * given length. If hole != 0, then write
2797 * a hole at the given offset for the given length.
2799 * Input: ifile : ptr to gpfs_ifile_t returned from gpfs_iopen()
2800 * buffer: ptr to data buffer
2801 * writeLen: length of data to write
2802 * offset: offset in file to write data
2803 * hole: flag =1 to write a "hole"
2806 * Returns: number of bytes/size of hole written (Success)
2807 * -1 and errno is set (Failure)
2809 * Errno: ENOSYS function not available
2810 * EINVAL missing or bad parameter
2811 * EISDIR file is a directory
2812 * EPERM caller must have superuser privilege
2813 * ESTALE cached fs information was invalid
2814 * GPFS_E_INVAL_IFILE bad ifile parameter
2815 * see system call write() ERRORS
2817 gpfs_off64_t GPFS_API
2818 gpfs_iwritex(gpfs_ifile_t
*ifile
, /* in only */
2819 void *buffer
, /* in only */
2820 gpfs_off64_t writeLen
, /* in only */
2821 gpfs_off64_t offset
, /* in only */
2822 int hole
); /* in only */
2825 /* NAME: gpfs_statfspool()
2827 * FUNCTION: Obtain status information about the storage pools
2829 * Input: pathname : path to any file in the file system
2830 * poolId : id of first pool to return
2831 * on return set to next poolId or -1
2832 * to indicate there are no more pools.
2833 * options : option flags (currently not used)
2834 * nPools : number of stat structs requested or 0
2835 * on return number of stat structs in buffer
2836 * or if nPools was 0 its value is the max number
2837 * of storage pools currently defined
2838 * buffer : ptr to return stat structures
2839 * bufferSize : sizeof stat buffer
2841 * The user is expected to issue two or more calls. On the first
2842 * call the user should pass nPools set to 0 and gpfs will
2843 * return in nPools the total number of storage pools currently
2844 * defined for the file system indicated by the pathname
2845 * and it returns in poolId the id of the first storage pool.
2846 * The buffer parameter may be set to NULL for this call.
2848 * The user may then allocate a buffer large enough to contain
2849 * a gpfs_statfspool_t structure for each of the pools and issue
2850 * a second call to obtain stat information about each pool.
2851 * Parameter nPools should be set the number of pools requested.
2852 * On return, nPools will be set to the number of stat structs
2853 * contained in the buffer, and poolId will be set to the id
2854 * of the next storage pool or -1 to indicate there are no
2855 * additional storage pools defined.
2857 * Alternatively, if the user has a valid poolId from a previous
2858 * call, the user may provide that poolId and a buffer large
2859 * enough for a single gpfs_statfspool_t structure, and the call
2860 * will return the status for a single storage pool.
2863 * Returns: 0 Successful
2866 * Errno: Specific error indication
2870 gpfs_statfspool(const char *pathname
, /* in only: path to file system*/
2871 gpfs_pool_t
*poolId
, /* in out: id of first pool to return
2872 on return set to next poolId
2873 or -1 when there are no more pools */
2874 unsigned int options
, /* in only: option flags */
2875 int *nPools
, /* in out: number of pool stats requested
2876 on return number of stat structs
2877 returned in buffer or if nPools was
2878 set to 0, the return value is the
2879 number of pools currently defined */
2880 void *buffer
, /* ptr to return stat structures */
2881 int bufferSize
); /* sizeof stat buffer or 0 */
2884 /* NAME: gpfs_getpoolname()
2886 * FUNCTION: Retrieves the name of the storage pool assigned for
2887 * this file's data. The storage pool name is a null-terminated
2888 * string, with a maximum length of GPFS_MAXNAMLEN.
2890 * Input: pathname: path to any file in the file system
2891 * poolId: f_poolid returned in gpfs_statfspool_t
2892 * buffer: pointer to buffer for returned name
2893 * bufferSize: size of buffer
2895 * Returns: 0 Successful
2896 * -1 Failure and errno is set
2898 * Errno: ENOSYS function not available
2899 * ESTALE file system was unmounted
2900 * E_FORMAT_INCOMPAT file system does not support pools
2901 * E2BIG buffer too small to return storage pool name
2904 gpfs_getpoolname(const char *pathname
,
2910 /* /usr/src/linux/include/linux/fs.h includes /usr/src/linux/include/linux/quota.h
2911 which has conflicting definitions. */
2912 #ifdef _LINUX_QUOTA_
2924 * Command definitions for the 'gpfs_quotactl' system call.
2925 * The commands are broken into a main command defined below
2926 * and a subcommand that is used to convey the type of
2927 * quota that is being manipulated (see above).
2930 #define SUBCMDMASK 0x00ff
2931 #define SUBCMDSHIFT 8
2932 #define GPFS_QCMD(cmd, type) (((cmd) << SUBCMDSHIFT) | ((type) & SUBCMDMASK))
2934 #define Q_QUOTAON 0x0100 /* enable quotas */
2935 #define Q_QUOTAOFF 0x0200 /* disable quotas */
2936 #define Q_GETQUOTA 0x0300 /* get limits and usage */
2937 #ifndef _LINUX_SOURCE_COMPAT
2938 /* Standard AIX definitions of quota commands */
2939 #define Q_SETQUOTA 0x0400 /* set limits */
2940 #define Q_SETQLIM Q_SETQUOTA
2942 /* Alternate definitions, for Linux Affinity */
2943 #define Q_SETQLIM 0x0400 /* set limits */
2944 #define Q_SETQUOTA 0x0700 /* set limits and usage */
2946 #define Q_SETUSE 0x0500 /* set usage */
2947 #define Q_SYNC 0x0600 /* sync disk copy of a file systems quotas */
2948 #define Q_SETGRACETIME 0x0900 /* set grace time */
2949 #define Q_SETGRACETIME_ENHANCE 0x0800 /* set grace time and update all
2951 #define Q_GETDQPFSET 0x0A00 /* get default quota per fileset */
2952 #define Q_SETDQPFSET 0x0B00 /* set default quota per fileset */
2953 #define Q_SETQUOTA_UPDATE_ET 0x0C00 /* this SETQUOTA needs to update entryType */
2954 #define Q_GETDQPFSYS 0x0D00 /* get default quota per file system */
2955 #define Q_SETDQPFSYS 0x0E00 /* set default quota per file system */
2957 /* gpfs quota types */
2958 #define GPFS_USRQUOTA 0
2959 #define GPFS_GRPQUOTA 1
2960 #define GPFS_FILESETQUOTA 2
2962 /* define GPFS generated errno */
2963 #define GPFS_E_NO_QUOTA_INST 237 /* file system does not support quotas */
2965 typedef struct gpfs_quotaInfo
2967 gpfs_off64_t blockUsage
; /* current block count in 1 KB units*/
2968 gpfs_off64_t blockHardLimit
; /* absolute limit on disk blks alloc */
2969 gpfs_off64_t blockSoftLimit
; /* preferred limit on disk blks */
2970 gpfs_off64_t blockInDoubt
; /* distributed shares + "lost" usage for blks */
2971 int inodeUsage
; /* current # allocated inodes */
2972 int inodeHardLimit
; /* absolute limit on allocated inodes */
2973 int inodeSoftLimit
; /* preferred inode limit */
2974 int inodeInDoubt
; /* distributed shares + "lost" usage for inodes */
2975 gpfs_uid_t quoId
; /* uid, gid or fileset id */
2976 int entryType
; /* entry type, not used */
2977 unsigned int blockGraceTime
; /* time limit for excessive disk use */
2978 unsigned int inodeGraceTime
; /* time limit for excessive inode use */
2982 /* NAME: gpfs_quotactl()
2984 * FUNCTION: Manipulate disk quotas
2985 * INPUT: pathname: specifies the pathname of any file within the
2986 * mounted file system to which the command is to
2988 * cmd: specifies a quota control command to be applied
2989 * to UID/GID/FILESETID id. The cmd parameter can be
2990 * constructed using GPFS_QCMD(cmd, type) macro defined
2992 * id: UID or GID or FILESETID that command applied to.
2993 * bufferP: points to the address of an optional, command
2994 * specific, data structure that is copied in or out of
2997 * OUTPUT: bufferP, if applicable.
2999 * Returns: 0 success
3003 * EFAULT An invalid bufferP parameter is supplied;
3004 * the associated structure could not be copied
3005 * in or out of the kernel
3007 * ENOENT No such file or directory
3008 * EPERM The quota control command is privileged and
3009 * the caller did not have root user authority
3011 * GPFS_E_NO_QUOTA_INST The file system does not support quotas
3014 gpfs_quotactl(const char *pathname
,
3020 /* NAME: gpfs_getfilesetid()
3022 * FUNCTION: Translate FilesetName to FilesetID
3024 * INPUT: pathname: specifies the pathname of any file within the
3025 * mounted file system to which the command is to
3027 * name: name of the fileset
3029 * OUTPUT: idP: points to the address of an integer that receives the ID
3031 * Returns: 0 success
3035 * EFAULT An invalid pointer is supplied; the associated
3036 * data could not be copied in or out of the kernel
3038 * ENOENT No such file, directory or fileset
3041 gpfs_getfilesetid(const char *pathname
,
3046 /* NAME: gpfs_clone_snap()
3048 * FUNCTION: Create an immutable clone parent from a source file
3050 * Input: sourcePathP: path to source file, which will be cloned
3051 * destPathP: path to destination file, to be created
3053 * If destPathP is NULL, then the source file will be changed
3054 * in place into an immutable clone parent.
3056 * Returns: 0 Successful
3059 * Errno: ENOSYS Function not available
3060 * ENOENT File does not exist
3061 * EACCESS Write access to target or source search permission denied
3062 * EINVAL Not a regular file or not a GPFS file system
3063 * EFAULT Input argument points outside accessible address space
3064 * ENAMETOOLONG Source or destination path name too long
3065 * ENOSPC Not enough space on disk
3066 * EISDIR Destination is a directory
3067 * EXDEV Source and destination aren't in the same file system
3068 * EROFS Destination is read-only
3069 * EPERM Invalid source file
3070 * EEXIST Destination file already exists
3071 * EBUSY Source file is open
3072 * EFORMAT File system does not support clones
3073 * EMEDIUMTYPE File system does not support clones
3076 gpfs_clone_snap(const char *sourcePathP
, const char *destPathP
);
3078 /* NAME: gpfs_clone_copy()
3080 * FUNCTION: Create a clone copy of an immutable clone parent file
3082 * Input: sourcePathP: path to immutable source file, to be cloned
3083 * destPathP: path to destination file, to be created
3085 * Returns: 0 Successful
3088 * Errno: ENOSYS Function not available
3089 * ENOENT File does not exist
3090 * EACCESS Write access to target or source search permission denied
3091 * EINVAL Not a regular file or not a GPFS file system
3092 * EFAULT Input argument points outside accessible address space
3093 * ENAMETOOLONG Source or destination path name too long
3094 * ENOSPC Not enough space on disk
3095 * EISDIR Destination is a directory
3096 * EXDEV Source and destination aren't in the same file system
3097 * EROFS Destination is read-only
3098 * EPERM Invalid source or destination file
3099 * EEXIST Destination file already exists
3100 * EFORMAT File system does not support clones
3101 * EMEDIUMTYPE File system does not support clones
3104 gpfs_clone_copy(const char *sourcePathP
, const char *destPathP
);
3107 /* NAME: gpfs_declone()
3109 * FUNCTION: Copy blocks from clone parent(s) to child so that the
3110 * parent blocks are no longer referenced by the child.
3112 * Input: fileDesc: File descriptor for file to be de-cloned
3113 * ancLimit: Ancestor limit (immediate parent only, or all)
3114 * nBlocks: Maximum number of GPFS blocks to copy
3115 * In/Out: offsetP: Pointer to starting offset within file (will be
3116 * updated to offset of next block to process or
3117 * -1 if no more blocks)
3119 * Returns: 0 Successful
3122 * Errno: ENOSYS Function not available
3123 * EINVAL Invalid argument to function
3124 * EBADF Bad file descriptor or not a GPFS file
3125 * EPERM Not a regular file
3126 * EACCESS Write access to target file not permitted
3127 * EFAULT Input argument points outside accessible address space
3128 * ENOSPC Not enough space on disk
3131 /* Values for ancLimit */
3132 #define GPFS_CLONE_ALL 0
3133 #define GPFS_CLONE_PARENT_ONLY 1
3136 gpfs_declone(gpfs_file_t fileDesc
, int ancLimit
, gpfs_off64_t nBlocks
,
3137 gpfs_off64_t
*offsetP
);
3139 /* NAME: gpfs_clone_split()
3141 * FUNCTION: Split a clone child file from its parent. Must call
3142 * gpfs_declone first, to remove all references.
3144 * Input: fileDesc: File descriptor for file to be split
3145 * ancLimit: Ancestor limit (immediate parent only, or all)
3147 * Returns: 0 Successful
3150 * Errno: ENOSYS Function not available
3151 * EINVAL Invalid argument to function
3152 * EBADF Bad file descriptor or not a GPFS file
3153 * EPERM Not a regular file or not a clone child
3154 * EACCESS Write access to target file not permitted
3157 gpfs_clone_split(gpfs_file_t fileDesc
, int ancLimit
);
3159 /* NAME: gpfs_clone_unsnap()
3161 * FUNCTION: Change a clone parent with no children back into a
3164 * Input: fileDesc: File descriptor for file to be un-snapped
3166 * Returns: 0 Successful
3169 * Errno: ENOSYS Function not available
3170 * EINVAL Invalid argument to function
3171 * EBADF Bad file descriptor or not a GPFS file
3172 * EPERM Not a regular file or not a clone parent
3173 * EACCESS Write access to target file not permitted
3176 gpfs_clone_unsnap(gpfs_file_t fileDesc
);
3178 /* NAME: gpfs_get_fset_masks()
3180 * FUNCTION: return bit masks governing "external" inode and inode-space numbering
3182 * Input: fset_snaphandle: ptr to an fset snaphandle
3183 * Output: the bit masks and inodes per block factor.
3185 * Returns: 0 Success
3188 * Errno: ENOSYS function not available
3189 * GPFS_E_INVAL_FSSNAPHANDLE invalid fssnapHandle
3192 gpfs_get_fset_masks(gpfs_fssnap_handle_t
* fset_snapHandle
,
3193 gpfs_ino64_t
* inodeSpaceMask
,
3194 gpfs_ino64_t
* inodeBlockMask
,
3195 int* inodesPerInodeBlock
);
3199 * API functions for Light Weight Event
3203 * Define light weight event types
3207 GPFS_LWE_EVENT_UNKNOWN
= 0, /* "Uknown event" */
3208 GPFS_LWE_EVENT_FILEOPEN
= 1, /* 'OPEN' - look at getInfo('OPEN_FLAGS') if you care */
3209 GPFS_LWE_EVENT_FILECLOSE
= 2, /* "File Close Event" 'CLOSE' */
3210 GPFS_LWE_EVENT_FILEREAD
= 3, /* "File Read Event" 'READ' */
3211 GPFS_LWE_EVENT_FILEWRITE
= 4, /* "File Write Event" 'WRITE' */
3212 GPFS_LWE_EVENT_FILEDESTROY
= 5, /* File is being destroyed 'DESTROY' */
3213 GPFS_LWE_EVENT_FILEEVICT
= 6, /* OpenFile object is being evicted from memory 'FILE_EVICT' */
3214 GPFS_LWE_EVENT_BUFFERFLUSH
= 7, /* Data buffer is being written to disk 'BUFFER_FLUSH' */
3215 GPFS_LWE_EVENT_POOLTHRESHOLD
= 8, /* Storage pool exceeded defined utilization 'POOL_THRESHOLD' */
3216 GPFS_LWE_EVENT_FILEDATA
= 9, /* "Read/Write/Trunc" event on open file */
3217 GPFS_LWE_EVENT_FILERENAME
= 10, /* Rename event on open file */
3218 GPFS_LWE_EVENT_FILEUNLINK
= 11, /* Unlink file event */
3219 GPFS_LWE_EVENT_FILERMDIR
= 12, /* Remove directory event */
3220 GPFS_LWE_EVENT_EVALUATE
= 13, /* Evaluate And Set Events */
3222 GPFS_LWE_EVENT_FILEOPEN_READ
= 14, /* Open for Read Only - EVENT 'OPEN_READ' - deprecated, use 'OPEN' */
3223 GPFS_LWE_EVENT_FILEOPEN_WRITE
= 15, /* Open with Writing privileges - EVENT 'OPEN_WRITE' - deprecated, use 'OPEN' */
3225 GPFS_LWE_EVENT_FILEPOOL_CHANGE
= 16, /* Open with Writing privileges - EVENT 'OPEN_WRITE' - deprecated, use 'OPEN' */
3226 GPFS_LWE_EVENT_XATTR_CHANGE
= 17, /* EAs of file are changed */
3227 GPFS_LWE_EVENT_ACL_CHANGE
= 18, /* ACLs (both GPFS ACLs and Posix permissions) of a file are changed */
3228 GPFS_LWE_EVENT_CREATE
= 19, /* create, including mkdir, symlink, special file */
3229 GPFS_LWE_EVENT_GPFSATTR_CHANGE
= 20, /* ts-specific attributes of file are changed */
3230 GPFS_LWE_EVENT_FILETRUNCATE
= 21, /* "File Truncate Event" 'TRUNCATE' */
3231 GPFS_LWE_EVENT_FS_UNMOUNT_ALL
= 22, /* FS is not externally mounted anywhere */
3233 GPFS_LWE_EVENT_MAX
= 23, /* 1 greater than any of the above */
3234 } gpfs_lwe_eventtype_t
;
3237 /* Define light weight event response types */
3240 GPFS_LWE_RESP_INVALID
= 0, /* "Response Invalid/Unknown" */
3241 GPFS_LWE_RESP_CONTINUE
= 1, /* "Response Continue" */
3242 GPFS_LWE_RESP_ABORT
= 2, /* "Response Abort" */
3243 GPFS_LWE_RESP_DONTCARE
= 3 /* "Response DontCare" */
3247 * Define light weight event inofrmation
3249 #define LWE_DATA_FS_NAME 0x00000001 /* "fsName" */
3250 #define LWE_DATA_PATH_NAME 0x00000002 /* "pathName" */
3251 #define LWE_DATA_PATH_NEW_NAME 0x00000004 /* "pathNewName" for reanem */
3252 #define LWE_DATA_URL 0x00000008 /* "URL" */
3253 #define LWE_DATA_INODE 0x00000010 /* "inode" */
3254 #define LWE_DATA_OPEN_FLAGS 0x00000020 /* "openFlags" */
3255 #define LWE_DATA_POOL_NAME 0x00000040 /* "poolName" */
3256 #define LWE_DATA_FILE_SIZE 0x00000080 /* "fileSize" */
3257 #define LWE_DATA_OWNER_UID 0x00000100 /* "ownerUserId" */
3258 #define LWE_DATA_OWNER_GID 0x00000200 /* "ownerGroupId" */
3259 #define LWE_DATA_ATIME 0x00000400 /* "atime" */
3260 #define LWE_DATA_MTIME 0x00000800 /* "mtime" */
3261 #define LWE_DATA_NOW_TIME 0x00001000 /* "nowTime" */
3262 #define LWE_DATA_ELAPSED_TIME 0x00002000 /* "elapsedTime" */
3263 #define LWE_DATA_CLIENT_UID 0x00004000 /* "clientUserId" */
3264 #define LWE_DATA_CLIENT_GID 0x00008000 /* "clientGroupId" */
3265 #define LWE_DATA_NFS_IP 0x00010000 /* "clientIp" */
3266 #define LWE_DATA_PROCESS_ID 0x00020000 /* "processId" */
3267 #define LWE_DATA_TARGET_POOL_NAME 0x00040000 /* "targetPoolName" */
3268 #define LWE_DATA_BYTES_READ 0x00080000 /* "bytesRead" */
3269 #define LWE_DATA_BYTES_WRITTEN 0x00100000 /* "bytesWritten" */
3270 #define LWE_DATA_CLUSTER_NAME 0x00200000 /* "clusterName" */
3271 #define LWE_DATA_NODE_NAME 0x00400000 /* "nodeName" */
3272 #define LWE_DATA_LWESEND 0x00800000 /* "lweSend" */
3275 * Define light weight events
3277 #define LWE_EVENT_EVALUATED 0x00000001 /* policy was evaluated */
3278 #define LWE_EVENT_FILEOPEN 0x00000002 /* "op_open" */
3279 #define LWE_EVENT_FILECLOSE 0x00000004 /* "op_close" */
3280 #define LWE_EVENT_FILEREAD 0x00000008 /* "op_read" */
3281 #define LWE_EVENT_FILEWRITE 0x00000010 /* "op_write" */
3282 #define LWE_EVENT_FILEDESTROY 0x00000020 /* "op_destroy" */
3283 #define LWE_EVENT_FILEEVICT 0x00000040 /* "op_evict" OpenFile object is being evicted from memory 'FILE_EVICT' */
3284 #define LWE_EVENT_BUFFERFLUSH 0x00000080 /* "op_buffer_flush" Data buffer is being written to disk 'BUFFER_FLUSH' */
3285 #define LWE_EVENT_POOLTHRESHOLD 0x00000100 /* "op_pool_threshhold" Storage pool exceeded defined utilization 'POOL_THRESHOLD' */
3286 #define LWE_EVENT_FILEDATA 0x00000200 /* "op_data" "Read/Write/Trunc" event on open file */
3287 #define LWE_EVENT_FILERENAME 0x00000400 /* "op_rename" Rename event on open file */
3288 #define LWE_EVENT_FILEUNLINK 0x00000800 /* "op_unlink" Unlink file event */
3289 #define LWE_EVENT_FILERMDIR 0x00001000 /* "op_rmdir" Remove directory event */
3290 #define LWE_EVENT_FILEOPEN_READ 0x00002000 /* "op_open_read" Open for Read Only - EVENT 'OPEN_READ' - deprecated, use 'OPEN' */
3291 #define LWE_EVENT_FILEOPEN_WRITE 0x00004000 /* "op_open_write" Open with Writing privileges - EVENT 'OPEN_WRITE' - deprecated, use 'OPEN' */
3292 #define LWE_EVENT_FILEPOOL_CHANGE 0x00008000 /* "op_pool_change" Open with Writing privileges - EVENT 'OPEN_WRITE' - deprecated, use 'OPEN' */
3295 * Defines for light weight sessions
3297 typedef unsigned long long gpfs_lwe_sessid_t
;
3298 #define GPFS_LWE_NO_SESSION ((gpfs_lwe_sessid_t) 0)
3299 #define GPFS_LWE_SESSION_INFO_LEN 256
3303 * Define light weight token to identify access right
3305 typedef struct gpfs_lwe_token
3307 unsigned long long high
;
3308 unsigned long long low
;
3311 bool operator == (const struct gpfs_lwe_token
& rhs
) const
3312 { return high
== rhs
.high
&& low
== rhs
.low
; };
3313 bool operator != (const struct gpfs_lwe_token
& rhs
) const
3314 { return high
!= rhs
.high
|| low
!= rhs
.low
; };
3315 #endif /* __cplusplus */
3319 /* Define special tokens */
3320 static const gpfs_lwe_token_t _gpfs_lwe_no_token
= { 0, 0 };
3321 #define GPFS_LWE_NO_TOKEN _gpfs_lwe_no_token
3323 static const gpfs_lwe_token_t _gpfs_lwe_invalid_token
= { 0, 1 };
3324 #define GPFS_LWE_INVALID_TOKEN _gpfs_lwe_invalid_token
3327 * Note: LWE data managers can set a file's off-line bit
3328 * or any of the managed bits visible to the policy language
3329 * by calling dm_set_region or dm_set_region_nosync
3330 * with a LWE session and LWE exclusive token. To set the bits
3331 * there must be * exactly one managed region with offset = -1
3332 * and size = 0. Any other values will return EINVAL.
3335 /* LWE also provides light weight regions
3336 * that are set via policy rules.
3338 #define GPFS_LWE_MAX_REGIONS 2
3340 /* LWE data events are generated from user access
3341 * to a LWE managed region. */
3342 #define GPFS_LWE_DATAEVENT_NONE (0x0)
3343 #define GPFS_LWE_DATAEVENT_READ (0x1)
3344 #define GPFS_LWE_DATAEVENT_WRITE (0x2)
3345 #define GPFS_LWE_DATAEVENT_TRUNCATE (0x4)
3346 #define GPFS_LWE_ATTRCHANGEEVENT_IMMUTABILITY (0x8)
3347 #define GPFS_LWE_ATTRCHANGEEVENT_APPENDONLY (0x10)
3352 * Define light weight event structure
3354 typedef struct gpfs_lwe_event
{
3355 int eventLen
; /* offset 0 */
3356 gpfs_lwe_eventtype_t eventType
; /* offset 4 */
3357 gpfs_lwe_token_t eventToken
; /* offset 8 <--- Must on DWORD */
3358 int isSync
; /* offset 16 */
3359 int parmLen
; /* offset 20 */
3360 char* parmP
; /* offset 24 <-- Must on DWORD */
3366 * Define light weight access rights
3368 #define GPFS_LWE_RIGHT_NULL 0
3369 #define GPFS_LWE_RIGHT_SHARED 1
3370 #define GPFS_LWE_RIGHT_EXCL 2
3373 /* Flag indicating whether to wait
3374 * when requesting a right or an event
3376 #define GPFS_LWE_FLAG_NONE 0
3377 #define GPFS_LWE_FLAG_WAIT 1
3383 /* NAME: gpfs_lwe_create_session()
3385 * FUNCTION: create a light weight event session
3387 * Input: oldsid: existing session id,
3388 * Set to GPFS_LWE_NO_SESSION to start new session
3389 * - If a session with the same name and id already exists
3390 * it is not terminated, nor will outstanding events
3391 * be redelivered. This is typically used if a session
3392 * is shared between multiple processes.
3393 * Set to an existing session's id to resume that session
3394 * - If a session with the same name exists, that session
3395 * will be terminated. All pending/outstanding events
3396 * for the old session will be redelivered on the new one.
3397 * This is typically used to take over a session from a
3398 * failed/hung process.
3399 * sessinfop: session string, unique for each session
3401 * Output: newsidp: session id for new session
3403 * Returns: 0 Success
3406 * Errno: ENOSYS Function not available
3407 * EINVAL invalid parameters
3408 * ENFILE maximum number of sessions have already been created
3409 * ENOMEM insufficient memory to create new session
3410 * ENOENT session to resume does not exist
3411 * EEXIST session to resume exists with different id
3412 * EPERM Caller does not hold appropriate privilege
3415 gpfs_lwe_create_session(gpfs_lwe_sessid_t oldsid
, /* IN */
3416 char *sessinfop
, /* IN */
3417 gpfs_lwe_sessid_t
*newsidp
); /* OUT */
3419 #define GPFS_MAX_LWE_SESSION_INFO_LEN 100
3423 /* NAME: gpfs_lwe_destroy_session()
3425 * FUNCTION: destroy a light weight event session
3427 * Input: sid: id of the session to be destroyed
3429 * Returns: 0 Success
3432 * Errno: ENOSYS Function not available
3433 * EINVAL sid invalid
3434 * EBUSY session is busy
3435 * EPERM Caller does not hold appropriate privilege
3438 gpfs_lwe_destroy_session(gpfs_lwe_sessid_t sid
); /* IN */
3443 /* NAME: gpfs_lwe_getall_sessions()
3445 * FUNCTION: fetch all lwe sessions
3447 * Input: nelem: max number of elements
3448 * sidbufp: array of session id
3449 * nelemp: number of session returned in sidbufp
3451 * Returns: 0 Success
3454 * Errno: ENOSYS Function not available
3455 * EINVAL pass in args invalid
3456 * E2BIG information is too large
3457 * EPERM Caller does not hold appropriate privilege
3460 gpfs_lwe_getall_sessions(unsigned int nelem
, /* IN */
3461 gpfs_lwe_sessid_t
*sidbufp
, /* OUT */
3462 unsigned int *nelemp
); /* OUT */
3465 /* NAME: gpfs_lw_query_session()
3467 * FUNCTION: query session string by id
3469 * Input: sid: id of session to be queryed
3470 * buflen: length of buffer
3471 * bufp: buffer to store sessions string
3472 * rlenp: returned length of bufp
3474 * Returns: 0 Success
3477 * Errno: ENOSYS Function not available
3478 * EINVAL pass in args invalid
3479 * E2BIG information is too large
3480 * EPERM Caller does not hold appropriate privilege
3483 gpfs_lwe_query_session(gpfs_lwe_sessid_t sid
, /* IN */
3484 size_t buflen
, /* IN */
3485 void *bufp
, /* OUT */
3486 size_t *rlenP
); /* OUT */
3489 /* NAME: gpfs_lwe_get_events()
3491 * FUNCTION: get events from a light weight session
3493 * Input: sid: id of the session
3494 * maxmsgs: max number of event to fetch,
3495 * 0 to fetch all possible
3496 * flags: GPFS_LWE_EV_WAIT: waiting for new events if event
3498 * buflen: length of the buffer
3499 * bufp: buffer to hold events
3500 * rlenp: returned length of bufp
3502 * Returns: 0 Success
3503 * E2BIG information is too large
3504 * EINVAL pass in args invalid
3507 gpfs_lwe_get_events(gpfs_lwe_sessid_t sid
, /* IN */
3508 unsigned int maxmsgs
, /* IN */
3509 unsigned int flags
, /* IN */
3510 size_t buflen
, /* IN */
3511 void *bufp
, /* OUT */
3512 size_t *rlenp
); /* OUT */
3514 /* NAME: gpfs_lwe_respond_event()
3516 * FUNCTION: response to a light weight event
3518 * Input: sid: id of the session
3519 * token: token of the event
3520 * response: response to the event
3521 * reterror: return error to event callers
3523 * Returns: 0 Success
3524 * EINVAL pass in args invalid
3528 gpfs_lwe_respond_event(gpfs_lwe_sessid_t sid
, /* IN */
3529 gpfs_lwe_token_t token
, /* IN */
3530 gpfs_lwe_resp_t response
, /* IN */
3531 int reterror
); /* IN */
3534 /* NAME: gpfs_lwe_request_right
3536 * FUNCTION: Request an access right to a file using a dmapi handle
3538 * Input: sid Id of lw session
3539 * hanp Pointer to dmapi handle
3540 * hlen Length of dmapi handle
3541 * right Shared or exclusive access requested
3542 * flags Caller will wait to acquire access if necessary
3544 * Output: token Unique identifier for access right
3546 * Returns: 0 Success
3549 * Errno: ENOSYS Function not available
3550 * ESTALE GPFS not available
3551 * EINVAL Invalid arguments
3552 * EFAULT Invalid pointer provided
3554 * ENOMEM Uable to allocate memory for request
3555 * EPERM Caller does not hold appropriate privilege
3556 * EAGAIN flags parameter did not include WAIT
3557 * and process would be blocked
3561 gpfs_lwe_request_right(gpfs_lwe_sessid_t sid
, /* IN */
3562 void *hanp
, /* IN */
3563 size_t hlen
, /* IN */
3564 unsigned int right
, /* IN */
3565 unsigned int flags
, /* IN */
3566 gpfs_lwe_token_t
*token
); /* OUT */
3569 /* NAME: gpfs_lwe_upgrade_right
3571 * FUNCTION: Upgrade an access right from shared to exclusive
3573 * This is a non-blocking call to upgrade an access right
3574 * from shared to exclusive. If the token already conveys
3575 * exclusive access this call returns imediately with sucess.
3576 * If another process also holds a shared access right
3577 * this call fails with EBUSY to avoid deadlocks.
3579 * Input: sid Id of lw session
3580 * hanp Pointer to dmapi handle
3581 * hlen Length of dmapi handle
3582 * token Unique identifier for access right
3586 * Returns: 0 Success
3589 * Errno: ENOSYS Function not available
3590 * ESTALE GPFS not available
3591 * EINVAL Invalid arguments
3592 * EINVAL The token is invalid
3593 * EFAULT Invalid pointer provided
3594 * EPERM Caller does not hold appropriate privilege
3595 * EPERM Token's right is not shared or exclusive
3596 * EBUSY Process would be blocked
3600 gpfs_lwe_upgrade_right(gpfs_lwe_sessid_t sid
, /* IN */
3601 void *hanp
, /* IN */
3602 size_t hlen
, /* IN */
3603 gpfs_lwe_token_t token
); /* IN */
3606 /* NAME: gpfs_lwe_downgrade_right
3608 * FUNCTION: Downgrade an access right from exclusive to shared
3610 * This reduces an access right from exclusive to shared
3611 * without dropping the exclusive right to acquire the shared.
3612 * The token must convey exclusive right before the call.
3614 * Input: sid Id of lw session
3615 * hanp Pointer to dmapi handle
3616 * hlen Length of dmapi handle
3617 * token Unique identifier for access right
3621 * Returns: 0 Success
3624 * Errno: ENOSYS Function not available
3625 * ESTALE GPFS not available
3626 * EINVAL Invalid arguments
3627 * EINVAL The token is invalid
3628 * EFAULT Invalid pointer provided
3629 * EPERM Caller does not hold appropriate privilege
3630 * EPERM Token's right is not exclusive
3634 gpfs_lwe_downgrade_right(gpfs_lwe_sessid_t sid
, /* IN */
3635 void *hanp
, /* IN */
3636 size_t hlen
, /* IN */
3637 gpfs_lwe_token_t token
); /* IN */
3640 /* NAME: gpfs_lwe_release_right
3642 * FUNCTION: Release an access right conveyed by a token
3644 * This releases the access right held by a token
3645 * and invalidates the token. Once the access right
3646 * is released the token cannot be reused.
3648 * Input: sid Id of lw session
3649 * hanp Pointer to dmapi handle
3650 * hlen Length of dmapi handle
3651 * token Unique identifier for access right
3655 * Returns: 0 Success
3658 * Errno: ENOSYS Function not available
3659 * ESTALE GPFS not available
3660 * EINVAL Invalid arguments
3661 * EINVAL The token is invalid
3662 * EFAULT Invalid pointer provided
3663 * EPERM Caller does not hold appropriate privilege
3666 gpfs_lwe_release_right(gpfs_lwe_sessid_t sid
, /* IN */
3667 void *hanp
, /* IN */
3668 size_t hlen
, /* IN */
3669 gpfs_lwe_token_t token
); /* IN */
3672 /* NAME: gpfs_lwe_getattrs()
3674 * FUNCTION: Retrieves all extended file attributes in opaque format.
3675 * This function together with gpfs_lwe_putattrs is intended for
3676 * use by a backup program to save (gpfs_lwe_getattrs) and
3677 * restore (gpfs_lwe_putattrs) all extended file attributes
3678 * (ACLs, user attributes, ...) in one call.
3680 * NOTE: This call is the lwe equivalent of gpfs_igetattrsx
3681 * but uses a file handle to identify the file
3682 * and an existing LWE token for locking it.
3685 * Input: sid Id of lw session
3686 * hanp Pointer to dmapi handle
3687 * hlen Length of dmapi handle
3688 * token Unique identifier for access right
3689 * flags Define behavior of get attributes
3690 * GPFS_ATTRFLAG_NO_PLACEMENT - file attributes for placement
3691 * are not saved, neither is the current storage pool.
3692 * GPFS_ATTRFLAG_IGNORE_POOL - file attributes for placement
3693 * are saved, but the current storage pool is not.
3694 * GPFS_ATTRFLAG_INCL_DMAPI - file attributes for dmapi are
3695 * included in the returned buffer
3696 * GPFS_ATTRFLAG_INCL_ENCR - file attributes for encryption
3697 * are included in the returned buffer
3699 * buffer: pointer to buffer for returned attributes
3700 * bufferSize: size of buffer
3701 * attrSize: ptr to returned size of attributes
3703 * Returns: 0 Successful
3706 * Errno: ENOSYS function not available
3707 * EINVAL Not a GPFS file
3708 * EINVAL invalid flags provided
3709 * ENOSPC buffer too small to return all attributes
3710 * *attrSizeP will be set to the size necessary
3713 gpfs_lwe_getattrs(gpfs_lwe_sessid_t sid
,
3716 gpfs_lwe_token_t token
,
3723 /* NAME: gpfs_lwe_putattrs()
3725 * FUNCTION: Sets all extended file attributes of a file.
3727 * This routine can optionally invoke the policy engine
3728 * to match a RESTORE rule using the file's attributes saved
3729 * in the extended attributes to set the file's storage pool and
3730 * data replication as when calling gpfs_fputattrswithpathname.
3731 * When used with the policy the caller should include the
3732 * full path to the file, including the file name, to allow
3733 * rule selection based on file name or path.
3735 * By default, the routine will not use RESTORE policy rules
3736 * for data placement. The pathName parameter will be ignored
3737 * and may be set to NULL.
3739 * If the call does not use RESTORE policy rules, or if the
3740 * file fails to match a RESTORE rule, or if there are no
3741 * RESTORE rules installed, then the storage pool and data
3742 * replication are selected as when calling gpfs_fputattrs().
3744 * The buffer passed in should contain extended attribute data
3745 * that was obtained by a previous call to gpfs_fgetattrs.
3747 * pathName is a UTF-8 encoded string. On Windows, applications
3748 * can convert UTF-16 ("Unicode") to UTF-8 using the platforms
3749 * WideCharToMultiByte function.
3751 * NOTE: This call is the lwe equivalent of gpfs_iputaattrsx
3752 * but uses a file handle to identify the file
3753 * and an existing LWE token for locking it.
3756 * Input: sid Id of lw session
3757 * hanp Pointer to dmapi handle
3758 * hlen Length of dmapi handle
3759 * token Unique identifier for access right
3760 * flags Define behavior of put attributes
3761 * GPFS_ATTRFLAG_NO_PLACEMENT - file attributes are restored
3762 * but the storage pool and data replication are unchanged
3763 * GPFS_ATTRFLAG_IGNORE_POOL - file attributes are restored
3764 * but the storage pool and data replication are selected
3765 * by matching the saved attributes to a placement rule
3766 * instead of restoring the saved storage pool.
3767 * GPFS_ATTRFLAG_USE_POLICY - file attributes are restored
3768 * but the storage pool and data replication are selected
3769 * by matching the saved attributes to a RESTORE rule
3770 * instead of restoring the saved storage pool.
3771 * GPFS_ATTRFLAG_FINALIZE_ATTRS - file attributes that are restored
3772 * after data is retored. If file is immutable/appendOnly
3773 * call without this flag before restoring data
3774 * then call with this flag after restoring data
3775 * GPFS_ATTRFLAG_INCL_ENCR - file attributes for encryption
3776 * are restored. Note that this may result in the file's
3777 * File Encryption Key (FEK) being changed, and in this
3778 * case any prior content in the file is effectively lost.
3779 * This option should only be used when the entire file
3780 * content is restored after the attributes are restored.
3782 * buffer: pointer to buffer for returned attributes
3783 * pathName: pointer to file path and file name for file
3784 * May be set to NULL.
3786 * Returns: 0 Successful
3787 * -1 Failure and errno is set
3789 * Errno: ENOSYS function not available
3790 * EINVAL the buffer does not contain valid attribute data
3791 * EINVAL invalid flags provided
3792 * EPERM caller must have superuser privilege
3793 * ESTALE cached fs information was invalid
3794 * GPFS_E_INVAL_IFILE bad ifile parameters
3797 gpfs_lwe_putattrs(gpfs_lwe_sessid_t sid
,
3800 gpfs_lwe_token_t token
,
3803 const char *pathName
);
3805 const char* GPFS_API
3806 gpfs_get_fspathname_from_fsname(const char* fsname_or_path
);
3807 /* Check that fsname_or_path refers to a GPFS file system and find the path to its root
3808 Return a strdup()ed copy of the path -OR- NULL w/errno
3814 const char *fspathname
, /* in only: path to file system*/
3815 unsigned int options
, /* in only: option flags: 0=begin at specified qip, 1=begin after qip */
3816 unsigned int qosid
, /* in only: 0 or a specific qosid at which to start or continue */
3817 gpfs_pool_t poolid
, /* in only: -1 or a specific poolid at which to start or continue */
3818 unsigned int mqips
, /* in only: max number of qip=(qosid,poolid) histories to retrieve */
3819 unsigned int nslots
, /* in only: max number of time slots of history to retrieve */
3820 void *bufferP
, /* ptr to return stat structures */
3821 unsigned int bufferSize
); /* sizeof stat buffer or 0 */
3826 const char *fspathname
, /* in only: path to file system*/
3827 void *bufferP
, /* in/out control/get/set structs */
3828 unsigned int bufferSize
);
3832 const char *fspathname
,
3833 const char *classname
, /* "gold", "silver", or .. "1" or "2" .. */
3834 int id
, /* process id or pgrp or userid */
3835 int which
, /* process, pgrp or user */
3836 double* qshareP
); /* return the share, percentage or when negative IOP limit */
3837 /* if id==0 then getpid() or getpgrp() or getuid()
3838 if which==0 or 1 then process, if 2 process then group, if 3 then userid
3839 Return -1 on error, with errno=
3840 ENOSYS if QOS is not available in the currently installed GPFS software.
3841 ENOENT if classname is not recognized.
3842 ENXIO if QOS throttling is not active
3843 (but classname is recognized and *qshareP has configured value)
3846 /* For the given process get QOS info */
3849 const char *fspathname
,
3851 char classname
[GPFS_MAXNAMLEN
+1], /* "gold", "silver", or .. "1" or "2" .. */
3852 int id
, /* process id or pgrp or userid */
3853 int which
, /* process, pgrp or user */
3854 double* qshareP
); /* return the share, percentage or when negative IOP limit */
3856 /* given classname, set *classnumP and set *qshareP
3857 Return -1 on error, with errno=
3858 ENOSYS if QOS is not available in the currently installed GPFS software.
3859 ENOENT if classname is not recognized.
3860 ENXIO if QOS throttling is not active
3861 (but classname is recognized, *classnumP and *qshareP have configured values)
3865 const char *fspathname
,
3867 const char *classname
,
3870 /* given classnumber, find name and share (similar to above), but start with number instead of name */
3873 const char *fspathname
,
3875 char classname
[GPFS_MAXNAMLEN
+1],
3879 gpfs_ioprio_set(int,int,int); /* do not call directly */
3882 gpfs_ioprio_get(int,int); /* do not call directly */
3885 /* NAME: gpfs_enc_file_rewrap_key()
3887 * FUNCTION: Re-wrap the File Encryption Key (FEK) for the file,
3888 * replacing the usage of the original (second parameter)
3889 * Master Encryption Key (MEK) with the new key provided as
3890 * the third parameter. The content of the file remains intact.
3892 * If the FEK is not currently being wrapped with the MEK
3893 * identified by the second parameter then no action is taken.
3895 * This function is normally invoked before the original MEK is
3898 * The file may be opened in read-only mode for this function
3899 * to perform the key rewrap.
3901 * Superuser privilege is required to invoke this API.
3903 * INPUT: fileDesc: File descriptor for file whose key is to be rewrapped
3904 * orig_key_p: Key ID for the key (MEK) to be replaced
3905 * new_key_p: Key ID for the new key (MEK) to be used
3909 * Returns: 0 success
3913 * EACCESS Existing or new key cannot be retrieved
3914 * The new key is already being used to wrap the
3916 * EBADF Bad file descriptor
3917 * EINVAL Arguments are invalid: key format is incorrect
3918 * EFAULT An invalid pointer is supplied; the associated
3919 * data could not be copied in or out of the kernel
3920 * E2BIG Key IDs provided are too long
3921 * ENOSYS Function not available (cluster or file system not
3922 * enabled for encryption)
3923 * EPERM File is in a snapshot
3924 * Caller must have superuser privilege
3927 /* The Key ID is a string comprised of the key ID and the remote key
3928 server RKM ID, separated by ':' */
3929 typedef const char *gpfs_enc_key_id_t
; /* "<KEY ID> : <KMS ID>" */
3932 gpfs_enc_file_rewrap_key(gpfs_file_t fileDesc
,
3933 gpfs_enc_key_id_t orig_key_p
,
3934 gpfs_enc_key_id_t new_key_p
);
3937 /* NAME: gpfs_enc_get_algo()
3939 * FUNCTION: Retrieve a string describing the encryption algorithm, key
3940 * length, Master Encryption Key(s) ID, and wrapping and combining
3941 * mechanisms used for the file.
3943 * INPUT: fileDesc: File descriptor for file whose encryption
3944 * algorithm is being retrieved
3945 * encryption_xattrP: content of the gpfs.Encryption
3946 * extended attribute, retrieved by a call to
3947 * gpfs_fcntl (with structure type GPFS_FCNTL_GET_XATTR)
3948 * xattr_len: length of the data in encryption_xattrP
3949 * algo_txt_size: space reserved by the caller for algo_txtP
3951 * OUTPUT: algo_txtP: NULL-terminated string describing the
3952 * encryption for the file
3954 * Returns: 0 success
3958 * ENOENT File not found
3959 * EBADF Bad file handle, not a GPFS file
3960 * EACCESS Permission denied
3961 * EFAULT Bad address provided
3962 * EINVAL Not a regular file
3963 * EINVAL Invalid values for xattr_len or algo_txt_size
3964 * EINVAL Invalid content of encryption extended attribute
3965 * ENOSYS Function not available
3966 * E2BIG Output string does not fit in algo_txtP
3970 gpfs_enc_get_algo(gpfs_file_t fileDesc
,
3971 const char *encryption_xattrP
,
3977 /* NAME: gpfs_init_trace()
3979 * FUNCTION: Initialize the GPFS trace facility and start to use it.
3980 * Must be called before calling gpfs_add_trace().
3982 * Returns: 0 Success
3985 * Errno: ENOENT file not found
3986 * ENOMEM Memory allocation failed
3987 * EACCESS Permission denied
3988 * ENFILE Too many open files
3989 * ENOSYS Function not available
3992 gpfs_init_trace(void);
3994 /* NAME: gpfs_query_trace()
3996 * FUNCTION: Query and cache the latest settings of GPFS trace facility.
3997 * Generally this should be called by the notification handler
3998 * for the "traceConfigChanged" event, which is invoked when
3999 * something changes in the configuration of the trace facility.
4001 * Returns: 0 Success
4004 * Errno: ENOENT file not found
4005 * ENOMEM Memory allocation failed
4006 * EACCESS Permission denied
4007 * ENFILE Too many open files
4008 * ENOSYS Function not available
4011 gpfs_query_trace(void);
4013 /* NAME: gpfs_add_trace()
4015 * FUNCTION: write the logs into GPFS trace driver. When the user specified
4016 * parameter "level" is less than or equal to the GPFS trace level,
4017 * the log message pointed to by parameter "msg" would be written to
4018 * GPFS trace buffer, and user can use mmtracectl command to cut
4019 * the GPFS trace buffer into a file to observe. Must be called after
4020 * the call to gpfs_init_trace(). Also ensure the gpfs_query_trace()
4021 * is called properly to update the gpfs trace level cached in
4022 * application, otherwise, the trace may miss to write down to
4023 * GPFS trace driver.
4025 * Input: level: the level for this trace generation. When the level
4026 * is less than or equal to the GPFS trace level, this
4027 * trace record would be written to GPFS trace buffer.
4028 * msg: the message string that would be put into GPFS trace buffer.
4033 gpfs_add_trace(int level
, const char *msg
);
4035 /* NAME: gpfs_fini_trace()
4037 * FUNCTION: Stop using GPFS trace facility. This should be paired with
4038 * gpfs_init_trace(), and must be called after the last
4044 void gpfs_fini_trace(void);
4047 * When GPFS_64BIT_INODES is defined, use the 64-bit interface definitions as
4051 #ifdef GPFS_64BIT_INODES
4052 #undef GPFS_D_VERSION
4053 #define GPFS_D_VERSION GPFS_D64_VERSION
4054 #undef GPFS_IA_VERSION
4055 #define GPFS_IA_VERSION GPFS_IA64_VERSION
4057 #define gpfs_ino_t gpfs_ino64_t
4058 #define gpfs_gen_t gpfs_gen64_t
4059 #define gpfs_uid_t gpfs_uid64_t
4060 #define gpfs_gid_t gpfs_gid64_t
4061 #define gpfs_snapid_t gpfs_snapid64_t
4062 #define gpfs_nlink_t gpfs_nlink64_t
4063 #define gpfs_timestruc_t gpfs_timestruc64_t
4064 #define gpfs_direntx_t gpfs_direntx64_t
4065 #define gpfs_direntx gpfs_direntx64
4066 #define gpfs_iattr_t gpfs_iattr64_t
4068 #define gpfs_get_snapid_from_fssnaphandle gpfs_get_snapid_from_fssnaphandle64
4069 #define gpfs_open_inodescan gpfs_open_inodescan64
4070 #define gpfs_open_inodescan_with_xattrs gpfs_open_inodescan_with_xattrs64
4071 #define gpfs_next_inode gpfs_next_inode64
4072 #define gpfs_next_inode_with_xattrs gpfs_next_inode_with_xattrs64
4073 #define gpfs_seek_inode gpfs_seek_inode64
4074 #define gpfs_stat_inode gpfs_stat_inode64
4075 #define gpfs_stat_inode_with_xattrs gpfs_stat_inode_with_xattrs64
4076 #define gpfs_iopen gpfs_iopen64
4077 #define gpfs_ireaddir gpfs_ireaddir64
4078 #define gpfs_ireaddirx gpfs_ireaddirx64
4079 #define gpfs_iwritedir gpfs_iwritedir64
4080 #define gpfs_ireadlink gpfs_ireadlink64
4083 #define gpfs_icreate gpfs_icreate64