2017-06-27 23:31:44 +03:00
|
|
|
/* -*- mode:c; tab-width:8; c-basic-offset:8; indent-tabs-mode:nil; -*- */
|
2011-02-06 07:45:09 +03:00
|
|
|
/*
|
|
|
|
Copyright (C) 2010 by Ronnie Sahlberg <ronniesahlberg@gmail.com>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2.1 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
|
|
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2014-02-14 01:19:51 +04:00
|
|
|
|
|
|
|
#ifndef _LIBNFS_PRIVATE_H_
|
|
|
|
#define _LIBNFS_PRIVATE_H_
|
|
|
|
|
2013-04-11 07:28:40 +04:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h" /* HAVE_SOCKADDR_STORAGE ? */
|
|
|
|
#endif
|
|
|
|
|
2016-07-29 20:25:39 +03:00
|
|
|
#ifdef HAVE_NET_IF_H
|
|
|
|
#include <net/if.h>
|
|
|
|
#endif
|
|
|
|
|
2021-09-10 05:01:31 +03:00
|
|
|
#if !defined(WIN32) && !defined(PS2_EE)
|
2012-07-04 10:53:12 +04:00
|
|
|
#include <sys/socket.h> /* struct sockaddr_storage */
|
2013-05-29 03:15:16 +04:00
|
|
|
#endif
|
2012-07-04 10:53:12 +04:00
|
|
|
|
2016-09-20 22:01:06 +03:00
|
|
|
#if defined(WIN32) && !defined(IFNAMSIZ)
|
|
|
|
#define IFNAMSIZ 255
|
|
|
|
#endif
|
|
|
|
|
2020-08-15 17:28:04 +03:00
|
|
|
#if defined(PS3_PPU) && !defined(IFNAMSIZ)
|
|
|
|
#define IFNAMSIZ 16
|
|
|
|
#endif
|
|
|
|
|
2021-09-10 05:01:31 +03:00
|
|
|
#if defined(PS2_EE) && !defined(IFNAMSIZ)
|
|
|
|
#define IFNAMSIZ 16
|
|
|
|
#endif
|
|
|
|
|
2021-10-05 13:24:55 +03:00
|
|
|
#include "libnfs-multithreading.h"
|
2012-07-04 10:53:12 +04:00
|
|
|
#include "libnfs-zdr.h"
|
2017-07-08 07:29:56 +03:00
|
|
|
#include "../nfs/libnfs-raw-nfs.h"
|
|
|
|
#include "../nfs4/libnfs-raw-nfs4.h"
|
2011-02-06 07:45:09 +03:00
|
|
|
|
2014-02-14 01:27:57 +04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2013-05-29 03:15:16 +04:00
|
|
|
|
2016-05-13 13:03:40 +03:00
|
|
|
#ifndef MIN
|
|
|
|
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
|
|
|
#endif
|
|
|
|
#ifndef MAX
|
|
|
|
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
|
|
|
#endif
|
|
|
|
|
2021-09-10 05:01:31 +03:00
|
|
|
#if !defined(HAVE_SOCKADDR_STORAGE) && !defined(WIN32) && !defined(PS2_EE)
|
2013-04-11 07:28:40 +04:00
|
|
|
/*
|
|
|
|
* RFC 2553: protocol-independent placeholder for socket addresses
|
|
|
|
*/
|
|
|
|
#define _SS_MAXSIZE 128
|
|
|
|
#define _SS_ALIGNSIZE (sizeof(double))
|
|
|
|
#define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(unsigned char) * 2)
|
|
|
|
#define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(unsigned char) * 2 - \
|
|
|
|
_SS_PAD1SIZE - _SS_ALIGNSIZE)
|
|
|
|
|
|
|
|
struct sockaddr_storage {
|
2013-04-13 06:13:11 +04:00
|
|
|
#ifdef HAVE_SOCKADDR_LEN
|
2013-04-11 07:28:40 +04:00
|
|
|
unsigned char ss_len; /* address length */
|
|
|
|
unsigned char ss_family; /* address family */
|
|
|
|
#else
|
|
|
|
unsigned short ss_family;
|
|
|
|
#endif
|
|
|
|
char __ss_pad1[_SS_PAD1SIZE];
|
|
|
|
double __ss_align; /* force desired structure storage alignment */
|
|
|
|
char __ss_pad2[_SS_PAD2SIZE];
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2011-10-04 05:31:56 +04:00
|
|
|
struct rpc_fragment {
|
|
|
|
struct rpc_fragment *next;
|
2016-09-21 19:58:01 +03:00
|
|
|
uint32_t size;
|
2011-10-04 05:31:56 +04:00
|
|
|
char *data;
|
|
|
|
};
|
|
|
|
|
2012-11-24 20:18:54 +04:00
|
|
|
#define RPC_CONTEXT_MAGIC 0xc6e46435
|
2013-12-23 16:12:28 +04:00
|
|
|
#define RPC_PARAM_UNDEFINED -1
|
2012-11-24 20:18:54 +04:00
|
|
|
|
2014-01-07 14:23:46 +04:00
|
|
|
/*
|
|
|
|
* Queue is singly-linked but we hold on to the tail
|
|
|
|
*/
|
|
|
|
struct rpc_queue {
|
|
|
|
struct rpc_pdu *head, *tail;
|
|
|
|
};
|
|
|
|
|
2014-02-20 18:02:08 +04:00
|
|
|
#define HASHES 1024
|
2014-06-23 18:31:32 +04:00
|
|
|
#define NFS_RA_TIMEOUT 5
|
2015-06-19 14:15:56 +03:00
|
|
|
#define NFS_MAX_XFER_SIZE (1024 * 1024)
|
2016-06-02 10:12:53 +03:00
|
|
|
#define ZDR_ENCODE_OVERHEAD 1024
|
|
|
|
#define ZDR_ENCODEBUF_MINSIZE 4096
|
2014-02-20 18:02:08 +04:00
|
|
|
|
2016-11-29 16:36:59 +03:00
|
|
|
struct rpc_endpoint {
|
|
|
|
struct rpc_endpoint *next;
|
|
|
|
int program;
|
|
|
|
int version;
|
|
|
|
struct service_proc *procs;
|
|
|
|
int num_procs;
|
|
|
|
};
|
|
|
|
|
2011-02-06 07:45:09 +03:00
|
|
|
struct rpc_context {
|
2013-12-23 16:12:28 +04:00
|
|
|
uint32_t magic;
|
2011-02-06 07:45:09 +03:00
|
|
|
int fd;
|
2015-09-22 15:54:48 +03:00
|
|
|
int old_fd;
|
2011-02-06 07:45:09 +03:00
|
|
|
int is_connected;
|
2017-01-12 16:51:45 +03:00
|
|
|
int is_nonblocking;
|
2011-02-06 07:45:09 +03:00
|
|
|
|
|
|
|
char *error_string;
|
|
|
|
|
|
|
|
rpc_cb connect_cb;
|
|
|
|
void *connect_data;
|
|
|
|
|
2012-07-05 04:23:19 +04:00
|
|
|
struct AUTH *auth;
|
2013-10-22 06:15:11 +04:00
|
|
|
uint32_t xid;
|
2011-02-06 07:45:09 +03:00
|
|
|
|
2014-01-07 14:23:46 +04:00
|
|
|
struct rpc_queue outqueue;
|
2013-12-23 16:12:28 +04:00
|
|
|
struct sockaddr_storage udp_src;
|
2014-02-20 18:02:08 +04:00
|
|
|
struct rpc_queue waitpdu[HASHES];
|
2017-01-12 16:38:11 +03:00
|
|
|
uint32_t waitpdu_len;
|
2021-10-05 13:24:55 +03:00
|
|
|
#ifdef HAVE_MULTITHREADING
|
|
|
|
libnfs_mutex_t rpc_mutex;
|
|
|
|
#endif /* HAVE_MULTITHREADING */
|
2011-02-06 07:45:09 +03:00
|
|
|
|
2013-12-23 16:12:28 +04:00
|
|
|
uint32_t inpos;
|
2016-12-22 17:12:56 +03:00
|
|
|
char rm_buf[4];
|
2013-12-23 16:12:28 +04:00
|
|
|
char *inbuf;
|
2011-06-26 11:17:59 +04:00
|
|
|
|
2013-12-23 16:12:28 +04:00
|
|
|
/* special fields for UDP, which can sometimes be BROADCASTed */
|
|
|
|
int is_udp;
|
2016-12-02 04:39:46 +03:00
|
|
|
struct sockaddr_storage udp_dest;
|
2013-12-23 16:12:28 +04:00
|
|
|
int is_broadcast;
|
2011-10-04 04:25:10 +04:00
|
|
|
|
2013-12-23 16:12:28 +04:00
|
|
|
/* track the address we connect to so we can auto-reconnect on session failure */
|
|
|
|
struct sockaddr_storage s;
|
|
|
|
int auto_reconnect;
|
2017-05-30 03:21:13 +03:00
|
|
|
int num_retries;
|
2011-10-04 05:31:56 +04:00
|
|
|
|
|
|
|
/* fragment reassembly */
|
|
|
|
struct rpc_fragment *fragments;
|
2014-02-14 01:19:51 +04:00
|
|
|
|
2013-12-23 16:12:28 +04:00
|
|
|
/* parameters passable via URL */
|
|
|
|
int tcp_syncnt;
|
2013-12-23 16:35:31 +04:00
|
|
|
int uid;
|
|
|
|
int gid;
|
2014-06-23 18:31:32 +04:00
|
|
|
uint32_t readahead;
|
2016-05-13 13:03:40 +03:00
|
|
|
uint32_t pagecache;
|
|
|
|
uint32_t pagecache_ttl;
|
2015-06-23 09:52:59 +03:00
|
|
|
int debug;
|
2017-07-08 09:46:24 +03:00
|
|
|
int timeout;
|
2016-07-29 20:25:39 +03:00
|
|
|
char ifname[IFNAMSIZ];
|
2016-11-29 16:36:59 +03:00
|
|
|
|
|
|
|
/* Is a server context ? */
|
|
|
|
int is_server_context;
|
|
|
|
struct rpc_endpoint *endpoints;
|
2011-02-06 07:45:09 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct rpc_pdu {
|
|
|
|
struct rpc_pdu *next;
|
|
|
|
|
2013-10-22 06:15:11 +04:00
|
|
|
uint32_t xid;
|
2012-07-04 10:53:12 +04:00
|
|
|
ZDR zdr;
|
2011-02-06 07:45:09 +03:00
|
|
|
|
2012-07-05 01:21:48 +04:00
|
|
|
uint32_t written;
|
2011-02-06 07:45:09 +03:00
|
|
|
struct rpc_data outdata;
|
|
|
|
|
|
|
|
rpc_cb cb;
|
|
|
|
void *private_data;
|
|
|
|
|
2012-07-04 10:53:12 +04:00
|
|
|
/* function to decode the zdr reply data and buffer to decode into */
|
|
|
|
zdrproc_t zdr_decode_fn;
|
|
|
|
caddr_t zdr_decode_buf;
|
2012-07-05 01:21:48 +04:00
|
|
|
uint32_t zdr_decode_bufsize;
|
2016-11-29 08:34:40 +03:00
|
|
|
|
|
|
|
#define PDU_DISCARD_AFTER_SENDING 0x00000001
|
|
|
|
uint32_t flags;
|
2017-05-09 04:38:42 +03:00
|
|
|
|
2017-07-08 10:08:17 +03:00
|
|
|
uint64_t timeout;
|
2011-02-06 07:45:09 +03:00
|
|
|
};
|
|
|
|
|
2014-01-07 14:23:46 +04:00
|
|
|
void rpc_reset_queue(struct rpc_queue *q);
|
|
|
|
void rpc_enqueue(struct rpc_queue *q, struct rpc_pdu *pdu);
|
|
|
|
void rpc_return_to_queue(struct rpc_queue *q, struct rpc_pdu *pdu);
|
2014-02-20 18:02:08 +04:00
|
|
|
unsigned int rpc_hash_xid(uint32_t xid);
|
2014-01-07 14:23:46 +04:00
|
|
|
|
2012-07-04 10:53:12 +04:00
|
|
|
struct rpc_pdu *rpc_allocate_pdu(struct rpc_context *rpc, int program, int version, int procedure, rpc_cb cb, void *private_data, zdrproc_t zdr_decode_fn, int zdr_bufsize);
|
2016-06-02 10:12:53 +03:00
|
|
|
struct rpc_pdu *rpc_allocate_pdu2(struct rpc_context *rpc, int program, int version, int procedure, rpc_cb cb, void *private_data, zdrproc_t zdr_decode_fn, int zdr_bufsize, size_t alloc_hint);
|
2011-02-06 07:45:09 +03:00
|
|
|
void rpc_free_pdu(struct rpc_context *rpc, struct rpc_pdu *pdu);
|
|
|
|
int rpc_queue_pdu(struct rpc_context *rpc, struct rpc_pdu *pdu);
|
2016-05-30 17:10:56 +03:00
|
|
|
uint32_t rpc_get_pdu_size(char *buf);
|
2011-02-06 07:45:09 +03:00
|
|
|
int rpc_process_pdu(struct rpc_context *rpc, char *buf, int size);
|
2015-03-11 07:06:38 +03:00
|
|
|
void rpc_error_all_pdus(struct rpc_context *rpc, const char *error);
|
2011-02-06 07:45:09 +03:00
|
|
|
|
2015-03-11 07:06:38 +03:00
|
|
|
void rpc_set_error(struct rpc_context *rpc, const char *error_string, ...)
|
2014-02-18 03:41:05 +04:00
|
|
|
#ifdef __GNUC__
|
|
|
|
__attribute__((format(printf, 2, 3)))
|
|
|
|
#endif
|
|
|
|
;
|
|
|
|
|
|
|
|
void nfs_set_error(struct nfs_context *nfs, char *error_string, ...)
|
|
|
|
#ifdef __GNUC__
|
|
|
|
__attribute__((format(printf, 2, 3)))
|
|
|
|
#endif
|
|
|
|
;
|
2011-06-19 03:38:20 +04:00
|
|
|
|
2021-10-15 11:14:18 +03:00
|
|
|
#if defined(PS2_EE)
|
|
|
|
#define RPC_LOG(rpc, level, format, ...) ;
|
|
|
|
#else
|
2015-06-23 09:52:59 +03:00
|
|
|
#define RPC_LOG(rpc, level, format, ...) \
|
|
|
|
do { \
|
|
|
|
if (level <= rpc->debug) { \
|
|
|
|
fprintf(stderr, "libnfs:%d " format "\n", level, ## __VA_ARGS__); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
2021-10-15 11:14:18 +03:00
|
|
|
#endif
|
2015-06-23 09:52:59 +03:00
|
|
|
|
2011-07-31 04:46:34 +04:00
|
|
|
const char *nfs_get_server(struct nfs_context *nfs);
|
|
|
|
const char *nfs_get_export(struct nfs_context *nfs);
|
2011-06-19 03:38:20 +04:00
|
|
|
|
2011-06-26 12:40:00 +04:00
|
|
|
/* we dont want to expose UDP to normal applications/users this is private to libnfs to use exclusively for broadcast RPC */
|
|
|
|
int rpc_bind_udp(struct rpc_context *rpc, char *addr, int port);
|
2011-06-26 12:42:53 +04:00
|
|
|
int rpc_set_udp_destination(struct rpc_context *rpc, char *addr, int port, int is_broadcast);
|
2011-06-26 11:27:40 +04:00
|
|
|
struct rpc_context *rpc_init_udp_context(void);
|
2011-06-26 12:45:38 +04:00
|
|
|
struct sockaddr *rpc_get_recv_sockaddr(struct rpc_context *rpc);
|
|
|
|
|
2017-05-30 03:21:13 +03:00
|
|
|
void rpc_set_autoreconnect(struct rpc_context *rpc, int num_retries);
|
2011-10-04 04:25:10 +04:00
|
|
|
|
2016-07-29 20:25:39 +03:00
|
|
|
void rpc_set_interface(struct rpc_context *rpc, const char *ifname);
|
|
|
|
|
2013-12-23 16:12:28 +04:00
|
|
|
void rpc_set_tcp_syncnt(struct rpc_context *rpc, int v);
|
2016-05-13 13:03:40 +03:00
|
|
|
void rpc_set_pagecache(struct rpc_context *rpc, uint32_t v);
|
|
|
|
void rpc_set_pagecache_ttl(struct rpc_context *rpc, uint32_t v);
|
2014-06-23 18:31:32 +04:00
|
|
|
void rpc_set_readahead(struct rpc_context *rpc, uint32_t v);
|
2015-06-23 09:52:59 +03:00
|
|
|
void rpc_set_debug(struct rpc_context *rpc, int level);
|
2016-03-02 08:35:41 +03:00
|
|
|
void rpc_set_timeout(struct rpc_context *rpc, int timeout);
|
|
|
|
int rpc_get_timeout(struct rpc_context *rpc);
|
2016-09-21 19:58:01 +03:00
|
|
|
int rpc_add_fragment(struct rpc_context *rpc, char *data, uint32_t size);
|
2011-10-04 05:31:56 +04:00
|
|
|
void rpc_free_all_fragments(struct rpc_context *rpc);
|
2016-12-02 02:41:08 +03:00
|
|
|
int rpc_is_udp_socket(struct rpc_context *rpc);
|
2017-07-08 09:33:55 +03:00
|
|
|
uint64_t rpc_current_time(void);
|
2011-10-04 05:31:56 +04:00
|
|
|
|
2016-12-03 21:18:36 +03:00
|
|
|
void *zdr_malloc(ZDR *zdrs, uint32_t size);
|
|
|
|
|
2017-06-27 23:31:44 +03:00
|
|
|
|
|
|
|
struct nfs_cb_data;
|
|
|
|
void free_nfs_cb_data(struct nfs_cb_data *data);
|
|
|
|
|
|
|
|
struct nfs_specdata {
|
|
|
|
uint32_t specdata1;
|
|
|
|
uint32_t specdata2;
|
|
|
|
};
|
|
|
|
struct nfs_time {
|
|
|
|
uint32_t seconds;
|
|
|
|
uint32_t nseconds;
|
|
|
|
};
|
|
|
|
struct nfs_attr {
|
|
|
|
uint32_t type;
|
|
|
|
uint32_t mode;
|
|
|
|
uint32_t uid;
|
|
|
|
uint32_t gid;
|
|
|
|
uint32_t nlink;
|
|
|
|
uint64_t size;
|
|
|
|
uint64_t used;
|
|
|
|
uint64_t fsid;
|
|
|
|
struct nfs_specdata rdev;
|
|
|
|
struct nfs_time atime;
|
|
|
|
struct nfs_time mtime;
|
|
|
|
struct nfs_time ctime;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct nfs_fh {
|
|
|
|
int len;
|
|
|
|
char *val;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct nfs_context {
|
|
|
|
struct rpc_context *rpc;
|
|
|
|
char *server;
|
|
|
|
char *export;
|
|
|
|
struct nfs_fh rootfh;
|
|
|
|
uint64_t readmax;
|
|
|
|
uint64_t writemax;
|
|
|
|
char *cwd;
|
|
|
|
int dircache_enabled;
|
|
|
|
int auto_reconnect;
|
|
|
|
struct nfsdir *dircache;
|
|
|
|
uint16_t mask;
|
|
|
|
|
|
|
|
int auto_traverse_mounts;
|
|
|
|
struct nested_mounts *nested_mounts;
|
|
|
|
|
2018-04-08 07:36:37 +03:00
|
|
|
int version;
|
|
|
|
int nfsport;
|
|
|
|
int mountport;
|
2017-07-06 00:15:51 +03:00
|
|
|
|
|
|
|
/* NFSv4 specific fields */
|
|
|
|
verifier4 verifier;
|
|
|
|
char *client_name;
|
|
|
|
uint64_t clientid;
|
|
|
|
verifier4 setclientid_confirm;
|
2017-07-16 00:46:38 +03:00
|
|
|
uint32_t seqid;
|
2018-01-07 03:54:09 +03:00
|
|
|
int has_lock_owner;
|
2021-10-05 13:24:55 +03:00
|
|
|
#ifdef HAVE_MULTITHREADING
|
|
|
|
int multithreading_enabled;
|
|
|
|
libnfs_mutex_t nfs_mutex;
|
|
|
|
libnfs_thread_t service_thread;
|
|
|
|
#endif /* HAVE_MULTITHREADING */
|
2017-06-27 23:31:44 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef int (*continue_func)(struct nfs_context *nfs, struct nfs_attr *attr,
|
|
|
|
struct nfs_cb_data *data);
|
|
|
|
|
|
|
|
struct nfs_cb_data {
|
|
|
|
struct nfs_context *nfs;
|
|
|
|
struct nfsfh *nfsfh;
|
|
|
|
char *saved_path, *path;
|
|
|
|
int link_count, no_follow;
|
|
|
|
|
|
|
|
nfs_cb cb;
|
|
|
|
void *private_data;
|
|
|
|
|
|
|
|
continue_func continue_cb;
|
|
|
|
void *continue_data;
|
|
|
|
void (*free_continue_data)(void *);
|
|
|
|
uint64_t continue_int;
|
|
|
|
|
|
|
|
struct nfs_fh fh;
|
|
|
|
|
|
|
|
/* for multi-read/write calls. */
|
|
|
|
int error;
|
|
|
|
int cancel;
|
|
|
|
int oom;
|
|
|
|
int num_calls;
|
|
|
|
size_t count, org_count;
|
|
|
|
uint64_t offset, max_offset, org_offset;
|
|
|
|
char *buffer;
|
|
|
|
int not_my_buffer;
|
|
|
|
const char *usrbuf;
|
|
|
|
int update_pos;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct nested_mounts {
|
|
|
|
struct nested_mounts *next;
|
|
|
|
char *path;
|
|
|
|
struct nfs_fh fh;
|
|
|
|
struct nfs_attr attr;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define MAX_DIR_CACHE 128
|
|
|
|
#define MAX_LINK_COUNT 40
|
|
|
|
|
|
|
|
struct nfsdir {
|
|
|
|
struct nfs_fh fh;
|
|
|
|
struct nfs_attr attr;
|
|
|
|
struct nfsdir *next;
|
|
|
|
|
|
|
|
struct nfsdirent *entries;
|
|
|
|
struct nfsdirent *current;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct nfs_readahead {
|
|
|
|
uint64_t fh_offset;
|
|
|
|
uint32_t cur_ra;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct nfs_pagecache_entry {
|
|
|
|
char buf[NFS_BLKSIZE];
|
|
|
|
uint64_t offset;
|
|
|
|
time_t ts;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct nfs_pagecache {
|
|
|
|
struct nfs_pagecache_entry *entries;
|
|
|
|
uint32_t num_entries;
|
|
|
|
time_t ttl;
|
|
|
|
};
|
|
|
|
|
2017-07-16 00:46:38 +03:00
|
|
|
struct stateid {
|
|
|
|
uint32_t seqid;
|
|
|
|
char other[12];
|
|
|
|
};
|
|
|
|
|
2017-06-27 23:31:44 +03:00
|
|
|
struct nfsfh {
|
2017-07-16 00:46:38 +03:00
|
|
|
struct nfs_fh fh;
|
|
|
|
int is_sync;
|
|
|
|
int is_append;
|
2017-07-30 02:44:31 +03:00
|
|
|
int is_dirty;
|
2017-07-16 00:46:38 +03:00
|
|
|
uint64_t offset;
|
|
|
|
struct nfs_readahead ra;
|
|
|
|
struct nfs_pagecache pagecache;
|
|
|
|
|
|
|
|
/* NFSv4 */
|
|
|
|
struct stateid stateid;
|
2018-01-07 01:35:42 +03:00
|
|
|
/* locking */
|
|
|
|
uint32_t lock_seqid;
|
|
|
|
struct stateid lock_stateid;
|
2017-06-27 23:31:44 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
const struct nfs_fh *nfs_get_rootfh(struct nfs_context *nfs);
|
|
|
|
|
|
|
|
int nfs_normalize_path(struct nfs_context *nfs, char *path);
|
|
|
|
void nfs_free_nfsdir(struct nfsdir *nfsdir);
|
|
|
|
void nfs_free_nfsfh(struct nfsfh *nfsfh);
|
|
|
|
|
|
|
|
void nfs_dircache_add(struct nfs_context *nfs, struct nfsdir *nfsdir);
|
|
|
|
struct nfsdir *nfs_dircache_find(struct nfs_context *nfs, struct nfs_fh *fh);
|
|
|
|
void nfs_dircache_drop(struct nfs_context *nfs, struct nfs_fh *fh);
|
|
|
|
|
|
|
|
char * nfs_pagecache_get(struct nfs_pagecache *pagecache, uint64_t offset);
|
|
|
|
void nfs_pagecache_put(struct nfs_pagecache *pagecache, uint64_t offset,
|
|
|
|
const char *buf, size_t len);
|
|
|
|
|
|
|
|
int nfs3_access_async(struct nfs_context *nfs, const char *path, int mode,
|
|
|
|
nfs_cb cb, void *private_data);
|
|
|
|
int nfs3_access2_async(struct nfs_context *nfs, const char *path, nfs_cb cb,
|
|
|
|
void *private_data);
|
|
|
|
int nfs3_chdir_async(struct nfs_context *nfs, const char *path,
|
|
|
|
nfs_cb cb, void *private_data);
|
|
|
|
int nfs3_chmod_async_internal(struct nfs_context *nfs, const char *path,
|
|
|
|
int no_follow, int mode, nfs_cb cb,
|
|
|
|
void *private_data);
|
|
|
|
int nfs3_chown_async_internal(struct nfs_context *nfs, const char *path,
|
|
|
|
int no_follow, int uid, int gid,
|
|
|
|
nfs_cb cb, void *private_data);
|
|
|
|
int nfs3_close_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb,
|
|
|
|
void *private_data);
|
|
|
|
int nfs3_create_async(struct nfs_context *nfs, const char *path, int flags,
|
|
|
|
int mode, nfs_cb cb, void *private_data);
|
|
|
|
int nfs3_fchmod_async(struct nfs_context *nfs, struct nfsfh *nfsfh, int mode,
|
|
|
|
nfs_cb cb, void *private_data);
|
|
|
|
int nfs3_fchown_async(struct nfs_context *nfs, struct nfsfh *nfsfh, int uid,
|
|
|
|
int gid, nfs_cb cb, void *private_data);
|
|
|
|
int nfs3_fstat_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb,
|
|
|
|
void *private_data);
|
|
|
|
int nfs3_fstat64_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb,
|
|
|
|
void *private_data);
|
|
|
|
int nfs3_fsync_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb,
|
|
|
|
void *private_data);
|
|
|
|
int nfs3_ftruncate_async(struct nfs_context *nfs, struct nfsfh *nfsfh,
|
|
|
|
uint64_t length, nfs_cb cb, void *private_data);
|
|
|
|
int nfs3_link_async(struct nfs_context *nfs, const char *oldpath,
|
|
|
|
const char *newpath, nfs_cb cb, void *private_data);
|
|
|
|
int nfs3_lseek_async(struct nfs_context *nfs, struct nfsfh *nfsfh,
|
|
|
|
int64_t offset, int whence, nfs_cb cb, void *private_data);
|
|
|
|
int nfs3_mkdir2_async(struct nfs_context *nfs, const char *path, int mode,
|
|
|
|
nfs_cb cb, void *private_data);
|
|
|
|
int nfs3_mknod_async(struct nfs_context *nfs, const char *path, int mode,
|
|
|
|
int dev, nfs_cb cb, void *private_data);
|
|
|
|
int nfs3_mount_async(struct nfs_context *nfs, const char *server,
|
|
|
|
const char *export, nfs_cb cb, void *private_data);
|
|
|
|
int nfs3_open_async(struct nfs_context *nfs, const char *path, int flags,
|
2017-08-06 09:02:39 +03:00
|
|
|
int mode, nfs_cb cb, void *private_data);
|
2017-06-27 23:31:44 +03:00
|
|
|
int nfs3_opendir_async(struct nfs_context *nfs, const char *path, nfs_cb cb,
|
|
|
|
void *private_data);
|
|
|
|
int nfs3_pread_async_internal(struct nfs_context *nfs, struct nfsfh *nfsfh,
|
|
|
|
uint64_t offset, size_t count, nfs_cb cb,
|
|
|
|
void *private_data, int update_pos);
|
|
|
|
int nfs3_pwrite_async_internal(struct nfs_context *nfs, struct nfsfh *nfsfh,
|
|
|
|
uint64_t offset, size_t count, const char *buf,
|
|
|
|
nfs_cb cb, void *private_data, int update_pos);
|
|
|
|
int nfs3_readlink_async(struct nfs_context *nfs, const char *path, nfs_cb cb,
|
|
|
|
void *private_data);
|
|
|
|
int nfs3_rename_async(struct nfs_context *nfs, const char *oldpath,
|
|
|
|
const char *newpath, nfs_cb cb, void *private_data);
|
|
|
|
int nfs3_rmdir_async(struct nfs_context *nfs, const char *path, nfs_cb cb,
|
|
|
|
void *private_data);
|
|
|
|
int nfs3_stat_async(struct nfs_context *nfs, const char *path,
|
|
|
|
nfs_cb cb, void *private_data);
|
2017-07-08 00:41:11 +03:00
|
|
|
int nfs3_stat64_async(struct nfs_context *nfs, const char *path,
|
|
|
|
int no_follow, nfs_cb cb, void *private_data);
|
2017-06-27 23:31:44 +03:00
|
|
|
int nfs3_statvfs_async(struct nfs_context *nfs, const char *path, nfs_cb cb,
|
|
|
|
void *private_data);
|
2018-12-26 06:33:38 +03:00
|
|
|
int nfs3_statvfs64_async(struct nfs_context *nfs, const char *path, nfs_cb cb,
|
|
|
|
void *private_data);
|
2017-06-27 23:31:44 +03:00
|
|
|
int nfs3_symlink_async(struct nfs_context *nfs, const char *oldpath,
|
|
|
|
const char *newpath, nfs_cb cb, void *private_data);
|
|
|
|
int nfs3_truncate_async(struct nfs_context *nfs, const char *path,
|
|
|
|
uint64_t length, nfs_cb cb, void *private_data);
|
2018-12-29 06:56:29 +03:00
|
|
|
int nfs3_umount_async(struct nfs_context *nfs, nfs_cb cb, void *private_data);
|
2017-06-27 23:31:44 +03:00
|
|
|
int nfs3_unlink_async(struct nfs_context *nfs, const char *path, nfs_cb cb,
|
|
|
|
void *private_data);
|
|
|
|
int nfs3_utime_async(struct nfs_context *nfs, const char *path,
|
|
|
|
struct utimbuf *times, nfs_cb cb, void *private_data);
|
|
|
|
int nfs3_utimes_async_internal(struct nfs_context *nfs, const char *path,
|
|
|
|
int no_follow, struct timeval *times,
|
|
|
|
nfs_cb cb, void *private_data);
|
|
|
|
int nfs3_write_async(struct nfs_context *nfs, struct nfsfh *nfsfh,
|
|
|
|
uint64_t count, const void *buf, nfs_cb cb,
|
|
|
|
void *private_data);
|
2017-07-06 00:15:51 +03:00
|
|
|
|
2017-09-02 22:43:04 +03:00
|
|
|
int nfs4_access_async(struct nfs_context *nfs, const char *path, int mode,
|
|
|
|
nfs_cb cb, void *private_data);
|
|
|
|
int nfs4_access2_async(struct nfs_context *nfs, const char *path, nfs_cb cb,
|
|
|
|
void *private_data);
|
2017-07-10 13:09:07 +03:00
|
|
|
int nfs4_chdir_async(struct nfs_context *nfs, const char *path,
|
|
|
|
nfs_cb cb, void *private_data);
|
2017-09-01 07:02:43 +03:00
|
|
|
int nfs4_chmod_async_internal(struct nfs_context *nfs, const char *path,
|
|
|
|
int no_follow, int mode, nfs_cb cb,
|
|
|
|
void *private_data);
|
2017-09-01 23:42:59 +03:00
|
|
|
int nfs4_chown_async_internal(struct nfs_context *nfs, const char *path,
|
|
|
|
int no_follow, int uid, int gid,
|
|
|
|
nfs_cb cb, void *private_data);
|
2017-07-16 00:46:38 +03:00
|
|
|
int nfs4_close_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb,
|
|
|
|
void *private_data);
|
2017-08-06 12:15:04 +03:00
|
|
|
int nfs4_create_async(struct nfs_context *nfs, const char *path, int flags,
|
|
|
|
int mode, nfs_cb cb, void *private_data);
|
2017-09-01 07:02:43 +03:00
|
|
|
int nfs4_fchmod_async(struct nfs_context *nfs, struct nfsfh *nfsfh, int mode,
|
|
|
|
nfs_cb cb, void *private_data);
|
2017-09-01 23:42:59 +03:00
|
|
|
int nfs4_fchown_async(struct nfs_context *nfs, struct nfsfh *nfsfh, int uid,
|
|
|
|
int gid, nfs_cb cb, void *private_data);
|
2018-01-08 07:37:55 +03:00
|
|
|
int nfs4_fcntl_async(struct nfs_context *nfs, struct nfsfh *nfsfh,
|
|
|
|
enum nfs4_fcntl_op cmd, void *arg,
|
|
|
|
nfs_cb cb, void *private_data);
|
2017-07-16 00:46:38 +03:00
|
|
|
int nfs4_fstat64_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb,
|
|
|
|
void *private_data);
|
2017-08-25 18:07:22 +03:00
|
|
|
int nfs4_fsync_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb,
|
|
|
|
void *private_data);
|
2017-08-25 18:31:25 +03:00
|
|
|
int nfs4_ftruncate_async(struct nfs_context *nfs, struct nfsfh *nfsfh,
|
|
|
|
uint64_t length, nfs_cb cb, void *private_data);
|
2017-08-08 13:47:22 +03:00
|
|
|
int nfs4_link_async(struct nfs_context *nfs, const char *oldpath,
|
|
|
|
const char *newpath, nfs_cb cb, void *private_data);
|
2017-08-26 01:05:12 +03:00
|
|
|
int nfs4_lseek_async(struct nfs_context *nfs, struct nfsfh *nfsfh,
|
|
|
|
int64_t offset, int whence, nfs_cb cb, void *private_data);
|
2018-01-07 01:35:42 +03:00
|
|
|
int nfs4_lockf_async(struct nfs_context *nfs, struct nfsfh *nfsfh,
|
|
|
|
enum nfs4_lock_op op, uint64_t count,
|
|
|
|
nfs_cb cb, void *private_data);
|
2017-07-13 16:04:35 +03:00
|
|
|
int nfs4_mkdir2_async(struct nfs_context *nfs, const char *path, int mode,
|
|
|
|
nfs_cb cb, void *private_data);
|
2017-08-15 13:05:47 +03:00
|
|
|
int nfs4_mknod_async(struct nfs_context *nfs, const char *path, int mode,
|
|
|
|
int dev, nfs_cb cb, void *private_data);
|
2017-07-06 00:15:51 +03:00
|
|
|
int nfs4_mount_async(struct nfs_context *nfs, const char *server,
|
|
|
|
const char *export, nfs_cb cb, void *private_data);
|
2017-07-16 00:46:38 +03:00
|
|
|
int nfs4_open_async(struct nfs_context *nfs, const char *path, int flags,
|
2017-08-06 09:02:39 +03:00
|
|
|
int mode, nfs_cb cb, void *private_data);
|
2017-08-20 02:08:46 +03:00
|
|
|
int nfs4_opendir_async(struct nfs_context *nfs, const char *path, nfs_cb cb,
|
|
|
|
void *private_data);
|
2017-07-26 02:22:40 +03:00
|
|
|
int nfs4_pread_async_internal(struct nfs_context *nfs, struct nfsfh *nfsfh,
|
|
|
|
uint64_t offset, size_t count, nfs_cb cb,
|
|
|
|
void *private_data, int update_pos);
|
2017-07-29 12:51:24 +03:00
|
|
|
int nfs4_pwrite_async_internal(struct nfs_context *nfs, struct nfsfh *nfsfh,
|
|
|
|
uint64_t offset, size_t count, const char *buf,
|
|
|
|
nfs_cb cb, void *private_data, int update_pos);
|
2017-07-26 05:14:04 +03:00
|
|
|
int nfs4_readlink_async(struct nfs_context *nfs, const char *path, nfs_cb cb,
|
|
|
|
void *private_data);
|
2017-08-14 02:01:23 +03:00
|
|
|
int nfs4_rename_async(struct nfs_context *nfs, const char *oldpath,
|
|
|
|
const char *newpath, nfs_cb cb, void *private_data);
|
2017-07-14 00:04:28 +03:00
|
|
|
int nfs4_rmdir_async(struct nfs_context *nfs, const char *path, nfs_cb cb,
|
|
|
|
void *private_data);
|
2017-07-08 00:41:11 +03:00
|
|
|
int nfs4_stat64_async(struct nfs_context *nfs, const char *path,
|
|
|
|
int no_follow, nfs_cb cb, void *private_data);
|
2017-08-27 00:56:19 +03:00
|
|
|
int nfs4_statvfs_async(struct nfs_context *nfs, const char *path, nfs_cb cb,
|
|
|
|
void *private_data);
|
2018-12-26 06:33:38 +03:00
|
|
|
int nfs4_statvfs64_async(struct nfs_context *nfs, const char *path, nfs_cb cb,
|
|
|
|
void *private_data);
|
2017-07-26 04:36:52 +03:00
|
|
|
int nfs4_symlink_async(struct nfs_context *nfs, const char *oldpath,
|
|
|
|
const char *newpath, nfs_cb cb, void *private_data);
|
2017-08-25 03:13:00 +03:00
|
|
|
int nfs4_truncate_async(struct nfs_context *nfs, const char *path,
|
|
|
|
uint64_t length, nfs_cb cb, void *private_data);
|
2017-08-06 12:24:05 +03:00
|
|
|
int nfs4_unlink_async(struct nfs_context *nfs, const char *path, nfs_cb cb,
|
|
|
|
void *private_data);
|
2018-01-10 10:09:14 +03:00
|
|
|
int nfs4_utime_async(struct nfs_context *nfs, const char *path,
|
|
|
|
struct utimbuf *times, nfs_cb cb, void *private_data);
|
2017-09-02 23:25:55 +03:00
|
|
|
int nfs4_utimes_async_internal(struct nfs_context *nfs, const char *path,
|
|
|
|
int no_follow, struct timeval *times,
|
|
|
|
nfs_cb cb, void *private_data);
|
2017-08-03 13:23:08 +03:00
|
|
|
int nfs4_write_async(struct nfs_context *nfs, struct nfsfh *nfsfh,
|
|
|
|
uint64_t count, const void *buf, nfs_cb cb,
|
|
|
|
void *private_data);
|
2017-07-08 00:41:11 +03:00
|
|
|
|
2014-02-14 01:27:57 +04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-02-14 01:19:51 +04:00
|
|
|
#endif /* !_LIBNFS_PRIVATE_H_ */
|