linux/net/9p/client.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * 9P Client
 *
 *  Copyright (C) 2008 by Eric Van Hensbergen <[email protected]>
 *  Copyright (C) 2007 by Latchesar Ionkov <[email protected]>
 */

#define pr_fmt(fmt)

#include <linux/module.h>
#include <linux/errno.h>
#include <linux/fs.h>
#include <linux/poll.h>
#include <linux/idr.h>
#include <linux/mutex.h>
#include <linux/slab.h>
#include <linux/sched/signal.h>
#include <linux/uaccess.h>
#include <linux/uio.h>
#include <linux/netfs.h>
#include <net/9p/9p.h>
#include <linux/parser.h>
#include <linux/seq_file.h>
#include <net/9p/client.h>
#include <net/9p/transport.h>
#include "protocol.h"

#define CREATE_TRACE_POINTS
#include <trace/events/9p.h>

/* DEFAULT MSIZE = 32 pages worth of payload + P9_HDRSZ +
 * room for write (16 extra) or read (11 extra) operands.
 */

#define DEFAULT_MSIZE

/* Client Option Parsing (code inspired by NFS code)
 *  - a little lazy - parse all client options
 */

enum {};

static const match_table_t tokens =;

inline int p9_is_proto_dotl(struct p9_client *clnt)
{}
EXPORT_SYMBOL();

inline int p9_is_proto_dotu(struct p9_client *clnt)
{}
EXPORT_SYMBOL();

int p9_show_client_options(struct seq_file *m, struct p9_client *clnt)
{}
EXPORT_SYMBOL();

/* Some error codes are taken directly from the server replies,
 * make sure they are valid.
 */
static int safe_errno(int err)
{}

/* Interpret mount option for protocol version */
static int get_protocol_version(char *s)
{}

/**
 * parse_opts - parse mount options into client structure
 * @opts: options string passed from mount
 * @clnt: existing v9fs client information
 *
 * Return 0 upon success, -ERRNO upon failure
 */

static int parse_opts(char *opts, struct p9_client *clnt)
{}

static int p9_fcall_init(struct p9_client *c, struct p9_fcall *fc,
			 int alloc_msize)
{}

void p9_fcall_fini(struct p9_fcall *fc)
{}
EXPORT_SYMBOL();

static struct kmem_cache *p9_req_cache;

/**
 * p9_tag_alloc - Allocate a new request.
 * @c: Client session.
 * @type: Transaction type.
 * @t_size: Buffer size for holding this request
 * (automatic calculation by format template if 0).
 * @r_size: Buffer size for holding server's reply on this request
 * (automatic calculation by format template if 0).
 * @fmt: Format template for assembling 9p request message
 * (see p9pdu_vwritef).
 * @ap: Variable arguments to be fed to passed format template
 * (see p9pdu_vwritef).
 *
 * Context: Process context.
 * Return: Pointer to new request.
 */
static struct p9_req_t *
p9_tag_alloc(struct p9_client *c, int8_t type, uint t_size, uint r_size,
	      const char *fmt, va_list ap)
{}

/**
 * p9_tag_lookup - Look up a request by tag.
 * @c: Client session.
 * @tag: Transaction ID.
 *
 * Context: Any context.
 * Return: A request, or %NULL if there is no request with that tag.
 */
struct p9_req_t *p9_tag_lookup(struct p9_client *c, u16 tag)
{}
EXPORT_SYMBOL();

/**
 * p9_tag_remove - Remove a tag.
 * @c: Client session.
 * @r: Request of reference.
 *
 * Context: Any context.
 */
static void p9_tag_remove(struct p9_client *c, struct p9_req_t *r)
{}

int p9_req_put(struct p9_client *c, struct p9_req_t *r)
{}
EXPORT_SYMBOL();

/**
 * p9_tag_cleanup - cleans up tags structure and reclaims resources
 * @c:  v9fs client struct
 *
 * This frees resources associated with the tags structure
 *
 */
static void p9_tag_cleanup(struct p9_client *c)
{}

/**
 * p9_client_cb - call back from transport to client
 * @c: client state
 * @req: request received
 * @status: request status, one of REQ_STATUS_*
 *
 */
