static int export_id = 0;
static int mount_id = 0;
-void dispatch_response(struct mount *mount, int priv_req_id)
+static void dispatch_response(struct fs_mount *mount, int priv_req_id)
{
int i;
struct fs_op *op;
add_id_to_freelist(priv_req_id, mount->freelist);
}
-static void handle_aio_events(struct mount *mount)
+static void handle_aio_events(struct fs_mount *mount)
{
int fd, ret, count, i, notify;
evtchn_port_t port;
}
-void allocate_request_array(struct mount *mount)
+static void allocate_request_array(struct fs_mount *mount)
{
int i, nr_entries = mount->nr_entries;
struct fs_request *requests;
}
-void* handle_mount(void *data)
+static void *handle_mount(void *data)
{
int more, notify;
- struct mount *mount = (struct mount *)data;
+ struct fs_mount *mount = (struct fs_mount *)data;
printf("Starting a thread for mount: %d\n", mount->mount_id);
allocate_request_array(mount);
static void handle_connection(int frontend_dom_id, int export_id, char *frontend)
{
- struct mount *mount;
+ struct fs_mount *mount;
struct fs_export *export;
int evt_port;
pthread_t handling_thread;
return;
}
- mount = (struct mount*)malloc(sizeof(struct mount));
+ mount = (struct fs_mount*)malloc(sizeof(struct fs_mount));
mount->dom_id = frontend_dom_id;
mount->export = export;
mount->mount_id = mount_id++;
} while (1);
}
-struct fs_export* create_export(char *name, char *export_path)
+static struct fs_export* create_export(char *name, char *export_path)
{
struct fs_export *curr_export, **last_export;
};
-struct mount
+struct fs_mount
{
struct fs_export *export;
int dom_id;
bool xenbus_create_request_node(void);
int xenbus_register_export(struct fs_export *export);
int xenbus_get_watch_fd(void);
-void xenbus_read_mount_request(struct mount *mount, char *frontend);
-void xenbus_write_backend_node(struct mount *mount);
-void xenbus_write_backend_ready(struct mount *mount);
+void xenbus_read_mount_request(struct fs_mount *mount, char *frontend);
+void xenbus_write_backend_node(struct fs_mount *mount);
+void xenbus_write_backend_ready(struct fs_mount *mount);
/* File operations, implemented in fs-ops.c */
struct fs_op
{
int type; /* Type of request (from fsif.h) this handlers
are responsible for */
- void (*dispatch_handler)(struct mount *mount, struct fsif_request *req);
- void (*response_handler)(struct mount *mount, struct fs_request *req);
+ void (*dispatch_handler)(struct fs_mount *mount, struct fsif_request *req);
+ void (*response_handler)(struct fs_mount *mount, struct fs_request *req);
};
/* This NULL terminated array of all file requests handlers */
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
-#include <sys/vfs.h>
+#include <sys/statvfs.h>
#include <sys/mount.h>
#include <unistd.h>
#include "fs-backend.h"
#define BUFFER_SIZE 1024
-unsigned short get_request(struct mount *mount, struct fsif_request *req)
+static unsigned short get_request(struct fs_mount *mount, struct fsif_request *req)
{
unsigned short id = get_id_from_freelist(mount->freelist);
return id;
}
-int get_fd(struct mount *mount)
+static int get_fd(struct fs_mount *mount)
{
int i;
}
-void dispatch_file_open(struct mount *mount, struct fsif_request *req)
+static void dispatch_file_open(struct fs_mount *mount, struct fsif_request *req)
{
char *file_name, full_path[BUFFER_SIZE];
int fd;
rsp->ret_val = (uint64_t)fd;
}
-void dispatch_file_close(struct mount *mount, struct fsif_request *req)
+static void dispatch_file_close(struct fs_mount *mount, struct fsif_request *req)
{
int ret;
RING_IDX rsp_idx;
rsp->id = req_id;
rsp->ret_val = (uint64_t)ret;
}
-void dispatch_file_read(struct mount *mount, struct fsif_request *req)
+
+static void dispatch_file_read(struct fs_mount *mount, struct fsif_request *req)
{
void *buf;
int fd;
mount->ring.req_cons++;
}
-void end_file_read(struct mount *mount, struct fs_request *priv_req)
+static void end_file_read(struct fs_mount *mount, struct fs_request *priv_req)
{
RING_IDX rsp_idx;
fsif_response_t *rsp;
rsp->ret_val = (uint64_t)aio_return(&priv_req->aiocb);
}
-void dispatch_file_write(struct mount *mount, struct fsif_request *req)
+static void dispatch_file_write(struct fs_mount *mount, struct fsif_request *req)
{
void *buf;
int fd;
mount->ring.req_cons++;
}
-void end_file_write(struct mount *mount, struct fs_request *priv_req)
+static void end_file_write(struct fs_mount *mount, struct fs_request *priv_req)
{
RING_IDX rsp_idx;
fsif_response_t *rsp;
rsp->ret_val = (uint64_t)aio_return(&priv_req->aiocb);
}
-void dispatch_stat(struct mount *mount, struct fsif_request *req)
+static void dispatch_stat(struct fs_mount *mount, struct fsif_request *req)
{
struct fsif_stat_response *buf;
struct stat stat;
/* Stat, and create the response */
ret = fstat(fd, &stat);
printf("Mode=%o, uid=%d, a_time=%ld\n",
- stat.st_mode, stat.st_uid, stat.st_atime);
+ stat.st_mode, stat.st_uid, (long)stat.st_atime);
buf->stat_mode = stat.st_mode;
buf->stat_uid = stat.st_uid;
buf->stat_gid = stat.st_gid;
}
-void dispatch_truncate(struct mount *mount, struct fsif_request *req)
+static void dispatch_truncate(struct fs_mount *mount, struct fsif_request *req)
{
int fd, ret;
uint16_t req_id;
rsp->ret_val = (uint64_t)ret;
}
-void dispatch_remove(struct mount *mount, struct fsif_request *req)
+static void dispatch_remove(struct fs_mount *mount, struct fsif_request *req)
{
char *file_name, full_path[BUFFER_SIZE];
int ret;
}
-void dispatch_rename(struct mount *mount, struct fsif_request *req)
+static void dispatch_rename(struct fs_mount *mount, struct fsif_request *req)
{
char *buf, *old_file_name, *new_file_name;
char old_full_path[BUFFER_SIZE], new_full_path[BUFFER_SIZE];
}
-void dispatch_create(struct mount *mount, struct fsif_request *req)
+static void dispatch_create(struct fs_mount *mount, struct fsif_request *req)
{
char *file_name, full_path[BUFFER_SIZE];
int ret;
rsp->ret_val = (uint64_t)ret;
}
-void dispatch_list(struct mount *mount, struct fsif_request *req)
+static void dispatch_list(struct fs_mount *mount, struct fsif_request *req)
{
char *file_name, *buf, full_path[BUFFER_SIZE];
uint32_t offset, nr_files, error_code;
rsp->ret_val = ret_val;
}
-void dispatch_chmod(struct mount *mount, struct fsif_request *req)
+static void dispatch_chmod(struct fs_mount *mount, struct fsif_request *req)
{
int fd, ret;
RING_IDX rsp_idx;
rsp->ret_val = (uint64_t)ret;
}
-void dispatch_fs_space(struct mount *mount, struct fsif_request *req)
+static void dispatch_fs_space(struct fs_mount *mount, struct fsif_request *req)
{
char *file_name, full_path[BUFFER_SIZE];
RING_IDX rsp_idx;
fsif_response_t *rsp;
uint16_t req_id;
- struct statfs stat;
+ struct statvfs stat;
int64_t ret;
printf("Dispatching fs space operation (gref=%d).\n", req->u.fspace.gref);
mount->export->export_path, file_name);
assert(xc_gnttab_munmap(mount->gnth, file_name, 1) == 0);
printf("Issuing fs space for %s\n", full_path);
- ret = statfs(full_path, &stat);
+ ret = statvfs(full_path, &stat);
if(ret >= 0)
ret = stat.f_bsize * stat.f_bfree;
rsp->ret_val = (uint64_t)ret;
}
-void dispatch_file_sync(struct mount *mount, struct fsif_request *req)
+static void dispatch_file_sync(struct fs_mount *mount, struct fsif_request *req)
{
int fd;
uint16_t req_id;
mount->ring.req_cons++;
}
-void end_file_sync(struct mount *mount, struct fs_request *priv_req)
+static void end_file_sync(struct fs_mount *mount, struct fs_request *priv_req)
{
RING_IDX rsp_idx;
fsif_response_t *rsp;