ia64/xen-unstable

changeset 18178:7a35ab9dba8a

fs-back: build fixes for BSD and cleanups.

Signed-of-by: Christoph Egger <Christoph.Egger@amd.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Jul 28 11:39:32 2008 +0100 (2008-07-28)
parents 3769051151ae
children fa8a39619154
files tools/fs-back/fs-backend.c tools/fs-back/fs-backend.h tools/fs-back/fs-ops.c tools/fs-back/fs-xenbus.c
line diff
     1.1 --- a/tools/fs-back/fs-backend.c	Mon Jul 28 11:36:39 2008 +0100
     1.2 +++ b/tools/fs-back/fs-backend.c	Mon Jul 28 11:39:32 2008 +0100
     1.3 @@ -16,7 +16,7 @@ static struct fs_export *fs_exports = NU
     1.4  static int export_id = 0;
     1.5  static int mount_id = 0;
     1.6  
     1.7 -void dispatch_response(struct mount *mount, int priv_req_id)
     1.8 +static void dispatch_response(struct fs_mount *mount, int priv_req_id)
     1.9  {
    1.10      int i;
    1.11      struct fs_op *op;
    1.12 @@ -41,7 +41,7 @@ void dispatch_response(struct mount *mou
    1.13      add_id_to_freelist(priv_req_id, mount->freelist);
    1.14  }
    1.15  
    1.16 -static void handle_aio_events(struct mount *mount)
    1.17 +static void handle_aio_events(struct fs_mount *mount)
    1.18  {
    1.19      int fd, ret, count, i, notify;
    1.20      evtchn_port_t port;
    1.21 @@ -103,7 +103,7 @@ read_event_channel:
    1.22  }
    1.23  
    1.24  
    1.25 -void allocate_request_array(struct mount *mount)
    1.26 +static void allocate_request_array(struct fs_mount *mount)
    1.27  {
    1.28      int i, nr_entries = mount->nr_entries;
    1.29      struct fs_request *requests;
    1.30 @@ -123,10 +123,10 @@ void allocate_request_array(struct mount
    1.31  }
    1.32  
    1.33  
    1.34 -void* handle_mount(void *data)
    1.35 +static void *handle_mount(void *data)
    1.36  {
    1.37      int more, notify;
    1.38 -    struct mount *mount = (struct mount *)data;
    1.39 +    struct fs_mount *mount = (struct fs_mount *)data;
    1.40      
    1.41      printf("Starting a thread for mount: %d\n", mount->mount_id);
    1.42      allocate_request_array(mount);
    1.43 @@ -193,7 +193,7 @@ moretodo:
    1.44  
    1.45  static void handle_connection(int frontend_dom_id, int export_id, char *frontend)
    1.46  {
    1.47 -    struct mount *mount;
    1.48 +    struct fs_mount *mount;
    1.49      struct fs_export *export;
    1.50      int evt_port;
    1.51      pthread_t handling_thread;
    1.52 @@ -216,7 +216,7 @@ static void handle_connection(int fronte
    1.53          return;
    1.54      }
    1.55  
    1.56 -    mount = (struct mount*)malloc(sizeof(struct mount));
    1.57 +    mount = (struct fs_mount*)malloc(sizeof(struct fs_mount));
    1.58      mount->dom_id = frontend_dom_id;
    1.59      mount->export = export;
    1.60      mount->mount_id = mount_id++;
    1.61 @@ -287,7 +287,7 @@ next_select:
    1.62      } while (1);
    1.63  }
    1.64  
    1.65 -struct fs_export* create_export(char *name, char *export_path)
    1.66 +static struct fs_export* create_export(char *name, char *export_path)
    1.67  {
    1.68      struct fs_export *curr_export, **last_export;
    1.69  
     2.1 --- a/tools/fs-back/fs-backend.h	Mon Jul 28 11:36:39 2008 +0100
     2.2 +++ b/tools/fs-back/fs-backend.h	Mon Jul 28 11:39:32 2008 +0100
     2.3 @@ -31,7 +31,7 @@ struct fs_request
     2.4  };
     2.5  
     2.6  
     2.7 -struct mount
     2.8 +struct fs_mount
     2.9  {
    2.10      struct fs_export *export;
    2.11      int dom_id;
    2.12 @@ -56,17 +56,17 @@ extern struct xs_handle *xsh;
    2.13  bool xenbus_create_request_node(void);
    2.14  int xenbus_register_export(struct fs_export *export);
    2.15  int xenbus_get_watch_fd(void);
    2.16 -void xenbus_read_mount_request(struct mount *mount, char *frontend);
    2.17 -void xenbus_write_backend_node(struct mount *mount);
    2.18 -void xenbus_write_backend_ready(struct mount *mount);
    2.19 +void xenbus_read_mount_request(struct fs_mount *mount, char *frontend);
    2.20 +void xenbus_write_backend_node(struct fs_mount *mount);
    2.21 +void xenbus_write_backend_ready(struct fs_mount *mount);
    2.22  
    2.23  /* File operations, implemented in fs-ops.c */
    2.24  struct fs_op
    2.25  {
    2.26      int type;       /* Type of request (from fsif.h) this handlers 
    2.27                         are responsible for */
    2.28 -    void (*dispatch_handler)(struct mount *mount, struct fsif_request *req);
    2.29 -    void (*response_handler)(struct mount *mount, struct fs_request *req);
    2.30 +    void (*dispatch_handler)(struct fs_mount *mount, struct fsif_request *req);
    2.31 +    void (*response_handler)(struct fs_mount *mount, struct fs_request *req);
    2.32  };
    2.33  
    2.34  /* This NULL terminated array of all file requests handlers */
     3.1 --- a/tools/fs-back/fs-ops.c	Mon Jul 28 11:36:39 2008 +0100
     3.2 +++ b/tools/fs-back/fs-ops.c	Mon Jul 28 11:39:32 2008 +0100
     3.3 @@ -10,7 +10,7 @@
     3.4  #include <sys/mman.h>
     3.5  #include <sys/types.h>
     3.6  #include <sys/stat.h>
     3.7 -#include <sys/vfs.h>
     3.8 +#include <sys/statvfs.h>
     3.9  #include <sys/mount.h>
    3.10  #include <unistd.h>
    3.11  #include "fs-backend.h"
    3.12 @@ -23,7 +23,7 @@
    3.13  #define BUFFER_SIZE 1024
    3.14  
    3.15  
    3.16 -unsigned short get_request(struct mount *mount, struct fsif_request *req)
    3.17 +static unsigned short get_request(struct fs_mount *mount, struct fsif_request *req)
    3.18  {
    3.19      unsigned short id = get_id_from_freelist(mount->freelist); 
    3.20  
    3.21 @@ -34,7 +34,7 @@ unsigned short get_request(struct mount 
    3.22      return id;
    3.23  }
    3.24  
    3.25 -int get_fd(struct mount *mount)
    3.26 +static int get_fd(struct fs_mount *mount)
    3.27  {
    3.28      int i;
    3.29  
    3.30 @@ -45,7 +45,7 @@ int get_fd(struct mount *mount)
    3.31  }
    3.32  
    3.33  
    3.34 -void dispatch_file_open(struct mount *mount, struct fsif_request *req)
    3.35 +static void dispatch_file_open(struct fs_mount *mount, struct fsif_request *req)
    3.36  {
    3.37      char *file_name, full_path[BUFFER_SIZE];
    3.38      int fd;
    3.39 @@ -93,7 +93,7 @@ void dispatch_file_open(struct mount *mo
    3.40      rsp->ret_val = (uint64_t)fd;
    3.41  }
    3.42  
    3.43 -void dispatch_file_close(struct mount *mount, struct fsif_request *req)
    3.44 +static void dispatch_file_close(struct fs_mount *mount, struct fsif_request *req)
    3.45  {
    3.46      int ret;
    3.47      RING_IDX rsp_idx;
    3.48 @@ -122,7 +122,8 @@ void dispatch_file_close(struct mount *m
    3.49      rsp->id = req_id; 
    3.50      rsp->ret_val = (uint64_t)ret;
    3.51  }
    3.52 -void dispatch_file_read(struct mount *mount, struct fsif_request *req)
    3.53 +
    3.54 +static void dispatch_file_read(struct fs_mount *mount, struct fsif_request *req)
    3.55  {
    3.56      void *buf;
    3.57      int fd;
    3.58 @@ -164,7 +165,7 @@ out:
    3.59      mount->ring.req_cons++;
    3.60  }
    3.61  
    3.62 -void end_file_read(struct mount *mount, struct fs_request *priv_req)
    3.63 +static void end_file_read(struct fs_mount *mount, struct fs_request *priv_req)
    3.64  {
    3.65      RING_IDX rsp_idx;
    3.66      fsif_response_t *rsp;
    3.67 @@ -182,7 +183,7 @@ void end_file_read(struct mount *mount, 
    3.68      rsp->ret_val = (uint64_t)aio_return(&priv_req->aiocb);
    3.69  }
    3.70  
    3.71 -void dispatch_file_write(struct mount *mount, struct fsif_request *req)
    3.72 +static void dispatch_file_write(struct fs_mount *mount, struct fsif_request *req)
    3.73  {
    3.74      void *buf;
    3.75      int fd;
    3.76 @@ -224,7 +225,7 @@ void dispatch_file_write(struct mount *m
    3.77      mount->ring.req_cons++;
    3.78  }
    3.79  
    3.80 -void end_file_write(struct mount *mount, struct fs_request *priv_req)
    3.81 +static void end_file_write(struct fs_mount *mount, struct fs_request *priv_req)
    3.82  {
    3.83      RING_IDX rsp_idx;
    3.84      fsif_response_t *rsp;
    3.85 @@ -242,7 +243,7 @@ void end_file_write(struct mount *mount,
    3.86      rsp->ret_val = (uint64_t)aio_return(&priv_req->aiocb);
    3.87  }
    3.88  
    3.89 -void dispatch_stat(struct mount *mount, struct fsif_request *req)
    3.90 +static void dispatch_stat(struct fs_mount *mount, struct fsif_request *req)
    3.91  {
    3.92      struct fsif_stat_response *buf;
    3.93      struct stat stat;
    3.94 @@ -272,7 +273,7 @@ void dispatch_stat(struct mount *mount, 
    3.95      /* Stat, and create the response */ 
    3.96      ret = fstat(fd, &stat);
    3.97      printf("Mode=%o, uid=%d, a_time=%ld\n",
    3.98 -            stat.st_mode, stat.st_uid, stat.st_atime);
    3.99 +            stat.st_mode, stat.st_uid, (long)stat.st_atime);
   3.100      buf->stat_mode  = stat.st_mode;
   3.101      buf->stat_uid   = stat.st_uid;
   3.102      buf->stat_gid   = stat.st_gid;
   3.103 @@ -303,7 +304,7 @@ void dispatch_stat(struct mount *mount, 
   3.104  }
   3.105  
   3.106  
   3.107 -void dispatch_truncate(struct mount *mount, struct fsif_request *req)
   3.108 +static void dispatch_truncate(struct fs_mount *mount, struct fsif_request *req)
   3.109  {
   3.110      int fd, ret;
   3.111      uint16_t req_id;
   3.112 @@ -335,7 +336,7 @@ void dispatch_truncate(struct mount *mou
   3.113      rsp->ret_val = (uint64_t)ret;
   3.114  }
   3.115  
   3.116 -void dispatch_remove(struct mount *mount, struct fsif_request *req)
   3.117 +static void dispatch_remove(struct fs_mount *mount, struct fsif_request *req)
   3.118  {
   3.119      char *file_name, full_path[BUFFER_SIZE];
   3.120      int ret;
   3.121 @@ -374,7 +375,7 @@ void dispatch_remove(struct mount *mount
   3.122  }
   3.123  
   3.124  
   3.125 -void dispatch_rename(struct mount *mount, struct fsif_request *req)
   3.126 +static void dispatch_rename(struct fs_mount *mount, struct fsif_request *req)
   3.127  {
   3.128      char *buf, *old_file_name, *new_file_name;
   3.129      char old_full_path[BUFFER_SIZE], new_full_path[BUFFER_SIZE];
   3.130 @@ -421,7 +422,7 @@ void dispatch_rename(struct mount *mount
   3.131  }
   3.132  
   3.133  
   3.134 -void dispatch_create(struct mount *mount, struct fsif_request *req)
   3.135 +static void dispatch_create(struct fs_mount *mount, struct fsif_request *req)
   3.136  {
   3.137      char *file_name, full_path[BUFFER_SIZE];
   3.138      int ret;
   3.139 @@ -481,7 +482,7 @@ void dispatch_create(struct mount *mount
   3.140      rsp->ret_val = (uint64_t)ret;
   3.141  }
   3.142  
   3.143 -void dispatch_list(struct mount *mount, struct fsif_request *req)
   3.144 +static void dispatch_list(struct fs_mount *mount, struct fsif_request *req)
   3.145  {
   3.146      char *file_name, *buf, full_path[BUFFER_SIZE];
   3.147      uint32_t offset, nr_files, error_code; 
   3.148 @@ -551,7 +552,7 @@ error_out:
   3.149      rsp->ret_val = ret_val;
   3.150  }
   3.151  
   3.152 -void dispatch_chmod(struct mount *mount, struct fsif_request *req)
   3.153 +static void dispatch_chmod(struct fs_mount *mount, struct fsif_request *req)
   3.154  {
   3.155      int fd, ret;
   3.156      RING_IDX rsp_idx;
   3.157 @@ -582,13 +583,13 @@ void dispatch_chmod(struct mount *mount,
   3.158      rsp->ret_val = (uint64_t)ret;
   3.159  }
   3.160  
   3.161 -void dispatch_fs_space(struct mount *mount, struct fsif_request *req)
   3.162 +static void dispatch_fs_space(struct fs_mount *mount, struct fsif_request *req)
   3.163  {
   3.164      char *file_name, full_path[BUFFER_SIZE];
   3.165      RING_IDX rsp_idx;
   3.166      fsif_response_t *rsp;
   3.167      uint16_t req_id;
   3.168 -    struct statfs stat;
   3.169 +    struct statvfs stat;
   3.170      int64_t ret;
   3.171  
   3.172      printf("Dispatching fs space operation (gref=%d).\n", req->u.fspace.gref);
   3.173 @@ -606,7 +607,7 @@ void dispatch_fs_space(struct mount *mou
   3.174             mount->export->export_path, file_name);
   3.175      assert(xc_gnttab_munmap(mount->gnth, file_name, 1) == 0);
   3.176      printf("Issuing fs space for %s\n", full_path);
   3.177 -    ret = statfs(full_path, &stat);
   3.178 +    ret = statvfs(full_path, &stat);
   3.179      if(ret >= 0)
   3.180          ret = stat.f_bsize * stat.f_bfree;
   3.181  
   3.182 @@ -623,7 +624,7 @@ void dispatch_fs_space(struct mount *mou
   3.183      rsp->ret_val = (uint64_t)ret;
   3.184  }
   3.185  
   3.186 -void dispatch_file_sync(struct mount *mount, struct fsif_request *req)
   3.187 +static void dispatch_file_sync(struct fs_mount *mount, struct fsif_request *req)
   3.188  {
   3.189      int fd;
   3.190      uint16_t req_id;
   3.191 @@ -653,7 +654,7 @@ void dispatch_file_sync(struct mount *mo
   3.192      mount->ring.req_cons++;
   3.193  }
   3.194  
   3.195 -void end_file_sync(struct mount *mount, struct fs_request *priv_req)
   3.196 +static void end_file_sync(struct fs_mount *mount, struct fs_request *priv_req)
   3.197  {
   3.198      RING_IDX rsp_idx;
   3.199      fsif_response_t *rsp;
     4.1 --- a/tools/fs-back/fs-xenbus.c	Mon Jul 28 11:36:39 2008 +0100
     4.2 +++ b/tools/fs-back/fs-xenbus.c	Mon Jul 28 11:39:32 2008 +0100
     4.3 @@ -109,7 +109,7 @@ int xenbus_get_watch_fd(void)
     4.4      return xs_fileno(xsh); 
     4.5  }
     4.6  
     4.7 -void xenbus_read_mount_request(struct mount *mount, char *frontend)
     4.8 +void xenbus_read_mount_request(struct fs_mount *mount, char *frontend)
     4.9  {
    4.10      char node[1024];
    4.11      char *s;
    4.12 @@ -150,7 +150,7 @@ static int get_self_id(void)
    4.13  } 
    4.14  
    4.15  
    4.16 -void xenbus_write_backend_node(struct mount *mount)
    4.17 +void xenbus_write_backend_node(struct fs_mount *mount)
    4.18  {
    4.19      char node[1024], backend_node[1024];
    4.20      int self_id;
    4.21 @@ -167,7 +167,7 @@ void xenbus_write_backend_node(struct mo
    4.22      xs_write(xsh, XBT_NULL, node, STATE_INITIALISED, strlen(STATE_INITIALISED));
    4.23  }
    4.24  
    4.25 -void xenbus_write_backend_ready(struct mount *mount)
    4.26 +void xenbus_write_backend_ready(struct fs_mount *mount)
    4.27  {
    4.28      char node[1024];
    4.29      int self_id;