mtools の料理方法

MS-DOS のフロッピーの読み書きするツールを料理しましょう。

最終更新日 : 1998 年 12 月 02 日


  1. 材料

    • Solaris[ developper ]以上ががインストールされたコンピュータ。
      今回は Solaris2.6 / Ultra1 を素材にしました。

    • GNU gcc の実行環境

    • GNU gzip の実行環境

    • mtools のソースコード

  2. 材料の入手

    ソース・コードを入手しないと話になりませんので、誰かにもらうかお買い物に行きましょう。
    下記の場所や雑誌の付録から入手してください。

    オリジナル Web サイトは、 http://linux.wauug.org/pub/knaff/mtools/mtools_toc.html のようです。 ftp サイトは、 ftp://linux.wauug.org/pub/knaff/fdutils/ のようです。
    どっから持ってきたか忘れましたが、 mtool-3.6.tar.gz を持ってきました。:)

  3. 下拵え

    まず材料を解凍します。
    ./configure という優れものを利用して Makefile を作成します。
    この時、 ./configure のオプションはいっぱいありますが、 INSTALL に書かれているもので、

    * Use ./configure --enable-vold to compile mtools to use Solaris's vold instead of directory accessing the floppy disk.

    Volume manager と共存したい場合は --enable-vold オプションを付けます。
    ただし、これを付けてしまうと Volume manager が FD を使用していないと使えなくなってしまいます。逆に付けないと Volume manager が FD を使用していると使えなくなってしまいます。まぁ、以下のような関係になっちゃいます。

    vold floppy/on vold floppy/off
    --enable-vold/on ×
    --eenable-vold/off ×

    さて、どうしようかという事で、両方作っちゃう事にします。
    Volume manager と共存できる方をオリジナルの名前で作って、共存できない方を m を n に変えた名前 ( ntools ) にして作成しちゃいます。
    パスは[ /usr/bin /usr/sbin /usr/ccs /usr/ccs/bin /usr/openwin/bin /usr/openwin/bin/xview /usr/local/bin . ]で、 LD_LIBARARY_PATH は[ /usr/openwin/lib:/usr/local/lib ]に張ってあります。

    # cd /usr/local/compile
    # gzip -dc mtools-3.6.tar.gz | tar xvf -
    # cd mtools-3.6
    # setenv CFLAGS -O2
    # ./configure --build=sparc-sun-solaris2.6 --prefix=/usr/local --enable-vold

  4. さてコンパイル

    ./configure で Makefile が出来ているのでこれでコンパイルすればいいのですが、なぜか ./configure の時に on_exit を使うようになっています。このままコンパイルすると on_exit が無いなんてエラーになってしまいますので、 config.h を編集して on_exit を使用しないようにしてから、 make します。

    # vi config.h

    /* Define if you have the on_exit function. */
    #define HAVE_ON_EXIT

    /* Define if you have the on_exit function. */
    /* #define HAVE_ON_EXIT */
    # make

  5. さぁ、盛り付け

    Makefile に install オプションがあるのでこれで盛り付けてしまいましょう。但し、 Makefile の中で /usr/bin/install を使用するようになっていますが、 Solaris2.6 では /usr/bin に install がありません。 /usr/sbin と /usr/ucb にありますが、 /usr/ucb を使用します。 Makefie のその部分を修正してからインストールします。

    # vi Makefile

    INSTALL = /usr/bin/install -c

    INSTALL = /usr/ucb/install -c
    # make install

  6. 再び下拵え

    Volume manager と共存しないのを作成します。
    まず、オブジェクトファイルなんかをきれいに掃除します。

    # make clean

    ./configure で --enable-vold なしで実行します。

    # ./configure --build=sparc-sun-solaris2.6 --prefix=/usr/local

  7. 再びコンパイル

    先程と同じように config.h で on_exit を使用しないように変更します。

    # vi config.h

    /* Define if you have the on_exit function. */
    #define HAVE_ON_EXIT

    /* Define if you have the on_exit function. */
    /* #define HAVE_ON_EXIT */
    #

    mtools が ntools になるように Makefile を以下のように変更します。早い話が mtools を ntools にしているだけだったりします。

    # vi Makefile

    LINKS=mattrib mcd mcopy mdel mdeltree mdir mformat minfo mlabel \
    mmd mmount mmove mpartition mrd mread mren mtype mwrite mtoolstest \
    mbadblocks mzip
    ↓
    LINKS=nattrib ncd ncopy ndel ndeltree ndir nformat ninfo nlabel \
    nmd nmount nmove npartition nrd nread nren ntype nwrite ntoolstest \
    nbadblocks nzip
    
    all:    mtools $(LINKS) mkmanifest
    ↓
    all:    ntools $(LINKS) mkmanifest
    
    mtools: $(OBJS1)
    ↓
    ntools: $(OBJS1)
    
    $(LINKS): mtools
    ↓
    $(LINKS): ntools
    
    do rm -f $$name && $(LN_S) mtools $$name; done
    ↓
    do rm -f $$name && $(LN_S) ntools $$name; done
    
    install:        $(bindir)/mtools install-man install-links \
                    $(bindir)/mkmanifest install-scripts install-info
    ↓
    install:        $(bindir)/ntools install-links
    
    $(bindir)/mtools: mtools
            $(top_srcdir)/mkinstalldirs $(bindir)
            $(INSTALL_PROGRAM) mtools $(bindir)/mtools
    ↓
    $(bindir)/ntools: ntools
            $(top_srcdir)/mkinstalldirs $(bindir)
            $(INSTALL_PROGRAM) ntools $(bindir)/ntools
    
    install-links: $(bindir)/mtools
            @for j in $(LINKS); do \
                    rm -f $(bindir)/$$j ; \
                    $(LN_S) mtools $(bindir)/$$j ; \
                    echo $(bindir)/$$j ; \
            done
    ↓
    install-links: $(bindir)/ntools
            @for j in $(LINKS); do \
                    rm -f $(bindir)/$$j ; \
                    $(LN_S) ntools $(bindir)/$$j ; \
                    echo $(bindir)/$$j ; \
            done
    
    #

    次に mtools.c を編集して ntools を認めてもらうように変更して make ね。これも m なんとかを n なんとかに変更するだけだったりします。

    # vi mtools.c

    static const struct dispatch {
            const char *cmd;
            void (*fn)(int, char **, int);
            int type;
    } dispatch[] = {
            {"mattrib",mattrib, 0},
            {"mbadblocks",mbadblocks, 0},
            {"mcd",mcd, 0},
            {"mcopy",mcopy, 0},
            {"mdel",mdel, 0},
            {"mdeltree",mdel, 2},
            {"mdir",mdir, 0},
            {"mformat",mformat, 0},
            {"minfo", minfo, 0},
            {"mlabel",mlabel, 0},
            {"mmd",mmd, 0},
            {"mmount",mmount, 0},
            {"mpartition",mpartition, 0},
            {"mrd",mdel, 1},
            {"mread",mcopy, 0},
            {"mmove",mmove, 0},
            {"mren",mmove, 1},
            {"mtoolstest", mtoolstest, 0},
            {"mtype",mcopy, 1},
            {"mwrite",mcopy, 0},
            {"mzip", mzip, 0}
    };
    ↓
    static const struct dispatch {
            const char *cmd;
            void (*fn)(int, char **, int);
            int type;
    } dispatch[] = {
            {"nattrib",mattrib, 0},
            {"nbadblocks",mbadblocks, 0},
            {"ncd",mcd, 0},
            {"ncopy",mcopy, 0},
            {"ndel",mdel, 0},
            {"ndeltree",mdel, 2},
            {"ndir",mdir, 0},
            {"nformat",mformat, 0},
            {"ninfo", minfo, 0},
            {"nlabel",mlabel, 0},
            {"nmd",mmd, 0},
            {"nmount",mmount, 0},
            {"npartition",mpartition, 0},
            {"nrd",mdel, 1},
            {"nread",mcopy, 0},
            {"nmove",mmove, 0},
            {"nren",mmove, 1},
            {"ntoolstest", mtoolstest, 0},
            {"ntype",mcopy, 1},
            {"nwrite",mcopy, 0},
            {"nzip", mzip, 0}
    };
    
    # make

  8. 再び盛り付け

    先程と同様に Makefile 内の /usr/bin/install を /usr/ucb/install に変更して make install ね

    # vi Makefile

    INSTALL = /usr/bin/install -c

    INSTALL = /usr/ucb/install -c
    # make install

  9. 食事

    さて、さっそく二つの味を試食しましょう。:)
    最初に Volume manager で foppy が認識する状態にして試します。
    /etc/vold.conf で floopy の設定がある事を確認して vold を初期化します。
    mdir は使用できて ndir は使用できないはずです。

    # vi /etc/vold.conf

    use floppy drive /dev/rdiskette[0-9] dev_floppy.so floopy%d
    # ps -ef | grep vold
    root 232 1 0 10:42:54 ? 0:02 /usr/sbin/vold
    # kill -HUP 232
    # volcheck
    # mdir
    # ndir
    Can't open /dev/rdiskette: Device busy
    Cannot initialize 'A:'

    次に Volume manager で floopy を認識しないようにして試します。
    /etc/vold.cont で flopy の設定をコメントアウトして vold を初期化して同じように試します。

    # vi /etc/vold.conf

    #use floppy drive /dev/rdiskette[0-9] dev_floppy.so floopy%d
    # ps -ef | grep vold
    root 232 1 0 10:42:54 ? 0:02 /usr/sbin/vold
    # kill -HUP 232
    # volcheck
    # mdir
    Can't open /vol/dev/aliases/floppy0: No such file or direcotory
    Cannot initialize 'A:'
    # ndir

  10. 後片付け

    ソース・コードなどはバックアップしておいて作業した生ごみは必要がなければ消してしまいましょう。

    # cd /usr/local/compile
    # rm -r mtools-3.6.tar.gz mtools-3.6


[ Solaris 料理コーナー ] [ トップページ ]

BEKKOAME//INTERNET で公開していたページです。
作成: 1998 年 12 月 02 日〜 Copyright (C) 1998 Katsauki Shimizu <katsuaki-s @_nifty.com> All rights reserved.

access counter