2 * Copyright (c) 1995-2003 Silicon Graphics, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2.1 of the GNU Lesser General Public License
6 * as published by the Free Software Foundation.
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this program; if not, write the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307,
24 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
25 * Mountain View, CA 94043, or:
29 * For further information regarding this notice, see:
31 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
42 #include <sys/types.h>
44 #include <linux/types.h>
50 /**************************************************************************
52 * The SGI implementation of DMAPI is based upon the X/Open document *
53 * Systems Management: Data Storage Managment (XDSM) API *
54 * dated February 1997. Not all DMAPI functions and structure fields *
55 * have been implemented. Most importantly, the DMAPI functions *
56 * dm_request_right, dm_release_right, dm_query_right, dm_upgrade_right *
57 * and dm_downgrade_right do not work as described in the specification. *
59 * The XFS filesystem currently does not allow its locking mechanisms to *
60 * be externally accessed from user space. While the above-mentioned *
61 * dm_xxx_right functions exist and can be called by applications, they *
62 * always return successfully without actually obtaining any locks *
63 * within the filesystem. *
65 * Applications which do not need full rights support and which only *
66 * make dm_xxx_right calls in order to satisfy the input requirements of *
67 * other DMAPI calls should be able to use these routines to avoid *
68 * having to implement special-case code for SGI platforms. Applications *
69 * which truely need the capabilities of a full implementation of rights *
70 * will unfortunately have to come up with alternate software solutions *
71 * until such time as rights can be completely implemented. *
73 * Functions and structure fields defined within this file which are not *
74 * supported in the SGI implementation of DMAPI are indicated by comments *
75 * following their definitions such as "not supported", or "not *
76 * completely supported". Any function or field not so marked may be *
77 * assumed to work exactly according to the spec. *
79 **************************************************************************/
83 /* The first portion of this file contains defines and typedefs that are
84 DMAPI implementation-dependent, and could be different on other platforms.
87 typedef __s64 dm_attrloc_t;
88 typedef unsigned int dm_boolean_t;
89 typedef __u64 dm_eventset_t;
90 typedef __u64 dm_fsid_t;
91 typedef __u64 dm_ino_t;
92 typedef __u32 dm_igen_t;
93 typedef __s64 dm_off_t;
94 typedef unsigned int dm_sequence_t;
95 typedef int dm_sessid_t;
96 typedef __u64 dm_size_t;
97 typedef __s64 dm_ssize_t;
98 typedef int dm_token_t;
100 /* XXX dev_t, mode_t, and nlink_t are not the same size in kernel space
101 and user space. This affects the field offsets for dm_stat_t.
102 The following solution is temporary.
104 user space sizes: dev_t=8 mode_t=4 nlink_t=4
105 kernel space : dev_t=2 mode_t=2 nlink_t=2
108 typedef __s64 dm_dev_t;
109 typedef int dm_mode_t;
110 typedef int dm_nlink_t;
113 #define DM_REGION_NOEVENT 0x0
114 #define DM_REGION_READ 0x1
115 #define DM_REGION_WRITE 0x2
116 #define DM_REGION_TRUNCATE 0x4
118 /* Values for the mask argument used with dm_get_fileattr, dm_get_bulkattr,
119 dm_get_dirattrs, and dm_set_fileattr.
122 #define DM_AT_MODE 0x0001
123 #define DM_AT_UID 0x0002
124 #define DM_AT_GID 0x0004
125 #define DM_AT_ATIME 0x0008
126 #define DM_AT_MTIME 0x0010
127 #define DM_AT_CTIME 0x0020
128 #define DM_AT_SIZE 0x0040
129 #define DM_AT_DTIME 0x0080
130 #define DM_AT_HANDLE 0x0100
131 #define DM_AT_EMASK 0x0200
132 #define DM_AT_PMANR 0x0400
133 #define DM_AT_PATTR 0x0800
134 #define DM_AT_STAT 0x1000
135 #define DM_AT_CFLAG 0x2000
137 #define DM_EV_WAIT 0x1 /* used in dm_get_events() */
139 #define DM_MOUNT_RDONLY 0x1 /* me_mode field in dm_mount_event_t */
141 #define DM_RR_WAIT 0x1
143 #define DM_UNMOUNT_FORCE 0x1 /* ne_mode field in dm_namesp_event_t */
145 #define DM_WRITE_SYNC 0x1 /* used in dm_write_invis() */
147 #define DM_SESSION_INFO_LEN 256
148 #define DM_NO_SESSION 0
151 #define DM_INVALID_TOKEN 0
152 #define DM_NO_TOKEN (-1)
153 #define DM_INVALID_HANP NULL
154 #define DM_INVALID_HLEN 0
155 #define DM_GLOBAL_HANP ((void *)(1LL))
156 #define DM_GLOBAL_HLEN ((size_t)(1))
157 #define DM_VER_STR_CONTENTS "SGI DMAPI (XDSM) API, Release 1.1."
160 #define DMEV_SET(event_type, event_list) \
161 ((event_list) |= (1 << (event_type)))
162 #define DMEV_CLR(event_type, event_list) \
163 ((event_list) &= ~(1 << (event_type)))
164 #define DMEV_ISSET(event_type, event_list) \
165 (int)(((event_list) & (1 << (event_type))) != 0)
166 #define DMEV_ZERO(event_list) \
171 int vd_offset; /* offset from start of containing struct */
172 unsigned int vd_length; /* length of data starting at vd_offset */
175 #define DM_GET_VALUE(p, field, type) \
176 ((type) ((char *)(p) + (p)->field.vd_offset))
178 #define DM_GET_LEN(p, field) \
179 ((p)->field.vd_length)
181 #define DM_STEP_TO_NEXT(p, type) \
182 ((type) ((p)->_link ? (char *)(p) + (p)->_link : NULL))
187 /* The remainder of this include file contains defines, typedefs, and
188 structures which are strictly defined by the DMAPI 2.3 specification.
190 (The _link field which appears in several structures is an
191 implementation-specific way to implement DM_STEP_TO_NEXT, and
192 should not be referenced directly by application code.)
196 #define DM_ATTR_NAME_SIZE 8
200 unsigned char an_chars[DM_ATTR_NAME_SIZE];
202 typedef struct dm_attrname dm_attrname_t;
207 dm_attrname_t al_name;
208 dm_vardata_t al_data;
210 typedef struct dm_attrlist dm_attrlist_t;
216 DM_CONFIG_CREATE_BY_HANDLE,
217 DM_CONFIG_DTIME_OVERLOAD,
219 DM_CONFIG_LOCK_UPGRADE,
220 DM_CONFIG_MAX_ATTR_ON_DESTROY,
221 DM_CONFIG_MAX_ATTRIBUTE_SIZE,
222 DM_CONFIG_MAX_HANDLE_SIZE,
223 DM_CONFIG_MAX_MANAGED_REGIONS,
224 DM_CONFIG_MAX_MESSAGE_DATA,
227 DM_CONFIG_PERS_ATTRIBUTES,
228 DM_CONFIG_PERS_EVENTS,
229 DM_CONFIG_PERS_INHERIT_ATTRIBS,
230 DM_CONFIG_PERS_MANAGED_REGIONS,
231 DM_CONFIG_PUNCH_HOLE,
232 DM_CONFIG_TOTAL_ATTRIBUTE_SPACE,
237 struct dm_dioinfo { /* non-standard SGI addition */
239 unsigned int d_miniosz;
240 unsigned int d_maxiosz;
241 dm_boolean_t d_dio_only;
243 typedef struct dm_dioinfo dm_dioinfo_t;
248 unsigned int di_pad1; /* reserved; do not reference */
249 dm_vardata_t di_fshandle;
250 dm_eventset_t di_eventset;
252 typedef struct dm_dispinfo dm_dispinfo_t;
255 #ifndef HAVE_DM_EVENTTYPE_T
256 #define HAVE_DM_EVENTTYPE_T
258 DM_EVENT_INVALID = -1,
259 DM_EVENT_CANCEL = 0, /* not supported */
261 DM_EVENT_PREUNMOUNT = 2,
262 DM_EVENT_UNMOUNT = 3,
263 DM_EVENT_DEBUT = 4, /* not supported */
265 DM_EVENT_CLOSE = 6, /* not supported */
266 DM_EVENT_POSTCREATE = 7,
268 DM_EVENT_POSTREMOVE = 9,
269 DM_EVENT_RENAME = 10,
270 DM_EVENT_POSTRENAME = 11,
272 DM_EVENT_POSTLINK = 13,
273 DM_EVENT_SYMLINK = 14,
274 DM_EVENT_POSTSYMLINK = 15,
277 DM_EVENT_TRUNCATE = 18,
278 DM_EVENT_ATTRIBUTE = 19,
279 DM_EVENT_DESTROY = 20,
280 DM_EVENT_NOSPACE = 21,
289 dm_eventtype_t ev_type;
291 dm_sequence_t ev_sequence;
292 dm_vardata_t ev_data;
294 typedef struct dm_eventmsg dm_eventmsg_t;
297 struct dm_cancel_event { /* not supported */
298 dm_sequence_t ce_sequence;
301 typedef struct dm_cancel_event dm_cancel_event_t;
304 struct dm_data_event {
305 dm_vardata_t de_handle;
309 typedef struct dm_data_event dm_data_event_t;
311 struct dm_destroy_event {
312 dm_vardata_t ds_handle;
313 dm_attrname_t ds_attrname;
314 dm_vardata_t ds_attrcopy;
316 typedef struct dm_destroy_event dm_destroy_event_t;
318 struct dm_mount_event {
320 dm_vardata_t me_handle1;
321 dm_vardata_t me_handle2;
322 dm_vardata_t me_name1;
323 dm_vardata_t me_name2;
324 dm_vardata_t me_roothandle;
326 typedef struct dm_mount_event dm_mount_event_t;
328 struct dm_namesp_event {
330 dm_vardata_t ne_handle1;
331 dm_vardata_t ne_handle2;
332 dm_vardata_t ne_name1;
333 dm_vardata_t ne_name2;
336 typedef struct dm_namesp_event dm_namesp_event_t;
347 dm_extenttype_t ex_type;
348 unsigned int ex_pad1; /* reserved; do not reference */
352 typedef struct dm_extent dm_extent_t;
362 unsigned int fa_pad1; /* reserved; do not reference */
365 typedef struct dm_fileattr dm_fileattr_t;
368 struct dm_inherit { /* not supported */
369 dm_attrname_t ih_name;
370 dm_mode_t ih_filetype;
372 typedef struct dm_inherit dm_inherit_t;
385 unsigned int rg_flags;
386 unsigned int rg_pad1; /* reserved; do not reference */
388 typedef struct dm_region dm_region_t;
399 #ifndef HAVE_DM_RIGHT_T
400 #define HAVE_DM_RIGHT_T
411 dm_vardata_t dt_handle;
412 dm_vardata_t dt_compname;
414 dm_eventset_t dt_emask;
415 int dt_pers; /* field not supported */
418 unsigned int dt_change; /* field not supported */
419 unsigned int dt_pad1; /* reserved; do not reference */
427 unsigned int dt_pad2; /* reserved; do not reference */
432 unsigned int dt_blksize;
435 /* Non-standard filesystem-specific fields. Currently XFS is the only
436 supported filesystem type.
439 __u64 dt_pad3; /* reserved; do not reference */
440 int dt_fstype; /* filesystem index; see sysfs(2) */
445 unsigned int extsize;
446 unsigned int extents;
447 unsigned short aextents;
448 unsigned short dmstate;
452 typedef struct dm_stat dm_stat_t;
454 #define dt_xfs_igen fsys_dep.sgi_xfs.igen
455 #define dt_xfs_xflags fsys_dep.sgi_xfs.xflags
456 #define dt_xfs_extsize fsys_dep.sgi_xfs.extsize
457 #define dt_xfs_extents fsys_dep.sgi_xfs.extents
458 #define dt_xfs_aextents fsys_dep.sgi_xfs.aextents
459 #define dt_xfs_dmstate fsys_dep.sgi_xfs.dmstate
461 /* Flags for the non-standard dt_xfs_xflags field. */
463 #define DM_XFLAG_REALTIME 0x00000001
464 #define DM_XFLAG_PREALLOC 0x00000002
465 #define DM_XFLAG_IMMUTABLE 0x00000008
466 #define DM_XFLAG_APPEND 0x00000010
467 #define DM_XFLAG_SYNC 0x00000020
468 #define DM_XFLAG_NOATIME 0x00000040
469 #define DM_XFLAG_NODUMP 0x00000080
470 #define DM_XFLAG_HASATTR 0x80000000
473 struct dm_timestruct {
477 typedef struct dm_timestruct dm_timestruct_t;
480 struct dm_xstat { /* not supported */
481 dm_stat_t dx_statinfo;
482 dm_vardata_t dx_attrdata;
484 typedef struct dm_xstat dm_xstat_t;
487 #define MAXDMFSFIDSZ 46
490 __u16 dm_fid_len; /* length of remainder */
492 __u32 dm_fid_gen; /* generation number */
493 __u64 dm_fid_ino; /* 64 bits inode number */
495 typedef struct dm_fid dm_fid_t;
500 __s64 align; /* force alignment of ha_fid */
501 dm_fsid_t _ha_fsid; /* unique file system identifier */
503 dm_fid_t ha_fid; /* file system specific file ID */
505 typedef struct dm_handle dm_handle_t;
506 #define ha_fsid ha_u._ha_fsid
508 #define DM_HSIZE(handle) (((char *) &(handle).ha_fid.dm_fid_pad \
509 - (char *) &(handle)) \
510 + (handle).ha_fid.dm_fid_len)
512 #define DM_HANDLE_CMP(h1, h2) memcmp(h1, h2, sizeof(dm_handle_t))
514 #define DM_FSHSIZE sizeof(dm_fsid_t)
517 /* The following list provides the prototypes for all functions defined in
522 dm_clear_inherit( /* not supported */
527 dm_attrname_t __user *attrnamep);
530 dm_create_by_handle( /* not supported */
532 void __user *dirhanp,
542 char __user *sessinfop,
543 dm_sessid_t __user *newsidp);
549 void __user *msgdatap,
550 dm_token_t __user *tokenp);
557 dm_downgrade_right( /* not completely supported; see caveat above */
575 size_t __user *rlenp);
585 dm_extent_t *extentp,
586 unsigned int *nelemp);
589 dm_get_bulkall( /* not supported */
595 dm_attrname_t *attrnamep,
617 dm_config_t flagname,
618 dm_size_t __user *retvalp);
621 dm_get_config_events(
625 dm_eventset_t __user *eventsetp,
626 unsigned int __user *nelemp);
646 dm_attrname_t __user *attrnamep,
649 size_t __user *rlenp);
658 dm_eventset_t __user *eventsetp,
659 unsigned int __user *nelemp);
664 unsigned int maxmsgs,
668 size_t __user *rlenp);
677 dm_stat_t __user *statp);
687 size_t __user *rlenp);
696 dm_region_t __user *regbufp,
697 unsigned int __user *nelemp);
704 size_t __user *rlenp);
714 size_t __user *rlenp);
717 dm_getall_inherit( /* not supported */
723 dm_inherit_t __user *inheritbufp,
724 unsigned int __user *nelemp);
729 dm_sessid_t __user *sidbufp,
730 unsigned int __user *nelemp);
736 dm_token_t __user *tokenbufp,
737 unsigned int __user *nelemp);
762 dm_handle_to_fshandle(
802 dm_attrloc_t __user *locp);
806 char **versionstrpp);
823 dm_mkdir_by_handle( /* not supported */
825 void __user *dirhanp,
836 dm_sessid_t targetsid,
837 dm_token_t __user *rtokenp);
876 dm_timestruct_t __user *delay);
886 dm_off_t __user *roffp,
887 dm_size_t __user *rlenp);
899 dm_query_right( /* not completely supported; see caveat above */
904 dm_right_t __user *rightp);
911 size_t __user *rlenp);
924 dm_release_right( /* not completely supported; see caveat above */
937 dm_attrname_t __user *attrnamep);
940 dm_request_right( /* not completely supported; see caveat above */
952 dm_response_t response,
955 void __user *respbufp);
959 dm_sessid_t targetsid,
960 dm_msgtype_t msgtype,
970 dm_eventset_t __user *eventsetp,
971 unsigned int maxevent);
979 dm_attrname_t __user *attrnamep,
990 dm_eventset_t __user *eventsetp,
991 unsigned int maxevent);
1000 dm_fileattr_t __user *attrp);
1003 dm_set_inherit( /* not supported */
1008 dm_attrname_t __user *attrnamep,
1018 dm_region_t __user *regbufp,
1019 dm_boolean_t __user *exactflagp);
1022 dm_set_return_on_destroy(
1027 dm_attrname_t __user *attrnamep,
1028 dm_boolean_t enable);
1031 dm_symlink_by_handle( /* not supported */
1033 void __user *dirhanp,
1049 dm_upgrade_right( /* not completely supported; see caveat above */
1066 /* Non-standard SGI additions to the DMAPI interface. */
1080 dm_dioinfo_t __user *diop);
1086 #endif /* __DMAPI_H__ */