~ubuntu-branches/ubuntu/lucid/davfs2/lucid-proposed

« back to all changes in this revision

Viewing changes to src/cache.h

  • Committer: Bazaar Package Importer
  • Author(s): Luciano Bello
  • Date: 2009-06-15 18:53:30 UTC
  • mfrom: (4.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090615185330-w0sig45by20gau13
Tags: 1.4.1-1
* New upstream version 1.4.1 (closes: #533057).
* Upstream location updated in copyright (closes: #533056).
* Debhelper compatibility version updated to 7.
* Standards-Version updated to 3.8.1.
* dh_clean -k was changed for dh_prep.
* /var/run/mount.davfs/ is not created during the instalation.
* New/improved debconf translations available:
  - Spanish translation (closes: #526721).
  - Japanese translation (closes: #528175).
* libneon27 had been switched for libneon27-gnutls (closes: #533058).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* 
2
 
** DAV directory chache
3
 
 */
4
 
 
5
 
/*
6
 
 *  This file is part of davfs2.
7
 
 *
8
 
 *  davfs2 is free software; you can redistribute it and/or modify
9
 
 *  it under the terms of the GNU General Public License as published by
10
 
 *  the Free Software Foundation; either version 2 of the License, or
11
 
 *  (at your option) any later version.
12
 
 *
13
 
 *  davfs2 is distributed in the hope that it will be useful,
14
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 
 *  GNU General Public License for more details.
17
 
 *
18
 
 *  You should have received a copy of the GNU General Public License
19
 
 *  along with davfs2; if not, write to the Free Software
20
 
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21
 
 */
22
 
 
23
 
 
24
 
#ifndef __DAV_CACHE_H__
25
 
#define __DAV_CACHE_H__
 
1
/*  cache.h: directory and file cache.
 
2
    Copyright (C) 2006, 2007, 2008, 2009 Werner Baumann
 
3
 
 
4
    This file is part of davfs2.
 
5
 
 
6
    davfs2 is free software; you can redistribute it and/or modify
 
7
    it under the terms of the GNU General Public License as published by
 
8
    the Free Software Foundation; either version 3 of the License, or
 
9
    (at your option) any later version.
 
10
 
 
11
    davfs2 is distributed in the hope that it will be useful,
 
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
    GNU General Public License for more details.
 
15
 
 
16
    You should have received a copy of the GNU General Public License
 
17
    along with davfs2; if not, write to the Free Software Foundation,
 
18
    Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */
 
19
 
 
20
 
 
21
#ifndef DAV_CACHE_H
 
22
#define DAV_CACHE_H
26
23
 
27
24
 
28
25
/* Constants */
143
140
struct dav_node_item {
144
141
    dav_node_list_item *next;
145
142
    dav_node *node;
 
143
    int attempts;
146
144
    time_t save_at;
147
145
};
148
146
 
150
148
/* Returned by dav_statfs(). */
151
149
typedef struct dav_stat dav_stat;
152
150
struct dav_stat {
153
 
    off_t blocks;
154
 
    off_t bfree;
155
 
    off_t bavail;
156
 
    off_t files;
157
 
    off_t ffree;
158
 
    off_t bsize;
159
 
    off_t namelen;
 
151
    off64_t     blocks;
 
152
    off64_t     bfree;
 
153
    off64_t     bavail;
 
154
    off64_t     files;
 
155
    off64_t     ffree;
 
156
    off_t       bsize;
 
157
    off_t       namelen;
 
158
    time_t      utime;      /* Time when last updated with data from the server.
 
159
                               must When 0 this structure contains fake data,
 
160
                               that not be changed when a file is changed or
 
161
                               deleted. */
160
162
};
161
163
 
162
164
 
188
190
   filesystem can be mounted, but will only get useable when the connection
189
191
   comes up.
190
192
   paramters: if not self explaining, please see mount_davfs.c, struct args. */
191
 
void dav_init_cache(uid_t uid, gid_t gid, mode_t file_mode, mode_t dir_mode,
192
 
                    mode_t f_umask, mode_t d_umask, size_t hash_table_sz,
193
 
                    time_t dir_rf, time_t file_rf, int delay_upl, int gui_opt,
194
 
                    time_t dir_rt, time_t dir_max_rt, time_t lock_rf,
195
 
                    size_t cache_sz, const char *tl_cache_dir,
196
 
                    const char *backup_dir, const char *host, const char *path,
197
 
                    const char *mpoint, int dbg);
 
193
void
 
194
dav_init_cache(const dav_args *args, const char *mpoint);
198
195
 
199
196
 
200
197
/* Tries to write back to the server all open files that have been changed or
204
201
   permanent cache is created.
205
202
   If got_sigterm is 1, dirty files will not be stored back to the server.
206
203
   Finally it frees all nodes. */
207
 
void dav_close_cache(int got_sigterm);
 
204
void
 
205
dav_close_cache(int got_sigterm);
208
206
 
209
207
 
210
208
/* Registers the kernel_interface.
211
209
   Sets pointers to the write_dir_entry_fn flush_flag.
212
210
   If blksize is not NULL, the preferred bloksize for IO is asigned.
213
211
   It returns the value of alignment. */
214
 
size_t dav_register_kernel_interface(dav_write_dir_entry_fn write_fn,
215
 
                                     int *flush_flag, unsigned int *blksize);
 
212
size_t
 
213
dav_register_kernel_interface(dav_write_dir_entry_fn write_fn, int *flush_flag,
 
214
                              unsigned int *blksize);
216
215
 
217
216
 
218
217
/* Scans the hash table for file nodes to be saved them back on the server,
223
222
   The return value indicates whether another run would be useful.
224
223
   return value: 0 there is nothing left to do.
225
224
                 1 another call of dav_tidy_cache would be useful. */
226
 
int dav_tidy_cache(void);
 
225
int
 
226
dav_tidy_cache(void);
227
227
 
228
228
 
229
229
/* Upcalls from the kernel, via the interface module. */
259
259
/* Tests whether user uid has access described by how to node.
260
260
   int how : A bit mask describing the kind of acces. It may be any combination
261
261
             of R_OK, W_OK, X_OK and F_OK. */
262
 
int dav_access(dav_node *node, uid_t uid, int how);
 
262
int
 
263
dav_access(dav_node *node, uid_t uid, int how);
263
264
 
264
265
 
265
266
/* Closed file descriptor fd of node.
267
268
   opening. If fd is 0 (coda), flags, pid and pgid are used to find the best
268
269
   matching file descriptor.
269
270
   Only access mode bits must be set in flags.*/
270
 
int dav_close(dav_node *node, int fd, int flags, pid_t pid, pid_t pgid);
 
271
int
 
272
dav_close(dav_node *node, int fd, int flags, pid_t pid, pid_t pgid);
271
273
 
272
274
 
273
275
/* Creates a new file node with name name in directory parent. The file is
278
280
   Permissions:
279
281
   uid must have execute permission for parent and all of its ancestors, as
280
282
   well as write permission for parent. */
281
 
int dav_create(dav_node **nodep, dav_node *parent, const char *name,
282
 
               uid_t uid, mode_t mode);
 
283
int
 
284
dav_create(dav_node **nodep, dav_node *parent, const char *name, uid_t uid,
 
285
           mode_t mode);
283
286
 
284
287
 
285
288
/* Checks whether node exists and uid has permissions. The kernel interface
287
290
   Permissions:
288
291
   uid must have execute permission for parent and all of its ancestors, as
289
292
   well as read permission for parent. */
290
 
int dav_getattr(dav_node *node, uid_t uid);
 
293
int
 
294
dav_getattr(dav_node *node, uid_t uid);
291
295
 
292
296
 
293
297
/* Checks whether node exists and uid has permissions. The value of
296
300
   Permissions:
297
301
   uid must have execute permission for parent and all of its ancestors, as
298
302
   well as read permission for parent. */
299
 
int dav_getxattr(dav_node *node, const char *name, char *buf, size_t *size,
300
 
                uid_t uid);
 
303
int
 
304
dav_getxattr(dav_node *node, const char *name, char *buf, size_t *size,
 
305
             uid_t uid);
 
306
 
 
307
 
 
308
/* Returns the list of supported extended attributes. This is just
 
309
   user.mime_type. */
 
310
int
 
311
dav_listxattr(dav_node *node, char *buf, size_t *size, uid_t uid);
301
312
 
302
313
 
303
314
/* Searches for a node with name name in the directory parent and returns the
305
316
   Permissions:
306
317
   uid must have execute permission for parent and all of its ancestors, as
307
318
   well as read permission for parent. */
308
 
int dav_lookup(dav_node **nodep, dav_node *parent, const char *name, uid_t uid);
 
319
int
 
320
dav_lookup(dav_node **nodep, dav_node *parent, const char *name, uid_t uid);
309
321
 
310
322
 
311
323
/* Creates a new directory named name in direcotry parent. The directory must
315
327
   Permissions:
316
328
   uid must have execute permission for parent and all of its ancestors, as
317
329
   well as write permission for parent. */
318
 
int dav_mkdir(dav_node **nodep, dav_node *parent, const char *name, uid_t uid,
319
 
              mode_t mode);
 
330
int
 
331
dav_mkdir(dav_node **nodep, dav_node *parent, const char *name, uid_t uid,
 
332
          mode_t mode);
320
333
 
321
334
 
322
335
/* Opens file or directory node according to flags and returns file descriptor
327
340
   Permissions:
328
341
   uid must have execute permission for parent and all of its ancestors, as
329
342
   as well as read and/or write permission for node, according to the
330
 
   accessmode. */
331
 
int dav_open(int *fd, dav_node *node, int flags, pid_t pid, pid_t pgid,
332
 
             uid_t uid);
 
343
   accessmode.
 
344
   If open_create is set to 1, permissions will not be checked. This flag must
 
345
   only be set when the call to dav_open is part of an open-call with flag
 
346
   O_CREATE. It allows dav_open to succeed if when the file mode would not
 
347
   allow this.  */
 
348
int
 
349
dav_open(int *fd, dav_node *node, int flags, pid_t pid, pid_t pgid, uid_t uid,
 
350
         int open_create);
333
351
 
334
352
/* Reads size bytes from file descriptor fd, starting at position offset
335
353
   and copies them into buf.
336
354
   The number of bytes read is returned in len.
337
355
   The file must be opened readonly or readwrite. */
338
 
int dav_read(ssize_t *len, dav_node * node, int fd, char *buf, size_t size,
339
 
             off_t offset);
 
356
int
 
357
dav_read(ssize_t *len, dav_node * node, int fd, char *buf, size_t size,
 
358
         off_t offset);
340
359
 
341
360
 
342
361
/* Removes file node name in directory parent from the cache and on the server.
344
363
   Permissions:
345
364
   uid must have execute permission for parent and all of its ancestors, as
346
365
   well as write permission for parent. */
347
 
int dav_remove(dav_node *parent, const char *name, uid_t uid);
 
366
int
 
367
dav_remove(dav_node *parent, const char *name, uid_t uid);
348
368
 
349
369
 
350
370
/* Moves file or directory src_name from directory src_parent to directory
356
376
   uid must have execute permission for src_parent and dst_parent and all of
357
377
   their ancestors, as well as write permission for src_parent and
358
378
   dst_parent. */
359
 
int dav_rename(dav_node *src_parent, const char *src_name,
360
 
               dav_node *dst_parent, const char *dst_name, uid_t uid);
 
379
int
 
380
dav_rename(dav_node *src_parent, const char *src_name, dav_node *dst_parent,
 
381
           const char *dst_name, uid_t uid);
361
382
 
362
383
 
363
384
/* Removes direcotry name in directory parent.
364
385
   The directory must be empty and not the local backup directory.
365
386
   uid must have execute permission for parent and all of its ancestors, as
366
387
   well as write permission for parent. */
367
 
int dav_rmdir(dav_node *parent, const char *name, uid_t uid);
 
388
int
 
389
dav_rmdir(dav_node *parent, const char *name, uid_t uid);
368
390
 
369
391
 
370
392
/* Returns a pointer to the root node in nodep.
371
393
   Permissions:
372
394
   uid must be root, as this function is only called when the file system is
373
395
   mounted. */
374
 
int dav_root(dav_node **nodep, uid_t uid);
 
396
int
 
397
dav_root(dav_node **nodep, uid_t uid);
375
398
 
376
399
 
377
400
/* Changes attributes of the node.
386
409
   To change gid, uid must be member of the new group or root.
387
410
   Note: This attributes, except size and the execute bit of mode, are only
388
411
         changed locally and not on the server. */
389
 
int dav_setattr(dav_node *node, uid_t uid, int sm, mode_t mode,
390
 
                int so, uid_t owner, int sg, gid_t gid, int sat, time_t atime,
391
 
                int smt, time_t mtime, int ssz, off_t size);
392
 
 
393
 
/* Returns struct dav_stat which currently is mainly fake.
 
412
int
 
413
dav_setattr(dav_node *node, uid_t uid, int sm, mode_t mode, int so,
 
414
            uid_t owner, int sg, gid_t gid, int sat, time_t atime, int smt,
 
415
            time_t mtime, int ssz, off_t size);
 
416
 
 
417
 
 
418
/* Returns struct dav_stat. If the server does not provide theinformation
 
419
   it will contain fake data.
394
420
   No permissions necessary. */
395
 
dav_stat dav_statfs(void);
 
421
dav_stat *
 
422
dav_statfs(void);
396
423
 
397
424
 
398
425
/* Calls fsync() for all filedescriptors of node, that are not read only.
399
426
   No permissions are checked. */
400
 
int dav_sync(dav_node *node);
 
427
int
 
428
dav_sync(dav_node *node);
401
429
 
402
430
 
403
431
/* Writes size bytes from buf to file descriptor fd, starting at position
404
432
   offset.
405
433
   The number of bytes written is returned in len.
406
434
   The file must be opened writeonly or readwrite. */
407
 
/* TODO: Remove pid; check flags. */
408
 
int dav_write(size_t *written, dav_node * node, int fd, char *buf, size_t size,
409
 
              off_t offset);
410
 
 
411
 
 
412
 
#endif
 
435
int
 
436
dav_write(size_t *written, dav_node * node, int fd, char *buf, size_t size,
 
437
          off_t offset);
 
438
 
 
439
 
 
440
#endif /* DAV_CACHE_H */