home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.next.sysadmin
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!destroyer!cs.ubc.ca!unixg.ubc.ca!kakwa.ucs.ualberta.ca!vega!ntomczak
- From: ntomczak@vega.math.ualberta.ca (N Tomczak-Jaegermann)
- Subject: MS-DOS disks labels under NeXTSTEP_3.0 - how to
- Message-ID: <ntomczak.722502506@vega>
- Summary: make them colourful
- Sender: news@kakwa.ucs.ualberta.ca
- Nntp-Posting-Host: vega.math.ualberta.ca
- Organization: University Of Alberta, Edmonton Canada
- Date: Mon, 23 Nov 1992 07:08:26 GMT
- Lines: 160
-
-
- If you who have problems with MS-DOS diskettes rejected because of
- garbled labels or you are bored with MS-DOS disks mounting as /no_name
- or /unknown here is a small program, relabel_dos, which may help to
- alleviate your worries. It works for me and it may work for you, but
- there are no guarantees of any kind and there is a distinct potential
- of loosing your data. So be careful and check first how it operates
- on spare copies of diskettes of the kind you are using. Check also
- if modified disks will not spook out your MS-DOS computer with
- which you would like to exchange disks. Maybe they might.
- !!Read carefully all instructions!!
-
- Have fun,
- Michal
-
- /******************* relabel_dos.c ************************
- *
- * Utility to modify labels on MS-DOS diskettes used on NeXT.
- *
- * Instructions:
- * To run this program you have to be 'root' (or, if you feel
- * bold and reckless today, you may make it 'suid root').
- * Start this program from a Terminal window and give it as an
- * argument a label you want to use. DO NOT insert a diskette
- * until asked by an alert box to do so. After succesful
- * program completion your diskette will be ejected. Insert
- * it back and NeXT hopefuly will mount the diskette under its
- * brand new label.
- *
- * If you will try this operation on a diskette which was
- * already mounted re-insertion of an ejected disk will NOT
- * change a displayed label. Eject that disk properly
- * from Workspace and re-insert once again.
- *
- * DIRE WARNINGS!!!
- * Main use of this program is make acceptable to NeXT
- * MS-DOS diskettes which are rejected because of garbage
- * labels. Therefore this program reads and writes raw,
- * not-mounted, floppies an does not attempt to check if
- * they are really MS-DOS. Executing it on a disk with
- * Unix or Mac file system will likely cause a damage not
- * easy recoverable on this side of formatting.
- * There is also no check if label characters are valid
- * from MS-DOS point of view - mostly because I do not know
- * if there are any limitations. Letters are converted to
- * an upper case just because NeXT is doing this. It does
- * not seem that this really matters. Spaces are ok in
- * labels, but an argument has to be quoted in such cases.
- * NeXT will convert on a display label blanks into underscores.
- * Lastly - ONE(!) MS-DOS computer did not mind diskettes
- * with modified labels. I have no idea if this applies
- * to your machine. Check it out on spare disks!!!
- *
- * Compilation:
- * compile with 'cc -O2 -s -object -o relabel_dos relabel_doc.c'
- *
- * Disclaimers:
- * This program is provided on 'as is' basis and using it you accept
- * full responsibility for its results. In no event I shall be liable
- * for any incidental, consequential, special or indirect damages of
- * any kind, including, without limitation, lost profits or
- * revenues, arising out of the use, installation, or operation of
- * this program.
- *
- * Michal Jaegermann
- * ntomczak@vega.math.ualberta.ca
- * ntomczak@vm.ucs.ualberta.ca
- *
- * 22 November 1992
- **********************************************************/
-
- #define FLOPPY "/dev/rfd0b"
- #define SECT_SIZE 512
- #define LABEL_START 43
- #define LABEL_WIDTH 11
-
- #include <stdio.h>
- #include <string.h>
- #include <ctype.h>
- #include <libc.h>
- #include <dev/disk.h>
- #include <sys/file.h>
-
- void
- eject_and_exit(int fd)
- {
- ioctl(fd, DKIOCEJECT, 0);
- close (fd);
- exit (1);
- }
-
- int
- main(int argc, char **argv)
- {
- unsigned char sect_buf[SECT_SIZE];
- unsigned char *label_end = §_buf[LABEL_START + LABEL_WIDTH];
- unsigned char *apos, *lpos;
- int fd;
- int c;
-
- if(argc < 2) {
- fprintf(stderr, "usage: %s new_label\n", argv[0]);
- exit (1);
- }
-
- /* get sector 0 from floppy */
-
- if (0 > (fd = open (FLOPPY, O_RDONLY, 0))) {
- fprintf(stderr, "cannot open " FLOPPY " for reading\n");
- exit(1);
- }
-
- if (SECT_SIZE != read(fd, sect_buf, SECT_SIZE)) {
- fprintf(stderr, "error reading boot sector\n");
- eject_and_exit (fd);
- }
- close(fd);
-
- /* modify label on a sector image - leftover filled with blanks*/
-
- apos = argv[1];
- lpos = §_buf[LABEL_START];
-
- c = 1;
- do {
- if ('\0' != c) {
- if ('\0' == (c = *apos++))
- continue;
- /*
- * NeXT does not seem to care about case
- * but maybe MS-DOS does - convert to upper case
- */
- if (islower(c))
- c = toupper(c);
- *lpos++ = c;
- }
- else {
- *lpos++ = ' ';
- }
- } while (lpos < label_end);
-
- /* write sector 0 back to floppy */
-
- if (0 > (fd = open (FLOPPY, O_WRONLY, 0))) {
- fprintf(stderr, "cannot open " FLOPPY " for writing\n");
- exit (1);
- }
-
- if (SECT_SIZE != write(fd, sect_buf, SECT_SIZE)) {
- fprintf(stderr, "error writing boot sector\n");
- eject_and_exit (fd);
- }
-
- /* eject modified disk and get out */
-
- ioctl(fd, DKIOCEJECT, 0);
- close(fd);
-
- return 0;
- }
-