LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-29-2014, 10:21 AM   #1
tn12
LQ Newbie
 
Registered: Sep 2014
Posts: 2

Rep: Reputation: Disabled
Linux System Calls


I want to learn about programming a linux system call using C language. I want to know a good source which teaches both code and theory in detail and explanatory manner
 
Old 09-29-2014, 10:27 AM   #2
jdkaye
LQ Guru
 
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 5,465

Rep: Reputation: Disabled
This link should get you started. After that you can have a look at this document.
jdk
 
Old 09-29-2014, 11:48 AM   #3
tn12
LQ Newbie
 
Registered: Sep 2014
Posts: 2

Original Poster
Rep: Reputation: Disabled
Here he/she just includes libraries/API and calls function access() rather than showing the function(System cAll) defintion. Refer to code if you need










#include <errno.h>
#include <stdio.h>
#include <unistd.h>
int main (int argc, char* argv[])
{
char* path = argv[1];
int rval;
/* Check file existence. */
rval = access (path, F_OK);
if (rval == 0)
printf (“%s exists\n”, path);
else {
if (errno == ENOENT)
printf (“%s does not exist\n”, path);
else if (errno == EACCES)
printf (“%s is not accessible\n”, path);
return 0;
}
/* Check read access. */
rval = access (path, R_OK);
if (rval == 0)
printf (“%s is readable\n”, path);
else
printf (“%s is not readable (access denied)\n”, path);
/* Check write access. */
rval = access (path, W_OK);
if (rval == 0)
printf (“%s is writable\n”, path);
else if (errno == EACCES)
printf (“%s is not writable (access denied)\n”, path);
else if (errno == EROFS)
printf (“%s is not writable (read-only filesystem)\n”, path);
return 0;
}
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux System Calls mopinion Programming 17 12-05-2011 05:56 AM
how does java calls the system calls which are written in c babu198649 Linux - General 3 12-05-2011 03:40 AM
linux system calls rblampain Programming 3 02-24-2010 11:06 PM
LINUX System calls Jitin Programming 1 08-02-2006 08:47 PM
linux system calls blanny Programming 4 03-04-2006 12:15 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration