Paul,

I can also do cat or cp with no problems.  The source code that gives me
EINVAL is below.

Thanks for your support!

Rod


// testowfs.cpp

#include <errno.h>
#include <stdlib.h>
#include <sys/types.h> 
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>

int main(int argc, char * argv[])
{
  if (argc <= 3)
  {
    printf("testowfs filename offset length\n");
    return 0;
  }

  const unsigned offset = atoi(argv[2]);
  const unsigned length = atoi(argv[3]);

  printf("reading %u bytes from position %u in \"%s\"\n", length,
offset, argv[1]);

  const int fd = open(argv[1], O_RDONLY);
  if (fd == -1)
  {
    const int error = errno;
    printf("error %d opening file\n", error);
    return error;
  }

  const off_t pos = lseek(fd, offset, SEEK_SET);
  if (pos == (off_t)-1)
  {
    const int error = errno;
    printf("error %d doing lseek\n", error);
    close(fd);
    return error;
  }
  if (pos != (off_t) offset)
  {
    printf("lseek returned %ld\n", pos);
    close(fd);
    return 0;
  }

  char * const buffer = new char[length+1];
  const ssize_t result = read(fd, buffer, length);
  if (result == (ssize_t)-1)
  {
    const int error = errno;
    printf("error %d doing read\n", error);
    delete[] buffer;
    close(fd);
    return error;
  }
  if (result != (ssize_t) length)
  {
    printf("read returned %d\n", result);
    delete[] buffer;
    close(fd);
    return 0;
  }

  buffer[length] = 0;
  printf("%s\n", buffer);
  delete[] buffer;
  close(fd);

  return 0;
} 

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Paul
Alfille
Sent: Friday, May 19, 2006 11:46 PM
To: [email protected]
Subject: Re: [Owfs-developers] RE: problem writing to DS1996

Rod, I'm having no problems from the command line with the full read.
I fixed the caching of partial data (eliminated it).

I'll need to write a comparable function to your C tester to replicate
your problems.

Paul



-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642
_______________________________________________
Owfs-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/owfs-developers

Reply via email to