home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / os / linux / 17120 < prev    next >
Encoding:
Internet Message Format  |  1992-11-18  |  4.2 KB

  1. Path: sparky!uunet!charon.amdahl.com!pacbell.com!sgiblab!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!uwm.edu!biosci!agate!doc.ic.ac.uk!uknet!cam-orl!iwj
  2. From: iwj@cam-orl.co.uk (Ian Jackson)
  3. Newsgroups: comp.os.linux
  4. Subject: Floppy driver default type - for SCSI and passworded BIOS
  5. Summary: patch enclosed to enable you to make your system more secure
  6. Keywords: floppy, fd, CMOS, BIOS, boot
  7. Message-ID: <1992Nov18.142202.14549@cam-orl.co.uk>
  8. Date: 18 Nov 92 14:22:02 GMT
  9. Followup-To: comp.os.linux
  10. Organization: Olivetti Research Ltd
  11. Lines: 100
  12.  
  13. Here is a small patch to floppy.c which allows the type of the first
  14. floppy drive to have a default in the kernel in case the CMOS thinks
  15. it's not present.
  16.  
  17. Linus would rather not put it in the default kernel as it is quite
  18. specialised, so I'm posting it here for any interested people.
  19.  
  20. I find the patch useful because I live in a shared house and I don't
  21. want anybody being able to boot my computer from a floppy and delete
  22. all my files, send rude mail, etc. (taking the cover off the computer
  23. is too extreme for them !).
  24.  
  25. Unfortunately, though I have a password-protected BIOS where I can
  26. change the boot order the Adaptec SCSI BIOS (which I have to leave
  27. enabled so I can boot from my SCSI disk) takes over the boot and
  28. always tries the floppy first; I think that most SCSI controllers do
  29. this.
  30.  
  31. The way round this is to configure the CMOS to record drive 'A' as
  32. "none". Then the Adaptec always fails to boot from it.  Unfortunately
  33. then you can't use the floppy, as Linux looks in the CMOS to find the
  34. drive type - and that's where this patch comes in.
  35.  
  36. You define FD0_DEFAULT_TYPE (in config.{dist,site}.h or wherever) as
  37. the number of the default drive type and it will use that if the CMOS
  38. says there is no drive. If you don't define the special symbol
  39. everything is just as before.
  40.  
  41. If you need to boot from floppy for any reason you go into the CMOS
  42. setup (giving the CMOS password, of course) and change the drive type
  43. back to whatever it should really be, and then you're away.
  44.  
  45. Unfortunately the patch results in yet another file depending on
  46. config.h and thus on config.{dist,site}.h, but then such is life.
  47.  
  48. I changed it about four days ago and it has been working fine since.
  49.  
  50. The enclosed patch was between 0.98.3 without the emergency mount
  51. patch and 0.98.5 with my modification, but I chopped out a spurious
  52. difference by hand, so it should now be relative to 0.98.5. I don't
  53. have RCS/CVS up yet so I haven't been able to check that.
  54.  
  55. Regards,
  56. Ian Jackson.
  57.  
  58. *** floppy.c%    Tue Nov 17 00:57:10 1992
  59. --- floppy.c    Tue Nov 17 00:57:06 1992
  60. ***************
  61. *** 58,63 ****
  62. --- 58,73 ----
  63.    * floppy as the first thing after bootup.
  64.    */
  65.   
  66. + /* 14.11.92
  67. +  * Added support for FD0_DEFAULT_TYPE, to allow use of fd0 even if
  68. +  * not present in CMOS configuration. This is intended to allow people
  69. +  * to prevent booting from floppy while still allowing access to the
  70. +  * drive once booted, if you have a password-protected BIOS.
  71. +  * This is needed even if you can change the boot order if you intend
  72. +  * to boot from an Adaptec SCSI disk, as Adaptec's BIOS (which you have
  73. +  * to leave switched on) will try the floppy anyway ! - Ian Jackson.
  74. +  */
  75.   #define REALLY_SLOW_IO
  76.   #define FLOPPY_IRQ 6
  77.   #define FLOPPY_DMA 2
  78. ***************
  79. *** 69,74 ****
  80. --- 79,85 ----
  81.   #include <linux/fdreg.h>
  82.   #include <linux/fd.h>
  83.   #include <linux/errno.h>
  84. + #include <linux/config.h>
  85.   
  86.   #include <asm/dma.h>
  87.   #include <asm/system.h>
  88. ***************
  89. *** 1149,1154 ****
  90. --- 1160,1176 ----
  91.           printk("fd%d is %s",drive,base->name);
  92.           return base;
  93.       }
  94. + #ifdef FD0_DEFAULT_TYPE
  95. + # if (FD0_DEFAULT_TYPE > 0) && (FD0_DEFAULT_TYPE < 5)
  96. +     if (drive == 0 && code == 0) {
  97. +             base = &floppy_types[(FD0_DEFAULT_TYPE-1)*2];
  98. +         printk("fd%d defaults to %s",drive,base->name);
  99. +         return base;
  100. +     }
  101. + # else
  102. + #  error FD0_DEFAULT_TYPE is out of range (1 to 4 is allowed)
  103. + # endif
  104. + #endif
  105.       printk("fd%d is unknown type %d",drive,code);
  106.       return NULL;
  107.   }
  108. -- 
  109. Ian Jackson  iwj@cam-orl.co.uk ..!uknet!cam-orl!iwj  These opinions are my own.
  110. Olivetti Research Ltd, Old Addenbrookes Site, Trumpington St, Cambridge, UK;
  111. Home: 35 Molewood Close, Cambridge, CB4 3SR; +44 223 327029.     +44 223 343398
  112.