diff options
author | Anand V. Avati <avati@dev.gluster.com> | 2009-08-17 15:25:44 -0700 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2009-08-17 15:25:44 -0700 |
commit | a31b0016347b3bc9b341fa0f4541ed137224f593 (patch) | |
tree | 3e1faf06a3e14e5022048886ecfa49267c92c986 /contrib/fuse-lib/misc.c | |
parent | 862cbb38375f0176582b06019ba406818d236828 (diff) | |
parent | 10824751f8669e7c39ebd46ab698ed0abd4e5165 (diff) |
Merge branch 'fusilli' of /data/git/users/csaba/glusterfs-fusilli
Conflicts:
xlators/mount/fuse/src/fuse-bridge.c
Diffstat (limited to 'contrib/fuse-lib/misc.c')
-rw-r--r-- | contrib/fuse-lib/misc.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/contrib/fuse-lib/misc.c b/contrib/fuse-lib/misc.c new file mode 100644 index 00000000000..877c3880de0 --- /dev/null +++ b/contrib/fuse-lib/misc.c @@ -0,0 +1,51 @@ +/* + FUSE: Filesystem in Userspace + Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu> + + This program can be distributed under the terms of the GNU LGPLv2. + See the file COPYING.LIB +*/ + +#include <stdint.h> +#include <string.h> +#include <limits.h> +#include <fcntl.h> +#include "fuse_kernel.h" +#include "fuse-misc.h" + +unsigned long +calc_timeout_sec (double t) +{ + if (t > (double) ULONG_MAX) + return ULONG_MAX; + else if (t < 0.0) + return 0; + else + return (unsigned long) t; +} + +unsigned int +calc_timeout_nsec (double t) +{ + double f = t - (double) calc_timeout_sec (t); + if (f < 0.0) + return 0; + else if (f >= 0.999999999) + return 999999999; + else + return (unsigned int) (f * 1.0e9); +} + +void +convert_fuse_file_lock (struct fuse_file_lock *fl, struct flock *flock) +{ + memset (flock, 0, sizeof (struct flock)); + flock->l_type = fl->type; + flock->l_whence = SEEK_SET; + flock->l_start = fl->start; + if (fl->end == OFFSET_MAX) + flock->l_len = 0; + else + flock->l_len = fl->end - fl->start + 1; + flock->l_pid = fl->pid; +} |