Merhaba,
Asagidaki yazilar Murat BALABAN(MB), N. Ersen SISECI(NES), Baris SIMSEK(BS) ve
Metin KAYA(MK)
arasinda gecen lseek(2) ve select(2) konulu sohbetten alintidir.
MK: select(2) 'ye utimeout parametresi olarak NULL verilirse select(2) nasil
davranir?
BS: Isletim sistemi select 'e bir sinyal gondermedigi muddetce select dosya
tanimlayicilari
(file descriptor set) uzerinde suresiz olarak bekler.
MK: Linux device driver'larda read(2) yapilirken asagidaki struct'in
llseek fonksiyonu kullaniliyor mu? "strace cat /dev/metin" ile
baktigimda "llseek" cagrisi goremedim ama emin olmak icin sormak istedim.
struct file_operations metin_fops = {
.owner = THIS_MODULE,
.llseek = metin_llseek,
.read = metin_read,
.write = metin_write,
.ioctl = metin_ioctl,
.open = metin_open,
.release = metin_release,
};
MB: open, read ve close hook'lari calisir. sen open(2) edip, lseek(2)
calistirirsan ancak o zaman lseek(2) calisir.
NES: lseek : Seek to a specified position in a file (used for random access
when reading or writing a file)
- The original seek system call used a 16 bit address
- "lseek" is named because it uses a "long" integer as the address
to seek to. In practice this is a 32 bit integer on most current machines
- The UNIX standards organizations have apparently not yet
standardized a suitable seek system call for 64 bit addresses
- Currently (January 2005), the llseek system call is available on
Solaris (hercules), but there is no indication that this system call is
portable
- Versions of Linux apparently support _llseek() or llseek() for raw
devices. Compilers may support lseek() as accepting a 64-bit long or add
lseek64(), according to a compile-time option.
MK: yani ben metin_read 'i implement ederken lseek kullanmamissam ya da
explicit olarak
cagirmamissam lseek calismaz mi?
MB: iki system call farkli amaclar icin kullaniliyor. read, sequential
olarak dosyadaki/device'daki veriyi okumak icin, lseek ise,
dosya/device'da ileri-geri gitmek icin.
Semantik olarak, bir system call icinden, ikinci bir system call
cagrilmaz, bunun icin cok iyi bir nedenin olmasi lazim.
lseek 'i explicit olarak cagirmamissan "strace cat /dev/a" gibi bir komutta
calismamasi lazim.
struct file_operations 'da f_nextoff dosyadaki offset'i (en son kaldigi
yeri) tutuyor.
Yani, bir sonraki read'de buradaki offset degeri esas olacaktir.
lseek(2)'i random access yapmak icin kullaniyorsun, yoksa normalde ona
gerek kalmadan isletim sistemi en son okudugu yerin state'ini tutuyor.
NES: "lseek" tanimlanmamissa "tail" gibi bir komutta nasil davranacaktir
isletim sistemi?
MB: Denemek lazim, fakat tahminim
#define ENOSYS 38 /* Function not implemented */
gibi bir hata aliyor olabilir.
--
Metin KAYA
EnderUNIX Software Developer Endersys Software Engineer
http://www.EnderUNIX.org/metin http://www.Endersys.com/
---------------------------------------------------------------------
Listeye soru sormadan once lutfen http://ipucu.enderunix.org sitesine bakiniz.
Cikmak icin, e-mail: [EMAIL PROTECTED]
Liste arsivi: http://news.gmane.org/gmane.org.user-groups.bsd.turkey
FreeBSD 6 kitabi cikti! http://www.acikakademi.com/catalog/freebsd6