dir: Prototype and function name cleanup
[openafs.git] / src / volser / vol_split.c
index f541041..f862f89 100644 (file)
@@ -8,50 +8,32 @@
 #include <afsconfig.h>
 #include <afs/param.h>
 
-#if defined(AFS_NAMEI_ENV) && !defined(AFS_NT40_ENV)
-#include <sys/types.h>
-#include <stdio.h>
-#ifdef AFS_PTHREAD_ENV
-#include <assert.h>
-#else /* AFS_PTHREAD_ENV */
-#include <afs/assert.h>
-#endif /* AFS_PTHREAD_ENV */
-#ifdef AFS_NT40_ENV
-#include <fcntl.h>
-#include <windows.h>
-#include <winbase.h>
-#include <io.h>
-#include <time.h>
-#else
+#include <roken.h>
+
+#ifdef HAVE_SYS_FILE_H
 #include <sys/file.h>
-#include <sys/time.h>
-#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#else
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
 #endif
-#endif
-#include <errno.h>
-#include <sys/stat.h>
 
+#if defined(AFS_NAMEI_ENV) && !defined(AFS_NT40_ENV)
+#include <afs/afs_assert.h>
+#include <afs/dir.h>
 #include <rx/xdr.h>
 #include <afs/afsint.h>
-#include "nfs.h"
-#include "lwp.h"
-#include "lock.h"
+#include <afs/nfs.h>
+#include <lwp.h>
+#include <lock.h>
 #include <afs/afssyscalls.h>
-#include "ihandle.h"
-#include "vnode.h"
-#include "volume.h"
-#include "partition.h"
-#include "viceinode.h"
+#include <afs/ihandle.h>
+#include <afs/vnode.h>
+#include <afs/volume.h>
+#include <afs/partition.h>
+#include <afs/viceinode.h>
+
 #include "vol.h"
 #include "volint.h"
 #include "volser.h"
 #include "physio.h"
-#include "volser_prototypes.h"
+#include "volser_internal.h"
 #ifdef AFS_RXOSD_SUPPORT
 #include "rxosd.h"
 #include "vol_osd.h"
@@ -80,12 +62,12 @@ struct Msg {
     char line[1024];
 };
 
