URI:
       Fixed return value of read and write. - susmb - mounting of SMB/CIFS shares via FUSE
  HTML git clone git://git.codemadness.org/susmb
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit ecf5e5c2e1afb93e4c503bf217cf3ddcf5601131
   DIR parent b1b3acf51f3aff93c15bfa514b64adee8adb6381
  HTML Author: geoff <devnull@localhost>
       Date:   Sat,  6 May 2006 23:25:13 +0000
       
       Fixed return value of read and write.
       
       Diffstat:
         M Makefile                            |       2 +-
         M usmb_file.c                         |       6 ++++--
         D utils.c                             |      66 -------------------------------
         D utils.h                             |       6 ------
       
       4 files changed, 5 insertions(+), 75 deletions(-)
       ---
   DIR diff --git a/Makefile b/Makefile
       @@ -6,7 +6,7 @@ CFLAGS = -Wall -W -std=c99 -pedantic -O $(shell pkg-config --cflags fuse) \
        LDLIBS = $(shell pkg-config --libs-only-l fuse) -lsmbclient
        LDFLAGS = $(shell pkg-config --libs-only-L fuse) -L$(SAMBA)/lib
        
       -SOURCES = usmb.c usmb_dir.c usmb_file.c utils.c
       +SOURCES = usmb.c usmb_dir.c usmb_file.c
        OBJECTS = $(SOURCES:.c=.o)
        
        PROGRAM = usmb
   DIR diff --git a/usmb_file.c b/usmb_file.c
       @@ -73,7 +73,8 @@ int usmb_read (const char *filename, char *buff, size_t len, off_t off,
        
          /* TODO: this may be WRONG: do we need to consider the offset */
          DEBUG (fprintf (stderr, "read (%p, %u)\n", buff, len));
       -  return smbc_read (fi->fh, buff, len);
       +  int bytes = smbc_read (fi->fh, buff, len);
       +  return (bytes < 0) ? -errno : bytes;
        }
        
        
       @@ -85,7 +86,8 @@ int usmb_write (const char *filename, const char *buff, size_t len, off_t off,
        
          /* TODO: this may be WRONG: do we need to consider the offset */
          DEBUG (fprintf (stderr, "write (%p, %u)\n", buff, len));
       -  return smbc_write (fi->fh, (char *)buff, len) ? -errno : 0;
       +  int bytes = smbc_write (fi->fh, (char *)buff, len);
       +  return (bytes < 0) ? -errno : bytes;
        }
        
        
   DIR diff --git a/utils.c b/utils.c
       @@ -1,66 +0,0 @@
       -#include <assert.h>
       -#include <stdarg.h>
       -#include <stddef.h>
       -#include <stdlib.h>
       -#include <string.h>
       -#include "utils.h"
       -
       -
       -#define INIT_LEN 256
       -char * concat_strings (int num, ...)
       -{
       -  va_list ap;
       -
       -  char *base, *out;
       -
       -  base = out = malloc (INIT_LEN);
       -  if (NULL == base)
       -    return NULL;
       -
       -  size_t buff_size = INIT_LEN;
       -
       -  va_start (ap, num);
       -  for (int i = 0; i < num; ++i)
       -  {
       -    const char *next = va_arg (ap, const char *);
       -    assert (NULL != next);
       -
       -    size_t next_len = strlen (next);
       -    size_t required = (out - base) + next_len + 1;
       -
       -    if (buff_size < required)
       -    {
       -      while (buff_size < required)
       -      {
       -        size_t dbl_len = buff_size * 2;
       -        if (dbl_len < buff_size)
       -        {
       -          free (base);
       -          return NULL;
       -        }
       -
       -        buff_size = dbl_len;
       -      }
       -
       -      ptrdiff_t diff = out - base;
       -
       -      char *newbase = realloc (base, buff_size);
       -      if (NULL == newbase)
       -      {
       -        free (base);
       -        return NULL;
       -      }
       -
       -      base = newbase;
       -      out = base + diff;
       -    }
       -
       -    memcpy (out, next, next_len);
       -    out += next_len;
       -  }
       -  va_end (ap);
       -
       -  *out = '\0';
       -  return base;
       -}
       -
   DIR diff --git a/utils.h b/utils.h
       @@ -1,6 +0,0 @@
       -#ifndef UTILS_H
       -  #define UTILS_H
       -
       -  char * concat_strings (int num, ...);
       -
       -#endif