flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Linux > linux 2.6+ system calls reference

Goto page 1, 2, 3, 4  Next
Author
Thread Post new topic Reply to topic
arafel



Joined: 29 Aug 2006
Posts: 131
Location: Jerusalem, Israel
linux 2.6+ system calls reference
Hi,

I want to introduce a small project which came to life a couple of month ago.
You may get it from here (grab the latest release): http://sourceforge.net/project/showfiles.php?group_id=173983

It's a reference for Linux 2.6+ system calls. Which provides a description of (almost)all system calls found in kernel 2.6 and later branches from Assembly point of view Smile
Also it includes a set of include files for FASM and GAS with structures and symbol definitions necessary for programming with syscalls.
And also there is a number (currently only two..) of examples provided which demonstrate some syscalls usage.

The project is currently in an alpha stage. A lot of things has not been verified yet, so please take this into account Wink .

Hope someone will find it useful.
Post 03 Oct 2006, 05:16
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7113
Location: Slovakia
very nice, thanks.

you seems to be missing mmap (90) by the way... note that is is called by pushing address of structure that holds argument, not by pushing each argument.

also

Code:

O_CREAT         equ 00000100
O_EXCL          equ 00000200
O_TRUNC         equ 00001000


i too saw these values in many descriptions, but on system where i tested it, values were 80h for EXCL, 200h for TRUNC and 40h for CREAT. Isn't it possible that these values are changed by libc and you are using those? please test this...
Post 03 Oct 2006, 10:38
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7113
Location: Slovakia
i will move it to Linux section and mark it as announcement, okay?
Post 03 Oct 2006, 11:26
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
arafel



Joined: 29 Aug 2006
Posts: 131
Location: Jerusalem, Israel

vid wrote:

you seems to be missing mmap (90) by the way... note that is is called by pushing address of structure that holds argument, not by pushing each argument.


Yeah, haven't added this one yet. Just want to clean/test/verify already existing stuff before adding anything new.

Quote:

also

Code:

O_CREAT         equ 00000100
O_EXCL          equ 00000200
O_TRUNC         equ 00001000


i too saw these values in many descriptions, but on system where i tested it, values were 80h for EXCL, 200h for TRUNC and 40h for CREAT. Isn't it possible that these values are changed by libc and you are using those? please test this...


