/*  Header for file handle management routines

    ©1998,1999 Joseph Walton

    This software is distributed under the terms of the GNU General Public
    License; either version 2 of the License, or (at your option) any
    later version.
*/

/*
    25-Sep-1998: Added a few more fields to LocalFile
    30-Sep-1999: Using a timeval instead of a DateStamp
    14-Oct-2000: The handle-fluushing interval is now a field in `global'
*/

#ifndef NFSD_HANDLE_LIST_H
#define NFSD_HANDLE_LIST_H

#include "nfs.h"
#include "dirlist.h"

#include <dos/dos.h>
#include <exec/lists.h>
#include <devices/timer.h>

struct LocalFile {
    struct MinNode lf_Node;
    STRPTR lf_Name;                 /* The local name of the file */
    nfs_fh lf_NFSHandle;            /* The NFS handle of this file */
    u_int lf_FileID;                /* Unique inode */
    BOOL lf_IsMount;                /* Is this a mount point? If so, do not flush. */
    ftype lf_Type;                  /* The type we think it has */
    struct timeval lf_LastUsed;     /* When we last used all this data */
    BPTR lf_Lock;                   /* Possibly a DOS lock on this resource */
    struct DEList *lf_DEList;       /* Possibly a list of entries in this directory */

    LONG lf_CfgSerial;              /* The cfgSerial that we may have cached values depending upon */
    LONG lf_ForcedUID;              /* These override the real values */
    LONG lf_ForcedGID;
    LONG lf_ForcedProtection;

};

/* It might be smart to hold an open lock or file handle here as well,
    but that raises problems with files being renamed during access,
    amongst other things */

BOOL init_handle_list(void);
void persistent_inode_fetch(void);
BOOL persistent_inode_store(void);
struct LocalFile *find_handle(nfs_fh *fh);
struct LocalFile *get_by_handle(nfs_fh *fh, nfsstat *stat, ULONG mode);
void release_lf(struct LocalFile *lf);
BOOL fh_match(nfs_fh *fha, nfs_fh *fhb);
BOOL flush_handles(void);
int32 *fh_copy(struct LocalFile *lf, int32 *dest);
void fh_print(nfs_fh *fh);
void correct_struct(struct LocalFile *lf);
struct LocalFile *get_namedlocalfile(STRPTR name);
struct LocalFile *find_namedlocalfile(STRPTR name);
void lose_localfile(STRPTR full_name);
ULONG handleHash(APTR handle);

#endif

