+2005-08-03  Miklos Szeredi <miklos@szeredi.hu>
+
+       * fix warnings in fuse.h and fuse_lowlevel.h if -Wshadow compiler
+       option is used (Paul Alfille).
+
 2005-08-02  Miklos Szeredi <miklos@szeredi.hu>
 
        * highlevel-lib: added mount options "attr_timeout" and
        "entry_timeout".  These options control the length of time file
        attributes and entries (names) are cached.  Both default to 1.0
        second.
-       
+
+       * kernel: correctly handle zero timeout for attributes and entries
+
 2005-08-01  Miklos Szeredi <miklos@szeredi.hu>
 
        * Added missing symbols to versionscript (Joshua J. Berry)
        newly created
 
        * lib (highlevel): make open method optional
- 
+
 2005-07-28  Miklos Szeredi <miklos@szeredi.hu>
 
        * kernel: invalidate attributes for read/readdir/readlink
 
        AC_SUBST(mkdir_p)
 fi
 
-CFLAGS="-Wall -W -g -O2"
+if test -z "$CFLAGS"; then
+       CFLAGS="-Wall -W -g -O2"
+fi
 CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DFUSE_USE_VERSION=22"
 
 AC_ARG_ENABLE(kernel-module,
 
     struct stat stbuf;
     size_t oldsize = b->size;
     b->size += fuse_dirent_size(strlen(name));
-    b->p = realloc(b->p, b->size);
+    b->p = (char *) realloc(b->p, b->size);
     memset(&stbuf, 0, sizeof(stbuf));
     stbuf.st_ino = ino;
     fuse_add_dirent(b->p + oldsize, name, &stbuf, b->size);
 
 #include <time.h>
 #include <errno.h>
 
-#define UNUSED(x) x __attribute__((unused))
-
 static int null_getattr(const char *path, struct stat *stbuf)
 {
     if(strcmp(path, "/") != 0)
     return 0;
 }
 
-static int null_truncate(const char *path, off_t UNUSED(size))
+static int null_truncate(const char *path, off_t size)
 {
+    (void) size;
+
     if(strcmp(path, "/") != 0)
         return -ENOENT;
 
     return 0;
 }
 
-static int null_open(const char *path, struct fuse_file_info *UNUSED(fi))
+static int null_open(const char *path, struct fuse_file_info *fi)
 {
+    (void) fi;
+
     if(strcmp(path, "/") != 0)
         return -ENOENT;
 
     return 0;
 }
 
-static int null_read(const char *path, char *UNUSED(buf), size_t size,
-                     off_t UNUSED(offset), struct fuse_file_info *UNUSED(fi))
+static int null_read(const char *path, char *buf, size_t size,
+                     off_t offset, struct fuse_file_info *fi)
 {
+    (void) buf;
+    (void) offset;
+    (void) fi;
+
     if(strcmp(path, "/") != 0)
         return -ENOENT;
 
     return size;
 }
 
-static int null_write(const char *path, const char *UNUSED(buf), size_t size,
-                     off_t UNUSED(offset), struct fuse_file_info *UNUSED(fi))
+static int null_write(const char *path, const char *buf, size_t size,
+                     off_t offset, struct fuse_file_info *fi)
 {
+    (void) buf;
+    (void) offset;
+    (void) fi;
+
     if(strcmp(path, "/") != 0)
         return -ENOENT;
 
 
  * @return 1 if buffer is full, zero otherwise
  */
 typedef int (*fuse_fill_dir_t) (void *buf, const char *name,
-                                const struct stat *stat, off_t off);
+                                const struct stat *stbuf, off_t off);
 
 /* Used by deprecated getdir() method */
 typedef struct fuse_dirhandle *fuse_dirh_t;
      * with the given flags.  In fact it cannot correctly do that
      * since it doesn't have a way to determine if the file was just
      * created (and hence the permission need not be checked).
-     * 
+     *
      * If permission needs to be checked, implement the access()
      * method, and do the check there.
      *
 
     /**
      * Check file access permissions
-     * 
+     *
      * Need not be implemented.  Will only be called for the access()
      * system call, and for the open() system call, unless a new file
      * is created (file didn't exist and O_CREAT was given).  If the
 
                      size_t size);
     void (*listxattr)(fuse_req_t req, fuse_ino_t ino, size_t size);
     void (*removexattr)(fuse_req_t req, fuse_ino_t ino, const char *name);
-    void (*getlk)  (fuse_req_t req, fuse_ino_t ino, 
+    void (*getlk)  (fuse_req_t req, fuse_ino_t ino,
                     const struct fuse_lock_param *lk);
     void (*setlk)  (fuse_req_t req, fuse_ino_t ino, int sleep,
                     const struct fuse_lock_param *lk);
 int fuse_reply_buf(fuse_req_t req, const char *buf, size_t size);
 
 /* statfs */
-int fuse_reply_statfs(fuse_req_t req, const struct statfs *statfs);
+int fuse_reply_statfs(fuse_req_t req, const struct statfs *stbuf);
 
 /* getxattr, listxattr */
 int fuse_reply_xattr(fuse_req_t req, size_t count);
 size_t fuse_dirent_size(size_t namelen);
 
 /* add a directory entry to the buffer */
-char *fuse_add_dirent(char *buf, const char *name, const struct stat *stat,
+char *fuse_add_dirent(char *buf, const char *name, const struct stat *stbuf,
                       off_t off);
 
 /* ------------------------------------------ */
 
                                            unsigned long nsec)
 {
        struct timespec ts = {sec, nsec};
-       return jiffies + timespec_to_jiffies(&ts);
+       return jiffies + ((sec || nsec) ? timespec_to_jiffies(&ts) : 0) - 1;
 }
 
 static void fuse_lookup_init(struct fuse_req *req, struct inode *dir,
                        return -EACCES;
 
                err = 0;
-               if (nd && 
+               if (nd &&
                    ((nd->flags & LOOKUP_ACCESS) ||
                     ((nd->flags & LOOKUP_OPEN) && mode != 0)))
                        err = fuse_access(inode, mask);
 
 static void fuse_readlink(fuse_req_t req, fuse_ino_t ino)
 {
     struct fuse *f = req_fuse_prepare(req);
-    char link[PATH_MAX + 1];
+    char linkname[PATH_MAX + 1];
     char *path;
     int err;
 
     if (path != NULL) {
         err = -ENOSYS;
         if (f->op.readlink)
-            err = f->op.readlink(path, link, sizeof(link));
+            err = f->op.readlink(path, linkname, sizeof(linkname));
         free(path);
     }
     pthread_rwlock_unlock(&f->tree_lock);
     if (!err) {
-        link[PATH_MAX] = '\0';
-        fuse_reply_readlink(req, link);
+        linkname[PATH_MAX] = '\0';
+        fuse_reply_readlink(req, linkname);
     } else
         reply_err(req, err);
 }
     reply_err(req, err);
 }
 
-static void fuse_symlink(fuse_req_t req, const char *link, fuse_ino_t parent,
-                         const char *name)
+static void fuse_symlink(fuse_req_t req, const char *linkname,
+                         fuse_ino_t parent, const char *name)
 {
     struct fuse *f = req_fuse_prepare(req);
     struct fuse_entry_param e;
         }
         err = -ENOSYS;
         if (f->op.symlink && f->op.getattr) {
-            err = f->op.symlink(link, path);
+            err = f->op.symlink(linkname, path);
             if (!err)
                 err = lookup_path(f, parent, name, path, &e);
         }
 }
 
 static int fill_dir_common(struct fuse_dirhandle *dh, const char *name,
-                           const struct stat *stat, off_t off)
+                           const struct stat *statp, off_t off)
 {
     struct stat stbuf;
     unsigned namelen = strlen(name);
     unsigned newlen;
     char *newptr;
 
-    if (stat)
-        stbuf = *stat;
+    if (statp)
+        stbuf = *statp;
     else {
         memset(&stbuf, 0, sizeof(stbuf));
-        stbuf.st_ino = -1;
+        stbuf.st_ino = (ino_t) -1;
     }
 
     if (!(dh->fuse->flags & FUSE_USE_INO)) {
             return 1;
     }
 
-    newptr = realloc(dh->contents, newlen);
+    newptr = (char *) realloc(dh->contents, newlen);
     if (!newptr) {
         dh->error = -ENOMEM;
         return 1;
     return 0;
 }
 
-static int fill_dir(void *buf, const char *name, const struct stat *stat,
+static int fill_dir(void *buf, const char *name, const struct stat *stbuf,
                     off_t off)
 {
-    return fill_dir_common((struct fuse_dirhandle *) buf, name, stat, off);
+    return fill_dir_common((struct fuse_dirhandle *) buf, name, stbuf, off);
 }
 
 static int fill_dir_old(struct fuse_dirhandle *dh, const char *name, int type,
 }
 
 static void convert_statfs_compat(struct fuse_statfs_compat1 *compatbuf,
-                                  struct statfs *statfs)
+                                  struct statfs *stbuf)
 {
-    statfs->f_bsize   = compatbuf->block_size;
-    statfs->f_blocks  = compatbuf->blocks;
-    statfs->f_bfree   = compatbuf->blocks_free;
-    statfs->f_bavail  = compatbuf->blocks_free;
-    statfs->f_files   = compatbuf->files;
-    statfs->f_ffree   = compatbuf->files_free;
-    statfs->f_namelen = compatbuf->namelen;
+    stbuf->f_bsize   = compatbuf->block_size;
+    stbuf->f_blocks  = compatbuf->blocks;
+    stbuf->f_bfree   = compatbuf->blocks_free;
+    stbuf->f_bavail  = compatbuf->blocks_free;
+    stbuf->f_files   = compatbuf->files;
+    stbuf->f_ffree   = compatbuf->files_free;
+    stbuf->f_namelen = compatbuf->namelen;
 }
 
 static void fuse_statfs(fuse_req_t req)
 struct fuse *fuse_new_compat1(int fd, int flags,
                               const struct fuse_operations_compat1 *op)
 {
-    char *opts = NULL;
+    const char *opts = NULL;
     if (flags & FUSE_DEBUG_COMPAT1)
         opts = "debug";
     return fuse_new_common(fd, opts, (struct fuse_operations *) op,
 
     return FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + namelen);
 }
 
-char *fuse_add_dirent(char *buf, const char *name, const struct stat *stat,
+char *fuse_add_dirent(char *buf, const char *name, const struct stat *stbuf,
                       off_t off)
 {
     unsigned namelen = strlen(name);
     unsigned padlen = entsize - entlen;
     struct fuse_dirent *dirent = (struct fuse_dirent *) buf;
 
-    dirent->ino = stat->st_ino;
+    dirent->ino = stbuf->st_ino;
     dirent->off = off;
     dirent->namelen = namelen;
-    dirent->type = (stat->st_mode & 0170000) >> 12;
+    dirent->type = (stbuf->st_mode & 0170000) >> 12;
     strncpy(dirent->name, name, namelen);
     if (padlen)
         memset(buf + entlen, 0, padlen);
     return buf + entsize;
 }
 
-static void convert_statfs(const struct statfs *statfs,
+static void convert_statfs(const struct statfs *stbuf,
                            struct fuse_kstatfs *kstatfs)
 {
-    kstatfs->bsize     = statfs->f_bsize;
-    kstatfs->blocks    = statfs->f_blocks;
-    kstatfs->bfree     = statfs->f_bfree;
-    kstatfs->bavail    = statfs->f_bavail;
-    kstatfs->files     = statfs->f_files;
-    kstatfs->ffree     = statfs->f_ffree;
-    kstatfs->namelen   = statfs->f_namelen;
+    kstatfs->bsize     = stbuf->f_bsize;
+    kstatfs->blocks    = stbuf->f_blocks;
+    kstatfs->bfree     = stbuf->f_bfree;
+    kstatfs->bavail    = stbuf->f_bavail;
+    kstatfs->files     = stbuf->f_files;
+    kstatfs->ffree     = stbuf->f_ffree;
+    kstatfs->namelen   = stbuf->f_namelen;
 }
 
 static void free_req(fuse_req_t req)
     return send_reply_req(req, &arg, sizeof(arg));
 }
 
-int fuse_reply_readlink(fuse_req_t req, const char *link)
+int fuse_reply_readlink(fuse_req_t req, const char *linkname)
 {
-    return send_reply_req(req, link, strlen(link));
+    return send_reply_req(req, linkname, strlen(linkname));
 }
 
 int fuse_reply_open(fuse_req_t req, const struct fuse_file_info *f)
     return send_reply_req(req, buf, size);
 }
 
-int fuse_reply_statfs(fuse_req_t req, const struct statfs *statfs)
+int fuse_reply_statfs(fuse_req_t req, const struct statfs *stbuf)
 {
     struct fuse_statfs_out arg;
 
     memset(&arg, 0, sizeof(arg));
-    convert_statfs(statfs, &arg.st);
+    convert_statfs(stbuf, &arg.st);
 
     return send_reply_req(req, &arg, sizeof(arg));
 }
 int fuse_reply_getlk(fuse_req_t req, const struct fuse_lock_param *lk)
 {
     struct fuse_lk_in_out arg;
-    
+
     memset(&arg, 0, sizeof(arg));
     convert_lock_param(lk, &arg.lk);
-    
+
     return send_reply_req(req, &arg, sizeof(arg));
 }
 
 }
 
 static void do_symlink(fuse_req_t req, fuse_ino_t nodeid, char *name,
-                       char *link)
+                       char *linkname)
 {
     if (req->f->op.symlink)
-        req->f->op.symlink(req, link, nodeid, name);
+        req->f->op.symlink(req, linkname, nodeid, name);
     else
         fuse_reply_err(req, ENOSYS);
 }
 {
     if (req->f->op.getlk) {
         struct fuse_lock_param lk;
-        
+
         memset(&lk, 0, sizeof(lk));
         convert_file_lock(&arg->lk, &lk);
         req->f->op.getlk(req, nodeid, &lk);
         fuse_reply_err(req, ENOSYS);
 }
 
-static void do_setlk(fuse_req_t req, fuse_ino_t nodeid, int sleep, 
+static void do_setlk(fuse_req_t req, fuse_ino_t nodeid, int issleep,
                      struct fuse_lk_in_out *arg)
 {
     if (req->f->op.setlk) {
         struct fuse_lock_param lk;
-        
+
         memset(&lk, 0, sizeof(lk));
         convert_file_lock(&arg->lk, &lk);
-        req->f->op.setlk(req, nodeid, sleep, &lk);
+        req->f->op.setlk(req, nodeid, issleep, &lk);
     } else
         fuse_reply_err(req, ENOSYS);
 }
 
     if (f->debug) {
         printf("unique: %llu, opcode: %s (%i), nodeid: %lu, insize: %i\n",
-               in->unique, opname(in->opcode), in->opcode,
+               in->unique, opname((enum fuse_opcode) in->opcode), in->opcode,
                (unsigned long) in->nodeid, cmd->buflen);
         fflush(stdout);
     }
     case FUSE_SETLKW:
         do_setlk(req, in->nodeid, 1, (struct fuse_lk_in_out *) inarg);
         break;
-        
+
     case FUSE_ACCESS:
         do_access(req, in->nodeid, (struct fuse_access_in *) inarg);
         break;
 
     struct fuse_worker *w;
     int i;
 
-    w = malloc(sizeof(struct fuse_worker));
+    w = (struct fuse_worker *) malloc(sizeof(struct fuse_worker));
     if (w == NULL) {
         fprintf(stderr, "fuse: failed to allocate worker structure\n");
         return -1;
 
     free(data);
 }
 
-static int mt_create_context_key()
+static int mt_create_context_key(void)
 {
     int err = 0;
     pthread_mutex_lock(&context_lock);
     return err;
 }
 
-static void mt_delete_context_key()
+static void mt_delete_context_key(void)
 {
     pthread_mutex_lock(&context_lock);
     context_ref--;
 
     fprintf(stderr, "see `%s -h' for usage\n", argv[0]);
 }
 
-static void exit_handler()
+static void exit_handler(int sig)
 {
+    (void) sig;
     if (fuse_instance != NULL)
         fuse_exit(fuse_instance);
 }
 
-static int set_one_signal_handler(int signal, void (*handler)(int))
+static int set_one_signal_handler(int sig, void (*handler)(int))
 {
     struct sigaction sa;
     struct sigaction old_sa;
     sigemptyset(&(sa.sa_mask));
     sa.sa_flags = 0;
 
-    if (sigaction(signal, NULL, &old_sa) == -1) {
+    if (sigaction(sig, NULL, &old_sa) == -1) {
         perror("FUSE: cannot get old signal handler");
         return -1;
     }
 
     if (old_sa.sa_handler == SIG_DFL &&
-        sigaction(signal, &sa, NULL) == -1) {
+        sigaction(sig, &sa, NULL) == -1) {
         perror("Cannot set signal handler");
         return -1;
     }
     return 0;
 }
 
-static int set_signal_handlers()
+static int set_signal_handlers(void)
 {
     if (set_one_signal_handler(SIGHUP, exit_handler) == -1 ||
         set_one_signal_handler(SIGINT, exit_handler) == -1 ||
     unsigned len = strlen(opt);
     if (*optp) {
         unsigned oldlen = strlen(*optp);
-        *optp = realloc(*optp, oldlen + 1 + len + 1);
+        *optp = (char *) realloc(*optp, oldlen + 1 + len + 1);
         if (*optp == NULL)
             return -1;
         (*optp)[oldlen] = ',';
         strcpy(*optp + oldlen + 1, opt);
     } else {
-        *optp = malloc(len + 1);
+        *optp = (char *) malloc(len + 1);
         if (*optp == NULL)
             return -1;
         strcpy(*optp, opt);
     else if (basename[1] != '\0')
         basename++;
 
-    fsname_opt = malloc(strlen(basename) + 64);
+    fsname_opt = (char *) malloc(strlen(basename) + 64);
     if (fsname_opt == NULL) {
         fprintf(stderr, "fuse: memory allocation failed\n");
         return -1;
 }
 
 #undef fuse_main
-int fuse_main()
+int fuse_main(void)
 {
     fprintf(stderr, "fuse_main(): This function does not exist\n");
     return -1;
 
         char env[10];
         const char *argv[32];
         int a = 0;
-        
+
         argv[a++] = mountprog;
         if (opts) {
             argv[a++] = "-o";
 
 static int user_allow_other = 0;
 static int mount_max = 1000;
 
-static const char *get_user_name()
+static const char *get_user_name(void)
 {
     struct passwd *pw = getpwuid(getuid());
     if (pw != NULL && pw->pw_name != NULL)
 #ifndef USE_UCLIBC
 /* use a lock file so that multiple fusermount processes don't try and
    modify the mtab file at once! */
-static int lock_mtab()
+static int lock_mtab(void)
 {
     const char *mtab_lock = _PATH_MOUNTED ".fuselock";
     int mtablock;
 
     found = 0;
     while ((entp = getmntent(fp)) != NULL) {
-        int remove = 0;
+        int removed = 0;
         if (!found && strcmp(entp->mnt_dir, mnt) == 0 &&
            strcmp(entp->mnt_type, "fuse") == 0) {
             if (user == NULL)
-                remove = 1;
+                removed = 1;
             else {
                 char *p = strstr(entp->mnt_opts, "user=");
                 if (p != NULL && strcmp(p + 5, user) == 0)
-                    remove = 1;
+                    removed = 1;
             }
         }
-        if (remove)
+        if (removed)
             found = 1;
         else {
             res = addmntent(newfp, entp);
     return 0;
 }
 
-static int count_fuse_fs()
+static int count_fuse_fs(void)
 {
     struct mntent *entp;
     int count = 0;
     else {
         unsigned oldsize = strlen(*optsp);
         unsigned newsize = oldsize + 1 + strlen(opt) + expand + 1;
-        newopts = realloc(*optsp, newsize);
+        newopts = (char *) realloc(*optsp, newsize);
         if (newopts)
             sprintf(newopts + oldsize, ",%s", opt);
     }
     char *fsname = NULL;
     int check_empty = 1;
 
-    optbuf = malloc(strlen(opts) + 128);
+    optbuf = (char *) malloc(strlen(opts) + 128);
     if (!optbuf) {
         fprintf(stderr, "%s: failed to allocate memory\n", progname);
         return -1;
             unsigned fsname_str_len = strlen(fsname_str);
             if (fsname)
                 free(fsname);
-            fsname = malloc(len - fsname_str_len + 1);
+            fsname = (char *) malloc(len - fsname_str_len + 1);
             if (!fsname) {
                 fprintf(stderr, "%s: failed to allocate memory\n", progname);
                 goto err;