Whamcloud - gitweb
2c1eadddbaa0c165bdd053f28e88c37412d7abaf
[fs/lustre-release.git] / lustre / include / lustre / lustre_user.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (C) 2001 Cluster File Systems, Inc. <braam@clusterfs.com>
5  *
6  *   This file is part of Lustre, http://www.lustre.org.
7  *
8  *   Lustre is free software; you can redistribute it and/or
9  *   modify it under the terms of version 2 of the GNU General Public
10  *   License as published by the Free Software Foundation.
11  *
12  *   Lustre is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *
17  *   You should have received a copy of the GNU General Public License
18  *   along with Lustre; if not, write to the Free Software
19  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  *
21  * Lustre public user-space interface definitions.
22  */
23 #ifndef _LUSTRE_USER_H
24 #define _LUSTRE_USER_H
25
26 #ifdef HAVE_ASM_TYPES_H
27 #include <asm/types.h>
28 #else
29 #include "types.h"
30 #endif
31
32 #ifdef __KERNEL__
33 #include <linux/string.h>
34 #else
35 #include <string.h>
36 #endif
37
38 /* for statfs() */
39 #define LL_SUPER_MAGIC 0x0BD00BD0
40
41 #define IOC_MDC_TYPE         'i'
42 #define IOC_MDC_GETSTRIPE    _IOWR(IOC_MDC_TYPE, 21, struct lov_mds_md *)
43 #define IOC_MDC_SHOWFID      _IOWR(IOC_MDC_TYPE, 23, struct lustre_id *)
44
45 #ifndef EXT3_IOC_GETFLAGS
46 #define EXT3_IOC_GETFLAGS               _IOR('f', 1, long)
47 #define EXT3_IOC_SETFLAGS               _IOW('f', 2, long)
48 #define EXT3_IOC_GETVERSION             _IOR('f', 3, long)
49 #define EXT3_IOC_SETVERSION             _IOW('f', 4, long)
50 #define EXT3_IOC_GETVERSION_OLD         _IOR('v', 1, long)
51 #define EXT3_IOC_SETVERSION_OLD         _IOW('v', 2, long)
52 #endif
53
54 #define LL_IOC_GETFLAGS                 _IOR ('f', 151, long)
55 #define LL_IOC_SETFLAGS                 _IOW ('f', 152, long)
56 #define LL_IOC_CLRFLAGS                 _IOW ('f', 153, long)
57 #define LL_IOC_LOV_SETSTRIPE            _IOW ('f', 154, long)
58 #define LL_IOC_LOV_GETSTRIPE            _IOW ('f', 155, long)
59 #define LL_IOC_LOV_SETEA                _IOW ('f', 156, long)
60 #define LL_IOC_RECREATE_OBJ             _IOW ('f', 157, long)
61 #define LL_IOC_CW_LOCK                  _IOW ('f', 158, long)
62 #define LL_IOC_CW_UNLOCK                _IOW ('f', 159, long)
63 #define LL_IOC_MDC_MKDIRSTRIPE          _IOW ('f', 160, long)
64 #define LL_IOC_GROUP_LOCK               _IOW ('f', 161, long)
65 #define LL_IOC_GROUP_UNLOCK             _IOW ('f', 162, long)
66 #define LL_IOC_GETFACL                  _IOW ('f', 163, long)
67 #define LL_IOC_SETFACL                  _IOW ('f', 164, long)
68
69 #define LL_IOC_FLUSH_CRED               _IOW ('f', 170, long)
70 #define LL_IOC_KEY_TYPE                 _IOW ('f', 171, long)
71 #define LL_IOC_DISABLE_CRYPTO           _IOW ('f', 172, long)
72 #define LL_IOC_ENABLE_CRYPTO            _IOW ('f', 173, long)
73
74
75 #define O_LOV_DELAY_CREATE    0100000000  /* hopefully this does not conflict */
76
77 #define LL_FILE_IGNORE_LOCK   0x00000001
78 #define LL_FILE_GROUP_LOCKED  0x00000002
79
80 #define LOV_USER_MAGIC_V1 0x0BD10BD0
81 #define LOV_USER_MAGIC    LOV_USER_MAGIC_V1
82
83 #define LOV_PATTERN_RAID0 0x001
84 #define LOV_PATTERN_RAID1 0x002
85 #define LOV_PATTERN_FIRST 0x100
86
87 #define lov_user_ost_data lov_user_ost_data_v1
88 struct lov_user_ost_data_v1 {     /* per-stripe data structure */
89         __u64 l_object_id;        /* OST object ID */
90         __u64 l_object_gr;        /* OST object group (creating MDS number) */
91         __u32 l_ost_gen;          /* generation of this OST index */
92         __u32 l_ost_idx;          /* OST index in LOV */
93 } __attribute__((packed));
94
95 #define lov_user_md lov_user_md_v1
96 struct lov_user_md_v1 {           /* LOV EA user data (host-endian) */
97         __u32 lmm_magic;          /* magic number = LOV_USER_MAGIC_V1 */
98         __u32 lmm_pattern;        /* LOV_PATTERN_RAID0, LOV_PATTERN_RAID1 */
99         __u64 lmm_object_id;      /* LOV object ID */
100         __u64 lmm_object_gr;      /* LOV object group */
101         __u32 lmm_stripe_size;    /* size of stripe in bytes */
102         __u16 lmm_stripe_count;   /* num stripes in use for this object */
103         __u16 lmm_stripe_offset;  /* starting stripe offset in lmm_objects */
104         struct lov_user_ost_data_v1 lmm_objects[0]; /* per-stripe data */
105 } __attribute__((packed));
106
107 struct ll_user_mkdir_stripe {
108         int lums_namelen;
109         char *lums_name;
110         mode_t lums_mode;
111         int lums_nstripes;
112 };
113
114 extern int op_create_file(char *name, long stripe_size, int stripe_offset,
115                           int stripe_count);
116 extern int op_create_dir(char *name, int stripe_count);
117 extern int get_file_stripe(char *path, struct lov_user_md *lum);
118
119 struct ll_recreate_obj {
120         __u64 lrc_id;
121         __u32 lrc_ost_idx;
122         __u32 lrc_padding;
123         __u64 lrc_group;
124 };
125
126 struct obd_uuid {
127         __u8 uuid[40];
128 };
129
130 static inline int obd_uuid_equals(struct obd_uuid *u1, struct obd_uuid *u2)
131 {
132          return strcmp((char *)u1->uuid, (char *)u2->uuid) == 0;
133 }
134
135 static inline int obd_uuid_empty(struct obd_uuid *uuid)
136 {
137         return uuid->uuid[0] == '\0';
138 }
139
140 static inline void obd_str2uuid(struct obd_uuid *uuid, char *tmp)
141 {
142         strncpy((char *)uuid->uuid, tmp, sizeof(*uuid));
143         uuid->uuid[sizeof(*uuid) - 1] = '\0';
144 }
145
146 /* remote acl ioctl */
147 struct ll_acl_ioctl_data {
148         char           *cmd;            /* IN */
149         unsigned long   cmd_len;
150         char           *res;            /* OUT */
151         unsigned long   res_len;
152         int             status;         /* OUT */
153 };
154
155 #endif /* _LUSTRE_USER_H */