void p9_client_cb(struct p9_client *c, struct p9_req_t *req, int status)
{}
EXPORT_SYMBOL();

/**
 * p9_parse_header - parse header arguments out of a packet
 * @pdu: packet to parse
 * @size: size of packet
 * @type: type of request
 * @tag: tag of packet
 * @rewind: set if we need to rewind offset afterwards
 */

int
p9_parse_header(struct p9_fcall *pdu, int32_t *size, int8_t *type,
		int16_t *tag, int rewind)
{}
EXPORT_SYMBOL();

/**
 * p9_check_errors - check 9p packet for error return and process it
 * @c: current client instance
 * @req: request to parse and check for error conditions
 *
 * returns error code if one is discovered, otherwise returns 0
 *
 * this will have to be more complicated if we have multiple
 * error packet types
 */

static int p9_check_errors(struct p9_client *c, struct p9_req_t *req)
{}

static struct p9_req_t *
p9_client_rpc(struct p9_client *c, int8_t type, const char *fmt, ...);

/**
 * p9_client_flush - flush (cancel) a request
 * @c: client state
 * @oldreq: request to cancel
 *
 * This sents a flush for a particular request and links
 * the flush request to the original request.  The current
 * code only supports a single flush request although the protocol
 * allows for multiple flush requests to be sent for a single request.
 *
 */

static int p9_client_flush(struct p9_client *c, struct p9_req_t *oldreq)
{}

static struct p9_req_t *p9_client_prepare_req(struct p9_client *c,
					      int8_t type, uint t_size, uint r_size,
					      const char *fmt, va_list ap)
{}

/**
 * p9_client_rpc - issue a request and wait for a response
 * @c: client session
 * @type: type of request
 * @fmt: protocol format string (see protocol.c)
 *
 * Returns request structure (which client must free using p9_req_put)
 */

static struct p9_req_t *
p9_client_rpc(struct p9_client *c, int8_t type, const char *fmt, ...)
{}

/**
 * p9_client_zc_rpc - issue a request and wait for a response
 * @c: client session
 * @type: type of request
 * @uidata: destination for zero copy read
 * @uodata: source for zero copy write
 * @inlen: read buffer size
 * @olen: write buffer size
 * @in_hdrlen: reader header size, This is the size of response protocol data
 * @fmt: protocol format string (see protocol.c)
 *
 * Returns request structure (which client must free using p9_req_put)
 */
static struct p9_req_t *p9_client_zc_rpc(struct p9_client *c, int8_t type,
					 struct iov_iter *uidata,
					 struct iov_iter *uodata,
					 int inlen, int olen, int in_hdrlen,
					 const char *fmt, ...)
{}

static struct p9_fid *p9_fid_create(struct p9_client *clnt)
{}

static void p9_fid_destroy(struct p9_fid *fid)
{}

/* We also need to export tracepoint symbols for tracepoint_enabled() */
EXPORT_TRACEPOINT_SYMBOL();

void do_trace_9p_fid_get(struct p9_fid *fid)
{}
EXPORT_SYMBOL();

void do_trace_9p_fid_put(struct p9_fid *fid)
{}
EXPORT_SYMBOL();

static int p9_client_version(struct p9_client *c)
{}

struct p9_client *p9_client_create(const char *dev_name, char *options)
{}
EXPORT_SYMBOL();

void p9_client_destroy(struct p9_client *clnt)
{}
EXPORT_SYMBOL();

void p9_client_disconnect(struct p9_client *clnt)
{}
EXPORT_SYMBOL();

void p9_client_begin_disconnect(struct p9_client *clnt)
{}
EXPORT_SYMBOL();

struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid,
				const char *uname, kuid_t n_uname,
				const char *aname)
{}
EXPORT_SYMBOL();

struct p9_fid *p9_client_walk(struct p9_fid *oldfid, uint16_t nwname,
			      const unsigned char * const *wnames, int clone)
{}
EXPORT_SYMBOL();

int p9_client_open(struct p9_fid *fid, int mode)
{}
EXPORT_SYMBOL();

