[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[FDclone-users:00661] Linux 2.6.18 で dosdisk.c コンパイルエラー (_syscall5 マクロ)



こんばんは、濱崎です。

久しぶりに FDclone のコンパイルをしました。
dosdisk.c のコンパイルにかかったところで、

cc -DLINUX=1 -O -D_FILE_OFFSET_BITS=64    -DFD=2 -c -o dosdisk.o dosdisk.c
dosdisk.c:1075: error: expected declaration specifiers or '...' before '_llseek'
dosdisk.c:1076: error: expected declaration specifiers or '...' before 'fd'
dosdisk.c:1077: error: expected declaration specifiers or '...' before 'ofs_h'
dosdisk.c:1078: error: expected declaration specifiers or '...' before 'ofs_l'
dosdisk.c:1079: error: expected declaration specifiers or '...' before 'result'
dosdisk.c:1080: error: expected declaration specifiers or '...' before 'whence'
make[1]: *** [dosdisk.o] エラー 1

とエラーメッセージが出て、止まりました。

調べてみたところ、
1075 行目で使用している _syscall5 マクロが、
展開されていないのが原因でした。

#include <linux/unistd.h> のある90行目の前後で 
一時的に __KERNEL__ を定義することでコンパイルが通りました。

こんな感じです。

# define __KERNEL__
#include <linux/unistd.h>  ← 元の 90行目
# undef  __KERNEL__


_syscall5 マクロの定義は私の環境では、
/usr/include/asm-i486/unistd.h
にあります。
このファイルには、他にも_syscall1, _syscall2, など同類が
まとめて定義されています。
これらの _syscallX の定義が、 
#ifdef __KERNEL__ と 
#endif __KERNEL__ とで囲まれています。 
カーネルモジュール以外からは使うな、ということなんでしょうね。

このファイルは、Linux カーネルソース由来のファイルで、
Debian では linux-kernel-headers パッケージに入っています。
__KERNEL__ による条件分岐は 以前はなかったので、
2.6.{15,16,17} あたりで入ったものと思います。

llseek の man page を見てみると syscall(2) を使うことを勧めています。
根本的な解決をするには、呼び出し方法を変える必要があるのでしょうね。
--------------------------------------------------
    濱崎 健 E-mail: hma@syd.odn.ne.jp