dmlite
0.6
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
include
dmlite
c
catalog.h
Go to the documentation of this file.
1
/** @file include/dmlite/c/catalog.h
2
* @brief C wrapper for DMLite Catalog API.
3
* @author Alejandro Álvarez Ayllon <aalvarez@cern.ch>
4
*/
5
#ifndef DMLITE_CATALOG_H
6
#define DMLITE_CATALOG_H
7
8
#include "
dmlite.h
"
9
#include "
inode.h
"
10
#include "
utils.h
"
11
12
#ifdef __cplusplus
13
extern
"C"
{
14
#endif
15
16
typedef
struct
dmlite_dir
dmlite_dir
;
17
18
/**
19
* @brief Changes the working dir.
20
* @param context The DM context.
21
* @param path The new working dir.
22
* @return 0 on success, error code otherwise.
23
*/
24
int
dmlite_chdir
(
dmlite_context
* context,
const
char
* path);
25
26
/**
27
* @brief Gets the current working directory.
28
* @param context The DM context.
29
* @param buffer If not NULL, the path will be stored here. <b>malloc</b> will be used otherwise.
30
* @param size The buffer size.
31
* @return A pointer to a string with the current working dir.
32
*/
33
char
*
dmlite_getcwd
(
dmlite_context
* context,
char
* buffer,
size_t
size);
34
35
/**
36
* @brief Sets the file mode creation mask.
37
* @param context The DM context.
38
* @param mask The new mask.
39
* @return The previous mask.
40
*/
41
mode_t
dmlite_umask
(
dmlite_context
* context, mode_t mask);
42
43
/**
44
* @brief Does a stat of a file or directory.
45
* @param context The DM context.
46
* @param path The path.
47
* @param buf Where to put the retrieved information.
48
* @return 0 on success, error code otherwise.
49
*/
50
int
dmlite_stat
(
dmlite_context
* context,
const
char
* path,
struct
stat* buf);
51
52
/**
53
* @brief Does a stat of a file, directory, or symbolic link (does not follow).
54
* @param context The DM context.
55
* @param path The path.
56
* @param buf Where to put the retrieved information.
57
* @return 0 on success, error code otherwise.
58
*/
59
int
dmlite_statl
(
dmlite_context
* context,
const
char
* path,
struct
stat* buf);
60
61
/**
62
* @brief Does an extended stat of a file, directory or symbolic link.
63
* @param context The DM context.
64
* @param path The path.
65
* @param buf Where to put the retrieved information.
66
* @return 0 on success, error code otherwise.
67
*/
68
int
dmlite_statx
(
dmlite_context
* context,
const
char
* path,
dmlite_xstat
* buf);
69
70
/**
71
* @brief Does an extended stat of a logical file using an associated replica filename.
72
* @param context The DM context.
73
* @param rfn Replica filename.
74
* @param buf Where to put the retrieved information.
75
* @return 0 on success, error code otherwise.
76
*/
77
int
dmlite_rstatx
(
dmlite_context
* context,
const
char
* rfn,
dmlite_xstat
* buf);
78
79
/**
80
* @brief Checks wether the process would be allowed to read, write, or check existence.
81
* @param context The DM context.
82
* @param lfn Logical filename.
83
* @param mode A mask consisting of one or more of R_OK, W_OK, X_OK and F_OK.
84
* @return 0 on success, error code otherwise.
85
*/
86
int
dmlite_access
(
dmlite_context
* context,
const
char
* lfn,
int
mode);
87
88
/**
89
* @brief Checks wether the process would be allowed to read, write, or check existence.
90
* @param context The DM context.
91
* @param rfn Replica filename.
92
* @param mode A mask consisting of one or more of R_OK, W_OK, X_OK and F_OK.
93
* @return 0 on success, error code otherwise.
94
*/
95
int
dmlite_accessr
(
dmlite_context
* context,
const
char
* rfn,
int
mode);
96
97
/**
98
* @brief Adds a new replica to an entry.
99
* @param context The DM context.
100
* @param replica The replica to add.
101
* @return 0 on success, error code otherwise.
102
*/
103
int
dmlite_addreplica
(
dmlite_context
* context,
const
dmlite_replica
* replica);
104
105
/**
106
* @brief Deletes a replica.
107
* @param context The DM context.
108
* @param replica The replica to delete.
109
* @return 0 on success, error code otherwise.
110
*/
111
int
dmlite_delreplica
(
dmlite_context
* context,
const
dmlite_replica
* replica);
112
113
/**
114
* @brief Gets the replicas of a file.
115
* @param context The DM context.
116
* @param path The logical file name.
117
* @param nReplicas The number of entries will be put here.
118
* @param fileReplicas An array with nEntries elements will be stored here. <b>Use dmlite_replicas_free to free it.</b>
119
* @return 0 on success, error code otherwise.
120
*/
121
int
dmlite_getreplicas
(
dmlite_context
* context,
const
char
* path,
unsigned
*nReplicas,
122
dmlite_replica
** fileReplicas);
123
124
/**
125
* @brief Frees a replica list.
126
* @param nReplicas The number of replicas contained in the array.
127
* @param fileReplicas The array to free.
128
* @return 0 on success, error code otherwise.
129
*/
130
int
dmlite_replicas_free
(
unsigned
nReplicas,
dmlite_replica
* fileReplicas);
131
132
/**
133
* @brief Creates a symlink
134
* @param context The DM context.
135
* @param oldPath The old path.
136
* @param newPath The new path.
137
* @return 0 on success, error code otherwise.
138
*/
139
int
dmlite_symlink
(
dmlite_context
* context,
140
const
char
* oldPath,
const
char
* newPath);
141
142
/**
143
* @brief Reads a symlink.
144
* @param context The DM context.
145
* @param path The symlink file.
146
* @param buf Where to put the symlink target.
147
* @param bufsize The size of the memory pointed by buf.
148
* @return 0 on success, error code otherwise.
149
*/
150
int
dmlite_readlink
(
dmlite_context
* context,
const
char
* path,
151
char
* buf,
size_t
bufsize);
152
153
/**
154
* @brief Removes a file.
155
* @param context The DM context.
156
* @param path The logical file name.
157
* @return 0 on success, error code otherwise.
158
*/
159
int
dmlite_unlink
(
dmlite_context
* context,
const
char
* path);
160
161
162
/**
163
* @brief Creates a file in the catalog (no replicas).
164
* @param context The DM context.
165
* @param path The logical file name.
166
* @param mode The creation mode.
167
* @return 0 on success, error code otherwise.
168
*/
169
int
dmlite_create
(
dmlite_context
* context,
const
char
* path, mode_t mode);
170
171
/**
172
* @brief Changes the mode of a file or directory.
173
* @param context The DM context.
174
* @param path The logical path.
175
* @param mode The new mode.
176
* @return 0 on success, error code otherwise.
177
*/
178
int
dmlite_chmod
(
dmlite_context
* context,
const
char
* path, mode_t mode);
179
180
/**
181
* @brief Changes the owner of a file or directory.
182
* @param context The DM context.
183
* @param path The logical path.
184
* @param newUid The new owner.
185
* @param newGid The new group.
186
* @return 0 on success, error code otherwise.
187
*/
188
int
dmlite_chown
(
dmlite_context
* context,
const
char
* path, uid_t newUid, gid_t newGid);
189
190
/**
191
* @brief Changes the owner of a file, directory or symlink (does not follow).
192
* @param context The DM context.
193
* @param path The logical path.
194
* @param newUid The new owner.
195
* @param newGid The new group.
196
* @return 0 on success, error code otherwise.
197
*/
198
int
dmlite_lchown
(
dmlite_context
* context,
const
char
* path, uid_t newUid, gid_t newGid);
199
200
/**
201
* @brief Changes the size of a file in the catalog.
202
* @param context The DM context.
203
* @param path The logical path.
204
* @param filesize The new file size.
205
* @return 0 on success, error code otherwise.
206
*/
207
int
dmlite_setfsize
(
dmlite_context
* context,
const
char
* path, uint64_t filesize);
208
209
/**
210
* @brief Changes the size and checksum of a file in the catalog.
211
* @param context The DM context.
212
* @param path The logical path.
213
* @param filesize The new file size.
214
* @param csumtype The new checksum type (CS, AD or MD).
215
* @param csumvalue The new checksum value.
216
* @return 0 on success, error code otherwise.
217
*/
218
int
dmlite_setfsizec
(
dmlite_context
* context,
const
char
* path, uint64_t filesize,
219
const
char
* csumtype,
const
char
* csumvalue);
220
221
/**
222
* @brief Changes the ACL of a file.
223
* @param context The DM context.
224
* @param path The logical path.
225
* @param nEntries The number of entries in the acl array.
226
* @param acl An ACL array.
227
* @return 0 on success, error code otherwise.
228
*/
229
int
dmlite_setacl
(
dmlite_context
* context,
const
char
* path,
unsigned
nEntries,
dmlite_aclentry
* acl);
230
231
/**
232
* @brief Changes access and/or modification time
233
* @param context The DM context.
234
* @param path The file path.
235
* @param buf A struct holding the new times.
236
* @return 0 on success, error code otherwise.
237
*/
238
int
dmlite_utime
(
dmlite_context
* context,
const
char
* path,
const
struct
utimbuf* buf);
239
240
/**
241
* @brief Gets the comment associated with a file.
242
* @param context The DM context.
243
* @param path The logical path.
244
* @param comment Where to put the retrieved comment. It must be at least of size COMMENT_MAX.
245
* @param bufsize Size of the memory zone pointed by comment.
246
* @return 0 on success, error code otherwise.
247
*/
248
int
dmlite_getcomment
(
dmlite_context
* context,
const
char
* path,
249
char
* comment,
size_t
bufsize);
250
251
/**
252
* @brief Sets the comment associated with a file.
253
* @param context The DM context.
254
* @param path The logical path.
255
* @param comment The comment to associate. '\\0' terminated string.
256
* @return 0 on success, error code otherwise.
257
*/
258
int
dmlite_setcomment
(
dmlite_context
* context,
const
char
* path,
const
char
* comment);
259
260
/**
261
* @brief Sets the file Grid Unique Identifier.
262
* @param context The DM context.
263
* @param path The logical path.
264
* @param guid The new GUID.
265
* @return 0 on success, error code otherwise.
266
*/
267
int
dmlite_setguid
(
dmlite_context
* context,
const
char
* path,
const
char
* guid);
268
269
/**
270
* @brief Updates the file extended attributes.
271
* @param context The DM context.
272
* @param path The logical path.
273
* @param xattr The new set of extended attributes.
274
* @return 0 on success, error code otherwise.
275
*/
276
int
dmlite_update_xattr
(
dmlite_context
* context,
const
char
* path,
277
const
dmlite_any_dict
* xattr);
278
279
/**
280
* @brief Gets the id of a group.
281
* @param context The DM context.
282
* @param groupName The group name.
283
* @param gid Where to put the group ID.
284
* @return 0 on success, error code otherwise.
285
*/
286
int
dmlite_getgrpbynam
(
dmlite_context
* context,
const
char
* groupName, gid_t* gid);
287
288
/**
289
* @brief Get the user id.
290
* @param context The DM context.
291
* @param userName The user name.
292
* @param uid Where to put the user ID.
293
* @return 0 on success, error code otherwise.
294
*/
295
int
dmlite_getusrbynam
(
dmlite_context
* context,
const
char
* userName, uid_t* uid);
296
297
/**
298
* @brief Opens a directory to read it later.
299
* @param context The DM context.
300
* @param path The directory to open.
301
* @return A pointer to an internal structure, or NULL on failure.
302
*/
303
dmlite_dir
*
dmlite_opendir
(
dmlite_context
* context,
const
char
* path);
304
305
/**
306
* @brief Closes a directory and free the internal structures.
307
* @param context The DM context.
308
* @param dir The pointer returned by dmlite_opendir.
309
* @return 0 on success, error code otherwise.
310
*/
311
int
dmlite_closedir
(
dmlite_context
* context,
dmlite_dir
* dir);
312
313
/**
314
* @brief Reads an entry from a directory.
315
* @param context The DM context.
316
* @param dir The pointer returned by dmlite_opendir.
317
* @return A pointer to a struct with the recovered data.
318
* NULL on failure, or end of dir. If an error occurred,
319
* dm_errno(context) will be different than 0.
320
* @note The pointer is internally allocated. Do not free it.
321
*/
322
struct
dirent *
dmlite_readdir
(
dmlite_context
* context,
dmlite_dir
* dir);
323
324
/**
325
* @brief Reads an entry from a directory (extended data).
326
* @param context The DM context.
327
* @param dir The pointer returned by dmlite_opendir.
328
* @return A pointer to a struct with the recovered data.
329
* NULL on failure, or end of dir. If an error occurred,
330
* dm_errno(context) will be different than 0.
331
* @note The pointer is internally allocated. Do not free it.
332
*/
333
dmlite_xstat
*
dmlite_readdirx
(
dmlite_context
* context,
dmlite_dir
* dir);
334
335
/**
336
* @brief Creates a new directory.
337
* @param context The DM context.
338
* @param path The directory for the new path. All the precedent folders must exist.
339
* @param mode Permissions to use for the creation.
340
* @return 0 on success, error code otherwise.
341
*/
342
int
dmlite_mkdir
(
dmlite_context
* context,
const
char
* path, mode_t mode);
343
344
/**
345
* @brief Renames a file, directory or symlink.
346
* @param context The DM context.
347
* @param oldPath The old name.
348
* @param newPath The new name.
349
* @return 0 on success, error code otherwise.
350
*/
351
int
dmlite_rename
(
dmlite_context
* context,
const
char
* oldPath,
const
char
* newPath);
352
353
/**
354
* @brief Deletes a directory. It must be empty.
355
* @param context The DM context.
356
* @param path The directory to remove.
357
* @return 0 on success, error code otherwise.
358
*/
359
int
dmlite_rmdir
(
dmlite_context
* context,
const
char
* path);
360
361
/**
362
* @brief Gets a specific replica.
363
* @param context The DM context.
364
* @param rfn The replica file name.
365
* @param replica A buffer where the retrieved data will be put.
366
* @return 0 on success, error code otherwise.
367
*/
368
int
dmlite_getreplica_by_rfn
(
dmlite_context
* context,
const
char
* rfn,
dmlite_replica
* replica);
369
370
/**
371
* @brief Updates a replica.
372
* @param context The DM context.
373
* @param replica The replica to modify.
374
* @return 0 on success, error code otherwise.
375
*/
376
int
dmlite_updatereplica
(
dmlite_context
* context,
const
dmlite_replica
* replica);
377
378
#ifdef __cplusplus
379
}
380
#endif
381
382
#endif
/* DMLITE_CATALOG_H */
Generated on Fri Jul 12 2013 07:49:12 for dmlite by
1.8.3.1