Change nfs-cp.c example to use lseek+read/write instead of pread/pwrite since some...
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Wed, 17 Apr 2013 01:28:50 +0000 (18:28 -0700)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Wed, 17 Apr 2013 01:28:50 +0000 (18:28 -0700)
Build nfs-ls and nfs-cp for amiga/aros

aros/Makefile.AROS
examples/nfs-cp.c

index 9ad038c2858bdc5198e782bd0e62bfd7bbe4c9a3..6d39137f5cbaa24a1616e939c0ec44f9fbe7a78a 100755 (executable)
@@ -10,7 +10,7 @@ OBJS+=portmap/portmap.o portmap/libnfs-raw-portmap.o
 OBJS+=rquota/rquota.o rquota/libnfs-raw-rquota.o
 OBJS+=aros/aros_compat.o
 
-EXAMPLES=examples/nfsclient-listservers examples/nfsclient-sync
+EXAMPLES=examples/nfsclient-listservers examples/nfsclient-sync examples/nfs-cp examples/nfs-ls
 
 all: lib/libnfs.a $(EXAMPLES)
 
@@ -27,3 +27,8 @@ examples/nfsclient-listservers: examples/nfsclient-listservers.c lib/libnfs.a
 examples/nfsclient-sync: examples/nfsclient-sync.c lib/libnfs.a
        $(CC) $(CFLAGS) -o $@ $< lib/libnfs.a
 
+examples/nfs-ls: examples/nfs-ls.c lib/libnfs.a
+       $(CC) $(CFLAGS) -o $@ $< lib/libnfs.a
+
+examples/nfs-cp: examples/nfs-cp.c lib/libnfs.a
+       $(CC) $(CFLAGS) -o $@ $< lib/libnfs.a
index 53e22d60209db560fa555fc1b1d09c4a1f663741..eeea40423790d2b5b2ace872e76545f583db45b7 100644 (file)
@@ -96,7 +96,8 @@ static int64_t
 file_pread(struct file_context *fc, char *buf, int64_t count, uint64_t off)
 {
        if (fc->is_nfs == 0) {
-               return pread(fc->fd, buf, count, off);
+               lseek(fc->fd, off, SEEK_SET);
+               return read(fc->fd, buf, count);
        } else {
                return nfs_pread(fc->nfs, fc->nfsfh, off, count, buf);
        }
@@ -106,7 +107,8 @@ static int64_t
 file_pwrite(struct file_context *fc, char *buf, int64_t count, uint64_t off)
 {
        if (fc->is_nfs == 0) {
-               return pwrite(fc->fd, buf, count, off);
+               lseek(fc->fd, off, SEEK_SET);
+               return write(fc->fd, buf, count);
        } else {
                return nfs_pwrite(fc->nfs, fc->nfsfh, off, count, buf);
        }