Giter VIP home page Giter VIP logo

gnats-nb's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

gnats-nb's Issues

mount uses mount_* for external fs types, umount should too.

Metadata

  • Number: 698
  • Originator: Simon J. Gerraty <[email protected]>
  • Arrived: Wed Jan 04 15:20:03 +0000 1995
  • Last modified: Mon Mar 20 17:53:32 +0000 2006
  • Environment: System: NetBSD bilbo.dn.itg.telecom.com.au 1.0 NetBSD 1.0 (FIREWALL) #5: Tue Dec 20 15:31:28 EST 1994 [email protected]:/src/sys/arch/i386/compile/FIREWALL i386

Description


When implementing a new remote filesystem type, the mount_<type> facility
supported by /sbin/mount is extremely useful.
However, it would be even better if /sbin/umount provided the same feature.

I note that SunOS's /usr/etc/umount appears to have this facility.

I can certainly add the functionality to umount if you like.

Audit trail


State-Changed-From-To: open->analyzed 
State-Changed-By: cgd 
State-Changed-When: Wed Jul 12 02:25:52 EDT 1995 
State-Changed-Why:  
analyzed. 
the same statement is true of: 
newfs (!! should take a -t to determine type, pass all args on, 
default to type == ffs if no -t given.  probably safe 
to require that 't' should be first arg.  maybe 'T' 
for compatibility with current arguments?) 
fsck (top-level program should parse fstab, be responsponsible 
for picking file systems to check (i.e. pass number stuff), 
and farmint out responsibilities to per-fs programs; 
current fsck should be fsck_ffs.) 
dumpfs (same comments as newfs, mostly, i think.) 

additionally, dump and restore should have equivalents for other file systems, 
as should clri and tunefs, and the current programs should be renamed to 
reflect their FFS-ness. 


Responsible-Changed-From-To: bin-bug-people->cgd 
Responsible-Changed-By: cgd 
Responsible-Changed-When: Wed Jul 12 02:25:52 EDT 1995 
Responsible-Changed-Why:  
"mybug!" 
Responsible-Changed-From-To: cgd->bin-bug-people 
Responsible-Changed-By: cgd 
Responsible-Changed-When: Sat Aug 19 05:55:17 EDT 1995 
Responsible-Changed-Why:  
unclaim. 
State-Changed-From-To: analyzed->feedback 
State-Changed-By: fair 
State-Changed-When: Thu Mar 11 02:48:55 PST 1999 
State-Changed-Why:  
what other things are required for an unmount besides calling the syscall? 
Given that some of the items in here have been acted upon, but most haven't 
in the four years this PR has been open, I'd say this issue was not pressing 
enough to warrant action. Unless feedback arrives to the contrary, this PR 
should be closed. 

From: "Simon J. Gerraty" <[email protected]>
To: [email protected], [email protected]
Cc: [email protected], [email protected]
Subject: Re: bin/698 
Date: Sun, 06 Jun 1999 23:44:18 +1000

 Is it perhaps the case that feedback should be sent to gnats-bugs
 rather than gnats-admin?  If so, the fact that mail requesting
 feedback includes gnats-admin but not gnats-bugs in the cc or reply-to
 list should be considered a bug.

 Clarification either way would be handy.

 --sjg

 > Date: Sun, 06 Jun 1999 23:35:44 +1000
 > From: "Simon J. Gerraty" <[email protected]>
 > 
 > I have no idea why the following does not appear in the records for
 > this PR - I'm beginig to think that much of the feedback I've sent
 > over the years has landed in the bit bucket.
 > 
 > --sjg
 > ------- Forwarded Message
 > 
 > Delivery-Date: Mon, 15 Mar 1999 00:55:34 +1100
 > Received: (from uucp@localhost) by zen.quick.com.au (8.8.8/8.7.3) id AAA11087; Mon, 15 Mar 1999 00:55:33 +1100 (EST)
 > Message-Id: <[email protected]>
 > Received: from localhost(127.0.0.1), claiming to be "zen.quick.com.au"
 >  via SMTP by localhost, id smtpd11083a; Sun Mar 14 05:55:26 1999
 > To: [email protected]
 > cc: sjg, [email protected]
 > Subject: Re: bin/698 
 > In-reply-to: Your message of "11 Mar 99 10:51:46 -0000."
 >              <[email protected]> 

Date: Mon, 22 Nov 1999 00:53:30 -0800
From: "Erik E. Fair" <[email protected]>
To: "Simon J. Gerraty" <[email protected]>
Cc: [email protected]
Subject: 698

Yes, in order to have feedback automatically recorded in a PR, one 
puts the PR  number in the subject of a message, and the message must 
be sent to [email protected]

[email protected] is nominally read by a human or three, but it 
gets the *full* transaction set of all GNATS PRs, and as such, it is 
difficult for a human to reliably determine if a particular letter 
has been recorded in a particular PR or not.

So, w.r.t. PR 698, why should there be an 
umount_{ffs,nfs,null,union,etc}, other than symmetry with mount? What 
does there need to be done to unmount any of the filesystem that we 
now support, besides calling unmount(2)?

    curious,

    Erik <[email protected]>

P.S.    please reply to [email protected].

Date: Tue, 23 Nov 1999 01:56:21 +1100
From: "Simon J. Gerraty" <[email protected]>
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: PR 698

[cc'd tech-kern in case anyone has any better ideas]

> So, w.r.t. PR 698, why should there be an 
> umount_{ffs,nfs,null,union,etc}, other than symmetry with mount? What 
> does there need to be done to unmount any of the filesystem that we 
> now support, besides calling unmount(2)?

Firstly umount_* need only exist if there is something meaningful for
it to do.  Take snfs as an example (http://www.quick.com.au/Products/sNFS.html)

This filesystem implements NFS over SSL.  The client snfsc does the
talking to the remote machine and tells the kernel to mount an "NFS" fs
using a handle that points at its own socket.  This is a pretty
standard way of implementing "interesting" filesystems without need
for the client OS to support anything but NFS over udp.

In the case of snfs there is no portmap involved - snfsd runs
under inetd and won't grok anything that does not arrive over the
encrypted channel.

This means that on NetBSD, while you can arrange for mount /foo to
work - by invoking mount_snfs, umount /foo will _not_ work as the only
thing the kernel knows about is an NFS mount, and umount(8) because it
"knows" NFS, attempts to send an MOUNTPROC_UMNT rpc to the server -
which is doomed to fail.

On systems like SunOS, Solaris etc which record the mount options
somewhere outside the kernel and will invoke umount_snfs things work
much better.

I understand why NetBSD stores the stuff in the kernel and agree that
it is better.  But we still lose due to the lack of info stored.  On
NetBSD you simply find the pid of the snfsc process and kill it -
shuts down the connection to the server and then dags around until it
can extricate itself from the kernel.  It would be wonderful if all
umount(2)'s took an option to say - "for heaven sake, no further
operations are going to work so just forget about this mount point!"
:-)

I don't claim to know what the correct solution is btw but
one approach I thought of was to add a couple of fields to struct
statfs.  Hmm I see that f_fstypename[] is already there (its been some
years since I looked), which may be part of what I want, but I can't
find where the values for f_type are defined - which I presume is what
the kernel cares about?

Ie. if f_type were set to indicate NFS and f_fstypename could be set
to indicate the real fs type, then the correct umount_foo could be
found.  If that is not the correct use of those fields, then perhaps a
new field is needed.

If we also had say f_mntopts[MNAMELEN] to record the mount options
needed to ensure that umount_foo could do its thing (just the snfsc
pid would do for umount_snfs) then we'd be in business.  Note that the
content of f_mntopts[] need only be meaningful to umount_foo.

Of course one then needs a means of getting the extra info into the
kernel.  

We'd need to either:

1. add an extra arg to mount(2) which could be null.
2. add a struct statfs* (which could be null) to struct nfs_args etc.
3. make the arg passed to mount(2)  something like:

struct dummyfs_args {
    struct statfs *sfs;
    void *data; /* the real data for sfs->f_type */
};

there may well be a better option that I've not thought of.
I'd expect that each of the above has disadvantages.

Hope that helps.

--sjg

Date: Mon, 22 Nov 1999 10:03:21 -0500
From: Bill Sommerfeld <[email protected]>
To: "Simon J. Gerraty" <[email protected]>
Cc: [email protected], [email protected], [email protected]
Subject: Re: PR 698 

> It would be wonderful if all umount(2)'s took an option to say -
> "for heaven sake, no further operations are going to work so just
> forget about this mount point!"  :-)

You mean, like umount -f / MNT_FORCE?

Note that MNT_FORCE has been buggy in the past; I've done a fair bit
of work to clean it up, but i'm willing to believe that there are some
bugs lingering.

                    - Bill

Date: Tue, 23 Nov 1999 02:09:25 +1100
From: "Simon J. Gerraty" <[email protected]>
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: PR 698 

> > It would be wonderful if all umount(2)'s took an option to say -
> > "for heaven sake, no further operations are going to work so just
> > forget about this mount point!"  :-)
> 
> You mean, like umount -f / MNT_FORCE?

Yes.  I dearly wish Solaris had that :-)

--sjg

State-Changed-From-To: feedback->suspended 
State-Changed-By: sjg 
State-Changed-When: Sat Feb 5 19:01:06 PST 2000 
State-Changed-Why:  
I think I know what needs to be done to address this - but 
won't have any time to work on it for quite a while. 


Responsible-Changed-From-To: bin-bug-people->sjg 
Responsible-Changed-By: sjg 
Responsible-Changed-When: Sat Feb 5 19:01:06 PST 2000 
Responsible-Changed-Why:  
I might as well fix it myself. 
State-Changed-From-To: suspended->feedback 
State-Changed-By: darcy 
State-Changed-When: Sun Feb 16 11:34:29 PST 2003 
State-Changed-Why:  
This has been around for over 8 years.  I think that either someone should 
submit the required changes or we should just close this.  Another can always 
be reopened when there is actual code available. 

From: "Greg A. Woods" <[email protected]>
To: [email protected] (NetBSD GNATS submissions and followups),
  [email protected]
Cc: [email protected], Mail/@proven.weird.com
Subject: Re: bin/698: mount uses mount_* for external fs types, umount should too.
Date: Wed, 26 Feb 2003 01:07:26 -0500 (EST)

 D'Arcy wrote in feedback:
 >  This has been around for over 8 years.  I think that either someone
 >  should submit the required changes or we should just close this.
 >  Another can always be reopened when there is actual code available.

 That reasoning is both bogus and dangerous.

 No bug report should ever be closed just because there's no code to fix
 it available.  The whole point of a bug report like this is to remind
 someone to write the code in the first place!  Please don't go closing
 bug reports without doing anything about them just to get rid of old PRs
 -- there is no valid rationale for that whatsoever.  There's nothing bad
 about old PRs sitting open when they still need eventual attention,
 especially not in a volunteer project.

 If what you meant to say was that you didn't think this PR is valid then
 say that instead.

 (Personally I think this PR is quite valid, and BTW, I also think it's
 best to put this info in the kernel and once upon a time I even had some
 stuff written up about something like this for SySvR4 but I seem to have
 lost it.)

 -- 
                                Greg A. Woods

 +1 416 218-0098;            <[email protected]>;           <[email protected]>
 Planix, Inc. <[email protected]>; VE3TCP; Secrets of the Weird <[email protected]>

From: "D'Arcy J.M. Cain" <[email protected]>
To: "Greg A. Woods" <[email protected]>,
  [email protected] (NetBSD GNATS submissions and followups),
  "Greg A. Woods" <[email protected]>, [email protected]
Cc:  
Subject: Re: bin/698: mount uses mount_* for external fs types, umount should too.
Date: Wed, 26 Feb 2003 07:59:06 -0500

 I don't think I was actually saying that they should be closed just because 
 they are old.  That's why out of 10 from 1995 that I started with 9 are still 
 open.  What I do want, though, is to stimulate discussion.  Nothing is going 
 to be closed unless it is either dealt with or there is a concensus that the 
 issue no longer (or never did) exists.

 -- 
 D'Arcy J.M. Cain <[email protected]>
 http://www.NetBSD.org/

From: "Greg A. Woods" <[email protected]>
To: [email protected]
Cc: [email protected] (NetBSD GNATS submissions and followups),
  [email protected]
Subject: Re: bin/698: mount uses mount_* for external fs types, umount should too.
Date: Wed, 26 Feb 2003 14:04:12 -0500 (EST)

 [ On Wednesday, February 26, 2003 at 07:59:06 (-0500), D'Arcy J.M. Cain wrote: ]
 > Subject: Re: bin/698: mount uses mount_* for external fs types, umount should too.
 >
 > I don't think I was actually saying that they should be closed just because 
 > they are old.  That's why out of 10 from 1995 that I started with 9 are still 
 > open.  What I do want, though, is to stimulate discussion.  Nothing is going 
 > to be closed unless it is either dealt with or there is a concensus that the 
 > issue no longer (or never did) exists.

 Good!  OK, I'm glad we're on the same page about that!  :-)

 -- 
                                Greg A. Woods

 +1 416 218-0098;            <[email protected]>;           <[email protected]>
 Planix, Inc. <[email protected]>; VE3TCP; Secrets of the Weird <[email protected]>
Responsible-Changed-From-To: sjg->darcy 
Responsible-Changed-By: darcy 
Responsible-Changed-When: Thu Mar 13 13:40:34 PST 2003 
Responsible-Changed-Why:  
Further to discussions on developers, I am taking responsibility for 
making sure that this PR gets closed. 
State-Changed-From-To: feedback->open 
State-Changed-By: perry 
State-Changed-When: Thu Apr 3 17:50:12 PST 2003 
State-Changed-Why:  
Since we are not currently awaiting feedback from the submitter, 
it is more properly listed as "open". 

Unformatted


 Core has decided on the direction for this PR.  From the minutes of the Core
 meeting of 20060316:

    * version mount syscall
    * each foo_args struct will have a version field, and an fstype
    * store the fstype in foo args [first few args are common]
    * support separate mount programs
    * don't store the pid internally

blocked state of hardware flow control is not cleared

Metadata

  • Number: 4227
  • Originator: Noriyuki Shiota <[email protected]>
  • Arrived: Mon Oct 06 10:05:01 +0000 1997
  • Last modified: Sun Sep 03 01:16:18 +0000 2006
  • Environment: System: NetBSD escar 1.2G NetBSD 1.2G (ESCAR_BT_BOCA) #15: Mon Oct 6 23:26:37 JST 1997 root@escar:/usr/src/sys/arch/i386/compile/ESCAR_BT_BOCA i386

Description


    On establishing ppp connection, I used following command:
        pppd `chat ...` ....
    and chat script is done normally.
    But if the host machine send the long motd message, serial driver
    negates RTS signal line.
    then pppd changes line descipline to ppp, RTS signal is still
    low. (serial driver's state is still blocked.)
    In this situation, pppd never receive PPP packet.


How to repeat


    Try to connect ppp to long motd ppp server.
    or
    f = open("/dev/tty00", O_RDWR);

    <receive may characters from serial line.
     (*tp->t_hwiflow)(tp, 1) is called.
     serial driver clears RTS signal line and enter block state>

    what = FREAD;
    ioctl(f, TIOCFLUSH, &what); /* flush receive buffer */

    read(f, buf, sizeof(buf));  <-- block forever...
                        receive no character because
                        RTS is still low.
    or
    f = open("/dev/tty00", O_RDWR);

    <receive may characters from serial line.
     (*tp->t_hwiflow)(tp, 1) is called.
     serial driver clears RTS signal line and enter block state>

    ldisc = PPPDISC;
    ioctl(f, TIOCSETD, &ldisc); /* change to PPP line descipline */

    read(f, buf, sizeof(buf));  <-- block forever...
                        receive no character because
                        RTS is still low.


Fix


*** tty.c.ORIG  Fri Jun 20 20:33:34 1997
--- tty.c   Tue Oct  7 02:04:29 1997
***************
*** 1057,1082 ****
--- 1057,1086 ----
  ttyflush(tp, rw)
    register struct tty *tp;
    int rw;
  {
    register int s;

    s = spltty();
    if (rw & FREAD) {
        FLUSHQ(&tp->t_canq);
        FLUSHQ(&tp->t_rawq);
        tp->t_rocount = 0;
        tp->t_rocol = 0;
        CLR(tp->t_state, TS_LOCAL);
+       if (ISSET(tp->t_state, TS_TBLOCK) &&
+           ISSET(tp->t_cflag, CHWFLOW) && tp->t_hwiflow &&
+           (*tp->t_hwiflow)(tp, 0) != 0)
+           CLR(tp->t_state, TS_TBLOCK);
        ttwakeup(tp);
    }
    if (rw & FWRITE) {
        CLR(tp->t_state, TS_TTSTOP);
        (*cdevsw[major(tp->t_dev)].d_stop)(tp, rw);
        FLUSHQ(&tp->t_outq);
        wakeup((caddr_t)&tp->t_outq);
        selwakeup(&tp->t_wsel);
    }
    splx(s);
  }

  /*

Audit trail


Responsible-Changed-From-To: kern-bug-people->mycroft 
Responsible-Changed-By: mycroft 
Responsible-Changed-When: Thu Oct 9 02:09:52 PDT 1997 
Responsible-Changed-Why:  
The patch isn't quite complete; it doesn't handle the IXOFF case.  I'll fix it 
shortly. 

From: "Charles M. Hannum" <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: Re: kern/4227: blocked state of hardware flow control is not cleared
Date: Thu, 9 Oct 1997 16:11:33 -0400 (EDT)

 Your patch is more or less correct, but:

 * It doesn't deal with the case of XON/XOFF flow control.  (This also
 requires a slight rearrangement so that we queue the XON character
 *after* flushing the write side.)

 * It could (if the case were actually possible, which it's not
 currently) cause a fairly severe malfunction when an input ring
 becomes full; the input will be unblocked and then immediately blocked
 again.

 * There is a remaining problem that I haven't solved in the following
 patch.  With your change, if the input ring is full, there will be a
 glitch on RTS during close, as it's raised by foohwiflow() and then
 immediately lowered again by fooclose().  This is actually a fairly
 serious error, and needs to be fixed.


 Index: tty.c
 ===================================================================
 RCS file: /cvsroot/src/sys/kern/tty.c,v
 retrieving revision 1.98
 diff -c -2 -r1.98 tty.c
 *** tty.c  1997/10/09 12:59:56 1.98
 --- tty.c  1997/10/09 20:09:31
 ***************
 *** 67,70 ****
 --- 67,72 ----
   static void ttyrubo __P((struct tty *, int));
   static int proc_compare __P((struct proc *, struct proc *));
 + static __inline void ttblock __P((struct tty *));
 + static __inline void ttunblock __P((struct tty *));

   /* Symbolic sleep message strings. */
 ***************
 *** 1014,1017 ****
 --- 1016,1055 ----
   }

 + static __inline void
 + ttblock(tp)
 +  struct tty *tp;
 + {
 + 
 +  /* Try to block remote output via software (XON/XOFF) flow control. */
 +  if (ISSET(tp->t_iflag, IXOFF) &&
 +      tp->t_cc[VSTOP] != _POSIX_VDISABLE &&
 +      putc(tp->t_cc[VSTOP], &tp->t_outq) == 0) {
 +      SET(tp->t_state, TS_TBLOCK);
 +      ttstart(tp);
 +  }
 +  /* Try to block remote output via hardware (CTS/RTS) flow control. */
 +  if (ISSET(tp->t_cflag, CHWFLOW) && tp->t_hwiflow &&
 +      (*tp->t_hwiflow)(tp, 1) != 0)
 +      SET(tp->t_state, TS_TBLOCK);
 + }
 + 
 + static __inline void
 + ttunblock(tp)
 +  struct tty *tp;
 + {
 + 
 +  /* Try to unblock remote output via software (XON/XOFF) flow control. */
 +  if (ISSET(tp->t_iflag, IXOFF) &&
 +      tp->t_cc[VSTART] != _POSIX_VDISABLE &&
 +      putc(tp->t_cc[VSTART], &tp->t_outq) == 0) {
 +      CLR(tp->t_state, TS_TBLOCK);
 +      ttstart(tp);
 +  }
 +  /* Try to unblock remote output via hardware (CTS/RTS) flow control. */
 +  if (ISSET(tp->t_cflag, CHWFLOW) && tp->t_hwiflow &&
 +      (*tp->t_hwiflow)(tp, 0) != 0)
 +      CLR(tp->t_state, TS_TBLOCK);
 + }
 + 
   /*
    * Wait for output to drain.
 ***************
 *** 1062,1065 ****
 --- 1100,1110 ----

    s = spltty();
 +  if (rw & FWRITE) {
 +      CLR(tp->t_state, TS_TTSTOP);
 +      (*cdevsw[major(tp->t_dev)].d_stop)(tp, rw);
 +      FLUSHQ(&tp->t_outq);
 +      wakeup((caddr_t)&tp->t_outq);
 +      selwakeup(&tp->t_wsel);
 +  }
    if (rw & FREAD) {
        FLUSHQ(&tp->t_canq);
 ***************
 *** 1068,1080 ****
        tp->t_rocol = 0;
        CLR(tp->t_state, TS_LOCAL);
        ttwakeup(tp);
    }
 -  if (rw & FWRITE) {
 -      CLR(tp->t_state, TS_TTSTOP);
 -      (*cdevsw[major(tp->t_dev)].d_stop)(tp, rw);
 -      FLUSHQ(&tp->t_outq);
 -      wakeup((caddr_t)&tp->t_outq);
 -      selwakeup(&tp->t_wsel);
 -  }
    splx(s);
   }
 --- 1113,1120 ----
        tp->t_rocol = 0;
        CLR(tp->t_state, TS_LOCAL);
 +      if (ISSET(tp->t_state, TS_TBLOCK))
 +          ttunblock(tp);
        ttwakeup(tp);
    }
    splx(s);
   }
 ***************
 *** 1102,1107 ****
    total = tp->t_rawq.c_cc + tp->t_canq.c_cc;
    if (tp->t_rawq.c_cc > TTYHOG) {
 -      ttyflush(tp, FREAD | FWRITE);
        CLR(tp->t_state, TS_TBLOCK);
    }
    /*
 --- 1142,1147 ----
    total = tp->t_rawq.c_cc + tp->t_canq.c_cc;
    if (tp->t_rawq.c_cc > TTYHOG) {
        CLR(tp->t_state, TS_TBLOCK);
 +      ttyflush(tp, FREAD | FWRITE);
    }
    /*
 ***************
 *** 1111,1126 ****
    if ((total >= TTYHOG / 2 &&
         !ISSET(tp->t_state, TS_TBLOCK) &&
 !       !ISSET(tp->t_lflag, ICANON)) || tp->t_canq.c_cc > 0) {
 !      if (ISSET(tp->t_iflag, IXOFF) &&
 !          tp->t_cc[VSTOP] != _POSIX_VDISABLE &&
 !          putc(tp->t_cc[VSTOP], &tp->t_outq) == 0) {
 !          SET(tp->t_state, TS_TBLOCK);
 !          ttstart(tp);
 !      }
 !      /* Try to block remote output via hardware flow control. */
 !      if (ISSET(tp->t_cflag, CHWFLOW) && tp->t_hwiflow &&
 !          (*tp->t_hwiflow)(tp, 1) != 0)
 !          SET(tp->t_state, TS_TBLOCK);
 !  }
   }

 --- 1151,1156 ----
    if ((total >= TTYHOG / 2 &&
         !ISSET(tp->t_state, TS_TBLOCK) &&
 !       !ISSET(tp->t_lflag, ICANON)) || tp->t_canq.c_cc > 0)
 !      ttblock(tp);
   }

 ***************
 *** 1189,1195 ****
            CLR(tp->t_state, TS_CARR_ON);
            if (ISSET(tp->t_state, TS_ISOPEN) && !CONNECTED(tp)) {
                if (tp->t_session && tp->t_session->s_leader)
                    psignal(tp->t_session->s_leader, SIGHUP);
 -              ttyflush(tp, FREAD | FWRITE);
                return (0);
            }
 --- 1219,1225 ----
            CLR(tp->t_state, TS_CARR_ON);
            if (ISSET(tp->t_state, TS_ISOPEN) && !CONNECTED(tp)) {
 +              ttyflush(tp, FREAD | FWRITE);
                if (tp->t_session && tp->t_session->s_leader)
                    psignal(tp->t_session->s_leader, SIGHUP);
                return (0);
            }
 ***************
 *** 1435,1450 ****
     */
    s = spltty();
 !  if (ISSET(tp->t_state, TS_TBLOCK) && tp->t_rawq.c_cc < TTYHOG/5) {
 !      if (ISSET(tp->t_iflag, IXOFF) &&
 !          cc[VSTART] != _POSIX_VDISABLE &&
 !          putc(cc[VSTART], &tp->t_outq) == 0) {
 !          CLR(tp->t_state, TS_TBLOCK);
 !          ttstart(tp);
 !      }
 !      /* Try to unblock remote output via hardware flow control. */
 !      if (ISSET(tp->t_cflag, CHWFLOW) && tp->t_hwiflow &&
 !          (*tp->t_hwiflow)(tp, 0) != 0)
 !          CLR(tp->t_state, TS_TBLOCK);
 !  }
    splx(s);
    return (error);
 --- 1465,1470 ----
     */
    s = spltty();
 !  if (ISSET(tp->t_state, TS_TBLOCK) && tp->t_rawq.c_cc < TTYHOG/5)
 !      ttunblock(tp);
    splx(s);
    return (error);

From: Noriyuki Shiota <[email protected]>
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: kern/4227: blocked state of hardware flow control is not cleared
Date: Mon, 13 Oct 1997 06:08:27 +0900

 > Your patch is more or less correct, but:
 > 
 > * It doesn't deal with the case of XON/XOFF flow control.  (This also
 > requires a slight rearrangement so that we queue the XON character
 > *after* flushing the write side.)

 I didn't consider the XON/XOFF flow control case.
 I understand the same treatment is requred for this case.

 > * It could (if the case were actually possible, which it's not
 > currently) cause a fairly severe malfunction when an input ring
 > becomes full; the input will be unblocked and then immediately blocked
 > again.

 Is it a malfunction?  I don't understand what you mean.  After flushing,
 if many characters are received, an input ring and **the line decipline queue**
 are filled up, then to block immediately is normal behavior, isn't it?

 But I think that to add foohwiflush() is ideal.

 > * There is a remaining problem that I haven't solved in the following
 > patch.  With your change, if the input ring is full, there will be a
 > glitch on RTS during close, as it's raised by foohwiflow() and then
 > immediately lowered again by fooclose().  This is actually a fairly
 > serious error, and needs to be fixed.

 I see.  It is necessary to add a mask FCLOSE or FUNBLOCK for the second
 argument of ttyflush(), and if this mask is set then ttyflush() deson't
 call foohwiflow(tp, 0).  (in XON/XOFF case, I think it is better it send
 cc[VSTART] on closing.)
 --- 
 Noriyuki Shiota        [email protected]
Responsible-Changed-From-To: mycroft->kern-bug-people
Responsible-Changed-By: [email protected]
Responsible-Changed-When: Sun, 03 Sep 2006 01:16:18 +0000
Responsible-Changed-Why:
Back to role account, mycroft doesn't have commit access any longer.



kernel condvar wait functions should take an absolute timeout

Metadata

  • Number: 38554
  • Arrived: Thu May 01 11:50:00 +0000 2008
  • Last modified: Mon Apr 09 05:58:17 +0000 2012
  • Environment: n/a

Description


When sleeping on condition variables in the kernel, threads must be
prepared to handle "spurious wakeups": wakeups that occur due to some
external agent and do not signal an event of interest to the sleeping 
thread.

We have lots of code segments that do, for example:

  while (!condition) {
     error = cv_timedwait(&cv, &lock, hz);
     if (error == EWOULDBLOCK)
       break;
     ...
  }

If a spurious wakeup occurs, the thread could sleep for N*hz instead
of hz, or it could awaken early and return. Early wakeups are bad news 
for syscalls like nanosleep().

How to repeat


Code inspection.


Fix


Make condvars take an absolute timeout and add some simple functions
to help with computing wakeup times. The above code fragment would
then look something like the following:

  when = cv_time_now() + cv_time_second();
  while (!condition) {
     error = cv_timedwait(&cv, &lock, when);
     if (error == EWOULDBLOCK)
       break;
     ...
  }

This makes condvars slightly more compatible with the Solaris
interfaces. I think it should also be done before 5.0, because
it's a fairly major change to the interface and it would be good
to have it full stable before it is set in stone.


Audit trail



Responsible-Changed-From-To: kern-bug-people->ad
Responsible-Changed-By: [email protected]
Responsible-Changed-When: Thu, 01 May 2008 12:22:01 +0000
Responsible-Changed-Why:
take


From: Jason Thorpe <[email protected]>
To: [email protected]
Cc: [email protected],
 [email protected],
 [email protected]
Subject: Re: kern/38554: kernel condvar wait functions should take an absolute timeout
Date: Thu, 1 May 2008 21:38:46 -0700

 On May 1, 2008, at 4:50 AM, [email protected] wrote:

 > This makes condvars slightly more compatible with the Solaris
 > interfaces. I think it should also be done before 5.0, because
 > it's a fairly major change to the interface and it would be good
 > to have it full stable before it is set in stone.


 Agreed.  What sort of timeout value do the Solaris CV routines take?   
 Timespec?

 -- thorpej

From: [email protected] (YAMAMOTO Takashi)
To: [email protected]
Cc: [email protected], [email protected], [email protected],
        [email protected]
Subject: Re: kern/38554: kernel condvar wait functions should take an absolute
 timeout
Date: Fri,  2 May 2008 14:12:57 +0900 (JST)

 > What sort of timeout value do the Solaris CV routines take?   
 > Timespec?

 clock_t.

 YAMAMOTO Takashi

Responsible-Changed-From-To: ad->kern-bug-people
Responsible-Changed-By: [email protected]
Responsible-Changed-When: Mon, 09 Apr 2012 05:58:17 +0000
Responsible-Changed-Why:
ad resigned, should not own PRs any more



union FS can deadlock while vgone()/vclean() is running

Metadata

  • Number: 1354
  • Originator: John Kohl <[John Kohl [email protected]](mailto:John Kohl <[email protected])>
  • Arrived: Sun Aug 13 20:50:02 +0000 1995
  • Last modified: Sun May 10 19:12:21 +0000 2009
  • Environment: System: NetBSD pattern 1.0A NetBSD 1.0A (PATTERN) #67: Sat Aug 12 23:17:42 EDT 1995 jtk@pattern:/u1/NetBSD-current/src/sys/arch/i386/compile/PATTERN i386

Description



I was doing a kernel build (makedepend) and a 'make install' in
/usr/src/include, and got the union file system deadlocked on itself.

/usr/src is a union mount; the top layer is UFS and the bottom layer
is NFS.

Here are kernel stack traces of the deadlocked processes, plus some
analysis and vnode printouts:

The processes (ddb output):

 2585 f882a600 f9e5c000   0     1  2190  004006  3  netbsd  find   f87b8e00
 2577 f880cf00 f9e56000 5509     1  2135  004006  3  netbsd  cpp   vget f8798500

process 2577's trace follows.  It is waiting in vget for VXWANT to
clear, i.e. the vnode to finish being recycled.  Note that in the
printout of the union vnode, 2577 has the lock on the upper layer node
( because it was locked in union_lookup1() ).  2577 was looking up
"../../../../net/radix.h, and was in the process of looking up the "net"
component.

2585 is waiting for the top-layer (UFS) node lock.  
Although not shown here, the union node is recorded as locked by PID
2585, with flags 0x12 == UN_LOCKED|UN_CACHED.

db> trace 0xf9e57bf4
bpendtsleep(f8826600,0,f8807980,0,f9e57c30) at bpendtsleep
bpendtsleep(f8798500,8,f812dd7d,0,f8826600) at bpendtsleep
_vget(f8798500,0) at _vget+0x35
_union_allocvp(f9e57ef4,f877d200,f87bed80,f87c4e80,f9e57f08) at _union_allocvp+
0x120
_union_lookup(f9e57d74,f880ab80,f9e57f08,f9e57ee4,f87a5820) at _union_lookup+0x
493
_lookup(f9e57ee4,0,1d0e0,f9e57ee4,f9e57e14) at _lookup+0x257
_namei(f9e57ee4,0,1d0e0,f8843540,f8847000) at _namei+0x16b
_vn_open(f9e57ee4,1,1a4,f7bfd0a4,f880cf00) at _vn_open+0x17c
_open(f880cf00,f9e57f84,f9e57f7c,0,1d0e0) at _open+0x91
_syscall() at _syscall+0x239
--- syscall (number 5) ---
db> call vprint(0, 0xf8798500)
type VDIR, usecount 0, writecount 0, refcount 0, flags (VXLOCK|VXWANT)
                tag VT_UNION, vp=f8798500, uppervp=f8770700, lowervp=f8807980
uppervp: type VDIR, usecount 2, writecount 0, refcount 0,
        tag VT_UFS, ino 80688, on dev 4, 5 (LOCKED)
        owner pid 2577 waiting pid 2585
lowervp: type VDIR, usecount 2, writecount 0, refcount 0,
        tag VT_NFS, fileid 176651 fsid 0x1b01

process 2585's trace follows. It was doing a lookup in a different
filesystem (/usr) and decided to recycle a union vnode.  Inside
vclean(), there's a call to VOP_LOCK(vp) before vinvalbuf() is called.
This is consistent with the notation in the union node that 2585 owns
the union node lock.  However, 2585 does NOT have the top-layer lock,
because inside union_lock() there's this code:

        if (((un->un_flags & UN_ULOCK) == 0) &&
            (vp->v_usecount != 0)) {
            VOP_LOCK(un->un_uppervp);
            un->un_flags |= UN_ULOCK;
        }

usecount is indeed 0 in this case--that's why it's on the freelist.

db> trace *0xf9e5c03c
bpendsleep(f87b8e00,f8770700,f9e5db60,f8187626,f87b8e00) at bpendsleep
bpendsleep(f87b8e00,8) at bpendsleep
_ufs_lock(f9e5db70,f8770700,f81d36ec,f8770700,f9e5dbb0) at _ufs_lock+0x22
_union_vptofh(f8826600) at _union_vptofh+0x35    << really union_fixup
_union_fsync(f9e5dbcc,f8798500,f9e5dc24,0,2) at _union_fsync+0x64
_vinvalbuf(f8798500,1,ffffffff,0,0,0) at _vinvalbuf+0x46
_vclean(f8798500,8) at _vclean+0x6d
_vgone(f8798500) at _vgone+0x34
_getnewvnode(1,f876a000,f8726100,f9e5dcc0,f92b702c) at _getnewvnode+0xdb
_ffs_vget(f876a000,1004,f9e5dd44,f87be780,f9e5de60) at _ffs_vget+0x4f
_ufs_lookup(f9e5dda8,f87be780,f9e5de60,f9e5de3c,f87dcc20) at _ufs_lookup+0xbb1
_lookup(f9e5de3c,f7bfd920,f882a600,8,0) at _lookup+0x257
_namei(f9e5de3c,f7bfd920,f882a600,8,14c40) at _namei+0x16b
_lstat(f882a600,f9e5df84,f9e5df7c,0,14c4c) at _lstat+0x4a
_syscall() at _syscall+0x239

The basic scenario is this, I think:

2577 starts looking up a name in the union FS.  It looks up the top
layer name, finds it's a directory, and takes the lock on it.
It then starts looking up the lower name, and blocks (maybe waiting for
the lock on the lowerdvp).

2585 calls getnewvnode(), and starts reclaim on the union directory node
for the name that 2577 is about to use.  It calls VOP_LOCK() which sets
the locked bits in the union layer but doesn't take the uppervp lock.
It then calls vinvalbuf() which calls VOP_FSYNC() which sees the missing
uppervp lock and tries to get the lock.  It blocks because 2577 has the
lock.

2577 then finishes its lookup in the lower file system.  It then calls
union_allocvp() while holding uppervp locked.  union_allocvp() finds the
union node on the hash chains, and tries to vget() the node.  vget
notices the 0xdeadb marker in the vnode free chain, and waits for the
vnode to be finished recycling.

voila, 2-process deadly embrace.

I'm guessing that the (vp->v_usecount != 0) check is inside union_lock()
to avoid a related deadlock--the vclean() process would mark the vnode
for cleaning but then block in VOP_LOCK() waiting for the uppervp lock,
while the union_allocvp() process would be in vget() waiting for the
vnode recycling to be completed.

I think something needs to change in the way union_allocvp() calls
vget.  It really can't hold the uppervp lock while calling vget on the
union node (because that can lead to deadlock as seen in this case), nor
can it comfortably drop/regain the uppervp lock (although it only needs
to do this for the cases where the union node is on the free list).


How to repeat


be very unlucky, or just try to run several processes at once doing
builds inside a union FS.


Audit trail


State-Changed-From-To: open->feedback 
State-Changed-By: sommerfeld 
State-Changed-When: Sat Jul 31 17:10:44 PDT 1999 
State-Changed-Why:  
I believe that htis may be fixed by Bill Studenmund's fix to getnewvnode() 
in vfs_subr.c 1.105, which is to not try to clean locked vnodes on the  
freelist.. 
State-Changed-From-To: feedback->open 
State-Changed-By: sommerfeld 
State-Changed-When: Sat Jul 31 17:16:32 PDT 1999 
State-Changed-Why:  
"Never mind".  union_islocked() doesn't DTRT for this to work (yet) 
. 


Responsible-Changed-From-To: kern-bug-people->sommerfeld 
Responsible-Changed-By: sommerfeld 
Responsible-Changed-When: Sat Jul 31 17:16:32 PDT 1999 
Responsible-Changed-Why:  
i'll deal with this. 

Responsible-Changed-From-To: sommerfeld->bin-bug-people
Responsible-Changed-By: [email protected]
Responsible-Changed-When: Sun, 10 May 2009 19:12:21 +0000
Responsible-Changed-Why:
sommerfelds accounts are no longer active



irq 9 causes problems on the Sager NP7500A

Metadata

  • Number: 4464
  • Originator: Eric S. Hvozda <[email protected]>
  • Arrived: Mon Nov 10 15:35:04 +0000 1997
  • Last modified: Sun Oct 26 21:33:37 +0000 2008
  • Environment: System: NetBSD helios.ack.org 1.3_ALPHA NetBSD 1.3_ALPHA (HELIOS) #4: Mon Nov 10 17:46:11 EST 1997 root@:/usr/src/sys/arch/i386/compile/HELIOS i386

Description



    On Sager NP7500A and look alikes (this particular notebook
    is marketed under various names by VARs), irq 9 causes problems
    if the pcmcia subsystem attempts to use it.

    These problems range anywhere to configured, but unusable
    devices (with a D-Link DE-650 ethernet card and a
    Megahertz V.34 modem) to drivers hanging (with an Adaptec
    SlimSCSI card).  In all cases one can get to DDB and cleanly
    reboot however.

How to repeat


    Try to use the pcmcia subsystem on a Sager NP7500A or lookalike
    and observe odd behavior and note that the subsystem is
    attempting to use irq 9 from the messages on the console.  

    If the system isn't using irq 9 (perhaps you don't have a 
    builtin sound blaster consuming irq 7, or only one pcmcia
    card) use PCIC_ISA_INTR_ALLOC_MASK appropriately in a
    kernel config file to force use of irq 9.

Fix



    Perhaps the best idea is to disable selection of irq 9
    in the pcmcia subsystem.  This could be done by altering the
    default value of PCIC_ISA_INTR_ALLOC_MASK in
    /sys/dev/isa/i82365_isa.c.  Currently it is set to 0xfbff, but
    a setting of 0xf9ff will disable both irq 9 and 10 (interestingly
    irq 10 is safe to use on the Sager NP7500A unlike the NEC
    Versa series).

    It's a toss up from my POV; if it's clearly documented how
    to change the behavior, perhaps we don't care.  However it could
    be a show stopper for installs.  Also it can also have the
    appearance that NetBSD doesn't support the Sager if someone
    is unlikely enough to have the pcmcia subsystem try to use irq 9.

    At any rate, the diabling of this irq isn't an issue on the
    Sager since 11 and 15 are still left for selection.

Audit trail



From: "Chris G. Demetriou" <[email protected]>
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: kern/4464: disable selection of irq 9 for pcmcia subsystem? 
Date: Tue, 11 Nov 97 08:42:23 -0800

 >  At any rate, the diabling of this irq isn't an issue on the
 >  Sager since 11 and 15 are still left for selection.

 Of course, by the nature of PC hardware, at least one of will
 undoubtedly cause problems for anothre notebook, and the other for
 another...  8-)

 "There's gotta be a better way to do this."  Isn't there some way to
 query the BIOS, or something?


 Data point: on my ThinkPad 760EL, IRQ 7 seems to be used for my PCMCIA
 modem (gee, looking at things, i guess i don't have my parallel port
 configured), and IRQ 9 seems to be used for my PCMCIA ethernet.  At
 home I've got a docking station with a (built-in) PCI SCSI adapter, a
 PCI slot, and two more PCMCIA slots (that I don't know the IRQ #s for
 off-hand 8-).



 chris
State-Changed-From-To: open->feedback
State-Changed-By: [email protected]
State-Changed-When: Tue, 13 May 2008 13:21:28 +0000
State-Changed-Why:
Is this still a problem?



State-Changed-From-To: feedback->open
State-Changed-By: [email protected]
State-Changed-When: Sun, 26 Oct 2008 21:33:37 +0000
State-Changed-Why:
Feedback timeout. Anyone else still have this hardware?



changes to man programs

Metadata

  • Number: 1904
  • Originator: Mike Grupenhoff
  • Arrived: Sat Jan 06 15:50:01 +0000 1996
  • Last modified: Thu Mar 22 20:35:49 +0000 2001
  • Environment: System: NetBSD snarf.umiacs.umd.edu 1.1A NetBSD 1.1A (SNARF) #7: Fri Dec 29 23:04:19 EST 1995 [email protected]:/usr/src/sys/arch/i386/compile/SNARF i386

Description



- apropos and whatis can't handle multiple whatis db's when they
  are specified in shell glob syntax.  For example, a line like:

  _whatdb         /usr/{share,local,afs,X11}/man/whatis.db

  in /etc/man.conf will not be handled properly.

- catman doesn't work with /etc/man.conf and linked manpages

- bsd.man.mk doesn't use the build rules listed in /etc/man.conf
  catman should be used in bsd.man.mk instead of nroff


How to repeat


look at the source

Audit trail



From: Mike Grupenhoff <[email protected]>
To: [email protected]
Cc:  Subject: Re: bin/1904
Date: Mon, 8 Jan 1996 20:25:28 -0500 (EST)

 The patch to catman that I sent in bin/1904 was incomplete with respect to
 handling manpages with extentions with more then one period (foo.1.gz, etc). 
 I wasn't sure at the time about the proper way to handle this, since a
 manpage might have a period in its name. 

 The previous patch did a strrchr(manpage, '.') to get the extension, 
 which obviously breaks with compressed pages.  At the bottom of this mail 
 is a patch which does a better job of guessing what the extension really 
 is.  Of course, if someone could guarantee to me that a manpage name will 
 never contain a '.', this could all be done a lot cleaner.  alas..

 I apologize for not getting this right the first time, in the first patch.  I
 had a moment of clarity today while shoveling snow, and came up with this
 workaround.  If you have a better way of handling this, let me know. 

 mike

 This patch should be applied after applying the one in bin/1904.

 Index: catman.c
 ===================================================================
 RCS file: /snarf/netbsd/master/src/usr.sbin/catman/catman.c,v
 retrieving revision 1.2
 diff -u -r1.2 catman.c
 --- catman.c   1996/01/07 15:50:45 1.2
 +++ catman.c   1996/01/08 01:51:53
 @@ -62,13 +62,14 @@
  int f_noprint;

  int catman __P((const char *));
 -int dirformat __P((char *, char *, char *));
 +int dirformat __P((char *, char *));
  void dosystem __P((const char *));
 -void lncatpages __P((char *, char *, char *, char *, char *));
 +void lncatpages __P((char *, char *, char *, char *));
  void makedefault __P((char *));
  void makesubdir __P((const char *));
  void makewhatis __P((const char *));
 -void mformat __P((char *, char *));
 +int mformat __P((char *, struct stat *, char *));
 +void mkcatsuff __P((char *, char *));
  void usage __P((void));

  int
 @@ -131,7 +132,7 @@
     */
    if (argc == 1)
        if (access(*argv, F_OK) == 0) {
 -          mformat(*argv, NULL);
 +          mformat(*argv, NULL, NULL);
            exit(0);
        } else
            makesubdir(*argv);
 @@ -166,8 +167,8 @@
    int rval;
    char mandir[PATH_MAX];
    char catdir[PATH_MAX];
 -  char *catsuffix, *slash;
 -  TAG *subdirp, *sufp;
 +  char *slash;
 +  TAG *subdirp;
    ENTRY *ep;

    if (chdir(path) != 0) {
 @@ -180,11 +181,6 @@
    else
        slash = "/";

 -  if ((sufp = getlist("_suffix")) == NULL)
 -      catsuffix = ".0";
 -  else
 -      catsuffix = sufp->list.tqh_first->s;
 -
    if ((subdirp = getlist("_subdir")) == NULL)
        errx(1, "No man subdirectories to scan!\n");

 @@ -194,7 +190,7 @@
            continue;
        sprintf(mandir, "%s%s%s", path, slash, ep->s);
        sprintf(catdir, "%s%scat%c", path, slash, ep->s[3]);
 -      rval |= dirformat(mandir, catdir, catsuffix);
 +      rval |= dirformat(mandir, catdir);
    }

    return (rval);
 @@ -305,15 +301,14 @@
  }

  void
 -lncatpages(mandir, manpage, catdir, catpage, catsuffix)
 -  char *mandir, *manpage, *catdir, *catpage, *catsuffix;
 +lncatpages(mandir, manpage, catdir, catpage)
 +  char *mandir, *manpage, *catdir, *catpage;
  {
    DIR *dirp;
    struct dirent *dp;
    struct stat st, manstat;
    char manfile[PATH_MAX];
    char catfile[PATH_MAX];
 -  char *tmp;

    if (stat(manpage, &manstat) < 0) {
        warn("can't stat %s", manpage);
 @@ -336,9 +331,7 @@
        }
        if (st.st_ino == manstat.st_ino) {
            sprintf(catfile, "%s/%s", catdir, dp->d_name);
 -          if ((tmp = strrchr(catfile, '.')) == NULL)
 -              continue;
 -          strcpy(tmp, catsuffix);
 +          mkcatsuff(manfile, catfile);
            unlink(catfile);
            if (f_noprint == 0)
                printf("ln %s %s\n", catpage, catfile);
 @@ -355,24 +348,22 @@
   * Format all pages in mandir, placing the output in catdir.
   */
  int
 -dirformat(mandir, catdir, catsuffix)
 -  char *mandir, *catdir, *catsuffix;
 +dirformat(mandir, catdir)
 +  char *mandir, *catdir;
  {
 -  int error, rval, symlink;
 +  int rval, slink;
    char manpage[PATH_MAX];
    char catpage[PATH_MAX];
 -  char *tmp, *mansuffix;
    DIR *dirp;
    struct dirent *dp;
    struct stat manstat;
 -  struct stat catstat;

    if (chdir(mandir) || (dirp = opendir(".")) == NULL) {
        if (errno != ENOENT)
            warn(mandir);
        return (0);
    }
 -  if (stat(catdir, &catstat) < 0) {
 +  if (stat(catdir, &manstat) < 0) {
        if (errno != ENOENT) {
            warn("can't stat %s", catdir);
            closedir(dirp);
 @@ -402,9 +393,9 @@
            continue;
        }

 -      symlink = 0;
 +      slink = 0;
        if (S_ISLNK(manstat.st_mode)) {
 -          symlink = 1;
 +          slink = 1;
            if (stat(manpage, &manstat) < 0) {
                warn("can't stat %s", manpage);
                continue;
 @@ -417,39 +408,19 @@
             * architecture specific pages.
             */
            if (S_ISDIR(manstat.st_mode))
 -              dirformat(manpage, catpage, catsuffix);
 +              dirformat(manpage, catpage);
            else
                warnx("not a regular file %s", manpage);
            continue;
        }

 -      if ((mansuffix = strrchr(manpage, '.')) == NULL)
 -          continue;
 -      if ((tmp = strrchr(catpage, '.')) == NULL)
 -          continue;
 -      else
 -          strcpy(tmp, catsuffix);
 -
 -      if ((error = stat(catpage, &catstat)) &&
 -          errno != ENOENT) {
 -          warn("can't stat %s", catpage);
 -          continue;
 -      }
 -
 -      /*
 -       * If manpage is out of date, reformat
 -       */
 -      if ((error && errno == ENOENT) || 
 -          (manstat.st_mtime >= catstat.st_mtime &&
 -          f_noformat == 0)) {
 -          mformat(manpage, catpage);
 +      if (mformat(manpage, &manstat, catpage)) {
            /*
             * If manpages hardlinked together, duplicate
             * with catpages.
             */
 -          if (manstat.st_nlink > 1 || symlink)
 -              lncatpages(mandir, manpage, catdir, catpage,
 -                  catsuffix);
 +          if (manstat.st_nlink > 1 || slink)
 +              lncatpages(mandir, manpage, catdir, catpage);
            rval = 1;
        }
    }
 @@ -457,12 +428,14 @@
    return (rval);
  }

 -void
 -mformat(manpage, catpage)
 +int
 +mformat(manpage, manstat, catpage)
    char *manpage, *catpage;
 +  struct stat *manstat;
  {
 -  int fnd;
 +  int error, fnd, rval;
    char buf[1024], fmtbuf[1024], *p, *sufent, *mansuffix;
 +  struct stat catstat;
    TAG *sufp;
    ENTRY *e_sufp;

 @@ -472,7 +445,7 @@
    if ((sufp = getlist("_build")) == NULL)
        errx(1, "No _build keywords found in %s", _PATH_MANCONF);

 -  for (fnd = 0, e_sufp = sufp->list.tqh_first; e_sufp != NULL;
 +  for (rval = fnd = 0, e_sufp = sufp->list.tqh_first; e_sufp != NULL;
        e_sufp = e_sufp->q.tqe_next) {
        if ((sufent = strdup(e_sufp->s)) == NULL)
            errx(1, "Out of memory");
 @@ -482,7 +455,9 @@
            continue;
        }
        *p = '\0';
 -      if (fnmatch(sufent, mansuffix, 0) != 0) {
 +
 +      snprintf(buf, sizeof(buf), "*%s", sufent);
 +      if (fnmatch(buf, manpage, 0) != 0) {
            free(sufent);
            continue;
        }
 @@ -494,17 +469,70 @@
         */
        if (catpage == NULL)
            strncpy(fmtbuf, p, sizeof(fmtbuf));
 -      else
 -          snprintf(fmtbuf, sizeof(fmtbuf), "%s > %s", p, catpage);
 +      else {
 +          mkcatsuff(sufent, catpage);
 +          if ((error = stat(catpage, &catstat)) &&
 +              errno != ENOENT) {
 +              warn("can't stat %s", catpage);
 +              continue;
 +          }
 +
 +          /*
 +           * See if manpage is out of date.
 +           */
 +          if ((error && errno == ENOENT) || 
 +              (manstat->st_mtime >= catstat.st_mtime &&
 +              f_noformat == 0))
 +              snprintf(fmtbuf, sizeof(fmtbuf), "%s > %s", p,
 +                  catpage);
 +          else {
 +              free(sufent);
 +              break;
 +          }
 +      }
        snprintf(buf, sizeof(buf), fmtbuf, manpage);
        if (f_noprint == 0 && catpage != NULL)
            printf("%s\n", buf);
        if (f_noaction == 0)
            dosystem(buf);
        free(sufent);
 +      rval = 1;
    }
    if (fnd == 0)
        warnx("Don't know how to format %s", manpage);
 +  return (rval);
 +}
 +
 +/*
 + * Given a path to a manpage and a path to a catpage, change
 + * the catpage suffix to _suffix.
 + */
 +void
 +mkcatsuff(mansuffix, catpage)
 +  char *mansuffix, *catpage;
 +{
 +  int ndots;
 +  char *q;
 +  static char *catsuffix = NULL;
 +  TAG *sufp;
 +
 +  if (catsuffix == NULL)
 +      if ((sufp = getlist("_suffix")) == NULL)
 +          catsuffix = ".0";
 +      else
 +          catsuffix = sufp->list.tqh_first->s;
 +
 +  /*
 +   * Hack:  We count the number of dots in the manpage suffix
 +   * and jump back that many dots in the catpage.
 +   */
 +  for (ndots = 0, q = mansuffix; *q; q++)
 +      if (*q == '.')
 +          ndots++;
 +  for (q = catpage + strlen(catpage); ndots; q--)
 +      if (*q == '.')
 +          ndots--;
 +  strcpy(q + 1, catsuffix);
  }

  void

Responsible-Changed-From-To: bin-bug-people->mikel
Responsible-Changed-By: mikel
Responsible-Changed-When: Sat Sep 27 23:06:15 1997
Responsible-Changed-Why:
I'm handling this one.

Responsible-Changed-From-To: mikel->bin-bug-people 
Responsible-Changed-By: fair 
Responsible-Changed-When: Thu Mar 22 12:29:11 PST 2001 
Responsible-Changed-Why:  
Mike Long's E-mail address now bounces, so he appears to have vanished. 
Back to the role account this PR goes, ready for some other intrepid 
developer to step up to the plate. 

RFC 1760 specifies that skey seed is followed by space or newline

Metadata

  • Number: 17250
  • Originator: Ken Dunlap <[email protected]>
  • Arrived: Thu Jun 13 19:56:00 +0000 2002
  • Last modified:
  • Environment: System: NetBSD panix3.panix.com 1.5.2 NetBSD 1.5.2 (PANIX-USER) #0: Wed Jan 16 21:45:14 EST 2002 [email protected]:/devel/netbsd/1.5.2/src/sys/arch/i386/compile/PANIX-USER i386

Description


    RFC 1760 specifies that the 3 tokens of an skey prompt be separated by
a single space, followed by a space or a newline.  libskey on NetBSD 1.5.2 
and 1.6 produce prompts which look like this:  [s/key #### seed]  .

How to repeat


    telnet or ftp to an skey enabled account on a NetBSD host.

Fix


    completely untested patch:
skeylogin.c
556c556
<       fprintf(stderr, "[%s]\n", skeyprompt);

---
>       fprintf(stderr, "[ %s ]\n", skeyprompt);


i386 fd.c patch to recognize NEC (Japanese) format

Metadata

  • Number: 2895
  • Originator: MINOURA Makoto <[email protected]>
  • Arrived: Sun Oct 27 07:05:00 +0000 1996
  • Last modified: Sat Feb 09 19:48:37 +0000 2008
  • Environment: System: NetBSD daisy 1.2 NetBSD 1.2 (DAISY) #25: Sun Oct 27 22:15:03 JST 1996 root@daisy:/usr/src/sys/arch/i386/compile/DAISY i386

Description


    In Japan, the format of which sector size=1024, number of sector=8,
    number of track=77 was the most popular one especially for 130mm
    (5inch) FD for long time, because it was adopted by the Japanese
    best seller PC, NEC PC-9801 series (and also others, including x68k).
    It is still used widely in some situations.  This patch enables
    the device driver to handle this type of format.

    Because of the small MAXNPARTITIONS, this patch overrides the
    old PC diskette description.  Hopefully, MAXNPARTITIONS should
    be increased to 16 or some.

    To recognize NEC (Japanese) format MS-DOS disk, msdosfs must be
    modified as well.  I'll send a patch as another report.

    For FFS, see PR bin/2404.

Fix


*** fd.c.ORIG   Sat Aug 31 20:35:24 1996
--- fd.c    Sun Oct 27 16:28:40 1996
***************
*** 149,155 ****
--- 149,159 ----
          { 18,2,36,2,0xff,0xcf,0x1b,0x6c,80,2880,1,FDC_500KBPS,"1.44MB"    }, /* 1.44MB diskette */
          { 15,2,30,2,0xff,0xdf,0x1b,0x54,80,2400,1,FDC_500KBPS, "1.2MB"    }, /* 1.2 MB AT-diskettes */
          {  9,2,18,2,0xff,0xdf,0x23,0x50,40, 720,2,FDC_300KBPS, "360KB/AT" }, /* 360kB in 1.2MB drive */
+ #ifndef FD_NEC_FORMAT
          {  9,2,18,2,0xff,0xdf,0x2a,0x50,40, 720,1,FDC_250KBPS, "360KB/PC" }, /* 360kB PC diskettes */
+ #else
+         {  8,2,16,3,0xff,0xdf,0x35,0x74,77,1232,1,FDC_500KBPS, "1.2MB/[1024bytes/sector]"    }, /* 1.2 MB japanese format */
+ #endif
          {  9,2,18,2,0xff,0xdf,0x2a,0x50,80,1440,1,FDC_250KBPS, "720KB"    }, /* 3.5" 720kB diskette */
          {  9,2,18,2,0xff,0xdf,0x23,0x50,80,1440,1,FDC_300KBPS, "720KB/x"  }, /* 720kB in 1.2MB drive */
          {  9,2,18,2,0xff,0xdf,0x2a,0x50,40, 720,2,FDC_250KBPS, "360KB/x"  }, /* 360kB in 720kB drive */
***************
*** 486,492 ****
--- 490,502 ----
    case NVRAM_DISKETTE_144M:
        return &fd_types[0];
    case NVRAM_DISKETTE_360K:
+ #ifdef FD_NEC_FORMAT
+           printf ("%s: drive %d: kernel does not configured to recognize this type of drive.\n",
+           fdc, drive);
+       return NULL;
+ #else
        return &fd_types[3];
+ #endif
    case NVRAM_DISKETTE_720K:
        return &fd_types[4];
    default:
***************
*** 515,524 ****
    struct fd_softc *fd = fd_cd.cd_devs[FDUNIT(bp->b_dev)];
    int sz;
    int s;

    /* Valid unit, controller, and request? */
    if (bp->b_blkno < 0 ||
!       (bp->b_bcount % FDC_BSIZE) != 0) {
        bp->b_error = EINVAL;
        goto bad;
    }
--- 525,537 ----
    struct fd_softc *fd = fd_cd.cd_devs[FDUNIT(bp->b_dev)];
    int sz;
    int s;
+   int fd_bsize = 128 << fd->sc_type->secsize;
+   int bf = fd_bsize / DEV_BSIZE;

    /* Valid unit, controller, and request? */
    if (bp->b_blkno < 0 ||
!       (bp->b_blkno % bf) != 0 ||
!       (bp->b_bcount % fd_bsize) != 0) {
        bp->b_error = EINVAL;
        goto bad;
    }
***************
*** 527,536 ****
    if (bp->b_bcount == 0)
        goto done;

!   sz = howmany(bp->b_bcount, FDC_BSIZE);

!   if (bp->b_blkno + sz > fd->sc_type->size) {
!       sz = fd->sc_type->size - bp->b_blkno;
        if (sz == 0) {
            /* If exactly at end of disk, return EOF. */
            goto done;
--- 540,549 ----
    if (bp->b_bcount == 0)
        goto done;

!   sz = howmany(bp->b_bcount, DEV_BSIZE);

!   if (bp->b_blkno + sz > fd->sc_type->size * bf) {
!       sz = fd->sc_type->size * bf - bp->b_blkno;
        if (sz == 0) {
            /* If exactly at end of disk, return EOF. */
            goto done;
***************
*** 544,550 ****
        bp->b_bcount = sz << DEV_BSHIFT;
    }

!   bp->b_cylin = bp->b_blkno / (FDC_BSIZE / DEV_BSIZE) / fd->sc_type->seccyl;

  #ifdef FD_DEBUG
    printf("fdstrategy: b_blkno %d b_bcount %d blkno %d cylin %d sz %d\n",
--- 557,563 ----
        bp->b_bcount = sz << DEV_BSHIFT;
    }

!   bp->b_cylin = bp->b_blkno / (fd_bsize / DEV_BSIZE) / fd->sc_type->seccyl;

  #ifdef FD_DEBUG
    printf("fdstrategy: b_blkno %d b_bcount %d blkno %d cylin %d sz %d\n",
***************
*** 884,889 ****
--- 897,903 ----
    bus_io_handle_t ioh = fdc->sc_ioh;
    int read, head, sec, i, nblks;
    struct fd_type *type;
+   int fd_bsize, bf;

  loop:
    /* Is there a drive for the controller to do a transfer with? */
***************
*** 892,897 ****
--- 906,913 ----
        fdc->sc_state = DEVIDLE;
        return 1;
    }
+   fd_bsize = 128 << fd->sc_type->secsize;
+   bf = fd_bsize / FDC_BSIZE;

    /* Is there a transfer to this drive?  If not, deactivate drive. */
    bp = fd->sc_q.b_actf;
***************
*** 907,913 ****
        fdc->sc_errors = 0;
        fd->sc_skip = 0;
        fd->sc_bcount = bp->b_bcount;
!       fd->sc_blkno = bp->b_blkno / (FDC_BSIZE / DEV_BSIZE);
        untimeout(fd_motor_off, fd);
        if ((fd->sc_flags & FD_MOTOR_WAIT) != 0) {
            fdc->sc_state = MOTORWAIT;
--- 923,929 ----
        fdc->sc_errors = 0;
        fd->sc_skip = 0;
        fd->sc_bcount = bp->b_bcount;
!       fd->sc_blkno = bp->b_blkno / (fd_bsize / DEV_BSIZE);
        untimeout(fd_motor_off, fd);
        if ((fd->sc_flags & FD_MOTOR_WAIT) != 0) {
            fdc->sc_state = MOTORWAIT;
***************
*** 958,967 ****
        type = fd->sc_type;
        sec = fd->sc_blkno % type->seccyl;
        nblks = type->seccyl - sec;
!       nblks = min(nblks, fd->sc_bcount / FDC_BSIZE);
!       nblks = min(nblks, FDC_MAXIOSIZE / FDC_BSIZE);
        fd->sc_nblks = nblks;
!       fd->sc_nbytes = nblks * FDC_BSIZE;
        head = sec / type->sectrac;
        sec -= head * type->sectrac;
  #ifdef DIAGNOSTIC
--- 974,983 ----
        type = fd->sc_type;
        sec = fd->sc_blkno % type->seccyl;
        nblks = type->seccyl - sec;
!       nblks = min(nblks, fd->sc_bcount / fd_bsize);
!       nblks = min(nblks, FDC_MAXIOSIZE / fd_bsize);
        fd->sc_nblks = nblks;
!       fd->sc_nbytes = nblks * fd_bsize;
        head = sec / type->sectrac;
        sec -= head * type->sectrac;
  #ifdef DIAGNOSTIC
***************
*** 1072,1078 ****
  #endif
        if (fdc->sc_errors) {
            diskerr(bp, "fd", "soft error", LOG_PRINTF,
!               fd->sc_skip / FDC_BSIZE, (struct disklabel *)NULL);
            printf("\n");
            fdc->sc_errors = 0;
        }
--- 1088,1094 ----
  #endif
        if (fdc->sc_errors) {
            diskerr(bp, "fd", "soft error", LOG_PRINTF,
!               fd->sc_skip / fd_bsize, (struct disklabel *)NULL);
            printf("\n");
            fdc->sc_errors = 0;
        }
***************
*** 1174,1180 ****

    default:
        diskerr(bp, "fd", "hard error", LOG_PRINTF,
!           fd->sc_skip / FDC_BSIZE, (struct disklabel *)NULL);
        printf(" (st0 %b st1 %b st2 %b cyl %d head %d sec %d)\n",
            fdc->sc_status[0], NE7_ST0BITS,
            fdc->sc_status[1], NE7_ST1BITS,
--- 1190,1197 ----

    default:
        diskerr(bp, "fd", "hard error", LOG_PRINTF,
!           fd->sc_skip / (128 << fd->sc_type->secsize),
!           (struct disklabel *)NULL);
        printf(" (st0 %b st1 %b st2 %b cyl %d head %d sec %d)\n",
            fdc->sc_status[0], NE7_ST0BITS,
            fdc->sc_status[1], NE7_ST1BITS,
***************
*** 1227,1233 ****

        buffer.d_secpercyl = fd->sc_type->seccyl;
        buffer.d_type = DTYPE_FLOPPY;
!       buffer.d_secsize = FDC_BSIZE;

        if (readdisklabel(dev, fdstrategy, &buffer, NULL) != NULL)
            return EINVAL;
--- 1244,1250 ----

        buffer.d_secpercyl = fd->sc_type->seccyl;
        buffer.d_type = DTYPE_FLOPPY;
!       buffer.d_secsize = 128 << fd->sc_type->secsize;

        if (readdisklabel(dev, fdstrategy, &buffer, NULL) != NULL)
            return EINVAL;



Audit trail


Responsible-Changed-From-To: gnats-admin->port-i386-maintainer 
Responsible-Changed-By: fair 
Responsible-Changed-When: Mon Dec 28 09:50:54 PST 1998 
Responsible-Changed-Why:  
This PR is the responsibility of the portmaster, 
not the GNATS database administrator. 
Responsible-Changed-From-To: port-i386-maintainer->kern-bug-people
Responsible-Changed-By: [email protected]
Responsible-Changed-When: Sat, 09 Feb 2008 19:48:37 +0000
Responsible-Changed-Why:
there is no longer an i386-specific fd.c.



strange vclean() crash

Metadata

  • Number: 44809
  • Arrived: Thu Mar 31 07:45:00 +0000 2011
  • Last modified:
  • Environment: System: NetBSD after-hours.aprisoft.de 5.99.48 NetBSD 5.99.48 (MODULAR) #36: Wed Mar 30 11:57:17 CEST 2011 [email protected]:/usr/src/sys/arch/sparc64/compile/MODULAR sparc64 Architecture: sparc64 Machine: sparc64

Description



Every now and then this machine crashes, in what looks like always the same
way:

trap type 0x34: cpu 0, pc=15176e4 npc=15176e8 pstate=0x820006<PRIV,IE>
kernel trap 34: mem address not aligned
Stopped in pid 10502.1 (find) at        netbsd:VOP_LOCK+0x64:   jmpl           %g1 + %g0], %o7
db{0}> bt
vclean(f242b40, 8, 0, 0, 96, 0) at netbsd:vclean+0xa8
getcleanvnode(f242b40, 0, f277400, 15, 15, 18cd400) at netbsd:getcleanvnode+0x15c
getnewvnode(1, d6e6030, d5e0830, 114d55f0, d1f0454, 0) at netbsd:getnewvnode+0x74
ffs_vget(d6e6030, 3bcd72, 114d5730, 4, 4000, d1f04f0) at netbsd:ffs_vget+0x20
ufs_lookup(0, 2c4, 300, 3fff, 2, 2) at netbsd:ufs_lookup+0x740
VOP_LOOKUP(17eb4a60, 114d5b40, 114d5b68, 179af10, badcafe, 0) at netbsd:VOP_LOOKUP+0xac
do_lookup(f277400, 114d5b20, 10, 10, 0, 114d58e8) at netbsd:do_lookup+0x48c
namei(114d5b20, 114d5b98, badcafe, 114d5b20, badcafe, badcafe) at netbsd:namei+0x14c
do_sys_stat(0, 0, 114d5c68, badcafe, badcafe, badcafe) at netbsd:do_sys_stat+0x38
sys___lstat50(f277400, 114d5dc0, 114d5e00, 4074f6a0, 4093f160, 4093f138) at netbsd:sys___lstat50+0x10
syscall_plain(114d5ed0, 114d5f50, 40744a88, 24f, 40744a88, c00) at netbsd:syscall_plain+0x138
?(40a02880, 40a028b0, 0, 1, 0, 40a203a0) at 0x1008f58
db{0}> show vnode 0xf242b40
OBJECT 0xf242b40: locked=0, pgops=0x170e708, npages=0, refs=-2147483647

VNODE flags 0x1010<MPSAFE,XLOCK>
mp 0x0 numoutput 0 size 0xffffffffffffffff writesize 0xffffffffffffffff
data 0x10073910 writecount 0 holdcnt 0
tag VT_MFS(3) type VBLK(3) mount 0x0 typedata 0x100a3cd0
v_lock 0xf242c48

crash happens here:

netbsd:VOP_LOCK+0x5c:   ldx             [%i0 + 0x98], %g2
netbsd:VOP_LOCK+0x60:   ldx             [%g2 + 0xf8], %g1
netbsd:VOP_LOCK+0x64:   jmpl            [%g1 + %g0], %o7
netbsd:VOP_LOCK+0x68:   add             %fp, 0x7d7, %o0

%i0 is clearly bogus:
i0          0x2000

so we end up with garbage:
g1          0x39d77614b250ef8d
g2          0xe78ee10


In source terms, this is at:
(gdb) list *(VOP_LOCK+0x64)
0x15176e4 is in VOP_LOCK (../../../../kern/vnode_if.c:1103).
1098            a.a_desc = VDESC(vop_lock);
1099            a.a_vp = vp;
1100            a.a_flags = flags;
1101            mpsafe = (vp->v_vflag & VV_MPSAFE);
1102            if (!mpsafe) { KERNEL_LOCK(1, curlwp); }
1103            error = (VCALL(vp, VOFFSET(vop_lock), &a));
1104            if (!mpsafe) { KERNEL_UNLOCK_ONE(curlwp); }
1105            return error;
1106    }

and called from:

(gdb) list *(vclean+0xa8)
0x1502968 is in vclean (../../../../kern/vfs_subr.c:1854).
1849            vp->v_iflag &= ~(VI_TEXT|VI_EXECMAP);
1850            active = (vp->v_usecount & VC_MASK) > 1;
1851    
1852            /* XXXAD should not lock vnode under layer */
1853            mutex_exit(&vp->v_interlock);
1854            VOP_LOCK(vp, LK_EXCLUSIVE);
1855    
1856            /*
1857             * Clean out any cached data associated with the vnode.
1858             * If purging an active vnode, it must be closed and

This are all mounts involved:

/dev/sd0a on / type ffs (log, local)
kernfs on /kern type kernfs (local)
ptyfs on /dev/pts type ptyfs (local)
procfs on /proc type procfs (local)

Any ideas what to examine when it happens next time?


How to repeat



No idea, just happens "sometimes" for me.


Fix



[dM] 8 partitions is awfully few

Metadata

  • Number: 2675
  • Originator: der Mouse <[email protected]>
  • Arrived: Mon Aug 05 16:20:03 +0000 1996
  • Last modified: Wed Jul 19 02:59:14 +0000 2006
  • Environment: Any SPARC (I use an IPC)

Description


    Especially with the advent of modern disks with sizes up around
    4G and 9G and the like, 8 partitions per disk seems awfully
    few.

How to repeat


    Try to split up a big disk.  Find yourself constrained by the
    seven-partition limit (eight including c).  Sigh.

Fix


    Here's what I've done.  It seems to work reasonably well.  I've
    tucked the "other" eight partitions in the spare space in the
    disklabel between the ASCII label string and the RPM value,
    with a magic number and a checksum.  If either magic or
    checksum is wrong, the "extended" eight partitions are all 0
    offset 0 size.

    The disksubr.c patch includes a fix to bounds_check_with_label;
    I think I saw a commit message indicating this - or something
    like it - went into the main branch, but it hasn't yet showed
    up in the sups.  I'm including it here on the theory that
    anyone who is into fiddling with disk labeling to the point of
    sixteen partitions probably also wants this fix. :-)

    I'm not sure I've done all that's necessary to MAKEDEV; I'd
    appreciate any remarks from those who know.

--- OLD/etc/etc.sparc/MAKEDEV   Thu Jan  1 00:00:00 1970
+++ NEW/etc/etc.sparc/MAKEDEV   Thu Jan  1 00:00:00 1970
@@ -167,27 +167,42 @@
    vnd*) name=vnd; blk=8; chr=110;;
    esac
    case $unit in
-   0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|\
-   17|18|19|20|21|22|23|24|25|26|27|28|29|30|31)
-       rm -f ${name}${unit}[a-h] r${name}${unit}[a-h]
-       mknod ${name}${unit}c   b $blk `expr $unit '*' 8 + 2`
-       mknod r${name}${unit}c  c $chr `expr $unit '*' 8 + 2`
-       mknod ${name}${unit}a   b $blk `expr $unit '*' 8 + 0`
-       mknod ${name}${unit}b   b $blk `expr $unit '*' 8 + 1`
-       mknod ${name}${unit}d   b $blk `expr $unit '*' 8 + 3`
-       mknod ${name}${unit}e   b $blk `expr $unit '*' 8 + 4`
-       mknod ${name}${unit}f   b $blk `expr $unit '*' 8 + 5`
-       mknod ${name}${unit}g   b $blk `expr $unit '*' 8 + 6`
-       mknod ${name}${unit}h   b $blk `expr $unit '*' 8 + 7`
-       mknod r${name}${unit}a  c $chr `expr $unit '*' 8 + 0`
-       mknod r${name}${unit}b  c $chr `expr $unit '*' 8 + 1`
-       mknod r${name}${unit}d  c $chr `expr $unit '*' 8 + 3`
-       mknod r${name}${unit}e  c $chr `expr $unit '*' 8 + 4`
-       mknod r${name}${unit}f  c $chr `expr $unit '*' 8 + 5`
-       mknod r${name}${unit}g  c $chr `expr $unit '*' 8 + 6`
-       mknod r${name}${unit}h  c $chr `expr $unit '*' 8 + 7`
-       chgrp operator ${name}${unit}[a-h] r${name}${unit}[a-h]
-       chmod 640 ${name}${unit}[a-h] r${name}${unit}[a-h]
+   0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15)
+       rm -f ${name}${unit}[a-p] r${name}${unit}[a-p]
+       mknod ${name}${unit}c   b $blk `expr $unit '*' 16 + 2`
+       mknod r${name}${unit}c  c $chr `expr $unit '*' 16 + 2`
+       mknod ${name}${unit}a   b $blk `expr $unit '*' 16 + 0`
+       mknod ${name}${unit}b   b $blk `expr $unit '*' 16 + 1`
+       mknod ${name}${unit}d   b $blk `expr $unit '*' 16 + 3`
+       mknod ${name}${unit}e   b $blk `expr $unit '*' 16 + 4`
+       mknod ${name}${unit}f   b $blk `expr $unit '*' 16 + 5`
+       mknod ${name}${unit}g   b $blk `expr $unit '*' 16 + 6`
+       mknod ${name}${unit}h   b $blk `expr $unit '*' 16 + 7`
+       mknod ${name}${unit}i   b $blk `expr $unit '*' 16 + 8`
+       mknod ${name}${unit}j   b $blk `expr $unit '*' 16 + 9`
+       mknod ${name}${unit}k   b $blk `expr $unit '*' 16 + 10`
+       mknod ${name}${unit}l   b $blk `expr $unit '*' 16 + 11`
+       mknod ${name}${unit}m   b $blk `expr $unit '*' 16 + 12`
+       mknod ${name}${unit}n   b $blk `expr $unit '*' 16 + 13`
+       mknod ${name}${unit}o   b $blk `expr $unit '*' 16 + 14`
+       mknod ${name}${unit}p   b $blk `expr $unit '*' 16 + 15`
+       mknod r${name}${unit}a  c $chr `expr $unit '*' 16 + 0`
+       mknod r${name}${unit}b  c $chr `expr $unit '*' 16 + 1`
+       mknod r${name}${unit}d  c $chr `expr $unit '*' 16 + 3`
+       mknod r${name}${unit}e  c $chr `expr $unit '*' 16 + 4`
+       mknod r${name}${unit}f  c $chr `expr $unit '*' 16 + 5`
+       mknod r${name}${unit}g  c $chr `expr $unit '*' 16 + 6`
+       mknod r${name}${unit}h  c $chr `expr $unit '*' 16 + 7`
+       mknod r${name}${unit}i  c $chr `expr $unit '*' 16 + 8`
+       mknod r${name}${unit}j  c $chr `expr $unit '*' 16 + 9`
+       mknod r${name}${unit}k  c $chr `expr $unit '*' 16 + 10`
+       mknod r${name}${unit}l  c $chr `expr $unit '*' 16 + 11`
+       mknod r${name}${unit}m  c $chr `expr $unit '*' 16 + 12`
+       mknod r${name}${unit}n  c $chr `expr $unit '*' 16 + 13`
+       mknod r${name}${unit}o  c $chr `expr $unit '*' 16 + 14`
+       mknod r${name}${unit}p  c $chr `expr $unit '*' 16 + 15`
+       chgrp operator ${name}${unit}[a-p] r${name}${unit}[a-p]
+       chmod 640 ${name}${unit}[a-p] r${name}${unit}[a-p]
        ;;
    *)
        echo bad unit for disk in: $i

--- OLD/sys/arch/sparc/include/disklabel.h  Thu Jan  1 00:00:00 1970
+++ NEW/sys/arch/sparc/include/disklabel.h  Thu Jan  1 00:00:00 1970
@@ -35,7 +35,7 @@

 #define    LABELSECTOR 0           /* sector containing label */
 #define    LABELOFFSET 64          /* offset of label in sector */
-#define    MAXPARTITIONS   8           /* number of partitions */
+#define    MAXPARTITIONS   16          /* number of partitions */
 #define    RAW_PART    2           /* raw partition: xx?c */

 struct cpu_disklabel {

--- OLD/sys/arch/sparc/include/sun_disklabel.h  Thu Jan  1 00:00:00 1970
+++ NEW/sys/arch/sparc/include/sun_disklabel.h  Thu Jan  1 00:00:00 1970
@@ -88,7 +88,17 @@

 struct sun_disklabel {         /* total size = 512 bytes */
    char    sl_text[128];
-   char    sl_xxx1[292];
+#if MAXPARTITIONS > 8
+#define SUNXPART (MAXPARTITIONS-8)
+   u_long  sl_xpsum;       /* additive cksum, [sl_xpmag,sl_xxx1) */
+   u_long  sl_xpmag;       /* "extended" magic number */
+#define SL_XPMAG (0x199d1fe2+SUNXPART)
+   struct sun_dkpart sl_xpart[SUNXPART];   /* "extended" partitions, i through p */
+   char    sl_xxx1[292-8-(8*SUNXPART)]; /* [292] including sl_x* */
+#else
+#define SUNXPART 0
+   char    sl_xxx1[292];
+#endif
    u_short sl_rpm;         /* rotational speed */
    u_short sl_pcylinders;      /* number of physical cyls */
    u_short sl_sparespercyl;    /* spare sectors per cylinder */

--- OLD/sys/arch/sparc/sparc/disksubr.c Thu Jan  1 00:00:00 1970
+++ NEW/sys/arch/sparc/sparc/disksubr.c Thu Jan  1 00:00:00 1970
@@ -285,14 +285,16 @@
 #define dkpart(dev) (minor(dev) & 7)

    struct partition *p = lp->d_partitions + dkpart(bp->b_dev);
-   int labelsect = lp->d_partitions[0].p_offset;
    int maxsz = p->p_size;
    int sz = (bp->b_bcount + DEV_BSIZE - 1) >> DEV_BSHIFT;

    /* overwriting disk label ? */
    /* XXX should also protect bootstrap in first 8K */
-   if (bp->b_blkno + p->p_offset <= LABELSECTOR + labelsect &&
-       (bp->b_flags & B_READ) == 0 && wlabel == 0) {
+   /* XXX this assumes everything <=LABELSECTOR is label! */
+   /*     But since LABELSECTOR is 0, that's ok for now. */
+   if ( (bp->b_blkno + p->p_offset <= LABELSECTOR) &&
+        ((bp->b_flags & B_READ) == 0) &&
+        (wlabel == 0) ) {
        bp->b_error = EROFS;
        goto bad;
    }
@@ -330,7 +332,7 @@

 /* What partition types to assume for Sun disklabels: */
 static u_char
-sun_fstypes[8] = {
+sun_fstypes[16] = {
    FS_BSDFFS,  /* a */
    FS_SWAP,    /* b */
    FS_OTHER,   /* c - whole disk */
@@ -339,8 +341,31 @@
    FS_BSDFFS,  /* f */
    FS_BSDFFS,  /* g */
    FS_BSDFFS,  /* h */
+   FS_BSDFFS,  /* i */
+   FS_BSDFFS,  /* j */
+   FS_BSDFFS,  /* k */
+   FS_BSDFFS,  /* l */
+   FS_BSDFFS,  /* m */
+   FS_BSDFFS,  /* n */
+   FS_BSDFFS,  /* o */
+   FS_BSDFFS,  /* p */
 };

+/* Given a struct sun_disklabel, assume it has an extended partition
+   table and compute the correct value for sl_xpsum. */
+static u_long sun_extended_sum(struct sun_disklabel *sl)
+{
+ u_long lsum;
+ u_long *xp;
+ u_long *ep;
+
+ xp = (u_long *) &sl->sl_xpmag;
+ ep = (u_long *) &sl->sl_xxx1[0];
+ lsum = 0;
+ for (;xp<ep;xp++) lsum += *xp;
+ return(lsum);
+}
+
 /*
  * Given a SunOS disk label, set lp to a BSD disk label.
  * Returns NULL on success, else an error string.
@@ -388,7 +413,7 @@
    lp->d_rpm          = sl->sl_rpm;
    lp->d_interleave   = sl->sl_interleave;

-   lp->d_npartitions = 8;
+   lp->d_npartitions = MAXPARTITIONS;
    /* These are as defined in <ufs/ffs/fs.h> */
    lp->d_bbsize = 8192;    /* XXX */
    lp->d_sbsize = 8192;    /* XXX */
@@ -414,6 +439,43 @@
        }
    }

+#if SUNXPART > 0
+
+   /* Clear "extended" partition info, tentatively */
+   for (i=0;i<SUNXPART;i++) {
+       npp = &lp->d_partitions[i+8];
+       npp->p_offset = 0;
+       npp->p_size = 0;
+       npp->p_fstype = FS_UNUSED;
+   }
+
+   /* Check to see if there's an "extended" partition table */
+   if (sl->sl_xpmag == SL_XPMAG) { /* probably... */
+       if (sun_extended_sum(sl) == sl->sl_xpsum) { /* ...yes! */
+           /* There is.  Copy over the "extended" partitions.
+              This code parallels the loop for partitions a-h. */
+           /* XXX Abstract the common code? */
+           for (i=0;i<SUNXPART;i++) {
+               spp = &sl->sl_xpart[i];
+               npp = &lp->d_partitions[i+8];
+               npp->p_offset = spp->sdkp_cyloffset * secpercyl;
+               npp->p_size = spp->sdkp_nsectors;
+               if (npp->p_size == 0) {
+                   npp->p_fstype = FS_UNUSED;
+               } else {
+                   npp->p_fstype = sun_fstypes[i+8];
+                   if (npp->p_fstype == FS_BSDFFS) {
+                       npp->p_fsize = 1024;
+                       npp->p_frag = 8;
+                       npp->p_cpg = 16;
+                   }
+               }
+           }
+       }
+   }
+
+#endif /* if SUNXPART > 0 */
+
    lp->d_checksum = 0;
    lp->d_checksum = dkcksum(lp);
    return (NULL);
@@ -463,6 +525,39 @@
        spp->sdkp_nsectors = npp->p_size;
    }
    sl->sl_magic = SUN_DKMAGIC;
+
+#if SUNXPART > 0
+
+   /* The reason we load the extended table stuff only conditionally
+      is so that a label that doesn't need it will have NULs there, like
+      a "traditional" Sun label.  Since Suns seem to ignore everything
+      between sl_text and sl_rpm, this probably doesn't matter, but it
+      certainly doesn't hurt anything and it's easy to do. */
+
+   /* Do we need to load the extended table? */
+   for (i=0;i<SUNXPART;i++) {
+       if (lp->d_partitions[i+8].p_offset || lp->d_partitions[i+8].p_size) break;
+   }
+   if (i < SUNXPART) { /* we do */
+       sl->sl_xpmag = SL_XPMAG;
+       for (i=0;i<SUNXPART;i++) {
+           spp = &sl->sl_xpart[i];
+           npp = &lp->d_partitions[i+8];
+           if (npp->p_offset % secpercyl) return(EINVAL);
+           sl->sl_xpart[i].sdkp_cyloffset = npp->p_offset / secpercyl;
+           sl->sl_xpart[i].sdkp_nsectors = npp->p_size;
+       }
+       sl->sl_xpsum = sun_extended_sum(sl);
+   } else {
+       sl->sl_xpmag = 0;
+       for (i=0;i<SUNXPART;i++) {
+           sl->sl_xpart[i].sdkp_cyloffset = 0;
+           sl->sl_xpart[i].sdkp_nsectors = 0;
+       }
+       sl->sl_xpsum = 0;
+   }
+
+#endif /* if SUNXPART > 0 */

    /* Correct the XOR check. */
    sp1 = (u_short *)sl;

                    der Mouse

                [email protected]
            01 EE 31 F6 BB 0C 34 36  00 F3 7C 5A C1 A0 67 1D

Audit trail



From: der Mouse <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: Re: kern/2675: [dM] 8 partitions is awfully few
Date: Mon, 5 Aug 1996 16:28:07 -0400

 > Synopsis:       [dM] 8 partitions is awfully few

 > --- OLD/sys/arch/sparc/sparc/disksubr.c  Thu Jan  1 00:00:00 1970
 > +++ NEW/sys/arch/sparc/sparc/disksubr.c  Thu Jan  1 00:00:00 1970
 > @@ -285,14 +285,16 @@
 >  #define dkpart(dev) (minor(dev) & 7)
 >  
 >      struct partition *p = lp->d_partitions + dkpart(bp->b_dev);
 > -    int labelsect = lp->d_partitions[0].p_offset;
 >      int maxsz = p->p_size;

 Duh.  Fix that up to read

 #define dkpart(dev) (((unsigned int)minor(dev)) % MAXPARTITIONS)

 which is probably what it should have been anyway.

                    der Mouse

                [email protected]
            01 EE 31 F6 BB 0C 34 36  00 F3 7C 5A C1 A0 67 1D
State-Changed-From-To: open->feedback 
State-Changed-By: jdolecek 
State-Changed-When: Fri Jun 29 03:57:41 PDT 2001 
State-Changed-Why:  
Ports are being switched to higher number of partitions. Is this 
still a problem for you? 

From: Jarom๏ฟฝr Dolecek <[email protected]>
To: der Mouse <[email protected]>
Cc: [email protected]
Subject: Re: kern/2675
Date: Fri, 6 Jul 2001 14:39:07 +0200 (CEST)

 der Mouse wrote:
 > The limit is still an _issue_ for me.  It hasn't been a _problem_ for
 > me since approximately the time I sent the PR; the fixes have been in
 > my private patch tree for a long time.

 Maybe, if you'd make necessary patches to make the change for sparc similar
 way this was handled on i386 and submit the patch via the gnats to this
 PR, the issue could be solved for you and rest of sparc users as well.

 Jaromir
 -- 
 Jaromir Dolecek <[email protected]>      http://www.ics.muni.cz/~dolecek/
 NetBSD - just plain best OS! -=*=- Got spare MCA cards or docs? Hand me them!

From: Jarom๏ฟฝr Dolecek <[email protected]>
To: der Mouse <[email protected]>
Cc: [email protected]
Subject: Re: kern/2675
Date: Sun, 15 Jul 2001 16:26:15 +0200 (CEST)

 der Mouse wrote:
 > I don't see how it isn't _already_ "solved for [me] and [the] rest of
 > [the] sparc users" (or at least those who care to bother)...is there
 > something wrong with the patches I provided?  They sure work for me.

 Well, I don't know whether they are good or wrong (haven't looked
 on them in that much detail), but since the i386 solution has already
 went through quite big discussion and was found out as acceptable,
 I'd be reluctant to use different thing for other ports.
 Unless the solution would be clearly superiour of course :)

 Jaromir
 -- 
 Jaromir Dolecek <[email protected]>      http://www.ics.muni.cz/~dolecek/
 NetBSD - just plain best OS! -=*=- Got spare MCA cards or docs? Hand me them!

From: der Mouse  <[email protected]>
To: Jarom๏ฟฝr Dolecek <[email protected]>
Cc: [email protected]
Subject: Re: kern/2675
Date: Sat, 6 Oct 2001 15:36:41 -0400 (EDT)

 >> I don't see how it isn't _already_ "solved for [me] and [the] rest
 >> of [the] sparc users" (or at least those who care to bother)...is
 >> there something wrong with the patches I provided?  They sure work
 >> for me.

 > Well, I don't know whether they are good or wrong (haven't looked on
 > them in that much detail), but since the i386 solution has already
 > went through quite big discussion and was found out as acceptable,
 > I'd be reluctant to use different thing for other ports.

 Well, of *course* the i386 solution is best for all the other ports!
 Let's port fdisk immediately!

 More seriously, what *is* the i386 solution?  As of my freeze point,
 the i386 port is still at MAXPARTITIONS=8.

 Not that it matters, I suppose.  I've seen no evidence anyone is in
 favor of what I suggested; most people couldn't give a damn and the few
 that have responded seem opposed.  (Like almost everything else I've
 tried to do for NetBSD.)  So there's probably no point in keeping the
 PR open.

 /~\ The ASCII              der Mouse
 \ / Ribbon Campaign
  X  Against HTML          [email protected]
 / \ Email!      7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B

From: Jarom๏ฟฝr Dolecek <[email protected]>
To: der Mouse <[email protected]>
Cc: [email protected]
Subject: Re: kern/2675
Date: Sun, 7 Oct 2001 21:04:18 +0200 (CEST)

 der Mouse wrote:
 > Well, of *course* the i386 solution is best for all the other ports!
 > Let's port fdisk immediately!

 Nono. It's just that that I'm reluctant to use something different
 if solution on one arch is good and suitable for other archs too.

 > More seriously, what *is* the i386 solution?  As of my freeze point,
 > the i386 port is still at MAXPARTITIONS=8.

 See <i386/disklabel.h>. The i386 solution is to use 'big' minors for
 partitions >8. Seems quite simple, does the job and maintains
 backward compatibility well. I think it could be adopted by
 other archs with only minor efford.

 > Not that it matters, I suppose.  I've seen no evidence anyone is in
 > favor of what I suggested; most people couldn't give a damn and the few
 > that have responded seem opposed.  (Like almost everything else I've
 > tried to do for NetBSD.)  So there's probably no point in keeping the
 > PR open.

 Well, there is - sparc still has MAXPARTITIONS=8 :)

 Jaromir
 -- 
 Jaromir Dolecek <[email protected]>      http://www.ics.muni.cz/~dolecek/
 NetBSD - just plain best OS! -=*=- Got spare MCA cards or docs? Hand me them!

From: der Mouse <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: Re: kern/2675
Date: Sat, 5 Jan 2002 15:38:44 -0500 (EST)

 > See <i386/disklabel.h>.  The i386 solution is to use 'big' minors for
 > partitions >8.  Seems quite simple, does the job and maintains
 > backward compatibility well.

 Oh, that's a solution to only the minor-numbering issue; it's got
 nothing to do with the rest of it, such as on-disk labels.

 I think it's really ugly (not to mention comparatively expensive,
 though I suppose converting between minor number and <unit,part> pairs
 doesn't happen all that often).  Having the mapping between <unit,part>
 pairs and minor numbers be that grossly nonlinear for all future time
 seems worse, to me, than one flag day in /dev.  That way lies a system
 that's little but an accretion of scar tissue upon scar tissue as each
 new feature doesn't dare break backward compatability in the slightest.

 But if that's is the way NetBSD has decided It Shall Be, to the point
 of refusing a working, burnt-in addressing of the issue that takes a
 different tack, then I guess it's that or nothing.  So far it's been
 nothing, and since it appears SPARC users are content with that, and
 the issue is a non-problem for me, it's no skin off my nose either way.

 I don't think it affects what I wrote except for the definition of
 dkpart() in disksubr.c (see the addon I sent just after the patches)
 and the corresponding MAKEDEV changes.

 /~\ The ASCII              der Mouse
 \ / Ribbon Campaign
  X  Against HTML          [email protected]
 / \ Email!      7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B
State-Changed-From-To: feedback->open 
State-Changed-By: fair 
State-Changed-When: Sun Jan 6 14:28:34 PST 2002 
State-Changed-Why:  
Feedback has been provided, and we should answer it properly. 

From: der Mouse <[email protected]>
To: [email protected]
Cc:  
Subject: Re: kern/2675
Date: Sun, 6 Jan 2002 19:21:30 -0500 (EST)

 > Feedback has been provided, and we should answer it properly.

 Arguably, I'm also the one who should be answering it, as I'm
 theoretically here as a PR cruncher.  But ISTM there is insufficient
 consensus that any part of the patchset in the PR is a Right enough
 Thing to commit. :-)

 In particular, ISTR seeing it said that /sparc -current hides a
 full-blown native NetBSD disklabel in the spare space I put the
 extended partitions in.  If this is true (it could be just confused
 memory), there is insufficient room to expand it to 16 partitions.  (By
 my count, an N-partition NetBSD disklabel occupies 148+(16*N) bytes.
 This means that the most partitions that can be fit into that 292-byte
 unused area by this method is 9.  By contrast, there's space for 35
 "extended" partitions, 43 total, the way I did it (and four bytes left
 over) - but those partitions have Sun-disklabel constraints.  This is
 more than MAXMAXPARTITIONS, but given the reason MAXMAXPARTITIONS is as
 low as it is, it's not clear that its limit should apply to a port that
 doesn't always have a full-blown NetBSD disklabel on-disk.  What, if
 anything, is MAXMAXPARTITIONS used for, anyway?)

 At any rate, if the decision is to go with a relatively high partition
 count by extending the Sun label, my patches may at least be a useful
 starting point.  (But more likely from historical evidence, I'd say, is
 that people will argue about what the right thing is and end up doing
 nothing because the argument is never settled.  Sigh.)

 /~\ The ASCII              der Mouse
 \ / Ribbon Campaign
  X  Against HTML          [email protected]
 / \ Email!      7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B

From: matthew green <[email protected]>
To: [email protected]
Cc:  
Subject: re: kern/2675
Date: Sat, 03 Apr 2004 02:49:22 +1000

 BTW, when fixing this problem for sparc one should be aware of PR#20277.
State-Changed-From-To: open->closed 
State-Changed-By: mycroft 
State-Changed-When: Tue Jul 6 06:17:38 UTC 2004 
State-Changed-Why:  
This was increased to 16 a long time ago. 
Responsible-Changed-From-To: kern-bug-people->port-sparc-maintainer
Responsible-Changed-By: [email protected]
Responsible-Changed-When: Wed, 19 Jul 2006 02:59:14 +0000
Responsible-Changed-Why:
This is sparc specific.


State-Changed-From-To: closed->open
State-Changed-By: [email protected]
State-Changed-When: Wed, 19 Jul 2006 02:59:14 +0000
State-Changed-Why:
The problem has only been solved for i386/amd64 and not generally.



ls -lW /dir/whiteout fails, but ls -lW /dir shows the whiteout

Metadata

  • Number: 3166
  • Originator: Marc Horowitz <[email protected]>
  • Arrived: Thu Jan 30 14:20:00 +0000 1997
  • Last modified:
  • Environment: System: NetBSD rover 1.2B NetBSD 1.2B (MARC) #0: Thu Nov 7 00:29:02 EST 1996 marc@rover:/u3/netbsd/src/sys/arch/i386/compile/MARC i386

Description



ls doesn't deal properly with listing whiteouts when a filename which
is a whiteout is specified.

It is true that the man page documents the behavior as is, but I
believe the behavior is incorrect.


How to repeat



> ls -lW /usr/local/bin
...
-rwxr-xr-x  1 marc  wheel    23660 Jan 20 14:11 emacsclient
?---------  0 root  wheel        0 Dec 31  1969 etags
-rwxr-xr-x  1 root  wheel  1164085 Jul  9  1996 expect
...
> /tmp/ls -lW /usr/local/bin/etags
ls: /usr/local/bin/etags: No such file or directory
> /tmp/ls -W /usr/local/bin/etags
ls: /usr/local/bin/etags: No such file or directory

in the last two cases, the whiteout does exist, so the error is in
error.


A union mount of a directory onto the same directory causes havoc

Metadata

  • Number: 3645
  • Originator: Rick Byers <[email protected]>
  • Arrived: Sun May 18 13:05:00 +0000 1997
  • Last modified: Mon Jun 07 06:42:23 +0000 1999
  • Environment: System: NetBSD rickb.iaw.on.ca 1.2E NetBSD 1.2E (RICKB) #3: Sat May 10 20:04:10 EST 1997 [email protected]:/usr/src/sys/arch/i386/compile/RICKB i386

Description


    A union mount from one directory onto the same directory causes the system to pretty much
    lock up.  For A while, I can ps etc, but any disk activity causes it to look up.  The mount
    process (or any other locked process) cannot be killed.  Generally the entire system
    completely locks up pretty quickly.  No special priveledges are required - any directory
    that the user owns can be used.

How to repeat


    mount_union somedir somedir

Fix


    No sure.  Definantly a kernel problem.  I've temporarily disabled the mount_union
    command, but that doesn't stop users from compiling their own program that attempts a 
    union mount.

Audit trail


State-Changed-From-To: open->feedback 
State-Changed-By: hwr 
State-Changed-When: Sat May 8 02:42:23 PDT 1999 
State-Changed-Why:  
Could you try, is this still happens with actual code? It might be that 
this went away with Lite2 merger. (yes, I know that your PR is 2 years old *sigh*) 

From: Rick Byers <[email protected]>
To: [email protected]
Cc:  Subject: kern/3645
Date: Sun, 23 May 1999 17:22:15 -0400

 The mount_union binary will no longer do this, but the kernel will.  A
 modified binary can still easily crash the system when the UNIONFS is in
 the kernel.
State-Changed-From-To: feedback->open 
State-Changed-By: hwr 
State-Changed-When: Sun Jun 6 23:41:42 PDT 1999 
State-Changed-Why:  
This is still a problem. 

non-512 bytes/sector media support case 1

Metadata

  • Number: 3790
  • Originator: Koji Imada - je4owb/2 <[email protected]>
  • Arrived: Wed Jun 25 01:35:01 +0000 1997
  • Last modified:
  • Environment: System: NetBSD bimota 1.2E NetBSD 1.2E (BIMOTA) #: Wed Jun 11 02:13:27 JST 1997 koji@ducati:/mnt2/NetBSD/work/src-ufs-mod/sys/arch/i386/compile/BIMOTA i386

Description


    Modification required to support non-512 bytes/sector media
    for file system and device drivers.

    This is case 1 of 3 implementation. This changes block io unit 
    to natural size of device and adapts file systems(cd9660, ffs
    msdosfs) and device driver(cd, sd).

    I will send mail to tech-kern about these 3 implementation.

    Also, these obsoletes kern/3460 and kern/3458

How to repeat


    Current NetBSD can't handle non-512 bytes/sector media properly.

Fix


    Apply following patches
Index: sys/arch/i386/i386/disksubr.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/arch/i386/i386/disksubr.c,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -u -r1.1.1.2 -r1.2
--- disksubr.c  1997/04/01 07:21:40 1.1.1.2
+++ disksubr.c  1997/05/29 17:50:43 1.2
@@ -91,7 +91,7 @@
    lp->d_partitions[i].p_offset = 0;

    /* get a buffer and initialize it */
-   bp = geteblk((int)lp->d_secsize);
+   bp = geteblk((int)BLKDEV_IOSIZE);
    bp->b_dev = dev;

    /* do dos partitions in the process of getting disklabel? */
@@ -100,6 +100,12 @@
    if (osdep && (dp = osdep->dosparts) != NULL) {
        /* read master boot record */
        bp->b_blkno = DOSBBSECTOR;
+#if 0
+       if (lp->d_secsize > DEV_BSIZE)
+           bp->b_blkno *= lp->d_secsize / DEV_BSIZE;
+       else
+           bp->b_blkno /= DEV_BSIZE / lp->d_secsize;
+#endif
        bp->b_bcount = lp->d_secsize;
        bp->b_flags = B_BUSY | B_READ;
        bp->b_cylin = DOSBBSECTOR / lp->d_secpercyl;
@@ -148,8 +154,14 @@

    /* next, dig out disk label */
    bp->b_blkno = dospartoff + LABELSECTOR;
+#if 0
+   if (lp->d_secsize > DEV_BSIZE)
+       bp->b_blkno *= lp->d_secsize / DEV_BSIZE;
+   else
+       bp->b_blkno /= DEV_BSIZE / lp->d_secsize;
+#endif
    bp->b_cylin = cyl;
-   bp->b_bcount = lp->d_secsize;
+   bp->b_bcount = BLKDEV_IOSIZE;
    bp->b_flags = B_BUSY | B_READ;
    (*strat)(bp);

@@ -159,7 +171,7 @@
        goto done;
    }
    for (dlp = (struct disklabel *)bp->b_data;
-       dlp <= (struct disklabel *)(bp->b_data + lp->d_secsize - sizeof(*dlp));
+       dlp <= (struct disklabel *)(bp->b_data + BLKDEV_IOSIZE - sizeof(*dlp));
        dlp = (struct disklabel *)((char *)dlp + sizeof(long))) {
        if (dlp->d_magic != DISKMAGIC || dlp->d_magic2 != DISKMAGIC) {
            if (msg == NULL)
@@ -186,10 +198,12 @@
            /* read a bad sector table */
            bp->b_flags = B_BUSY | B_READ;
            bp->b_blkno = lp->d_secperunit - lp->d_nsectors + i;
+#if 0
            if (lp->d_secsize > DEV_BSIZE)
                bp->b_blkno *= lp->d_secsize / DEV_BSIZE;
            else
                bp->b_blkno /= DEV_BSIZE / lp->d_secsize;
+#endif
            bp->b_bcount = lp->d_secsize;
            bp->b_cylin = lp->d_ncylinders - 1;
            (*strat)(bp);
@@ -291,7 +305,7 @@
    int error, dospartoff, cyl, i;

    /* get a buffer and initialize it */
-   bp = geteblk((int)lp->d_secsize);
+   bp = geteblk(BLKDEV_IOSIZE);
    bp->b_dev = dev;

    /* do dos partitions in the process of getting disklabel? */
@@ -300,6 +314,12 @@
    if (osdep && (dp = osdep->dosparts) != NULL) {
        /* read master boot record */
        bp->b_blkno = DOSBBSECTOR;
+#if 0
+       if (lp->d_secsize > DEV_BSIZE)
+           bp->b_blkno *= lp->d_secsize / DEV_BSIZE;
+       else
+           bp->b_blkno /= DEV_BSIZE / lp->d_secsize;
+#endif
        bp->b_bcount = lp->d_secsize;
        bp->b_flags = B_BUSY | B_READ;
        bp->b_cylin = DOSBBSECTOR / lp->d_secpercyl;
@@ -333,8 +353,14 @@

    /* next, dig out disk label */
    bp->b_blkno = dospartoff + LABELSECTOR;
+#if 0
+   if (lp->d_secsize > DEV_BSIZE)
+       bp->b_blkno *= lp->d_secsize / DEV_BSIZE;
+   else
+       bp->b_blkno /= DEV_BSIZE / lp->d_secsize;
+#endif
    bp->b_cylin = cyl;
-   bp->b_bcount = lp->d_secsize;
+   bp->b_bcount = BLKDEV_IOSIZE;
    bp->b_flags = B_BUSY | B_READ;
    (*strat)(bp);

@@ -342,7 +368,7 @@
    if ((error = biowait(bp)) != 0)
        goto done;
    for (dlp = (struct disklabel *)bp->b_data;
-       dlp <= (struct disklabel *)(bp->b_data + lp->d_secsize - sizeof(*dlp));
+       dlp <= (struct disklabel *)(bp->b_data + BLKDEV_IOSIZE - sizeof(*dlp));
        dlp = (struct disklabel *)((char *)dlp + sizeof(long))) {
        if (dlp->d_magic == DISKMAGIC && dlp->d_magic2 == DISKMAGIC &&
            dkcksum(dlp) == 0) {
@@ -374,12 +400,21 @@
 {
    struct partition *p = lp->d_partitions + DISKPART(bp->b_dev);
    int labelsector = lp->d_partitions[2].p_offset + LABELSECTOR;
-   int sz;
+   int sz, blkno;
+
+#if 1
+   blkno = bp->b_blkno;
+#else
+   if (lp->d_secsize > DEV_BSIZE)
+       blkno = bp->b_blkno / (lp->d_secsize / DEV_BSIZE);
+   else
+       blkno = bp->b_blkno * (DEV_BSIZE / lp->d_secsize);
+#endif

    sz = howmany(bp->b_bcount, lp->d_secsize);

-   if (bp->b_blkno + sz > p->p_size) {
-       sz = p->p_size - bp->b_blkno;
+   if (blkno + sz > p->p_size) {
+       sz = p->p_size - blkno;
        if (sz == 0) {
            /* If exactly at end of disk, return EOF. */
            bp->b_resid = bp->b_bcount;
@@ -391,13 +426,13 @@
            goto bad;
        }
        /* Otherwise, truncate request. */
-       bp->b_bcount = sz << DEV_BSHIFT;
+       bp->b_bcount = sz * lp->d_secsize;
    }

    /* Overwriting disk label? */
-   if (bp->b_blkno + p->p_offset <= labelsector &&
+   if (blkno + p->p_offset <= labelsector &&
 #if LABELSECTOR != 0
-       bp->b_blkno + p->p_offset + sz > labelsector &&
+       blkno + p->p_offset + sz > labelsector &&
 #endif
        (bp->b_flags & B_READ) == 0 && !wlabel) {
        bp->b_error = EROFS;
@@ -405,8 +440,7 @@
    }

    /* calculate cylinder for disksort to order transfers with */
-   bp->b_cylin = (bp->b_blkno + p->p_offset) /
-       (lp->d_secsize / DEV_BSIZE) / lp->d_secpercyl;
+   bp->b_cylin = (blkno + p->p_offset) / lp->d_secpercyl;
    return (1);

 bad:
Index: sys/dev/vnd.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/dev/vnd.c,v
retrieving revision 1.1.1.5
retrieving revision 1.4
diff -u -r1.1.1.5 -r1.4
--- vnd.c   1997/06/23 16:24:04 1.1.1.5
+++ vnd.c   1997/06/24 03:11:11 1.4
@@ -94,6 +94,10 @@
 #define b_cylin    b_resid

 #define    vndunit(x)  DISKUNIT(x)
+#define VNDPART(dev)   DISKPART(dev)
+#define MAKEVNDDEV(maj, unit, part)    MAKEDISKDEV(maj, unit, part)
+
+#define VNDLABELDEV(dev) (MAKEVNDDEV(major(dev), vndunit(dev), RAW_PART))

 struct vndxfer {
    struct buf  *vx_bp;     /* Pointer to parent buffer */
@@ -118,6 +122,9 @@
 struct vnd_softc {
    int      sc_flags;  /* flags */
    size_t       sc_size;   /* size of vnd */
+   int      sc_bsize;  /* block size for special file */
+   int      sc_blksize;    /* number of bytes/dector */
+   int      sc_bshift; /* shift constant */
    struct vnode    *sc_vp;     /* vnode */
    struct ucred    *sc_cred;   /* credentials */
    int      sc_maxactive;  /* max # of active requests */
@@ -129,6 +136,8 @@
 /* sc_flags */
 #define    VNF_ALIVE   0x01
 #define VNF_INITED 0x02
+#define VNF_WLABEL 0x04
+#define VNF_LABELLING  0x08
 #define VNF_WANTED 0x40
 #define VNF_LOCKED 0x80

@@ -140,10 +149,11 @@

 void   vndclear __P((struct vnd_softc *));
 void   vndstart __P((struct vnd_softc *));
-int    vndsetcred __P((struct vnd_softc *, struct ucred *));
+int    vndsetcred __P((struct vnd_softc *, struct ucred *, struct proc *p));
 void   vndthrottle __P((struct vnd_softc *, struct vnode *));
 void   vndiodone __P((struct buf *));
 void   vndshutdown __P((void));
+void   vndgetdisklabel __P((dev_t dev, struct vnd_softc *vnd));

 static int vndlock __P((struct vnd_softc *));
 static void vndunlock __P((struct vnd_softc *));
@@ -196,6 +206,15 @@
    part = DISKPART(dev);
    pmask = (1 << part);

+   /* Check that the partition exists. */
+   if (part != RAW_PART &&
+       ((sc->sc_flags & VNF_INITED) == 0 ||
+        part >= sc->sc_dkdev.dk_label->d_npartitions ||
+        sc->sc_dkdev.dk_label->d_partitions[part].p_fstype == FS_UNUSED)) {
+       error = ENXIO;
+       goto bad;
+   }
+
    /* Prevent our unit from being unconfigured while open. */
    switch (mode) {
    case S_IFCHR:
@@ -211,6 +230,10 @@

    vndunlock(sc);
    return (0);
+
+bad:
+   vndunlock(sc);
+   return error;
 }

 int
@@ -272,6 +295,7 @@
    int sz, flags, error;

 #ifdef DEBUG
+   printf("vndstrategy(%p): bsize %ld\n", bp, vnd->sc_vp->v_mount->mnt_stat.f_iosize);
    if (vnddebug & VDB_FOLLOW)
        printf("vndstrategy(%p): unit %d\n", bp, unit);
 #endif
@@ -281,9 +305,28 @@
        biodone(bp);
        return;
    }
+
+   if (VNDPART(bp->b_dev) != RAW_PART &&
+       bounds_check_with_label(bp, vnd->sc_dkdev.dk_label,
+       (vnd->sc_flags & (VNF_WLABEL|VNF_LABELLING)) != 0) <= 0) {
+       bp->b_resid = bp->b_bcount;
+       biodone(bp);
+       return;
+   }
+
+#if 1
    bn = bp->b_blkno;
-   sz = howmany(bp->b_bcount, DEV_BSIZE);
+#else
+   bn = bp->b_blkno / (vnd->sc_dkdev.dk_label->d_secsize / DEV_BSIZE);
+#endif
    bp->b_resid = bp->b_bcount;
+   sz = howmany(bp->b_bcount, vnd->sc_blksize);
+
+   if (VNDPART(bp->b_dev) != RAW_PART) {
+       bn += vnd->sc_dkdev.dk_label->d_partitions[VNDPART(bp->b_dev)].p_offset;
+   }
+   bn *= vnd->sc_dkdev.dk_label->d_secsize / vnd->sc_blksize;
+
    if (bn < 0 || bn + sz > vnd->sc_size) {
        if (bn != vnd->sc_size) {
            bp->b_error = EINVAL;
@@ -292,8 +335,13 @@
        biodone(bp);
        return;
    }
-   bn = dbtob(bn);
+
+   bn = bn << vnd->sc_bshift;
+#if 1
+   bsize = vnd->sc_bsize;
+#else
    bsize = vnd->sc_vp->v_mount->mnt_stat.f_iosize;
+#endif
    addr = bp->b_data;
    flags = bp->b_flags | B_CALL;

@@ -512,6 +560,7 @@
 {
    int unit = vndunit(dev);
    struct vnd_softc *sc;
+   int bshift;

 #ifdef DEBUG
    if (vnddebug & VDB_FOLLOW)
@@ -524,8 +573,9 @@

    if ((sc->sc_flags & VNF_INITED) == 0)
        return (ENXIO);
+   bshift = ffs(sc->sc_dkdev.dk_label->d_secsize)-1;

-   return (physio(vndstrategy, NULL, dev, B_READ, minphys, uio));
+   return (physio2(vndstrategy, NULL, dev, B_READ, minphys, uio, bshift));
 }

 /* ARGSUSED */
@@ -537,6 +587,7 @@
 {
    int unit = vndunit(dev);
    struct vnd_softc *sc;
+   int bshift;

 #ifdef DEBUG
    if (vnddebug & VDB_FOLLOW)
@@ -549,8 +600,9 @@

    if ((sc->sc_flags & VNF_INITED) == 0)
        return (ENXIO);
+   bshift = ffs(sc->sc_dkdev.dk_label->d_secsize)-1;

-   return (physio(vndstrategy, NULL, dev, B_WRITE, minphys, uio));
+   return (physio2(vndstrategy, NULL, dev, B_WRITE, minphys, uio, bshift));
 }

 /* ARGSUSED */
@@ -588,6 +640,10 @@
        if (vnd->sc_flags & VNF_INITED)
            return (EBUSY);

+       if (vio->vnd_size == 0 || vio->vnd_size % DEV_BSIZE != 0 ||
+           vio->vnd_size > BLKDEV_IOSIZE)
+           vio->vnd_size = DEV_BSIZE;
+
        if ((error = vndlock(vnd)) != 0)
            return (error);

@@ -602,23 +658,55 @@
            vndunlock(vnd);
            return(error);
        }
-       error = VOP_GETATTR(nd.ni_vp, &vattr, p->p_ucred, p);
+       if (nd.ni_vp->v_type == VBLK || nd.ni_vp->v_type == VCHR) {
+           struct partinfo dpart;
+
+           dpart.disklab = NULL;
+           dpart.part = NULL;
+           error = VOP_IOCTL(nd.ni_vp, DIOCGPART, (caddr_t)&dpart,
+               FREAD, NOCRED, p);
+           if (error == 0) {
+               if (dpart.disklab != NULL && dpart.disklab->d_secsize != 0)
+                   vattr.va_blocksize = dpart.disklab->d_secsize;
+               else
+                   vattr.va_blocksize = DEV_BSIZE;
+               if (dpart.part == NULL)
+                   vattr.va_size = 0;
+               else {
+                   vattr.va_size = dpart.part->p_size *
+                       dpart.disklab->d_secsize;
+               }
+           }
+       } else {
+           error = VOP_GETATTR(nd.ni_vp, &vattr, p->p_ucred, p);
+       }
        if (error) {
            VOP_UNLOCK(nd.ni_vp);
            (void) vn_close(nd.ni_vp, FREAD|FWRITE, p->p_ucred, p);
            vndunlock(vnd);
            return(error);
        }
+           
        VOP_UNLOCK(nd.ni_vp);
        vnd->sc_vp = nd.ni_vp;
-       vnd->sc_size = btodb(vattr.va_size);    /* note truncation */
-       if ((error = vndsetcred(vnd, p->p_ucred)) != 0) {
+       vnd->sc_blksize = vio->vnd_size;
+       vnd->sc_bshift = ffs(vnd->sc_blksize) - 1;
+       vnd->sc_size = vattr.va_size >> vnd->sc_bshift; /* note truncation */
+       if (nd.ni_vp->v_type != VBLK && nd.ni_vp->v_type != VCHR) {
+           vnd->sc_bsize = nd.ni_vp->v_mount->mnt_stat.f_iosize;
+       } else {
+           if (vattr.va_blocksize != 0)
+               vnd->sc_bsize = vattr.va_blocksize;
+           else
+               vnd->sc_bsize = DEV_BSIZE;
+       }
+       if ((error = vndsetcred(vnd, p->p_ucred, p)) != 0) {
            (void) vn_close(nd.ni_vp, FREAD|FWRITE, p->p_ucred, p);
            vndunlock(vnd);
            return(error);
        }
        vndthrottle(vnd, vnd->sc_vp);
-       vio->vnd_size = dbtob(vnd->sc_size);
+       vio->vnd_size = vnd->sc_size << vnd->sc_bshift;
        vnd->sc_flags |= VNF_INITED;
 #ifdef DEBUG
        if (vnddebug & VDB_INIT)
@@ -632,6 +720,8 @@
        vnd->sc_dkdev.dk_name = vnd->sc_xname;
        disk_attach(&vnd->sc_dkdev);

+       vndgetdisklabel(dev, vnd);
+
        vndunlock(vnd);

        break;
@@ -673,6 +763,60 @@
    /*
     * XXX Should support disklabels.
     */
+   case DIOCGDINFO:
+       if ((vnd->sc_flags & VNF_INITED) == 0)
+           return (ENXIO);
+
+       *(struct disklabel *)data = *(vnd->sc_dkdev.dk_label);
+       return 0;
+
+   case DIOCGPART:
+       if ((vnd->sc_flags & VNF_INITED) == 0)
+           return (ENXIO);
+
+       ((struct partinfo *)data)->disklab = vnd->sc_dkdev.dk_label;
+       ((struct partinfo *)data)->part =
+           &vnd->sc_dkdev.dk_label->d_partitions[VNDPART(dev)];
+       return 0;
+
+
+   case DIOCWDINFO:
+   case DIOCSDINFO:
+       if ((vnd->sc_flags & VNF_INITED) == 0)
+           return (ENXIO);
+
+       if ((flag & FWRITE) == 0)
+           return EBADF;
+
+       if ((error = vndlock(vnd)) != 0)
+           return error;
+       vnd->sc_flags |= VNF_LABELLING;
+
+       error = setdisklabel(vnd->sc_dkdev.dk_label,
+           (struct disklabel *)data, /*vnd->sc_dkdev.dk_openmask : */0,
+           vnd->sc_dkdev.dk_cpulabel);
+       if (error == 0) {
+           if (cmd == DIOCWDINFO)
+               error = writedisklabel(VNDLABELDEV(dev),
+                   vndstrategy, vnd->sc_dkdev.dk_label,
+                   vnd->sc_dkdev.dk_cpulabel);
+       }
+
+       vnd->sc_flags &= ~VNF_LABELLING;
+       vndunlock(vnd);
+       return error;
+
+   case DIOCWLABEL:
+       if ((vnd->sc_flags & VNF_INITED) == 0)
+           return (ENXIO);
+
+       if ((flag & FWRITE) == 0)
+           return EBADF;
+       if (*(int *)data)
+           vnd->sc_flags |= VNF_WLABEL;
+       else
+           vnd->sc_flags &= ~VNF_WLABEL;
+       return 0;

    default:
        return(ENOTTY);
@@ -682,15 +826,69 @@
 }

 /*
+ * Load the label information on the named device
+ */
+void
+vndgetdisklabel(dev, vnd)
+   dev_t dev;
+   struct vnd_softc *vnd;
+{
+   struct disklabel *lp = vnd->sc_dkdev.dk_label;
+   char *errstring;
+
+   bzero(lp, sizeof(struct disklabel));
+   bzero(vnd->sc_dkdev.dk_cpulabel, sizeof(struct cpu_disklabel));
+
+   lp->d_secsize = vnd->sc_blksize;
+   lp->d_ntracks = 64;
+   lp->d_nsectors = 32;
+   lp->d_ncylinders = vnd->sc_size / (64 * 32);
+   lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors;
+   if (lp->d_secpercyl == 0) {
+       lp->d_secpercyl = 100;
+       /* as long as it's not 0 - readdisklabel divides by it (?) */
+   }
+
+   strncpy(lp->d_typename, "vnode disk", 16);
+   lp->d_type = DTYPE_VND;
+   strncpy(lp->d_packname, "fictitious", 16);
+   lp->d_secperunit = vnd->sc_size;
+   lp->d_rpm = 3600;
+   lp->d_interleave = 1;
+   lp->d_flags = 0;
+
+   lp->d_partitions[RAW_PART].p_offset = 0;
+   lp->d_partitions[RAW_PART].p_size =
+       lp->d_secperunit;
+   lp->d_partitions[RAW_PART].p_fstype = FS_UNUSED;
+   lp->d_npartitions = RAW_PART + 1;
+
+   lp->d_magic = DISKMAGIC;
+   lp->d_magic2 = DISKMAGIC;
+   lp->d_checksum = dkcksum(lp);
+
+   /*
+    * Call the generic disklabel extraction routine
+    */
+   errstring = readdisklabel(dev,
+                 vndstrategy, lp, vnd->sc_dkdev.dk_cpulabel);
+   if (errstring) {
+       printf("%s: %s\n", vnd->sc_xname, errstring);
+       return;
+   }
+}
+
+/*
  * Duplicate the current processes' credentials.  Since we are called only
  * as the result of a SET ioctl and only root can do that, any future access
  * to this "disk" is essentially as root.  Note that credentials may change
  * if some other uid can write directly to the mapped file (NFS).
  */
 int
-vndsetcred(vnd, cred)
+vndsetcred(vnd, cred, p)
    register struct vnd_softc *vnd;
    struct ucred *cred;
+   struct proc *p;
 {
    struct uio auio;
    struct iovec aiov;
@@ -709,6 +907,7 @@
    auio.uio_rw = UIO_READ;
    auio.uio_segflg = UIO_SYSSPACE;
    auio.uio_resid = aiov.iov_len;
+   auio.uio_procp = p;
    VOP_LOCK(vnd->sc_vp);
    error = VOP_READ(vnd->sc_vp, &auio, 0, vnd->sc_cred);
    VOP_UNLOCK(vnd->sc_vp);
Index: sys/isofs/cd9660/cd9660_bmap.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/isofs/cd9660/cd9660_bmap.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 cd9660_bmap.c
--- cd9660_bmap.c   1997/04/01 07:13:06 1.1.1.2
+++ cd9660_bmap.c   1997/06/25 07:27:12
@@ -84,7 +84,11 @@
     * Compute the requested block number
     */
    bshift = ip->i_mnt->im_bshift;
-   *ap->a_bnp = (ip->iso_start + lblkno) << (bshift - DEV_BSHIFT);
+#if 0
+   *ap->a_bnp = (ip->iso_start + lblkno) << ip->i_mnt->im_sshift;
+#else
+   *ap->a_bnp = (ip->iso_start + lblkno);
+#endif

    /*
     * Determine maximum number of readahead blocks following the
Index: sys/isofs/cd9660/cd9660_rrip.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/isofs/cd9660/cd9660_rrip.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 cd9660_rrip.c
--- cd9660_rrip.c   1997/04/01 07:13:10 1.1.1.2
+++ cd9660_rrip.c   1997/06/25 07:27:24
@@ -574,7 +574,11 @@
            if (ana->iso_ce_blk >= ana->imp->volume_space_size
                || ana->iso_ce_off + ana->iso_ce_len > ana->imp->logical_block_size
                || bread(ana->imp->im_devvp,
-                    ana->iso_ce_blk << (ana->imp->im_bshift - DEV_BSHIFT),
+#if 0
+                    ana->iso_ce_blk << ana->imp->im_sshift,
+#else
+                    ana->iso_ce_blk,
+#endif
                     ana->imp->logical_block_size, NOCRED, &bp))
                /* what to do now? */
                break;
Index: sys/isofs/cd9660/cd9660_vfsops.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/isofs/cd9660/cd9660_vfsops.c,v
retrieving revision 1.1.1.3
diff -u -r1.1.1.3 cd9660_vfsops.c
--- cd9660_vfsops.c 1997/06/23 16:26:16 1.1.1.3
+++ cd9660_vfsops.c 1997/06/25 07:29:13
@@ -233,6 +233,13 @@
    struct iso_primary_descriptor *pri;
    struct iso_directory_record *rootp;
    int logical_block_size;
+#if 0
+   struct partinfo dpart;
+   int bsize, sshift;
+   struct ucred *cred;
+
+   cred = p ? p->p_ucred : NOCRED;
+#endif

    if (!ronly)
        return EROFS;
@@ -260,10 +267,23 @@
     * whichever is greater.  For now, we'll just use a constant.
     */
    iso_bsize = ISO_DEFAULT_BLOCK_SIZE;
+#if 0
+   if (VOP_IOCTL(devvp, DIOCGPART, (caddr_t)&dpart, FREAD, cred, p) != 0)
+       bsize = DEV_BSIZE;
+   else
+       bsize = dpart.disklab->d_secsize;
+
+   sshift = ffs(iso_bsize) - ffs(bsize);
+#endif

    for (iso_blknum = 16; iso_blknum < 100; iso_blknum++) {
-       if ((error = bread(devvp, iso_blknum * btodb(iso_bsize),
+#if 0
+       if ((error = bread(devvp, iso_blknum << sshift,
+                  iso_bsize, NOCRED, &bp)) != 0)
+#else
+       if ((error = bread(devvp, iso_blknum,
                   iso_bsize, NOCRED, &bp)) != 0)
+#endif
            goto out;

        vdp = (struct iso_volume_descriptor *)bp->b_data;
@@ -312,6 +332,10 @@
    while ((1 << isomp->im_bshift) < isomp->logical_block_size)
        isomp->im_bshift++;

+#if 0
+   isomp->system_block_size = bsize;
+   isomp->im_sshift = sshift;
+#endif
    bp->b_flags |= B_AGE;
    brelse(bp);
    bp = NULL;
@@ -331,7 +355,11 @@
    if (!(argp->flags & ISOFSMNT_NORRIP)) {
        if ((error = bread(isomp->im_devvp,
                   (isomp->root_extent + isonum_711(rootp->ext_attr_length)) <<
-                  (isomp->im_bshift - DEV_BSHIFT),
+#if 0
+                  isomp->im_sshift,
+#else
+                  0,
+#endif
                   isomp->logical_block_size, NOCRED,
                   &bp)) != 0)
            goto out;
Index: sys/kern/kern_physio.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/kern/kern_physio.c,v
retrieving revision 1.1.1.3
retrieving revision 1.2
diff -u -r1.1.1.3 -r1.2
--- kern_physio.c   1997/05/23 21:58:02 1.1.1.3
+++ kern_physio.c   1997/05/29 17:50:47 1.2
@@ -78,6 +78,19 @@
    void (*minphys) __P((struct buf *));
    struct uio *uio;
 {
+   return physio2(strategy, bp, dev, flags, minphys, uio, DEV_BSHIFT);
+}
+
+int
+physio2(strategy, bp, dev, flags, minphys, uio, bshift)
+   void (*strategy) __P((struct buf *));
+   struct buf *bp;
+   dev_t dev;
+   int flags;
+   void (*minphys) __P((struct buf *));
+   struct uio *uio;
+   int bshift;
+{
    struct iovec *iovp;
    struct proc *p = curproc;
    int error, done, i, nobuf, s, todo;
@@ -143,7 +156,12 @@
            bp->b_flags = B_BUSY | B_PHYS | B_RAW | flags;

            /* [set up the buffer for a maximum-sized transfer] */
+#if 1
+           bp->b_blkno = uio->uio_offset >> bshift;
+#else
            bp->b_blkno = btodb(uio->uio_offset);
+#endif
+
            bp->b_bcount = iovp->iov_len;
            bp->b_data = iovp->iov_base;

Index: sys/scsi/cd.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/scsi/cd.c,v
retrieving revision 1.1.1.3
retrieving revision 1.2
diff -u -r1.1.1.3 -r1.2
--- cd.c    1997/04/11 07:23:35 1.1.1.3
+++ cd.c    1997/05/29 17:50:50 1.2
@@ -549,13 +549,18 @@
         * First, translate the block to absolute and put it in terms
         * of the logical blocksize of the device.
         */
+#if 1
+       blkno = bp->b_blkno;
+#else
        blkno =
            bp->b_blkno / (cd->sc_dk.dk_label->d_secsize / DEV_BSIZE);
+#endif
        if (CDPART(bp->b_dev) != RAW_PART) {
              p = &cd->sc_dk.dk_label->d_partitions[CDPART(bp->b_dev)];
              blkno += p->p_offset;
        }
-       nblks = howmany(bp->b_bcount, cd->sc_dk.dk_label->d_secsize);
+       blkno *= cd->sc_dk.dk_label->d_secsize / cd->params.blksize;
+       nblks = howmany(bp->b_bcount, cd->params.blksize);

        /*
         *  Fill out the scsi command.  If the transfer will
@@ -647,8 +652,10 @@
    struct uio *uio;
    int ioflag;
 {
+   struct cd_softc *cd = cd_cd.cd_devs[CDUNIT(dev)];
+   int bshift = ffs(cd->sc_dk.dk_label->d_secsize)-1;

-   return (physio(cdstrategy, NULL, dev, B_READ, cdminphys, uio));
+   return (physio2(cdstrategy, NULL, dev, B_READ, cdminphys, uio, bshift));
 }

 int
@@ -657,8 +664,10 @@
    struct uio *uio;
    int ioflag;
 {
+   struct cd_softc *cd = cd_cd.cd_devs[CDUNIT(dev)];
+   int bshift = ffs(cd->sc_dk.dk_label->d_secsize)-1;

-   return (physio(cdstrategy, NULL, dev, B_WRITE, cdminphys, uio));
+   return (physio2(cdstrategy, NULL, dev, B_WRITE, cdminphys, uio, bshift));
 }

 /*
@@ -942,6 +951,7 @@
    struct cd_softc *cd;
 {
    struct disklabel *lp = cd->sc_dk.dk_label;
+   char *errstring;

    bzero(lp, sizeof(struct disklabel));
    bzero(cd->sc_dk.dk_cpulabel, sizeof(struct cpu_disklabel));
@@ -962,17 +972,46 @@

    lp->d_partitions[0].p_offset = 0;
    lp->d_partitions[0].p_size =
-       lp->d_secperunit * (lp->d_secsize / DEV_BSIZE);
+       lp->d_secperunit;
    lp->d_partitions[0].p_fstype = FS_ISO9660;
    lp->d_partitions[RAW_PART].p_offset = 0;
    lp->d_partitions[RAW_PART].p_size =
-       lp->d_secperunit * (lp->d_secsize / DEV_BSIZE);
+       lp->d_secperunit;
    lp->d_partitions[RAW_PART].p_fstype = FS_ISO9660;
    lp->d_npartitions = RAW_PART + 1;

    lp->d_magic = DISKMAGIC;
    lp->d_magic2 = DISKMAGIC;
    lp->d_checksum = dkcksum(lp);
+
+   /*
+    * Call the generic disklabel extraction routine
+    */
+   errstring = readdisklabel(MAKECDDEV(0, cd->sc_dev.dv_unit, RAW_PART),
+                 cdstrategy, lp, cd->sc_dk.dk_cpulabel);
+
+#if 0
+   if (errstring) {
+       printf("%s: %s\n", cd->sc_dev.dv_xname, errstring);
+       return;
+   }
+#else
+   if (errstring && strcmp(errstring, "no disk label") == 0) {
+       lp->d_partitions[0].p_offset = 0;
+       lp->d_partitions[0].p_size =
+           lp->d_secperunit;
+       lp->d_partitions[0].p_fstype = FS_ISO9660;
+       lp->d_partitions[RAW_PART].p_offset = 0;
+       lp->d_partitions[RAW_PART].p_size =
+           lp->d_secperunit;
+       lp->d_partitions[RAW_PART].p_fstype = FS_ISO9660;
+       lp->d_npartitions = RAW_PART + 1;
+
+       lp->d_magic = DISKMAGIC;
+       lp->d_magic2 = DISKMAGIC;
+       lp->d_checksum = dkcksum(lp);
+   }
+#endif
 }

 /*
Index: sys/scsi/sd.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/scsi/sd.c,v
retrieving revision 1.1.1.4
retrieving revision 1.3
diff -u -r1.1.1.4 -r1.3
--- sd.c    1997/06/23 16:30:19 1.1.1.4
+++ sd.c    1997/06/24 03:11:50 1.3
@@ -577,13 +577,13 @@
         * First, translate the block to absolute and put it in terms
         * of the logical blocksize of the device.
         */
-       blkno =
-           bp->b_blkno / (sd->sc_dk.dk_label->d_secsize / DEV_BSIZE);
+       blkno = bp->b_blkno;
        if (SDPART(bp->b_dev) != RAW_PART) {
             p = &sd->sc_dk.dk_label->d_partitions[SDPART(bp->b_dev)];
             blkno += p->p_offset;
        }
-       nblks = howmany(bp->b_bcount, sd->sc_dk.dk_label->d_secsize);
+       blkno *= sd->sc_dk.dk_label->d_secsize / sd->params.blksize;
+       nblks = howmany(bp->b_bcount, sd->params.blksize);

        /*
         *  Fill out the scsi command.  If the transfer will
@@ -675,8 +675,10 @@
    struct uio *uio;
    int ioflag;
 {
+   struct sd_softc *sd = sd_cd.cd_devs[SDUNIT(dev)];
+   int bshift = ffs(sd->sc_dk.dk_label->d_secsize)-1;

-   return (physio(sdstrategy, NULL, dev, B_READ, sdminphys, uio));
+   return (physio2(sdstrategy, NULL, dev, B_READ, sdminphys, uio, bshift));
 }

 int
@@ -685,8 +687,10 @@
    struct uio *uio;
    int ioflag;
 {
+   struct sd_softc *sd = sd_cd.cd_devs[SDUNIT(dev)];
+   int bshift = ffs(sd->sc_dk.dk_label->d_secsize)-1;

-   return (physio(sdstrategy, NULL, dev, B_WRITE, sdminphys, uio));
+   return (physio2(sdstrategy, NULL, dev, B_WRITE, sdminphys, uio, bshift));
 }

 /*
@@ -810,7 +814,7 @@

    lp->d_partitions[RAW_PART].p_offset = 0;
    lp->d_partitions[RAW_PART].p_size =
-       lp->d_secperunit * (lp->d_secsize / DEV_BSIZE);
+       lp->d_secperunit;
    lp->d_partitions[RAW_PART].p_fstype = FS_UNUSED;
    lp->d_npartitions = RAW_PART + 1;

Index: sys/sys/buf.h
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/sys/buf.h,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -u -r1.1.1.2 -r1.2
--- buf.h   1997/04/14 06:25:49 1.1.1.2
+++ buf.h   1997/05/29 17:50:51 1.2
@@ -187,6 +187,8 @@
 void   minphys __P((struct buf *bp));
 int    physio __P((void (*strategy)(struct buf *), struct buf *bp, dev_t dev,
            int flags, void (*minphys)(struct buf *), struct uio *uio));
+int    physio2 __P((void (*strategy)(struct buf *), struct buf *bp, dev_t dev,
+           int flags, void (*minphys)(struct buf *), struct uio *uio, int bshift));
 void  brelvp __P((struct buf *));
 void  reassignbuf __P((struct buf *, struct vnode *));
 void  bgetvp __P((struct vnode *, struct buf *));
Index: sys/ufs/ffs/ffs_vfsops.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/ufs/ffs/ffs_vfsops.c,v
retrieving revision 1.1.1.3
diff -u -r1.1.1.3 ffs_vfsops.c
--- ffs_vfsops.c    1997/06/23 16:31:06 1.1.1.3
+++ ffs_vfsops.c    1997/06/25 07:33:13
@@ -307,7 +307,9 @@
    struct csum *space;
    struct buf *bp;
    struct fs *fs, *newfs;
+#if 1
    struct partinfo dpart;
+#endif
    int i, blks, size, error;
    int32_t *lp;

@@ -322,10 +324,15 @@
    /*
     * Step 2: re-read superblock from disk.
     */
+#if 1
    if (VOP_IOCTL(devvp, DIOCGPART, (caddr_t)&dpart, FREAD, NOCRED, p) != 0)
        size = DEV_BSIZE;
    else
        size = dpart.disklab->d_secsize;
+#else
+   size = DEV_BSIZE;
+#endif
+
    error = bread(devvp, (daddr_t)(SBOFF / size), SBSIZE, NOCRED, &bp);
    if (error)
        return (error);
@@ -424,10 +431,12 @@
    struct buf *bp;
    register struct fs *fs;
    dev_t dev;
+#if 1
    struct partinfo dpart;
+#endif
    caddr_t base, space;
    int blks;
-   int error, i, size, ronly;
+   int error, i, size, ssize, ronly;
    int32_t *lp;
    struct ucred *cred;
    extern struct vnode *rootvp;
@@ -452,10 +461,14 @@
    error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, p);
    if (error)
        return (error);
+#if 1
    if (VOP_IOCTL(devvp, DIOCGPART, (caddr_t)&dpart, FREAD, cred, p) != 0)
        size = DEV_BSIZE;
    else
        size = dpart.disklab->d_secsize;
+#else
+   size = DEV_BSIZE;
+#endif

    bp = NULL;
    ump = NULL;

specific IP address UDP ports don't get broadcasts

Metadata

  • Number: 4360
  • Originator: John Kohl <[email protected]>
  • Arrived: Sun Oct 26 20:50:01 +0000 1997
  • Last modified: Mon Jun 05 20:39:44 +0000 2000
  • Environment: System: NetBSD kolvir.arlington.ma.us 1.3_ALPHA NetBSD 1.3_ALPHA (KOLVIR) #9: Sat Oct 25 22:52:08 EDT 1997 [email protected]:/u4/sandbox/src/sys/arch/i386/compile/KOLVIR i386

Description


It appears that UDP servers listening on a specific interface
address/socket pair do not receive broadcasts on those interfaces,
and/or inetd(8) doesn't fork off such servers when broadcast packets arrive.


How to repeat


Bind "ip-address" as an alias on an ethernet interface.

Put a line like this in your inetd.conf:
ip-address:netbios-ns   dgram   udp wait    root    /usr/local/samba/bin/nmbd nmbd

Cause another host on the network to send a UDP broadcast to this port.

Watch that inetd never forks off nmbd.


tty's don't support per-port settable defaults.

Metadata

  • Number: 2887
  • Originator: Bill Studenmund <[email protected]>
  • Arrived: Tue Oct 22 22:05:02 +0000 1996
  • Last modified: Sat Mar 08 09:57:42 +0000 2008
  • Environment: all netbsd System: NetBSD pokey 1.1B NetBSD 1.1B (MACFS) #31: Sun Oct 13 19:00:52 PDT 1996 croot@pokey:/y1/src11/sys/arch/mac68k/compile/MACFS mac68k

Description


    All the tty drivers I could see folow the same procedure on
first open. They set the tty's termios structure up from compile-time
defaults. This procedure prohibits per-port, run-time customization of tty
settings.


Fix



Below I enclose an implimentation of per-port defaults. I mentioned this idea
on tech-kern, and got no arguments (actually no comment). As suggested 
on tech-kern, I add a defaults struct termios to struct tty. I add two
new IOCTL's to manipulate these defaults. These defaults are initialized
in ttymalloc (since it takes all steps to set up a tty, it seemed like a good
addition). As such, the only necessary change to a driver to take advantage
of the defaults is for the code in the open routine which will set up the
defaults during a first-open. Currently drivers fill each field in the
t_termios on first-open (or first first-open for some). This proposal replaces
all that code with a bcopy from the defaults to the working struct termios,
so most drivers will become slightly simpler. As the driver must be (slightly)
changed to use defaults, drivers can opt not to use defaults. I do not forsee
pty's supporting defaults. :-)

The two IOCTL's will either return the current defaults struct termios, or
copy the current termios to the defualt termios. I opted against permitting
arbitrary defaults setting as the defaults need to be verified by the
param routine for the driver. This routine both verifies and sets in hardware
the values in its termios. To change the rotine to optionally just verify would
be a major code change. The only point where the distinction is important is
if the port is in use while defaults are being set; the port will be left in
the default state. As defaults would typically only be changed at boot or
while the port is down, no difficulty is forseen.

I also enclose two new libc routines to use these IOCTL's, and changes
to bin/stty to impliment a "-D" option to set and review the defaults.
Due to my unfamiliarity with man page formatting, I only updated the
stty manpage to document the changes. I do not feel comfortable writing
the formatted man page for the libc changes, though could write an
unformatted starter if asked.

The one open question with these changes is who should be able to change the
defaults. At present, no permission checks are made (other than the ability
to open the tty). I an uncertain what requirements are best, and perhaps an
option similar to UCONSOLE will be needed.

I enclose a new tcgetdef.c, tcsetdef.c, and diffs to all other files changed in
the kernel. As an example, I also enclose patches to the mac68k z8530 tty driver,
the M.I. z8530 tty driver, and dev/isa/com.c. The mac68k patch is larger than
the other two as the mac68k had internally implimented defaults (w/o modifiability).

**** Begin src/lib/libc/termios/tcgetdef.c ****
/*  $NetBSD: tcgetattr.c,v 1.2 1995/06/26 23:05:55 jtc Exp $    */

/*-
 * Copyright (c) 1989, 1993
 *  The Regents of the University of California.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *  This product includes software developed by the University of
 *  California, Berkeley and its contributors.
 * 4. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)termios.c   8.2 (Berkeley) 2/21/94";
#else
static char rcsid[] = "$NetBSD: tcgetattr.c,v 1.2 1995/06/26 23:05:55 jtc Exp $";
#endif
#endif /* LIBC_SCCS and not lint */

#include <sys/ioctl.h>
#include <termios.h>

int
tcgetdef(fd, t)
    int fd;
    struct termios *t;
{
    return (ioctl(fd, TIOCGDEFS, t));
}
**** end src/lib/libc/termios/tcgetdef.c ****

**** begin src/lib/libc/termios/tcsetdef.c ****
/*  $NetBSD: tcsetdef.c,v 0.1 1996/09/14 23:06:06 wrs Exp $ */

/*-
 * Copyright (c) 1989, 1993
 *  The Regents of the University of California.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *  This product includes software developed by the University of
 *  California, Berkeley and its contributors.
 * 4. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)termios.c   8.2 (Berkeley) 2/21/94";
#else
static char rcsid[] = "$NetBSD: tcsetdef.c,v 0.1 1996/09/14 23:06:06 wrs Exp $";
#endif
#endif /* LIBC_SCCS and not lint */

#include <sys/ioctl.h>
#include <termios.h>
#include <errno.h>

int
tcsetdef(fd)
    int fd;
{
    return (ioctl(fd, TIOCSDEFS, 0));
}
**** end src/lib/libc/termios/tcsetdef.c ****

Now for the diff's:
*** /sys/sys/termios.h.orig Tue Sep 17 22:50:02 1996
--- /sys/sys/termios.h  Tue Sep 17 22:51:56 1996
***************
*** 249,254 ****
--- 249,256 ----
  int   cfsetospeed __P((struct termios *, speed_t));
  int   tcgetattr __P((int, struct termios *));
  int   tcsetattr __P((int, int, const struct termios *));
+ int   tcgetdef  __P((int, struct termios *));
+ int   tcsetdef  __P((int));
  int   tcdrain __P((int));
  int   tcflow __P((int, int));
  int   tcflush __P((int, int));
*** /sys/kern/tty.c.orig    Sun Aug 25 21:26:06 1996
--- /sys/kern/tty.c Thu Sep 19 22:50:49 1996
***************
*** 891,896 ****
--- 891,910 ----
            pgsignal(tp->t_pgrp, SIGWINCH, 1);
        }
        break;
+   case TIOCGDEFS: {           /* get tty default termios */
+       struct termios *t = (struct termios *)data;
+ 
+                 bcopy(&tp->t_defaults, t, sizeof(struct termios));
+       printf("Did TIOCGDEFS.\n");
+       break;
+   }
+   case TIOCSDEFS:         /* set tty default termios */
+       /* set defaults to current state since driver already
+        * verified these settings. */
+       /* XXX do we need to check permissions? */
+       bcopy(&tp->t_termios, &tp->t_defaults, sizeof(struct termios));
+       printf("Did TIOCSDEFS.\n");
+       break;
    default:
  #ifdef COMPAT_OLDTTY
        return (ttcompat(tp, cmd, data, flag, p));
***************
*** 2026,2031 ****
--- 2040,2046 ----

  /*
   * Allocate a tty structure and its associated buffers.
+  * Also set up default termios structure.
   */
  struct tty *
  ttymalloc()
***************
*** 2039,2044 ****
--- 2054,2067 ----
    clalloc(&tp->t_canq, 1024, 1);
    /* output queue doesn't need quoting */
    clalloc(&tp->t_outq, 1024, 0);
+   /* now set up default termios */
+   tp->t_defaults.c_cflag = TTYDEF_CFLAG;
+   tp->t_defaults.c_iflag = TTYDEF_IFLAG;
+   tp->t_defaults.c_lflag = TTYDEF_LFLAG;
+   tp->t_defaults.c_oflag = TTYDEF_OFLAG;
+   tp->t_defaults.c_ispeed = tp->t_defaults.c_ospeed = TTYDEF_SPEED;
+   ttychars(tp);
+   bcopy(&tp->t_cc, &tp->t_defaults.c_cc, sizeof(tp->t_cc));
    return(tp);
  }

--- /sys/sys/tty.h.orig Sun Aug 25 21:16:53 1996
+++ /sys/sys/tty.h  Sun Sep 15 22:26:17 1996
@@ -109,6 +109,7 @@
    short   t_hiwat;        /* High water mark. */
    short   t_lowat;        /* Low water mark. */
    short   t_gen;          /* Generation number. */
+   struct  termios t_defaults; /* Tty default termios state. */
 };

 #define    t_cc        t_termios.c_cc
@@ -116,10 +117,16 @@
 #define    t_iflag     t_termios.c_iflag
 #define    t_ispeed    t_termios.c_ispeed
 #define    t_lflag     t_termios.c_lflag
-#define    t_min       t_termios.c_min
 #define    t_oflag     t_termios.c_oflag
 #define    t_ospeed    t_termios.c_ospeed
-#define    t_time      t_termios.c_time
+
+#define    t_d_cc      t_defaults.c_cc
+#define    t_d_cflag   t_defaults.c_cflag
+#define    t_d_iflag   t_defaults.c_iflag
+#define    t_d_ispeed  t_defaults.c_ispeed
+#define    t_d_lflag   t_defaults.c_lflag
+#define    t_d_oflag   t_defaults.c_oflag
+#define    t_d_ospeed  t_defaults.c_ospeed

 #define    TTIPRI  25          /* Sleep priority for tty reads. */
 #define    TTOPRI  26          /* Sleep priority for tty writes. */
--- /sys/sys/ttycom.h.orig  Sun Aug 25 21:13:17 1996
+++ /sys/sys/ttycom.h   Sun Aug 25 21:44:16 1996
@@ -129,6 +129,8 @@
 #define        TIOCFLAG_CLOCAL     0x02    /* set clocal on open */
 #define        TIOCFLAG_CRTSCTS    0x04    /* set crtscts on open */
 #define        TIOCFLAG_MDMBUF     0x08    /* set mdmbuf on open */
+#define    TIOCGDEFS   _IOR('t', 91, struct termios)   /* get tty defaults */
+#define TIOCSDEFS   _IO('t', 90)       /* set tty defaults to current */

 #define    TTYDISC     0       /* termios tty line discipline */
 #define    TABLDISC    3       /* tablet discipline */
*** /sys/arch/mac68k/dev/z8530tty.c.960810  Sat Aug 10 10:08:13 1996
--- /sys/arch/mac68k/dev/z8530tty.c Sun Oct  6 15:16:30 1996
***************
*** 160,172 ****
    zst->zst_swflags = cf->cf_flags;    /* softcar, etc. */
    zst->zst_hwflags = args->hwflags;

-   zst->zst_cflag = ZSTTY_DEF_CFLAG;   /* set up defaults */
-   zst->zst_iflag = TTYDEF_IFLAG;      /* an ioctl can change */
-   zst->zst_lflag = TTYDEF_LFLAG;      /* these values, modifying */
-   zst->zst_oflag = TTYDEF_OFLAG;      /* initial defaults */
-   zst->zst_ispeed = zst->zst_ospeed = cs->cs_defspeed;
-   /* zst_cc set after tty is malloc'd */
- 
    dev = makedev(ZSTTY_MAJOR, tty_unit);

    if (zst->zst_swflags)
--- 160,165 ----
***************
*** 197,204 ****
    tp->t_oproc = zsstart;
    tp->t_param = zsparam;
    tp->t_hwiflow = zshwiflow;
-   ttychars(tp);
-   bcopy(tp->t_cc, zst->zst_cc, sizeof(tp->t_cc));

    zst->zst_tty = tp;
    zst->zst_rbhiwat =  zstty_rbuf_size;    /* impossible value */
--- 190,195 ----
***************
*** 227,239 ****
    if (zst->zst_hwflags & ZS_HWFLAG_CONSOLE) {
        /* This unit is the console. */
        zst->zst_swflags |= TIOCFLAG_SOFTCAR;
-       /* Call _param so interrupts get enabled. */
-       bcopy(&zst->zst_termios, &tp->t_termios, sizeof(struct termios));
-       /* copy the whole termios in as the first "first open" won't
-        * do it since the speed != 0 */
        cs->cs_defspeed = zs_getspeed(cs);
!       tp->t_ispeed = cs->cs_defspeed;
!       tp->t_ospeed = cs->cs_defspeed;
        (void) zsparam(tp, &tp->t_termios);
    } else {
        /* Not the console; may need reset. */
--- 218,228 ----
    if (zst->zst_hwflags & ZS_HWFLAG_CONSOLE) {
        /* This unit is the console. */
        zst->zst_swflags |= TIOCFLAG_SOFTCAR;
        cs->cs_defspeed = zs_getspeed(cs);
!       tp->t_d_ispeed = cs->cs_defspeed;
!       tp->t_d_ospeed = cs->cs_defspeed;
!       bcopy(&tp->t_defaults, &tp->t_termios, sizeof(struct termios));
!       /* Call _param so interrupts get enabled. */
        (void) zsparam(tp, &tp->t_termios);
    } else {
        /* Not the console; may need reset. */
***************
*** 317,335 ****
    s = spltty();

    if ((tp->t_state & TS_ISOPEN) == 0) {
!       if ((tp->t_ispeed == 0) || (zst->zst_resetdef)) {
!           /* First open. Executed if either the tty
!            * was uninitialized, or if we choose to
!            * reset defaults w/ each open. */
!           bcopy(&zst->zst_termios, &tp->t_termios,
!               sizeof(struct termios));
!           if (zst->zst_swflags & TIOCFLAG_CLOCAL)
!               tp->t_cflag |= CLOCAL;
!           if (zst->zst_swflags & TIOCFLAG_CRTSCTS)
!               tp->t_cflag |= CRTSCTS;
!           if (zst->zst_swflags & TIOCFLAG_MDMBUF)
!               tp->t_cflag |= MDMBUF;
!       }
        (void) zsparam(tp, &tp->t_termios);
        ttsetwater(tp);
        /* Flush any pending input. */
--- 306,319 ----
    s = spltty();

    if ((tp->t_state & TS_ISOPEN) == 0) {
!       bcopy(&tp->t_defaults, &tp->t_termios,
!           sizeof(struct termios));
!       if (zst->zst_swflags & TIOCFLAG_CLOCAL)
!           tp->t_cflag |= CLOCAL;
!       if (zst->zst_swflags & TIOCFLAG_CRTSCTS)
!           tp->t_cflag |= CRTSCTS;
!       if (zst->zst_swflags & TIOCFLAG_MDMBUF)
!           tp->t_cflag |= MDMBUF;
        (void) zsparam(tp, &tp->t_termios);
        ttsetwater(tp);
        /* Flush any pending input. */
*** /sys/arch/mac68k/dev/zs.c.orig  Sat Aug 10 09:49:55 1996
--- /sys/arch/mac68k/dev/zs.c   Thu Sep 19 22:59:49 1996
***************
*** 368,383 ****
        zst->zst_hwflags |= ZS_HWFLAG_IGCTS;

    if (theflags & ZSMAC_RAW) {
!       zst->zst_cflag = ZSTTY_RAW_CFLAG;
!       zst->zst_iflag = ZSTTY_RAW_IFLAG;
!       zst->zst_lflag = ZSTTY_RAW_LFLAG;
!       zst->zst_oflag = ZSTTY_RAW_OFLAG;
        printf(" (raw defaults)");
    }
    if (theflags & ZSMAC_LOCALTALK) {
        printf(" shielding from LocalTalk");
!       zst->zst_ospeed = tp->t_ospeed = 1;
!       zst->zst_ispeed = tp->t_ispeed = 1;
        cs->cs_defspeed = 1;
        cs->cs_creg[ZSRR_BAUDLO] = cs->cs_preg[ZSRR_BAUDLO] = 0xff;
        cs->cs_creg[ZSRR_BAUDHI] = cs->cs_preg[ZSRR_BAUDHI] = 0xff;
--- 371,386 ----
        zst->zst_hwflags |= ZS_HWFLAG_IGCTS;

    if (theflags & ZSMAC_RAW) {
!       tp->t_d_cflag = ZSTTY_RAW_CFLAG;
!       tp->t_d_iflag = ZSTTY_RAW_IFLAG;
!       tp->t_d_lflag = ZSTTY_RAW_LFLAG;
!       tp->t_d_oflag = ZSTTY_RAW_OFLAG;
        printf(" (raw defaults)");
    }
    if (theflags & ZSMAC_LOCALTALK) {
        printf(" shielding from LocalTalk");
!       tp->t_d_ospeed = tp->t_ospeed = 1;
!       tp->t_d_ispeed = tp->t_ispeed = 1;
        cs->cs_defspeed = 1;
        cs->cs_creg[ZSRR_BAUDLO] = cs->cs_preg[ZSRR_BAUDLO] = 0xff;
        cs->cs_creg[ZSRR_BAUDHI] = cs->cs_preg[ZSRR_BAUDHI] = 0xff;
*** /src/lib/libc/termios/Makefile.inc.orig Sun Sep 15 21:30:20 1996
--- /src/lib/libc/termios/Makefile.inc  Sun Sep 15 21:30:55 1996
***************
*** 4,10 ****

  SRCS+=    cfgetispeed.c cfgetospeed.c cfmakeraw.c cfsetispeed.c cfsetospeed.c \
    cfsetspeed.c tcdrain.c tcflow.c tcflush.c tcgetattr.c tcgetpgrp.c \
!   tcsendbreak.c tcsetattr.c tcsetpgrp.c

  MAN+= tcgetpgrp.3 tcsendbreak.3 tcsetattr.3 tcsetpgrp.3

--- 4,10 ----

  SRCS+=    cfgetispeed.c cfgetospeed.c cfmakeraw.c cfsetispeed.c cfsetospeed.c \
    cfsetspeed.c tcdrain.c tcflow.c tcflush.c tcgetattr.c tcgetpgrp.c \
!   tcsendbreak.c tcsetattr.c tcsetpgrp.c tcsetdef.c tcgetdef.c

  MAN+= tcgetpgrp.3 tcsendbreak.3 tcsetattr.3 tcsetpgrp.3

*** /src/bin/stty/stty.1.orig   Wed Oct  9 22:35:01 1996
--- /src/bin/stty/stty.1    Wed Oct  9 22:37:40 1996
***************
*** 46,51 ****
--- 46,52 ----
  .Nm stty
  .Op Fl a | Fl e | Fl g
  .Op Fl f Ar file
+ .Op Fl D
  .Op operands
  .Sh DESCRIPTION
  The
***************
*** 88,93 ****
--- 89,98 ----
  .Nm stty
  to restore the current terminal state as per
  .St -p1003.2 .
+ .It Fl D
+ Display and/or modify the per-tty defaults for this tty rather than
+ the current status. Note: changing the defaults requires changing
+ the current settings to match the defaults.
  .El
  .Pp
  The following arguments are available to set the terminal
*** /src/bin/stty/stty.c.orig   Sat Sep 14 12:37:22 1996
--- /src/bin/stty/stty.c    Mon Sep 23 16:47:10 1996
***************
*** 68,82 ****
  {
    struct info i;
    enum FMT fmt;
!   int ch;

    fmt = NOTSET;
    i.fd = STDIN_FILENO;

    opterr = 0;
    while (optind < argc &&
!       strspn(argv[optind], "-aefg") == strlen(argv[optind]) &&
!       (ch = getopt(argc, argv, "aef:g")) != -1)
        switch(ch) {
        case 'a':       /* undocumented: POSIX compatibility */
            fmt = POSIX;
--- 68,82 ----
  {
    struct info i;
    enum FMT fmt;
!   int ch, do_defaults = 0;

    fmt = NOTSET;
    i.fd = STDIN_FILENO;

    opterr = 0;
    while (optind < argc &&
!       strspn(argv[optind], "-aefgD") == strlen(argv[optind]) &&
!       (ch = getopt(argc, argv, "aef:gD")) != -1)
        switch(ch) {
        case 'a':       /* undocumented: POSIX compatibility */
            fmt = POSIX;
***************
*** 91,96 ****
--- 91,99 ----
        case 'g':
            fmt = GFLAG;
            break;
+       case 'D':
+           do_defaults = 1;
+           break;
        case '?':
        default:
            goto args;
***************
*** 101,108 ****

    if (ioctl(i.fd, TIOCGETD, &i.ldisc) < 0)
        err(1, "TIOCGETD");
!   if (tcgetattr(i.fd, &i.t) < 0)
!       err(1, "tcgetattr");
    if (ioctl(i.fd, TIOCGWINSZ, &i.win) < 0)
        warn("TIOCGWINSZ");

--- 104,115 ----

    if (ioctl(i.fd, TIOCGETD, &i.ldisc) < 0)
        err(1, "TIOCGETD");
!   if (do_defaults) {
!       if (tcgetdef(i.fd, &i.t) < 0)
!           err(1, "tcgetdef");
!   } else
!       if (tcgetattr(i.fd, &i.t) < 0)
!           err(1, "tcgetattr");
    if (ioctl(i.fd, TIOCGWINSZ, &i.win) < 0)
        warn("TIOCGWINSZ");

***************
*** 152,157 ****
--- 159,166 ----

    if (i.set && tcsetattr(i.fd, 0, &i.t) < 0)
        err(1, "tcsetattr");
+   if (i.set && do_defaults && tcsetdef(i.fd) < 0)
+       err(1, "tcsetdef");
    if (i.wset && ioctl(i.fd, TIOCSWINSZ, &i.win) < 0)
        warn("TIOCSWINSZ");
    exit(0);
*** /sys/dev/ic/z8530tty.c.orig Sun Oct 20 18:26:21 1996
--- /sys/dev/ic/z8530tty.c  Sun Oct 20 18:28:30 1996
***************
*** 357,374 ****

    if ((tp->t_state & TS_ISOPEN) == 0) {
        /* First open. */
!       ttychars(tp);
!       tp->t_iflag = TTYDEF_IFLAG;
!       tp->t_oflag = TTYDEF_OFLAG;
!       tp->t_cflag = ZSTTY_DEF_CFLAG;
        if (zst->zst_swflags & TIOCFLAG_CLOCAL)
            tp->t_cflag |= CLOCAL;
        if (zst->zst_swflags & TIOCFLAG_CRTSCTS)
            tp->t_cflag |= CRTSCTS;
        if (zst->zst_swflags & TIOCFLAG_MDMBUF)
            tp->t_cflag |= MDMBUF;
-       tp->t_lflag = TTYDEF_LFLAG;
-       tp->t_ispeed = tp->t_ospeed = cs->cs_defspeed;
        (void) zsparam(tp, &tp->t_termios);
        ttsetwater(tp);
        /* Flush any pending input. */
--- 357,370 ----

    if ((tp->t_state & TS_ISOPEN) == 0) {
        /* First open. */
!       bcopy(&tp->t_defaults, &tp->t_termios,
!           sizeof(struct termios));
        if (zst->zst_swflags & TIOCFLAG_CLOCAL)
            tp->t_cflag |= CLOCAL;
        if (zst->zst_swflags & TIOCFLAG_CRTSCTS)
            tp->t_cflag |= CRTSCTS;
        if (zst->zst_swflags & TIOCFLAG_MDMBUF)
            tp->t_cflag |= MDMBUF;
        (void) zsparam(tp, &tp->t_termios);
        ttsetwater(tp);
        /* Flush any pending input. */
*** /sys/dev/isa/com.c.orig Sun Oct 20 18:30:26 1996
--- /sys/dev/isa/com.c  Sun Oct 20 18:31:42 1996
***************
*** 539,559 ****
    tp->t_dev = dev;
    if (!ISSET(tp->t_state, TS_ISOPEN)) {
        SET(tp->t_state, TS_WOPEN);
!       ttychars(tp);
!       tp->t_iflag = TTYDEF_IFLAG;
!       tp->t_oflag = TTYDEF_OFLAG;
        if (ISSET(sc->sc_hwflags, COM_HW_CONSOLE))
            tp->t_cflag = comconscflag;
-       else
-           tp->t_cflag = TTYDEF_CFLAG;
        if (ISSET(sc->sc_swflags, COM_SW_CLOCAL))
            SET(tp->t_cflag, CLOCAL);
        if (ISSET(sc->sc_swflags, COM_SW_CRTSCTS))
            SET(tp->t_cflag, CRTSCTS);
        if (ISSET(sc->sc_swflags, COM_SW_MDMBUF))
            SET(tp->t_cflag, MDMBUF);
-       tp->t_lflag = TTYDEF_LFLAG;
-       tp->t_ispeed = tp->t_ospeed = comdefaultrate;

        s = spltty();

--- 539,554 ----
    tp->t_dev = dev;
    if (!ISSET(tp->t_state, TS_ISOPEN)) {
        SET(tp->t_state, TS_WOPEN);
!       bcopy(&tp->t_defaults, &tp->t_termios,
!           sizeof(struct termios));
        if (ISSET(sc->sc_hwflags, COM_HW_CONSOLE))
            tp->t_cflag = comconscflag;
        if (ISSET(sc->sc_swflags, COM_SW_CLOCAL))
            SET(tp->t_cflag, CLOCAL);
        if (ISSET(sc->sc_swflags, COM_SW_CRTSCTS))
            SET(tp->t_cflag, CRTSCTS);
        if (ISSET(sc->sc_swflags, COM_SW_MDMBUF))
            SET(tp->t_cflag, MDMBUF);

        s = spltty();


Audit trail


State-Changed-From-To: open->feedback
State-Changed-By: [email protected]
State-Changed-When: Sat, 23 Sep 2006 22:48:51 +0000
State-Changed-Why:
I'd actually be in favor of integrating this change.  What do you think, at
this far (temporal) remove from when you proposed it?


From: Bill Studenmund <[email protected]>
To: [email protected]
Cc: [email protected], [email protected],
    [email protected], [email protected], [email protected]
Subject: Re: kern/2887 (tty's don't support per-port settable defaults.)
Date: Sat, 23 Sep 2006 20:59:03 -0700

 --k+w/mQv8wyuph6w0
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable

 On Sat, Sep 23, 2006 at 10:48:53PM +0000, [email protected] wrote:
 > Synopsis: tty's don't support per-port settable defaults.
 >=20
 > State-Changed-From-To: open->feedback
 > State-Changed-By: [email protected]
 > State-Changed-When: Sat, 23 Sep 2006 22:48:51 +0000
 > State-Changed-Why:
 > I'd actually be in favor of integrating this change.  What do you think, =
 at
 > this far (temporal) remove from when you proposed it?

 Wow, this is a blast from the past. I'd forgotten about this.

 Yeah, let's do it.

 Take care,

 Bill

 --k+w/mQv8wyuph6w0
 Content-Type: application/pgp-signature
 Content-Disposition: inline

 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.3 (NetBSD)

 iD8DBQFFFgKHWz+3JHUci9cRAt9LAJ9QZHW5trufT1LzXXhMqF2Fw+TT1QCfZolG
 74Rt4ZbGVThC9zd+8NULSSU=
 =LOXQ
 -----END PGP SIGNATURE-----

 --k+w/mQv8wyuph6w0--

State-Changed-From-To: feedback->open
State-Changed-By: [email protected]
State-Changed-When: Sat, 08 Mar 2008 09:57:42 +0000
State-Changed-Why:
Feedback received. Now let's merge it.



sa's ``memory integral'' broken?

Metadata

  • Number: 2107
  • Originator: Michael Graff <[email protected]>
  • Arrived: Wed Feb 21 13:50:07 +0000 1996
  • Last modified: Thu Jul 18 09:32:59 +0000 2013
  • Environment: System: NetBSD packrat.flame.org 1.1A NetBSD 1.1A (PACKRAT) #0: Sat Feb 17 18:06:28 CST 1996 [email protected]:/usr/src/sys/arch/i386/compile/PACKRAT i386

Description


    sa -m produces the following output:

root       4475602     13509.78cpu     26804306tio           0k*sec
daemon         243        77.29cpu        16388tio           0k*sec
postgres      2846        32.30cpu        72942tio           0k*sec
explorer    319858  20433708.81cpu      8694079tio           0k*sec
basilisk       946         8.80cpu        18110tio           0k*sec
flipk          483         1.45cpu         7072tio           0k*sec
gendalia       132         5.89cpu         7821tio           0k*sec
spirit          22         0.09cpu          146tio           0k*sec
feather         79         0.11cpu          449tio           0k*sec
graphix        178         0.41cpu         1316tio           0k*sec
spberry      22467       275.73cpu       429479tio           0k*sec
nsheeley      2344        16.20cpu        56819tio           0k*sec
grpeters        26         0.01cpu          102tio           0k*sec
ccsanady      1691         5.01cpu        19718tio           0k*sec
32001           31         0.06cpu          271tio           0k*sec
ftp          20781       479.42cpu       519009tio           0k*sec
nobody         978        26.77cpu       277204tio           0k*sec

Some of these stats are at the very least questionable, but the 0k*sec
is quite clearly broken.


How to repeat


sa -m with accounting on.


Fix


None known yet -- I was going to look into this later next month, but
wanted to remind myself about this, as well as get it in the pr
database in case someone else wants to look at it.  It's not high on
my personal list  ;)


Audit trail


Responsible-Changed-From-To: bin-bug-people->explorer 
Responsible-Changed-By: lukem 
Responsible-Changed-When: Tue Jun 26 08:15:07 PDT 2001 
Responsible-Changed-Why:  
Mike is now a developer, so he can work out what to do 
with his PR. 

I'll point out the following comment in the BUGS section: 
NetBSD's VM system does not record the CPU storage integral. 

That probably explains the observed behaviour 
Responsible-Changed-From-To: explorer->bin-bug-people
Responsible-Changed-By: [email protected]
Responsible-Changed-When: Thu, 18 Jul 2013 09:32:59 +0000
Responsible-Changed-Why:
back to role account, explorer resigned



the kernel's handling of group permissions is suboptimal

Metadata

  • Number: 4217
  • Originator: Chris G. Demetriou <[email protected]>
  • Arrived: Fri Oct 03 16:05:05 +0000 1997
  • Last modified: Sun Aug 10 16:26:01 +0000 2003
  • Environment: System: NetBSD brick.demetriou.com 1.2G NetBSD 1.2G (BRICK) #116: Wed Jul 16 14:03:06 PDT 1997 [email protected]:/usr/src/sys/arch/i386/compile/BRICK i386

Description


    The kernel's handling of group permissions is suboptimal.  In
    particular, it has (at least) the following deficiencies (for
    non-superusers):

    (1) setgroups() can only be invoked by root, despite the fact
        that the manual page says that "only the super-user may set
        new groups."  It's impossible for a process to _remove_
        groups from its group access list.  This means that it's
        impossible for a "smart" process to completely relinquish
        certain privileges.

    (2) setgid() can't set group ID to one of the groups in the
        group access list, only to either the real group id or the
        saved group id.  This, too, means that it's impossible
        for a "smart" process to relinquish certain privileges.  Such
        a process might want to setgid() to a certain group ID, then
        relinquish other group membership, then invoke another program.

    (3) same as (2), but for setegid().

    (3) same as (2), but for setregid().


How to repeat


    Try code which performs any of the above operations.


Fix


    None provided.  Note that there are 'interesting' issues if
    the real or effective group IDs aren't in the process's
    group list; logically they probably should be.  (That doesn't
    necessarily have to be reported directly to user programs which
    do getgroups(), but having one array could make life a lot easier.
    Indeed, it might make life easier in the existing code!)

Audit trail



From: David Laight <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: re: kern/4217: the kernel's handling of group permissions is suboptimal
Date: Sun, 10 Aug 2003 09:37:14 +0100

 1) Posix takes the stance:
     The related function setgroups() is a privileged operation and
     therefore is not covered by this volume of IEEE Std 1003.1-2001.
    which is rather a copout and not helpful at all!

 2/3/4) Posix requires the current behaviour.
    Although I agree that being able to call setgid() with any of the
    supplemantary groups could be useful - although of limited use
    given that netbsd doesn't use the actual group for very much.

 Perhaps the documentation of setgroups should be changed?
 Or maybe we should let a non-priveleged user re-order the list?

    David

 -- 
 David Laight: [email protected]

From: Andrew Brown <[email protected]>
To: David Laight <[email protected]>
Cc: [email protected], [email protected]
Subject: Re: kern/4217: the kernel's handling of group permissions is suboptimal
Date: Sun, 10 Aug 2003 12:25:35 -0400

 >1) Posix takes the stance:
 >    The related function setgroups() is a privileged operation and
 >    therefore is not covered by this volume of IEEE Std 1003.1-2001.
 >   which is rather a copout and not helpful at all!

 if the man page says "only the superuser can add more groups" and
 posix says "hey, look...a yak", then it doesn't seem to me to be wrong
 to adjust the code slightly in order to allow people to lower their
 privileges.

 >2/3/4) Posix requires the current behaviour.
 >   Although I agree that being able to call setgid() with any of the
 >   supplemantary groups could be useful - although of limited use
 >   given that netbsd doesn't use the actual group for very much.

 uh...nfs?  besides, it would be rather useful if a process that had
 gained privileges via a setgid binary to be able to give away all its
 other group privileges...

 >Perhaps the documentation of setgroups should be changed?

 nah...

 >Or maybe we should let a non-priveleged user re-order the list?

 yeah...

 imho.

 -- 
 |-----< "CODE WARRIOR" >-----|
 [email protected]             * "ah!  i see you have the internet
 [email protected] (Andrew Brown)                that goes *ping*!"
 [email protected]       * "information is power -- share the wealth."

fuword() definition problem

Metadata

  • Number: 2512
  • Originator: Unprivileged user <[email protected]>
  • Arrived: Tue Jun 04 04:35:01 +0000 1996
  • Last modified: Mon Jun 05 22:30:01 +0000 2000
  • Environment: System: NetBSD jocelyn.rhein.de 1.1B NetBSD 1.1B (DRACO) #95: Fri May 31 13:21:53 MET DST 1996 [email protected]:/bulk/s2/src/sys/arch/amiga/compile/DRACO amiga

Description


    The kernel fuword() returns a "word of data" inside an int,
    but is also supposed to return -1 on error, which is .. rather
    difficult if sizeof(int) == sizeof(word of data).

    (We dont have this problem with fusword and fubytes, because (to
    my knowledge) none of our ports uses shorts or bytes as ints).
    Furthermore, the fetch family doesn't support 64bit machines well...


How to repeat


    Look for more effective ways to integrate Motorola's m68060 software
    support package than calling copyin()/copyout() for the transfer of
    bytes, int16s and int32s. Find fuxxx() and suxxx(). Read prototypes.
    Read implementation. Scratch head. Sigh.

small bug in libedit might cause abnormal program termination


    libedit covers several vi and emacs functions and stores
    descriptions about them in a structure called el_func_help
    which will be generated automatically. This structure is
    terminated by { NULL, 0, NULL } as customary to have an
    exit condition for use with loops. The problem is that
    the map_init function in lib/libedit/map.c do not respect
    this null-termination. It allocates memory for only N
    functions, but N+1 is necessary to include the termination.
    You'll get a segmentation fault in certain cases.


union FS can return bogus value for lookup of `.', causing later panic

Metadata

  • Number: 1677
  • Originator: John Kohl <[John Kohl [email protected]](mailto:John Kohl <[email protected])>
  • Arrived: Mon Oct 23 19:35:03 +0000 1995
  • Last modified: Mon Jun 05 19:43:55 +0000 2000
  • Environment: System: NetBSD pattern 1.1_ALPHA NetBSD 1.1_ALPHA (PATTERN) #195: Sun Oct 22 13:31:09 EDT 1995 jtk@pattern:/u1/NetBSD-current/src/sys/arch/i386/compile/PATTERN i386

Description


If the union FS is looking up `.' in a directory  which is searchable in
the top level but unsearchable in the bottom level, it returns a union vnode
that is not the same as the starting vnode.  This returned vnode is only
half-locked, in that another union vnode points to the same lower layer
vnode.

Because the lower layer could not be looked up, union_lookup() called
union_allocvp() with lowervp == NULLVP.  This resulted in
union_allocvp() failing to find the "real" cached vnode for `.' and it
creates a new one.  The new one has UN_LOCKED set, and the uppervp is
indeed locked, but the lock was taken on behalf of the "real" vnode for `.'

This causes trouble in things like sys_lstat() and it kin which have
code like:
    NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | LOCKPARENT, UIO_USERSPACE,
        SCARG(uap, path), p);
    if (error = namei(&nd))
        return (error);
    vp = nd.ni_vp;
    dvp = nd.ni_dvp;
        if (dvp == vp)
            vrele(dvp);
        else
            vput(dvp);
        error = vn_stat(vp, &sb, p);
        vput(vp);
        if (error)
            return (error);

The second vput() results in a panic from UFS (if DIAGNOSTIC) when it
attempts to unlock an unlocked UFS vnode.


How to repeat


1) in the lower layer:
    mkdir Foo
    chmod 700 Foo
    chown otheruser Foo
2) in the upper layer:
    mkdir Foo
3) mount the union FS
4) ls -la /union_mountpoint/Foo
5) watch the machine croak


Fix


Not sure what the "right thing" is.  Maybe short-circuit `.'?

What about other cases where some user might not have the appropriate
lookup permissions in the lower layer?  It seems like we must never let
union_allocvp() be called in such a way as to generate two union vnodes
for the same underlying object.

non-512 bytes/sector media support case 2

Metadata

  • Number: 3791
  • Originator: Koji Imada - je4owb/2 <[email protected]>
  • Arrived: Wed Jun 25 01:35:02 +0000 1997
  • Last modified: Mon Feb 28 14:55:46 +0000 2011
  • Environment: System: NetBSD bimota 1.2E NetBSD 1.2E (BIMOTA) #: Wed Jun 11 02:13:27 JST 1997 koji@ducati:/mnt2/NetBSD/work/src-ufs-mod/sys/arch/i386/compile/BIMOTA i386

Description


    Modification required to support non-512 bytes/sector media
    for file system and device drivers.

    This is case 2 of 3 implementation. This keeps block io unit
    as DEV_BSIZE and adapts file systems(cd9660, ffs, msdosfs) and
    device driver(cd, sd) to support non-512 bytes/sector media.

    I will send mail to tech-kern about these 3 implementation.

    Also, these obsoletes kern/3460 and kern/3458

How to repeat


    Current NetBSD can't handle non-512 bytes/sector media properly.

Fix


    Apply following patches
Index: sys/arch/i386/i386/disksubr.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/arch/i386/i386/disksubr.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 disksubr.c
--- disksubr.c  1997/04/01 07:21:40 1.1.1.2
+++ disksubr.c  1997/06/25 06:38:03
@@ -91,7 +91,7 @@
    lp->d_partitions[i].p_offset = 0;

    /* get a buffer and initialize it */
-   bp = geteblk((int)lp->d_secsize);
+   bp = geteblk((int)BLKDEV_IOSIZE);
    bp->b_dev = dev;

    /* do dos partitions in the process of getting disklabel? */
@@ -100,6 +100,12 @@
    if (osdep && (dp = osdep->dosparts) != NULL) {
        /* read master boot record */
        bp->b_blkno = DOSBBSECTOR;
+#if 1
+       if (lp->d_secsize > DEV_BSIZE)
+           bp->b_blkno *= lp->d_secsize / DEV_BSIZE;
+       else
+           bp->b_blkno /= DEV_BSIZE / lp->d_secsize;
+#endif
        bp->b_bcount = lp->d_secsize;
        bp->b_flags = B_BUSY | B_READ;
        bp->b_cylin = DOSBBSECTOR / lp->d_secpercyl;
@@ -148,8 +154,14 @@

    /* next, dig out disk label */
    bp->b_blkno = dospartoff + LABELSECTOR;
+#if 1
+   if (lp->d_secsize > DEV_BSIZE)
+       bp->b_blkno *= lp->d_secsize / DEV_BSIZE;
+   else
+       bp->b_blkno /= DEV_BSIZE / lp->d_secsize;
+#endif
    bp->b_cylin = cyl;
-   bp->b_bcount = lp->d_secsize;
+   bp->b_bcount = BLKDEV_IOSIZE;
    bp->b_flags = B_BUSY | B_READ;
    (*strat)(bp);

@@ -159,7 +171,7 @@
        goto done;
    }
    for (dlp = (struct disklabel *)bp->b_data;
-       dlp <= (struct disklabel *)(bp->b_data + lp->d_secsize - sizeof(*dlp));
+       dlp <= (struct disklabel *)(bp->b_data + BLKDEV_IOSIZE - sizeof(*dlp));
        dlp = (struct disklabel *)((char *)dlp + sizeof(long))) {
        if (dlp->d_magic != DISKMAGIC || dlp->d_magic2 != DISKMAGIC) {
            if (msg == NULL)
@@ -186,10 +198,12 @@
            /* read a bad sector table */
            bp->b_flags = B_BUSY | B_READ;
            bp->b_blkno = lp->d_secperunit - lp->d_nsectors + i;
+#if 1
            if (lp->d_secsize > DEV_BSIZE)
                bp->b_blkno *= lp->d_secsize / DEV_BSIZE;
            else
                bp->b_blkno /= DEV_BSIZE / lp->d_secsize;
+#endif
            bp->b_bcount = lp->d_secsize;
            bp->b_cylin = lp->d_ncylinders - 1;
            (*strat)(bp);
@@ -291,7 +305,7 @@
    int error, dospartoff, cyl, i;

    /* get a buffer and initialize it */
-   bp = geteblk((int)lp->d_secsize);
+   bp = geteblk(BLKDEV_IOSIZE);
    bp->b_dev = dev;

    /* do dos partitions in the process of getting disklabel? */
@@ -300,6 +314,12 @@
    if (osdep && (dp = osdep->dosparts) != NULL) {
        /* read master boot record */
        bp->b_blkno = DOSBBSECTOR;
+#if 1
+       if (lp->d_secsize > DEV_BSIZE)
+           bp->b_blkno *= lp->d_secsize / DEV_BSIZE;
+       else
+           bp->b_blkno /= DEV_BSIZE / lp->d_secsize;
+#endif
        bp->b_bcount = lp->d_secsize;
        bp->b_flags = B_BUSY | B_READ;
        bp->b_cylin = DOSBBSECTOR / lp->d_secpercyl;
@@ -333,8 +353,14 @@

    /* next, dig out disk label */
    bp->b_blkno = dospartoff + LABELSECTOR;
+#if 1
+   if (lp->d_secsize > DEV_BSIZE)
+       bp->b_blkno *= lp->d_secsize / DEV_BSIZE;
+   else
+       bp->b_blkno /= DEV_BSIZE / lp->d_secsize;
+#endif
    bp->b_cylin = cyl;
-   bp->b_bcount = lp->d_secsize;
+   bp->b_bcount = BLKDEV_IOSIZE;
    bp->b_flags = B_BUSY | B_READ;
    (*strat)(bp);

@@ -342,7 +368,7 @@
    if ((error = biowait(bp)) != 0)
        goto done;
    for (dlp = (struct disklabel *)bp->b_data;
-       dlp <= (struct disklabel *)(bp->b_data + lp->d_secsize - sizeof(*dlp));
+       dlp <= (struct disklabel *)(bp->b_data + BLKDEV_IOSIZE - sizeof(*dlp));
        dlp = (struct disklabel *)((char *)dlp + sizeof(long))) {
        if (dlp->d_magic == DISKMAGIC && dlp->d_magic2 == DISKMAGIC &&
            dkcksum(dlp) == 0) {
@@ -374,12 +400,21 @@
 {
    struct partition *p = lp->d_partitions + DISKPART(bp->b_dev);
    int labelsector = lp->d_partitions[2].p_offset + LABELSECTOR;
-   int sz;
+   int sz, blkno;
+
+#if 0
+   blkno = bp->b_blkno;
+#else
+   if (lp->d_secsize > DEV_BSIZE)
+       blkno = bp->b_blkno / (lp->d_secsize / DEV_BSIZE);
+   else
+       blkno = bp->b_blkno * (DEV_BSIZE / lp->d_secsize);
+#endif

    sz = howmany(bp->b_bcount, lp->d_secsize);

-   if (bp->b_blkno + sz > p->p_size) {
-       sz = p->p_size - bp->b_blkno;
+   if (blkno + sz > p->p_size) {
+       sz = p->p_size - blkno;
        if (sz == 0) {
            /* If exactly at end of disk, return EOF. */
            bp->b_resid = bp->b_bcount;
@@ -391,13 +426,13 @@
            goto bad;
        }
        /* Otherwise, truncate request. */
-       bp->b_bcount = sz << DEV_BSHIFT;
+       bp->b_bcount = sz * lp->d_secsize;
    }

    /* Overwriting disk label? */
-   if (bp->b_blkno + p->p_offset <= labelsector &&
+   if (blkno + p->p_offset <= labelsector &&
 #if LABELSECTOR != 0
-       bp->b_blkno + p->p_offset + sz > labelsector &&
+       blkno + p->p_offset + sz > labelsector &&
 #endif
        (bp->b_flags & B_READ) == 0 && !wlabel) {
        bp->b_error = EROFS;
@@ -405,8 +440,7 @@
    }

    /* calculate cylinder for disksort to order transfers with */
-   bp->b_cylin = (bp->b_blkno + p->p_offset) /
-       (lp->d_secsize / DEV_BSIZE) / lp->d_secpercyl;
+   bp->b_cylin = (blkno + p->p_offset) / lp->d_secpercyl;
    return (1);

 bad:
Index: sys/dev/vnd.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/dev/vnd.c,v
retrieving revision 1.1.1.5
diff -u -r1.1.1.5 vnd.c
--- vnd.c   1997/06/23 16:24:04 1.1.1.5
+++ vnd.c   1997/06/25 06:43:42
@@ -94,6 +94,10 @@
 #define b_cylin    b_resid

 #define    vndunit(x)  DISKUNIT(x)
+#define VNDPART(dev)   DISKPART(dev)
+#define MAKEVNDDEV(maj, unit, part)    MAKEDISKDEV(maj, unit, part)
+
+#define VNDLABELDEV(dev) (MAKEVNDDEV(major(dev), vndunit(dev), RAW_PART))

 struct vndxfer {
    struct buf  *vx_bp;     /* Pointer to parent buffer */
@@ -118,6 +122,9 @@
 struct vnd_softc {
    int      sc_flags;  /* flags */
    size_t       sc_size;   /* size of vnd */
+   int      sc_bsize;  /* block size for special file */
+   int      sc_blksize;    /* number of bytes/dector */
+   int      sc_bshift; /* shift constant */
    struct vnode    *sc_vp;     /* vnode */
    struct ucred    *sc_cred;   /* credentials */
    int      sc_maxactive;  /* max # of active requests */
@@ -129,6 +136,8 @@
 /* sc_flags */
 #define    VNF_ALIVE   0x01
 #define VNF_INITED 0x02
+#define VNF_WLABEL 0x04
+#define VNF_LABELLING  0x08
 #define VNF_WANTED 0x40
 #define VNF_LOCKED 0x80

@@ -140,10 +149,11 @@

 void   vndclear __P((struct vnd_softc *));
 void   vndstart __P((struct vnd_softc *));
-int    vndsetcred __P((struct vnd_softc *, struct ucred *));
+int    vndsetcred __P((struct vnd_softc *, struct ucred *, struct proc *p));
 void   vndthrottle __P((struct vnd_softc *, struct vnode *));
 void   vndiodone __P((struct buf *));
 void   vndshutdown __P((void));
+void   vndgetdisklabel __P((dev_t dev, struct vnd_softc *vnd));

 static int vndlock __P((struct vnd_softc *));
 static void vndunlock __P((struct vnd_softc *));
@@ -196,6 +206,15 @@
    part = DISKPART(dev);
    pmask = (1 << part);

+   /* Check that the partition exists. */
+   if (part != RAW_PART &&
+       ((sc->sc_flags & VNF_INITED) == 0 ||
+        part >= sc->sc_dkdev.dk_label->d_npartitions ||
+        sc->sc_dkdev.dk_label->d_partitions[part].p_fstype == FS_UNUSED)) {
+       error = ENXIO;
+       goto bad;
+   }
+
    /* Prevent our unit from being unconfigured while open. */
    switch (mode) {
    case S_IFCHR:
@@ -211,6 +230,10 @@

    vndunlock(sc);
    return (0);
+
+bad:
+   vndunlock(sc);
+   return error;
 }

 int
@@ -272,6 +295,7 @@
    int sz, flags, error;

 #ifdef DEBUG
+   printf("vndstrategy(%p): bsize %ld\n", bp, vnd->sc_vp->v_mount->mnt_stat.f_iosize);
    if (vnddebug & VDB_FOLLOW)
        printf("vndstrategy(%p): unit %d\n", bp, unit);
 #endif
@@ -281,9 +305,28 @@
        biodone(bp);
        return;
    }
+
+   if (VNDPART(bp->b_dev) != RAW_PART &&
+       bounds_check_with_label(bp, vnd->sc_dkdev.dk_label,
+       (vnd->sc_flags & (VNF_WLABEL|VNF_LABELLING)) != 0) <= 0) {
+       bp->b_resid = bp->b_bcount;
+       biodone(bp);
+       return;
+   }
+
+#if 0
    bn = bp->b_blkno;
-   sz = howmany(bp->b_bcount, DEV_BSIZE);
+#else
+   bn = bp->b_blkno / (vnd->sc_dkdev.dk_label->d_secsize / DEV_BSIZE);
+#endif
    bp->b_resid = bp->b_bcount;
+   sz = howmany(bp->b_bcount, vnd->sc_blksize);
+
+   if (VNDPART(bp->b_dev) != RAW_PART) {
+       bn += vnd->sc_dkdev.dk_label->d_partitions[VNDPART(bp->b_dev)].p_offset;
+   }
+   bn *= vnd->sc_dkdev.dk_label->d_secsize / vnd->sc_blksize;
+
    if (bn < 0 || bn + sz > vnd->sc_size) {
        if (bn != vnd->sc_size) {
            bp->b_error = EINVAL;
@@ -292,8 +335,13 @@
        biodone(bp);
        return;
    }
-   bn = dbtob(bn);
+
+   bn = bn << vnd->sc_bshift;
+#if 1
+   bsize = vnd->sc_bsize;
+#else
    bsize = vnd->sc_vp->v_mount->mnt_stat.f_iosize;
+#endif
    addr = bp->b_data;
    flags = bp->b_flags | B_CALL;

@@ -512,6 +560,9 @@
 {
    int unit = vndunit(dev);
    struct vnd_softc *sc;
+#if 0
+   int bshift;
+#endif

 #ifdef DEBUG
    if (vnddebug & VDB_FOLLOW)
@@ -525,7 +576,13 @@
    if ((sc->sc_flags & VNF_INITED) == 0)
        return (ENXIO);

+#if 1
    return (physio(vndstrategy, NULL, dev, B_READ, minphys, uio));
+#else
+   bshift = ffs(sc->sc_dkdev.dk_label->d_secsize)-1;
+
+   return (physio2(vndstrategy, NULL, dev, B_READ, minphys, uio, bshift));
+#endif
 }

 /* ARGSUSED */
@@ -537,6 +594,9 @@
 {
    int unit = vndunit(dev);
    struct vnd_softc *sc;
+#if 0
+   int bshift;
+#endif

 #ifdef DEBUG
    if (vnddebug & VDB_FOLLOW)
@@ -550,7 +610,13 @@
    if ((sc->sc_flags & VNF_INITED) == 0)
        return (ENXIO);

+#if 1
    return (physio(vndstrategy, NULL, dev, B_WRITE, minphys, uio));
+#else
+   bshift = ffs(sc->sc_dkdev.dk_label->d_secsize)-1;
+
+   return (physio2(vndstrategy, NULL, dev, B_WRITE, minphys, uio, bshift));
+#endif
 }

 /* ARGSUSED */
@@ -588,6 +654,10 @@
        if (vnd->sc_flags & VNF_INITED)
            return (EBUSY);

+       if (vio->vnd_size == 0 || vio->vnd_size % DEV_BSIZE != 0 ||
+           vio->vnd_size > BLKDEV_IOSIZE)
+           vio->vnd_size = DEV_BSIZE;
+
        if ((error = vndlock(vnd)) != 0)
            return (error);

@@ -602,23 +672,55 @@
            vndunlock(vnd);
            return(error);
        }
-       error = VOP_GETATTR(nd.ni_vp, &vattr, p->p_ucred, p);
+       if (nd.ni_vp->v_type == VBLK || nd.ni_vp->v_type == VCHR) {
+           struct partinfo dpart;
+
+           dpart.disklab = NULL;
+           dpart.part = NULL;
+           error = VOP_IOCTL(nd.ni_vp, DIOCGPART, (caddr_t)&dpart,
+               FREAD, NOCRED, p);
+           if (error == 0) {
+               if (dpart.disklab != NULL && dpart.disklab->d_secsize != 0)
+                   vattr.va_blocksize = dpart.disklab->d_secsize;
+               else
+                   vattr.va_blocksize = DEV_BSIZE;
+               if (dpart.part == NULL)
+                   vattr.va_size = 0;
+               else {
+                   vattr.va_size = dpart.part->p_size *
+                       dpart.disklab->d_secsize;
+               }
+           }
+       } else {
+           error = VOP_GETATTR(nd.ni_vp, &vattr, p->p_ucred, p);
+       }
        if (error) {
            VOP_UNLOCK(nd.ni_vp);
            (void) vn_close(nd.ni_vp, FREAD|FWRITE, p->p_ucred, p);
            vndunlock(vnd);
            return(error);
        }
+           
        VOP_UNLOCK(nd.ni_vp);
        vnd->sc_vp = nd.ni_vp;
-       vnd->sc_size = btodb(vattr.va_size);    /* note truncation */
-       if ((error = vndsetcred(vnd, p->p_ucred)) != 0) {
+       vnd->sc_blksize = vio->vnd_size;
+       vnd->sc_bshift = ffs(vnd->sc_blksize) - 1;
+       vnd->sc_size = vattr.va_size >> vnd->sc_bshift; /* note truncation */
+       if (nd.ni_vp->v_type != VBLK && nd.ni_vp->v_type != VCHR) {
+           vnd->sc_bsize = nd.ni_vp->v_mount->mnt_stat.f_iosize;
+       } else {
+           if (vattr.va_blocksize != 0)
+               vnd->sc_bsize = vattr.va_blocksize;
+           else
+               vnd->sc_bsize = DEV_BSIZE;
+       }
+       if ((error = vndsetcred(vnd, p->p_ucred, p)) != 0) {
            (void) vn_close(nd.ni_vp, FREAD|FWRITE, p->p_ucred, p);
            vndunlock(vnd);
            return(error);
        }
        vndthrottle(vnd, vnd->sc_vp);
-       vio->vnd_size = dbtob(vnd->sc_size);
+       vio->vnd_size = vnd->sc_size << vnd->sc_bshift;
        vnd->sc_flags |= VNF_INITED;
 #ifdef DEBUG
        if (vnddebug & VDB_INIT)
@@ -632,6 +734,8 @@
        vnd->sc_dkdev.dk_name = vnd->sc_xname;
        disk_attach(&vnd->sc_dkdev);

+       vndgetdisklabel(dev, vnd);
+
        vndunlock(vnd);

        break;
@@ -673,6 +777,60 @@
    /*
     * XXX Should support disklabels.
     */
+   case DIOCGDINFO:
+       if ((vnd->sc_flags & VNF_INITED) == 0)
+           return (ENXIO);
+
+       *(struct disklabel *)data = *(vnd->sc_dkdev.dk_label);
+       return 0;
+
+   case DIOCGPART:
+       if ((vnd->sc_flags & VNF_INITED) == 0)
+           return (ENXIO);
+
+       ((struct partinfo *)data)->disklab = vnd->sc_dkdev.dk_label;
+       ((struct partinfo *)data)->part =
+           &vnd->sc_dkdev.dk_label->d_partitions[VNDPART(dev)];
+       return 0;
+
+
+   case DIOCWDINFO:
+   case DIOCSDINFO:
+       if ((vnd->sc_flags & VNF_INITED) == 0)
+           return (ENXIO);
+
+       if ((flag & FWRITE) == 0)
+           return EBADF;
+
+       if ((error = vndlock(vnd)) != 0)
+           return error;
+       vnd->sc_flags |= VNF_LABELLING;
+
+       error = setdisklabel(vnd->sc_dkdev.dk_label,
+           (struct disklabel *)data, /*vnd->sc_dkdev.dk_openmask : */0,
+           vnd->sc_dkdev.dk_cpulabel);
+       if (error == 0) {
+           if (cmd == DIOCWDINFO)
+               error = writedisklabel(VNDLABELDEV(dev),
+                   vndstrategy, vnd->sc_dkdev.dk_label,
+                   vnd->sc_dkdev.dk_cpulabel);
+       }
+
+       vnd->sc_flags &= ~VNF_LABELLING;
+       vndunlock(vnd);
+       return error;
+
+   case DIOCWLABEL:
+       if ((vnd->sc_flags & VNF_INITED) == 0)
+           return (ENXIO);
+
+       if ((flag & FWRITE) == 0)
+           return EBADF;
+       if (*(int *)data)
+           vnd->sc_flags |= VNF_WLABEL;
+       else
+           vnd->sc_flags &= ~VNF_WLABEL;
+       return 0;

    default:
        return(ENOTTY);
@@ -682,15 +840,69 @@
 }

 /*
+ * Load the label information on the named device
+ */
+void
+vndgetdisklabel(dev, vnd)
+   dev_t dev;
+   struct vnd_softc *vnd;
+{
+   struct disklabel *lp = vnd->sc_dkdev.dk_label;
+   char *errstring;
+
+   bzero(lp, sizeof(struct disklabel));
+   bzero(vnd->sc_dkdev.dk_cpulabel, sizeof(struct cpu_disklabel));
+
+   lp->d_secsize = vnd->sc_blksize;
+   lp->d_ntracks = 64;
+   lp->d_nsectors = 32;
+   lp->d_ncylinders = vnd->sc_size / (64 * 32);
+   lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors;
+   if (lp->d_secpercyl == 0) {
+       lp->d_secpercyl = 100;
+       /* as long as it's not 0 - readdisklabel divides by it (?) */
+   }
+
+   strncpy(lp->d_typename, "vnode disk", 16);
+   lp->d_type = DTYPE_VND;
+   strncpy(lp->d_packname, "fictitious", 16);
+   lp->d_secperunit = vnd->sc_size;
+   lp->d_rpm = 3600;
+   lp->d_interleave = 1;
+   lp->d_flags = 0;
+
+   lp->d_partitions[RAW_PART].p_offset = 0;
+   lp->d_partitions[RAW_PART].p_size =
+       lp->d_secperunit;
+   lp->d_partitions[RAW_PART].p_fstype = FS_UNUSED;
+   lp->d_npartitions = RAW_PART + 1;
+
+   lp->d_magic = DISKMAGIC;
+   lp->d_magic2 = DISKMAGIC;
+   lp->d_checksum = dkcksum(lp);
+
+   /*
+    * Call the generic disklabel extraction routine
+    */
+   errstring = readdisklabel(dev,
+                 vndstrategy, lp, vnd->sc_dkdev.dk_cpulabel);
+   if (errstring) {
+       printf("%s: %s\n", vnd->sc_xname, errstring);
+       return;
+   }
+}
+
+/*
  * Duplicate the current processes' credentials.  Since we are called only
  * as the result of a SET ioctl and only root can do that, any future access
  * to this "disk" is essentially as root.  Note that credentials may change
  * if some other uid can write directly to the mapped file (NFS).
  */
 int
-vndsetcred(vnd, cred)
+vndsetcred(vnd, cred, p)
    register struct vnd_softc *vnd;
    struct ucred *cred;
+   struct proc *p;
 {
    struct uio auio;
    struct iovec aiov;
@@ -709,6 +921,7 @@
    auio.uio_rw = UIO_READ;
    auio.uio_segflg = UIO_SYSSPACE;
    auio.uio_resid = aiov.iov_len;
+   auio.uio_procp = p;
    VOP_LOCK(vnd->sc_vp);
    error = VOP_READ(vnd->sc_vp, &auio, 0, vnd->sc_cred);
    VOP_UNLOCK(vnd->sc_vp);
Index: sys/msdosfs/msdosfs_denode.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/msdosfs/msdosfs_denode.c,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -u -r1.1.1.2 -r1.2
--- msdosfs_denode.c    1997/04/01 07:16:17 1.1.1.2
+++ msdosfs_denode.c    1997/05/29 17:50:58 1.2
@@ -380,12 +380,12 @@
    if ((boff = length & pmp->pm_crbomask) != 0) {
        if (isadir) {
            bn = cntobn(pmp, eofentry);
-           error = bread(pmp->pm_devvp, bn, pmp->pm_bpcluster,
-               NOCRED, &bp);
+           error = bread(pmp->pm_devvp, fsbtosb(pmp, bn),
+               pmp->pm_bpcluster, NOCRED, &bp);
        } else {
            bn = de_blk(pmp, length);
-           error = bread(DETOV(dep), bn, pmp->pm_bpcluster,
-               NOCRED, &bp);
+           error = bread(DETOV(dep), fsbtosb(pmp, bn),
+               pmp->pm_bpcluster, NOCRED, &bp);
        }
        if (error) {
            brelse(bp);
Index: sys/msdosfs/msdosfs_fat.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/msdosfs/msdosfs_fat.c,v
retrieving revision 1.1.1.3
retrieving revision 1.2
diff -u -r1.1.1.3 -r1.2
--- msdosfs_fat.c   1997/05/23 22:00:06 1.1.1.3
+++ msdosfs_fat.c   1997/05/29 17:51:00 1.2
@@ -223,7 +223,8 @@
        if (bn != bp_bn) {
            if (bp)
                brelse(bp);
-           error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp);
+           error = bread(pmp->pm_devvp, fsbtosb(pmp, bn), bsize,
+               NOCRED, &bp);
            if (error) {
                brelse(bp);
                return (error);
@@ -349,7 +350,8 @@
    for (i = 1; i < pmp->pm_FATs; i++) {
        fatbn += pmp->pm_FATsecs;
        /* getblk() never fails */
-       bpn = getblk(pmp->pm_devvp, fatbn, bp->b_bcount, 0, 0);
+       bpn = getblk(pmp->pm_devvp, fsbtosb(pmp, fatbn), bp->b_bcount,
+           0, 0);
        bcopy(bp->b_data, bpn->b_data, bp->b_bcount);
        if (pmp->pm_flags & MSDOSFSMNT_WAITONFAT)
            bwrite(bpn);
@@ -491,7 +493,7 @@

    byteoffset = FATOFS(pmp, cn);
    fatblock(pmp, byteoffset, &bn, &bsize, &bo);
-   if ((error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp)) != 0) {
+   if ((error = bread(pmp->pm_devvp, fsbtosb(pmp, bn), bsize, NOCRED, &bp)) != 0) {
        brelse(bp);
        return (error);
    }
@@ -562,7 +564,7 @@
    while (count > 0) {
        byteoffset = FATOFS(pmp, start);
        fatblock(pmp, byteoffset, &bn, &bsize, &bo);
-       error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp);
+       error = bread(pmp->pm_devvp, fsbtosb(pmp, bn), bsize, NOCRED, &bp);
        if (error) {
            brelse(bp);
            return (error);
@@ -792,7 +794,7 @@
        if (lbn != bn) {
            if (bp)
                updatefats(pmp, bp, lbn);
-           error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp);
+           error = bread(pmp->pm_devvp, fsbtosb(pmp, bn), bsize, NOCRED, &bp);
            if (error) {
                brelse(bp);
                return (error);
@@ -860,7 +862,7 @@
            if (bp)
                brelse(bp);
            fatblock(pmp, byteoffset, &bn, &bsize, NULL);
-           error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp);
+           error = bread(pmp->pm_devvp, fsbtosb(pmp, bn), bsize, NOCRED, &bp);
            if (error) {
                brelse(bp);
                return (error);
@@ -986,20 +988,22 @@
                 * Get the buf header for the new block of the file.
                 */
                if (dep->de_Attributes & ATTR_DIRECTORY)
-                   bp = getblk(pmp->pm_devvp, cntobn(pmp, cn++),
+                   bp = getblk(pmp->pm_devvp, fsbtosb(pmp, cntobn(pmp, cn++)),
                            pmp->pm_bpcluster, 0, 0);
                else {
-                   bp = getblk(DETOV(dep), de_cn2bn(pmp, frcn++),
+                   bp = getblk(DETOV(dep), fsbtosb(pmp, de_cn2bn(pmp, frcn++)),
                        pmp->pm_bpcluster, 0, 0);
                    /*
                     * Do the bmap now, as in msdosfs_write
                     */
                    if (pcbmap(dep,
-                       de_bn2cn(pmp, bp->b_lblkno),
+                       de_bn2cn(pmp, sbtofsb(pmp, bp->b_lblkno)),
                        &bp->b_blkno, 0, 0))
                        bp->b_blkno = -1;
                    if (bp->b_blkno == -1)
                        panic("extendfile: pcbmap");
+                   else
+                       bp->b_blkno = fsbtosb(pmp, bp->b_blkno);
                }
                clrbuf(bp);
                if (bpp) {
Index: sys/msdosfs/msdosfs_lookup.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/msdosfs/msdosfs_lookup.c,v
retrieving revision 1.1.1.3
retrieving revision 1.2
diff -u -r1.1.1.3 -r1.2
--- msdosfs_lookup.c    1997/05/12 21:48:22 1.1.1.3
+++ msdosfs_lookup.c    1997/05/29 17:51:01 1.2
@@ -261,7 +261,7 @@
                break;
            return (error);
        }
-       error = bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp);
+       error = bread(pmp->pm_devvp, fsbtosb(pmp, bn), blsize, NOCRED, &bp);
        if (error) {
            brelse(bp);
            return (error);
@@ -629,7 +629,7 @@
    diroffset = ddep->de_fndoffset;
    if (dirclust != MSDOSFSROOT)
        diroffset &= pmp->pm_crbomask;
-   if ((error = bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp)) != 0) {
+   if ((error = bread(pmp->pm_devvp, fsbtosb(pmp, bn), blsize, NOCRED, &bp)) != 0) {
        brelse(bp);
        return error;
    }
@@ -659,8 +659,8 @@
                if (error)
                    return error;

-               error = bread(pmp->pm_devvp, bn, blsize,
-                         NOCRED, &bp);
+               error = bread(pmp->pm_devvp, fsbtosb(pmp, bn),
+                         blsize, NOCRED, &bp);
                if (error) {
                    brelse(bp);
                    return error;
@@ -722,7 +722,7 @@
                return (1); /* it's empty */
            return (0);
        }
-       error = bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp);
+       error = bread(pmp->pm_devvp, fsbtosb(pmp, bn), blsize, NOCRED, &bp);
        if (error) {
            brelse(bp);
            return (0);
@@ -807,7 +807,7 @@
        }
        pmp = dep->de_pmp;
        scn = dep->de_StartCluster;
-       error = bread(pmp->pm_devvp, cntobn(pmp, scn),
+       error = bread(pmp->pm_devvp, fsbtosb(pmp, cntobn(pmp, scn)),
                  pmp->pm_bpcluster, NOCRED, &bp);
        if (error)
            break;
@@ -865,7 +865,7 @@
        && de_blk(pmp, diroffset + blsize) > pmp->pm_rootdirsize)
        blsize = de_bn2off(pmp, pmp->pm_rootdirsize) & pmp->pm_crbomask;
    bn = detobn(pmp, dirclust, diroffset);
-   if ((error = bread(pmp->pm_devvp, bn, blsize, NOCRED, bpp)) != 0) {
+   if ((error = bread(pmp->pm_devvp, fsbtosb(pmp, bn), blsize, NOCRED, bpp)) != 0) {
        brelse(*bpp);
        *bpp = NULL;
        return (error);
@@ -922,7 +922,7 @@
        error = pcbmap(pdep, de_cluster(pmp, offset), &bn, 0, &blsize);
        if (error)
            return error;
-       error = bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp);
+       error = bread(pmp->pm_devvp, fsbtosb(pmp, bn), blsize, NOCRED, &bp);
        if (error) {
            brelse(bp);
            return error;
@@ -985,7 +985,7 @@
                    return 0;
                return error;
            }
-           error = bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp);
+           error = bread(pmp->pm_devvp, fsbtosb(pmp, bn), blsize, NOCRED, &bp);
            if (error) {
                brelse(bp);
                return error;
@@ -1036,7 +1036,7 @@
    for (cn = 0;; cn++) {
        if (pcbmap(dep, cn, &bn, 0, &blsize))
            return 0;
-       if (bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp)) {
+       if (bread(pmp->pm_devvp, fsbtosb(pmp, bn), blsize, NOCRED, &bp)) {
            brelse(bp);
            return 0;
        }
Index: sys/msdosfs/msdosfs_vfsops.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/msdosfs/msdosfs_vfsops.c,v
retrieving revision 1.1.1.3
diff -u -r1.1.1.3 msdosfs_vfsops.c
--- msdosfs_vfsops.c    1997/05/12 21:48:23 1.1.1.3
+++ msdosfs_vfsops.c    1997/06/25 07:44:14
@@ -317,7 +317,7 @@
     * Read the boot sector of the filesystem, and then check the
     * boot signature.  If not a dos boot sector then error out.
     */
-   if ((error = bread(devvp, 0, 512, NOCRED, &bp)) != 0)
+   if ((error = bread(devvp, 0, BLKDEV_IOSIZE, NOCRED, &bp)) != 0)
        goto error_exit;
    bp->b_flags |= B_AGE;
    bsp = (union bootsector *)bp->b_data;
@@ -412,6 +412,15 @@
        SecPerClust;
    pmp->pm_maxcluster = pmp->pm_nmbrofclusters + 1;
    pmp->pm_fatsize = pmp->pm_FATsecs * pmp->pm_BytesPerSec;
+#if 0
+   if (VOP_IOCTL(devvp, DIOCGPART, (caddr_t)&dpart, FREAD, NOCRED, p) != 0)
+       tmp = DEV_BSIZE;
+   else
+       tmp = dpart.disklab->d_secsize;
+#else
+   tmp = DEV_BSIZE;
+#endif
+   pmp->pm_fsbtosb = ffs(pmp->pm_BytesPerSec) - ffs(tmp);

    if (argp->flags & MSDOSFSMNT_GEMDOSFS) {
        if ((pmp->pm_nmbrofclusters <= (0xff0 - 2))
Index: sys/msdosfs/msdosfs_vnops.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/msdosfs/msdosfs_vnops.c,v
retrieving revision 1.1.1.3
retrieving revision 1.2
diff -u -r1.1.1.3 -r1.2
--- msdosfs_vnops.c 1997/05/12 21:48:24 1.1.1.3
+++ msdosfs_vnops.c 1997/05/29 17:51:03 1.2
@@ -466,16 +466,16 @@
         * vnode for the directory.
         */
        if (isadir) {
-           error = bread(pmp->pm_devvp, lbn, blsize, NOCRED, &bp);
+           error = bread(pmp->pm_devvp, fsbtosb(pmp, lbn), blsize, NOCRED, &bp);
        } else {
            rablock = lbn + 1;
            if (vp->v_lastr + 1 == lbn &&
                de_cn2off(pmp, rablock) < dep->de_FileSize)
-               error = breada(vp, de_cn2bn(pmp, lbn),
+               error = breada(vp, fsbtosb(pmp, de_cn2bn(pmp, lbn)),
                    pmp->pm_bpcluster, de_cn2bn(pmp, rablock),
                    pmp->pm_bpcluster, NOCRED, &bp);
            else
-               error = bread(vp, de_cn2bn(pmp, lbn),
+               error = bread(vp, fsbtosb(pmp, de_cn2bn(pmp, lbn)),
                    pmp->pm_bpcluster, NOCRED, &bp);
            vp->v_lastr = lbn;
        }
@@ -603,7 +603,7 @@
             * or we write the cluster from its start beyond EOF,
             * then no need to read data from disk.
             */
-           bp = getblk(thisvp, bn, pmp->pm_bpcluster, 0, 0);
+           bp = getblk(thisvp, fsbtosb(pmp, bn), pmp->pm_bpcluster, 0, 0);
            clrbuf(bp);
            /*
             * Do the bmap now, since pcbmap needs buffers
@@ -611,10 +611,12 @@
             */
            if (bp->b_blkno == bp->b_lblkno) {
                error = pcbmap(dep,
-                          de_bn2cn(pmp, bp->b_lblkno),
+                          de_bn2cn(pmp, sbtofsb(pmp, bp->b_lblkno)),
                           &bp->b_blkno, 0, 0);
                if (error)
                    bp->b_blkno = -1;
+               else
+                   bp->b_blkno = fsbtosb(pmp, bp->b_blkno);
            }
            if (bp->b_blkno == -1) {
                brelse(bp);
@@ -626,7 +628,7 @@
            /*
             * The block we need to write into exists, so read it in.
             */
-           error = bread(thisvp, bn, pmp->pm_bpcluster,
+           error = bread(thisvp, fsbtosb(pmp, bn), pmp->pm_bpcluster,
                      NOCRED, &bp);
            if (error) {
                brelse(bp);
@@ -638,6 +640,7 @@
        n = min(uio->uio_resid, pmp->pm_bpcluster - croffset);
        if (uio->uio_offset + n > dep->de_FileSize) {
            dep->de_FileSize = uio->uio_offset + n;
+
            vnode_pager_setsize(vp, dep->de_FileSize);  /* why? */
        }
        (void) vnode_pager_uncache(vp); /* why not? */
@@ -1135,7 +1138,7 @@
            panic("msdosfs_rename: updating .. in root directory?\n");
        } else
            bn = cntobn(pmp, cn);
-       error = bread(pmp->pm_devvp, bn, pmp->pm_bpcluster,
+       error = bread(pmp->pm_devvp, fsbtosb(pmp, bn), pmp->pm_bpcluster,
                  NOCRED, &bp);
        if (error) {
            /* XXX should really panic here, fs is corrupt */
@@ -1242,7 +1245,7 @@
     */
    bn = cntobn(pmp, newcluster);
    /* always succeeds */
-   bp = getblk(pmp->pm_devvp, bn, pmp->pm_bpcluster, 0, 0);
+   bp = getblk(pmp->pm_devvp, fsbtosb(pmp, bn), pmp->pm_bpcluster, 0, 0);
    bzero(bp->b_data, pmp->pm_bpcluster);
    bcopy(&dosdirtemplate, bp->b_data, sizeof dosdirtemplate);
    denp = (struct direntry *)bp->b_data;
@@ -1507,7 +1510,7 @@
        n = min(n, diff);
        if ((error = pcbmap(dep, lbn, &bn, &cn, &blsize)) != 0)
            break;
-       error = bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp);
+       error = bread(pmp->pm_devvp, fsbtosb(pmp, bn), blsize, NOCRED, &bp);
        if (error) {
            brelse(bp);
            return (error);
@@ -1801,10 +1804,12 @@
     * don't allow files with holes, so we shouldn't ever see this.
     */
    if (bp->b_blkno == bp->b_lblkno) {
-       error = pcbmap(dep, de_bn2cn(dep->de_pmp, bp->b_lblkno),
+       error = pcbmap(dep, de_bn2cn(dep->de_pmp, sbtofsb(dep->de_pmp, bp->b_lblkno)),
                   &bp->b_blkno, 0, 0);
        if (error)
            bp->b_blkno = -1;
+       else
+           bp->b_blkno = fsbtosb(dep->de_pmp, bp->b_blkno);
        if (bp->b_blkno == -1)
            clrbuf(bp);
    }
Index: sys/msdosfs/msdosfsmount.h
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/msdosfs/msdosfsmount.h,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -u -r1.1.1.2 -r1.2
--- msdosfsmount.h  1997/04/01 07:16:23 1.1.1.2
+++ msdosfsmount.h  1997/05/29 17:51:04 1.2
@@ -58,6 +58,7 @@
    mode_t pm_mask;     /* mask to and with file protection bits */
    struct vnode *pm_devvp; /* vnode for block device mntd */
    struct bpb50 pm_bpb;    /* BIOS parameter blk for this fs */
+   int pm_fsbtosb;     /* fsbtosb and sbtofsb shift constant */
    u_long pm_fatblk;   /* block # of first FAT */
    u_long pm_rootdirblk;   /* block # of root directory */
    u_long pm_rootdirsize;  /* size in blocks (not clusters) */
@@ -78,6 +79,15 @@
    struct netexport pm_export; /* export information */
    u_int  pm_fatentrysize; /* size of fat entry (12/16) */
 };
+
+/*
+ * Turn file system block numbers into system block addresses.
+ * This maps file system blocks to system size blocks.
+ */
+#define fsbtosb(pmp, bn) \
+   ((bn) << (pmp)->pm_fsbtosb)
+#define sbtofsb(pmp, bn) \
+   ((bn) >> (pmp)->pm_fsbtosb)

 /*
  * Mount point flags:
Index: sys/scsi/cd.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/scsi/cd.c,v
retrieving revision 1.1.1.3
diff -u -r1.1.1.3 cd.c
--- cd.c    1997/04/11 07:23:35 1.1.1.3
+++ cd.c    1997/06/25 06:45:15
@@ -549,13 +549,18 @@
         * First, translate the block to absolute and put it in terms
         * of the logical blocksize of the device.
         */
+#if 0
+       blkno = bp->b_blkno;
+#else
        blkno =
            bp->b_blkno / (cd->sc_dk.dk_label->d_secsize / DEV_BSIZE);
+#endif
        if (CDPART(bp->b_dev) != RAW_PART) {
              p = &cd->sc_dk.dk_label->d_partitions[CDPART(bp->b_dev)];
              blkno += p->p_offset;
        }
-       nblks = howmany(bp->b_bcount, cd->sc_dk.dk_label->d_secsize);
+       blkno *= cd->sc_dk.dk_label->d_secsize / cd->params.blksize;
+       nblks = howmany(bp->b_bcount, cd->params.blksize);

        /*
         *  Fill out the scsi command.  If the transfer will
@@ -647,8 +652,14 @@
    struct uio *uio;
    int ioflag;
 {
-
+   struct cd_softc *cd = cd_cd.cd_devs[CDUNIT(dev)];
+#if 1
    return (physio(cdstrategy, NULL, dev, B_READ, cdminphys, uio));
+#else
+   int bshift = ffs(cd->sc_dk.dk_label->d_secsize)-1;
+
+   return (physio2(cdstrategy, NULL, dev, B_READ, cdminphys, uio, bshift));
+#endif
 }

 int
@@ -657,8 +668,14 @@
    struct uio *uio;
    int ioflag;
 {
-
+   struct cd_softc *cd = cd_cd.cd_devs[CDUNIT(dev)];
+#if 1
    return (physio(cdstrategy, NULL, dev, B_WRITE, cdminphys, uio));
+#else
+   int bshift = ffs(cd->sc_dk.dk_label->d_secsize)-1;
+
+   return (physio2(cdstrategy, NULL, dev, B_WRITE, cdminphys, uio, bshift));
+#endif
 }

 /*
@@ -942,6 +959,7 @@
    struct cd_softc *cd;
 {
    struct disklabel *lp = cd->sc_dk.dk_label;
+   char *errstring;

    bzero(lp, sizeof(struct disklabel));
    bzero(cd->sc_dk.dk_cpulabel, sizeof(struct cpu_disklabel));
@@ -962,17 +980,46 @@

    lp->d_partitions[0].p_offset = 0;
    lp->d_partitions[0].p_size =
-       lp->d_secperunit * (lp->d_secsize / DEV_BSIZE);
+       lp->d_secperunit;
    lp->d_partitions[0].p_fstype = FS_ISO9660;
    lp->d_partitions[RAW_PART].p_offset = 0;
    lp->d_partitions[RAW_PART].p_size =
-       lp->d_secperunit * (lp->d_secsize / DEV_BSIZE);
+       lp->d_secperunit;
    lp->d_partitions[RAW_PART].p_fstype = FS_ISO9660;
    lp->d_npartitions = RAW_PART + 1;

    lp->d_magic = DISKMAGIC;
    lp->d_magic2 = DISKMAGIC;
    lp->d_checksum = dkcksum(lp);
+
+   /*
+    * Call the generic disklabel extraction routine
+    */
+   errstring = readdisklabel(MAKECDDEV(0, cd->sc_dev.dv_unit, RAW_PART),
+                 cdstrategy, lp, cd->sc_dk.dk_cpulabel);
+
+#if 0
+   if (errstring) {
+       printf("%s: %s\n", cd->sc_dev.dv_xname, errstring);
+       return;
+   }
+#else
+   if (errstring && strcmp(errstring, "no disk label") == 0) {
+       lp->d_partitions[0].p_offset = 0;
+       lp->d_partitions[0].p_size =
+           lp->d_secperunit;
+       lp->d_partitions[0].p_fstype = FS_ISO9660;
+       lp->d_partitions[RAW_PART].p_offset = 0;
+       lp->d_partitions[RAW_PART].p_size =
+           lp->d_secperunit;
+       lp->d_partitions[RAW_PART].p_fstype = FS_ISO9660;
+       lp->d_npartitions = RAW_PART + 1;
+
+       lp->d_magic = DISKMAGIC;
+       lp->d_magic2 = DISKMAGIC;
+       lp->d_checksum = dkcksum(lp);
+   }
+#endif
 }

 /*
Index: sys/scsi/sd.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/scsi/sd.c,v
retrieving revision 1.1.1.4
diff -u -r1.1.1.4 sd.c
--- sd.c    1997/06/23 16:30:19 1.1.1.4
+++ sd.c    1997/06/25 06:47:42
@@ -577,13 +577,18 @@
         * First, translate the block to absolute and put it in terms
         * of the logical blocksize of the device.
         */
+#if 1
        blkno =
            bp->b_blkno / (sd->sc_dk.dk_label->d_secsize / DEV_BSIZE);
+#else
+       blkno = bp->b_blkno;
+#endif
        if (SDPART(bp->b_dev) != RAW_PART) {
             p = &sd->sc_dk.dk_label->d_partitions[SDPART(bp->b_dev)];
             blkno += p->p_offset;
        }
-       nblks = howmany(bp->b_bcount, sd->sc_dk.dk_label->d_secsize);
+       blkno *= sd->sc_dk.dk_label->d_secsize / sd->params.blksize;
+       nblks = howmany(bp->b_bcount, sd->params.blksize);

        /*
         *  Fill out the scsi command.  If the transfer will
@@ -675,8 +680,14 @@
    struct uio *uio;
    int ioflag;
 {
-
+   struct sd_softc *sd = sd_cd.cd_devs[SDUNIT(dev)];
+#if 1
    return (physio(sdstrategy, NULL, dev, B_READ, sdminphys, uio));
+#else
+   int bshift = ffs(sd->sc_dk.dk_label->d_secsize)-1;
+
+   return (physio2(sdstrategy, NULL, dev, B_READ, sdminphys, uio, bshift));
+#endif
 }

 int
@@ -685,8 +696,14 @@
    struct uio *uio;
    int ioflag;
 {
-
+   struct sd_softc *sd = sd_cd.cd_devs[SDUNIT(dev)];
+#if 1
    return (physio(sdstrategy, NULL, dev, B_WRITE, sdminphys, uio));
+#else
+   int bshift = ffs(sd->sc_dk.dk_label->d_secsize)-1;
+
+   return (physio2(sdstrategy, NULL, dev, B_WRITE, sdminphys, uio, bshift));
+#endif
 }

 /*
@@ -810,7 +827,7 @@

    lp->d_partitions[RAW_PART].p_offset = 0;
    lp->d_partitions[RAW_PART].p_size =
-       lp->d_secperunit * (lp->d_secsize / DEV_BSIZE);
+       lp->d_secperunit;
    lp->d_partitions[RAW_PART].p_fstype = FS_UNUSED;
    lp->d_npartitions = RAW_PART + 1;

Index: sys/ufs/ffs/ffs_vfsops.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/ufs/ffs/ffs_vfsops.c,v
retrieving revision 1.1.1.3
diff -u -r1.1.1.3 ffs_vfsops.c
--- ffs_vfsops.c    1997/06/23 16:31:06 1.1.1.3
+++ ffs_vfsops.c    1997/06/25 06:50:49
@@ -307,7 +307,9 @@
    struct csum *space;
    struct buf *bp;
    struct fs *fs, *newfs;
+#if 0
    struct partinfo dpart;
+#endif
    int i, blks, size, error;
    int32_t *lp;

@@ -322,10 +324,15 @@
    /*
     * Step 2: re-read superblock from disk.
     */
+#if 0
    if (VOP_IOCTL(devvp, DIOCGPART, (caddr_t)&dpart, FREAD, NOCRED, p) != 0)
        size = DEV_BSIZE;
    else
        size = dpart.disklab->d_secsize;
+#else
+   size = DEV_BSIZE;
+#endif
+
    error = bread(devvp, (daddr_t)(SBOFF / size), SBSIZE, NOCRED, &bp);
    if (error)
        return (error);
@@ -343,6 +350,7 @@
     */
    bcopy(&fs->fs_csp[0], &newfs->fs_csp[0], sizeof(fs->fs_csp));
    newfs->fs_maxcluster = fs->fs_maxcluster;
+   newfs->fs_fsbtosb = fs->fs_fsbtosb;
    bcopy(newfs, fs, (u_int)fs->fs_sbsize);
    if (fs->fs_sbsize < SBSIZE)
        bp->b_flags |= B_INVAL;
@@ -424,10 +432,12 @@
    struct buf *bp;
    register struct fs *fs;
    dev_t dev;
+#if 0
    struct partinfo dpart;
+#endif
    caddr_t base, space;
    int blks;
-   int error, i, size, ronly;
+   int error, i, size, ssize, ronly;
    int32_t *lp;
    struct ucred *cred;
    extern struct vnode *rootvp;
@@ -452,10 +462,14 @@
    error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, p);
    if (error)
        return (error);
+#if 0
    if (VOP_IOCTL(devvp, DIOCGPART, (caddr_t)&dpart, FREAD, cred, p) != 0)
        size = DEV_BSIZE;
    else
        size = dpart.disklab->d_secsize;
+#else
+   size = DEV_BSIZE;
+#endif

    bp = NULL;
    ump = NULL;
@@ -473,6 +487,21 @@
        error = EROFS;      /* XXX what should be returned? */
        goto out;
    }
+   /* XXX bread assumes b_blkno in DEV_BSIZE unit. Calculate fsbtosb */
+
+   ssize = fs->fs_fsize / fs->fs_nspf;
+   fs->fs_fsbtosb = fs->fs_fsbtodb;
+   if (ssize >= size) {
+       ssize = ssize / size;
+       for (i = 0; ssize > 1; ssize >>= 1)
+           i ++;
+       fs->fs_fsbtosb += i;
+   } else {
+       ssize = size / ssize;
+       for (i = 0; ssize > 1; ssize >>= 1)
+           i ++;
+       fs->fs_fsbtosb -= i;
+   }
    ump = malloc(sizeof *ump, M_UFSMNT, M_WAITOK);
    bzero((caddr_t)ump, sizeof *ump);
    ump->um_fs = malloc((u_long)fs->fs_sbsize, M_UFSMNT,
@@ -523,7 +552,7 @@
    ump->um_dev = dev;
    ump->um_devvp = devvp;
    ump->um_nindir = fs->fs_nindir;
-   ump->um_bptrtodb = fs->fs_fsbtodb;
+   ump->um_bptrtodb = fs->fs_fsbtosb;
    ump->um_seqinc = fs->fs_frag;
    for (i = 0; i < MAXQUOTAS; i++)
        ump->um_quotas[i] = NULLVP;
@@ -921,11 +950,12 @@
    register struct buf *bp;
    int i, error = 0;

-   bp = getblk(mp->um_devvp, SBOFF >> (fs->fs_fshift - fs->fs_fsbtodb),
+   bp = getblk(mp->um_devvp, SBOFF >> (fs->fs_fshift - fs->fs_fsbtosb),
        (int)fs->fs_sbsize, 0, 0);
    bcopy((caddr_t)fs, bp->b_data, (u_int)fs->fs_sbsize);
    /* Restore compatibility to old file systems.          XXX */
    dfs = (struct fs *)bp->b_data;              /* XXX */
+   dfs->fs_fsbtosb = 0;                    /* XXX */
    if (fs->fs_postblformat == FS_42POSTBLFMT)      /* XXX */
        dfs->fs_nrpos = -1;             /* XXX */
    if (fs->fs_inodefmt < FS_44INODEFMT) {          /* XXX */
Index: sys/ufs/ffs/fs.h
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/ufs/ffs/fs.h,v
retrieving revision 1.1.1.2
retrieving revision 1.3
diff -u -r1.1.1.2 -r1.3
--- fs.h    1997/06/23 16:31:07 1.1.1.2
+++ fs.h    1997/06/24 03:12:03 1.3
@@ -228,7 +228,8 @@
    int32_t  *fs_maxcluster;    /* max cluster in each cyl group */
    int32_t  fs_cpc;        /* cyl per cycle in postbl */
    int16_t  fs_opostbl[16][8]; /* old rotation block list head */
-   int32_t  fs_sparecon[49];   /* reserved for future constants */
+   int32_t  fs_fsbtosb;        /* fsbtodb and dbtofsb shift constant */
+   int32_t  fs_sparecon[48];   /* reserved for future constants */
    time_t   fs_fscktime;       /* last time fsck(8)ed */
    int32_t  fs_contigsumsize;  /* size of cluster summary array */ 
    int32_t  fs_maxsymlinklen;  /* max length of an internal symlink */
@@ -394,8 +395,8 @@
  * Turn file system block numbers into disk block addresses.
  * This maps file system blocks to device size blocks.
  */
-#define fsbtodb(fs, b) ((b) << (fs)->fs_fsbtodb)
-#define    dbtofsb(fs, b)  ((b) >> (fs)->fs_fsbtodb)
+#define fsbtodb(fs, b) ((b) << (fs)->fs_fsbtosb)
+#define    dbtofsb(fs, b)  ((b) >> (fs)->fs_fsbtosb)

 /*
  * Cylinder group macros to locate things in cylinder groups.

Audit trail


Responsible-Changed-From-To: kern-bug-people->wrstuden 
Responsible-Changed-By: thorpej 
Responsible-Changed-When: Tue Jan 25 23:46:35 PST 2000 
Responsible-Changed-Why:  
wrstuden is handling large-block disks 
Responsible-Changed-From-To: wrstuden->kern-bug-people
Responsible-Changed-By: [email protected]
Responsible-Changed-When: Mon, 28 Feb 2011 14:55:46 +0000
Responsible-Changed-Why:
Reset responsible field for retired developer.



ppp-related crash during shutdown

Metadata

  • Number: 39199
  • Arrived: Wed Jul 23 18:55:00 +0000 2008
  • Last modified: Sat Sep 06 18:17:42 +0000 2008
  • Environment: System: NetBSD 4.99.69 Architecture: i386 Machine: i386

Description


    The system crashed during shutdown.

    At the time, pppd was running over a serial port on a PCMCIA modem
    card.


How to repeat


    Insert PCMCIA modem card.

    Run pppd over the com port on the modem card.

    shutdown -p now (or perhaps it was shutdown -r now; I don't remember)
    [...]
    Done running shutdown hooks.
    tap0 detached [unrelated to this problem, I assume]
    uvm_fault(0xc088b040, 0xdeadb000, 1) -> 0xe
    fatal page fault in supervisor mode
    trap type 6 code 0 eip c01e9465 cs 8 eflags 10282 cr2 deadbeff ilevel 6
    kernel: supervisor trap page fault, code = 0
    Stopped in pid 1535.1 (pppd) at netbsd:pfi_ihead_RB_REMOVE+0x25: movl
    0
    x10(%edx),%eax
    db{1}> bt
    pfi_ihead_RB_REMOVE ...
    pfi_kif_unref ...
    pfi_detach_ifgroup ....
    if_delgroup ...
    pfi_destroy_groups ...
    pfil_ifnet_wrapper ...
    pfil_run_hooks ...
    if_detach ...
    ppp_clone_destroy ...
    pppclose ...
    ttioctl ...
    [...]


Fix


    Unknown


mountd ALLDIRS deficiency

Metadata

  • Number: 2556
  • Originator: Jan-Hinrich Fessel <[email protected]>
  • Arrived: Mon Jun 17 14:50:01 +0000 1996
  • Last modified: Mon Jun 05 22:30:39 +0000 2000
  • Environment: System: NetBSD zappa.unna.Ping.DE 1.1A NetBSD 1.1A (ZAPPA) #52: Sat Mar 16 13:53:02 MET 1996 [email protected]:/usr/src/sys/arch/i386/compile/ZAPPA i386

Description


    The -alldirs option to mountd (in /etc/exports) is only usable if the directrory
    to be exported is a directory a filesystem is mounted on, e.g 
    /dev/sd1g                   249151   224938    11755    95%    /usr/local
    can be exported with -alldirs, /usr/local/faces fails to be exported -alldirs.

How to repeat


    zappa# df
    Filesystem               1K-blocks     Used    Avail Capacity  Mounted on
    /dev/sd0a                    16415    12841     2753    82%    /
    kernfs                           1        1        0   100%    /kern
    procfs                           4        4        0   100%    /proc
    fdesc                            1        1        0   100%    /dev
    mfs:23                       26959     2585    23026    10%    /tmp
    /dev/sd0g                   180735   105872    65826    62%    /usr
    /dev/sd1g                   249151   224938    11755    95%    /usr/local
    /dev/sd0e                  1314541   700505   548308    56%    /usr/src
    /dev/sd1h                   322182   274714    31358    90%    /export/home
    /dev/sd1f                   409896   180864   208537    46%    /var
    /dev/sd1a                    16055     1851    13401    12%    /var/spool/uucp
    /dev/sd0h                   412639   325584    66423    83%    /export/ftp
    amd:84                           0        0        0   100%    /cdrom
    amd:84                           0        0        0   100%    /home
    zippo:/export/home/oskar    301141   197511    88572    69%    /amd/zippo/export/home/oskar
    zappa# cat /etc/exports
    /export/ftp     -alldirs -maproot=root 193.100.14.22 193.100.14.21 193.100.14.19 193.100.14.18
    /usr/src        -alldirs -maproot=root 193.100.14.22 193.100.14.19 193.100.14.18
    /usr/local/faces        -alldirs
    /xwin           -maproot=root 193.100.14.22 193.100.14.18
    /export/home            -maproot=root 193.100.14.22 193.100.14.18
    /cdrom          -ro
    zappa# mountd -d
    Getting export list.
    Got line /export/ftp    -alldirs -maproot=root 193.100.14.22 193.100.14.21 193.100.14.19 193.100.14.18
    Making new ep fs=0x407,0x78b
    doing opt -alldirs -maproot=root 193.100.14.22 193.100.14.21 193.100.14.19 193.100.14.18
    doing opt -maproot=root 193.100.14.22 193.100.14.21 193.100.14.19 193.100.14.18
    got host 193.100.14.22
    got host 193.100.14.21
    got host 193.100.14.19
    got host 193.100.14.18
    Got line /usr/src       -alldirs -maproot=root 193.100.14.22 193.100.14.19 193.100.14.18
    Making new ep fs=0x404,0x78b
    doing opt -alldirs -maproot=root 193.100.14.22 193.100.14.19 193.100.14.18
    doing opt -maproot=root 193.100.14.22 193.100.14.19 193.100.14.18
    got host 193.100.14.22
    got host 193.100.14.19
    got host 193.100.14.18
    Got line /usr/local/faces       -alldirs
    Making new ep fs=0x40e,0x78b
    doing opt -alldirs
    Adding a default entry
    Got line /xwin          -maproot=root 193.100.14.22 193.100.14.18
    Making new ep fs=0x400,0x78b
    doing opt -maproot=root 193.100.14.22 193.100.14.18
    got host 193.100.14.22
    got host 193.100.14.18
    Got line /export/home           -maproot=root 193.100.14.22 193.100.14.18
    Making new ep fs=0x40f,0x78b
    doing opt -maproot=root 193.100.14.22 193.100.14.18
    got host 193.100.14.22
    got host 193.100.14.18
    Got line /cdrom         -ro
    Making new ep fs=0x1c01,0x70b
    doing opt -ro
    Adding a default entry
    Getting mount list.
    Here we go.
    Jun 17 20:08:44 zappa mountd[26107]: Could not remount /usr/local/faces: Invalid argument
    Jun 17 20:08:44 zappa mountd[26107]: Bad exports list line /usr/local/faces     -alldirs

    This is espacially annoying when using amd on homedirs on the other end...


Fix



    temporary hack: just allow the mount, regardless what the mount call to
    update the kernel says, if we export -alldirs:

diff -c mountd.c~ mountd.c
*** mountd.c~   Mon Jun 17 20:00:08 1996
--- mountd.c    Mon Jun 17 19:58:08 1996
***************
*** 1606,1612 ****
--- 1606,1614 ----
                        if (opt_flags & OP_ALLDIRS) {
                                syslog(LOG_ERR, "Could not remount %s: %m",
                                        dirp);
+                               /*
                                return (1);
+                               */
                        }
                        /* back up over the last component */
                        while (*cp == '/' && cp > dirp)



Mounting on directories provided by pseudo-filesystems can be lost

Metadata

  • Number: 2856
  • Originator:
    <[[email protected] (Wolfgang Solfrank)](mailto:[email protected] %28Wolfgang Solfrank%29)>
  • Arrived: Thu Oct 17 11:20:03 +0000 1996
  • Last modified: Mon Jun 05 22:16:24 +0000 2000
  • Environment: System: NetBSD august 1.2A NetBSD 1.2A (GENERIC) #23: Tue Oct 15 16:22:05 MET DST 1996 ws@kurt:/home/NetBSD/kernel/NetBSD/sys/arch/powerpc/compile/GENERIC PowerPC

Description



Some pseudo-filesystems provide directories.  E.g the proc filesystem has
a directory for every process in the system.  These directories can get lost
independent of any filesystem activity.  When you mount some filesystem on
such a directory, you may loose the filesystem as you can neither access any
files on it nor even do an unmount of it.

A similar problem might be in nfs, when a client does a rmdir on some
directory the server has mounted something on, or when a server does an
rmdir of a directory a client has mounted something on (albeit the latter
will at least result in some ESTALE errors), but I cannot test this at
the moment.


How to repeat



$ mount -t msdos /dev/ofdisk0c /proc/curproc

Subsequent mount calls will reveal a mount on /proc/xxx with xxx being some
process number, but ls /proc will not show this.


sys/dev/isa/seagate.c is not MI

Metadata

  • Number: 18887
  • Originator: Perry E. Metzger <[email protected]>
  • Arrived: Sat Nov 02 02:15:00 +0000 2002
  • Last modified:
  • Environment: System: NetBSD alchemist 1.6H NetBSD 1.6H (ALCHEMIST) #0: Thu Oct 3 19:36:25 EDT 2002 perry@alchemist:/usr/src/sys/arch/i386/compile/ALCHEMIST i386 Architecture: i386 Machine: i386

Description


    sys/dev/isa/seagate.c contains x86 asm in it. This would tend
to make one believe it is not, in fact, MI code.

How to repeat


    fgrep asm /usr/src/sys/dev/isa/seagate.c

Fix


    Either make it use right abstraction or move the thing.


Firefox on NetBSD sparc64 incorrectly displays orange and blue colours

Metadata

  • Number: 48800
  • Arrived: Sun May 11 09:05:00 +0000 2014
  • Last modified: Sun May 11 09:20:05 +0000 2014
  • Environment: NetBSD ultra10 6.99.40 NetBSD 6.99.40 (GENERIC.UP) #0: Sun May 4 16:11:50 BST 2014 roman@atom510:/opt/obj.sparc64/sys/arch/sparc64/compile/GENERIC.UP sparc64

Description


firefox-29.0 and various previous versions incorrectly display orange and blue colours, i.e. those colours are swapped. You can see the effect on the following screenshot:

https://drive.google.com/file/d/0B5_0Y3a5LFU8ZEhaOFh4V3FENlE/edit?usp=sharing

The following observations have been made:

1. The issue seems to occur on sparc64 with Creator3D UPA framebuffer (ffb0 at mainbus0 addr 0xfebc0000: Creator3D, model SUNW,501-4788, dac 10)

2. Someone has tried running the same firefox binary package on sparc64 but with a PCI graphics card and the issue was not reproducable.

3. The issue is not reproducable if I enable X11 forwarding and ssh into sparc64 machine from x86, then executing firefox on sparc64, so that it is displayed on x86.

4. It is only firefox binary that shows the issue on sparc64. Other GTK programs on the same machine display the same image correctly.

It seems like a big/little-endian bug in firefox that only shows up with Creator3D framebuffer, or maybe there is an issue with X11 ffb driver??

How to repeat


Run firefox on sparc64 with Creator3D framebuffer.

Audit trail



Responsible-Changed-From-To: pkg-manager->ryoon
Responsible-Changed-By: [email protected]
Responsible-Changed-When: Sun, 11 May 2014 09:20:05 +0000
Responsible-Changed-Why:
Over to maintainer.



umapfs over nfs wierdness

Metadata

  • Number: 4315
  • Originator: Yoav Yerushalmi <[email protected]>
  • Arrived: Tue Oct 21 14:35:04 +0000 1997
  • Last modified: Tue Sep 07 18:50:48 +0000 1999
  • Environment: System: NetBSD eagle 1.2 NetBSD 1.2 (ATHENAOTHER) #13: Sun Nov 10 03:22:41 EST 1996 ghudson@the-light-fantastic:/afs/sipb.mit.edu/project/netbsd/release/athena-7.7.2/netbsd-1.2/src/sys/arch/i386/compile/ATHENAOTHER i386

Description


    I mount an NFS filesystem, and then mount a umapfs system
on top of it to remap uids. Then, I try to rm a file through the
umap. The file does get rm'd, but NFS turd is left behind (.nfsXXXXXX).
This suggests the file is still open in something, but certainly not
in any program I'm running.  When the umap mount is removed, the
NFS turd disappears.


How to repeat


    mount -t nfs <NFS mountpoint> /foo
    mount -t umap -u <uidfile> -g <gidfile> /foo /bar
    rm /bar/baz
    (ls -l .nfs*)
    umount /bar
    ls -l /foo/.nfs*

Audit trail


Responsible-Changed-From-To: kern-bug-people->perseant 
Responsible-Changed-By: hwr 
Responsible-Changed-When: Tue May 4 01:56:43 PDT 1999 
Responsible-Changed-Why:  
Konrad wants to take care of this. 
Responsible-Changed-From-To: perseant->kern-bug-people 
Responsible-Changed-By: perseant 
Responsible-Changed-When: Tue Sep 7 11:49:06 PDT 1999 
Responsible-Changed-Why:  
Need to give this one up because the VFS layer needs to change in order to fix 
is properly.  Wrstuden proposed the necessary change, so there is still hope... 

Unformatted


 1997 oct 23 added synopsis & subject. -is

during setup of a yp-slave server I see two times

Metadata

  • Number: 4334
  • Originator: Uwe Arndt <[email protected]>
  • Arrived: Fri Oct 24 08:05:02 +0000 1997
  • Last modified:
  • Environment: System: NetBSD harvey.uni-koblenz.de 1.2G NetBSD 1.2G (UWES) #0: Mon Oct 20 13:55:21 CEST 1997 root@handy:/usr/src/sys/arch/i386/compile/UWES i386

Description


during setup of a yp-slave server I see two times
        yp_match_host: clnt_call: RPC Time out
        and the two databases (hosts.byname and hosts.byaddr) are
        empty ( except YP_INTERDOMAIN, YP_MASTER_NAMExxxxx,
        YP_LAST_MODIFIED0877356828).

How to repeat


        ypinit -s <with solaris 2.5 master>

Fix


        my current work arround is to move the add_secure in
        ypxfr behind the getting of the host entries, so I get
        at least the host entries, actually I remove add_secure
        because the pushing of new list takes very long (timeout).
        I can't see why this is happening, I would expect solaris
        to send "no matching entry".

Unformatted


        yp_match_host: clnt_call: RPC Time out

./gomoku runs out of memory and segfaults

Metadata

  • Number: 3126
  • Originator: Andrew Wheadon <[email protected]>
  • Arrived: Sat Jan 18 10:20:02 +0000 1997
  • Last modified: Sat Jan 19 20:55:04 +0000 2008
  • Environment: System: NetBSD wipux2.wifo.uni-mannheim.de 1.2B NetBSD 1.2B (WIPOOL) #0: Sat Jan 11 03:34:48 MET 1997 [email protected]:/src/src/sys/arch/i386/compile/WIPOOL i386

Description


When playing gomoku it will usually start using up masses of memory
after about 8 turns (4 each), it will then sit there calculating 
for about 5 minutes before it runs out of memory (if ulimit is set
to 16MB), after which it will segfault. (it failed 4 out of 5 times).


How to repeat


    play gomoku until it starts thinking for ages and then
    watch it growing with 'top' until it Segfaults.


Fix


unlimit and add lots of memory to machine or 
free memory after each game (not sufficient since it will often
use up too much memory in one game)
check whether malloc returns NULL and do appropriate action in 
pickmove.c (unluckily appropriate action means more than just "continue;")
or
make it more intelligent or
make the board smaller (not easy either)
or contact author for newer version.
rm -fr gomoku



Audit trail



From: Andrew Wheadon <[email protected]>
To: [email protected]
Cc:  Subject: Re: bin/3126: games/gomoku segfaults
Date: Sat, 18 Jan 1997 20:40:40 +0100 (MET)

 I forgot to post reliable examples which can be followed:

 Two reliable example:
 you play white
 Computer   You
 K10 (computer always starts with K10 if black)
        J7 (i.e. don't play near computer)
 J9  (random)
        K7
 G7 (computer hopes)
        H8 (spoil computers hope)
 M12 (computer tries force)
        M7 (ignore computers threat)
 Segfaults.
 alternate (but same general tactic)
 you play white
 K10
    J7
 H8 (random)
    K7
 G7
    J9
 F6
    M7
 Segfaults.

 Except for once the computer always played like this.
 Generally ignore it the first two goes, then fill in the
 hole in it's attempted diagonal row and then put a piece
 along your row leaving one hole in it and placing the piece
 away from the diagonal row belonging to the computer.

 -- 
 The cost of living hasn't affected its popularity. (Mark Twain)
 current    release=doc host=netbsd.wifo.uni-mannheim.de \ "NetBSD-current mirror"
 hostbase=/mit/ftp/pub/NetBSD base=/usr prefix=/usr backup delete use-rel-suffix

From: Hubert Feyrer <[email protected]>
To: [email protected]
Cc: [email protected],
        Hubert Feyrer <[email protected]>
Subject: Re: bin/3126: gomoku segfaulting?
Date: Tue, 27 Jul 1999 04:01:44 +0200 (MET DST)

 Hi,

 I'm digging through the NetBSD PR database a bit, and found Pr 3126:
 ./gomoku runs out of memory and segfaults (see
 http://www.NetBSD.org/cgi-bin/query-pr-single.pl?number=3126). 

 I was not able to reproduce this, but then, the given example didn't work
 for me, and I don't know more about that game... maybe you do? 
 What do you think about the PR?


  - Hubert

 -- 
 NetBSD - Better for your uptime than Viagra


From: "Joseph S. Myers" <[email protected]>
To: Hubert Feyrer <[email protected]>
Cc: [email protected]
Subject: Re: bin/3126: gomoku segfaulting?
Date: Tue, 27 Jul 1999 18:30:32 +0100 (BST)

 On Tue, 27 Jul 1999, Hubert Feyrer wrote:

 > I'm digging through the NetBSD PR database a bit, and found Pr 3126:
 > ./gomoku runs out of memory and segfaults (see
 > http://www.NetBSD.org/cgi-bin/query-pr-single.pl?number=3126). 
 > 
 > I was not able to reproduce this, but then, the given example didn't work
 > for me, and I don't know more about that game... maybe you do? 
 > What do you think about the PR?

 I'm reasonably sure that the last time I tested it, it still easily uses
 16M of memory (and doesn't check allocation failure - that bit is fixed in
 my 10K lines of unmerged patches).  As for fixing the memory consumption
 or algorithm - I don't claim to be sufficiently good at gomoku to tell
 what is good enough for computer play.  I have the following from Paul
 Janzen of OpenBSD ([email protected]) on the algorithm (as of
 last August, but he doesn't seem to have worked on it since):

   gomoku is not "done", in that the algorithm still totally sucks (I really
   need to go looking for a new BSD-compatible algorithm.  For what it's worth,
   emacs' gomoku also has a lousy algorithm, but at least it's fast.)  For
   this reason I've held off merging the latest NetBSD gomoku, since most of
   the code I hope will disappear.  However, I have thrown in an improved
   player input scheme, based on the one by esr in "bs".

 -- 
 Joseph S. Myers
 [email protected]

From: David Holland <[email protected]>
To: [email protected]
Cc: 
Subject: Re: bin/3126: ./gomoku runs out of memory and segfaults
Date: Sat, 19 Jan 2008 15:52:37 -0500

 Update:

 In -current it apparently no longer segfaults, but if you crank down
 limits (or, presumably, run on a system without much ram) it will run
 out of memory very promptly and exit. (And it prints "Out of memory"
 in such a way that it's immediately erased by endwin(), so you can't
 tell what happened...)

 It also still uses a really stupid move choice algorithm. :-|

 -- 
    - David A. Holland / [email protected]


ftp doesn't play nice with some servers

Metadata

  • Number: 10897
  • Arrived: Sat Aug 26 14:19:00 +0000 2000
  • Last modified: Sat Jun 16 07:19:24 +0000 2012
  • Environment: System: NetBSD zoo 1.5E NetBSD 1.5E (ZOO-$Revision: 1.55 $) #0: Sat Aug 12 14:34:20 MDT 2000 jim@zoo:/home/tmp/compile/sys/arch/i386/compile/ZOO i386

Description


    If I connect to ftp.netscape.com with the default configuration
    (no startup flags except -i) and try to do a directory listing
    (dir or ls), the connection is dropped.  Initially, there's a
    message about EPSV not being understood (which seems to happen
    with most servers), but evidently the fallback to active mode
    is not working in this case.  If I force active mode on the
    command line (-A), then I can get a directory listing.  It seems
    like the default behavior should be less prone to failure, whatever
    it takes to accomplish that.


How to repeat


    ftp -i ftp.netscape.com
    dir


Audit trail



From: [email protected]
To: [email protected]
Cc: [email protected]
Subject: Re: bin/10897: ftp doesn't play nice with some servers
Date: Sat, 26 Aug 2000 23:54:30 +0900

 >>Synopsis:       ftp doesn't play nice with some servers

    this seems to be problem on ftp.netscape.com.  I happened to be
    connected to this guy,
 220 ftp-va52 SGI 1.5: FTP server (Version wu-2.4.2-academ[BETA-17](2) Wed Jul 19 13:06:02 PDT 2000) ready.

    and this guy chokes with normal IPv4 passive connection (I mean, PASV).
    there should be something really badly configured on the
    ftp.netscape.com side.

 itojun

From: [email protected]
To: [email protected], [email protected]
Cc:  
Subject: Re: bin/10897: ftp doesn't play nice with some servers
Date: Sat, 26 Aug 2000 23:58:16 +0900

 ------- =_aaaaaaaaaa0
 Content-Type: text/plain; charset="us-ascii"
 Content-ID: <[email protected]>
 Content-Transfer-Encoding: 7bit

 >  this seems to be problem on ftp.netscape.com.  I happened to be
 >  connected to this guy,
 >220 ftp-va52 SGI 1.5: FTP server (Version wu-2.4.2-academ[BETA-17](2) Wed Jul 19 13:06:02 PDT 2000) ready.
 >  and this guy chokes with normal IPv4 passive connection (I mean, PASV).
 >  there should be something really badly configured on the
 >  ftp.netscape.com side.

    here is transcript.  noticed the following:
    - 205.188.247.193 dies with PASV.
    - 207.220.85.30 works just fine with PASV.

 itojun



 ------- =_aaaaaaaaaa0
 Content-Type: text/plain; charset="us-ascii"
 Content-ID: <[email protected]>
 Content-Transfer-Encoding: 7bit

 ftp> open 205.188.247.193
 Connected to 205.188.247.193.
 220 ftp-va54 SGI 1.5: FTP server (Version wu-2.4.2-academ[BETA-17](2) Wed Jul 19 13:06:02 PDT 2000) ready.
 ftp_login: user `<null>' pass `<null>' host `205.188.247.193'
 Name (205.188.247.193:itojun): ftp
 ---> USER ftp
 331 Guest login ok, send your complete e-mail address as password.
 Password:
 ---> PASS XXXX
 230-Welcome to the Netscape Communications Corporation FTP server.
 230-
 230-If you have any odd problems, try logging in with a minus sign (-)
 230-as the first character of your password.  This will turn off a feature 
 230-that may be confusing your ftp client program.
 230-
 230-Please send any questions, comments, or problem reports about 
 230-this server to [email protected].
 230-
 230-***********  October 13, 1995  **********
 230-Private ftp is now only on ftp1.netscape.com.  Anonymous is supported on
 230-ftp 2 through 8.  If you are accessing a named account please use ftp1.
 230-
 230 Guest login ok, access restrictions apply.
 ---> SYST
 215 UNIX Type: L8
 Remote system type is UNIX.
 Using binary mode to transfer files.
 ---> PWD
 di257 "/" is current directory.
 got remotepwd as `/'
 ftp> dir
 ---> PASV
 ^C
 421 Service not available, user interrupt. Connection closed.



 ------- =_aaaaaaaaaa0
 Content-Type: text/plain; charset="us-ascii"
 Content-ID: <[email protected]>
 Content-Transfer-Encoding: 7bit

 ftp> ftp ftp.netscape.com
 Trying 207.200.85.30...
 Connected to hvftp-mv.netscape.com.
 220 ftp106 SGI 1.5: FTP server (Version wu-2.4.2-academ[BETA-17](2) Wed Jul 19 13:06:02 PDT 2000) ready.
 ftp_login: user `<null>' pass `<null>' host `ftp.netscape.com'
 Name (ftp.netscape.com:itojun): ftp
 ---> USER ftp
 331 Guest login ok, send your complete e-mail address as password.
 Password:
 ---> PASS XXXX
 230-Welcome to the Netscape Communications Corporation FTP server.
 230-
 230-If you have any odd problems, try logging in with a minus sign (-)
 230-as the first character of your password.  This will turn off a feature 
 230-that may be confusing your ftp client program.
 230-
 230-Please send any questions, comments, or problem reports about 
 230-this server to [email protected].
 230-
 230-***********  October 13, 1995  **********
 230-Private ftp is now only on ftp1.netscape.com.  Anonymous is supported on
 230-ftp 2 through 8.  If you are accessing a named account please use ftp1.
 230-
 230 Guest login ok, access restrictions apply.
 ---> SYST
 215 UNIX Type: L8
 Remote system type is UNIX.
 Using binary mode to transfer files.
 ---> PWD
 257 "/" is current directory.
 got remotepwd as `/'
 ftp> dir
 ---> PASV
 227 Entering Passive Mode (207,200,85,30,27,177)
 ---> LIST
 150 Opening ASCII mode data connection for /bin/ls.
 total 8
 drwxr-xr-x    7 root     sys           71 Aug  8 01:58 .
 drwxr-xr-x    7 root     sys           71 Aug  8 01:58 ..
 d--x--x--x    2 root     other         20 Mar 18  1999 bin
 dr-xr-xr-x    2 root     other         22 Oct 19  1998 dev
 d--x--x--x    2 root     other         78 Feb  3  1999 etc
 dr-xr-xr-x    2 root     other         98 Nov  5  1998 lib32
 drwxr-xr-x   26 888      sys         4096 Jun 13 09:42 pub
 226 Transfer complete.
 ftp> close
 ---> QUIT
 221 Goodbye.

 ------- =_aaaaaaaaaa0--

From: Jim Bernard <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: Re: bin/10897: ftp doesn't play nice with some servers
Date: Sat, 26 Aug 2000 19:59:08 -0600

 On Sat, Aug 26, 2000 at 11:58:16PM +0900, [email protected] wrote:
 > >    this seems to be problem on ftp.netscape.com.  I happened to be
 > >    connected to this guy,

   I tried using ftp to ftp.netscape.com from a Linux system with no problems.
 (I didn't pay attention to exactly which server I got, but every time I tried
 using the NetBSD ftp client in the default configuration, I couldn't get a
 directory listing.)

   Here's another server where the default behavior of the ftp client prevents
 listing a directory:

   ftp.igd.fhg.de

From: [email protected]
To: Jim Bernard <[email protected]>
Cc: [email protected]
Subject: Re: bin/10897: ftp doesn't play nice with some servers
Date: Sun, 27 Aug 2000 11:28:01 +0900

 ------- =_aaaaaaaaaa0
 Content-Type: text/plain; charset="us-ascii"
 Content-ID: <[email protected]>
 Content-Transfer-Encoding: 7bit

 >> >   this seems to be problem on ftp.netscape.com.  I happened to be
 >> >   connected to this guy,
 >  I tried using ftp to ftp.netscape.com from a Linux system with no problems.
 >(I didn't pay attention to exactly which server I got, but every time I tried
 >using the NetBSD ftp client in the default configuration, I couldn't get a
 >directory listing.)

    could you please do the following:
    - use the one I contacted and choked (with IPv4 numeric address),
      as there are several instances of ftp.netscape.com.  to get
      repeatable behavior, we need to use the exact one.
    - please try to enable "debug" and/or "verbose" option, and send me
      the exact transaction.  "linux system with no problem" gives no
      information about what kind of transaction was used.

 >  Here's another server where the default behavior of the ftp client prevents
 >listing a directory:
 >  ftp.igd.fhg.de

    the server (192.44.32.10) chokes with PASV, just like one of
    ftp.netscape.com.  the issue is unrelated to the use of EPSV.
    I have tested with the following:
    - NetBSD 1.4.2 ftp client (never issues EPSV)
        PASV chokes, PORT is okay
    - NetBSD 1.5_ALPHA2 ftp client (issues EPSV)
        EPSV unsupported, PASV chokes, PORT is okay
    - FreeBSD 2.2.8 ftp client (never issues EPSV)
        PASV chokes, PORT is okay
    NetBSD 1.4.2/1.5 client works better than FreeBSD 2.2.8, as
    it implements fallback case from PASV to PORT.

 itojun


 ------- =_aaaaaaaaaa0
 Content-Type: text/plain; charset="us-ascii"
 Content-ID: <[email protected]>
 Content-Transfer-Encoding: 7bit

 (NetBSD 1.4.2)

 itojun[lychee:~/work/isakmpd/isakmpd] /usr/bin/ftp 192.44.32.10
 Connected to 192.44.32.10.
 220 ProFTPD 1.2.0pre10 Server (ProFTPD Anonymous Server) [nikolausharnoncourt]
 Name (192.44.32.10:itojun): ftp
 331 Anonymous login ok, send your complete e-mail address as password.
 Password:
 230 Anonymous access granted, restrictions apply.
 Remote system type is UNIX.
 Using binary mode to transfer files.
 ftp> passive
 Passive mode off.
 ftp> debug
 Debugging on (debug=1).
 ftp> dir
 ---> PORT 210,160,95,106,254,53
 200 PORT command successful.
 ---> LIST
 150 Opening ASCII mode data connection for file list.
 lrwxrwxrwx   1 root     sys             7 Dec  2  1997 bin -> usr/bin
 dr-xr-xr-x   2 root     sys           512 Dec  2  1997 dev
 dr-xr-xr-x   3 root     sys           512 Dec  8  1997 etc
 drwxrwxrwx  19 root     sys          1024 Aug 27 03:15 incoming
 -rw-r--r--   1 root     sys         91517 Aug 27 03:30 ls-lR.gz
 drwxrwxrwx 113 root     sys          3584 Aug 24 16:00 outgoing
 drwxrwxr-x  10 root     290           512 Jan 18  1999 pub
 dr-xr-xr-x   5 root     sys           512 Dec  2  1997 usr
 226 Transfer complete.
 ftp> passive
 Passive mode on.
 ftp> dir
 ---> PASV
 227 Entering Passive Mode (192,44,32,10,234,43).
 ---> PORT 210,160,95,106,254,51                <--- fallback to PORT
 200 PORT command successful.
 ---> LIST
 150 Opening ASCII mode data connection for file list.
 lrwxrwxrwx   1 root     sys             7 Dec  2  1997 bin -> usr/bin
 dr-xr-xr-x   2 root     sys           512 Dec  2  1997 dev
 dr-xr-xr-x   3 root     sys           512 Dec  8  1997 etc
 drwxrwxrwx  19 root     sys          1024 Aug 27 03:15 incoming
 -rw-r--r--   1 root     sys         91517 Aug 27 03:30 ls-lR.gz
 drwxrwxrwx 113 root     sys          3584 Aug 24 16:00 outgoing
 drwxrwxr-x  10 root     290           512 Jan 18  1999 pub
 dr-xr-xr-x   5 root     sys           512 Dec  2  1997 usr
 226 Transfer complete.

 ------- =_aaaaaaaaaa0
 Content-Type: text/plain; charset="us-ascii"
 Content-ID: <[email protected]>
 Content-Transfer-Encoding: 7bit

 (NetBSD 1.5_ALPHA2)

 itojun[mango:/home/itojun] itojun[mango:~] ftp 192.44.32.10
 Connected to 192.44.32.10.
 220 ProFTPD 1.2.0pre10 Server (ProFTPD Anonymous Server) [nikolausharnoncourt]
 Name (192.44.32.10:itojun): ftp
 331 Anonymous login ok, send your complete e-mail address as password.
 Password:
 230 Anonymous access granted, restrictions apply.
 Remote system type is UNIX.
 Using binary mode to transfer files.
 ftp> debug
 Debugging on (debug=1).
 ftp> dir
 ---> EPSV
 500 EPSV not understood.
 disabling epsv4 for this connection
 ---> PASV
 227 Entering Passive Mode (192,44,32,10,234,47).
 ---> PORT 210,160,95,104,255,252           <--- fallback to PORT
 200 PORT command successful.
 ---> LIST
 150 Opening ASCII mode data connection for file list.
 lrwxrwxrwx   1 root     sys             7 Dec  2  1997 bin -> usr/bin
 dr-xr-xr-x   2 root     sys           512 Dec  2  1997 dev
 dr-xr-xr-x   3 root     sys           512 Dec  8  1997 etc
 drwxrwxrwx  19 root     sys          1024 Aug 27 03:15 incoming
 -rw-r--r--   1 root     sys         91517 Aug 27 03:30 ls-lR.gz
 drwxrwxrwx 113 root     sys          3584 Aug 24 16:00 outgoing
 drwxrwxr-x  10 root     290           512 Jan 18  1999 pub
 dr-xr-xr-x   5 root     sys           512 Dec  2  1997 usr
 226 Transfer complete.


 ------- =_aaaaaaaaaa0--

From: Jim Bernard <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: Re: bin/10897: ftp doesn't play nice with some servers
Date: Sat, 26 Aug 2000 21:32:20 -0600

 On Sun, Aug 27, 2000 at 11:28:01AM +0900, [email protected] wrote:
 >  could you please do the following:
 >  - use the one I contacted and choked (with IPv4 numeric address),
 >    as there are several instances of ftp.netscape.com.  to get
 >    repeatable behavior, we need to use the exact one.

   Yes.  NetBSD's ftp client chokes (without -A).  Linux's doesn't.  Nor AIX's.

 >  - please try to enable "debug" and/or "verbose" option, and send me
 >    the exact transaction.  "linux system with no problem" gives no
 >    information about what kind of transaction was used.

   OK, on Linux (Red Hat 6.2):

     ftp -i 205.188.247.193
     ...
     ftp> debug
     Debugging on (debug=1).
     ftp> dir
     ftp: setsockopt (ignored): Permission denied
     ---> PORT xx,xx,xx,xx,9,145
     200 PORT command successful.
     ---> LIST
     150 Opening ASCII mode data connection for /bin/ls.
     ...
     226 Transfer complete.

   AIX behaves similarly (just goes right to PORT, and works fine).

   NetBSD (1.5E) looks like:

     ftp -i 205.188.247.193
     ...
     ftp> debug
     Debugging on (debug=1).
     ftp> dir
     ---> EPSV
     500 'EPSV': command not understood.
     disabling epsv4 for this connection
     ---> PASV
     at which point it just hangs until timing out.

 >  the server (192.44.32.10) chokes with PASV, just like one of
 >  ftp.netscape.com.  the issue is unrelated to the use of EPSV.

   Evidently that is correct, though with debugging off (the default),
 the only message given refers to EPSV.

 >  I have tested with the following:
 >  - NetBSD 1.4.2 ftp client (never issues EPSV)
 >      PASV chokes, PORT is okay
 >  - NetBSD 1.5_ALPHA2 ftp client (issues EPSV)
 >      EPSV unsupported, PASV chokes, PORT is okay
 >  - FreeBSD 2.2.8 ftp client (never issues EPSV)
 >      PASV chokes, PORT is okay
 >  NetBSD 1.4.2/1.5 client works better than FreeBSD 2.2.8, as
 >  it implements fallback case from PASV to PORT.

   The NetBSD (1.5E as of Aug. 12) client does _not_ fall back from PASV to PORT
 with either 205.188.247.193 (ftp.netscape.com) or 192.44.32.10 (ftp.igd.fhg.de).

 --Jim

From: [email protected]
To: Jim Bernard <[email protected]>
Cc: [email protected]
Subject: Re: bin/10897: ftp doesn't play nice with some servers
Date: Sun, 27 Aug 2000 13:00:09 +0900

 >>     I have tested with the following:
 >>     - NetBSD 1.4.2 ftp client (never issues EPSV)
 >>         PASV chokes, PORT is okay
 >>     - NetBSD 1.5_ALPHA2 ftp client (issues EPSV)
 >>         EPSV unsupported, PASV chokes, PORT is okay
 >>     - FreeBSD 2.2.8 ftp client (never issues EPSV)
 >>         PASV chokes, PORT is okay
 >>     NetBSD 1.4.2/1.5 client works better than FreeBSD 2.2.8, as
 >>     it implements fallback case from PASV to PORT.
 >  The NetBSD (1.5E as of Aug. 12) client does _not_ fall back from PASV to PORT
 >with either 205.188.247.193 (ftp.netscape.com) or 192.44.32.10 (ftp.igd.fhg.de).

    try waiting a little bit longer.

 itojun

From: [email protected]
To: Jim Bernard <[email protected]>, [email protected]
Cc:  
Subject: Re: bin/10897: ftp doesn't play nice with some servers
Date: Sun, 27 Aug 2000 17:49:42 +0900

 >>  The NetBSD (1.5E as of Aug. 12) client does _not_ fall back from PASV to PORT
 >>with either 205.188.247.193 (ftp.netscape.com) or 192.44.32.10 (ftp.igd.fhg.de).
 >  try waiting a little bit longer.

    "little bit longer" means 1 minute or more.  for me it successfully
    fall back to PORT.  I admit this is rather slow, but as the peer has
    broken PASV support, it is the best client can do (if we switch to
    PORT too early, we will see wrong behavior).

 itojun


 itojun[turmeric:~/NetBSD.clean/pkgsrc/net/zebra] ftp 192.44.32.10
 Connected to 192.44.32.10.
 220 ProFTPD 1.2.0pre10 Server (ProFTPD Anonymous Server) [nikolausharnoncourt]
 Name (192.44.32.10:itojun): ftp
 331 Anonymous login ok, send your complete e-mail address as password.
 Password:
 230 Anonymous access granted, restrictions apply.
 Remote system type is UNIX.
 Using binary mode to transfer files.
 debugftp> debug
 Debugging on (debug=1).
 ftp> dir
 ---> EPSV
 500 EPSV not understood.
 disabling epsv4 for this connection
 ---> PASV
 227 Entering Passive Mode (192,44,32,10,234,127).
 ---> PORT 210,160,95,98,255,227            <--- wait 1 minute or more
 200 PORT command successful.
 ---> LIST
 150 Opening ASCII mode data connection for file list.
 lrwxrwxrwx   1 root     sys             7 Dec  2  1997 bin -> usr/bin
 dr-xr-xr-x   2 root     sys           512 Dec  2  1997 dev
 dr-xr-xr-x   3 root     sys           512 Dec  8  1997 etc
 drwxrwxrwx  19 root     sys          1024 Aug 27 03:15 incoming
 -rw-r--r--   1 root     sys         91517 Aug 27 03:30 ls-lR.gz
 drwxrwxrwx 113 root     sys          3584 Aug 24 16:00 outgoing
 drwxrwxr-x  10 root     290           512 Jan 18  1999 pub
 dr-xr-xr-x   5 root     sys           512 Dec  2  1997 usr
 226 Transfer complete.
 ftp> status
 Connected and logged into 192.44.32.10.
 No proxy connection.
 Gate ftp: off, server (none), port ftpgate.
 Passive mode: off; fallback to active mode: on.
 Mode: stream; Type: binary; Form: non-print; Structure: file.
 Verbose: on; Bell: off; Prompting: on; Globbing: on.
 Store unique: off; Receive unique: off.
 Preserve modification times: on.
 Case: off; CR stripping: on.
 Ntrans: off.
 Nmap: off.
 Hash mark printing: off; Mark count: 1024; Progress bar: on.
 Get transfer rate throttle: off; maximum: 0; increment 1024.
 Put transfer rate throttle: off; maximum: 0; increment 1024.
 Socket buffer sizes: send 16384, receive 16384.
 Use of PORT cmds: on.
 Use of EPSV/EPRT cmds for IPv4: on (disabled for this connection).
 Command line editing: on.
 Version: NetBSD-ftp 20000806
 ftp> ^D
 ---> QUIT
 un221 Goodbye.
 itojun[turmeric:~/NetBSD.clean/pkgsrc/net/zebra] uname -a
 NetBSD turmeric.itojun.org 1.5E NetBSD 1.5E (TURMERIC.v6) #5: Mon Aug 21 17:51:07 PDT 2000     [email protected]:/usr/home/itojun/NetBSD/src/sys/arch/i386/compile/TURMERIC.v6 i386


From: Jim Bernard <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: Re: bin/10897: ftp doesn't play nice with some servers
Date: Sun, 27 Aug 2000 06:52:16 -0600

 On Sun, Aug 27, 2000 at 01:00:09PM +0900, [email protected] wrote:
 > 
 > >>   I have tested with the following:
 > >>   - NetBSD 1.4.2 ftp client (never issues EPSV)
 > >>       PASV chokes, PORT is okay
 > >>   - NetBSD 1.5_ALPHA2 ftp client (issues EPSV)
 > >>       EPSV unsupported, PASV chokes, PORT is okay
 > >>   - FreeBSD 2.2.8 ftp client (never issues EPSV)
 > >>       PASV chokes, PORT is okay
 > >>   NetBSD 1.4.2/1.5 client works better than FreeBSD 2.2.8, as
 > >>   it implements fallback case from PASV to PORT.
 > >  The NetBSD (1.5E as of Aug. 12) client does _not_ fall back from PASV to PORT
 > >with either 205.188.247.193 (ftp.netscape.com) or 192.44.32.10 (ftp.igd.fhg.de).
 > 
 >  try waiting a little bit longer.

   It always times out and disconnects on me if I wait long enough on the
 netscape site; I haven't waited that long at ftp.igd.fhg.de.

From: Jim Bernard <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: Re: bin/10897: ftp doesn't play nice with some servers
Date: Sun, 27 Aug 2000 07:31:05 -0600

 On Sun, Aug 27, 2000 at 05:49:42PM +0900, [email protected] wrote:
 > 
 > >>  The NetBSD (1.5E as of Aug. 12) client does _not_ fall back from PASV to PORT
 > >>with either 205.188.247.193 (ftp.netscape.com) or 192.44.32.10 (ftp.igd.fhg.de).
 > >    try waiting a little bit longer.
 > 
 >  "little bit longer" means 1 minute or more.  for me it successfully
 >  fall back to PORT.  I admit this is rather slow, but as the peer has
 >  broken PASV support, it is the best client can do (if we switch to
 >  PORT too early, we will see wrong behavior).
 > 
 > itojun

   Try it at the netscape site.  It always times out and disconnects on me.

   BTW: What do you mean by "if we switch to PORT too early, we will see
 wrong behavior".  Clearly, other clients (and NetBSD's with -A) just do
 PORT right away without any problem.  Or are you just saying that if the
 server really is going to respond to PASV and the client switches before
 the response, the connection will be messed up?

 > itojun[turmeric:~/NetBSD.clean/pkgsrc/net/zebra] ftp 192.44.32.10
 ...
 > ftp> dir
 > ---> EPSV
 > 500 EPSV not understood.
 > disabling epsv4 for this connection
 > ---> PASV
 > 227 Entering Passive Mode (192,44,32,10,234,127).
 > ---> PORT 210,160,95,98,255,227          <--- wait 1 minute or more

   It it NOT OK to have to wait this long for every data-returning command!

   In any case, a very important point is that users presented with an ftp client
 they have to wait on for a full minute or more to execute each data-returning
 command (_if_ it doesn't just disconnect), when the clients on other systems
 "just work", and do so promptly, are not going to conclude that the fault
 lies with the remote server.  The conclusion will inevitably be that NetBSD's
 ftp client is broken.  The fact that it may be more featureful and powerful
 in dealing with certain "problem" network setups won't matter one bit to the
 user faced with such difficulties in the simplest situations.

   It looks to me like it is just too soon to be _defaulting_ to the
 EPSV->PASV->PORT fallback scheme (unless there is a way to make it work
 better), given that there clearly are plenty of servers out there that don't
 work properly with it.  The fact that I came across two in a single day is
 sufficient to demonstrate that this is a serious problem.

 --Jim

From: [email protected]
To: Jim Bernard <[email protected]>
Cc: [email protected]
Subject: Re: bin/10897: ftp doesn't play nice with some servers
Date: Mon, 28 Aug 2000 01:22:49 +0900

 >  Try it at the netscape site.  It always times out and disconnects on me.
 >
 >  BTW: What do you mean by "if we switch to PORT too early, we will see
 >wrong behavior".  Clearly, other clients (and NetBSD's with -A) just do
 >PORT right away without any problem.  Or are you just saying that if the
 >server really is going to respond to PASV and the client switches before
 >the response, the connection will be messed up?

    the latter.

 >  It it NOT OK to have to wait this long for every data-returning command!
 >
 >  In any case, a very important point is that users presented with an ftp client
 >they have to wait on for a full minute or more to execute each data-returning
 >command (_if_ it doesn't just disconnect), when the clients on other systems
 >"just work", and do so promptly, are not going to conclude that the fault
 >lies with the remote server.  The conclusion will inevitably be that NetBSD's
 >ftp client is broken.  The fact that it may be more featureful and powerful
 >in dealing with certain "problem" network setups won't matter one bit to the
 >user faced with such difficulties in the simplest situations.
 >
 >  It looks to me like it is just too soon to be _defaulting_ to the
 >EPSV->PASV->PORT fallback scheme (unless there is a way to make it work
 >better), given that there clearly are plenty of servers out there that don't
 >work properly with it.  The fact that I came across two in a single day is
 >sufficient to demonstrate that this is a serious problem.

    the behavior change (PORT -> PASV to PASV -> PORT) was made because,
    it is increasingly becoming common to have NAT/firewall devices
    that does not work with PORT, and work with PASV only.  it is
    increasingly becoming common to try PASV first.  try ftp client on
    OpenBSD and recent FreeBSD.  they both start with PASV and has the
    same problem.

    with broken (i'd say so) firewall device PORT does not work.
    with broken server like ftp.netscape.com PASV does not work.  it is
    the question of which one we should try first.  regardless from which
    one we pick, we get problem report from the other party!

    BTW, i am not the guy who made the change.  i just wanted to clarify
    which part of ftp behavior was the source of your problem, since
    the original report was not clear enough (and i think it was clarified
    enough for me).  i should stop here.

 itojun

From: Jim Bernard <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: Re: bin/10897: ftp doesn't play nice with some servers
Date: Sun, 27 Aug 2000 11:15:12 -0600

 On Mon, Aug 28, 2000 at 01:22:49AM +0900, [email protected] wrote:
 > >  It looks to me like it is just too soon to be _defaulting_ to the
 > >EPSV->PASV->PORT fallback scheme (unless there is a way to make it work
 > >better), given that there clearly are plenty of servers out there that don't
 > >work properly with it.  The fact that I came across two in a single day is
 > >sufficient to demonstrate that this is a serious problem.
 > 
 >  the behavior change (PORT -> PASV to PASV -> PORT) was made because,
 >  it is increasingly becoming common to have NAT/firewall devices
 >  that does not work with PORT, and work with PASV only.  it is
 >  increasingly becoming common to try PASV first.  try ftp client on
 >  OpenBSD and recent FreeBSD.  they both start with PASV and has the
 >  same problem.
 > 
 >  with broken (i'd say so) firewall device PORT does not work.
 >  with broken server like ftp.netscape.com PASV does not work.  it is
 >  the question of which one we should try first.  regardless from which
 >  one we pick, we get problem report from the other party!

   Yes, I understand.  The important things to think about are:

     (1) Is there a way to improve robustness with _some_ chosen fallback
    sequence so that nobody has to tolerate this kind of breakage?

     (2) If the answer to (1) is "no", is the current sequence the best
    choice given the current mix of broken servers and firewall
    configurations.  I'm guessing that it is not; certainly it's not
    best for me, nor for the people around me.  It is perhaps worth
    keeping in mind that users might have some influence over the local
    firewall configuration (even if they don't have direct control over
    it), but they have little influence over the behavior of remote
    ftp servers.

     (3) If there is not a "good enough" solution, perhaps there should be some
    simple way to tailor the default behavior for the local installation
    (other than telling every user to always use -A or -p).  Perhaps
    a system-wide configuration file would be appropriate.

 >  BTW, i am not the guy who made the change.

   Yes, I know.  But I thought, from your interest, that maybe you were going
 to tackle the problem (or, I feared, dismiss it) anyway.

 >  i just wanted to clarify
 >  which part of ftp behavior was the source of your problem, since
 >  the original report was not clear enough (and i think it was clarified
 >  enough for me).  i should stop here.

   OK.  Thanks for the discussion and for pointing out that PASV was the
 real problem.  (I guess the PR has gotten rather long by now!)

 --Jim

From: [email protected]
To: Jim Bernard <[email protected]>
Cc: [email protected]
Subject: Re: bin/10897: ftp doesn't play nice with some servers
Date: Mon, 28 Aug 2000 02:38:28 +0900

 >    (3) If there is not a "good enough" solution, perhaps there should be some
 >  simple way to tailor the default behavior for the local installation
 >  (other than telling every user to always use -A or -p).  Perhaps
 >  a system-wide configuration file would be appropriate.

    how about $FTPMODE?

 itojun

From: Jim Bernard <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: Re: bin/10897: ftp doesn't play nice with some servers
Date: Sun, 27 Aug 2000 12:11:20 -0600

 On Mon, Aug 28, 2000 at 02:38:28AM +0900, [email protected] wrote:
 > >    (3) If there is not a "good enough" solution, perhaps there should be some
 > >    simple way to tailor the default behavior for the local installation
 > >    (other than telling every user to always use -A or -p).  Perhaps
 > >    a system-wide configuration file would be appropriate.
 > 
 >  how about $FTPMODE?

   Sure, that's better than -A/-p, but it still requires action on the part
 of every user (or a system administrator to impose environment variables on
 users, which is something I tend to dislike generally, since I often disagree
 with the choices made by other folks).  Since, every user on a particular
 machine sees the same local network environment, it seems to me that a
 configuration file is reasonable, though it does add a small startup penalty
 and adds to the noise in /etc.

   A configuration file also has the advantage that, if a default version is
 provided in the distribution, it will alert the system administrator to the
 issue, whereas depending on users to read the man page instead of giving up
 in frustration (or switching to Linux) will result in the feature not being
 discovered in many cases.  It also makes it easy to change the behavior in
 the event that a change in the local firewall configuration warrants it.
 It would also make it possible (in principle) to configure different defaults
 on different interfaces.

 --Jim
Responsible-Changed-From-To: bin-bug-people->lukem 
Responsible-Changed-By: lukem 
Responsible-Changed-When: Mon Aug 28 04:53:47 PDT 2000 
Responsible-Changed-Why:  
i'm mr ftp 
Responsible-Changed-From-To: lukem->bin-bug-people
Responsible-Changed-By: [email protected]
Responsible-Changed-When: Sat, 16 Jun 2012 07:19:24 +0000
Responsible-Changed-Why:
12 years later, I'm not going to change the behaviour



union mounts panic when unmounting, panic when done twice

Metadata

  • Number: 2423
  • Originator: Andrew Wheadon <[email protected]>
  • Arrived: Thu May 16 12:50:03 +0000 1996
  • Last modified: Mon Jun 05 22:28:14 +0000 2000
  • Environment: System: NetBSD wipux2 1.1B NetBSD 1.1B (WIPOOL) #0: Thu May 16 14:57:24 MET DST 1996 toor@wipux2:/src/src/sys/arch/i386/compile/WIPOOL i386

Description


three bugs: 1) panics when unmounting, 2) allows double-mounting,
        which is followed by panic on access, 3) no dependencies
        explained when compiling kernel.
one nicety: 4) union-mounts are not nfs-exportable

1)
    Union mounts panic when trying to unmount them:
mount -t union -o -b /src2/boot/wippc00 /src2/boot/wippc51
ls /src2/boot/wippc51
umount /src2/boot/wippc51
    vgone
    vflush
    union_unmount
    dounmount
    sys_unmount
    syscall (22)

2)
    Union mounts are easily mounted twice over each other:

mount /src2/boot/wippc53
mount /src2/boot/wippc53
(this is the output of 'mount')
...
/dev/sd1g on /src2 type ffs (NFS exported, local)
:/src2/boot/wippc00 on /src2/boot/wippc51 type union
:/src2/boot/wippc00 on /src2/boot/wippc53 type union
:/src2/boot/wippc00 on /src2/boot/wippc55 type union
:/src2/boot/wippc00 on /src2/boot/wippc53 type union


    and when you then try to ls /src2/boot/wippc53 it (naturally)
    panics:
    panic locking against myself
    ufs_lock
    union_dir_cache
    sys_getdirentries
    syscall (196)
    (I have the (11mb compressed) core-dump for this one)

3)
    When compiling the Kernel and setting 'option UNION', unions
    will still fail to mount. At least one of the following additional
    options are needed to compile a kernel that supports UNION
    NULLFS,UMAPFS (probably NULLFS) but dependency is not defined
    in files*.

4)
<root@wipux2:/src2/boot> mount -v -t nfs wipux2:/src2/boot /mnt
wipux2:/src2/boot on /mnt type nfs
<root@wipux2:/src2/boot> ls /mnt/wippc53
.s      dev/    home/   root/   src2/   usr/
bin/    etc/    mnt/    sbin/   tmp/    var/
<root@wipux2:/src2/boot> mount
...
:/src2/boot/wippc00 on /src2/boot/wippc53 type union
wipux2:/src2/boot on /mnt type nfs
...
<root@wipux2:/src2/boot> umount /mnt
<root@wipux2:/src2/boot> mount -v -t nfs wipux2:/src2/boot/wippc53 /mnt
nfs: can't access /src2/boot/wippc53: Permission denied
<root@wipux2:/src2/boot> umount /mnt

As you can tell mounting /src2/boot lets me see the file but
ignores the union, and just shows me truely local files. (ie. the kernel
file on wippc00/netbsd is not listed etc.)
Trying to mount the union-directory fails completely.


How to repeat


    see above.

Fix


    1)  ??? 
    2)  Do NOT permit mounting same stuff in same place twice.
    3)  somehow add dependencies for config.
    4)  ???

printf/scanf don't support X/Open positional parameters

Metadata

  • Number: 1862
  • Originator: J.T. Conklin <["J.T. Conklin" ](mailto:"J.T. Conklin" <jtc)>
  • Arrived: Wed Dec 27 19:35:23 +0000 1995
  • Last modified: Thu Jul 28 19:29:44 +0000 2011
  • Environment: System: NetBSD pain.lcs.mit.edu 1.0A NetBSD 1.0A (PAIN) #0: Sat Oct 7 08:07:40 EDT 1995 [email protected]:/a/users/mycroft/sys/arch/i386/compile/PAIN i386

Description


Printf and scanf do not support the X/Open positional parameters.  This
makes message catalogs much less useful than they could be.


How to repeat


Use code that uses this feature.


Fix


Add support to printf/scanf in a efficent manner.


Audit trail



Responsible-Changed-From-To: lib-bug-people->jtc
Responsible-Changed-By: jtc
Responsible-Changed-When: Thu Dec 28 14:10:57 1995
Responsible-Changed-Why:

Responsible-Changed-From-To: jtc->lib-bug-people 
Responsible-Changed-By: fair 
Responsible-Changed-When: Thu Jun 17 14:37:47 PDT 1999 
Responsible-Changed-Why:  
jtc's attentions are elsewhere - someone else should pick this up. 
(if I read this right, it's an i18n problem) 
Responsible-Changed-From-To: lib-bug-people->kleink 
Responsible-Changed-By: lukem 
Responsible-Changed-When: Wed Apr 18 05:03:00 PDT 2001 
Responsible-Changed-Why:  
klaus is our standards guru; what are his thoughts? 

From: Klaus Klein <[email protected]>
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: lib/1862
Date: 18 Apr 2001 14:36:34 +0200

 These are indeed extensions defined in XPG4; Erik's comment about i18n
 is likely to have been guided by that these positional parameters can
 be handy when doing i18n work. They're one of the reasons why I added
 va_copy.

 I can look after this after the specified-width integer rototill,
 which affects printf/scanf as well.


 - Klaus

From: David Laight <[email protected]>
To: [email protected]
Subject: re: lib/1862: printf/scanf don't support X/Open positional parameters
Date: Mon, 1 Sep 2003 15:50:02 +0100

 I've just sat down and implemented this for printf.

 However there are definite security problems lurking for scanf and
 even parts of printf.

 Consider the following eror message:

    printf("value %d unexpected\n", n);

 Now if I have control over the format string and the value of 'n' I can
 write a small integer to any location in the program by making 'n' its
 address and the format "xxxx%n".

 Without control of the data "xxxx%<argnum>$n..." could be arranged to
 overwrite via ANY pointer on the callers stack.

 Similarly use of %<argnum>$ in a scanf format string could overwrite
 the value read using any on-stack pointer.

 These overwrites can all be done with standard format strings, but the
 %n$ variants make it so much easier!

 Anyway the patch is below.
 It allows upto 1024 arguments, but TOG say that NL_ARGMAX need only be 9.
 Assuming a single digit would simplify some of the code, and a small number
 does reduce the opportunity for locating a useful on-stack pointer.

    David

 Index: vfprintf.c
 ===================================================================
 RCS file: /cvsroot/src/lib/libc/stdio/vfprintf.c,v
 retrieving revision 1.45
 diff -u -p -r1.45 vfprintf.c
 --- vfprintf.c 2003/08/07 16:43:34 1.45
 +++ vfprintf.c 2003/09/01 14:43:02
 @@ -65,9 +65,20 @@ __RCSID("$NetBSD: vfprintf.c,v 1.45 2003
  #include "fvwrite.h"
  #include "extern.h"

 +#ifdef FLOATING_POINT
 +#define POSITIONAL_PARAMS
 +#endif
 +
  static int __sprint __P((FILE *, struct __suio *));
  static int __sbprintf __P((FILE *, const char *, va_list)) 
       __attribute__((__format__(__printf__, 2, 0)));
 +#ifdef POSITIONAL_PARAMS
 +static void *set_printf_args(const char *, _BSD_VA_LIST_);
 +static uintmax_t get_arg_int(void *, int);
 +static double get_arg_double(void *, int);
 +static void *get_arg_ptr(void *, int);
 +static void free_parg(void *);
 +#endif

  /*
   * Flush out all the vectors defined by the given uio,
 @@ -187,6 +198,11 @@ __UNCONST(v)
  #define   SIZEINT     0x200       /* (signed) size_t */
  #define   ZEROPAD     0x400       /* zero (as opposed to blank) pad */
  #define FPT       0x800       /* Floating point number */
 +#ifdef POSITIONAL_PARAMS
 +#define POINTER       0x10000     /* Pointer to something */
 +#define SIGNED        0x20000     /* signed value */
 +#define CHARINT       0x40000     /* move above when %hhd implemented */
 +#endif

  int
  vfprintf(fp, fmt0, ap)
 @@ -264,11 +280,16 @@ vfprintf_unlocked(fp, fmt0, ap)
     {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '};
    static const char zeroes[PADSIZE] =
     {'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'};
 +#ifdef POSITIONAL_PARAMS  /* %nnn$... */
 +  void *parg = NULL;
 +  int argnum = 0;
 +  char *ncp;
 +#endif

    /*
     * BEWARE, these `goto error' on error, and PAD uses `n'.
     */
 -#define   PRINT(ptr, len) { \
 +#define   PRINT(ptr, len) do { \
    iovp->iov_base = __UNCONST(ptr); \
    iovp->iov_len = (len); \
    uio.uio_resid += (len); \
 @@ -278,8 +299,9 @@ vfprintf_unlocked(fp, fmt0, ap)
            goto error; \
        iovp = iov; \
    } \
 -}
 -#define   PAD(howmany, with) { \
 +} while (/*CONSTCOND*/0)
 +
 +#define   PAD(howmany, with) do { \
    if ((n = (howmany)) > 0) { \
        while (n > PADSIZE) { \
            PRINT(with, PADSIZE); \
 @@ -287,19 +309,20 @@ vfprintf_unlocked(fp, fmt0, ap)
        } \
        PRINT(with, n); \
    } \
 -}
 -#define   FLUSH() { \
 +} while (/*CONSTCOND*/0)
 +
 +#define   FLUSH() do { \
    if (uio.uio_resid && __sprint(fp, &uio)) \
        goto error; \
    uio.uio_iovcnt = 0; \
    iovp = iov; \
 -}
 +} while (/*CONSTCOND*/0)

    /*
     * To extend shorts properly, we need both signed and unsigned
     * argument extraction methods.
     */
 -#define   SARG() \
 +#define   SARG(flags, ap) \
    (flags&MAXINT ? va_arg(ap, intmax_t) : \
        flags&PTRINT ? va_arg(ap, ptrdiff_t) : \
        flags&SIZEINT ? va_arg(ap, ssize_t) : /* XXX */ \
 @@ -307,7 +330,7 @@ vfprintf_unlocked(fp, fmt0, ap)
        flags&LONGINT ? va_arg(ap, long) : \
        flags&SHORTINT ? (long)(short)va_arg(ap, int) : \
        (long)va_arg(ap, int))
 -#define   UARG() \
 +#define   UARG(flags, ap) \
    (flags&MAXINT ? va_arg(ap, uintmax_t) : \
        flags&PTRINT ? va_arg(ap, uintptr_t) : /* XXX */ \
        flags&SIZEINT ? va_arg(ap, size_t) : \
 @@ -383,13 +406,24 @@ reswitch:    switch (ch) {
            flags |= ALT;
            goto rflag;
        case '*':
 +#ifdef POSITIONAL_PARAMS
 +          if (parg != NULL) {
 +              n = strtoul(fmt, &ncp, 10);
 +              fmt = ncp;
 +              ch = *fmt++;
 +              if (ch != '$')
 +                  goto reswitch;
 +              width = (int)get_arg_int(parg, n);
 +          } else
 +#endif
 +          width = va_arg(ap, int);
            /*
             * ``A negative field width argument is taken as a
             * - flag followed by a positive field width.''
             *  -- ANSI X3J11
             * They don't exclude field widths read from args.
             */
 -          if ((width = va_arg(ap, int)) >= 0)
 +          if (width >= 0)
                goto rflag;
            width = -width;
            /* FALLTHROUGH */
 @@ -401,6 +435,16 @@ reswitch: switch (ch) {
            goto rflag;
        case '.':
            if ((ch = *fmt++) == '*') {
 +#ifdef POSITIONAL_PARAMS
 +              if (parg != NULL) {
 +                  n = strtoul(fmt, &ncp, 10);
 +                  fmt = ncp;
 +                  ch = *fmt++;
 +                  if (ch != '$')
 +                      goto reswitch;
 +                  n = (int)get_arg_int(parg, n);
 +              } else
 +#endif
                n = va_arg(ap, int);
                prec = n < 0 ? -1 : n;
                goto rflag;
 @@ -427,6 +471,14 @@ reswitch: switch (ch) {
                n = 10 * n + to_digit(ch);
                ch = *fmt++;
            } while (is_digit(ch));
 +#ifdef POSITIONAL_PARAMS
 +          if (ch == '$') {
 +              if (parg == NULL)
 +                  parg = set_printf_args(fmt0, ap);
 +              argnum = n;
 +              goto rflag;
 +          }
 +#endif
            width = n;
            goto reswitch;
  #ifdef FLOATING_POINT
 @@ -458,6 +510,11 @@ reswitch: switch (ch) {
            flags |= SIZEINT;
            goto rflag;
        case 'c':
 +#ifdef POSITIONAL_PARAMS
 +          if (parg != NULL)
 +              *buf = (int)get_arg_int(parg, argnum);
 +          else
 +#endif
            *buf = va_arg(ap, int);
            cp = buf;
            size = 1;
 @@ -468,7 +525,12 @@ reswitch: switch (ch) {
            /*FALLTHROUGH*/
        case 'd':
        case 'i':
 -          _uintmax = SARG();
 +#ifdef POSITIONAL_PARAMS
 +          if (parg != NULL)
 +              _uintmax = get_arg_int(parg, argnum);
 +          else
 +#endif
 +          _uintmax = SARG(flags, ap);
            if ((intmax_t)_uintmax < 0) {
                _uintmax = -_uintmax;
                sign = '-';
 @@ -488,6 +550,11 @@ reswitch: switch (ch) {
                prec = 1;
            }

 +#ifdef POSITIONAL_PARAMS
 +          if (parg != NULL)
 +              _double = get_arg_double(parg, argnum);
 +          else
 +#endif
            if (flags & LONGDBL) {
                _double = (double) va_arg(ap, long double);
            } else {
 @@ -549,6 +616,15 @@ reswitch: switch (ch) {
            break;
  #endif /* FLOATING_POINT */
        case 'n':
 +#ifdef POSITIONAL_PARAMS
 +          if (parg != NULL)
 +              /*
 +               * This could be implemented, but it stinks
 +               * of a security risk.
 +               */
 +              PRINT("(%n unassigned)", 15);
 +          else
 +#endif
            if (flags & MAXINT)
                *va_arg(ap, intmax_t *) = ret;
            else if (flags & PTRINT)
 @@ -568,7 +644,12 @@ reswitch: switch (ch) {
            flags |= LONGINT;
            /*FALLTHROUGH*/
        case 'o':
 -          _uintmax = UARG();
 +#ifdef POSITIONAL_PARAMS
 +          if (parg != NULL)
 +              _uintmax = get_arg_int(parg, argnum);
 +          else
 +#endif
 +          _uintmax = UARG(flags, ap);
            base = OCT;
            goto nosign;
        case 'p':
 @@ -579,15 +660,26 @@ reswitch:    switch (ch) {
             * defined manner.''
             *  -- ANSI X3J11
             */
 +#ifdef POSITIONAL_PARAMS
 +          if (parg != NULL)
 +              _uintmax = (uintptr_t)get_arg_ptr(parg, argnum);
 +          else
 +#endif
            /* NOSTRICT */
 -          _uintmax = (u_long)va_arg(ap, void *);
 +          _uintmax = (uintptr_t)va_arg(ap, void *);
            base = HEX;
            xdigs = "0123456789abcdef";
            flags |= HEXPREFIX;
            ch = 'x';
            goto nosign;
        case 's':
 -          if ((cp = va_arg(ap, char *)) == NULL)
 +#ifdef POSITIONAL_PARAMS
 +          if (parg != NULL)
 +              cp = get_arg_ptr(parg, argnum);
 +          else
 +#endif
 +          cp = va_arg(ap, char *);
 +          if (cp == NULL)
                cp = "(null)";
            if (prec >= 0) {
                /*
 @@ -611,7 +703,12 @@ reswitch: switch (ch) {
            flags |= LONGINT;
            /*FALLTHROUGH*/
        case 'u':
 -          _uintmax = UARG();
 +#ifdef POSITIONAL_PARAMS
 +          if (parg != NULL)
 +              _uintmax = get_arg_int(parg, argnum);
 +          else
 +#endif
 +          _uintmax = UARG(flags, ap);
            base = DEC;
            goto nosign;
        case 'X':
 @@ -619,7 +716,13 @@ reswitch: switch (ch) {
            goto hex;
        case 'x':
            xdigs = "0123456789abcdef";
 -hex:          _uintmax = UARG();
 +hex:
 +#ifdef POSITIONAL_PARAMS
 +          if (parg != NULL)
 +              _uintmax = get_arg_int(parg, argnum);
 +          else
 +#endif
 +          _uintmax = UARG(flags, ap);
            base = HEX;
            /* leading 0x/X only if non-zero */
            if (flags & ALT && _uintmax != 0)
 @@ -797,6 +900,10 @@ done:
  error:
    if (__sferror(fp))
        ret = -1;
 +#ifdef POSITIONAL_PARAMS
 +  if (parg != NULL)
 +      free_parg(parg);
 +#endif
    return (ret);
  }

 @@ -883,3 +990,213 @@ exponent(p0, expon, fmtch)
    return (p - p0);
  }
  #endif /* FLOATING_POINT */
 +
 +#ifdef POSITIONAL_PARAMS
 +struct parg {
 +  int     flags;
 +  union   {
 +      uintmax_t   _uintmax;
 +      void        *_pointer;
 +      double      _double;
 +  } val;
 +};
 +
 +static void *parse_fmt(const char *);
 +
 +static uintmax_t
 +get_arg_int(void *parg, int argnum)
 +{
 +  struct parg *arg = parg;
 +
 +  if (argnum >= arg->flags)
 +      return 0;
 +  return arg[argnum].val._uintmax;
 +}
 +
 +static double
 +get_arg_double(void *parg, int argnum)
 +{
 +  struct parg *arg = parg;
 +
 +  if (argnum >= arg->flags)
 +      return 0;
 +  return arg[argnum].val._double;
 +}
 +
 +static void *
 +get_arg_ptr(void *parg, int argnum)
 +{
 +  struct parg *arg = parg;
 +
 +  if (argnum >= arg->flags)
 +      return 0;
 +  return arg[argnum].val._pointer;
 +}
 +
 +static void *
 +set_printf_args(const char *fmt, _BSD_VA_LIST_ ap)
 +{
 +  struct parg *arg;
 +  int flags;
 +  int i;
 +
 +  /*
 +   * In order to set ap so that the n'th argument can be picked next
 +   * we have to know the type of all the arguments.
 +   */
 +  arg = parse_fmt(fmt);
 +  if (arg == NULL)
 +      return NULL;
 +
 +  /* Now walk ap along the arguments saving the values */
 +  for (i = 1; i < arg[0].flags; i++) {
 +      flags = arg[i].flags;
 +      if (flags == 0)
 +          /* unsigned int or arg not used in format */
 +          arg[i].val._uintmax = va_arg(ap, int);
 +      else if (flags & POINTER)
 +          if (flags & CHARINT)
 +              arg[i].val._pointer = va_arg(ap, char *);
 +          else
 +              arg[i].val._pointer = va_arg(ap, void *);
 +      else if (flags & FPT)
 +          if (flags & LONGDBL)
 +              arg[i].val._double = va_arg(ap, long double);
 +          else
 +              arg[i].val._double = va_arg(ap, double);
 +      else if (flags & SIGNED)
 +          arg[i].val._uintmax = SARG(flags, ap);
 +      else
 +          arg[i].val._uintmax = UARG(flags, ap);
 +  }
 +  return arg;
 +}
 +
 +static void
 +free_parg(void *arg)
 +{
 +
 +  free(arg);
 +}
 +
 +static void
 +save_arg(struct parg **parg, int argnum, int flags)
 +{
 +  struct parg *arg = *parg, *narg;
 +  int newlim;
 +
 +  if (argnum <= 0 || argnum > 1024)   /* Should be {NL_ARGMAX} */
 +      return;
 +
 +  if (arg == NULL || argnum >= arg[0].flags) {
 +      newlim = argnum + 15;
 +      narg = realloc(arg, newlim * sizeof *arg);
 +      if (narg == NULL)
 +          return;
 +      memset(narg + narg[0].flags, 0,
 +          (newlim - narg[0].flags) * sizeof *arg);
 +      narg[0].flags = newlim;
 +      *parg = narg;
 +      arg = narg;
 +  }
 +  arg += argnum;
 +  arg->flags = flags;
 +}
 +
 +static void *
 +parse_fmt(const char *fmt)
 +{
 +  struct parg *arg = NULL;
 +  char *ncp;  /* avoid &fmt to kelp optimsation */
 +  int argnum;
 +  int flags;
 +  int n;
 +  char ch;
 +  wchar_t wc;
 +  mbstate_t ps;
 +
 +  mbrtowc(NULL, NULL, 0, &ps);
 +
 +  for (;;) {
 +      do {
 +          n = mbrtowc(&wc, fmt, MB_CUR_MAX, &ps);
 +          if (n <= 0)
 +              return arg;
 +          fmt += n;
 +      } while (wc != '%');
 +      flags = 0;
 +      argnum = 0;
 +      for (;;) {
 +          ch = *fmt++;
 +          switch (ch) {
 +          case ' ':   continue;
 +          case '#':   continue;
 +          case '-':   continue;
 +          case '+':   continue;
 +          case '*':   continue;
 +          case '0':   continue;
 +          case '.':   continue;
 +          case 'h':   flags |= SHORTINT;  continue;
 +          case 'j':   flags |= MAXINT;    continue;
 +#ifdef FLOATING_POINT
 +          case 'L':   flags |= LONGDBL;   continue;
 +#endif
 +          case 'q':   flags |= QUADINT;   continue;
 +          case 't':   flags |= PTRINT;    continue;
 +          case 'z':   flags |= SIZEINT;   continue;
 +          case 'l':
 +              if (fmt[0] == 'l') {
 +                  fmt++;
 +                  flags |= QUADINT;
 +              } else
 +                  flags |= LONGINT;
 +              continue;
 +          case '1': case '2': case '3': case '4':
 +          case '5': case '6': case '7': case '8': case '9':
 +              n = strtoul(fmt - 1, &ncp, 10);
 +              fmt = ncp;
 +              if (*fmt == '$') {
 +                  fmt++;
 +                  if (argnum == 0)
 +                      argnum = n;
 +                  else
 +                      save_arg(&arg, n, SIGNED);
 +              }
 +              continue;
 +          case 'D':
 +              flags |= LONGINT | SIGNED;
 +              break;
 +          case 'O': case 'U':
 +              flags |= LONGINT;
 +              break;
 +          case 'd': case 'i':
 +              flags |= SIGNED;
 +              break;
 +          case 'c': case 'o': case 'u': case 'X': case 'x':
 +              break;
 +#ifdef FLOATING_POINT
 +          case 'e': case 'f': case 'g':
 +          case 'E': case 'F': case 'G':
 +              flags |= FPT;
 +              break;
 +#endif /* FLOATING_POINT */
 +          case 's':
 +              flags |= CHARINT | POINTER;
 +              break;
 +          case 'n': case 'p':
 +              flags |= POINTER;
 +              break;
 +          default:
 +              /* Unexpected end of format */
 +              if (ch == 0)
 +                  return arg;
 +              ch = 0;
 +              break;
 +          }
 +          if (ch != 0)
 +              save_arg(&arg, argnum, flags);
 +          break;
 +      }
 +  }
 +}
 +#endif

 -- 
 David Laight: [email protected]

From: Charles Blundell <[email protected]>
To: David Laight <[email protected]>
Cc: [email protected]
Subject: Re: lib/1862: printf/scanf don't support X/Open positional parameters
Date: Mon, 1 Sep 2003 17:32:41 +0100

 on Mon, Sep 01, 2003 at 03:50:02PM +0100, David Laight wrote:
 > These overwrites can all be done with standard format strings, but the
 > %n$ variants make it so much easier!

 When the parameters to printf are bounded to some length, the
 presence of this feature can make things possible that were not
 previously.

 > Index: vfprintf.c
 > ===================================================================
 > RCS file: /cvsroot/src/lib/libc/stdio/vfprintf.c,v
 > retrieving revision 1.45
 > diff -u -p -r1.45 vfprintf.c
 > --- vfprintf.c   2003/08/07 16:43:34 1.45
 > +++ vfprintf.c   2003/09/01 14:43:02
 > +static uintmax_t
 > +get_arg_int(void *parg, int argnum)
 > +{
 > +    struct parg *arg = parg;
 > +
 > +    if (argnum >= arg->flags)
 > +        return 0;
 > +    return arg[argnum].val._uintmax;
 > +}

 I think you need to check for a negative argnum here, since argnum
 is the return from strtoul? (which allows it to vary above INT_MAX
 and negatives..)

 Likewise for get_arg_double and get_arg_ptr.


From: Simon Gerraty <[email protected]>
To: David Laight <[email protected]>
Cc: [email protected]
Subject: Re: lib/1862: printf/scanf don't support X/Open positional parameters 
Date: Mon, 01 Sep 2003 09:53:56 -0700

 On Mon, 1 Sep 2003 15:50:02 +0100, David Laight writes:
 >I've just sat down and implemented this for printf.

 Thanks.  Do we _need_ this though?

 >However there are definite security problems lurking for scanf and
 >even parts of printf.

 Yep, I recall a paper about just how easy it is to use this feature 
 to hack addresses in linux.

 What's the rationale (X/Open's) for these changes anyway?

 Thanks
 --sjg

From: Martin Husemann <[email protected]>
To: Simon Gerraty <[email protected]>
Cc: David Laight <[email protected]>, [email protected]
Subject: Re: lib/1862: printf/scanf don't support X/Open positional parameters
Date: Mon, 1 Sep 2003 19:08:01 +0200

 On Mon, Sep 01, 2003 at 09:53:56AM -0700, Simon Gerraty wrote:
 > What's the rationale (X/Open's) for these changes anyway?

 You load the format string from a message catalog and translators are able to
 move filled in parameters around. Pretty nice feature, but the specification
 is way overcomplicated. It would be enough to allow positional pre-formated
 string parameters, maybe with a width field.

 (That's my understanding; I don't know anything of X/Open's motivation)

 Martin

From: David Laight <[email protected]>
To: Martin Husemann <[email protected]>
Cc: Simon Gerraty <[email protected]>, [email protected]
Subject: Re: lib/1862: printf/scanf don't support X/Open positional parameters
Date: Mon, 1 Sep 2003 20:58:14 +0100

 On Mon, Sep 01, 2003 at 07:08:01PM +0200, Martin Husemann wrote:
 > On Mon, Sep 01, 2003 at 09:53:56AM -0700, Simon Gerraty wrote:
 > > What's the rationale (X/Open's) for these changes anyway?
 > 
 > You load the format string from a message catalog and translators are able to
 > move filled in parameters around. Pretty nice feature, but the specification
 > is way overcomplicated. It would be enough to allow positional pre-formated
 > string parameters, maybe with a width field.

 I think that part of the original rational came from an internationalisation
 process that extracted all (and I mean ALL) of the text strings from programs
 into a message catalog.  The translators where then expected to be able
 to translate the numbered string fragments without any context!
 (even "\n" got into the catalog!)

 The only problem I see is that "%*.*d" isn't treated as a single entity
 and always requires 3 argument specifiers "%3$*1$.*2$d".

 My 'gut' feel is that the original implementation (and hence the syntax)
 assumed that all the arguments (to printf) were the same size on the stack
 and hence that the stack could just be indexed to find the desired value.

 I think I might actually reduce the maximum number of selectable
 arguments to 9 (the minimum that IEEE 1003.1 2001 requires) in order to
 make it much harder to do a sucessful hack - and make the code simpler.

 > (That's my understanding; I don't know anything of X/Open's motivation)

 I've just looked at the X/Open XRAT, nothing about printf there [1].
 There is an implementation in the 1996 Unixware 2 sources, the copyright
 suggests this goes back to 1988 (and was always copyright Novell - IIRC
 they changed all the copyrights to be Novell regardless of the original one!)
 However this doesn't look like the original implementation (and I definitely
 haven't copied it!).  I don't have any pre-UW2 SVR4 sources.

    David

 [1] some interesting words about mkdir xxx/ though

 -- 
 David Laight: [email protected]

From: "Perry E. Metzger" <[email protected]>
To: David Laight <[email protected]>
Cc: [email protected]
Subject: Re: lib/1862: printf/scanf don't support X/Open positional parameters
Date: 02 Sep 2003 16:05:03 -0400

 David Laight <[email protected]> writes:
 > I've just sat down and implemented this for printf.

 One note. Open and FreeBSD have an implementation of this already. I
 think it would be best if we shared their implementation, if only so
 that we could avoid implementing new tweaks in the future by stealing
 their code...

 Perry

From: "Steven M. Bellovin" <[email protected]>
To: "Perry E. Metzger" <[email protected]>
Cc: David Laight <[email protected]>, [email protected]
Subject: Re: lib/1862: printf/scanf don't support X/Open positional parameters 
Date: Tue, 02 Sep 2003 16:32:55 -0400

 In message <[email protected]>, "Perry E. Metzger" writes:
 >
 >David Laight <[email protected]> writes:
 >> I've just sat down and implemented this for printf.
 >
 >One note. Open and FreeBSD have an implementation of this already. I
 >think it would be best if we shared their implementation, if only so
 >that we could avoid implementing new tweaks in the future by stealing
 >their code...

 But perhaps we shouldn't use the feature in any NetBSD code...


        --Steve Bellovin, http://www.research.att.com/~smb



From: "Perry E. Metzger" <[email protected]>
To: "Steven M. Bellovin" <[email protected]>
Cc: David Laight <[email protected]>, [email protected]
Subject: Re: lib/1862: printf/scanf don't support X/Open positional parameters
Date: 02 Sep 2003 16:39:15 -0400

 "Steven M. Bellovin" <[email protected]> writes:
 > But perhaps we shouldn't use the feature in any NetBSD code...

 I tend to agree that the main purpose of implementing this should be
 standards compliance.

 -- 
 Perry E. Metzger       [email protected]
From: David Holland <[email protected]>
To: [email protected]
Cc: 
Subject: Re: lib/1862: printf/scanf don't support X/Open positional parameters
Date: Sat, 9 Feb 2008 18:28:03 +0000

 Updating this for the century of the fruitbat: positional parameter
 support has been committed for printf, but not scanf.

 -- 
 David A. Holland
 [email protected]


Unformatted



 See also standards/19556.

non-512 bytes/sector media support case 3

Metadata

  • Number: 3792
  • Originator: Koji Imada - je4owb/2 <[email protected]>
  • Arrived: Wed Jun 25 01:50:01 +0000 1997
  • Last modified: Mon Feb 28 14:56:01 +0000 2011
  • Environment: System: NetBSD bimota 1.2E NetBSD 1.2E (BIMOTA) #: Wed Jun 11 02:13:27 JST 1997 koji@ducati:/mnt2/NetBSD/work/src-ufs-mod/sys/arch/i386/compile/BIMOTA i386

Description


    Modification required to support non-512 bytes/sector media
    for file system and device drivers.

    This is case 3 of 3 implementation. This changes block io unit
    to natural size of device and adapts file systems(cd9660, ffs,
    msdosfs) and device driver(cd, sd) to support non-512
    bytes/sector media.

    I will send mail to tech-kern about these 3 implementation.

    Also, these obsoletes kern/3460 and kern/3458

How to repeat


    Current NetBSD can't handle non-512 bytes/sector media properly.

Fix


    Apply following patches
Index: sys/arch/i386/i386/disksubr.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/arch/i386/i386/disksubr.c,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -u -r1.1.1.2 -r1.2
--- disksubr.c  1997/04/01 07:21:40 1.1.1.2
+++ disksubr.c  1997/05/29 17:50:43 1.2
@@ -91,7 +91,7 @@
    lp->d_partitions[i].p_offset = 0;

    /* get a buffer and initialize it */
-   bp = geteblk((int)lp->d_secsize);
+   bp = geteblk((int)BLKDEV_IOSIZE);
    bp->b_dev = dev;

    /* do dos partitions in the process of getting disklabel? */
@@ -100,6 +100,12 @@
    if (osdep && (dp = osdep->dosparts) != NULL) {
        /* read master boot record */
        bp->b_blkno = DOSBBSECTOR;
+#if 0
+       if (lp->d_secsize > DEV_BSIZE)
+           bp->b_blkno *= lp->d_secsize / DEV_BSIZE;
+       else
+           bp->b_blkno /= DEV_BSIZE / lp->d_secsize;
+#endif
        bp->b_bcount = lp->d_secsize;
        bp->b_flags = B_BUSY | B_READ;
        bp->b_cylin = DOSBBSECTOR / lp->d_secpercyl;
@@ -148,8 +154,14 @@

    /* next, dig out disk label */
    bp->b_blkno = dospartoff + LABELSECTOR;
+#if 0
+   if (lp->d_secsize > DEV_BSIZE)
+       bp->b_blkno *= lp->d_secsize / DEV_BSIZE;
+   else
+       bp->b_blkno /= DEV_BSIZE / lp->d_secsize;
+#endif
    bp->b_cylin = cyl;
-   bp->b_bcount = lp->d_secsize;
+   bp->b_bcount = BLKDEV_IOSIZE;
    bp->b_flags = B_BUSY | B_READ;
    (*strat)(bp);

@@ -159,7 +171,7 @@
        goto done;
    }
    for (dlp = (struct disklabel *)bp->b_data;
-       dlp <= (struct disklabel *)(bp->b_data + lp->d_secsize - sizeof(*dlp));
+       dlp <= (struct disklabel *)(bp->b_data + BLKDEV_IOSIZE - sizeof(*dlp));
        dlp = (struct disklabel *)((char *)dlp + sizeof(long))) {
        if (dlp->d_magic != DISKMAGIC || dlp->d_magic2 != DISKMAGIC) {
            if (msg == NULL)
@@ -186,10 +198,12 @@
            /* read a bad sector table */
            bp->b_flags = B_BUSY | B_READ;
            bp->b_blkno = lp->d_secperunit - lp->d_nsectors + i;
+#if 0
            if (lp->d_secsize > DEV_BSIZE)
                bp->b_blkno *= lp->d_secsize / DEV_BSIZE;
            else
                bp->b_blkno /= DEV_BSIZE / lp->d_secsize;
+#endif
            bp->b_bcount = lp->d_secsize;
            bp->b_cylin = lp->d_ncylinders - 1;
            (*strat)(bp);
@@ -291,7 +305,7 @@
    int error, dospartoff, cyl, i;

    /* get a buffer and initialize it */
-   bp = geteblk((int)lp->d_secsize);
+   bp = geteblk(BLKDEV_IOSIZE);
    bp->b_dev = dev;

    /* do dos partitions in the process of getting disklabel? */
@@ -300,6 +314,12 @@
    if (osdep && (dp = osdep->dosparts) != NULL) {
        /* read master boot record */
        bp->b_blkno = DOSBBSECTOR;
+#if 0
+       if (lp->d_secsize > DEV_BSIZE)
+           bp->b_blkno *= lp->d_secsize / DEV_BSIZE;
+       else
+           bp->b_blkno /= DEV_BSIZE / lp->d_secsize;
+#endif
        bp->b_bcount = lp->d_secsize;
        bp->b_flags = B_BUSY | B_READ;
        bp->b_cylin = DOSBBSECTOR / lp->d_secpercyl;
@@ -333,8 +353,14 @@

    /* next, dig out disk label */
    bp->b_blkno = dospartoff + LABELSECTOR;
+#if 0
+   if (lp->d_secsize > DEV_BSIZE)
+       bp->b_blkno *= lp->d_secsize / DEV_BSIZE;
+   else
+       bp->b_blkno /= DEV_BSIZE / lp->d_secsize;
+#endif
    bp->b_cylin = cyl;
-   bp->b_bcount = lp->d_secsize;
+   bp->b_bcount = BLKDEV_IOSIZE;
    bp->b_flags = B_BUSY | B_READ;
    (*strat)(bp);

@@ -342,7 +368,7 @@
    if ((error = biowait(bp)) != 0)
        goto done;
    for (dlp = (struct disklabel *)bp->b_data;
-       dlp <= (struct disklabel *)(bp->b_data + lp->d_secsize - sizeof(*dlp));
+       dlp <= (struct disklabel *)(bp->b_data + BLKDEV_IOSIZE - sizeof(*dlp));
        dlp = (struct disklabel *)((char *)dlp + sizeof(long))) {
        if (dlp->d_magic == DISKMAGIC && dlp->d_magic2 == DISKMAGIC &&
            dkcksum(dlp) == 0) {
@@ -374,12 +400,21 @@
 {
    struct partition *p = lp->d_partitions + DISKPART(bp->b_dev);
    int labelsector = lp->d_partitions[2].p_offset + LABELSECTOR;
-   int sz;
+   int sz, blkno;
+
+#if 1
+   blkno = bp->b_blkno;
+#else
+   if (lp->d_secsize > DEV_BSIZE)
+       blkno = bp->b_blkno / (lp->d_secsize / DEV_BSIZE);
+   else
+       blkno = bp->b_blkno * (DEV_BSIZE / lp->d_secsize);
+#endif

    sz = howmany(bp->b_bcount, lp->d_secsize);

-   if (bp->b_blkno + sz > p->p_size) {
-       sz = p->p_size - bp->b_blkno;
+   if (blkno + sz > p->p_size) {
+       sz = p->p_size - blkno;
        if (sz == 0) {
            /* If exactly at end of disk, return EOF. */
            bp->b_resid = bp->b_bcount;
@@ -391,13 +426,13 @@
            goto bad;
        }
        /* Otherwise, truncate request. */
-       bp->b_bcount = sz << DEV_BSHIFT;
+       bp->b_bcount = sz * lp->d_secsize;
    }

    /* Overwriting disk label? */
-   if (bp->b_blkno + p->p_offset <= labelsector &&
+   if (blkno + p->p_offset <= labelsector &&
 #if LABELSECTOR != 0
-       bp->b_blkno + p->p_offset + sz > labelsector &&
+       blkno + p->p_offset + sz > labelsector &&
 #endif
        (bp->b_flags & B_READ) == 0 && !wlabel) {
        bp->b_error = EROFS;
@@ -405,8 +440,7 @@
    }

    /* calculate cylinder for disksort to order transfers with */
-   bp->b_cylin = (bp->b_blkno + p->p_offset) /
-       (lp->d_secsize / DEV_BSIZE) / lp->d_secpercyl;
+   bp->b_cylin = (blkno + p->p_offset) / lp->d_secpercyl;
    return (1);

 bad:
Index: sys/dev/vnd.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/dev/vnd.c,v
retrieving revision 1.1.1.5
retrieving revision 1.4
diff -u -r1.1.1.5 -r1.4
--- vnd.c   1997/06/23 16:24:04 1.1.1.5
+++ vnd.c   1997/06/24 03:11:11 1.4
@@ -94,6 +94,10 @@
 #define b_cylin    b_resid

 #define    vndunit(x)  DISKUNIT(x)
+#define VNDPART(dev)   DISKPART(dev)
+#define MAKEVNDDEV(maj, unit, part)    MAKEDISKDEV(maj, unit, part)
+
+#define VNDLABELDEV(dev) (MAKEVNDDEV(major(dev), vndunit(dev), RAW_PART))

 struct vndxfer {
    struct buf  *vx_bp;     /* Pointer to parent buffer */
@@ -118,6 +122,9 @@
 struct vnd_softc {
    int      sc_flags;  /* flags */
    size_t       sc_size;   /* size of vnd */
+   int      sc_bsize;  /* block size for special file */
+   int      sc_blksize;    /* number of bytes/dector */
+   int      sc_bshift; /* shift constant */
    struct vnode    *sc_vp;     /* vnode */
    struct ucred    *sc_cred;   /* credentials */
    int      sc_maxactive;  /* max # of active requests */
@@ -129,6 +136,8 @@
 /* sc_flags */
 #define    VNF_ALIVE   0x01
 #define VNF_INITED 0x02
+#define VNF_WLABEL 0x04
+#define VNF_LABELLING  0x08
 #define VNF_WANTED 0x40
 #define VNF_LOCKED 0x80

@@ -140,10 +149,11 @@

 void   vndclear __P((struct vnd_softc *));
 void   vndstart __P((struct vnd_softc *));
-int    vndsetcred __P((struct vnd_softc *, struct ucred *));
+int    vndsetcred __P((struct vnd_softc *, struct ucred *, struct proc *p));
 void   vndthrottle __P((struct vnd_softc *, struct vnode *));
 void   vndiodone __P((struct buf *));
 void   vndshutdown __P((void));
+void   vndgetdisklabel __P((dev_t dev, struct vnd_softc *vnd));

 static int vndlock __P((struct vnd_softc *));
 static void vndunlock __P((struct vnd_softc *));
@@ -196,6 +206,15 @@
    part = DISKPART(dev);
    pmask = (1 << part);

+   /* Check that the partition exists. */
+   if (part != RAW_PART &&
+       ((sc->sc_flags & VNF_INITED) == 0 ||
+        part >= sc->sc_dkdev.dk_label->d_npartitions ||
+        sc->sc_dkdev.dk_label->d_partitions[part].p_fstype == FS_UNUSED)) {
+       error = ENXIO;
+       goto bad;
+   }
+
    /* Prevent our unit from being unconfigured while open. */
    switch (mode) {
    case S_IFCHR:
@@ -211,6 +230,10 @@

    vndunlock(sc);
    return (0);
+
+bad:
+   vndunlock(sc);
+   return error;
 }

 int
@@ -272,6 +295,7 @@
    int sz, flags, error;

 #ifdef DEBUG
+   printf("vndstrategy(%p): bsize %ld\n", bp, vnd->sc_vp->v_mount->mnt_stat.f_iosize);
    if (vnddebug & VDB_FOLLOW)
        printf("vndstrategy(%p): unit %d\n", bp, unit);
 #endif
@@ -281,9 +305,28 @@
        biodone(bp);
        return;
    }
+
+   if (VNDPART(bp->b_dev) != RAW_PART &&
+       bounds_check_with_label(bp, vnd->sc_dkdev.dk_label,
+       (vnd->sc_flags & (VNF_WLABEL|VNF_LABELLING)) != 0) <= 0) {
+       bp->b_resid = bp->b_bcount;
+       biodone(bp);
+       return;
+   }
+
+#if 1
    bn = bp->b_blkno;
-   sz = howmany(bp->b_bcount, DEV_BSIZE);
+#else
+   bn = bp->b_blkno / (vnd->sc_dkdev.dk_label->d_secsize / DEV_BSIZE);
+#endif
    bp->b_resid = bp->b_bcount;
+   sz = howmany(bp->b_bcount, vnd->sc_blksize);
+
+   if (VNDPART(bp->b_dev) != RAW_PART) {
+       bn += vnd->sc_dkdev.dk_label->d_partitions[VNDPART(bp->b_dev)].p_offset;
+   }
+   bn *= vnd->sc_dkdev.dk_label->d_secsize / vnd->sc_blksize;
+
    if (bn < 0 || bn + sz > vnd->sc_size) {
        if (bn != vnd->sc_size) {
            bp->b_error = EINVAL;
@@ -292,8 +335,13 @@
        biodone(bp);
        return;
    }
-   bn = dbtob(bn);
+
+   bn = bn << vnd->sc_bshift;
+#if 1
+   bsize = vnd->sc_bsize;
+#else
    bsize = vnd->sc_vp->v_mount->mnt_stat.f_iosize;
+#endif
    addr = bp->b_data;
    flags = bp->b_flags | B_CALL;

@@ -512,6 +560,7 @@
 {
    int unit = vndunit(dev);
    struct vnd_softc *sc;
+   int bshift;

 #ifdef DEBUG
    if (vnddebug & VDB_FOLLOW)
@@ -524,8 +573,9 @@

    if ((sc->sc_flags & VNF_INITED) == 0)
        return (ENXIO);
+   bshift = ffs(sc->sc_dkdev.dk_label->d_secsize)-1;

-   return (physio(vndstrategy, NULL, dev, B_READ, minphys, uio));
+   return (physio2(vndstrategy, NULL, dev, B_READ, minphys, uio, bshift));
 }

 /* ARGSUSED */
@@ -537,6 +587,7 @@
 {
    int unit = vndunit(dev);
    struct vnd_softc *sc;
+   int bshift;

 #ifdef DEBUG
    if (vnddebug & VDB_FOLLOW)
@@ -549,8 +600,9 @@

    if ((sc->sc_flags & VNF_INITED) == 0)
        return (ENXIO);
+   bshift = ffs(sc->sc_dkdev.dk_label->d_secsize)-1;

-   return (physio(vndstrategy, NULL, dev, B_WRITE, minphys, uio));
+   return (physio2(vndstrategy, NULL, dev, B_WRITE, minphys, uio, bshift));
 }

 /* ARGSUSED */
@@ -588,6 +640,10 @@
        if (vnd->sc_flags & VNF_INITED)
            return (EBUSY);

+       if (vio->vnd_size == 0 || vio->vnd_size % DEV_BSIZE != 0 ||
+           vio->vnd_size > BLKDEV_IOSIZE)
+           vio->vnd_size = DEV_BSIZE;
+
        if ((error = vndlock(vnd)) != 0)
            return (error);

@@ -602,23 +658,55 @@
            vndunlock(vnd);
            return(error);
        }
-       error = VOP_GETATTR(nd.ni_vp, &vattr, p->p_ucred, p);
+       if (nd.ni_vp->v_type == VBLK || nd.ni_vp->v_type == VCHR) {
+           struct partinfo dpart;
+
+           dpart.disklab = NULL;
+           dpart.part = NULL;
+           error = VOP_IOCTL(nd.ni_vp, DIOCGPART, (caddr_t)&dpart,
+               FREAD, NOCRED, p);
+           if (error == 0) {
+               if (dpart.disklab != NULL && dpart.disklab->d_secsize != 0)
+                   vattr.va_blocksize = dpart.disklab->d_secsize;
+               else
+                   vattr.va_blocksize = DEV_BSIZE;
+               if (dpart.part == NULL)
+                   vattr.va_size = 0;
+               else {
+                   vattr.va_size = dpart.part->p_size *
+                       dpart.disklab->d_secsize;
+               }
+           }
+       } else {
+           error = VOP_GETATTR(nd.ni_vp, &vattr, p->p_ucred, p);
+       }
        if (error) {
            VOP_UNLOCK(nd.ni_vp);
            (void) vn_close(nd.ni_vp, FREAD|FWRITE, p->p_ucred, p);
            vndunlock(vnd);
            return(error);
        }
+           
        VOP_UNLOCK(nd.ni_vp);
        vnd->sc_vp = nd.ni_vp;
-       vnd->sc_size = btodb(vattr.va_size);    /* note truncation */
-       if ((error = vndsetcred(vnd, p->p_ucred)) != 0) {
+       vnd->sc_blksize = vio->vnd_size;
+       vnd->sc_bshift = ffs(vnd->sc_blksize) - 1;
+       vnd->sc_size = vattr.va_size >> vnd->sc_bshift; /* note truncation */
+       if (nd.ni_vp->v_type != VBLK && nd.ni_vp->v_type != VCHR) {
+           vnd->sc_bsize = nd.ni_vp->v_mount->mnt_stat.f_iosize;
+       } else {
+           if (vattr.va_blocksize != 0)
+               vnd->sc_bsize = vattr.va_blocksize;
+           else
+               vnd->sc_bsize = DEV_BSIZE;
+       }
+       if ((error = vndsetcred(vnd, p->p_ucred, p)) != 0) {
            (void) vn_close(nd.ni_vp, FREAD|FWRITE, p->p_ucred, p);
            vndunlock(vnd);
            return(error);
        }
        vndthrottle(vnd, vnd->sc_vp);
-       vio->vnd_size = dbtob(vnd->sc_size);
+       vio->vnd_size = vnd->sc_size << vnd->sc_bshift;
        vnd->sc_flags |= VNF_INITED;
 #ifdef DEBUG
        if (vnddebug & VDB_INIT)
@@ -632,6 +720,8 @@
        vnd->sc_dkdev.dk_name = vnd->sc_xname;
        disk_attach(&vnd->sc_dkdev);

+       vndgetdisklabel(dev, vnd);
+
        vndunlock(vnd);

        break;
@@ -673,6 +763,60 @@
    /*
     * XXX Should support disklabels.
     */
+   case DIOCGDINFO:
+       if ((vnd->sc_flags & VNF_INITED) == 0)
+           return (ENXIO);
+
+       *(struct disklabel *)data = *(vnd->sc_dkdev.dk_label);
+       return 0;
+
+   case DIOCGPART:
+       if ((vnd->sc_flags & VNF_INITED) == 0)
+           return (ENXIO);
+
+       ((struct partinfo *)data)->disklab = vnd->sc_dkdev.dk_label;
+       ((struct partinfo *)data)->part =
+           &vnd->sc_dkdev.dk_label->d_partitions[VNDPART(dev)];
+       return 0;
+
+
+   case DIOCWDINFO:
+   case DIOCSDINFO:
+       if ((vnd->sc_flags & VNF_INITED) == 0)
+           return (ENXIO);
+
+       if ((flag & FWRITE) == 0)
+           return EBADF;
+
+       if ((error = vndlock(vnd)) != 0)
+           return error;
+       vnd->sc_flags |= VNF_LABELLING;
+
+       error = setdisklabel(vnd->sc_dkdev.dk_label,
+           (struct disklabel *)data, /*vnd->sc_dkdev.dk_openmask : */0,
+           vnd->sc_dkdev.dk_cpulabel);
+       if (error == 0) {
+           if (cmd == DIOCWDINFO)
+               error = writedisklabel(VNDLABELDEV(dev),
+                   vndstrategy, vnd->sc_dkdev.dk_label,
+                   vnd->sc_dkdev.dk_cpulabel);
+       }
+
+       vnd->sc_flags &= ~VNF_LABELLING;
+       vndunlock(vnd);
+       return error;
+
+   case DIOCWLABEL:
+       if ((vnd->sc_flags & VNF_INITED) == 0)
+           return (ENXIO);
+
+       if ((flag & FWRITE) == 0)
+           return EBADF;
+       if (*(int *)data)
+           vnd->sc_flags |= VNF_WLABEL;
+       else
+           vnd->sc_flags &= ~VNF_WLABEL;
+       return 0;

    default:
        return(ENOTTY);
@@ -682,15 +826,69 @@
 }

 /*
+ * Load the label information on the named device
+ */
+void
+vndgetdisklabel(dev, vnd)
+   dev_t dev;
+   struct vnd_softc *vnd;
+{
+   struct disklabel *lp = vnd->sc_dkdev.dk_label;
+   char *errstring;
+
+   bzero(lp, sizeof(struct disklabel));
+   bzero(vnd->sc_dkdev.dk_cpulabel, sizeof(struct cpu_disklabel));
+
+   lp->d_secsize = vnd->sc_blksize;
+   lp->d_ntracks = 64;
+   lp->d_nsectors = 32;
+   lp->d_ncylinders = vnd->sc_size / (64 * 32);
+   lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors;
+   if (lp->d_secpercyl == 0) {
+       lp->d_secpercyl = 100;
+       /* as long as it's not 0 - readdisklabel divides by it (?) */
+   }
+
+   strncpy(lp->d_typename, "vnode disk", 16);
+   lp->d_type = DTYPE_VND;
+   strncpy(lp->d_packname, "fictitious", 16);
+   lp->d_secperunit = vnd->sc_size;
+   lp->d_rpm = 3600;
+   lp->d_interleave = 1;
+   lp->d_flags = 0;
+
+   lp->d_partitions[RAW_PART].p_offset = 0;
+   lp->d_partitions[RAW_PART].p_size =
+       lp->d_secperunit;
+   lp->d_partitions[RAW_PART].p_fstype = FS_UNUSED;
+   lp->d_npartitions = RAW_PART + 1;
+
+   lp->d_magic = DISKMAGIC;
+   lp->d_magic2 = DISKMAGIC;
+   lp->d_checksum = dkcksum(lp);
+
+   /*
+    * Call the generic disklabel extraction routine
+    */
+   errstring = readdisklabel(dev,
+                 vndstrategy, lp, vnd->sc_dkdev.dk_cpulabel);
+   if (errstring) {
+       printf("%s: %s\n", vnd->sc_xname, errstring);
+       return;
+   }
+}
+
+/*
  * Duplicate the current processes' credentials.  Since we are called only
  * as the result of a SET ioctl and only root can do that, any future access
  * to this "disk" is essentially as root.  Note that credentials may change
  * if some other uid can write directly to the mapped file (NFS).
  */
 int
-vndsetcred(vnd, cred)
+vndsetcred(vnd, cred, p)
    register struct vnd_softc *vnd;
    struct ucred *cred;
+   struct proc *p;
 {
    struct uio auio;
    struct iovec aiov;
@@ -709,6 +907,7 @@
    auio.uio_rw = UIO_READ;
    auio.uio_segflg = UIO_SYSSPACE;
    auio.uio_resid = aiov.iov_len;
+   auio.uio_procp = p;
    VOP_LOCK(vnd->sc_vp);
    error = VOP_READ(vnd->sc_vp, &auio, 0, vnd->sc_cred);
    VOP_UNLOCK(vnd->sc_vp);
Index: sys/isofs/cd9660/cd9660_bmap.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/isofs/cd9660/cd9660_bmap.c,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -u -r1.1.1.2 -r1.2
--- cd9660_bmap.c   1997/04/01 07:13:06 1.1.1.2
+++ cd9660_bmap.c   1997/05/29 17:50:53 1.2
@@ -84,7 +84,11 @@
     * Compute the requested block number
     */
    bshift = ip->i_mnt->im_bshift;
+#if 1
+   *ap->a_bnp = (ip->iso_start + lblkno) << ip->i_mnt->im_sshift;
+#else
    *ap->a_bnp = (ip->iso_start + lblkno) << (bshift - DEV_BSHIFT);
+#endif

    /*
     * Determine maximum number of readahead blocks following the
Index: sys/isofs/cd9660/cd9660_extern.h
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/isofs/cd9660/cd9660_extern.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- cd9660_extern.h 1997/04/01 07:13:14 1.1.1.1
+++ cd9660_extern.h 1997/05/29 17:50:55 1.2
@@ -61,7 +61,12 @@
    int logical_block_size;
    int im_bshift;
    int im_bmask;
-   
+
+#if 1
+   int system_block_size;
+   int im_sshift;
+#endif 
+
    int volume_space_size;
    struct netexport im_export;

Index: sys/isofs/cd9660/cd9660_rrip.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/isofs/cd9660/cd9660_rrip.c,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -u -r1.1.1.2 -r1.2
--- cd9660_rrip.c   1997/04/01 07:13:10 1.1.1.2
+++ cd9660_rrip.c   1997/05/29 17:50:56 1.2
@@ -574,7 +574,11 @@
            if (ana->iso_ce_blk >= ana->imp->volume_space_size
                || ana->iso_ce_off + ana->iso_ce_len > ana->imp->logical_block_size
                || bread(ana->imp->im_devvp,
+#if 1
+                    ana->iso_ce_blk << ana->imp->im_sshift,
+#else
                     ana->iso_ce_blk << (ana->imp->im_bshift - DEV_BSHIFT),
+#endif
                     ana->imp->logical_block_size, NOCRED, &bp))
                /* what to do now? */
                break;
Index: sys/isofs/cd9660/cd9660_vfsops.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/isofs/cd9660/cd9660_vfsops.c,v
retrieving revision 1.1.1.3
retrieving revision 1.3
diff -u -r1.1.1.3 -r1.3
--- cd9660_vfsops.c 1997/06/23 16:26:16 1.1.1.3
+++ cd9660_vfsops.c 1997/06/24 03:11:32 1.3
@@ -233,6 +233,13 @@
    struct iso_primary_descriptor *pri;
    struct iso_directory_record *rootp;
    int logical_block_size;
+#if 1
+   struct partinfo dpart;
+   int bsize, sshift;
+   struct ucred *cred;
+
+   cred = p ? p->p_ucred : NOCRED;
+#endif

    if (!ronly)
        return EROFS;
@@ -260,10 +267,23 @@
     * whichever is greater.  For now, we'll just use a constant.
     */
    iso_bsize = ISO_DEFAULT_BLOCK_SIZE;
+#if 1
+   if (VOP_IOCTL(devvp, DIOCGPART, (caddr_t)&dpart, FREAD, cred, p) != 0)
+       bsize = DEV_BSIZE;
+   else
+       bsize = dpart.disklab->d_secsize;
+
+   sshift = ffs(iso_bsize) - ffs(bsize);
+#endif

    for (iso_blknum = 16; iso_blknum < 100; iso_blknum++) {
+#if 1
+       if ((error = bread(devvp, iso_blknum << sshift,
+                  iso_bsize, NOCRED, &bp)) != 0)
+#else
        if ((error = bread(devvp, iso_blknum * btodb(iso_bsize),
                   iso_bsize, NOCRED, &bp)) != 0)
+#endif
            goto out;

        vdp = (struct iso_volume_descriptor *)bp->b_data;
@@ -312,6 +332,10 @@
    while ((1 << isomp->im_bshift) < isomp->logical_block_size)
        isomp->im_bshift++;

+#if 1
+   isomp->system_block_size = bsize;
+   isomp->im_sshift = sshift;
+#endif
    bp->b_flags |= B_AGE;
    brelse(bp);
    bp = NULL;
@@ -331,7 +355,11 @@
    if (!(argp->flags & ISOFSMNT_NORRIP)) {
        if ((error = bread(isomp->im_devvp,
                   (isomp->root_extent + isonum_711(rootp->ext_attr_length)) <<
+#if 1
+                  isomp->im_sshift,
+#else
                   (isomp->im_bshift - DEV_BSHIFT),
+#endif
                   isomp->logical_block_size, NOCRED,
                   &bp)) != 0)
            goto out;
Index: sys/kern/kern_physio.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/kern/kern_physio.c,v
retrieving revision 1.1.1.3
retrieving revision 1.2
diff -u -r1.1.1.3 -r1.2
--- kern_physio.c   1997/05/23 21:58:02 1.1.1.3
+++ kern_physio.c   1997/05/29 17:50:47 1.2
@@ -78,6 +78,19 @@
    void (*minphys) __P((struct buf *));
    struct uio *uio;
 {
+   return physio2(strategy, bp, dev, flags, minphys, uio, DEV_BSHIFT);
+}
+
+int
+physio2(strategy, bp, dev, flags, minphys, uio, bshift)
+   void (*strategy) __P((struct buf *));
+   struct buf *bp;
+   dev_t dev;
+   int flags;
+   void (*minphys) __P((struct buf *));
+   struct uio *uio;
+   int bshift;
+{
    struct iovec *iovp;
    struct proc *p = curproc;
    int error, done, i, nobuf, s, todo;
@@ -143,7 +156,12 @@
            bp->b_flags = B_BUSY | B_PHYS | B_RAW | flags;

            /* [set up the buffer for a maximum-sized transfer] */
+#if 1
+           bp->b_blkno = uio->uio_offset >> bshift;
+#else
            bp->b_blkno = btodb(uio->uio_offset);
+#endif
+
            bp->b_bcount = iovp->iov_len;
            bp->b_data = iovp->iov_base;

Index: sys/scsi/cd.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/scsi/cd.c,v
retrieving revision 1.1.1.3
retrieving revision 1.2
diff -u -r1.1.1.3 -r1.2
--- cd.c    1997/04/11 07:23:35 1.1.1.3
+++ cd.c    1997/05/29 17:50:50 1.2
@@ -549,13 +549,18 @@
         * First, translate the block to absolute and put it in terms
         * of the logical blocksize of the device.
         */
+#if 1
+       blkno = bp->b_blkno;
+#else
        blkno =
            bp->b_blkno / (cd->sc_dk.dk_label->d_secsize / DEV_BSIZE);
+#endif
        if (CDPART(bp->b_dev) != RAW_PART) {
              p = &cd->sc_dk.dk_label->d_partitions[CDPART(bp->b_dev)];
              blkno += p->p_offset;
        }
-       nblks = howmany(bp->b_bcount, cd->sc_dk.dk_label->d_secsize);
+       blkno *= cd->sc_dk.dk_label->d_secsize / cd->params.blksize;
+       nblks = howmany(bp->b_bcount, cd->params.blksize);

        /*
         *  Fill out the scsi command.  If the transfer will
@@ -647,8 +652,10 @@
    struct uio *uio;
    int ioflag;
 {
+   struct cd_softc *cd = cd_cd.cd_devs[CDUNIT(dev)];
+   int bshift = ffs(cd->sc_dk.dk_label->d_secsize)-1;

-   return (physio(cdstrategy, NULL, dev, B_READ, cdminphys, uio));
+   return (physio2(cdstrategy, NULL, dev, B_READ, cdminphys, uio, bshift));
 }

 int
@@ -657,8 +664,10 @@
    struct uio *uio;
    int ioflag;
 {
+   struct cd_softc *cd = cd_cd.cd_devs[CDUNIT(dev)];
+   int bshift = ffs(cd->sc_dk.dk_label->d_secsize)-1;

-   return (physio(cdstrategy, NULL, dev, B_WRITE, cdminphys, uio));
+   return (physio2(cdstrategy, NULL, dev, B_WRITE, cdminphys, uio, bshift));
 }

 /*
@@ -942,6 +951,7 @@
    struct cd_softc *cd;
 {
    struct disklabel *lp = cd->sc_dk.dk_label;
+   char *errstring;

    bzero(lp, sizeof(struct disklabel));
    bzero(cd->sc_dk.dk_cpulabel, sizeof(struct cpu_disklabel));
@@ -962,17 +972,46 @@

    lp->d_partitions[0].p_offset = 0;
    lp->d_partitions[0].p_size =
-       lp->d_secperunit * (lp->d_secsize / DEV_BSIZE);
+       lp->d_secperunit;
    lp->d_partitions[0].p_fstype = FS_ISO9660;
    lp->d_partitions[RAW_PART].p_offset = 0;
    lp->d_partitions[RAW_PART].p_size =
-       lp->d_secperunit * (lp->d_secsize / DEV_BSIZE);
+       lp->d_secperunit;
    lp->d_partitions[RAW_PART].p_fstype = FS_ISO9660;
    lp->d_npartitions = RAW_PART + 1;

    lp->d_magic = DISKMAGIC;
    lp->d_magic2 = DISKMAGIC;
    lp->d_checksum = dkcksum(lp);
+
+   /*
+    * Call the generic disklabel extraction routine
+    */
+   errstring = readdisklabel(MAKECDDEV(0, cd->sc_dev.dv_unit, RAW_PART),
+                 cdstrategy, lp, cd->sc_dk.dk_cpulabel);
+
+#if 0
+   if (errstring) {
+       printf("%s: %s\n", cd->sc_dev.dv_xname, errstring);
+       return;
+   }
+#else
+   if (errstring && strcmp(errstring, "no disk label") == 0) {
+       lp->d_partitions[0].p_offset = 0;
+       lp->d_partitions[0].p_size =
+           lp->d_secperunit;
+       lp->d_partitions[0].p_fstype = FS_ISO9660;
+       lp->d_partitions[RAW_PART].p_offset = 0;
+       lp->d_partitions[RAW_PART].p_size =
+           lp->d_secperunit;
+       lp->d_partitions[RAW_PART].p_fstype = FS_ISO9660;
+       lp->d_npartitions = RAW_PART + 1;
+
+       lp->d_magic = DISKMAGIC;
+       lp->d_magic2 = DISKMAGIC;
+       lp->d_checksum = dkcksum(lp);
+   }
+#endif
 }

 /*
Index: sys/scsi/sd.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/scsi/sd.c,v
retrieving revision 1.1.1.4
retrieving revision 1.3
diff -u -r1.1.1.4 -r1.3
--- sd.c    1997/06/23 16:30:19 1.1.1.4
+++ sd.c    1997/06/24 03:11:50 1.3
@@ -577,13 +577,13 @@
         * First, translate the block to absolute and put it in terms
         * of the logical blocksize of the device.
         */
-       blkno =
-           bp->b_blkno / (sd->sc_dk.dk_label->d_secsize / DEV_BSIZE);
+       blkno = bp->b_blkno;
        if (SDPART(bp->b_dev) != RAW_PART) {
             p = &sd->sc_dk.dk_label->d_partitions[SDPART(bp->b_dev)];
             blkno += p->p_offset;
        }
-       nblks = howmany(bp->b_bcount, sd->sc_dk.dk_label->d_secsize);
+       blkno *= sd->sc_dk.dk_label->d_secsize / sd->params.blksize;
+       nblks = howmany(bp->b_bcount, sd->params.blksize);

        /*
         *  Fill out the scsi command.  If the transfer will
@@ -675,8 +675,10 @@
    struct uio *uio;
    int ioflag;
 {
+   struct sd_softc *sd = sd_cd.cd_devs[SDUNIT(dev)];
+   int bshift = ffs(sd->sc_dk.dk_label->d_secsize)-1;

-   return (physio(sdstrategy, NULL, dev, B_READ, sdminphys, uio));
+   return (physio2(sdstrategy, NULL, dev, B_READ, sdminphys, uio, bshift));
 }

 int
@@ -685,8 +687,10 @@
    struct uio *uio;
    int ioflag;
 {
+   struct sd_softc *sd = sd_cd.cd_devs[SDUNIT(dev)];
+   int bshift = ffs(sd->sc_dk.dk_label->d_secsize)-1;

-   return (physio(sdstrategy, NULL, dev, B_WRITE, sdminphys, uio));
+   return (physio2(sdstrategy, NULL, dev, B_WRITE, sdminphys, uio, bshift));
 }

 /*
@@ -810,7 +814,7 @@

    lp->d_partitions[RAW_PART].p_offset = 0;
    lp->d_partitions[RAW_PART].p_size =
-       lp->d_secperunit * (lp->d_secsize / DEV_BSIZE);
+       lp->d_secperunit;
    lp->d_partitions[RAW_PART].p_fstype = FS_UNUSED;
    lp->d_npartitions = RAW_PART + 1;

Index: sys/sys/buf.h
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/sys/buf.h,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -u -r1.1.1.2 -r1.2
--- buf.h   1997/04/14 06:25:49 1.1.1.2
+++ buf.h   1997/05/29 17:50:51 1.2
@@ -187,6 +187,8 @@
 void   minphys __P((struct buf *bp));
 int    physio __P((void (*strategy)(struct buf *), struct buf *bp, dev_t dev,
            int flags, void (*minphys)(struct buf *), struct uio *uio));
+int    physio2 __P((void (*strategy)(struct buf *), struct buf *bp, dev_t dev,
+           int flags, void (*minphys)(struct buf *), struct uio *uio, int bshift));
 void  brelvp __P((struct buf *));
 void  reassignbuf __P((struct buf *, struct vnode *));
 void  bgetvp __P((struct vnode *, struct buf *));
Index: sys/ufs/ffs/ffs_vfsops.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/ufs/ffs/ffs_vfsops.c,v
retrieving revision 1.1.1.3
retrieving revision 1.4
diff -u -r1.1.1.3 -r1.4
--- ffs_vfsops.c    1997/06/23 16:31:06 1.1.1.3
+++ ffs_vfsops.c    1997/06/24 03:12:02 1.4
@@ -307,7 +307,9 @@
    struct csum *space;
    struct buf *bp;
    struct fs *fs, *newfs;
+#if 1
    struct partinfo dpart;
+#endif
    int i, blks, size, error;
    int32_t *lp;

@@ -322,10 +324,15 @@
    /*
     * Step 2: re-read superblock from disk.
     */
+#if 1
    if (VOP_IOCTL(devvp, DIOCGPART, (caddr_t)&dpart, FREAD, NOCRED, p) != 0)
        size = DEV_BSIZE;
    else
        size = dpart.disklab->d_secsize;
+#else
+   size = DEV_BSIZE;
+#endif
+
    error = bread(devvp, (daddr_t)(SBOFF / size), SBSIZE, NOCRED, &bp);
    if (error)
        return (error);
@@ -343,6 +350,7 @@
     */
    bcopy(&fs->fs_csp[0], &newfs->fs_csp[0], sizeof(fs->fs_csp));
    newfs->fs_maxcluster = fs->fs_maxcluster;
+   newfs->fs_fsbtosb = fs->fs_fsbtosb;
    bcopy(newfs, fs, (u_int)fs->fs_sbsize);
    if (fs->fs_sbsize < SBSIZE)
        bp->b_flags |= B_INVAL;
@@ -424,10 +432,12 @@
    struct buf *bp;
    register struct fs *fs;
    dev_t dev;
+#if 1
    struct partinfo dpart;
+#endif
    caddr_t base, space;
    int blks;
-   int error, i, size, ronly;
+   int error, i, size, ssize, ronly;
    int32_t *lp;
    struct ucred *cred;
    extern struct vnode *rootvp;
@@ -452,10 +462,14 @@
    error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, p);
    if (error)
        return (error);
+#if 1
    if (VOP_IOCTL(devvp, DIOCGPART, (caddr_t)&dpart, FREAD, cred, p) != 0)
        size = DEV_BSIZE;
    else
        size = dpart.disklab->d_secsize;
+#else
+   size = DEV_BSIZE;
+#endif

    bp = NULL;
    ump = NULL;
@@ -473,6 +487,21 @@
        error = EROFS;      /* XXX what should be returned? */
        goto out;
    }
+   /* XXX bread assumes b_blkno in DEV_BSIZE unit. Calculate fsbtosb */
+
+   ssize = fs->fs_fsize / fs->fs_nspf;
+   fs->fs_fsbtosb = fs->fs_fsbtodb;
+   if (ssize >= size) {
+       ssize = ssize / size;
+       for (i = 0; ssize > 1; ssize >>= 1)
+           i ++;
+       fs->fs_fsbtosb += i;
+   } else {
+       ssize = size / ssize;
+       for (i = 0; ssize > 1; ssize >>= 1)
+           i ++;
+       fs->fs_fsbtosb -= i;
+   }
    ump = malloc(sizeof *ump, M_UFSMNT, M_WAITOK);
    bzero((caddr_t)ump, sizeof *ump);
    ump->um_fs = malloc((u_long)fs->fs_sbsize, M_UFSMNT,
@@ -523,7 +552,7 @@
    ump->um_dev = dev;
    ump->um_devvp = devvp;
    ump->um_nindir = fs->fs_nindir;
-   ump->um_bptrtodb = fs->fs_fsbtodb;
+   ump->um_bptrtodb = fs->fs_fsbtosb;
    ump->um_seqinc = fs->fs_frag;
    for (i = 0; i < MAXQUOTAS; i++)
        ump->um_quotas[i] = NULLVP;
@@ -921,11 +950,12 @@
    register struct buf *bp;
    int i, error = 0;

-   bp = getblk(mp->um_devvp, SBOFF >> (fs->fs_fshift - fs->fs_fsbtodb),
+   bp = getblk(mp->um_devvp, SBOFF >> (fs->fs_fshift - fs->fs_fsbtosb),
        (int)fs->fs_sbsize, 0, 0);
    bcopy((caddr_t)fs, bp->b_data, (u_int)fs->fs_sbsize);
    /* Restore compatibility to old file systems.          XXX */
    dfs = (struct fs *)bp->b_data;              /* XXX */
+   dfs->fs_fsbtosb = 0;                    /* XXX */
    if (fs->fs_postblformat == FS_42POSTBLFMT)      /* XXX */
        dfs->fs_nrpos = -1;             /* XXX */
    if (fs->fs_inodefmt < FS_44INODEFMT) {          /* XXX */
Index: sys/ufs/ffs/fs.h
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/ufs/ffs/fs.h,v
retrieving revision 1.1.1.2
retrieving revision 1.3
diff -u -r1.1.1.2 -r1.3
--- fs.h    1997/06/23 16:31:07 1.1.1.2
+++ fs.h    1997/06/24 03:12:03 1.3
@@ -228,7 +228,8 @@
    int32_t  *fs_maxcluster;    /* max cluster in each cyl group */
    int32_t  fs_cpc;        /* cyl per cycle in postbl */
    int16_t  fs_opostbl[16][8]; /* old rotation block list head */
-   int32_t  fs_sparecon[49];   /* reserved for future constants */
+   int32_t  fs_fsbtosb;        /* fsbtodb and dbtofsb shift constant */
+   int32_t  fs_sparecon[48];   /* reserved for future constants */
    time_t   fs_fscktime;       /* last time fsck(8)ed */
    int32_t  fs_contigsumsize;  /* size of cluster summary array */ 
    int32_t  fs_maxsymlinklen;  /* max length of an internal symlink */
@@ -394,8 +395,8 @@
  * Turn file system block numbers into disk block addresses.
  * This maps file system blocks to device size blocks.
  */
-#define fsbtodb(fs, b) ((b) << (fs)->fs_fsbtodb)
-#define    dbtofsb(fs, b)  ((b) >> (fs)->fs_fsbtodb)
+#define fsbtodb(fs, b) ((b) << (fs)->fs_fsbtosb)
+#define    dbtofsb(fs, b)  ((b) >> (fs)->fs_fsbtosb)

 /*
  * Cylinder group macros to locate things in cylinder groups.

Audit trail



From: Leo Weppelman <[email protected]>
To: [email protected]
Cc:  Subject: kern/3792 [ partially updated the patches for 13/07/98-current ]
Date: Tue, 14 Jul 1998 13:31:58 +0200

 This is a _partial_ update. Notably the MD and the dev/vnd parts are
 missing.


 diff -ru /usr/src/sys.org/dev/scsipi/cd.c /mnt/sys/dev/scsipi/cd.c
 --- /usr/src/sys.org/dev/scsipi/cd.c   Sun Mar 22 21:02:26 1998
 +++ /mnt/sys/dev/scsipi/cd.c   Mon Jul 13 21:30:54 1998
 @@ -517,12 +517,13 @@
         * First, translate the block to absolute and put it in terms
         * of the logical blocksize of the device.
         */
 -      blkno = bp->b_blkno / (lp->d_secsize / DEV_BSIZE);
 +      blkno = bp->b_blkno;
        if (CDPART(bp->b_dev) != RAW_PART) {
            p = &lp->d_partitions[CDPART(bp->b_dev)];
            blkno += p->p_offset;
        }
 -      nblks = howmany(bp->b_bcount, lp->d_secsize);
 +      blkno *= lp->d_secsize / cd->params.blksize;
 +      nblks = howmany(bp->b_bcount, cd->params.blksize);

  #if NCD_SCSIBUS > 0
        /*
 @@ -620,8 +621,10 @@
    struct uio *uio;
    int ioflag;
  {
 +  struct cd_softc *cd = cd_cd.cd_devs[CDUNIT(dev)];
 +  int bshift = ffs(cd->sc_dk.dk_label->d_secsize)-1;

 -  return (physio(cdstrategy, NULL, dev, B_READ, cdminphys, uio));
 +  return (physio2(cdstrategy, NULL, dev, B_READ, cdminphys, uio, bshift));
  }

  int
 @@ -630,8 +633,10 @@
    struct uio *uio;
    int ioflag;
  {
 -
 -  return (physio(cdstrategy, NULL, dev, B_WRITE, cdminphys, uio));
 +  struct cd_softc *cd = cd_cd.cd_devs[CDUNIT(dev)];
 +  int bshift = ffs(cd->sc_dk.dk_label->d_secsize)-1;
 + 
 +  return (physio2(cdstrategy, NULL, dev, B_WRITE, cdminphys, uio, bshift));
  }

  /*
 @@ -901,6 +906,7 @@
    struct cd_softc *cd;
    struct disklabel *lp;
  {
 +  char    *errstring;

    bzero(lp, sizeof(struct disklabel));

 @@ -919,18 +925,36 @@
    lp->d_flags = D_REMOVABLE;

    lp->d_partitions[0].p_offset = 0;
 -  lp->d_partitions[0].p_size =
 -      lp->d_secperunit * (lp->d_secsize / DEV_BSIZE);
 +  lp->d_partitions[0].p_size = lp->d_secperunit;
    lp->d_partitions[0].p_fstype = FS_ISO9660;
    lp->d_partitions[RAW_PART].p_offset = 0;
 -  lp->d_partitions[RAW_PART].p_size =
 -      lp->d_secperunit * (lp->d_secsize / DEV_BSIZE);
 +  lp->d_partitions[RAW_PART].p_size = lp->d_secperunit;
    lp->d_partitions[RAW_PART].p_fstype = FS_ISO9660;
    lp->d_npartitions = RAW_PART + 1;

    lp->d_magic = DISKMAGIC;
    lp->d_magic2 = DISKMAGIC;
    lp->d_checksum = dkcksum(lp);
 +
 +  /*
 +   * Call the generic disklabel extraction routine
 +   */
 +  errstring = readdisklabel(MAKECDDEV(0, cd->sc_dev.dv_unit, RAW_PART),
 +                cdstrategy, lp, cd->sc_dk.dk_cpulabel);
 +
 +  if (errstring && strcmp(errstring, "no disk label") == 0) {
 +      lp->d_partitions[0].p_offset = 0;
 +      lp->d_partitions[0].p_size = lp->d_secperunit;
 +      lp->d_partitions[0].p_fstype = FS_ISO9660;
 +      lp->d_partitions[RAW_PART].p_offset = 0;
 +      lp->d_partitions[RAW_PART].p_size = lp->d_secperunit;
 +      lp->d_partitions[RAW_PART].p_fstype = FS_ISO9660;
 +      lp->d_npartitions = RAW_PART + 1;
 +
 +      lp->d_magic = DISKMAGIC;
 +      lp->d_magic2 = DISKMAGIC;
 +      lp->d_checksum = dkcksum(lp);
 +  }
  }

  /*
 diff -ru /usr/src/sys.org/dev/scsipi/sd.c /mnt/sys/dev/scsipi/sd.c
 --- /usr/src/sys.org/dev/scsipi/sd.c   Tue Mar 10 10:37:22 1998
 +++ /mnt/sys/dev/scsipi/sd.c   Mon Jul 13 21:30:54 1998
 @@ -567,12 +567,13 @@
         * First, translate the block to absolute and put it in terms
         * of the logical blocksize of the device.
         */
 -      blkno = bp->b_blkno / (lp->d_secsize / DEV_BSIZE);
 +      blkno = bp->b_blkno;
        if (SDPART(bp->b_dev) != RAW_PART) {
            p = &lp->d_partitions[SDPART(bp->b_dev)];
            blkno += p->p_offset;
        }
 -      nblks = howmany(bp->b_bcount, lp->d_secsize);
 +      blkno *= lp->d_secsize / sd->params.blksize;
 +      nblks = howmany(bp->b_bcount, sd->params.blksize);

  #if NSD_SCSIBUS > 0
        /*
 @@ -800,8 +801,7 @@
    lp->d_flags = 0;

    lp->d_partitions[RAW_PART].p_offset = 0;
 -  lp->d_partitions[RAW_PART].p_size =
 -      lp->d_secperunit * (lp->d_secsize / DEV_BSIZE);
 +  lp->d_partitions[RAW_PART].p_size = lp->d_secperunit;
    lp->d_partitions[RAW_PART].p_fstype = FS_UNUSED;
    lp->d_npartitions = RAW_PART + 1;

 diff -ru /usr/src/sys.org/isofs/cd9660/cd9660_bmap.c /mnt/sys/isofs/cd9660/cd9660_bmap.c
 --- /usr/src/sys.org/isofs/cd9660/cd9660_bmap.c    Fri Jan 24 13:20:24 1997
 +++ /mnt/sys/isofs/cd9660/cd9660_bmap.c    Mon Jul 13 21:30:54 1998
 @@ -84,7 +84,11 @@
     * Compute the requested block number
     */
    bshift = ip->i_mnt->im_bshift;
 +#if 1
 +  *ap->a_bnp = (ip->iso_start + lblkno) << ip->i_mnt->im_sshift;
 +#else
    *ap->a_bnp = (ip->iso_start + lblkno) << (bshift - DEV_BSHIFT);
 +#endif

    /*
     * Determine maximum number of readahead blocks following the
 Only in /mnt/sys/isofs/cd9660: cd9660_bmap.c.orig
 diff -ru /usr/src/sys.org/isofs/cd9660/cd9660_extern.h /mnt/sys/isofs/cd9660/cd9660_extern.h
 --- /usr/src/sys.org/isofs/cd9660/cd9660_extern.h  Mon Jul 13 20:57:02 1998
 +++ /mnt/sys/isofs/cd9660/cd9660_extern.h  Mon Jul 13 21:30:54 1998
 @@ -61,6 +61,11 @@
    int logical_block_size;
    int im_bshift;
    int im_bmask;
 +
 +#if 1
 +  int system_block_size;
 +  int im_sshift;
 +#endif

    int volume_space_size;
    struct netexport im_export;
 Only in /mnt/sys/isofs/cd9660: cd9660_extern.h.orig
 diff -ru /usr/src/sys.org/isofs/cd9660/cd9660_lookup.c /mnt/sys/isofs/cd9660/cd9660_lookup.c
 --- /usr/src/sys.org/isofs/cd9660/cd9660_lookup.c  Tue Mar 10 10:37:22 1998
 +++ /mnt/sys/isofs/cd9660/cd9660_lookup.c  Mon Jul 13 21:30:54 1998
 @@ -313,7 +313,11 @@
                    if (isonum_711(ep->flags)&2)
                        ino = isodirino(ep, imp);
                    else
 +#if 1
 +                      ino = (bp->b_blkno<<imp->im_bshift)
 +#else
                        ino = dbtob(bp->b_blkno)
 +#endif
                            + entryoffsetinblock;
                    saveoffset = dp->i_offset;
                } else if (ino)
 @@ -330,7 +334,12 @@
            if (isonum_711(ep->flags)&2)
                ino = isodirino(ep, imp);
            else
 +#if 1
 +              ino = (bp->b_blkno << imp->im_bshift)
 +                      + entryoffsetinblock;
 +#else
                ino = dbtob(bp->b_blkno) + entryoffsetinblock;
 +#endif
            dp->i_ino = ino;
            cd9660_rrip_getname(ep,altname,&namelen,&dp->i_ino,imp);
            if (namelen == cnp->cn_namelen
 Only in /mnt/sys/isofs/cd9660: cd9660_lookup.c.orig
 diff -ru /usr/src/sys.org/isofs/cd9660/cd9660_rrip.c /mnt/sys/isofs/cd9660/cd9660_rrip.c
 --- /usr/src/sys.org/isofs/cd9660/cd9660_rrip.c    Fri Jan 24 13:20:31 1997
 +++ /mnt/sys/isofs/cd9660/cd9660_rrip.c    Mon Jul 13 21:30:54 1998
 @@ -574,7 +574,11 @@
            if (ana->iso_ce_blk >= ana->imp->volume_space_size
                || ana->iso_ce_off + ana->iso_ce_len > ana->imp->logical_block_size
                || bread(ana->imp->im_devvp,
 +#if 1
 +                   ana->iso_ce_blk << ana->imp->im_sshift,
 +#else
                     ana->iso_ce_blk << (ana->imp->im_bshift - DEV_BSHIFT),
 +#endif
                     ana->imp->logical_block_size, NOCRED, &bp))
                /* what to do now? */
                break;
 Only in /mnt/sys/isofs/cd9660: cd9660_rrip.c.orig
 diff -ru /usr/src/sys.org/isofs/cd9660/cd9660_vfsops.c /mnt/sys/isofs/cd9660/cd9660_vfsops.c
 --- /usr/src/sys.org/isofs/cd9660/cd9660_vfsops.c  Mon Jul 13 20:57:01 1998
 +++ /mnt/sys/isofs/cd9660/cd9660_vfsops.c  Mon Jul 13 21:30:54 1998
 @@ -238,6 +238,14 @@
    struct iso_primary_descriptor *pri;
    struct iso_directory_record *rootp;
    int logical_block_size;
 +
 +#if 1
 +  struct partinfo dpart;
 +  int bsize, sshift;
 +  struct ucred *cred;
 +
 +  cred = p ? p->p_ucred : NOCRED;
 +#endif

    if (!ronly)
        return EROFS;
 @@ -265,10 +273,22 @@
     * whichever is greater.  For now, we'll just use a constant.
     */
    iso_bsize = ISO_DEFAULT_BLOCK_SIZE;
 +#if 1
 +  if (VOP_IOCTL(devvp, DIOCGPART, (caddr_t)&dpart, FREAD, cred, p) != 0)
 +      bsize = DEV_BSIZE;
 +  else bsize = dpart.disklab->d_secsize;
 +
 +  sshift = ffs(iso_bsize) - ffs(bsize);
 +#endif

    for (iso_blknum = 16; iso_blknum < 100; iso_blknum++) {
 +#if 1
 +      if ((error = bread(devvp, iso_blknum << sshift,
 +                 iso_bsize, NOCRED, &bp)) != 0)
 +#else
        if ((error = bread(devvp, iso_blknum * btodb(iso_bsize),
                   iso_bsize, NOCRED, &bp)) != 0)
 +#endif
            goto out;

        vdp = (struct iso_volume_descriptor *)bp->b_data;
 @@ -317,6 +337,10 @@
    while ((1 << isomp->im_bshift) < isomp->logical_block_size)
        isomp->im_bshift++;

 +#if 1
 +  isomp->system_block_size = bsize;
 +  isomp->im_sshift = sshift;
 +#endif
    bp->b_flags |= B_AGE;
    brelse(bp);
    bp = NULL;
 @@ -336,7 +360,11 @@
    if (!(argp->flags & ISOFSMNT_NORRIP)) {
        if ((error = bread(isomp->im_devvp,
                   (isomp->root_extent + isonum_711(rootp->ext_attr_length)) <<
 +#if 1
 +                 isomp->im_sshift,
 +#else
                   (isomp->im_bshift - DEV_BSHIFT),
 +#endif
                   isomp->logical_block_size, NOCRED,
                   &bp)) != 0)
            goto out;
 @@ -663,7 +691,11 @@
        }

        error = bread(imp->im_devvp,
 +#if 1
 +                lbn << imp->im_sshift,
 +#else
                  lbn << (imp->im_bshift - DEV_BSHIFT),
 +#endif
                  imp->logical_block_size, NOCRED, &bp);
        if (error) {
            vput(vp);
 Only in /mnt/sys/isofs/cd9660: cd9660_vfsops.c.orig
 diff -ru /usr/src/sys.org/isofs/cd9660/cd9660_vnops.c /mnt/sys/isofs/cd9660/cd9660_vnops.c
 --- /usr/src/sys.org/isofs/cd9660/cd9660_vnops.c   Mon Jul 13 20:57:02 1998
 +++ /mnt/sys/isofs/cd9660/cd9660_vnops.c   Mon Jul 13 21:30:54 1998
 @@ -1,4 +1,4 @@
 -/*    $NetBSD: cd9660_vnops.c,v 1.47 1998/06/25 22:21:13 thorpej Exp $    */
 +/*    $NetBSD: cd9660_vnops.c,v 1.43 1998/03/01 02:22:09 fvdl Exp $   */

  /*-
   * Copyright (c) 1994
 @@ -545,7 +545,11 @@
        if (isonum_711(ep->flags)&2)
            idp->current.d_fileno = isodirino(ep, imp);
        else
 +#if 1
 +          idp->current.d_fileno = (bp->b_blkno << imp->im_bshift)+
 +#else
            idp->current.d_fileno = dbtob(bp->b_blkno) +
 +#endif
                entryoffsetinblock;

        idp->curroff += reclen;
 @@ -657,7 +661,11 @@
     */
    error = bread(imp->im_devvp,
              (ip->i_number >> imp->im_bshift) <<
 +#if 1
 +            imp->im_sshift,
 +#else
              (imp->im_bshift - DEV_BSHIFT),
 +#endif
              imp->logical_block_size, NOCRED, &bp);
    if (error) {
        brelse(bp);
 diff -ru /usr/src/sys.org/kern/kern_physio.c /mnt/sys/kern/kern_physio.c
 --- /usr/src/sys.org/kern/kern_physio.c    Wed Jun 10 15:22:00 1998
 +++ /mnt/sys/kern/kern_physio.c    Mon Jul 13 21:30:54 1998
 @@ -85,6 +85,19 @@
    void (*minphys) __P((struct buf *));
    struct uio *uio;
  {
 +  return physio2(strategy, bp, dev, flags, minphys, uio, DEV_BSHIFT);
 +}
 +
 +int
 +physio2(strategy, bp, dev, flags, minphys, uio, bshift)
 +  void (*strategy) __P((struct buf *));
 +  struct buf *bp;
 +  dev_t dev;
 +  int flags;
 +  void (*minphys) __P((struct buf *));
 +  struct uio *uio;
 +  int bshift;
 +{
    struct iovec *iovp;
    struct proc *p = curproc;
    int error, done, i, nobuf, s, todo;
 @@ -164,7 +177,7 @@
            bp->b_flags = B_BUSY | B_PHYS | B_RAW | flags;

            /* [set up the buffer for a maximum-sized transfer] */
 -          bp->b_blkno = btodb(uio->uio_offset);
 +          bp->b_blkno = uio->uio_offset >> bshift;
            bp->b_bcount = iovp->iov_len;
            bp->b_data = iovp->iov_base;

 diff -ru /usr/src/sys.org/msdosfs/msdosfs_denode.c /mnt/sys/msdosfs/msdosfs_denode.c
 --- /usr/src/sys.org/msdosfs/msdosfs_denode.c  Wed Jun 10 15:22:04 1998
 +++ /mnt/sys/msdosfs/msdosfs_denode.c  Mon Jul 13 21:30:54 1998
 @@ -414,12 +414,12 @@
    if ((boff = length & pmp->pm_crbomask) != 0) {
        if (isadir) {
            bn = cntobn(pmp, eofentry);
 -          error = bread(pmp->pm_devvp, bn, pmp->pm_bpcluster,
 -              NOCRED, &bp);
 +          error = bread(pmp->pm_devvp, fsbtosb(pmp, bn),
 +                  pmp->pm_bpcluster, NOCRED, &bp);
        } else {
            bn = de_blk(pmp, length);
 -          error = bread(DETOV(dep), bn, pmp->pm_bpcluster,
 -              NOCRED, &bp);
 +          error = bread(DETOV(dep), fsbtosb(pmp, bn),
 +                  pmp->pm_bpcluster, NOCRED, &bp);
        }
        if (error) {
            brelse(bp);
 Only in /mnt/sys/msdosfs: msdosfs_denode.c.orig
 diff -ru /usr/src/sys.org/msdosfs/msdosfs_fat.c /mnt/sys/msdosfs/msdosfs_fat.c
 --- /usr/src/sys.org/msdosfs/msdosfs_fat.c Sat May  2 13:14:20 1998
 +++ /mnt/sys/msdosfs/msdosfs_fat.c Mon Jul 13 21:30:54 1998
 @@ -223,7 +223,8 @@
        if (bn != bp_bn) {
            if (bp)
                brelse(bp);
 -          error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp);
 +          error = bread(pmp->pm_devvp, fsbtosb(pmp, bn), bsize,
 +                              NOCRED, &bp);
            if (error) {
                brelse(bp);
                return (error);
 @@ -392,7 +393,8 @@
        for (i = 1; i < pmp->pm_FATs; i++) {
            fatbn += pmp->pm_FATsecs;
            /* getblk() never fails */
 -          bpn = getblk(pmp->pm_devvp, fatbn, bp->b_bcount, 0, 0);
 +          bpn = getblk(pmp->pm_devvp, fsbtosb(pmp, fatbn),
 +                          bp->b_bcount, 0, 0);
            bcopy(bp->b_data, bpn->b_data, bp->b_bcount);
            if (pmp->pm_flags & MSDOSFSMNT_WAITONFAT)
                bwrite(bpn);
 @@ -541,7 +543,8 @@

    byteoffset = FATOFS(pmp, cn);
    fatblock(pmp, byteoffset, &bn, &bsize, &bo);
 -  if ((error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp)) != 0) {
 +  if ((error = bread(pmp->pm_devvp, fsbtosb(pmp, bn), bsize, NOCRED,
 +                              &bp)) != 0) {
        brelse(bp);
        return (error);
    }
 @@ -627,7 +630,8 @@
    while (count > 0) {
        byteoffset = FATOFS(pmp, start);
        fatblock(pmp, byteoffset, &bn, &bsize, &bo);
 -      error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp);
 +      error = bread(pmp->pm_devvp, fsbtosb(pmp, bn), bsize,
 +                              NOCRED, &bp);
        if (error) {
            brelse(bp);
            return (error);
 @@ -868,7 +872,8 @@
        if (lbn != bn) {
            if (bp)
                updatefats(pmp, bp, lbn);
 -          error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp);
 +          error = bread(pmp->pm_devvp, fsbtosb(pmp, bn), bsize,
 +                              NOCRED, &bp);
            if (error) {
                brelse(bp);
                return (error);
 @@ -943,7 +948,8 @@
            if (bp)
                brelse(bp);
            fatblock(pmp, byteoffset, &bn, &bsize, NULL);
 -          error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp);
 +          error = bread(pmp->pm_devvp, fsbtosb(pmp, bn), bsize,
 +                              NOCRED, &bp);
            if (error) {
                brelse(bp);
                return (error);
 @@ -1064,27 +1070,33 @@
         * cache.
         */
        fc_setcache(dep, FC_LASTFC, frcn + got - 1, cn + got - 1);
 -
 +  
        if (flags & DE_CLEAR) {
            while (got-- > 0) {
                /*
                 * Get the buf header for the new block of the file.
                 */
                if (dep->de_Attributes & ATTR_DIRECTORY)
 -                  bp = getblk(pmp->pm_devvp, cntobn(pmp, cn++),
 +                  bp = getblk(pmp->pm_devvp,
 +                      fsbtosb(pmp, cntobn(pmp, cn++)),
                            pmp->pm_bpcluster, 0, 0);
                else {
 -                  bp = getblk(DETOV(dep), de_cn2bn(pmp, frcn++),
 +                  bp = getblk(DETOV(dep),
 +                      fsbtosb(pmp, de_cn2bn(pmp, frcn++)),
                        pmp->pm_bpcluster, 0, 0);
                    /*
                     * Do the bmap now, as in msdosfs_write
                     */
                    if (pcbmap(dep,
 -                      de_bn2cn(pmp, bp->b_lblkno),
 +                      fsbtosb(pmp,
 +                      de_bn2cn(pmp, bp->b_lblkno)),
                        &bp->b_blkno, 0, 0))
                        bp->b_blkno = -1;
                    if (bp->b_blkno == -1)
                        panic("extendfile: pcbmap");
 +                  else
 +                      bp->b_blkno = fsbtosb(pmp,
 +                              bp->b_blkno);
                }
                clrbuf(bp);
                if (bpp) {
 Only in /mnt/sys/msdosfs: msdosfs_fat.c.orig
 diff -ru /usr/src/sys.org/msdosfs/msdosfs_lookup.c /mnt/sys/msdosfs/msdosfs_lookup.c
 --- /usr/src/sys.org/msdosfs/msdosfs_lookup.c  Tue Mar 10 10:37:33 1998
 +++ /mnt/sys/msdosfs/msdosfs_lookup.c  Mon Jul 13 21:30:54 1998
 @@ -265,7 +265,8 @@
                break;
            return (error);
        }
 -      error = bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp);
 +      error = bread(pmp->pm_devvp, fsbtosb(pmp, bn), blsize,
 +                              NOCRED, &bp);
        if (error) {
            brelse(bp);
            return (error);
 @@ -657,7 +658,8 @@
    diroffset = ddep->de_fndoffset;
    if (dirclust != MSDOSFSROOT)
        diroffset &= pmp->pm_crbomask;
 -  if ((error = bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp)) != 0) {
 +  if ((error = bread(pmp->pm_devvp, fsbtosb(pmp, bn), blsize,
 +                      NOCRED, &bp)) != 0) {
        brelse(bp);
        return error;
    }
 @@ -687,8 +689,8 @@
                if (error)
                    return error;

 -              error = bread(pmp->pm_devvp, bn, blsize,
 -                        NOCRED, &bp);
 +              error = bread(pmp->pm_devvp, fsbtosb(pmp, bn),
 +                          blsize, NOCRED, &bp);
                if (error) {
                    brelse(bp);
                    return error;
 @@ -752,7 +754,8 @@
                return (1); /* it's empty */
            return (0);
        }
 -      error = bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp);
 +      error = bread(pmp->pm_devvp, fsbtosb(pmp, bn), blsize,
 +                          NOCRED, &bp);
        if (error) {
            brelse(bp);
            return (0);
 @@ -844,7 +847,7 @@
            break;
        }
        scn = dep->de_StartCluster;
 -      error = bread(pmp->pm_devvp, cntobn(pmp, scn),
 +      error = bread(pmp->pm_devvp, fsbtosb(pmp, cntobn(pmp, scn)),
                  pmp->pm_bpcluster, NOCRED, &bp);
        if (error)
            break;
 @@ -913,7 +916,8 @@
        && de_blk(pmp, diroffset + blsize) > pmp->pm_rootdirsize)
        blsize = de_bn2off(pmp, pmp->pm_rootdirsize) & pmp->pm_crbomask;
    bn = detobn(pmp, dirclust, diroffset);
 -  if ((error = bread(pmp->pm_devvp, bn, blsize, NOCRED, bpp)) != 0) {
 +  if ((error = bread(pmp->pm_devvp, fsbtosb(pmp, bn), blsize,
 +                          NOCRED, bpp)) != 0) {
        brelse(*bpp);
        *bpp = NULL;
        return (error);
 @@ -972,7 +976,8 @@
        error = pcbmap(pdep, de_cluster(pmp, offset), &bn, 0, &blsize);
        if (error)
            return error;
 -      error = bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp);
 +      error = bread(pmp->pm_devvp, fsbtosb(pmp, bn), blsize,
 +                              NOCRED, &bp);
        if (error) {
            brelse(bp);
            return error;
 @@ -1046,7 +1051,8 @@
                    return 0;
                return error;
            }
 -          error = bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp);
 +          error = bread(pmp->pm_devvp, fsbtosb(pmp, bn),
 +                          blsize, NOCRED, &bp);
            if (error) {
                brelse(bp);
                return error;
 @@ -1097,7 +1103,8 @@
    for (cn = 0;; cn++) {
        if (pcbmap(dep, cn, &bn, 0, &blsize))
            return 0;
 -      if (bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp)) {
 +      if (bread(pmp->pm_devvp, fsbtosb(pmp, bn), blsize,
 +                          NOCRED, &bp)) {
            brelse(bp);
            return 0;
        }
 Only in /mnt/sys/msdosfs: msdosfs_lookup.c.orig
 diff -ru /usr/src/sys.org/msdosfs/msdosfs_vfsops.c /mnt/sys/msdosfs/msdosfs_vfsops.c
 --- /usr/src/sys.org/msdosfs/msdosfs_vfsops.c  Mon Jul 13 20:57:05 1998
 +++ /mnt/sys/msdosfs/msdosfs_vfsops.c  Mon Jul 13 21:30:54 1998
 @@ -421,7 +421,7 @@
     * Read the boot sector of the filesystem, and then check the
     * boot signature.  If not a dos boot sector then error out.
     */
 -  if ((error = bread(devvp, 0, 512, NOCRED, &bp)) != 0)
 +  if ((error = bread(devvp, 0, BLKDEV_IOSIZE, NOCRED, &bp)) != 0)
        goto error_exit;
    bp->b_flags |= B_AGE;
    bsp = (union bootsector *)bp->b_data;
 @@ -563,6 +563,11 @@
        SecPerClust;
    pmp->pm_maxcluster = pmp->pm_nmbrofclusters + 1;
    pmp->pm_fatsize = pmp->pm_FATsecs * pmp->pm_BytesPerSec;
 +  if (VOP_IOCTL(devvp, DIOCGPART, (caddr_t)&dpart, FREAD, NOCRED, p) != 0)
 +      tmp = DEV_BSIZE;
 +  else
 +      tmp = dpart.disklab->d_secsize;
 +  pmp->pm_fsbtosb = ffs(pmp->pm_BytesPerSec) - ffs(tmp);

    if (argp->flags & MSDOSFSMNT_GEMDOSFS) {
        if ((pmp->pm_nmbrofclusters <= (0xff0 - 2))
 Only in /mnt/sys/msdosfs: msdosfs_vfsops.c.orig
 diff -ru /usr/src/sys.org/msdosfs/msdosfs_vnops.c /mnt/sys/msdosfs/msdosfs_vnops.c
 --- /usr/src/sys.org/msdosfs/msdosfs_vnops.c   Tue Apr 21 13:13:28 1998
 +++ /mnt/sys/msdosfs/msdosfs_vnops.c   Mon Jul 13 21:30:54 1998
 @@ -496,16 +496,19 @@
         * vnode for the directory.
         */
        if (isadir) {
 -          error = bread(pmp->pm_devvp, lbn, blsize, NOCRED, &bp);
 +          error = bread(pmp->pm_devvp, fsbtosb(pmp, lbn),
 +                          blsize, NOCRED, &bp);
        } else {
            rablock = lbn + 1;
            if (vp->v_lastr + 1 == lbn &&
                de_cn2off(pmp, rablock) < dep->de_FileSize)
 -              error = breada(vp, de_cn2bn(pmp, lbn),
 +              error = breada(vp,
 +                  fsbtosb(pmp, de_cn2bn(pmp, lbn)),
                    pmp->pm_bpcluster, de_cn2bn(pmp, rablock),
                    pmp->pm_bpcluster, NOCRED, &bp);
            else
 -              error = bread(vp, de_cn2bn(pmp, lbn),
 +              error = bread(vp,
 +                  fsbtosb(pmp, de_cn2bn(pmp, lbn)),
                    pmp->pm_bpcluster, NOCRED, &bp);
            vp->v_lastr = lbn;
        }
 @@ -633,7 +636,8 @@
             * or we write the cluster from its start beyond EOF,
             * then no need to read data from disk.
             */
 -          bp = getblk(thisvp, bn, pmp->pm_bpcluster, 0, 0);
 +          bp = getblk(thisvp, fsbtosb(pmp, bn),
 +                      pmp->pm_bpcluster, 0, 0);
            clrbuf(bp);
            /*
             * Do the bmap now, since pcbmap needs buffers
 @@ -641,10 +645,13 @@
             */
            if (bp->b_blkno == bp->b_lblkno) {
                error = pcbmap(dep,
 -                         de_bn2cn(pmp, bp->b_lblkno),
 +                         de_bn2cn(pmp,
 +                        sbtofsb(pmp, bp->b_lblkno)),
                           &bp->b_blkno, 0, 0);
                if (error)
                    bp->b_blkno = -1;
 +              else
 +                  bp->b_blkno = fsbtosb(pmp, bp->b_blkno);
            }
            if (bp->b_blkno == -1) {
                brelse(bp);
 @@ -656,8 +663,8 @@
            /*
             * The block we need to write into exists, so read it in.
             */
 -          error = bread(thisvp, bn, pmp->pm_bpcluster,
 -                    NOCRED, &bp);
 +          error = bread(thisvp, fsbtosb(pmp, bn),
 +                      pmp->pm_bpcluster, NOCRED, &bp);
            if (error) {
                brelse(bp);
                break;
 @@ -1187,8 +1194,8 @@
            panic("msdosfs_rename: updating .. in root directory?\n");
        } else
            bn = cntobn(pmp, cn);
 -      error = bread(pmp->pm_devvp, bn, pmp->pm_bpcluster,
 -                NOCRED, &bp);
 +      error = bread(pmp->pm_devvp, fsbtosb(pmp, bn),
 +                  pmp->pm_bpcluster, NOCRED, &bp);
        if (error) {
            /* XXX should really panic here, fs is corrupt */
            brelse(bp);
 @@ -1296,7 +1303,7 @@
     */
    bn = cntobn(pmp, newcluster);
    /* always succeeds */
 -  bp = getblk(pmp->pm_devvp, bn, pmp->pm_bpcluster, 0, 0);
 +  bp = getblk(pmp->pm_devvp, fsbtosb(pmp, bn), pmp->pm_bpcluster, 0, 0);
    bzero(bp->b_data, pmp->pm_bpcluster);
    bcopy(&dosdirtemplate, bp->b_data, sizeof dosdirtemplate);
    denp = (struct direntry *)bp->b_data;
 @@ -1582,7 +1589,8 @@
        n = min(n, diff);
        if ((error = pcbmap(dep, lbn, &bn, &cn, &blsize)) != 0)
            break;
 -      error = bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp);
 +      error = bread(pmp->pm_devvp, fsbtosb(pmp, bn), blsize,
 +                              NOCRED, &bp);
        if (error) {
            brelse(bp);
            return (error);
 @@ -1835,10 +1843,13 @@
     * don't allow files with holes, so we shouldn't ever see this.
     */
    if (bp->b_blkno == bp->b_lblkno) {
 -      error = pcbmap(dep, de_bn2cn(dep->de_pmp, bp->b_lblkno),
 +      error = pcbmap(dep, de_bn2cn(dep->de_pmp,
 +                 sbtofsb(dep->de_pmp, bp->b_lblkno)),
                   &bp->b_blkno, 0, 0);
        if (error)
            bp->b_blkno = -1;
 +      else
 +          bp->b_blkno = fsbtosb(dep->de_pmp, bp->b_blkno);
        if (bp->b_blkno == -1)
            clrbuf(bp);
    }
 Only in /mnt/sys/msdosfs: msdosfs_vnops.c.orig
 diff -ru /usr/src/sys.org/msdosfs/msdosfsmount.h /mnt/sys/msdosfs/msdosfsmount.h
 --- /usr/src/sys.org/msdosfs/msdosfsmount.h    Tue Mar 10 10:37:33 1998
 +++ /mnt/sys/msdosfs/msdosfsmount.h    Mon Jul 13 21:30:54 1998
 @@ -87,6 +87,7 @@
    mode_t pm_mask;     /* mask to and with file protection bits */
    struct vnode *pm_devvp; /* vnode for block device mntd */
    struct bpb50 pm_bpb;    /* BIOS parameter blk for this fs */
 +  int pm_fsbtosb;     /* fsbtosb and sbtofsb shift constant */
    u_long pm_FATsecs;  /* actual number of fat sectors */
    u_long pm_fatblk;   /* block # of first FAT */
    u_long pm_rootdirblk;   /* block # (cluster # for FAT32) of root directory number */
 @@ -115,6 +116,16 @@
  };
  /* Byte offset in FAT on filesystem pmp, cluster cn */
  #define   FATOFS(pmp, cn) ((cn) * (pmp)->pm_fatmult / (pmp)->pm_fatdiv)
 +
 +
 +/*
 + * Turn file system block numbers into system block addresses.
 + * This maps file system blocks to system size blocks.
 + */
 +#define fsbtosb(pmp, bn) \
 +  ((bn) << (pmp)->pm_fsbtosb)
 +#define sbtofsb(pmp, bn) \
 +  ((bn) >> (pmp)->pm_fsbtosb)

  #define   VFSTOMSDOSFS(mp)    ((struct msdosfsmount *)mp->mnt_data)

 Only in /mnt/sys/msdosfs: msdosfsmount.h.orig
 diff -ru /usr/src/sys.org/sys/buf.h /mnt/sys/sys/buf.h
 --- /usr/src/sys.org/sys/buf.h Tue Mar 10 10:37:39 1998
 +++ /mnt/sys/sys/buf.h Mon Jul 13 21:30:54 1998
 @@ -196,6 +196,9 @@
  void  minphys __P((struct buf *bp));
  int   physio __P((void (*strategy)(struct buf *), struct buf *bp, dev_t dev,
            int flags, void (*minphys)(struct buf *), struct uio *uio));
 +int   physio2 __P((void (*strategy)(struct buf *), struct buf *bp, dev_t dev,
 +          int flags, void (*minphys)(struct buf *), struct uio *uio,
 +          int bshift));
  void  brelvp __P((struct buf *));
  void  reassignbuf __P((struct buf *, struct vnode *));
  void  bgetvp __P((struct vnode *, struct buf *));
 Only in /mnt/sys/sys: buf.h.orig
 diff -ru /usr/src/sys.org/ufs/ffs/ffs_bswap.c /mnt/sys/ufs/ffs/ffs_bswap.c
 --- /usr/src/sys.org/ufs/ffs/ffs_bswap.c   Wed Jun 17 11:02:30 1998
 +++ /mnt/sys/ufs/ffs/ffs_bswap.c   Mon Jul 13 21:30:54 1998
 @@ -71,16 +71,17 @@
    n->fs_postbloff = bswap32(o->fs_postbloff);
    n->fs_rotbloff = bswap32(o->fs_rotbloff);
    n->fs_magic = bswap32(o->fs_magic);
 +  n->fs_fsbtosb =  bswap32(o->fs_fsbtosb);
    /* byteswap the postbl */
    o16 = (ufs_rw32(o->fs_postblformat, ns) == FS_42POSTBLFMT)
 -      ? o->fs_opostbl[0]
 -      : (int16_t *)((u_int8_t *)o + ufs_rw32(o->fs_postbloff, ns));
 +      ? o->fs_opostbl[0]
 +      : (int16_t *)((u_int8_t *)o + ufs_rw32(o->fs_postbloff, ns));
    n16 = (ufs_rw32(o->fs_postblformat, ns) == FS_42POSTBLFMT)
 -      ? n->fs_opostbl[0]
 -      : (int16_t *)((u_int8_t *)n + ufs_rw32(n->fs_postbloff, ns));
 +      ? n->fs_opostbl[0]
 +      : (int16_t *)((u_int8_t *)n + ufs_rw32(n->fs_postbloff, ns));
    for (i = 0;
 -       i < ufs_rw32(o->fs_cpc, ns) * ufs_rw32(o->fs_nrpos, ns);
 -       i++)
 +      i < ufs_rw32(o->fs_cpc, ns) * ufs_rw32(o->fs_nrpos, ns);
 +      i++)
        n16[i] = bswap16(o16[i]);
  }

 Only in /mnt/sys/ufs/ffs: ffs_bswap.c.orig
 diff -ru /usr/src/sys.org/ufs/ffs/ffs_vfsops.c /mnt/sys/ufs/ffs/ffs_vfsops.c
 --- /usr/src/sys.org/ufs/ffs/ffs_vfsops.c  Mon Jul 13 20:57:04 1998
 +++ /mnt/sys/ufs/ffs/ffs_vfsops.c  Mon Jul 13 21:30:54 1998
 @@ -355,6 +355,7 @@
     */
    bcopy(&fs->fs_csp[0], &newfs->fs_csp[0], sizeof(fs->fs_csp));
    newfs->fs_maxcluster = fs->fs_maxcluster;
 +  newfs->fs_fsbtosb = fs->fs_fsbtosb;
    bcopy(newfs, fs, (u_int)fs->fs_sbsize);
    if (fs->fs_sbsize < SBSIZE)
        bp->b_flags |= B_INVAL;
 @@ -457,7 +458,7 @@
    struct partinfo dpart;
    caddr_t base, space;
    int blks;
 -  int error, i, size, ronly, needswap;
 +  int error, i, size, ssize, ronly, needswap;
    int32_t *lp;
    struct ucred *cred;
    extern struct vnode *rootvp;
 @@ -526,6 +527,21 @@
        error = EROFS;      /* XXX what should be returned? */
        goto out2;
    }
 +  /* XXX bread assumes b_blkno in DEV_BSIZE unit. Calculate fsbtosb */
 +
 +  ssize = fs->fs_fsize / fs->fs_nspf;
 +  fs->fs_fsbtosb = fs->fs_fsbtodb;
 +  if (ssize >= size) {
 +      ssize = ssize / size;
 +      for (i = 0; ssize > 1; ssize >>= 1)
 +          i ++;
 +      fs->fs_fsbtosb += i;
 +  } else {
 +      ssize = size / ssize;
 +      for (i = 0; ssize > 1; ssize >>= 1)
 +          i ++;
 +      fs->fs_fsbtosb -= i;
 +  }
    ump = malloc(sizeof *ump, M_UFSMNT, M_WAITOK);
    bzero((caddr_t)ump, sizeof *ump);
    ump->um_fs = fs;
 @@ -584,7 +600,7 @@
    ump->um_dev = dev;
    ump->um_devvp = devvp;
    ump->um_nindir = fs->fs_nindir;
 -  ump->um_bptrtodb = fs->fs_fsbtodb;
 +  ump->um_bptrtodb = fs->fs_fsbtosb;
    ump->um_seqinc = fs->fs_frag;
    for (i = 0; i < MAXQUOTAS; i++)
        ump->um_quotas[i] = NULLVP;
 @@ -1063,9 +1079,10 @@
    }                           /* XXX */
    fs->fs_maxfilesize = mp->um_savedmaxfilesize;   /* XXX */

 -  bp = getblk(mp->um_devvp, SBOFF >> (fs->fs_fshift - fs->fs_fsbtodb),
 +  bp = getblk(mp->um_devvp, SBOFF >> (fs->fs_fshift - fs->fs_fsbtosb),
        (int)fs->fs_sbsize, 0, 0);
    bcopy(fs, bp->b_data, fs->fs_sbsize);
 +  ((struct fs*)bp->b_data)->fs_fsbtosb = 0;                   /* XXX */
  #ifdef FFS_EI
    if (mp->um_flags & UFS_NEEDSWAP)
        ffs_sb_swap(fs, (struct fs*)bp->b_data, 1);
 Only in /mnt/sys/ufs/ffs: ffs_vfsops.c.orig
 diff -ru /usr/src/sys.org/ufs/ffs/fs.h /mnt/sys/ufs/ffs/fs.h
 --- /usr/src/sys.org/ufs/ffs/fs.h  Sun Mar 22 21:02:29 1998
 +++ /mnt/sys/ufs/ffs/fs.h  Mon Jul 13 21:30:54 1998
 @@ -228,7 +228,8 @@
    int32_t  *fs_maxcluster;    /* max cluster in each cyl group */
    int32_t  fs_cpc;        /* cyl per cycle in postbl */
    int16_t  fs_opostbl[16][8]; /* old rotation block list head */
 -  int32_t  fs_sparecon[49];   /* reserved for future constants */
 +  int32_t  fs_fsbtosb;        /* fsbtodb and dbtofsb shift constant */
 +  int32_t  fs_sparecon[48];   /* reserved for future constants */
    time_t   fs_fscktime;       /* last time fsck(8)ed */
    int32_t  fs_contigsumsize;  /* size of cluster summary array */ 
    int32_t  fs_maxsymlinklen;  /* max length of an internal symlink */
 @@ -402,8 +403,8 @@
   * Turn file system block numbers into disk block addresses.
   * This maps file system blocks to device size blocks.
   */
 -#define fsbtodb(fs, b)    ((b) << (fs)->fs_fsbtodb)
 -#define   dbtofsb(fs, b)  ((b) >> (fs)->fs_fsbtodb)
 +#define fsbtodb(fs, b)    ((b) << (fs)->fs_fsbtosb)
 +#define   dbtofsb(fs, b)  ((b) >> (fs)->fs_fsbtosb)

  /*
   * Cylinder group macros to locate things in cylinder groups.
 Only in /mnt/sys/ufs/ffs: fs.h.orig
 diff -ru /usr/src/sys.org/vm/vm_swap.c /mnt/sys/vm/vm_swap.c
 --- /usr/src/sys.org/vm/vm_swap.c  Tue Mar 10 10:37:12 1998
 +++ /mnt/sys/vm/vm_swap.c  Mon Jul 13 21:30:54 1998
 @@ -36,6 +36,7 @@
  #include <sys/proc.h>
  #include <sys/namei.h>
  #include <sys/disklabel.h>
 +#include <sys/dkio.h>
  #include <sys/dmap.h>
  #include <sys/errno.h>
  #include <sys/kernel.h>
 @@ -123,9 +124,9 @@
    struct extent       *swd_ex;
    struct vnode        *swd_vp;
    CIRCLEQ_ENTRY(swapdev)  swd_next;
 +  int         swd_bsize;

  #ifdef SWAP_TO_FILES
 -  int         swd_bsize;
    int         swd_maxactive;
    struct buf      swd_tab;
    struct ucred        *swd_cred;
 @@ -530,6 +531,7 @@
    extern int (**nfsv2_vnodeop_p) __P((void *));
  #endif /* NFS */
    dev_t dev = sdp->swd_dev;
 +  struct partinfo dpart;
    char *name;


 @@ -549,6 +551,17 @@
            error = ENXIO;
            goto bad;
        }
 +      if (VOP_IOCTL(vp, DIOCGPART, (caddr_t)&dpart, FREAD,
 +                          p->p_ucred, p) != 0)
 +          sdp->swd_bsize = DEV_BSIZE;
 +      else
 +          sdp->swd_bsize = dpart.disklab->d_secsize;
 +#if 0 /* (*d_psize)() returns in DEV_BSIZE unit */
 +      if (sdp->swd_bsize > DEV_BSIZE)
 +          nblks /= (sdp->swd_bsize / DEV_BSIZE);
 +      else
 +          nblks *= (DEV_BSIZE / sdp->swd_bsize);
 +#endif
        break;

  #ifdef SWAP_TO_FILES
 @@ -881,7 +894,10 @@
    default:
        panic("swstrategy: vnode type %x", sdp->swd_vp->v_type);
    case VBLK:
 -      bp->b_blkno = bn;
 +      if (sdp->swd_bsize > DEV_BSIZE)
 +          bp->b_blkno = bn / (sdp->swd_bsize / DEV_BSIZE);
 +      else
 +          bp->b_blkno = bn * (DEV_BSIZE / sdp->swd_bsize);
        vp = sdp->swd_vp;
        bp->b_dev = sdp->swd_dev;
        VHOLD(vp);

Responsible-Changed-From-To: kern-bug-people->wrstuden 
Responsible-Changed-By: thorpej 
Responsible-Changed-When: Tue Jan 25 23:47:00 PST 2000 
Responsible-Changed-Why:  
wrstuden is handling large-block disks 
Responsible-Changed-From-To: wrstuden->kern-bug-people
Responsible-Changed-By: [email protected]
Responsible-Changed-When: Mon, 28 Feb 2011 14:56:01 +0000
Responsible-Changed-Why:
Reset responsible field for retired developer.



logout() does not seem to log out a tty logged in with login()

Metadata

  • Number: 17803
  • Originator: dive <[email protected]>
  • Arrived: Fri Aug 02 03:17:00 +0000 2002
  • Last modified:
  • Environment: System: NetBSD eros.endersgame.net 1.6E NetBSD 1.6E (EROS) #360: Sat Jul 27 06:51:10 EDT 2002 [email protected]:/disk2/a/cvs/netbsd/current/src/sys/arch/i386/compile/EROS i386 Architecture: i386 Machine: i386

Description


ssh.com's ssh 3.2.0 sshd2 server uses libutil login() and logout() to log
users in and out of utmp. For as long as I have been running ssh.com's
sshd2, utmp hasn't been updated right (or at all)
at first, up to today, users never got entered into utmp at all when logging
in over ssh. a user could log in, and would never show up in w. this changed
after updating this morning, i believe due to the utmpx stuff. Now when a
user logs in to ssh, they show up in w/who correctly, but when they log out,
they leave a stale utmp entry, and w complains as such. I have tested with a
hand-rolled program to call logout("ttyXX"), and logout never logs out a
tty, no matter what it is called with. For example, I had 'ttyp2' with a
stale utmp entry, and tried logout("ttyp2") which returned 0, logout("p2")
returned 0, logout("/dev/ttyp2") returned 0.
I strings'd /var/run/utmpx and found ttyp2 with a '2' nearby, so tried
logoutx("ttyp2",2,2) (I am almost positive that the second and third
arguments aren't technically right, but there is no man page for logoutx)
and it worked.
To summarize, logout() should log out a tty if it was logged in with
login(). I checked through the ssh 3.2.0 server source, and it does *not*
use loginx, so there is no reason it should have to use logoutx to log the
tty out.

How to repeat


install ssh 3.2.0 from ssh.com on a -current machine. observe problems with
utmp when users log in/out.

Fix


a workaround, albiet a kludgy one, is to make lib/sshsession/wtmp.c call
logoutx((char *)line,2,2) instead of logout((char *)line)

Unformatted


 current as of 20020801

Kernel panic on Alpha at 1.6

Metadata

  • Number: 18983
  • Originator: Kevin P. Neal
  • Arrived: Sat Nov 09 00:58:00 +0000 2002
  • Last modified: Sat Nov 12 16:51:05 +0000 2005
  • Environment: System: NetBSD tesseract.neutralgood.org 1.6 NetBSD 1.6 (TESSERACT) #35: Mon Oct 28 22:44:20 EST 2002 [email protected]:/local/kernel/compile/TESSERACT alpha Architecture: alpha Machine: alpha

Description


I got up this morning to find that my AXPpci33 had crashed. From looking
at the dmesg I'd guess that there was some sort of network problem that
blew up NFS (NFS that was mounted through the automounter, even). 

I do have a crash dump if it is needed.

From my dmesg:

setclock: 50/11/8/1/57/24
nfs server tome:/local: not responding
nfs server tome:/usr: not responding
nfs server tome:/var: not responding

CPU 0: fatal kernel trap:

CPU 0    trap entry = 0x4 (unaligned access fault)
CPU 0    a0         = 0xdeadbeefdeadbeef
CPU 0    a1         = 0x28
CPU 0    a2         = 0x3
CPU 0    pc         = 0xfffffc0000351e20
CPU 0    ra         = 0xfffffc0000448f38
CPU 0    pv         = 0xfffffc0000351da0
CPU 0    curproc    = 0xfffffc00021ecba0
CPU 0        pid = 542, comm = find

panic: trap
syncing disks... tlp0: receive ring overrun
tlp1: receive ring overrun
panic: lockmgr: locking against myself

dumping to dev 8,9 offset 298595



How to repeat



I really don't know. 


fsck doesn't "dirty" file systems with weird errors

Metadata

  • Number: 2447
  • Originator: Chris G. Demetriou <[email protected]>
  • Arrived: Mon May 20 12:20:15 +0000 1996
  • Last modified: Mon Jun 05 22:15:05 +0000 2000
  • Environment: System: NetBSD bunnahabhain.pdl.cs.cmu.edu 1.1B NetBSD 1.1B (BUNNY) #41: Sun May 19 17:34:11 EDT 1996 [email protected]:/usr/src/sys/arch/alpha/compile/BUNNY alpha

Description


    If fsck -p finds an 'unexpected inconsistency' in a file system,
    it doesn't mark the file system as dirty.  I'd say that it should.


How to repeat



    clri an inode on a file system.  unmount it.  run 'fsck -fp' then
    run 'fsck'.  You'll get messages like:

    balvenie# fsck -fp /dev/rsd2a
    /dev/rsd2a: UNALLOCATED  I=3302  OWNER=root MODE=0
    /dev/rsd2a: SIZE=0 MTIME=Dec 31 19:00 1969 
    /dev/rsd2a: NAME=/root/.klogin

    /dev/rsd2a: UNEXPECTED INCONSISTENCY; RUN fsck_ffs MANUALLY.
    balvenie# fsck /dev/rsd2a 
    ** /dev/rsd2a
    ** File system is clean; not checking

    This isn't necessarily a bug, however, it seems ... a bit odd
    for fsck to discard useful information like this, especially
    when the information points to a problem which could cause
    file system corruption or a system panic in the future.


Fix


    None supplied.

Audit trail



From: der Mouse <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: Re:  bin/2447: clean file systems with 'unexpected inconsistencies' not dirtied
Date: Tue, 21 May 1996 06:22:31 -0400

 >  If fsck -p finds an 'unexpected inconsistency' in a file system,
 >  it doesn't mark the file system as dirty.  I'd say that it should.

 I'm not so sure; if the filesystem is clean (well, is marked clean),
 fsck -p won't even run on it.  If you use -f with -p, well, you should
 also use -f with the manual run, no?  (I Hate Clean Bits...I Hate Clean
 Bits...I Hate Clean Bits... :-)

 On a side note, I would say that clri _definitely_ should dirty the
 filesystem it operates on.

                    der Mouse

                [email protected]

Adding user quota support to mail.local

Metadata

  • Number: 4239
  • Originator: Jukka Marin <[email protected]>
  • Arrived: Wed Oct 08 02:05:01 +0000 1997
  • Last modified:
  • Environment: NetBSD 1.2 and -current

Description


    mail.local doesn't check the user quota, so mail boxes can grow
    and fill the entire disk partition.  The supplied fix adds a
    new command line option to mail.local to enable quota checking.

How to repeat


    Send huge mail messages -> the spool partition fills up.

ISA com driver no longer groks B0 as hangup

Metadata

  • Number: 4123
  • Originator: John Kohl <[email protected]>
  • Arrived: Thu Sep 18 22:35:01 +0000 1997
  • Last modified: Thu Feb 11 12:40:38 +0000 1999
  • Environment: System: NetBSD kolvir.arlington.ma.us 1.2G NetBSD 1.2G (KOLVIR) #22: Fri Sep 19 01:09:15 EDT 1997 [email protected]:/u4/sandbox/src/sys/arch/i386/compile/KOLVIR i386

Description


    The latest changes to the com driver to handle multiple
frequency multipliers seems to have broken the POSIX requirement that a
baud rate of B0 mean "hang up".  comparam() rejects a termios with a
speed of B0.


How to repeat



#include <termios.h>

main()
{
    struct termios t;

    tcgetattr(0, &t);
    cfsetispeed(&t, 0);
    cfsetospeed(&t, B0);
    if (tcsetattr(0, TCSANOW, &t) == -1)
    perror("tcsetattr");
}


Fix


    There's an #if 0 in comrate() which when converted to #if 1
seems to do the trick.  I'm not sure if that's quite right, though ...

Audit trail


Responsible-Changed-From-To: kern-bug-people->kleink 
Responsible-Changed-By: jtk 
Responsible-Changed-When: Thu Feb 11 04:40:07 PST 1999 
Responsible-Changed-Why:  
assigning to Klaus for standards comments 

From: "Charles M. Hannum" <[email protected]>
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: kern/4123
Date: Wed, 28 Apr 1999 19:11:26 -0400 (EDT)

 I thought I had already appended this to the PR.

 One might assume that since I specifically turned that code off, that
 just turning it back on is not the right thing to do.

 As it turns out, there are multiple problems with it:

 * Turning on DTR on a baud rate change is clearly wrong; the `else'
   clause *must* be omitted.

 * The interaction between B0 and TIOCSDTR/TIOCCDTR is not well
   defined.

 * It's not clear whether `hang up' in the POSIX text means to cycle
   DTR, or to just leave it turned off.

 * What happens to the rest of the settings?  It's obviously not
   correct to *just* set the baud rate registers to some random value.
   Does hanging up mean that we should stop receiving data?  Stop
   sending?  Both?  The code doesn't deal with this.

 I asked Klaus to define the semantics for me more precisely so that I
 could implement it, but I don't think this ever happened.


PR3123 test program makes 68060 panic if compiled with old gcc

Metadata

  • Number: 4332
  • Originator: Ignatios Souvatzis <[email protected]>
  • Arrived: Fri Oct 24 05:50:02 +0000 1997
  • Last modified: Thu Jan 17 20:23:57 +0000 2002
  • Environment: NetBSD/Amiga on 68060

Description


If you run the test program from PR 3123, compiled with the faulty gcc, 
it will not get a SIGBUS, but panic the machine.

The FSLW reported by the panic says "invalid root level pointer", which is 
very fishy, as the virtual address in error is in the user stack area (and in
its first page, which should be there as soon as the process has started to
run).


How to repeat


    cc -o trampoline trampoline.c
    ./trampoline

Audit trail


Responsible-Changed-From-To: gnats-admin->is 
Responsible-Changed-By: is 
Responsible-Changed-When: Fri Oct 24 06:26:39 PDT 1997 
Responsible-Changed-Why:  
I'm looking into this.  

The HPN patch for OpenSSH breaks on SOCKS proxies

Metadata

  • Number: 45049
  • Arrived: Fri Jun 10 21:10:00 +0000 2011
  • Last modified: Fri Oct 07 05:00:03 +0000 2011
  • Environment: System: NetBSD rst.defora.lan 5.1_STABLE NetBSD 5.1_STABLE (GENERIC) #0: Sun Apr 24 04:27:02 UTC 2011 [email protected]:/home/i386/obj/sys/arch/i386/compile/GENERIC i386 Architecture: i386 Machine: i386

Description


I am currently using OpenSSH over SOCKS proxies, as provided by existing
OpenSSH connections (using the "DynamicForward" mechanism). When using
the default SSH binaries from NetBSD base (on both client and server
side) I am observing difficulties after a few minutes of use with
interactive sessions:
- data is sent properly from the client to the server
- data is received from the server to the client, but never displayed on
  the terminal
- when this occurs, the ssh client forwarding the connection outputs the
  following error: "rcvd too much data"

This behavior has already been reported publicly, like found here in the
Gentoo bug reporting system:
http://bugs.gentoo.org/197182

During the ensueing debugging process, the HPN patch was found to be the
culprit. This patch seems to be applied by default on NetBSD; see
src/crypto/dist/ssh/HPN-README, and the output of "ssh -v" for instance:

Remote protocol version 2.0, remote software version OpenSSH_5.0
NetBSD_Secure_Shell-20080403-hpn13v1
debug1: match: OpenSSH_5.0 NetBSD_Secure_Shell-20080403-hpn13v1 pat
OpenSSH*

Replacing the SSH client used to forward connections over SOCKS with one
built from pkgsrc/security/openssh (without the "hpn-patch" option set)
seems to work-around the problem.

Alternatively, using the SSH client from base with the (undocumented
except in HPN-README) "HPNDisabled=yes" option seems to do the trick
too.


How to repeat


first:
$ ssh -D 9050 some.remote.host

then, with pkgsrc's net/tsocks configured:
$ cat /usr/pkg/etc/tsocks.conf
local = 192.168.0.0/255.255.0.0
server = 127.0.0.1
server_type = 5
server_port = 9050
$ tsocks ssh some.other.host

after a while, the connection seems to break, and error messages appear
on the first client (providing the SOCKS proxy).


Fix


As mentioned above, the "HPNDisabled" option can be enabled to
workaround the problem.

Unfortunately, the HPN project doesn't seem to have enough resources to
maintain its patch properly:
http://www.psc.edu/networking/projects/hpn-ssh/


Audit trail


From: Pierre Pronchery <[email protected]>
To: [email protected]
Cc: 
Subject: Re: bin/45049: The HPN patch for OpenSSH breaks on SOCKS proxies
Date: Fri, 10 Jun 2011 23:12:22 +0200

 See also:
 http://mail-index.netbsd.org/netbsd-users/2010/06/13/msg006406.html

 Cheers,
 -- 
 khorben

From: Richard Hansen <[email protected]>
To: [email protected]
Cc: 
Subject: Re: bin/45049: The HPN patch for OpenSSH breaks on SOCKS proxies
Date: Thu, 06 Oct 2011 23:50:52 -0400

 I am also experiencing this bug.

  From the bottom of the HPN web site
 <http://www.psc.edu/networking/projects/hpn-ssh/>:

      Recent problems with buffer_append_space in HPN-SSH.
      If you are experiencing disconnects due to a failure in
      buffer_append_space please let us know.  We're currently tracking
      some problems with this and we're trying to gather more information
      to help resolve it.  You may want to try using
      -oHPNBufferSize=16384 to restrict the growth of the buffer.  Let us
      know if that helps.

 I did try setting HPNBufferSize to 16384 and it did make the problem go 
 away.

ukbd: new useful mappings from usb to at keycodes

Metadata

  • Number: 37683
  • Arrived: Thu Jan 03 19:15:01 +0000 2008
  • Last modified: Tue Jan 20 08:43:46 +0000 2009
  • Environment: System: NetBSD ficus 4.99.40 NetBSD 4.99.40 (FICUS) #90: Thu Jan 3 19:57:17 CET 2008 troot@ficus:/usr/obj/sys/arch/i386/compile/FICUS i386 Architecture: i386 Machine: i386

Description


The attached patch add mappings from usb to AT keycodes for the L-keys and some
other keys found on e.g. the sun type 6 usb keyboards.
Extended AT-keycodes where found in atKeynames.h.

This patch is required when using xorg in 'standard' keyboard protocol.

Fix


--- sys/dev/usb/ukbd.c~ 2008-01-03 10:19:57.000000000 +0100
+++ sys/dev/usb/ukbd.c  2008-01-03 19:55:33.000000000 +0100
@@ -119,11 +119,11 @@
     0x7f, 0xd2, 0xc7, 0xc9, 0xd3, 0xcf, 0xd1, 0xcd, /* 48 - 4f */
     0xcb, 0xd0, 0xc8, 0x45, 0xb5, 0x37, 0x4a, 0x4e, /* 50 - 57 */
     0x9c, 0x4f, 0x50, 0x51, 0x4b, 0x4c, 0x4d, 0x47, /* 58 - 5f */
-    0x48, 0x49, 0x52, 0x53, 0x56, 0xdd,   NN, 0x59, /* 60 - 67 */
+    0x48, 0x49, 0x52, 0x53, 0x56, 0xdd, 0x84, 0x59, /* 60 - 67 */
     0x5d, 0x5e, 0x5f,   NN,   NN,   NN,   NN,   NN, /* 68 - 6f */
-      NN,   NN,   NN,   NN,   NN,   NN,   NN,   NN, /* 70 - 77 */
-      NN,   NN,   NN,   NN,   NN,   NN,   NN,   NN, /* 78 - 7f */
-      NN,   NN,   NN,   NN,   NN, 0x7e,   NN, 0x73, /* 80 - 87 */
+      NN,   NN,   NN,   NN, 0x8f, 0x88, 0x8b, 0x8d, /* 70 - 77 */
+    0x89, 0x8a, 0x8c, 0x92, 0x8e, 0x90, 0x91, 0x85, /* 78 - 7f */
+    0x87, 0x86,   NN,   NN,   NN, 0x7e,   NN, 0x73, /* 80 - 87 */
     0x70, 0x7d, 0x79, 0x7b, 0x5c,   NN,   NN,   NN, /* 88 - 8f */
       NN,   NN, 0x78, 0x77, 0x76,   NN,   NN,   NN, /* 90 - 97 */
       NN,   NN,   NN,   NN,   NN,   NN,   NN,   NN, /* 98 - 9f */


Audit trail



Responsible-Changed-From-To: kern-bug-people->tron
Responsible-Changed-By: [email protected]
Responsible-Changed-When: Wed, 30 Jan 2008 21:22:17 +0000
Responsible-Changed-Why:
I'll handle this PR.


State-Changed-From-To: open->feedback
State-Changed-By: [email protected]
State-Changed-When: Sat, 02 Feb 2008 15:10:09 +0000
State-Changed-Why:
The extra keys are neither mentioned in the USB-HID spec nor in Microsoft's
specification. Do you know of any technical document which lists the codes?


From: Anthony Mallet <[email protected]>
To: [email protected]
Cc: [email protected],
    [email protected],
    [email protected]
Subject: Re: kern/37683 (ukbd: new useful mappings from usb to at keycodes)
Date: Mon, 4 Feb 2008 09:34:15 +0100

 [email protected] writes:
 | Synopsis: ukbd: new useful mappings from usb to at keycodes
 | 
 | State-Changed-From-To: open->feedback
 | State-Changed-By: [email protected]
 | State-Changed-When: Sat, 02 Feb 2008 15:10:09 +0000
 | State-Changed-Why:
 | The extra keys are neither mentioned in the USB-HID spec nor in Microsoft's
 | specification. Do you know of any technical document which lists the codes?

 Hi,

 Yes, that's a kind of hack from Xorg (and XFree). Those "extended keys"
 are defined in atKeynames.h (e.g. /usr/pkg/include/xorg/atKeynames.h)
 because PS/2 keyboards cannot generate such events.

 Xorg says:
  * Fake 'scancodes' in the following ranges are generated for 2-byte
  * codes not handled elsewhere.  These correspond to most extended keys
  * on so-called "Internet" keyboards:
  *      0x79-0x93

 This file is not used when using the 'standard' xorg keyboard protocol
 and the translation is done by ukbd (hence this PR). OpenBSD has a
 similar patch for their driver (their cvsweb seem to be down right now, I
 cannot find the rev number but it's in ukbd.c too, from
 M. Herrb). FreeBSD did also something similar in rev. 1.46 of ukbd.c,
 although I don't know where their mappings come from.

 Note that the atKeyname file is used inside the bsd kbd driver module
 (see PR/37674).

State-Changed-From-To: feedback->open
State-Changed-By: [email protected]
State-Changed-When: Mon, 04 Feb 2008 08:42:07 +0000
State-Changed-Why:
Feedback was provided.


From: Anthony Mallet <[email protected]>
To: [email protected]
Cc: [email protected],
    [email protected],
    [email protected]
Subject: Re: kern/37683 (ukbd: new useful mappings from usb to at keycodes)
Date: Mon, 4 Feb 2008 09:51:25 +0100

 Anthony Mallet writes:
 |  | The extra keys are neither mentioned in the USB-HID spec nor in Microsoft's
 |  | specification. Do you know of any technical document which lists the codes?

 Sorry, forgot to mention this:

 The USB keycode is defined in e.g. the microsoft document mentioned in
 ukbd.c (page 2). That's the mapping to an AT keycode that is not standard
 and defined by Xorg.

From: Martin Husemann <[email protected]>
To: [email protected]
Cc: 
Subject: Re: kern/37683 (ukbd: new useful mappings from usb to at keycodes)
Date: Mon, 4 Feb 2008 11:00:35 +0100

 FWIW, I think we should realy follow Michael Lorenz' suggestion and modify
 all wskbd drivers to only pass raw USB keycodes up. And get rid of the
 ***** back and forth mappings in X.

 Martin

From: Matthias Drochner <[email protected]>
To: Anthony Mallet <[email protected]>
Cc: [email protected], [email protected], [email protected],
    [email protected]
Subject: Re: kern/37683 (ukbd: new useful mappings from usb to at keycodes) 
Date: Tue, 05 Feb 2008 18:47:14 +0100

 [email protected] said:
 > that's a kind of hack from Xorg (and XFree). Those "extended keys" are
 > defined in atKeynames.h (e.g. /usr/pkg/include/xorg/atKeynames.h)
 > because PS/2 keyboards cannot generate such events. 

 I see -- imo it makes sense to follow the examples.

 > OpenBSD has a similar patch for their driver (their cvsweb seem to be
 > down right now, I cannot find the rev number but it's in ukbd.c too,
 > from M. Herrb)

 So why does your patch differ from the OpenBSD scancodes?

 > FreeBSD did also something similar in rev. 1.46 of ukbd.c,
 > although I don't know where their mappings come from.

 FreeBSD uses another mapping mechanism appearently which I didn't
 look closer at (not just using the MSB as a marker for extended
 scancodes).

 best regards
 Matthias




 -------------------------------------------------------------------
 -------------------------------------------------------------------
 Forschungszentrum Juelich GmbH
 52425 Juelich

 Sitz der Gesellschaft: Juelich
 Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
 Vorsitzende des Aufsichtsrats: MinDir'in Baerbel Brumme-Bothe
 Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
 Dr. Ulrich Krafft (stellv. Vorsitzender), Dr. Sebastian M. Schmidt
 -------------------------------------------------------------------
 -------------------------------------------------------------------

From: Matthias Drochner <[email protected]>
To: [email protected]
Cc: [email protected], [email protected], [email protected],
    [email protected]
Subject: Re: kern/37683 (ukbd: new useful mappings from usb to at keycodes) 
Date: Tue, 05 Feb 2008 18:53:45 +0100

 [email protected] said:
 > we should realy follow Michael Lorenz' suggestion and modify
 >  all wskbd drivers to only pass raw USB keycodes up

 So this would mean to translate at to USB codes in pckbd.c?

 best regards
 Matthias




 -------------------------------------------------------------------
 -------------------------------------------------------------------
 Forschungszentrum Juelich GmbH
 52425 Juelich

 Sitz der Gesellschaft: Juelich
 Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
 Vorsitzende des Aufsichtsrats: MinDir'in Baerbel Brumme-Bothe
 Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
 Dr. Ulrich Krafft (stellv. Vorsitzender), Dr. Sebastian M. Schmidt
 -------------------------------------------------------------------
 -------------------------------------------------------------------

From: Martin Husemann <[email protected]>
To: [email protected]
Cc: 
Subject: Re: kern/37683 (ukbd: new useful mappings from usb to at keycodes)
Date: Tue, 5 Feb 2008 21:03:58 +0100

 On Tue, Feb 05, 2008 at 06:55:01PM +0000, Matthias Drochner wrote:
 >  So this would mean to translate at to USB codes in pckbd.c?

 Yes - so wsmux always receives USB codes, no matter what driver is underneath.
 Think of a mac with adb + usb keyboard, or a sparc wit sun + usb. Both of
 those setups have no chance of working with X right now. (only w/o wsmux)

 Martin

From: Anthony Mallet <[email protected]>
To: [email protected]
Cc: [email protected],
    [email protected],
    [email protected]
Subject: Re: kern/37683 (ukbd: new useful mappings from usb to at keycodes) 
Date: Wed, 6 Feb 2008 20:24:47 +0100

 Matthias Drochner writes:
 |  > OpenBSD has a similar patch for their driver (their cvsweb seem to be
 |  > down right now, I cannot find the rev number but it's in ukbd.c too,
 |  > from M. Herrb)
 |  
 |  So why does your patch differ from the OpenBSD scancodes?

 I have not a real answer yet. First I mapped more keys than in OpenBSD:
 the L keys plus the Help, Power, AudioMute et al. keys.

 Second, I'll check with Matthieu Herrb and try to understand where the
 OpenBSD scancode come from. What he told me at the moment is that there
 is a magic offset of 8 that is added sowhere between ukbd and xkb...

 I'll keep you informed as soon as I have a more precise answer.

State-Changed-From-To: open->feedback
State-Changed-By: [email protected]
State-Changed-When: Tue, 20 May 2008 07:51:40 +0000
State-Changed-Why:
Any update on this? Did you get an answer from Matthieu Herrb?


From: Anthony Mallet <[email protected]>
To: [email protected]
Cc: [email protected],
    [email protected],
    [email protected]
Subject: Re: kern/37683 (ukbd: new useful mappings from usb to at keycodes)
Date: Thu, 22 May 2008 21:04:46 +0200

 [email protected] writes:
 | State-Changed-From-To: open->feedback
 | State-Changed-By: [email protected]
 | State-Changed-When: Tue, 20 May 2008 07:51:40 +0000
 | State-Changed-Why:
 | Any update on this? Did you get an answer from Matthieu Herrb?

 Not really. At the time when I asked, he couldn't tell me more than
 "there is a magic offset of 8 somewhere". What is strange is that I
 couldn't find this offset elsewhere in the scancodes. But I must admit
 that I have had hard times following the trajectory of these codes all
 the way long from my keyboard to my X windows ...

 Anyway, I have absolutely no objection if you think that it's better to
 use codes from OpenBSD's patch. What I would like mostly is that my keys
 would generate some keycode, no matter the value :)

State-Changed-From-To: feedback->open
State-Changed-By: [email protected]
State-Changed-When: Thu, 22 May 2008 20:16:27 +0000
State-Changed-Why:
Feedback was provided.


Responsible-Changed-From-To: tron->kern-bug-people
Responsible-Changed-By: [email protected]
Responsible-Changed-When: Tue, 20 Jan 2009 08:43:46 +0000
Responsible-Changed-Why:
It is unlikely that I'm going to fix this PR.



Race condition in the kernel log() and printf() functions

Metadata

  • Number: 3840
  • Originator: Rob Black <[email protected]>
  • Arrived: Tue Jul 08 13:05:01 +0000 1997
  • Last modified:

Description


If either the log() or printf() function is called within a routine which
is capable of interrupting spltty then there is a potential race
condition if the console output has been redirected with ioctl TIOCCONS
(or anything else which sets the constty variable). The culprit is a
line in putchar() in kern/subr_prf.c which sets the TOTTY flag. This
redirects any output flagged as TOCONS to the constty device. It is
not safe to use the tty subsystem under these circumstances. These
conditions are sufficient to cause a race in printf(). To cause a race
in log() requires the additional condition that syslogd is not running
(if the log device is open then log() only writes to that and not to
the console - except via syslogd of course).

Note for anyone who is interested: this problem also affects FreeBSD.


How to repeat


Its a race condition. Run xconsole, add suitable debugging and wait.


Fix


A partial fix is as follows. This patch just disables the setting of the
TOTTY flag. The output will normally be duplicated via syslogd. If syslogd
is not running then the output is dumped to the screen regardless of the
setting of constty so that no messages are lost. This fix is a bit of a
hack but it prevents the race and a proper fix is a lot of work. It is
also arguable that the TOLOG section should be guarded by splhigh().

*** subr_prf.c  Tue Jul  8 20:40:42 1997
--- subr_prf.c.new      Tue Jul  8 20:47:07 1997
***************
*** 544,550 ****
                constty = NULL;
        if ((flags & TOCONS) && tp == NULL && constty) {
                tp = constty;
-               flags |= TOTTY;
        }
        if ((flags & TOTTY) && tp && tputchar(c, tp) < 0 &&
            (flags & TOCONS) && tp == constty)
--- 544,549 ----
***************
*** 560,566 ****
                if (mbp->msg_bufx < 0 || mbp->msg_bufx >= MSG_BSIZE)
                        mbp->msg_bufx = 0;
        }
!       if ((flags & TOCONS) && constty == NULL && c != '\0')
                (*v_putc)(c);
  }

--- 559,565 ----
                if (mbp->msg_bufx < 0 || mbp->msg_bufx >= MSG_BSIZE)
                        mbp->msg_bufx = 0;
        }
!       if ((flags & TOCONS) && (constty == NULL || !log_open) && c != '\0')
                (*v_putc)(c);
  }


[dM] chmod(1)/setmode(3) symbolic mode improvement

Metadata

  • Number: 2689
  • Originator: der Mouse <[email protected]>
  • Arrived: Mon Aug 12 13:35:02 +0000 1996
  • Last modified: Mon Jun 05 22:16:02 +0000 2000
  • Environment: Any

Description


    These patches make setmode(3), and therefore chmod(1), accept
    symbolic modes such as are printed by ls(1), with the ability
    to "don't-care" out bits by replacing characters with dots.
    chmod.c needed touching because with these changes, a mode
    argument can begin with --, which confuses getopt(3).

How to repeat


    Wish you could take a mode from ls and hand it to chmod.
    Notice you can't.
    Sigh.

Fix


    Here's what I've done.  I also did some fiddle edits in
    chmod.1, mostly replacing "``foo''" with ".Dq foo" for various
    values of foo.

--- OLD/bin/chmod/chmod.1   Thu Jan  1 00:00:00 1970
+++ NEW/bin/chmod/chmod.1   Thu Jan  1 00:00:00 1970
@@ -132,7 +132,13 @@
 .Pp
 The symbolic mode is described by the following grammar:
 .Bd -literal -offset indent
-mode         ::= clause [, clause ...]
+mode         ::= ls_mode | op_mode
+ls_mode      ::= ls_r ls_w ls_xs ls_r ls_w ls_xs ls_r ls_w ls_xt
+ls_r         ::= r | \- | .
+ls_w         ::= w | \- | .
+ls_xs        ::= x | s | S | \- | .
+ls_xt        ::= x | t | T | \- | .
+op_mode      ::= clause [, clause ...]
 clause       ::= [who ...] [action ...] last_action
 action       ::= op [perm ...]
 last_action  ::= op [perm ...]
@@ -141,13 +147,35 @@
 perm         ::= r | s | t | w | x | X | u | g | o
 .Ed
 .Pp
+If an
+.Ar ls_mode
+is used, it is simply a symbolic mode such as that printed by
+.Xr ls 1
+with the first character (which indicates the file type) stripped,
+and possibly with some characters replaced by dots, indicating that
+.Nm chmod
+should not change the bit(s) corresponding to that character.  (When using
+this style of symbolic mode, there is no way to, for example, specify the
+group-execute bit's state without specifying the setgid bit's state as well.
+Affecting one of a pair of bits that use the same character without
+affecting the other is simply not possible with an
+.Ar ls_mode . )
+.Pp
 The
 .Ar who
-symbols ``u'', ``g'', and ``o'' specify the user, group, and other parts
+symbols
+.Dq u ,
+.Dq g ,
+and
+.Dq o
+specify the user, group, and other parts
 of the mode bits, respectively.
 The
 .Ar who
-symbol ``a'' is equivalent to ``ugo''.
+symbol
+.Dq a
+is equivalent to
+.Dq ugo .
 .Pp
 .ne 1i
 The
@@ -170,9 +198,13 @@
 execute/search bits are set in the original (unmodified) mode.
 Operations with the
 .Ar perm
-symbol ``X'' are only meaningful in conjunction with the
+symbol
+.Dq X
+are only meaningful in conjunction with the
 .Ar op
-symbol ``+'', and are ignored in all other cases.
+symbol
+.Dq + ,
+and are ignored in all other cases.
 .It u
 The user permission bits in the mode of the original file.
 .It g
@@ -188,7 +220,9 @@
 .It +
 If no value is supplied for
 .Ar perm ,
-the ``+'' operation has no effect.
+the
+.Dq +
+operation has no effect.
 If no value is supplied for
 .Ar who ,
 each permission bit specified in
@@ -203,7 +237,9 @@
 .It \&\-
 If no value is supplied for
 .Ar perm ,
-the ``\-'' operation has no effect.
+the
+.Dq \-
+operation has no effect.
 If no value is supplied for
 .Ar who ,
 each permission bit specified in
@@ -240,15 +276,20 @@
 order specified.
 .Pp
 Operations upon the other permissions only (specified by the symbol
-``o'' by itself), in combination with the
+.Dq o
+by itself), in combination with the
 .Ar perm
-symbols ``s'' or ``t'', are ignored.
+symbols
+.Dq s
+or
+.Dq t ,
+are ignored.
 .Sh EXAMPLES
 .Bl -tag -width "u=rwx,go=u-w" -compact
 .It Li 644
 make a file readable by anyone and writable by the owner only.
 .Pp
-.It Li go-w
+.It Li go\-w
 deny write permission to group and others.
 .Pp
 .It Li =rw,+X
@@ -261,13 +302,18 @@
 .Pp
 .It Li 755
 .It Li u=rwx,go=rx
-.It Li u=rwx,go=u-w
+.It Li u=rwx,go=u\-w
 make a file readable/executable by everyone and writable by the owner only.
 .Pp
+.It Li rw.r\-.\-\-.
+make a file readable by owner and group, writeable by owner only, and do
+not touch the execute, set-ID, or sticky bits.
+.Pp
 .It Li go=
+.It Li ...\-\-\-\-\-\-
 clear all mode bits for group and others.
 .Pp
-.It Li g=u-w
+.It Li g=u\-w
 set the group bits equal to the user bits, but clear the group write bit.
 .El
 .Sh BUGS
@@ -293,5 +339,7 @@
 symbols
 .Dq t
 and
-.Dq X
-which are not included in that standard.
+.Dq X ,
+and the
+.Ar ls_mode
+specifications, which are not included in that standard.
--- OLD/bin/chmod/chmod.c   Thu Jan  1 00:00:00 1970
+++ NEW/bin/chmod/chmod.c   Thu Jan  1 00:00:00 1970
@@ -125,6 +125,14 @@
 done:  argv += optind;
    argc -= optind;

+   /* If we have a mode beginning with --, like --x--x--x,
+      getopt will mistake it for a -- end-of-flags indicator. */
+   if ( (argv[-1][0] == '-') &&
+        (argv[-1][1] == '-') &&
+        (strlen(argv[-1]) == 9) ) {
+       argc ++;
+       argv --;
+   }
    if (argc < 2)
        usage();

--- OLD/lib/libc/gen/setmode.c  Thu Jan  1 00:00:00 1970
+++ NEW/lib/libc/gen/setmode.c  Thu Jan  1 00:00:00 1970
@@ -168,6 +168,74 @@

 #define    STANDARD_BITS   (S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO)

+static int ls_mode_p(const char *s, int *setp, int *clrp)
+{
+ /* N, ch1, set1, clr1, ch2, set2, clr2, ... chN, setN, clrN,
+    repeated once per character in the mode.  N==0 signals end. */
+ static int prog[] = { 3, 'r', S_IRUSR, 0,
+             '-', 0, S_IRUSR,
+             '.', 0, 0,
+              3, 'w', S_IWUSR, 0,
+             '-', 0, S_IWUSR,
+             '.', 0, 0,
+              5, 'x', S_IXUSR, S_ISUID,
+             's', S_IXUSR|S_ISUID, 0,
+             'S', S_ISUID, S_IXUSR,
+             '-', 0, S_IXUSR|S_ISUID,
+             '.', 0, 0,
+              3, 'r', S_IRGRP, 0,
+             '-', 0, S_IRGRP,
+             '.', 0, 0,
+              3, 'w', S_IWGRP, 0,
+             '-', 0, S_IWGRP,
+             '.', 0, 0,
+              5, 'x', S_IXGRP, S_ISGID,
+             's', S_IXGRP|S_ISGID, 0,
+             'S', S_ISGID, S_IXGRP,
+             '-', 0, S_IXGRP|S_ISGID,
+             '.', 0, 0,
+              3, 'r', S_IROTH, 0,
+             '-', 0, S_IROTH,
+             '.', 0, 0,
+              3, 'w', S_IWOTH, 0,
+             '-', 0, S_IWOTH,
+             '.', 0, 0,
+              5, 'x', S_IXOTH, S_ISTXT,
+             't', S_IXOTH|S_ISTXT, 0,
+             'T', S_ISTXT, S_IXOTH,
+             '-', 0, S_IXOTH|S_ISTXT,
+             '.', 0, 0,
+              0 };
+ int *pp;
+ int n;
+ int mset;
+ int mclr;
+ int bad;
+
+ pp = &prog[0];
+ mset = 0;
+ mclr = 0;
+ while (1)
+  { n = *pp++;
+    if (n == 0)
+     { if (*s) return(0);
+       *setp = mset;
+       *clrp = mclr;
+       return(1);
+     }
+    bad = 1;
+    for (;n>0;n--,pp+=3)
+     { if (*s == pp[0])
+   { mset |= pp[1];
+     mclr |= pp[2];
+     bad = 0;
+   }
+     }
+    if (bad) return(0);
+    s ++;
+  }
+}
+
 void *
 setmode(p)
    register char *p;
@@ -178,6 +246,7 @@
    sigset_t sigset, sigoset;
    mode_t mask;
    int equalopdone, permXbits, setlen;
+   int permset, permclr;

    if (!*p)
        return (NULL);
@@ -217,6 +286,15 @@
                return (NULL);
            }
        ADDCMD('=', (STANDARD_BITS|S_ISTXT), perm, mask);
+       return (saveset);
+   }
+
+   /*
+    * Check for ls-style symbolic modes.
+    */
+   if (ls_mode_p(p,&permset,&permclr)) {
+       ADDCMD('+', STANDARD_BITS|S_ISTXT, permset, 0);
+       ADDCMD('-', STANDARD_BITS|S_ISTXT, permclr, 0);
        return (saveset);
    }


                    der Mouse

                [email protected]
            01 EE 31 F6 BB 0C 34 36  00 F3 7C 5A C1 A0 67 1D

Audit trail



From: Michael Graff <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: Re: bin/2689: [dM] chmod(1)/setmode(3) symbolic mode improvement
Date: 13 Aug 1996 00:38:29 -0400

 der Mouse <[email protected]> writes:

 >  These patches make setmode(3), and therefore chmod(1), accept
 >  symbolic modes such as are printed by ls(1), with the ability
 >  to "don't-care" out bits by replacing characters with dots.
 >  chmod.c needed touching because with these changes, a mode
 >  argument can begin with --, which confuses getopt(3).
 > >How-To-Repeat:
 >  Wish you could take a mode from ls and hand it to chmod.
 >  Notice you can't.
 >  Sigh.

 What is the difference between doing this with, say, symbolic changes
 like chmod u+rwX,g+rwX?

 These do the same thing, and are standard sort of critters.  I'd hate to
 break posix unless there is a good reason to do so.

 STANDARDS
      The chmod utility is expected to be IEEE Std1003.2 (``POSIX.2'') compati-
      ble with the exception of the perm symbols ``t'' and ``X'' which are not
      included in that standard.

 --Michael

Unformatted


        $NetBSD: chmod.c,v 1.12 1995/03/21 09:02:09 cgd Exp $
        $NetBSD: chmod.1,v 1.8 1995/03/21 09:02:07 cgd Exp $
        $NetBSD: setmode.c,v 1.13 1996/04/03 19:49:01 jtc Exp $

union file system botches file locks after copy-on-write operations

Metadata

  • Number: 2826
  • Originator: John Kohl <[email protected]>
  • Arrived: Wed Oct 09 17:50:01 +0000 1996
  • Last modified:
  • Environment: System: NetBSD pattern 1.2 NetBSD 1.2 (PATTERN) #102: Thu Sep 12 18:46:38 EDT 1996 jtk@pattern:/u4/sandbox/src/sys/arch/i386/compile/PATTERN i386

Description


    The union file system botches file locking if a file which
exists only in the lower layer is open for read and read-locked (via
fcntl(2)) while another process opens it for write.  The union vnode is
modified by a copy-on-write operation which creates an upper-layer
shadow of the file.

The lower-layer file remains read-locked by the original locker, yet
when it closes the file descriptor or exits, the lock is not cleaned out
because the union file system code redirects locking operations to the
fresh upper-layer copy of the file.

The lower-layer file then remains read-locked until the system is
rebooted.


How to repeat


Here is a sample program which you can compile twice, once with -DWLOCK
and once without.  Run the non-write version in one window, pause at its
prompt, and then run the write version in another window.
exit them both.

Run the write version again--it will indicate that a now-nonexistent
process ID still has the file read-locked.

#include <fcntl.h>
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>

main(argc, argv)
    int argc;
    char **argv;
{
    FILE *f;
    int fd;
    struct flock lock;
    char foo[8192];

    if (argc != 2) {
        printf("usage: %s tmpfile\n", argv[0]);
        exit(1);
    }
#ifdef WLOCK
    f = fopen(argv[1], "a+");
#else
    f = fopen(argv[1], "r");
#endif
    if (!f) {
        perror(argv[1]);
        exit(1);
    }
    printf("F_UNLCK == %d\n", F_UNLCK);
    if (fcntl(fileno(f), F_GETLK, (void *)&lock) == 0) {
        printf("lock held by pid %d type %d\n", lock.l_pid,
               lock.l_type);
    }
#ifdef WLOCK
    lock.l_type = F_WRLCK;
#else
    lock.l_type = F_RDLCK;
#endif
    lock.l_whence = SEEK_SET;
    lock.l_start = 0;
    lock.l_len = 0;
    lock.l_pid = 0;
    if (fcntl(fileno(f), F_SETLK, (void *)&lock) == 0)
        printf("pid %d obtained lock\n", getpid());
    else {
        perror("fcntl");
        lock.l_type = F_WRLCK;
        lock.l_whence = SEEK_SET;
        lock.l_start = 0;
        lock.l_len = 0;
        lock.l_pid = 0;
        if (fcntl(fileno(f), F_GETLK, (void *)&lock) == 0)
            printf("BAD: lock blocked by pid %d type %d\n", lock.l_pid,
                   lock.l_type);
        else
            perror("fcntl");
    }
    printf("press return:");
    gets(foo);
    lock.l_type = F_WRLCK;
    lock.l_whence = SEEK_SET;
    lock.l_start = 0;
    lock.l_len = 0;
    lock.l_pid = 0;
    if (fcntl(fileno(f), F_GETLK, (void *)&lock) == 0) {
        printf("lock held by pid %d type %d\n", lock.l_pid,
               lock.l_type);
    } else
        perror("fcntl");
    fd = open(argv[1], O_RDWR);
    if (fd != -1) {
        lock.l_type = F_WRLCK;
        lock.l_whence = SEEK_SET;
        lock.l_start = 0;
        lock.l_len = 0;
        lock.l_pid = 0;
        if (fcntl(fd, F_GETLK, (void *)&lock) == 0) {
            printf("lock held by pid %d type %d\n", lock.l_pid,
                   lock.l_type);
        } else
            printf("no lock on file\n");
    }
    exit(0);
}


Fix


    Maybe keep track of file locking operations in the union layer?

static threaded programs crash

Metadata

  • Number: 48709
  • Arrived: Fri Apr 04 19:30:00 +0000 2014
  • Last modified:
  • Environment: System: NetBSD gemini.duskware.de 6.99.39 NetBSD 6.99.39 (GENERIC-$Revision: 1.358 $) #11: Fri Apr 4 14:06:15 CEST 2014 [email protected]:/usr/src/sys/arch/alpha/compile/GENERIC alpha Architecture: alpha Machine: alpha

Description



The test program for staticaly linked TLS access dies on alpha with a segfault,
try:

    cd /usr/tests/lib/libc/tls && ./t_tls_static -l

but also this minimalistic program dies, if compiled with -static -pthread:

--8<--
#include <stdlib.h>
#include <pthread.h>
void *func(void *arg) { return 0; }
int main(int arg, char **argv)
{
    pthread_t t;
    pthread_create(&t, NULL, func, NULL);
    return 0;
}
-->8--

Nick and I traced this to register t12 getting corrupted in _libc_init when
calling __libc_thr_init. However, it is not that simple: the original object
code (with relocations) is fine:

Disassembly of section .text.startup:

0000000000000000 <_libc_init>:
   0:   00 00 bb 27     ldah    gp,0(t12)
                        0: GPDISP       .text.startup+0x4
   4:   00 00 bd 23     lda     gp,0(gp)
   8:   f0 ff de 23     lda     sp,-16(sp)
   c:   00 00 5e b7     stq     ra,0(sp)
[..]
  64:   00 00 7d a7     ldq     t12,0(gp)
                        64: ELF_LITERAL __guard_setup
  68:   00 40 5b 6b     jsr     ra,(t12),6c <_libc_init+0x6c>
                        68: LITUSE      .text.startup+0x3
                        68: HINT        __guard_setup
  6c:   00 00 ba 27     ldah    gp,0(ra)
                        6c: GPDISP      .text.startup+0x4
  70:   00 00 bd 23     lda     gp,0(gp)
  74:   00 00 7d a7     ldq     t12,0(gp)
                        74: ELF_LITERAL __libc_atomic_init
  78:   00 40 5b 6b     jsr     ra,(t12),7c <_libc_init+0x7c>
                        78: LITUSE      .text.startup+0x3
                        78: HINT        __libc_atomic_init
  7c:   00 00 ba 27     ldah    gp,0(ra)
                        7c: GPDISP      .text.startup+0x4
  80:   00 00 bd 23     lda     gp,0(gp)
  84:   00 00 7d a7     ldq     t12,0(gp)
                        84: ELF_LITERAL __libc_static_tls_setup
  88:   00 40 5b 6b     jsr     ra,(t12),8c <_libc_init+0x8c>
                        88: LITUSE      .text.startup+0x3
                        88: HINT        __libc_static_tls_setup
  8c:   00 00 ba 27     ldah    gp,0(ra)
                        8c: GPDISP      .text.startup+0x4
  90:   00 00 bd 23     lda     gp,0(gp)
  94:   00 00 7d a7     ldq     t12,0(gp)
                        94: ELF_LITERAL __libc_thr_init
  98:   00 40 5b 6b     jsr     ra,(t12),9c <_libc_init+0x9c>
                        98: LITUSE      .text.startup+0x3
                        98: HINT        __libc_thr_init

As you can see, t12 is used for the jsr call and set up right before the
function call. I don't see where it is restored, but I might have 
misunderstood something about the abi.

Now binutils is smart and optimizes this for static linked
(and small) binaries:

   1200467b4:   00 00 fe 2f     unop    
   1200467b8:   43 00 40 d3     bsr     ra,1200468c8 <__guard_setup+0x8>
   1200467bc:   00 00 fe 2f     unop    
   1200467c0:   00 00 fe 2f     unop    
   1200467c4:   00 00 fe 2f     unop    
   1200467c8:   15 00 40 d3     bsr     ra,120046820 <__libc_atomic_init>
   1200467cc:   00 00 fe 2f     unop    
   1200467d0:   00 00 fe 2f     unop    
   1200467d4:   00 00 fe 2f     unop    
   1200467d8:   9b 5a 5f d3     bsr     ra,12001d248 <__libc_static_tls_setup+0x8>
   1200467dc:   00 00 fe 2f     unop    
   1200467e0:   00 00 fe 2f     unop    
   1200467e4:   00 00 fe 2f     unop    
   1200467e8:   b1 f0 5e d3     bsr     ra,120002ab0 <__libc_thr_init>
   1200467ec:   00 00 fe 2f     unop    
   1200467f0:   00 00 fe 2f     unop    
   1200467f4:   00 00 fe 2f     unop    

The pattern is simple: the first two instructions in public functions
set up the gp register for this function. When it is known that the gp value
is not needed, or the same as in the calling function, the gp setup is skipped
and the jsr can be replaced by a bsr - but to past the two instructions (i.e.
typically function address + 8).

If you look at the disassembly above, you'll find some functions where the bsr
does not use the +8 offset: __libc_atomic_init and __libc_thr_init.

For the former, this is fine: it is an empty function and does not do
gp setup:

0000000120046820 <__libc_atomic_init>:
   120046820:   01 80 fa 6b     ret
   120046824:   00 00 fe 2f     unop    
   120046828:   1f 04 ff 47     nop     
   12004682c:   00 00 fe 2f     unop    

However, for __libc_thr_init it is not fine:

0000000120002ab0 <__libc_thr_init>:
   120002ab0:   06 00 bb 27     ldah    gp,6(t12)
   120002ab4:   78 f6 bd 23     lda     gp,-2440(gp)
   120002ab8:   c0 ff de 23     lda     sp,-64(sp)

So the
   1200467e8:   b1 f0 5e d3     bsr     ra,120002ab0 <__libc_thr_init>
actually modifies register t12 - and it is never restored.

I wonder if the "hidden" attribute of the function name is declared 
inconsistently somewhere (__libc_thr_init is aliased for libpthread), or
if this is a binutils bug -- or if I am just missing something.

Does anyone have an idea why binutils things it is ok to convert the
__libc_thr_init call to bsr without an offset?


How to repeat


cd /usr/tests/lib/libc/tls
./t_tls_static -l


Fix


n/a

A3000 hangs when attaching HP Scanjet IIcx

Metadata

  • Number: 2649
  • Originator: Ignatios Souvatzis <[email protected]>
  • Arrived: Tue Jul 23 03:05:04 +0000 1996
  • Last modified: Thu Mar 22 23:19:14 +0000 2001
  • Environment: System: NetBSD beverly.rhein.de 1.2_BETA NetBSD 1.2_BETA (GENERIC) #42: Sun Jul 14 14:34:45 MET DST 1996 [email protected]:/bulk/s2/src/sys/arch/amiga/compile/GENERIC amiga

Description


    My A3000 hangs when attaching to a HP Scanjet II cx.
    This happens right after the string "scan0: HP ScanJet IIcx" is
    printed to the console. The SCSI bus busy LED stays lighted.

    Yes, the SCSI bus was properly terminated. The same scanner works
    fine with NetBSD-1.2_BETA on a i486 machine it is normally connected
    to via an Adaptec 2940 interface.

    I booted into the debugger and tried to toggle several of the sbic.c
    switches (sbic_enable_reselect=0, sbic_no_dma=1,
    sbic_parallel_operations=0), without any change in behaviour.

    I guess I'm a victim of the remaining 1% of bugs in the Amiga sbic.c
    driver after the last big change just before -1.1.

    Note that there is another report (although not as a formal PR to us)
    from [email protected] (Neil Brewitt). He tried to use a 
    MUSTEK 6000 with an A3000. His scenario is a bit different: The machine
    survives the auto-configure period, then any process trying to talk
    to the Mustek hangs in "disk wait" (D).


How to repeat


    Connect HP Scanjet to built-in SCSI interface; reboot.

Audit trail


Responsible-Changed-From-To: gnats-admin->port-amiga-maintainer 
Responsible-Changed-By: fair 
Responsible-Changed-When: Mon Dec 28 09:33:48 PST 1998 
Responsible-Changed-Why:  
This PR is the responsibility of the portmaster, 
not the GNATS database administrator. 

ibcs2 emulation lacks sysfs()

Metadata

  • Number: 3711
  • Originator: Arne H. Juul <[email protected]>
  • Arrived: Thu Jun 05 07:05:01 +0000 1997
  • Last modified: Mon Nov 06 16:11:27 +0000 2000
  • Environment: System: NetBSD leon.math.ntnu.no 1.2E NetBSD 1.2E (NIKITA) #14: Thu Jun 5 14:39:16 CEST 1997 [email protected]:/usr/src/sys/arch/i386/compile/NIKITA i386

Description


    The IBCS2 emulation environment in NetBSD has stubbed out
    the sysfs() call.  This causes problems for some types of
    programs, in my case AXXiON-NetBackup.

    To implement sysfs() one needs to establish a mapping
    between filesystem-type name and number.  I noticed that
    the FreeBSD emulation already has such a mapping, so I
    extended that emulation a bit and made it common instead
    of making another version.  The mapping should in theory
    be dynamic, but in practice it suffices to add new
    filesystem types as (or preferrably a bit before) they
    are implemented for Net/FreeBSD.


How to repeat


    Try to run a SCO (or other ibcs2) program that uses sysfs().

Audit trail



From: "Chris G. Demetriou" <[email protected]>
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: kern/3711: ibcs2 emulation lacks sysfs() 
Date: Thu, 05 Jun 97 07:30:50 -0700

 >  To implement sysfs() one needs to establish a mapping
 >  between filesystem-type name and number.  I noticed that
 >  the FreeBSD emulation already has such a mapping, so I
 >  extended that emulation a bit and made it common instead
 >  of making another version.  The mapping should in theory
 >  be dynamic, but in practice it suffices to add new
 >  filesystem types as (or preferrably a bit before) they
 >  are implemented for Net/FreeBSD.

 This patch, and the understanding behind it, is incorrect.

 That table is necessarily OS-dependent.  It maps from file system type
 to the file system type number that _the target OS_ would use for that
 file system type.

 Those numbers do not necessarily have any similarity in different
 OSes, so the translation table sill have to be different.
 Additionally, the supported file systems in each OS are going to be
 slightly different.  Only file systems which are supported by the
 target OS should be listed in the table.  Others use some undefined or
 reserved (or otherwise 'weird') value.

 So, it's incorrect to attempt to use the FreeBSD table for iBCS2, or
 to generalize it to any other system, for that matter.

 Also, the mapping should _not_ be dynamic, for the reasons cited
 above.

 If the needs of sysfs() are different than what that table was
 intended to do, well, then it should probably use a different
 mechanism.  8-)



 cgd

From: "Arne Henrik Juul" <[email protected]>
To: "Chris G. Demetriou" <[email protected]>
Cc: [email protected], [email protected], [email protected]
Subject: Re: kern/3711: ibcs2 emulation lacks sysfs()
Date: Thu, 5 Jun 1997 19:34:38 +0200

 On Jun 5,  7:30, Chris G. Demetriou wrote:
 > >    To implement sysfs() one needs to establish a mapping
 > >    between filesystem-type name and number.  I noticed that
 > >    the FreeBSD emulation already has such a mapping, so I
 > >    extended that emulation a bit and made it common instead
 > >    of making another version.  The mapping should in theory
 > >    be dynamic, but in practice it suffices to add new
 > >    filesystem types as (or preferrably a bit before) they
 > >    are implemented for Net/FreeBSD.
 >
 > This patch, and the understanding behind it, is incorrect.
 >
 > That table is necessarily OS-dependent.  It maps from file system type
 > to the file system type number that _the target OS_ would use for that
 > file system type.
 >
 > Those numbers do not necessarily have any similarity in different
 > OSes, so the translation table sill have to be different.
 > Additionally, the supported file systems in each OS are going to be
 > slightly different.  Only file systems which are supported by the
 > target OS should be listed in the table.  Others use some undefined or
 > reserved (or otherwise 'weird') value.
 >
 > So, it's incorrect to attempt to use the FreeBSD table for iBCS2, or
 > to generalize it to any other system, for that matter.
 >
 > Also, the mapping should _not_ be dynamic, for the reasons cited
 > above.
 >
 > If the needs of sysfs() are different than what that table was
 > intended to do, well, then it should probably use a different
 > mechanism.  8-)

 I agree that the table for FreeBSD was intended to solve a different
 problem.  However, for the purpose of sysfs() we just need a table - any
 table will do - which maps between filesystem type-number and type-name.
 I didn't want to create another table to grow outdated (the FreeBSD one
 was slightly out of date already).

 Any IBCS2 application that needs to treat a specific filesystem type
 would (one hopes) use sysfs() to map name-to-number.  I guess the most
 common use of sysfs would be to map a filesystem type (as returned by
 statfs) to a string, probably for display purposes.  The numbers
 and names are dynamic, I think (at least on SCO).

 It might be that some application might want to recognize the strings
 returned by sysfs().  In that case, we would have to lie to the
 application in some way, I guess.  The most 'equivalent' filesystem
 type is probably NFS, which you might have noticed I already
 did a translation of.  If we wanted to do a better translation we would
 need another (type of) table, but I don't know which other translation
 we should then make; we don't have EAFS or S5 filesystem types, AFAIK.

 I hope this reasoning makes sense  :-)

   -  Arne H. J.

From: Arne Henrik Juul <[email protected]>
To: [email protected]
Cc:  Subject: Re: kern/3711: ibcs2 emulation lacks sysfs()
Date: Mon, 20 Oct 1997 13:16:57 +0200

 Here is an updated patch for sysfs() emulation that also
 covers SVR4 emulation, tested on NetBSD/sparc with a
 Solaris program.  This patch updates svr4/syscalls.master
 so one needs to update the dependant syscall files as well.

   -  Arne H. J.

 diff -ruP orig.src/sys/compat/ibcs2/ibcs2_misc.c src/sys/compat/ibcs2/ibcs2_misc.c
 --- orig.src/sys/compat/ibcs2/ibcs2_misc.c Sat Oct 11 15:18:09 1997
 +++ src/sys/compat/ibcs2/ibcs2_misc.c  Thu Oct 16 16:08:51 1997
 @@ -103,6 +103,7 @@
  #include <compat/ibcs2/ibcs2_syscallargs.h>
  #include <compat/ibcs2/ibcs2_sysi86.h>

 +#include <compat/common/compat_mnttype.h>

  int
  ibcs2_sys_ulimit(p, v, retval)
 @@ -1187,6 +1188,10 @@
    return EINVAL;
  }

 +/*
 + * This call takes one, two, or three parameters,
 + * and the types differ.  Yeuch.
 + */
  int
  ibcs2_sys_sysfs(p, v, retval)
    struct proc *p;
 @@ -1198,6 +1203,9 @@
        syscallarg(caddr_t) d1;
        syscallarg(char *) buf;
    } */ *uap = v;
 +  int error, i;
 +  char fstype[MFSNAMELEN];
 +  char *fst;

  #define IBCS2_GETFSIND        1
  #define IBCS2_GETFSTYP        2
 @@ -1205,10 +1213,34 @@

    switch(SCARG(uap, cmd)) {
    case IBCS2_GETFSIND:
 +      if ((error = copyinstr(SCARG(uap, d1), fstype,
 +               sizeof fstype, (u_int *)0)))
 +          return (error);
 +      /* special case nfs. */
 +      if (!strcmp(fstype, "NFS")) strcpy(fstype, "nfs");
 +      error = convert_mount_type_to_num(fstype, retval);
 +      return (error);
    case IBCS2_GETFSTYP:
 +      i = (int)SCARG(uap, d1);
 +      fst = convert_mount_type_to_name(i);
 +      if (fst) {
 +          /* special case nfs AGAIN. */
 +          if (!strcmp(fst, "nfs"))
 +              strcpy(fstype, "NFS");
 +          else
 +              strcpy(fstype, fst);
 +          if ((error = copyout(fstype, SCARG(uap, buf),
 +                      strlen(fstype)+1)))
 +              return (error);
 +          *retval = 0;
 +          return 0;
 +      }
 +      return EINVAL;
    case IBCS2_GETNFSTYP:
 +      *retval = get_num_mount_types();
 +      return 0;
    }
 -  return EINVAL;      /* XXX - TODO */
 +  return EINVAL;
  }

  int
 diff -ruP orig.src/sys/compat/common/compat_mnttype.c src/sys/compat/common/compat_mnttype.c
 --- orig.src/sys/compat/common/compat_mnttype.c    Thu Jan  1 01:00:00 1970
 +++ src/sys/compat/common/compat_mnttype.c Thu Aug 21 01:49:50 1997
 @@ -0,0 +1,66 @@
 +#include <sys/param.h>
 +#include <sys/systm.h>
 +#include <sys/mount.h>
 +#include <compat/common/compat_mnttype.h>
 +
 +/*
 + * List of filesystem types.  This needs to be updated whenever
 + * a) somebody adds a filesystem to NetBSD
 + * b) somebody adds a filesystem to FreeBSD
 + * Used for binary compatibility modes, primarily with FreeBSD,
 + * but also for SysV, see ibcs2_sys_sysfs().
 + *
 + * LKM filesystems are not supported.
 + */
 +static char *netbsd_mount_type[] = {
 +      "(none)", /*  0 = MOUNT_NONE */
 +      "ffs",    /*  1 = "Fast" Filesystem */
 +      "nfs",    /*  2 = Network Filesystem */
 +      "mfs",    /*  3 = Memory Filesystem */
 +      "msdos",  /*  4 = MSDOS Filesystem */
 +      "lfs",    /*  5 = Log-based Filesystem */
 +      "lofs",   /*  6 = Loopback filesystem */
 +      "fdesc",  /*  7 = File Descriptor Filesystem */
 +      "portal", /*  8 = Portal Filesystem */
 +      "null",   /*  9 = Minimal Filesystem Layer */
 +      "umap",   /* 10 = User/Group Identifier Remapping Filesystem */
 +      "kernfs", /* 11 = Kernel Information Filesystem */
 +      "procfs", /* 12 = /proc Filesystem */
 +      "afs",    /* 13 = Andrew Filesystem */
 +      "cd9660", /* 14 = ISO9660 (aka CDROM) Filesystem */
 +      "union",  /* 15 = Union (translucent) Filesystem */
 +            /* These filesystems don't exist in NetBSD yet */
 +      NULL,     /* 16 = "devfs" - existing device Filesystem */
 +      "ext2fs", /* 17 = Linux EXT2FS */
 +      "netcon", /* 18 = Netcon Novell filesystem */
 +            /* These filesystems don't exist in FreeBSD */
 +      "adosfs", /* 19 = AmigaDOS Filesystem */
 +};
 +#define NUMFSTYPES 20
 +
 +int
 +convert_mount_type_to_num(const char *name, int *num)
 +{
 +  int i;
 +  for (i=0; i<NUMFSTYPES; i++) {
 +      if (!strcmp(name, netbsd_mount_type[i])) {
 +          *num = i;
 +          return 0;
 +      }
 +  }
 +  return EINVAL;
 +}
 +
 +char *
 +convert_mount_type_to_name(int num)
 +{
 +  if (num>=0 && num<NUMFSTYPES) {
 +      return (netbsd_mount_type[num]);
 +  }
 +  return (NULL);
 +}
 +
 +int get_num_mount_types(void)
 +{
 +  return NUMFSTYPES;
 +}
 diff -ruP orig.src/sys/compat/common/compat_mnttype.h src/sys/compat/common/compat_mnttype.h
 --- orig.src/sys/compat/common/compat_mnttype.h    Thu Jan  1 01:00:00 1970
 +++ src/sys/compat/common/compat_mnttype.h Thu Aug 21 01:49:50 1997
 @@ -0,0 +1,3 @@
 +extern int convert_mount_type_to_num(const char *name, int *num);
 +extern char *convert_mount_type_to_name(int num);
 +extern int get_num_mount_types(void);
 diff -ruP orig.src/sys/compat/freebsd/freebsd_file.c src/sys/compat/freebsd/freebsd_file.c
 --- orig.src/sys/compat/freebsd/freebsd_file.c Fri Oct 10 14:22:04 1997
 +++ src/sys/compat/freebsd/freebsd_file.c  Tue Oct 14 02:08:36 1997
 @@ -49,45 +49,12 @@

  #include <compat/freebsd/freebsd_syscallargs.h>
  #include <compat/freebsd/freebsd_util.h>
 +#include <compat/common/compat_mnttype.h>

  #define   ARRAY_LENGTH(array) (sizeof(array)/sizeof(array[0]))

  const char freebsd_emul_path[] = "/emul/freebsd";

 -static char * convert_from_freebsd_mount_type __P((int));
 -
 -static char *
 -convert_from_freebsd_mount_type(type)
 -  int type;
 -{
 -  static char *netbsd_mount_type[] = {
 -      NULL,     /*  0 = MOUNT_NONE */
 -      "ffs",    /*  1 = "Fast" Filesystem */
 -      "nfs",    /*  2 = Network Filesystem */
 -      "mfs",    /*  3 = Memory Filesystem */
 -      "msdos",  /*  4 = MSDOS Filesystem */
 -      "lfs",    /*  5 = Log-based Filesystem */
 -      "lofs",   /*  6 = Loopback filesystem */
 -      "fdesc",  /*  7 = File Descriptor Filesystem */
 -      "portal", /*  8 = Portal Filesystem */
 -      "null",   /*  9 = Minimal Filesystem Layer */
 -      "umap",   /* 10 = User/Group Identifier Remapping Filesystem */
 -      "kernfs", /* 11 = Kernel Information Filesystem */
 -      "procfs", /* 12 = /proc Filesystem */
 -      "afs",    /* 13 = Andrew Filesystem */
 -      "cd9660", /* 14 = ISO9660 (aka CDROM) Filesystem */
 -      "union",  /* 15 = Union (translucent) Filesystem */
 -      NULL,     /* 16 = "devfs" - existing device Filesystem */
 -#if 0 /* These filesystems don't exist in FreeBSD */
 -      "adosfs", /* ?? = AmigaDOS Filesystem */
 -#endif
 -  };
 -
 -  if (type < 0 || type >= ARRAY_LENGTH(netbsd_mount_type))
 -      return (NULL);
 -  return (netbsd_mount_type[type]);
 -}
 -
  int
  freebsd_sys_mount(p, v, retval)
    struct proc *p;
 @@ -105,7 +72,7 @@
    caddr_t sg = stackgap_init(p->p_emul);
    struct sys_mount_args bma;

 -  if ((type = convert_from_freebsd_mount_type(SCARG(uap, type))) == NULL)
 +  if ((type = convert_mount_type_to_name(SCARG(uap, type))) == NULL)
        return ENODEV;
    s = stackgap_alloc(&sg, MFSNAMELEN + 1);
    if ((error = copyout(type, s, strlen(type) + 1)) != 0)
 diff -ruP orig.src/sys/compat/ibcs2/ibcs2_stat.c src/sys/compat/ibcs2/ibcs2_stat.c
 --- orig.src/sys/compat/ibcs2/ibcs2_stat.c Sat May  4 13:50:20 1996
 +++ src/sys/compat/ibcs2/ibcs2_stat.c  Tue Oct 14 02:08:39 1997
 @@ -39,6 +39,7 @@
  #include <sys/malloc.h>
  #include <sys/vnode.h>
  #include <sys/syscallargs.h>
 +#include <sys/syslog.h>

  #include <vm/vm.h>

 @@ -52,6 +53,8 @@
  #include <compat/ibcs2/ibcs2_util.h>
  #include <compat/ibcs2/ibcs2_utsname.h>

 +#include <compat/common/compat_mnttype.h>
 +
  static void bsd_stat2ibcs_stat __P((struct ostat *, struct ibcs2_stat *));
  static int cvt_statfs __P((struct statfs *, caddr_t, int));

 @@ -81,9 +84,16 @@
    int len;
  {
    struct ibcs2_statfs ssfs;
 +  int fstyp;

    bzero(&ssfs, sizeof ssfs);
 -  ssfs.f_fstyp = 0;
 +  if (convert_mount_type_to_num(sp->f_fstypename, &fstyp)) {
 +      log(LOG_WARNING, "Unknown fstypename %s in ibcs2 cvt_statfs\n",
 +          sp->f_fstypename);
 +      ssfs.f_fstyp = 0;
 +  } else {
 +      ssfs.f_fstyp = fstyp;
 +  }
    ssfs.f_bsize = sp->f_bsize;
    ssfs.f_frsize = 0;
    ssfs.f_blocks = sp->f_blocks;
 diff -ruP orig.src/sys/compat/svr4/svr4_misc.c src/sys/compat/svr4/svr4_misc.c
 --- src/sys/compat/svr4/svr4_misc.c    Sat Oct 11 15:18:45 1997
 +++ src/sys/compat/svr4/svr4_misc.c    Thu Oct 16 16:29:52 1997
 @@ -80,6 +80,8 @@
  #include <compat/svr4/svr4_sysconfig.h>
  #include <compat/svr4/svr4_acl.h>

 +#include <compat/common/compat_mnttype.h>
 +
  #include <vm/vm.h>

  static __inline clock_t timeval_to_clock_t __P((struct timeval *));
 @@ -1534,6 +1536,63 @@
    }

    return 0;
 +}
 +
 +
 +/*
 + * This call takes one, two, or three parameters,
 + * and the types differ.  Yeuch.
 + * Copied directly from ibcs2 emulation.
 + */
 +  int
 +svr4_sys_sysfs(p, v, retval)
 +  struct proc *p;
 +  void *v;
 +  register_t *retval;
 +{
 +  struct svr4_sys_sysfs_args /* {
 +      syscallarg(int) cmd;
 +      syscallarg(caddr_t) d1;
 +      syscallarg(char *) buf;
 +  } */ *uap = v;
 +  int error, i;
 +  char fstype[MFSNAMELEN];
 +  char *fst;
 + 
 +#define SVR4_GETFSIND        1
 +#define SVR4_GETFSTYP        2
 +#define SVR4_GETNFSTYP       3
 +
 +  switch(SCARG(uap, cmd)) {
 +  case SVR4_GETFSIND:
 +      if ((error = copyinstr(SCARG(uap, d1), fstype,
 +               sizeof fstype, (u_int *)0)))
 +          return (error);
 +      /* special case nfs. */
 +      if (!strcmp(fstype, "NFS")) strcpy(fstype, "nfs");
 +      error = convert_mount_type_to_num(fstype, retval);
 +      return (error);
 +  case SVR4_GETFSTYP:
 +      i = (int)SCARG(uap, d1);
 +      fst = convert_mount_type_to_name(i);
 +      if (fst) {
 +          /* special case nfs AGAIN. */
 +          if (!strcmp(fst, "nfs"))
 +              strcpy(fstype, "NFS");
 +          else
 +              strcpy(fstype, fst);
 +          if ((error = copyout(fstype, SCARG(uap, buf),
 +                      strlen(fstype)+1)))
 +              return (error);
 +          *retval = 0;
 +          return 0;
 +      }
 +      return EINVAL;
 +  case SVR4_GETNFSTYP:
 +      *retval = get_num_mount_types();
 +      return 0;
 +  }
 +  return EINVAL;
  }


 diff -ruP orig.src/sys/compat/svr4/syscalls.master src/sys/compat/svr4/syscalls.master
 --- orig.src/sys/compat/svr4/syscalls.master   Wed Oct 15 22:53:39 1997
 +++ src/sys/compat/svr4/syscalls.master    Thu Oct 16 16:29:52 1997
 @@ -151,7 +151,7 @@
                int nbytes); }
  82    OBSOL       libattach
  83    OBSOL       libdetach
 -84    UNIMPL      sysfs
 +84    STD     { int svr4_sys_sysfs(int cmd, caddr_t d1, char *buf); }
  85    STD     { int svr4_sys_getmsg(int fd, struct svr4_strbuf *ctl, \
                struct svr4_strbuf *dat, int *flags); }
  86    STD     { int svr4_sys_putmsg(int fd, struct svr4_strbuf *ctl, \
 diff -ruP orig.src/sys/compat/svr4/svr4_syscall.h src/sys/compat/svr4/svr4_syscall.h
 --- orig.src/sys/compat/svr4/svr4_syscall.h    Tue Jul 22 13:21:17 1997
 +++ src/sys/compat/svr4/svr4_syscall.h Thu Oct 16 16:30:15 1997
 @@ -174,6 +174,9 @@

                /* 82 is obsolete libattach */
                /* 83 is obsolete libdetach */
 +/* syscall: "sysfs" ret: "int" args: "int" "caddr_t" "char *" */
 +#define   SVR4_SYS_sysfs  84
 +
  /* syscall: "getmsg" ret: "int" args: "int" "struct svr4_strbuf *" "struct svr4_strbuf *" "int *" */
  #define   SVR4_SYS_getmsg 85

 diff -ruP orig.src/sys/compat/svr4/svr4_syscallargs.h src/sys/compat/svr4/svr4_syscallargs.h
 --- orig.src/sys/compat/svr4/svr4_syscallargs.h    Tue Jul 22 13:21:17 1997
 +++ src/sys/compat/svr4/svr4_syscallargs.h Thu Oct 16 16:30:15 1997
 @@ -153,6 +153,12 @@
    syscallarg(int) nbytes;
  };

 +struct svr4_sys_sysfs_args {
 +  syscallarg(int) cmd;
 +  syscallarg(caddr_t) d1;
 +  syscallarg(char *) buf;
 +};
 +
  struct svr4_sys_getmsg_args {
    syscallarg(int) fd;
    syscallarg(struct svr4_strbuf *) ctl;
 diff -ruP orig.src/sys/compat/svr4/svr4_syscalls.c src/sys/compat/svr4/svr4_syscalls.c
 --- orig.src/sys/compat/svr4/svr4_syscalls.c   Tue Jul 22 13:21:17 1997
 +++ src/sys/compat/svr4/svr4_syscalls.c    Thu Oct 16 16:30:15 1997
 @@ -102,7 +102,7 @@
    "getdents",         /* 81 = getdents */
    "#82 (obsolete libattach)",     /* 82 = obsolete libattach */
    "#83 (obsolete libdetach)",     /* 83 = obsolete libdetach */
 -  "#84 (unimplemented sysfs)",        /* 84 = unimplemented sysfs */
 +  "sysfs",            /* 84 = sysfs */
    "getmsg",           /* 85 = getmsg */
    "putmsg",           /* 86 = putmsg */
    "poll",         /* 87 = poll */
 diff -ruP orig.src/sys/compat/svr4/svr4_sysent.c src/sys/compat/svr4/svr4_sysent.c
 --- orig.src/sys/compat/svr4/svr4_sysent.c Tue Jul 22 13:21:17 1997
 +++ src/sys/compat/svr4/svr4_sysent.c  Thu Oct 16 16:30:15 1997
 @@ -223,8 +223,8 @@
        sys_nosys },            /* 82 = obsolete libattach */
    { 0, 0,
        sys_nosys },            /* 83 = obsolete libdetach */
 -  { 0, 0,
 -      sys_nosys },            /* 84 = unimplemented sysfs */
 +  { 3, s(struct svr4_sys_sysfs_args),
 +      svr4_sys_sysfs },           /* 84 = sysfs */
    { 4, s(struct svr4_sys_getmsg_args),
        svr4_sys_getmsg },          /* 85 = getmsg */
    { 4, s(struct svr4_sys_putmsg_args),

Exabyte 8505 read/write of compressed high density tapes

Metadata

  • Number: 2155
  • Originator: Klaus Helbing <[email protected]>
  • Arrived: Fri Mar 01 15:05:02 +0000 1996
  • Last modified: Wed Mar 24 20:45:42 +0000 2004
  • Environment: System: NetBSD phop5.physik.uni-bonn.de 1.1A NetBSD 1.1A (PHOP) #0: Wed Feb 7 15:50:38 MET 1996 [email protected]:/usr/src/sys/arch/i386/compile/PHOP i386

Description


    Rewriting of Exabyte tapes -- previously inscribed (by e.g. a 
    DECstation) in compressed 8500-Exabyte format --- fails even when 
    trying to write uncompressed. 
    Writing of new Exabyte tapes in compressed 8500 format fails.

    Reason: According to device manual of my exabyte the various formats 
        correspond to the following density codes:
        8500 normal :   0x00
        8500 compressed :   0x8c
        8500 compressed :   0x90
        8500 normal :   0x14
        But /sys/scsi/st.c says
#define SCSI_2_MAX_DENSITY_CODE 0x17    /* maximum density code specified
                                         * in SCSI II spec. */


How to repeat


    see description but repetition is not recommendable because of time 
    outs that lead to system crash!

Fix


Make the following devices where /dev/*st0l stands for 8500 normal, 
    /dev/*st0h 8500 compressed, /dev/*st0m EXB-8200 format compressed,
    /dev/*st0a 8200 normal.
crw-rw----  1 root  operator   14,   3 Nov 24 15:16 /dev/enrst0
crw-rw-r--  1 root  wheel      14,  15 Jan  9 18:19 /dev/enrst0a
crw-rw-r--  1 root  wheel      14,   7 Jan  9 18:18 /dev/enrst0h
crw-rw-r--  1 root  wheel      14,   3 Jan  9 18:18 /dev/enrst0l
crw-rw-r--  1 root  wheel      14,  11 Jan  9 18:19 /dev/enrst0m
brw-rw----  1 root  operator    5,   3 Nov 24 15:16 /dev/enst0
brw-rw-r--  1 root  wheel       5,  15 Jan  9 18:20 /dev/enst0a
brw-rw-r--  1 root  wheel       5,   7 Jan  9 18:19 /dev/enst0h
brw-rw-r--  1 root  wheel       5,   3 Jan  9 18:19 /dev/enst0l
brw-rw-r--  1 root  wheel       5,  11 Jan  9 18:19 /dev/enst0m
crw-rw----  1 root  operator   14,   2 Nov 24 15:16 /dev/erst0
crw-rw-r--  1 root  wheel      14,  14 Jan  9 18:24 /dev/erst0a
crw-rw-r--  1 root  wheel      14,   6 Jan  9 18:23 /dev/erst0h
crw-rw-r--  1 root  wheel      14,   2 Jan  9 18:23 /dev/erst0l
crw-rw-r--  1 root  wheel      14,  10 Jan  9 18:23 /dev/erst0m
brw-rw----  1 root  operator    5,   2 Nov 24 15:16 /dev/est0
brw-rw-r--  1 root  wheel       5,  14 Jan  9 18:24 /dev/est0a
brw-rw-r--  1 root  wheel       5,   6 Jan  9 18:24 /dev/est0h
brw-rw-r--  1 root  wheel       5,   2 Jan  9 18:24 /dev/est0l
brw-rw-r--  1 root  wheel       5,  10 Jan  9 18:24 /dev/est0m
crw-rw----  1 root  operator   14,   1 Nov 24 15:16 /dev/nrst0
crw-rw-r--  1 root  wheel      14,  13 Jan  9 20:53 /dev/nrst0a
crw-rw-r--  1 root  wheel      14,   5 Feb 29 15:39 /dev/nrst0h
crw-rw-r--  1 root  wheel      14,   1 Feb  1 11:05 /dev/nrst0l
crw-rw-r--  1 root  wheel      14,   9 Feb  1 11:19 /dev/nrst0m
brw-rw----  1 root  operator    5,   1 Nov 24 15:16 /dev/nst0
brw-rw-r--  1 root  wheel       5,  13 Jan  9 18:26 /dev/nst0a
brw-rw-r--  1 root  wheel       5,   5 Jan  9 18:25 /dev/nst0h
brw-rw-r--  1 root  wheel       5,   1 Jan  9 18:25 /dev/nst0l
brw-rw-r--  1 root  wheel       5,   9 Jan  9 18:26 /dev/nst0m
crw-rw----  1 root  operator   14,   0 Nov 24 15:16 /dev/rst0
crw-rw-r--  1 root  wheel      14,  12 Jan  9 18:26 /dev/rst0a
crw-rw-r--  1 root  wheel      14,   4 Jan  9 18:26 /dev/rst0h
crw-rw-r--  1 root  wheel      14,   0 Jan  9 18:26 /dev/rst0l
crw-rw-r--  1 root  wheel      14,   8 Jan  9 18:26 /dev/rst0m
brw-rw----  1 root  operator    5,   0 Nov 24 15:16 /dev/st0
brw-rw-r--  1 root  wheel       5,  12 Jan  9 18:27 /dev/st0a
brw-rw-r--  1 root  wheel       5,   4 Jan  9 18:27 /dev/st0h
brw-rw-r--  1 root  wheel       5,   0 Jan  9 18:27 /dev/st0l
brw-rw-r--  1 root  wheel       5,   8 Jan  9 18:27 /dev/st0m

and patch the source tree as follows (but replace EXB-85058SQANXR1 by 
something more universal (I did not understand the matching algorithm):

*** sys/scsi/scsiconf.c.orig    Fri Jan 12 13:28:18 1996
--- sys/scsi/scsiconf.c Tue Feb  6 20:43:18 1996
***************
*** 337,342 ****
--- 337,344 ----
    {T_SEQUENTIAL, T_REMOV,
     "EXABYTE ", "EXB-8200        ", "",     SDEV_NOLUNS},
    {T_SEQUENTIAL, T_REMOV,
+    "EXABYTE ", "EXB-85058SQANXR1", "",     SDEV_NOLUNS},
+   {T_SEQUENTIAL, T_REMOV,
     "SONY    ", "SDT-2000        ", "2.09", SDEV_NOLUNS},
    {T_SEQUENTIAL, T_REMOV,
     "SONY    ", "SDT-5000        ", "3.",   SDEV_NOSYNCWIDE},
*** sys/scsi/st.c.orig  Fri Jan 12 13:28:20 1996
--- sys/scsi/st.c   Tue Feb  6 20:43:19 1996
***************
*** 79,86 ****
  #define STUNIT(z) ((minor(z) >> 4)       )
  #define CTLMODE   3

! #define SCSI_2_MAX_DENSITY_CODE   0x17    /* maximum density code specified
!                    * in SCSI II spec. */
  /*
   * Define various devices that we know mis-behave in some way,
   * and note how they are bad, so we can correct for them
--- 79,86 ----
  #define STUNIT(z) ((minor(z) >> 4)       )
  #define CTLMODE   3

! #define SCSI_2_MAX_DENSITY_CODE   0xff
! 
  /*
   * Define various devices that we know mis-behave in some way,
   * and note how they are bad, so we can correct for them
***************
*** 200,214 ****
        0, 0, 0,                /* minor 8-11 */
        0, 0, 0                 /* minor 12-15 */
    }},
- #if 0
    {T_SEQUENTIAL, T_REMOV,
!    "EXABYTE ", "EXB-8200        ", "",     0, 12, {
!       0, 0, 0,                /* minor 0-3 */
!       0, 0, 0,                /* minor 4-7 */
!       0, 0, 0,                /* minor 8-11 */
!       0, 0, 0                 /* minor 12-15 */
    }},
- #endif
  };

  #define NOEJECT 0
--- 200,212 ----
        0, 0, 0,                /* minor 8-11 */
        0, 0, 0                 /* minor 12-15 */
    }},
    {T_SEQUENTIAL, T_REMOV,
!    "EXABYTE ", "EXB-85058SQANXR1", "",     0, 0, {
!       0, 0, 0x00,             /* minor 0-3 */
!       0, 0, 0x8c,             /* minor 4-7 */
!       0, 0, 0x90,             /* minor 8-11 */
!       0, 0, 0x14              /* minor 12-15 */
    }},
  };

  #define NOEJECT 0

Audit trail


Responsible-Changed-From-To: kern-bug-people->mjacob 
Responsible-Changed-By: lukem 
Responsible-Changed-When: Wed Apr 18 05:10:34 PDT 2001 
Responsible-Changed-Why:  
matt jacob is our scsi tape guru; maybe he can comment on this pr 
Responsible-Changed-From-To: mjacob->bouyer 
Responsible-Changed-By: fair 
Responsible-Changed-When: Wed Mar 24 20:43:32 UTC 2004 
Responsible-Changed-Why:  

Matt Jacob resigned from the NetBSD Project. Manuel Bouyer is our 
SCSI expert (if not an expert in SCSI tapes). Manuel, can you look 
over this ancient PR, please? 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.