check raw mode to see if cr-nl is needed (from serge@arpa)
[unix-history] / usr / src / sys / ufs / lfs / lfs_vfsops.c
index d7ed0dd..66e84b2 100644 (file)
@@ -1,16 +1,22 @@
-/*     lfs_vfsops.c    6.6     84/07/08        */
+/*
+ * Copyright (c) 1982 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ *     @(#)lfs_vfsops.c        6.11 (Berkeley) %G%
+ */
 
 
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/inode.h"
-#include "../h/proc.h"
-#include "../h/fs.h"
-#include "../h/buf.h"
-#include "../h/mount.h"
-#include "../h/file.h"
-#include "../h/conf.h"
+#include "param.h"
+#include "systm.h"
+#include "dir.h"
+#include "user.h"
+#include "inode.h"
+#include "proc.h"
+#include "fs.h"
+#include "buf.h"
+#include "mount.h"
+#include "file.h"
+#include "conf.h"
 
 smount()
 {
 
 smount()
 {
@@ -35,16 +41,21 @@ smount()
        ip = namei(ndp);
        if (ip == NULL)
                return;
        ip = namei(ndp);
        if (ip == NULL)
                return;
-       if (ip->i_count!=1 || (ip->i_mode&IFMT) != IFDIR) {
+       if (ip->i_count != 1) {
                iput(ip);
                u.u_error = EBUSY;
                return;
        }
                iput(ip);
                u.u_error = EBUSY;
                return;
        }
+       if ((ip->i_mode&IFMT) != IFDIR) {
+               iput(ip);
+               u.u_error = ENOTDIR;
+               return;
+       }
        fs = mountfs(dev, uap->ronly, ip);
        if (fs == 0)
                return;
        (void) copyinstr(uap->freg, fs->fs_fsmnt, sizeof(fs->fs_fsmnt)-1, &len);
        fs = mountfs(dev, uap->ronly, ip);
        if (fs == 0)
                return;
        (void) copyinstr(uap->freg, fs->fs_fsmnt, sizeof(fs->fs_fsmnt)-1, &len);
-       bzero(fs->fs_fsmnt, sizeof (fs->fs_fsmnt) - len);
+       bzero(fs->fs_fsmnt + len, sizeof (fs->fs_fsmnt) - len);
 }
 
 /* this routine has races if running twice */
 }
 
 /* this routine has races if running twice */
@@ -62,11 +73,13 @@ mountfs(dev, ronly, ip)
        caddr_t space;
        int i, size;
        register error;
        caddr_t space;
        int i, size;
        register error;
+       int needclose = 0;
 
        error =
            (*bdevsw[major(dev)].d_open)(dev, ronly ? FREAD : FREAD|FWRITE);
        if (error)
                goto out;
 
        error =
            (*bdevsw[major(dev)].d_open)(dev, ronly ? FREAD : FREAD|FWRITE);
        if (error)
                goto out;
+       needclose = 1;
        tp = bread(dev, SBLOCK, SBSIZE);
        if (tp->b_flags & B_ERROR)
                goto out;
        tp = bread(dev, SBLOCK, SBSIZE);
        if (tp->b_flags & B_ERROR)
                goto out;
@@ -117,7 +130,7 @@ found:
                        goto out;
                }
                bcopy((caddr_t)tp->b_un.b_addr, space, (u_int)size);
                        goto out;
                }
                bcopy((caddr_t)tp->b_un.b_addr, space, (u_int)size);
-               fs->fs_csp[i / fs->fs_frag] = (struct csum *)space;
+               fs->fs_csp[fragstoblks(fs, i)] = (struct csum *)space;
                space += size;
                brelse(tp);
                tp = 0;
                space += size;
                brelse(tp);
                tp = 0;
@@ -140,6 +153,9 @@ out:
                brelse(bp);
        if (tp)
                brelse(tp);
                brelse(bp);
        if (tp)
                brelse(tp);
+       if (needclose)
+               (*bdevsw[major(dev)].d_close)(dev, ronly ? FREAD : FREAD|FWRITE);
+       binval(dev);
        u.u_error = error;
        return (0);
 }
        u.u_error = error;
        return (0);
 }
@@ -251,8 +267,11 @@ getmdev(pdev, fname)
        ndp->ni_segflg = UIO_USERSPACE;
        ndp->ni_dirp = fname;
        ip = namei(ndp);
        ndp->ni_segflg = UIO_USERSPACE;
        ndp->ni_dirp = fname;
        ip = namei(ndp);
-       if (ip == NULL)
+       if (ip == NULL) {
+               if (u.u_error == ENOENT)
+                       return (ENODEV); /* needs translation */
                return (u.u_error);
                return (u.u_error);
+       }
        if ((ip->i_mode&IFMT) != IFBLK) {
                iput(ip);
                return (ENOTBLK);
        if ((ip->i_mode&IFMT) != IFBLK) {
                iput(ip);
                return (ENOTBLK);