diff options
author | Csaba Henk <csaba@gluster.com> | 2009-08-10 19:46:45 -0700 |
---|---|---|
committer | Csaba Henk <csaba@gluster.com> | 2009-08-12 06:21:04 -0700 |
commit | 472ac9944b2e99b8dd4a7e33f8dc4ae0f111b0cc (patch) | |
tree | 35afa43b65ae457657d00570f0a2f3da6802e0fd /contrib/fuse-lib/misc.c | |
parent | ab5df475c5c7e9e0f3268fe94a6280e71d34c1db (diff) |
fuse: move libfuse derived code over under contrib/
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; +} |