usd: Tidy header includes
[openafs.git] / src / usd / usd_file.c
index 93279b4..8b71e30 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright 2000, International Business Machines Corporation and others.
  * All Rights Reserved.
- * 
+ *
  * This software has been released under the terms of the IBM Public
  * License.  For details, see the LICENSE file in the top-level source
  * directory or online at http://www.openafs.org/dl/license10.html
 #include <afsconfig.h>
 #include <afs/param.h>
 
-RCSID
-    ("$Header$");
+#include <roken.h>
 
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <sys/stat.h>
 #if defined(AFS_AIX_ENV)
 #include <sys/tape.h>
 #include <sys/statfs.h>
@@ -25,16 +19,16 @@ RCSID
 #ifdef AFS_DARWIN_ENV
 #include <sys/ioccom.h>
 #endif
-#if defined(AFS_DUX40_ENV) || defined(AFS_OBSD_ENV) || defined(AFS_NBSD_ENV)
+#if defined(AFS_DUX40_ENV) || defined(AFS_OBSD_ENV) || defined(AFS_NBSD_ENV) || (defined(AFS_DARWIN_ENV) && !defined(AFS_DARWIN100_ENV))
 #include <sys/ioctl.h>
 #endif
+#ifndef AFS_DARWIN100_ENV
 #include <sys/mtio.h>
+#endif
 #endif /* AFS_AIX_ENV */
 
-#include <string.h>
-#include <stdlib.h>
+#include <afs/afs_assert.h>
 
-#include <afs/debug.h>
 #include "usd.h"
 
 #ifdef O_LARGEFILE
@@ -77,7 +71,7 @@ static int
 usd_FileRead(usd_handle_t usd, char *buf, afs_uint32 nbytes,
             afs_uint32 * xferdP)
 {
-    int fd = (int)(usd->handle);
+    int fd = (intptr_t)(usd->handle);
     int got;
 
     got = read(fd, buf, nbytes);
@@ -95,7 +89,7 @@ static int
 usd_FileWrite(usd_handle_t usd, char *buf, afs_uint32 nbytes,
              afs_uint32 * xferdP)
 {
-    int fd = (int)(usd->handle);
+    int fd = (intptr_t)(usd->handle);
     int sent;
 
     sent = write(fd, buf, nbytes);
@@ -115,7 +109,7 @@ static int
 usd_FileSeek(usd_handle_t usd, afs_hyper_t reqOff, int whence,
             afs_hyper_t * curOffP)
 {
-    int fd = (int)(usd->handle);
+    int fd = (intptr_t)(usd->handle);
     osi_lloff_t lloff;
 
     if (!osi_hFitsInOff(reqOff, lloff))
@@ -134,7 +128,7 @@ usd_FileSeek(usd_handle_t usd, afs_hyper_t reqOff, int whence,
 static int
 usd_FileIoctl(usd_handle_t usd, int req, void *arg)
 {
-    int fd = (int)(usd->handle);
+    int fd = (intptr_t)(usd->handle);
 #ifdef O_LARGEFILE
     struct stat64 info;
 #else /* O_LARGEFILE */
@@ -211,6 +205,9 @@ usd_FileIoctl(usd_handle_t usd, int req, void *arg)
 
     case USD_IOCTL_TAPEOPERATION:
        {
+#ifdef AFS_DARWIN100_ENV
+           code = EOPNOTSUPP;
+#else
            usd_tapeop_t *tapeOpp = (usd_tapeop_t *) arg;
 #if defined(AFS_AIX_ENV)
            struct stop os_tapeop;
@@ -257,7 +254,7 @@ usd_FileIoctl(usd_handle_t usd, int req, void *arg)
 
            code = ioctl(fd, MTIOCTOP, &os_tapeop);
 #endif /* AFS_AIX_ENV */
-
+#endif
            if (code == -1) {
                code = errno;
            } else {
@@ -287,7 +284,7 @@ usd_FileIoctl(usd_handle_t usd, int req, void *arg)
 static int
 usd_FileClose(usd_handle_t usd)
 {
-    int fd = (int)(usd->handle);
+    int fd = (intptr_t)(usd->handle);
     int code = 0;
     int ccode;
 
@@ -348,7 +345,7 @@ usd_FileOpen(const char *path, int flags, int mode, usd_handle_t * usdP)
 
     usd = (usd_handle_t) malloc(sizeof(*usd));
     memset(usd, 0, sizeof(*usd));
-    usd->handle = (void *)fd;
+    usd->handle = (void *)(intptr_t)fd;
     usd->read = usd_FileRead;
     usd->write = usd_FileWrite;
     usd->seek = usd_FileSeek;
@@ -383,10 +380,10 @@ usd_FileOpen(const char *path, int flags, int mode, usd_handle_t * usdP)
 
        /* If we're trying to obtain a write lock on a real disk, then the
         * aggregate must not be attached by the kernel.  If so, unlock it
-        * and fail. 
+        * and fail.
         * WARNING: The code to check for the above has been removed when this
         * file was ported from DFS src. It should be put back if
-        * this library is used to access hard disks 
+        * this library is used to access hard disks
         */
     }