-static afs_int32 
-ExtractVnodes(struct Msg *m, Volume *vol, afs_int32 class, 
+static afs_int32
+ExtractVnodes(struct Msg *m, Volume *vol, afs_int32 class,
              struct VnodeExtract **list,
-             afs_int32 *length, afs_uint32 where, 
+             afs_uint32 *length, afs_uint32 where,
              struct VnodeDiskObject *vd,
-             afs_int32 *parent, struct VnodeDiskObject *parentvd)
+             afs_uint32 *parent, struct VnodeDiskObject *parentvd)
 {
     afs_int32 code = 0;
     char buf[SIZEOF_LARGEDISKVNODE];
@@ -94,8 +76,8 @@ ExtractVnodes(struct Msg *m, Volume *vol, afs_int32 class,
     StreamHandle_t *stream = 0;
     struct VnodeClassInfo *vcp = &VnodeClassInfo[class];
     struct VnodeExtract *e;
-    afs_uint32 size;
-    afs_uint32 offset;
+    afs_sfsize_t size;
+    afs_foff_t offset;
 
     *length = 0;
     if (parent)
@@ -103,7 +85,7 @@ ExtractVnodes(struct Msg *m, Volume *vol, afs_int32 class,
 
     fdP = IH_OPEN(vol->vnodeIndex[class].handle);
     if (!fdP) {
-       sprintf(m->line, "Couldn't open %s Index of volume %u\n", 
+       sprintf(m->line, "Couldn't open %s Index of volume %u\n",
                class ? "small":"large", V_id(vol));
        rx_Write(m->call, m->line, strlen(m->line));
        code = EIO;
@@ -119,13 +101,13 @@ ExtractVnodes(struct Msg *m, Volume *vol, afs_int32 class,
     memset(*list, 0, size / vcp->diskSize * sizeof(struct VnodeExtract));
     stream = FDH_FDOPEN(fdP, "r");
     if (!stream) {
-       sprintf(m->line, "Couldn't stream open %s Index of volume %u\n", 
+       sprintf(m->line, "Couldn't stream open %s Index of volume %u\n",
                class ? "small":"large", V_id(vol));
        rx_Write(m->call, m->line, strlen(m->line));
-       return EIO;
+       code = EIO;
        goto Bad_Extract;
     }
-    code = STREAM_SEEK(stream, vcp->diskSize, 0);
+    code = STREAM_ASEEK(stream, vcp->diskSize);
     if (code)
        goto Bad_Extract;
 
@@ -150,8 +132,8 @@ ExtractVnodes(struct Msg *m, Volume *vol, afs_int32 class,
     if (class == vLarge) {
        if (*parent) {
            offset = (*parent + 1 - class) << (vcp->logSize -1);
-            code = STREAM_SEEK(stream, offset, 0);
-           if (STREAM_READ(vnode, vcp->diskSize, 1, stream) == 1) 
+            code = STREAM_ASEEK(stream, offset);
+           if (STREAM_READ(vnode, vcp->diskSize, 1, stream) == 1)
                memcpy(parentvd, vnode, vcp->diskSize);
            else
                code = EIO;
@@ -167,7 +149,7 @@ ExtractVnodes(struct Msg *m, Volume *vol, afs_int32 class,
                        V_id(vol));
        rx_Write(m->call, m->line, strlen(m->line));
     }
-    
+
 Bad_Extract:
     if (stream)
        STREAM_CLOSE(stream);
@@ -180,11 +162,11 @@ Bad_Extract:
     return code;
 }
 
-static afs_int32 
-FindVnodes(struct Msg *m, afs_uint32 where, 
-          struct VnodeExtract *list, afs_int32 length, 
-          struct VnodeExtract *dlist, afs_int32 dlength, 
-          afs_int32 *needed, afs_int32 class)
+static afs_int32
+FindVnodes(struct Msg *m, afs_uint32 where,
+          struct VnodeExtract *list, afs_int32 length,
+          struct VnodeExtract *dlist, afs_int32 dlength,
+          afs_uint32 *needed, afs_int32 class)
 {
     afs_int32 i, j, found = 0;
     afs_int32 parent = 0;
@@ -201,17 +183,17 @@ FindVnodes(struct Msg *m, afs_uint32 where,
            list[i].flag |= (NEEDED + CHANGEPARENT);
            (*needed)++;
        }
-    } 
+    }
     if (list[0].vN & 1) {              /* only for directories */
        if (!found) {
-           sprintf(m->line, 
+           sprintf(m->line,
                "SplitVolume: directory %u where to start new volume not found\n",
                 where);
            rx_Write(m->call, m->line, strlen(m->line));
            return ENOENT;
        }
        found = 0;
-       for (i=0; i<length; i++) { 
+       for (i=0; i<length; i++) {
            if (list[i].vN == parent) { /* dir where to create mount point */
                list[i].flag |= PARENT;
                found = 1;
@@ -219,7 +201,7 @@ FindVnodes(struct Msg *m, afs_uint32 where,
            }
        }
        if (!found) {
-           sprintf(m->line, "SplitVolume: parent directory %u not found\n", 
+           sprintf(m->line, "SplitVolume: parent directory %u not found\n",
                        parent);
            rx_Write(m->call, m->line, strlen(m->line));
            return ENOENT;
@@ -241,23 +223,24 @@ FindVnodes(struct Msg *m, afs_uint32 where,
        }
     }
     if (m->verbose) {
-       sprintf(m->line, "%u %s vnodes will go into the new volume\n", 
+       sprintf(m->line, "%u %s vnodes will go into the new volume\n",
                        *needed, class ? "small" : "large");
        rx_Write(m->call, m->line, strlen(m->line));
     }
     return 0;
 }
-    
-static afs_int32 
+
+static afs_int32
 copyDir(struct Msg *m, IHandle_t *inh, IHandle_t *outh)
 {
     FdHandle_t *infdP, *outfdP;
     char *tbuf;
-    afs_size_t size;
+    afs_sfsize_t size;
+    afs_foff_t offset;
 
     infdP = IH_OPEN(inh);
     if (!infdP) {
-       sprintf(m->line, "Couldn't open input directory %u.%u.%u\n", 
+       sprintf(m->line, "Couldn't open input directory %u.%u.%u\n",
                    infdP->fd_ih->ih_vid,
                    (afs_uint32)(infdP->fd_ih->ih_ino & NAMEI_VNODEMASK),
                    (afs_uint32)(infdP->fd_ih->ih_ino >> NAMEI_UNIQSHIFT));
@@ -266,7 +249,7 @@ copyDir(struct Msg *m, IHandle_t *inh, IHandle_t *outh)
     }
     outfdP = IH_OPEN(outh);
     if (!outfdP) {
-       sprintf(m->line, "Couldn't open output directory %u.%u.%u\n", 
+       sprintf(m->line, "Couldn't open output directory %u.%u.%u\n",
                    outfdP->fd_ih->ih_vid,
                    (afs_uint32)(outfdP->fd_ih->ih_ino & NAMEI_VNODEMASK),
                    (afs_uint32)(outfdP->fd_ih->ih_ino >> NAMEI_UNIQSHIFT));
@@ -275,14 +258,13 @@ copyDir(struct Msg *m, IHandle_t *inh, IHandle_t *outh)
        return EIO;
     }
     tbuf = malloc(2048);
-    FDH_SEEK(infdP, 0, 0);
-    FDH_SEEK(outfdP, 0, 0);
+    offset = 0;
     size = FDH_SIZE(infdP);
     while (size) {
-       afs_int32 tlen;
+       size_t tlen;
         tlen = size > 2048 ? 2048 : size;
-        if (FDH_READ(infdP, tbuf, tlen) != tlen) {
-                   sprintf(m->line, "Couldn't read directory %u.%u.%u\n", 
+        if (FDH_PREAD(infdP, tbuf, tlen, offset) != tlen) {
+                   sprintf(m->line, "Couldn't read directory %u.%u.%u\n",
                    infdP->fd_ih->ih_vid,
                    (afs_uint32)(infdP->fd_ih->ih_ino & NAMEI_VNODEMASK),
                    (afs_uint32)(infdP->fd_ih->ih_ino >> NAMEI_UNIQSHIFT));
@@ -292,8 +274,8 @@ copyDir(struct Msg *m, IHandle_t *inh, IHandle_t *outh)
            free(tbuf);
            return EIO;
        }
-       if (FDH_WRITE(outfdP, tbuf, tlen) != tlen) {
-           sprintf(m->line, "Couldn't write directory %u.%u.%u\n", 
+       if (FDH_PWRITE(outfdP, tbuf, tlen, offset) != tlen) {
+           sprintf(m->line, "Couldn't write directory %u.%u.%u\n",
                    outfdP->fd_ih->ih_vid,
                    (afs_uint32)(outfdP->fd_ih->ih_ino & NAMEI_VNODEMASK),
                    (afs_uint32)(outfdP->fd_ih->ih_ino >> NAMEI_UNIQSHIFT));
@@ -304,6 +286,7 @@ copyDir(struct Msg *m, IHandle_t *inh, IHandle_t *outh)
            return EIO;
        }
        size -= tlen;
+       offset += tlen;
     }
     free(tbuf);
     FDH_CLOSE(outfdP);
@@ -311,11 +294,11 @@ copyDir(struct Msg *m, IHandle_t *inh, IHandle_t *outh)
     return 0;
 }
 
-afs_int32 copyVnodes(struct Msg *m, Volume *vol, Volume *newvol, 
-                       afs_int32 class, 
+afs_int32 copyVnodes(struct Msg *m, Volume *vol, Volume *newvol,
+                       afs_int32 class,
                        struct VnodeExtract *list, afs_int32 length,
                        afs_int32 where, afs_uint64 *blocks,
-                       struct VnodeDiskObject *parVnode) 
+                       struct VnodeDiskObject *parVnode)
 {
     afs_int32 i, code = 0;
     char buf[SIZEOF_LARGEDISKVNODE];
@@ -324,20 +307,20 @@ afs_int32 copyVnodes(struct Msg *m, Volume *vol, Volume *newvol,
     FdHandle_t *newfdP = 0;
     struct VnodeClassInfo *vcp = &VnodeClassInfo[class];
     struct VnodeExtract *e;
-    afs_uint64 size;
+    afs_sfsize_t size;
     afs_uint64 offset;
     Inode ino, newino;
 
     fdP = IH_OPEN(vol->vnodeIndex[class].handle);
     if (!fdP) {
-       Log("Couldn't open %s Index of volume %u\n", 
+       Log("Couldn't open %s Index of volume %u\n",
                class ? "small":"large", V_id(vol));
        code = EIO;
        goto Bad_Copy;
     }
     newfdP = IH_OPEN(newvol->vnodeIndex[class].handle);
     if (!newfdP) {
-       Log("Couldn't open %s Index of volume %u\n", 
+       Log("Couldn't open %s Index of volume %u\n",
                class ? "small":"large", V_id(newvol));
        code = EIO;
        goto Bad_Copy;
@@ -349,17 +332,16 @@ afs_int32 copyVnodes(struct Msg *m, Volume *vol, Volume *newvol,
        if (e->flag) {
            afs_uint64 size;
            offset = (e->vN + 1 - class) << (vcp->logSize -1);
-           if (FDH_SEEK(fdP, offset, 0) != offset
-            || FDH_READ(fdP, vnode, vcp->diskSize) != vcp->diskSize) {
-               Log("Couldn't read in %s Index of volume %u at offset\n", 
-                       class ? "small":"large", V_id(vol), offset);
+           if (FDH_PREAD(fdP, vnode, vcp->diskSize, offset) != vcp->diskSize) {
+               Log("Couldn't read in %s Index of volume %u at offset %llu\n",
+                   class ? "small":"large", V_id(vol), offset);
                code = EIO;
                goto Bad_Copy;
            }
            if (e->flag & PARENT) {
-               /* 
-                *   do a preventive copy on write for later update 
-                 */ 
+               /*
+                *   do a preventive copy on write for later update
+                 */
                IHandle_t *newh = 0;
                IHandle_t *h = 0;
 #if defined(NEARINODE_HINT) && !defined(AFS_NAMEI_ENV)
@@ -369,7 +351,7 @@ afs_int32 copyVnodes(struct Msg *m, Volume *vol, Volume *newvol,
 
                newino = IH_CREATE(V_linkHandle(vol), V_device(vol),
                                VPartitionPath(V_partition(vol)),
-                               nearInode, V_parentId(vol), 
+                               nearInode, V_parentId(vol),
                                e->vN, vnode->uniquifier,
                                vnode->dataVersion);
                IH_INIT(newh, V_device(vol), V_parentId(vol), newino);
@@ -381,10 +363,9 @@ afs_int32 copyVnodes(struct Msg *m, Volume *vol, Volume *newvol,
                /* Now update the vnode and write it back to disk */
                VNDISK_SET_INO(vnode, newino);
                vnode->cloned = 0;
-               if (FDH_SEEK(fdP, offset, 0) != offset
-                || FDH_WRITE(fdP, vnode, vcp->diskSize) != vcp->diskSize) {
-                   Log("Couldn't write in %s Index of volume %u at offset\n", 
-                           class ? "small":"large", V_id(vol), offset);
+               if (FDH_PWRITE(fdP, vnode, vcp->diskSize, offset) != vcp->diskSize) {
+                   Log("Couldn't write in %s Index of volume %u at offset %llu\n",
+                       class ? "small":"large", V_id(vol), offset);
                    code = EIO;
                    goto Bad_Copy;
                }
@@ -401,15 +382,15 @@ afs_int32 copyVnodes(struct Msg *m, Volume *vol, Volume *newvol,
                    V_pref(vol,nearInode)
 #endif
                    IH_INIT(h, vol->device, V_parentId(vol), ino);
-                   if (e->parent == where) 
+                   if (e->parent == where)
                        vnode->parent = 1;
                    newino = IH_CREATE(V_linkHandle(newvol), V_device(newvol),
                                VPartitionPath(V_partition(newvol)),
-                               nearInode, V_parentId(newvol), 
+                               nearInode, V_parentId(newvol),
                                e->vN, vnode->uniquifier,
                                vnode->dataVersion);
                    if (!VALID_INO(newino)) {
-                       Log("IH_CREATE failed for %u.%u.%u\n", 
+                       Log("IH_CREATE failed for %u.%u.%u\n",
                            V_id(newvol), e->vN, vnode->uniquifier);
                        code = EIO;
                        goto Bad_Copy;
@@ -428,11 +409,9 @@ afs_int32 copyVnodes(struct Msg *m, Volume *vol, Volume *newvol,
                if (e->flag & CHANGEPARENT)
                    vnode->parent = 1; /* in new root-directory */
                vnode->cloned = 0;
-               if (FDH_SEEK(newfdP, offset, 0) != offset
-                || FDH_WRITE(newfdP, vnode, vcp->diskSize) != vcp->diskSize) {
-                   Log("Couldn't write in %s Index of volume %u to offset\n", 
-                           class ? "small":"large", V_id(newvol), 
-                           offset);
+               if (FDH_PWRITE(newfdP, vnode, vcp->diskSize, offset) != vcp->diskSize) {
+                   Log("Couldn't write in %s Index of volume %u to offset %llu\n",
+                       class ? "small":"large", V_id(newvol), offset);
                    code = EIO;
                    goto Bad_Copy;
                }
@@ -440,27 +419,25 @@ afs_int32 copyVnodes(struct Msg *m, Volume *vol, Volume *newvol,
         }
     }
     /*
-     *  Now copy the root directory from old to new volume 
+     *  Now copy the root directory from old to new volume
      */
     if (class == vLarge) {
        IHandle_t *h, *newh;
         char buf2[SIZEOF_LARGEDISKVNODE];
         struct VnodeDiskObject *vnode2 = (struct VnodeDiskObject *)&buf2;
        afs_uint64 newoffset;
-       
+
        newoffset = vcp->diskSize;
-       if (FDH_SEEK(newfdP, newoffset, 0) != newoffset
-        || FDH_READ(newfdP, vnode2, vcp->diskSize) != vcp->diskSize) {
-           Log("splitvolume: couldn't read in large Index of new volume %u at offset %u\n", 
+       if (FDH_PREAD(newfdP, vnode2, vcp->diskSize, newoffset) != vcp->diskSize) {
+           Log("splitvolume: couldn't read in large Index of new volume %u at offset %u\n",
                    V_id(newvol), vcp->diskSize);
            code = EIO;
            goto Bad_Copy;
        }
        offset = (where + 1 - class) << (vcp->logSize -1);
-       if (FDH_SEEK(fdP, offset, 0) != offset
-        || FDH_READ(fdP, vnode, vcp->diskSize) != vcp->diskSize) {
-           Log("Couldn't read in large Index of old volume %u at offset\n", 
-                       V_id(vol), offset);
+       if (FDH_PREAD(fdP, vnode, vcp->diskSize, offset) != vcp->diskSize) {
+           Log("Couldn't read in large Index of old volume %u at offset %llu\n",
+               V_id(vol), offset);
            code = EIO;
            goto Bad_Copy;
        }
@@ -472,8 +449,9 @@ afs_int32 copyVnodes(struct Msg *m, Volume *vol, Volume *newvol,
        IH_INIT(newh, newvol->device, V_parentId(newvol), newino);
        code = copyDir(m, h, newh);
        if (code) {
-           Log("splitvolume: copyDir failed for new root from %u.u.u to %u.1.1\n", 
-                       V_id(vol), where, vnode->uniquifier, V_id(newvol));
+           Log("splitvolume: copyDir failed for new root from "
+               "%u.%u.%u to %u.1.1\n",
+               V_id(vol), where, vnode->uniquifier, V_id(newvol));
            code = EIO;
            goto Bad_Copy;
        }
@@ -482,12 +460,11 @@ afs_int32 copyVnodes(struct Msg *m, Volume *vol, Volume *newvol,
        vnode->cloned = 0;
        vnode->parent = vnode2->parent;
        vnode->serverModifyTime = vnode2->serverModifyTime;
-       if (FDH_SEEK(newfdP, newoffset, 0) != newoffset
-         || FDH_WRITE(newfdP, vnode, vcp->diskSize) != vcp->diskSize) {
-           Log("splitvolume: couldn't write in large Index of %u at offset %u\n", 
+       if (FDH_PWRITE(newfdP, vnode, vcp->diskSize, newoffset) != vcp->diskSize) {
+           Log("splitvolume: couldn't write in large Index of %u at offset %u\n",
                    V_id(newvol), vcp->diskSize);
            code = EIO;
-       } 
+       }
     }
 Bad_Copy:
     if (fdP)
@@ -498,7 +475,7 @@ Bad_Copy:
 }
 
 static afs_int32
-findName(Volume *vol, struct VnodeDiskObject *vd, afs_uint32 vN, 
+findName(Volume *vol, struct VnodeDiskObject *vd, afs_uint32 vN,
         afs_uint32 un, char *name,afs_int32 length)
 {
     afs_int32 code;
@@ -508,13 +485,13 @@ findName(Volume *vol, struct VnodeDiskObject *vd, afs_uint32 vN,
     ino = VNDISK_GET_INO(vd);
     SetSalvageDirHandle(&dir, V_id(vol), V_device(vol), ino);
 
-    code = InverseLookup(&dir, vN, un, name, length);
-    FidZap(&dir);   
+    code = afs_dir_InverseLookup(&dir, vN, un, name, length);
+    FidZap(&dir);
     return code;
 }
 
 static afs_int32
-createMountpoint(Volume *vol, Volume *newvol, struct VnodeDiskObject *parent, 
+createMountpoint(Volume *vol, Volume *newvol, struct VnodeDiskObject *parent,
                afs_uint32 vN,  struct VnodeDiskObject *vd, char *name)
 {
     afs_int32 code;
@@ -523,7 +500,8 @@ createMountpoint(Volume *vol, Volume *newvol, struct VnodeDiskObject *parent,
     IHandle_t *h;
     struct VnodeDiskObject vnode;
     FdHandle_t *fdP, *fdP2;
-    afs_uint64 offset, size;
+    afs_uint64 size;
+    afs_foff_t offset;
     afs_int32 class = vSmall;
     struct VnodeClassInfo *vcp = &VnodeClassInfo[class];
 #if defined(NEARINODE_HINT) && !defined(AFS_NAMEI_ENV)
@@ -533,6 +511,7 @@ createMountpoint(Volume *vol, Volume *newvol, struct VnodeDiskObject *parent,
     struct timeval now;
     afs_uint32 newvN;
     char symlink[32];
+    ssize_t rc;
 
     FT_GetTimeOfDay(&now, 0);
     fdP = IH_OPEN(vol->vnodeIndex[vSmall].handle);
@@ -541,13 +520,18 @@ createMountpoint(Volume *vol, Volume *newvol, struct VnodeDiskObject *parent,
        return EIO;
     }
     offset = vcp->diskSize;
-    if (FDH_SEEK(fdP, offset, 0) != offset) {
-       Log("split volume: error seeking in small vnode index of %u\n", V_id(vol));
-       return EIO;
-    }
     while (1) {
-       if (FDH_READ(fdP, &vnode, vcp->diskSize) != vcp->diskSize)
-           break;
+       rc = FDH_PREAD(fdP, &vnode, vcp->diskSize, offset);
+       if (rc != vcp->diskSize) {
+           if (rc < 0) {
+               Log("split volume: error reading small vnode index of %u\n", V_id(vol));
+               return EIO;
+            }
+            if (rc == 0)
+                break;
+            if (rc < vcp->diskSize)
+                break;
+       }
        if (vnode.type == vNull)
            break;
        offset += vcp->diskSize;
@@ -573,19 +557,18 @@ createMountpoint(Volume *vol, Volume *newvol, struct VnodeDiskObject *parent,
     newino = IH_CREATE(V_linkHandle(vol), V_device(vol),
                VPartitionPath(V_partition(vol)), nearInode,
                 V_parentId(vol), newvN, vnode.uniquifier, 1);
-    
+
     IH_INIT(h, V_device(vol), V_parentId(vol), newino);
     fdP2 = IH_OPEN(h);
     if (!fdP2) {
-       Log("split volume: couldn't open inode for mountpoint %u.%u.%u\n", 
+       Log("split volume: couldn't open inode for mountpoint %u.%u.%u\n",
                V_id(vol), newvN, vnode.uniquifier);
        return EIO;
     }
-    FDH_SEEK(fdP2, 0, 0);
     sprintf(symlink, "#%s", V_name(newvol));
     size = strlen(symlink) + 1;
-    if (FDH_WRITE(fdP2, symlink, size) != size) {
-       Log("split volume: couldn't write mountpoint %u.%u.%u\n", 
+    if (FDH_PWRITE(fdP2, symlink, size, 0) != size) {
+       Log("split volume: couldn't write mountpoint %u.%u.%u\n",
                V_id(vol), newvN, vnode.uniquifier);
        return EIO;
     }
@@ -595,10 +578,9 @@ createMountpoint(Volume *vol, Volume *newvol, struct VnodeDiskObject *parent,
     VNDISK_SET_LEN(&vnode, size);
 #ifndef AFS_RXOSD_SUPPORT
     vnode.vnodeMagic = SMALLVNODEMAGIC;
-#endif    
-    if (FDH_SEEK(fdP, offset, 0) != offset
-      || FDH_WRITE(fdP, &vnode, vcp->diskSize) != vcp->diskSize) {
-       Log("split volume: couldn't write vnode for mountpoint %u.%u.%u\n", 
+#endif
+    if (FDH_PWRITE(fdP, &vnode, vcp->diskSize, offset) != vcp->diskSize) {
+       Log("split volume: couldn't write vnode for mountpoint %u.%u.%u\n",
                V_id(vol), newvN, vnode.uniquifier);
        return EIO;
     }
@@ -615,23 +597,22 @@ createMountpoint(Volume *vol, Volume *newvol, struct VnodeDiskObject *parent,
     ino = VNDISK_GET_INO(parent);
     SetSalvageDirHandle(&dir, V_id(vol), V_device(vol), ino);
 
-    code = Delete(&dir, name);
+    code = afs_dir_Delete(&dir, name);
     if (code) {
        Log("splitvolume: couldn't delete directory entry for %s in %u.%u.%u, code = %d\n",
                        name, V_id(vol), vN, parent->uniquifier, code);
        return code;
     }
-    code = Create(&dir, name, &fid);
-    FidZap(&dir);   
+    code = afs_dir_Create(&dir, name, &fid);
+    FidZap(&dir);
+
     class = vLarge;
     vcp = &VnodeClassInfo[class];
     fdP = IH_OPEN(vol->vnodeIndex[class].handle);
     offset = (vN + 1 - class) << (vcp->logSize -1);
     parent->dataVersion++;
-    if (FDH_SEEK(fdP, offset, 0) != offset
-      || FDH_WRITE(fdP, parent, vcp->diskSize) != vcp->diskSize) {
-       Log("split volume: couldn't write vnode for parent directory %u.%u.%u\n", 
+    if (FDH_PWRITE(fdP, parent, vcp->diskSize, offset) != vcp->diskSize) {
+       Log("split volume: couldn't write vnode for parent directory %u.%u.%u\n",
                V_id(vol), vN, parent->uniquifier);
        return EIO;
     }
@@ -639,8 +620,8 @@ createMountpoint(Volume *vol, Volume *newvol, struct VnodeDiskObject *parent,
     return code;
 }
 
-static afs_int32 
-deleteVnodes(Volume *vol, afs_int32 class, 
+static afs_int32
+deleteVnodes(Volume *vol, afs_int32 class,
             struct VnodeExtract *list, afs_int32 length,
             afs_uint64 *blocks)
 {
@@ -650,33 +631,25 @@ deleteVnodes(Volume *vol, afs_int32 class,
     FdHandle_t *fdP = 0;
     struct VnodeClassInfo *vcp = &VnodeClassInfo[class];
     struct VnodeExtract *e;
-    afs_uint64 size;
+    afs_sfsize_t size;
     afs_uint64 offset;
     Inode ino;
 
     fdP = IH_OPEN(vol->vnodeIndex[class].handle);
     if (!fdP) {
-       Log("Couldn't open %s Index of volume %u\n", 
+       Log("Couldn't open %s Index of volume %u\n",
                class ? "small":"large", V_id(vol));
        code = EIO;
        goto Bad_Delete;
     }
-    size = FDH_SIZE(fdP);
 
     for (i=0; i<length; i++) {
        e = &list[i];
        if (e->flag & NEEDED) {
-           afs_uint64 size;
            offset = (e->vN + 1 - class) << (vcp->logSize -1);
-           if (FDH_SEEK(fdP, offset, 0) != offset) {
-               Log("Couldn't seek in %s Index of volume %u to offset\n", 
-                       class ? "small":"large", V_id(vol), offset);
-               code = EIO;
-               goto Bad_Delete;
-           }
-           if (FDH_READ(fdP, vnode, vcp->diskSize) != vcp->diskSize) {
-               Log("Couldn't read in %s Index of volume %u at offset\n", 
-                       class ? "small":"large", V_id(vol), offset);
+           if (FDH_PREAD(fdP, vnode, vcp->diskSize, offset) != vcp->diskSize) {
+               Log("Couldn't read in %s Index of volume %u at offset %llu\n",
+                   class ? "small":"large", V_id(vol), offset);
                code = EIO;
                goto Bad_Delete;
            }
@@ -694,11 +667,9 @@ deleteVnodes(Volume *vol, afs_int32 class,
            }
            memset(vnode, 0, vcp->diskSize);
            vnode->type = vNull;
-           if (FDH_SEEK(fdP, offset, 0) != offset 
-             || FDH_WRITE(fdP, vnode, vcp->diskSize) != vcp->diskSize) {
-                  Log("Couldn't write in %s Index of volume %u to offset\n", 
-                           class ? "small":"large", V_id(vol), 
-                           offset);
+           if (FDH_PWRITE(fdP, vnode, vcp->diskSize, offset) != vcp->diskSize) {
+                  Log("Couldn't write in %s Index of volume %u to offset %llu\n",
+                      class ? "small":"large", V_id(vol), offset);
            }
         }
     }
@@ -708,8 +679,8 @@ Bad_Delete:
     return code;
 }
 
-afs_int32 
-split_volume(struct rx_call *call, Volume *vol, Volume *newvol, 
+afs_int32
+split_volume(struct rx_call *call, Volume *vol, Volume *newvol,
             afs_uint32 where, afs_int32 verbose)
 {
     Error code = 0;
@@ -731,22 +702,22 @@ split_volume(struct rx_call *call, Volume *vol, Volume *newvol,
     m->call = call;
     m->verbose = verbose;
 
-    /* 
+    /*
      *  First step: planning
      *
      *  Find out which directories will belong to the new volume
      *
      */
     if (verbose) {
-       sprintf(m->line, 
+       sprintf(m->line,
                "1st step: extract vnode essence from large vnode file\n");
        rx_Write(m->call, m->line, strlen(m->line));
     }
 
-    code = ExtractVnodes(m, vol, vLarge, &dirList, &dl, where, rootVnode, 
+    code = ExtractVnodes(m, vol, vLarge, &dirList, &dl, where, rootVnode,
                        &parent, parVnode);
     if (code) {
-       sprintf(m->line, 
+       sprintf(m->line,
                "ExtractVnodes failed for %u for directories with code %d\n",
                V_id(vol), code);
        rx_Write(m->call, m->line, strlen(m->line));
@@ -755,31 +726,31 @@ split_volume(struct rx_call *call, Volume *vol, Volume *newvol,
 
     if (verbose) {
        sprintf(m->line, "2nd step: look for name of vnode %u in directory %u.%u.%u\n",
-               where, V_id(vol), parent, parVnode->uniquifier); 
+               where, V_id(vol), parent, parVnode->uniquifier);
        rx_Write(m->call, m->line, strlen(m->line));
     }
-    code = findName(vol, parVnode, where, rootVnode->uniquifier, 
+    code = findName(vol, parVnode, where, rootVnode->uniquifier,
                     name,  sizeof(name));
     if (code) {
-       sprintf(m->line, 
+       sprintf(m->line,
                "splitvolume: could'nt find name of %u in directory %u.%u.%u.\n",
-               where, V_id(vol), parent, parVnode->uniquifier); 
+               where, V_id(vol), parent, parVnode->uniquifier);
        rx_Write(m->call, m->line, strlen(m->line));
        return code;
     }
     if (verbose) {
-       sprintf(m->line, "name of %u is %s\n", where, name); 
+       sprintf(m->line, "name of %u is %s\n", where, name);
        rx_Write(m->call, m->line, strlen(m->line));
     }
 
     if (verbose) {
-       sprintf(m->line, "3rd step: find all directory vnodes belonging to the subtree under %u \"%s\"\n", 
+       sprintf(m->line, "3rd step: find all directory vnodes belonging to the subtree under %u \"%s\"\n",
                        where, name);
        rx_Write(m->call, m->line, strlen(m->line));
     }
     code = FindVnodes(m, where, dirList, dl, dirList, dl, &dirsNeeded, 1);
     if (code) {
-       sprintf(m->line, 
+       sprintf(m->line,
                "FindVnodes for directories failed with code %d\n", code);
        rx_Write(m->call, m->line, strlen(m->line));
        return code;
@@ -791,20 +762,20 @@ split_volume(struct rx_call *call, Volume *vol, Volume *newvol,
     }
     code = ExtractVnodes(m, vol, vSmall, &fileList, &fl, where, 0, 0, 0);
     if (code) {
-       sprintf(m->line, 
+       sprintf(m->line,
                "ExtractVnodes failed for %u for files with code %d\n",
                V_id(vol), code);
        rx_Write(m->call, m->line, strlen(m->line));
        return code;
     }
     if (verbose) {
-       sprintf(m->line, "5th step: find all small vnodes belonging to the subtree under %u \"%s\"\n", 
+       sprintf(m->line, "5th step: find all small vnodes belonging to the subtree under %u \"%s\"\n",
                        where, name);
        rx_Write(m->call, m->line, strlen(m->line));
     }
     FindVnodes(m, where, fileList, fl, dirList, dl, &filesNeeded, 0);
 
-    /* 
+    /*
      *  Third step: create hard links for all files needed
      *
      */
@@ -815,15 +786,15 @@ split_volume(struct rx_call *call, Volume *vol, Volume *newvol,
        sprintf(m->line, "6th step: create hard links in the AFSIDat tree between files of the old and new volume\n");
        rx_Write(m->call, m->line, strlen(m->line));
     }
-    code = copyVnodes(m, vol, newvol, 1, fileList, fl, where, &blocks, 0); 
+    code = copyVnodes(m, vol, newvol, 1, fileList, fl, where, &blocks, 0);
     if (code) {
        sprintf(m->line, "copyVnodes for files failed with code %d\n", code);
        rx_Write(m->call, m->line, strlen(m->line));
        return code;
     }
-       
-    /* 
-     *  Forth step: create hard links for all directories and copy 
+
+    /*
+     *  Forth step: create hard links for all directories and copy
      *  split directory to new root directory
      */
 
@@ -832,7 +803,7 @@ split_volume(struct rx_call *call, Volume *vol, Volume *newvol,
                where);
        rx_Write(m->call, m->line, strlen(m->line));
     }
-    code = copyVnodes(m, vol, newvol, 0, dirList, dl, where, &blocks, parVnode); 
+    code = copyVnodes(m, vol, newvol, 0, dirList, dl, where, &blocks, parVnode);
     if (code) {
        sprintf(m->line, "copyVnodes for directories failed with code %d\n", code);
        rx_Write(m->call, m->line, strlen(m->line));
@@ -867,7 +838,7 @@ split_volume(struct rx_call *call, Volume *vol, Volume *newvol,
        sprintf(m->line, "9th step: create mountpoint \"%s\" for new volume in old volume's directory %u.\n", name, parent);
        rx_Write(m->call, m->line, strlen(m->line));
     }
-    
+
     code = createMountpoint(vol, newvol, parVnode, parent, rootVnode, name);
     if (code) {
        sprintf(m->line, "createMountpoint failed with code %d\n", code);
@@ -878,7 +849,7 @@ split_volume(struct rx_call *call, Volume *vol, Volume *newvol,
      * Now both volumes should be ready and consistent, but the old volume
      * contains still the vnodes and data we transferred into the new one.
      * Delete orphaned vnodes and data.
-     */ 
+     */
 
     blocks = 0;
     if (verbose) {