int p9_client_create_dotl(struct p9_fid *ofid, const char *name, u32 flags,
			  u32 mode, kgid_t gid, struct p9_qid *qid)
{}
EXPORT_SYMBOL();

int p9_client_fcreate(struct p9_fid *fid, const char *name, u32 perm, int mode,
		     char *extension)
{}
EXPORT_SYMBOL();

int p9_client_symlink(struct p9_fid *dfid, const char *name,
		      const char *symtgt, kgid_t gid, struct p9_qid *qid)
{}
EXPORT_SYMBOL();

int p9_client_link(struct p9_fid *dfid, struct p9_fid *oldfid, const char *newname)
{}
EXPORT_SYMBOL();

int p9_client_fsync(struct p9_fid *fid, int datasync)
{}
EXPORT_SYMBOL();

int p9_client_clunk(struct p9_fid *fid)
{}
EXPORT_SYMBOL();

int p9_client_remove(struct p9_fid *fid)
{}
EXPORT_SYMBOL();

int p9_client_unlinkat(struct p9_fid *dfid, const char *name, int flags)
{}
EXPORT_SYMBOL();

int
p9_client_read(struct p9_fid *fid, u64 offset, struct iov_iter *to, int *err)
{}
EXPORT_SYMBOL();

int
p9_client_read_once(struct p9_fid *fid, u64 offset, struct iov_iter *to,
		    int *err)
{}
EXPORT_SYMBOL();

int
p9_client_write(struct p9_fid *fid, u64 offset, struct iov_iter *from, int *err)
{}
EXPORT_SYMBOL();

void
p9_client_write_subreq(struct netfs_io_subrequest *subreq)
{}
EXPORT_SYMBOL();

struct p9_wstat *p9_client_stat(struct p9_fid *fid)
{}
EXPORT_SYMBOL();

struct p9_stat_dotl *p9_client_getattr_dotl(struct p9_fid *fid,
					    u64 request_mask)
{}
EXPORT_SYMBOL();

static int p9_client_statsize(struct p9_wstat *wst, int proto_version)
{}

int p9_client_wstat(struct p9_fid *fid, struct p9_wstat *wst)
{}
EXPORT_SYMBOL();

int p9_client_setattr(struct p9_fid *fid, struct p9_iattr_dotl *p9attr)
{}
EXPORT_SYMBOL();

int p9_client_statfs(struct p9_fid *fid, struct p9_rstatfs *sb)
{}
EXPORT_SYMBOL();

int p9_client_rename(struct p9_fid *fid,
		     struct p9_fid *newdirfid, const char *name)
{}
EXPORT_SYMBOL();

int p9_client_renameat(struct p9_fid *olddirfid, const char *old_name,
		       struct p9_fid *newdirfid, const char *new_name)
{}
EXPORT_SYMBOL();

/* An xattrwalk without @attr_name gives the fid for the lisxattr namespace
 */
struct p9_fid *p9_client_xattrwalk(struct p9_fid *file_fid,
				   const char *attr_name, u64 *attr_size)
{}
EXPORT_SYMBOL_GPL();

int p9_client_xattrcreate(struct p9_fid *fid, const char *name,
			  u64 attr_size, int flags)
{}
EXPORT_SYMBOL_GPL();

int p9_client_readdir(struct p9_fid *fid, char *data, u32 count, u64 offset)
{}
EXPORT_SYMBOL();

int p9_client_mknod_dotl(struct p9_fid *fid, const char *name, int mode,
			 dev_t rdev, kgid_t gid, struct p9_qid *qid)
{}
EXPORT_SYMBOL();

int p9_client_mkdir_dotl(struct p9_fid *fid, const char *name, int mode,
			 kgid_t gid, struct p9_qid *qid)
{}
EXPORT_SYMBOL();

int p9_client_lock_dotl(struct p9_fid *fid, struct p9_flock *flock, u8 *status)
{}
EXPORT_SYMBOL();

int p9_client_getlock_dotl(struct p9_fid *fid, struct p9_getlock *glock)
{}
EXPORT_SYMBOL();

int p9_client_readlink(struct p9_fid *fid, char **target)
{}
EXPORT_SYMBOL();

int __init p9_client_init(void)
{}

void __exit p9_client_exit(void)
{}