ReactOS  0.4.12-dev-102-g4b7f1e0
mount.c File Reference
#include <windows.h>
#include <strsafe.h>
#include <stdio.h>
#include "daemon_debug.h"
#include "nfs41_ops.h"
#include "upcall.h"
#include "util.h"
Include dependency graph for mount.c:

Go to the source code of this file.

Functions

static int parse_mount (unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
 
static int handle_mount (nfs41_upcall *upcall)
 
static int marshall_mount (unsigned char *buffer, uint32_t *length, nfs41_upcall *upcall)
 
static void cancel_mount (IN nfs41_upcall *upcall)
 
static int parse_unmount (unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
 
static int handle_unmount (nfs41_upcall *upcall)
 

Variables

const nfs41_upcall_op nfs41_op_mount
 
const nfs41_upcall_op nfs41_op_unmount
 

Function Documentation

◆ cancel_mount()

static void cancel_mount ( IN nfs41_upcall upcall)
static

Definition at line 145 of file mount.c.

146 {
147  if (upcall->root_ref != INVALID_HANDLE_VALUE)
148  nfs41_root_deref(upcall->root_ref);
149 }
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
nfs41_updowncall_list upcall
Definition: nfs41_driver.c:273
void nfs41_root_deref(IN nfs41_root *root)
Definition: namespace.c:100

◆ handle_mount()

static int handle_mount ( nfs41_upcall upcall)
static

Definition at line 56 of file mount.c.

57 {
58  int status;
59  mount_upcall_args *args = &upcall->args.mount;
61  multi_addr4 addrs;
65 
66  // resolve hostname,port
67  status = nfs41_server_resolve(args->hostname, 2049, &addrs);
68  if (status) {
69  eprintf("nfs41_server_resolve() failed with %d\n", status);
70  goto out;
71  }
72 
73  if (upcall->root_ref != INVALID_HANDLE_VALUE) {
74  /* use an existing root from a previous mount, but don't take an
75  * extra reference; we'll only get one UNMOUNT upcall for each root */
76  root = upcall->root_ref;
77  } else {
78  // create root
79  status = nfs41_root_create(args->hostname, args->sec_flavor,
80  args->wsize + WRITE_OVERHEAD, args->rsize + READ_OVERHEAD, &root);
81  if (status) {
82  eprintf("nfs41_root_create() failed %d\n", status);
83  goto out;
84  }
85  root->uid = upcall->uid;
86  root->gid = upcall->gid;
87  }
88 
89  // find or create the client/session
90  status = nfs41_root_mount_addrs(root, &addrs, 0, 0, &client);
91  if (status) {
92  eprintf("nfs41_root_mount_addrs() failed with %d\n", status);
93  goto out_err;
94  }
95 
96  // make a copy of the path for nfs41_lookup()
97  InitializeSRWLock(&path.lock);
98  if (FAILED(StringCchCopyA(path.path, NFS41_MAX_PATH_LEN, args->path))) {
100  goto out_err;
101  }
102  path.len = (unsigned short)strlen(path.path);
103 
104  // look up the mount path, and fail if it doesn't exist
105  status = nfs41_lookup(root, client->session,
106  &path, NULL, &file, NULL, NULL);
107  if (status) {
108  eprintf("nfs41_lookup('%s') failed with %d\n", path.path, status);
109  status = ERROR_BAD_NETPATH;
110  goto out_err;
111  }
112 
114 
115  if (upcall->root_ref == INVALID_HANDLE_VALUE)
116  nfs41_root_ref(root);
117  upcall->root_ref = root;
118  args->lease_time = client->session->lease_time;
119 out:
120  return status;
121 
122 out_err:
123  if (upcall->root_ref == INVALID_HANDLE_VALUE)
124  nfs41_root_deref(root);
125  goto out;
126 }
uid_t uid
Definition: upcall.h:200
struct __nfs41_superblock * superblock
Definition: nfs41_types.h:56
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLsizei const GLchar ** path
Definition: glext.h:7234
struct _root root
const char * path
Definition: upcall.h:33
DWORD lease_time
Definition: upcall.h:37
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
int nfs41_lookup(IN nfs41_root *root, IN nfs41_session *session, IN OUT nfs41_abs_path *path_inout, OUT OPTIONAL nfs41_path_fh *parent_out, OUT OPTIONAL nfs41_path_fh *target_out, OUT OPTIONAL nfs41_file_info *info_out, OUT nfs41_session **session_out)
Definition: lookup.c:424
void eprintf(LPCSTR format,...)
Definition: daemon_debug.c:86
uint32_t uid
Definition: nfs41.h:281
Definition: match.c:390
#define ERROR_BAD_NETPATH
Definition: winerror.h:145
#define NFS41_MAX_PATH_LEN
Definition: nfs41_const.h:46
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:91
nfs41_root * root_ref
Definition: upcall.h:206
DWORD sec_flavor
Definition: upcall.h:34
int nfs41_root_mount_addrs(IN nfs41_root *root, IN const multi_addr4 *addrs, IN bool_t is_data, IN OPTIONAL uint32_t lease_time, OUT nfs41_client **client_out)
Definition: namespace.c:335
smooth NULL
Definition: ftsmooth.c:416
#define WRITE_OVERHEAD
Definition: nfs41_const.h:75
void nfs41_root_ref(IN nfs41_root *root)
Definition: namespace.c:92
int nfs41_server_resolve(IN const char *hostname, IN unsigned short port, OUT multi_addr4 *addrs)
Definition: nfs41_server.c:275
upcall_args args
Definition: upcall.h:198
unsigned short len
Definition: nfs41_types.h:43
const char file[]
Definition: icontest.c:11
static FILE * client
Definition: client.c:41
static FILE * out
Definition: regtests2xml.c:44
FILE_FS_ATTRIBUTE_INFORMATION FsAttrs
Definition: upcall.h:38
#define READ_OVERHEAD
Definition: nfs41_const.h:68
VOID WINAPI InitializeSRWLock(PSRWLOCK Lock)
Definition: sync.c:75
const char * hostname
Definition: upcall.h:32
gid_t gid
Definition: upcall.h:201
STRSAFEAPI StringCchCopyA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:145
mount_upcall_args mount
Definition: upcall.h:176
int nfs41_root_create(IN const char *name, IN uint32_t sec_flavor, IN uint32_t wsize, IN uint32_t rsize, OUT nfs41_root **root_out)
Definition: namespace.c:37
void nfs41_root_deref(IN nfs41_root *root)
Definition: namespace.c:100
void nfs41_superblock_fs_attributes(IN const nfs41_superblock *superblock, OUT struct _FILE_FS_ATTRIBUTE_INFORMATION *FsAttrs)
uint32_t gid
Definition: nfs41.h:282
char path[NFS41_MAX_PATH_LEN]
Definition: nfs41_types.h:42
static SERVICE_STATUS status
Definition: service.c:31
struct __nfs41_session * session
Definition: nfs41.h:199
#define ERROR_FILENAME_EXCED_RANGE
Definition: winerror.h:263

◆ handle_unmount()

static int handle_unmount ( nfs41_upcall upcall)
static

Definition at line 166 of file mount.c.

167 {
168  /* release the original reference from nfs41_root_create() */
169  nfs41_root_deref(upcall->root_ref);
170  return ERROR_SUCCESS;
171 }
#define ERROR_SUCCESS
Definition: deptool.c:10
nfs41_root * root_ref
Definition: upcall.h:206
void nfs41_root_deref(IN nfs41_root *root)
Definition: namespace.c:100

◆ marshall_mount()

static int marshall_mount ( unsigned char buffer,
uint32_t length,
nfs41_upcall upcall 
)
static

Definition at line 128 of file mount.c.

129 {
130  mount_upcall_args *args = &upcall->args.mount;
131  int status;
132  dprintf(2, "NFS41_MOUNT: writing pointer to nfs41_root %p, version %d, "
133  "lease_time %d\n", upcall->root_ref, NFS41D_VERSION, args->lease_time);
134  status = safe_write(&buffer, length, &upcall->root_ref, sizeof(HANDLE));
135  if (status) goto out;
136  status = safe_write(&buffer, length, &NFS41D_VERSION, sizeof(DWORD));
137  if (status) goto out;
138  status = safe_write(&buffer, length, &args->lease_time, sizeof(DWORD));
139  if (status) goto out;
140  status = safe_write(&buffer, length, &args->FsAttrs, sizeof(args->FsAttrs));
141 out:
142  return status;
143 }
DWORD lease_time
Definition: upcall.h:37
GLuint buffer
Definition: glext.h:5915
Definition: match.c:390
nfs41_root * root_ref
Definition: upcall.h:206
#define dprintf
Definition: regdump.c:33
DWORD NFS41D_VERSION
Definition: nfs41_daemon.c:42
upcall_args args
Definition: upcall.h:198
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
static FILE * out
Definition: regtests2xml.c:44
FILE_FS_ATTRIBUTE_INFORMATION FsAttrs
Definition: upcall.h:38
unsigned long DWORD
Definition: ntddk_ex.h:95
int safe_write(unsigned char **pos, uint32_t *remaining, void *src, uint32_t src_len)
Definition: util.c:44
mount_upcall_args mount
Definition: upcall.h:176
static SERVICE_STATUS status
Definition: service.c:31

◆ parse_mount()

static int parse_mount ( unsigned char buffer,
uint32_t  length,
nfs41_upcall upcall 
)
static

Definition at line 33 of file mount.c.

34 {
35  int status;
36  mount_upcall_args *args = &upcall->args.mount;
37 
38  status = get_name(&buffer, &length, &args->hostname);
39  if(status) goto out;
40  status = get_name(&buffer, &length, &args->path);
41  if(status) goto out;
42  status = safe_read(&buffer, &length, &args->sec_flavor, sizeof(DWORD));
43  if (status) goto out;
44  status = safe_read(&buffer, &length, &args->rsize, sizeof(DWORD));
45  if (status) goto out;
46  status = safe_read(&buffer, &length, &args->wsize, sizeof(DWORD));
47  if (status) goto out;
48 
49  dprintf(1, "parsing NFS14_MOUNT: srv_name=%s root=%s sec_flavor=%s "
50  "rsize=%d wsize=%d\n", args->hostname, args->path,
51  secflavorop2name(args->sec_flavor), args->rsize, args->wsize);
52 out:
53  return status;
54 }
const char * path
Definition: upcall.h:33
GLuint buffer
Definition: glext.h:5915
Definition: match.c:390
DWORD sec_flavor
Definition: upcall.h:34
#define dprintf
Definition: regdump.c:33
int get_name(unsigned char **pos, uint32_t *remaining, const char **out_name)
Definition: util.c:55
upcall_args args
Definition: upcall.h:198
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
static FILE * out
Definition: regtests2xml.c:44
unsigned long DWORD
Definition: ntddk_ex.h:95
const char * secflavorop2name(DWORD sec_flavor)
Definition: daemon_debug.c:558
const char * hostname
Definition: upcall.h:32
mount_upcall_args mount
Definition: upcall.h:176
int safe_read(unsigned char **pos, uint32_t *remaining, void *dest, uint32_t dest_len)
Definition: util.c:33
static SERVICE_STATUS status
Definition: service.c:31

◆ parse_unmount()

static int parse_unmount ( unsigned char buffer,
uint32_t  length,
nfs41_upcall upcall 
)
static

Definition at line 160 of file mount.c.

161 {
162  dprintf(1, "parsing NFS41_UNMOUNT: root=%p\n", upcall->root_ref);
163  return ERROR_SUCCESS;
164 }
#define ERROR_SUCCESS
Definition: deptool.c:10
nfs41_root * root_ref
Definition: upcall.h:206
#define dprintf
Definition: regdump.c:33

Variable Documentation

◆ nfs41_op_mount

const nfs41_upcall_op nfs41_op_mount
Initial value:
= {
}
static int handle_mount(nfs41_upcall *upcall)
Definition: mount.c:56
static int marshall_mount(unsigned char *buffer, uint32_t *length, nfs41_upcall *upcall)
Definition: mount.c:128
static void cancel_mount(IN nfs41_upcall *upcall)
Definition: mount.c:145
static int parse_mount(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
Definition: mount.c:33

Definition at line 151 of file mount.c.

◆ nfs41_op_unmount

const nfs41_upcall_op nfs41_op_unmount
Initial value:
= {
}
static int handle_unmount(nfs41_upcall *upcall)
Definition: mount.c:166
static int parse_unmount(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
Definition: mount.c:160

Definition at line 173 of file mount.c.