ia64/xen-unstable

changeset 19391:fe4b23bd3a95

fs-back: build fixes

Remove some unused variables and replaces read and write
to the pipe with read_exact and write_exact (these two functions are
implemented in libxc, that we have to link anyway).

This allows fs-backed to be compiled with -D_FORTIFY_SOURCE=2, hence
should fix the problems reported by Boris.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Mar 18 13:25:25 2009 +0000 (2009-03-18)
parents b8242b82b561
children bedd3906979e
files tools/fs-back/fs-backend.c tools/fs-back/fs-ops.c
line diff
     1.1 --- a/tools/fs-back/fs-backend.c	Wed Mar 18 13:24:42 2009 +0000
     1.2 +++ b/tools/fs-back/fs-backend.c	Wed Mar 18 13:25:25 2009 +0000
     1.3 @@ -10,6 +10,7 @@
     1.4  #include <sys/select.h>
     1.5  #include <sys/socket.h>
     1.6  #include <xen/io/ring.h>
     1.7 +#include <xc_private.h>
     1.8  #include <err.h>
     1.9  #include "sys-queue.h"
    1.10  #include "fs-backend.h"
    1.11 @@ -182,7 +183,6 @@ static void handle_connection(int fronte
    1.12  {
    1.13      struct fs_mount *mount;
    1.14      struct fs_export *export;
    1.15 -    int evt_port;
    1.16      struct fsif_sring *sring;
    1.17      uint32_t dom_ids[MAX_RING_SIZE];
    1.18      int i;
    1.19 @@ -336,12 +336,8 @@ static void await_connections(void)
    1.20          }
    1.21          if (FD_ISSET(pipefds[0], &fds)) {
    1.22              struct fs_request *request;
    1.23 -            int ret;
    1.24 -            ret = read(pipefds[0], &request, sizeof(struct fs_request *));
    1.25 -            if (ret != sizeof(struct fs_request *)) {
    1.26 -                fprintf(stderr, "read request failed\n");
    1.27 -                continue;
    1.28 -            }
    1.29 +            if (read_exact(pipefds[0], &request, sizeof(struct fs_request *)) < 0)
    1.30 +                err(1, "read request failed\n");
    1.31              handle_aio_event(request); 
    1.32          }
    1.33          LIST_FOREACH(pointer, &mount_requests_head, entries) {
    1.34 @@ -380,7 +376,8 @@ static void aio_signal_handler(int signo
    1.35  {
    1.36      struct fs_request *request = (struct fs_request*) info->si_value.sival_ptr;
    1.37      int saved_errno = errno;
    1.38 -    write(pipefds[1], &request, sizeof(struct fs_request *));
    1.39 +    if (write_exact(pipefds[1], &request, sizeof(struct fs_request *)) < 0)
    1.40 +        err(1, "write request filed\n");
    1.41      errno = saved_errno;
    1.42  }
    1.43  
     2.1 --- a/tools/fs-back/fs-ops.c	Wed Mar 18 13:24:42 2009 +0000
     2.2 +++ b/tools/fs-back/fs-ops.c	Wed Mar 18 13:25:25 2009 +0000
     2.3 @@ -49,7 +49,6 @@ static void dispatch_file_open(struct fs
     2.4  {
     2.5      char *file_name, full_path[BUFFER_SIZE];
     2.6      int fd;
     2.7 -    struct timeval tv1, tv2;
     2.8      RING_IDX rsp_idx;
     2.9      fsif_response_t *rsp;
    2.10      uint16_t req_id;
    2.11 @@ -127,7 +126,7 @@ static void dispatch_file_close(struct f
    2.12  static void dispatch_file_read(struct fs_mount *mount, struct fsif_request *req)
    2.13  {
    2.14      void *buf;
    2.15 -    int fd, i, count;
    2.16 +    int fd, count;
    2.17      uint16_t req_id;
    2.18      unsigned short priv_id;
    2.19      struct fs_request *priv_req;
    2.20 @@ -169,7 +168,6 @@ static void dispatch_file_read(struct fs
    2.21      priv_req->aiocb.aio_sigevent.sigev_value.sival_ptr = priv_req;
    2.22      assert(aio_read(&priv_req->aiocb) >= 0);
    2.23  
    2.24 -out: 
    2.25      /* We can advance the request consumer index, from here on, the request
    2.26       * should not be used (it may be overrinden by a response) */
    2.27      mount->ring.req_cons++;
    2.28 @@ -198,7 +196,7 @@ static void end_file_read(struct fs_moun
    2.29  static void dispatch_file_write(struct fs_mount *mount, struct fsif_request *req)
    2.30  {
    2.31      void *buf;
    2.32 -    int fd, count, i;
    2.33 +    int fd, count;
    2.34      uint16_t req_id;
    2.35      unsigned short priv_id;
    2.36      struct fs_request *priv_req;
    2.37 @@ -268,7 +266,6 @@ static void end_file_write(struct fs_mou
    2.38  
    2.39  static void dispatch_stat(struct fs_mount *mount, struct fsif_request *req)
    2.40  {
    2.41 -    struct fsif_stat_response *buf;
    2.42      struct stat stat;
    2.43      int fd, ret;
    2.44      uint16_t req_id;