[SOLVED] lseek function applied on open disk crashes my program.
Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I originally started writing wxFile class and wxSeek functions, As that was crashing, I wanted to do away with it and use plain lseek. Even now I want get around the problem and want to call lseek function. Is there any way to do that? As the function is not reaching lseek at all in this case, there has to be some problem in compiling the code. So, how do I get rid of that?
I am not conversant with coredump, but I think this is a very complicated way to discover a bug in the library, as wxWidgets should clarify/correct it.
if you have a simple case just report it to the developers, you do not need to analyze or solve it. However the stack trace may give a lot of info about the problem.
So if you want to solve this I recommend you to make a library without wxWidgets and this implements your file i/o (you can also try to link statically the runtime). You will use this lib in your app with wxWidgets instead of the original runtime (so you will have my_lseek, my_open or similar)
I originally started writing wxFile class and wxSeek functions, As that was crashing, I wanted to do away with it and use plain lseek. Even now I want get around the problem and want to call lseek function. Is there any way to do that? As the function is not reaching lseek at all in this case, there has to be some problem in compiling the code. So, how do I get rid of that?
I am not conversant with coredump, but I think this is a very complicated way to discover a bug in the library, as wxWidgets should clarify/correct it.
I see two ways to bypass wxWidget's lseek and call the real one:
Or write your own lseek function and call call lseek syscall directly.
But this (assembler) function shoul be changed for each new processor or operation system
I open a disk using int f= open(devicename,O_RDWR);
then I want to seek to a position. Here it is 0( could be anything). lseek(f,0,SEEK_SET);
After this I want to write something. The device name is /dev/sdc ( a disk, it could be sda, sdb anything).
But just after lseek is executed, I get a coredumped message on the command prompt.
If I omit lseek, I can go on writing and after closing, can see the data. But I need lseek. Note that lseek64 also creashes the same way.
Am I doing something silly? Please help.
Basudeb
Here, you are trying to perform lseek on Block device (sdc) which is not supported. Since Block device read/write bytes in fixed size blocks. where as character device read/write bytes in a stream. Hence lseek can be performed only on character device.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.