Whamcloud - gitweb
LU-2838 build: Syntax issues in sources
[fs/lustre-release.git] / libcfs / libcfs / darwin / darwin-fs.c
index 2234082..88b9b1e 100644 (file)
@@ -1,6 +1,4 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
  * GPL HEADER START
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -89,48 +87,44 @@ vnode_size(vnode_t vp, off_t *sizep, vfs_context_t ctx)
  * not so important to implement for MT.
  */
 int
-kern_file_size(struct cfs_kern_file *fp, off_t *psize) 
+kern_file_size(struct cfs_kern_file *fp, off_t *psize)
 {
-        int     error;
-        off_t   size;
+       int     error;
+       off_t   size;
 
-        error = vnode_size(fp->f_vp, &size, fp->f_ctxt);
-        if (error) 
-                return error;
+       error = vnode_size(fp->f_vp, &size, fp->f_ctxt);
+       if (error)
+               return error;
 
-        if (psize)
-                *psize = size;
-        return 0;
+       if (psize)
+               *psize = size;
+       return 0;
 }
 
 struct cfs_kern_file *
-kern_file_open(const char * filename, int uflags, int mode, int *err)
+kern_file_open(const char *filename, int uflags, int mode)
 {
-        struct cfs_kern_file    *fp;
-        vnode_t         vp;
-        int             error;
-
-        fp = (struct cfs_kern_file *)_MALLOC(sizeof(struct cfs_kern_file), M_TEMP, M_WAITOK);
-        if (fp == NULL) {
-                if (err != NULL)
-                        *err = -ENOMEM;
-                return NULL;
-        }
-        fp->f_flags = FFLAGS(uflags);
-        fp->f_ctxt = vfs_context_create(NULL);
-
-        if ((error = vnode_open(filename, fp->f_flags, 
-                                mode, 0, &vp, fp->f_ctxt))){
-                if (err != NULL)
-                        *err = -error;
-                _FREE(fp, M_TEMP);
-        } else {
-                if (err != NULL)
-                        *err = 0;
-                fp->f_vp = vp;
-        }
+       struct cfs_kern_file    *fp;
+       vnode_t                 vp;
+       int                     error;
+
+       fp = (struct cfs_kern_file *)_MALLOC(sizeof(struct cfs_kern_file),
+                                            M_TEMP, M_WAITOK);
+       if (fp == NULL)
+               return ERR_PTR(-ENOMEM);
 
-        return fp;
+       fp->f_flags = FFLAGS(uflags);
+       fp->f_ctxt = vfs_context_create(NULL);
+
+       error = vnode_open(filename, fp->f_flags, mode, 0, &vp, fp->f_ctxt);
+       if (error != 0) {
+               _FREE(fp, M_TEMP);
+               return ERR_PTR(-error);
+       } else {
+               fp->f_vp = vp;
+       }
+
+       return fp;
 }
 
 int
@@ -212,31 +206,29 @@ kern_file_size(struct file *fp, off_t *size)
         return 0;
 }
 
-cfs_file_t *
-kern_file_open(const char * filename, int flags, int mode, int *err)
+struct file *
+kern_file_open(const char *filename, int flags, int mode)
 {
-       struct nameidata nd;
-       cfs_file_t      *fp;
+       struct nameidata        nd;
+       struct file             *fp;
        register struct vnode   *vp;
        int                     rc;
        extern struct fileops   vnops;
        extern int nfiles;
-        CFS_DECL_CONE_DATA;
+       CFS_DECL_CONE_DATA;
 
-        CFS_CONE_IN;
+       CFS_CONE_IN;
        nfiles++;
-       MALLOC_ZONE(fp, cfs_file_t *, sizeof(cfs_file_t), M_FILE, M_WAITOK|M_ZERO);
-       bzero(fp, sizeof(cfs_file_t));
+       MALLOC_ZONE(fp, struct file *, sizeof(file_t), M_FILE, M_WAITOK|M_ZERO);
+       bzero(fp, sizeof(*fp));
        fp->f_count = 1;
-        LIST_CIRCLE(fp, f_list);
+       LIST_CIRCLE(fp, f_list);
        NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, (char *)filename, current_proc());
        if ((rc = vn_open(&nd, flags, mode)) != 0){
-                printf("filp_open failed at (%d)\n", rc);
-                if (err != NULL)
-                        *err = rc;
-                FREE_ZONE(fp, sizeof *fp, M_FILE);
-                CFS_CONE_EX;
-               return NULL;
+               printf("filp_open failed at (%d)\n", rc);
+               FREE_ZONE(fp, sizeof(*fp), M_FILE);
+               CFS_CONE_EX;
+               return ERR_PTR(rc);
        }
        vp = nd.ni_vp;
        fp->f_flag = flags & FMASK;
@@ -253,13 +245,13 @@ kern_file_open(const char * filename, int flags, int mode, int *err)
         * we should release the lock before return
         */
        VOP_UNLOCK(vp, 0, current_proc());
-        CFS_CONE_EX;
+       CFS_CONE_EX;
 
        return fp;
 }
 
 static int
-frele_internal(cfs_file_t *fp)
+frele_internal(struct file *fp)
 {
        if (fp->f_count == (short)0xffff)
                panic("frele of lustre: stale");
@@ -269,10 +261,10 @@ frele_internal(cfs_file_t *fp)
 }
 
 int
-kern_file_close (cfs_file_t *fp)
+kern_file_close(struct file *fp)
 {
        struct vnode    *vp;
-        CFS_DECL_CONE_DATA;
+       CFS_DECL_CONE_DATA;
        
        if (fp == NULL)
                return 0;
@@ -311,7 +303,7 @@ extern void bwillwrite(void);
  * Write buffer to filp inside kernel
  */
 int
-kern_file_write (cfs_file_t *fp, void *buf, size_t nbyte, loff_t *pos)
+kern_file_write(struct file *fp, void *buf, size_t nbyte, loff_t *pos)
 {
        struct uio auio;
        struct iovec aiov;
@@ -367,7 +359,7 @@ kern_file_write (cfs_file_t *fp, void *buf, size_t nbyte, loff_t *pos)
  * Read from filp inside kernel
  */
 int
-kern_file_read (cfs_file_t *fp, void *buf, size_t nbyte, loff_t *pos)
+kern_file_read(struct file *fp, void *buf, size_t nbyte, loff_t *pos)
 {
        struct uio auio;
        struct iovec aiov;
@@ -411,7 +403,7 @@ kern_file_read (cfs_file_t *fp, void *buf, size_t nbyte, loff_t *pos)
 }
 
 int
-kern_file_sync (cfs_file_t *fp)
+kern_file_sync(struct file *fp)
 {
        struct vnode *vp = (struct vnode *)fp->f_data;
        struct proc *p = current_proc();