Hmmm. Don't know about 80h, 200h, and 40h.
But 100, 200, 1000 should be correct. They are taken directly from the linux kernel source (2.6.18. however afaik those particular values haven't changed since Linux 1.0 so they should be the same on all kernel versions):

#define O_CREAT 00000100 /* not fcntl */
#define O_EXCL 00000200 /* not fcntl */
#define O_TRUNC 00001000 /* not fcntl */

Could you please assemble samples/basic/filecreate.asm and see whether it works on that system? (it uses sys_open with O_CREAT and O_EXCL to create a file.)


Quote:

i will move it to Linux section and mark it as announcement, okay?


Sure. Thanks. Smile
Post 03 Oct 2006, 11:47
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7113
Location: Slovakia

Code:
vid@cray:~$ strace ./filecreate
execve("./filecreate", ["./filecreate"], [/* 28 vars */]) = 0
open("newfile.txt"O_RDWR|O_APPEND|O_CREAT|O_TRUNC|O_EXCL|O_NOCTTY|O_ASYNC|0x3c01274) = -1 EEXIST (File exists)
write(1"The file already exists and can "...47The file already exists and can not be created
) = 47
_exit(0)                                = ?
Process 20269 detached

Post 03 Oct 2006, 12:07
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
arafel



Joined: 29 Aug 2006
Posts: 131
Location: Jerusalem, Israel
ok works like it should. creates file on the first execution. fails on any sequent execution if file newfile.txt is not deleted.
what worries me however is that O_SYNC and permission bits got screwed somehow. i'll check this a bit later.. need to eat something first. Rolling Eyes
Post 03 Oct 2006, 12:32
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7113
Location: Slovakia
btw, system is "grsecurity applied on vanila kernel" as described by friend. i was playing with it, and i found values of constants to be such as i told you.
Post 03 Oct 2006, 12:34
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7113
Location: Slovakia
no, it is even without grsec... hm...
Post 03 Oct 2006, 12:41
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
arafel



Joined: 29 Aug 2006
Posts: 131
Location: Jerusalem, Israel
what was the filename (and location) of the file where you found those constants?
Post 03 Oct 2006, 12:43
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7113
Location: Slovakia
same output on another machine... try yours. it may even be problem of strace. but i am using values that strace was using in FASMLIB, and it seems to work... hm
Post 03 Oct 2006, 12:51
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
arafel



Joined: 29 Aug 2006
Posts: 131
Location: Jerusalem, Israel
lol. what a stupid mistake.
I totally forgot that FASM does not handle octal numbers like C does. So it actually sees all the octals (prefixed with "0" in C) as decimals!
Will fix this asap.

edit:
here is a fixed versions of symbols.inc
Post 03 Oct 2006, 14:39
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7113
Location: Slovakia
OH! i was also wondering why there is no "0x"... but i thought radix is defaultly based to 16 somehow.

prefixing octal numbers with "0" is the most stupid thing i ever saw...

thanks for clearing this up for me
Post 03 Oct 2006, 15:16
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7113
Location: Slovakia
and don't forget to check ALL constants whether they weren't octal.
Post 03 Oct 2006, 15:17
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
arafel



Joined: 29 Aug 2006
Posts: 131
Location: Jerusalem, Israel
already fixed Smile see the attachment in the previous post.
Post 03 Oct 2006, 15:25
View user's profile Send private message Reply with quote
a16b03



Joined: 24 Jan 2006
Posts: 43
Location: Riga, Latvia
Exelent work

It would be cool if this info would bee added to http://flatassembler.net/docs.php
Post 07 Oct 2006, 20:26
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
arafel



Joined: 29 Aug 2006
Posts: 131
Location: Jerusalem, Israel
thanks a16b03
Post 07 Oct 2006, 22:28
View user's profile Send private message Reply with quote
arafel



Joined: 29 Aug 2006
Posts: 131
Location: Jerusalem, Israel
New release has been uploaded to the sourcforge..
It fixes some critical bugs in include files. + some fixes in the reference.
Post 08 Oct 2006, 01:15
View user's profile Send private message Reply with quote
arafel



Joined: 29 Aug 2006
Posts: 131
Location: Jerusalem, Israel
After a lot of thinking I have decided to take this project into a completely, well,.. maybe not completely, but nevertheless different direction.
LSCR from now on will incorporate more than just a reference and a few examples. Namely, there will be set of miscellaneous helper utilities, much more extended set of include files and sample applications covering not only the system calls usage but a more broad range of programming aspects.

Currently documentation of the first 127 system calls has been reviewed and tested. A bunch of new samples has been added: IPC, sockets, kernel modules, gui (one xlib and one xaw example). And I finally settled with the package layout, so there won't be any major changes in the directory structure anymore.

As for development cycle, highest priority for now stands on:

- completing review of the remaining 200+ system calls.
- finishing include files (especially xlib).
- and continuing to add new examples and utilities.

and plans for a near future:

- create include files for GTK+ and Qt.
- make 64bit version. (most likely will go into separate package. not sure yet.)
- create some kind of automated solution for porting FASM examples/includes onto other assemblers (GAS, maybe NASM).
- ...
Post 13 Oct 2006, 17:35
View user's profile Send private message Reply with quote
a16b03



Joined: 24 Jan 2006
Posts: 43
Location: Riga, Latvia
I know You're very busy, but, if possible it would bee GREAT if you could add info (at least basic info) how to program some basic devices under linux...

This info is very hard to find, and it would be usefull for new programmers and maby someone else.[/b]
Post 13 Oct 2006, 18:44
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
orbital_fox



Joined: 08 Sep 2006
Posts: 14
i would recomment that u create a web accessible version tooo..

SF provides web space Wink

_________________
http://section-9.co.nr
Post 17 Oct 2006, 10:16
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2, 3, 4  Next

< Last Thread | Next Thread >

Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.