<?xml version="1.0" encoding="ISO-8859-1"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>C Board - Linux Programming</title>
		<link>http://cboard.cprogramming.com</link>
		<description>Questions specific to linux programming</description>
		<language>en</language>
		<lastBuildDate>Sat, 21 Nov 2009 01:51:47 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://cboard.cprogramming.com/images/misc/rss.jpg</url>
			<title>C Board - Linux Programming</title>
			<link>http://cboard.cprogramming.com</link>
		</image>
		<item>
			<title>C and RS232 problem</title>
			<link>http://cboard.cprogramming.com/linux-programming/121800-c-rs232-problem.html</link>
			<pubDate>Fri, 20 Nov 2009 16:39:55 GMT</pubDate>
			<description><![CDATA[Hi all, 
 
I'm in troubles in writing C drivers for a device using RS232 port. 
I cannot establish any communications between my linux box and that device! On the other hand I'm sure the RS232 on the device is working properly because using a hyperterminal on another Windows machine everything...]]></description>
			<content:encoded><![CDATA[<div>Hi all,<br />
<br />
I'm in troubles in writing C drivers for a device using RS232 port.<br />
I cannot establish any communications between my linux box and that device! On the other hand I'm sure the RS232 on the device is working properly because using a hyperterminal on another Windows machine everything works fine.<br />
<br />
Here is what is reported in the manual of the device:<br />
<br />
&quot;The RS232 communication parameters are:<br />
9600 BAUD, 8 BIT, NO PARITY, 1 STOP BIT (8N1)<br />
...<br />
Each command is an ASCII string, and must be terminated by a Carriage Return character[...] The responses are terminated by a Carriage Return character.&quot;<br />
<br />
Here is my code:<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">#include &lt;stdio.h&gt;<br />
#include &lt;string.h&gt;<br />
#include &lt;unistd.h&gt;<br />
#include &lt;fcntl.h&gt;<br />
#include &lt;termios.h&gt;<br />
#include &lt;stdlib.h&gt;<br />
<br />
int open_port(char *port)<br />
{<br />
<br />
&nbsp; int fd;<br />
&nbsp; if (!port)<br />
&nbsp; &nbsp; return -1;<br />
&nbsp; if ((fd=open(port,O_RDWR | O_NOCTTY | O_NDELAY))&lt;0)<br />
&nbsp; &nbsp; return -2;<br />
&nbsp; fcntl(fd,F_SETFL,0);<br />
&nbsp; return fd;<br />
}<br />
<br />
void configure_port(int fd)<br />
{<br />
&nbsp; struct termios newtio;<br />
&nbsp; bzero(&amp;newtio,sizeof(newtio));<br />
&nbsp; newtio.c_cflag = BAUDRATE | CS8 | CLOCAL | CREAD ;<br />
&nbsp; newtio.c_iflag = IGNPAR | ICRNL;<br />
&nbsp; newtio.c_oflag=0;<br />
&nbsp; newtio.c_lflag=ICANON;<br />
&nbsp; tcflush(fd,TCIFLUSH);<br />
&nbsp; tcsetattr(fd,TCSANOW,&amp;newtio);<br />
}<br />
<br />
int main (int argc, char **argv)<br />
{<br />
&nbsp; int fd;<br />
&nbsp; char PORT[]=&quot;/dev/ttyUSB0&quot;;<br />
&nbsp; int status;<br />
&nbsp; char buffer[255];<br />
<br />
&nbsp; if ((fd=open_port(PORT))&lt;0)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; printf(&quot;Error in opening serial port fd=%d\n&quot;,fd);<br />
&nbsp; &nbsp; &nbsp; return -1;<br />
&nbsp; &nbsp; }<br />
<br />
&nbsp; configure_port(fd);<br />
<br />
&nbsp; if ((status=write(fd,&quot;SE\r&quot;,3))&lt;3)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; printf(&quot;Error in writing on serial port\n&quot;);<br />
&nbsp; &nbsp; &nbsp; return -1;<br />
&nbsp; &nbsp; }<br />
<br />
&nbsp;  status=read(fd,buffer,255);<br />
&nbsp;  buffer[status]=0;<br />
&nbsp;  printf(&quot;:%s:%d\n&quot;,buffer,status);<br />
&nbsp;  return 0;<br />
}</code><hr />
</div>This code is compiled without any errors or warnings but unfortunately I cannot read correct values from the device (the device should respond 2 digits ASCII<br />
code terminated with Carriage Return character to the command SE).<br />
In particular sometimes it happens to read &quot;SE\r&quot; (so exactly the same command I write on the RS232 from the pc) and in some other cases the read values are wrong in format and in length.<br />
I cannot figure out where the problem is. I guess it is a rs232 configuration problem because as I told you using hyperterminal on Windows everything is ok but I really did not realize what is going wrong.<br />
Maybe the problem is that I'm using a serial to usb converter and it needs further configuration I'm missing? (The same converter works with hyperterminal).<br />
By the way here is the output of my linux box when I plug in the converter:<br />
<br />
usb 2-1: new full speed USB device using uhci_hcd and address 13<br />
usb 2-1: configuration #1 chosen from 1 choice<br />
pl2303 2-1:1.0 pl2303 converter detected<br />
usb 2-1: pl2303 converter now attached to ttyUSB0<br />
<br />
Any suggestions?<br />
<br />
Any help is really appreciated.<br />
<br />
Thank you for your attention.<br />
<br />
Bye</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/linux-programming/">Linux Programming</category>
			<dc:creator>gda</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/linux-programming/121800-c-rs232-problem.html</guid>
		</item>
		<item>
			<title>To kill a LED (during shutdown)</title>
			<link>http://cboard.cprogramming.com/linux-programming/121781-kill-led-during-shutdown.html</link>
			<pubDate>Thu, 19 Nov 2009 22:52:51 GMT</pubDate>
			<description>During system shutdown, what would be the best was to execute some code after the drives have been unmounted? 
The system consists of a x86 system running Debian Linux from a CompactFlash. On the end product there will be no monitor so I need to disable a LED (simple I/O write) to indicate to the...</description>
			<content:encoded><![CDATA[<div>During system shutdown, what would be the best was to execute some code after the drives have been unmounted?<br />
The system consists of a x86 system running Debian Linux from a CompactFlash. On the end product there will be no monitor so I need to disable a LED (simple I/O write) to indicate to the user that it is safe to power-down.<br />
My current train of thought is to write a daemon that loads at startup and does the I/O write at exit. But, being a linux noob, I'm not sure how to a) hook the system shutdown to the daemon or b) tie into the exit functionality within the daemon code. <br />
Any suggestions/comments?</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/linux-programming/">Linux Programming</category>
			<dc:creator>pdphillips</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/linux-programming/121781-kill-led-during-shutdown.html</guid>
		</item>
		<item>
			<title>Makefile</title>
			<link>http://cboard.cprogramming.com/linux-programming/121677-makefile.html</link>
			<pubDate>Mon, 16 Nov 2009 16:13:35 GMT</pubDate>
			<description><![CDATA[Hello. 
 
Is it possible somehow to specify a debug option in a Makefile. So I can run  
 
> make debug module 
 
The only solution I have found now is to use debug-module for every module I have. 
 
Anyone knows? :)]]></description>
			<content:encoded><![CDATA[<div>Hello.<br />
<br />
Is it possible somehow to specify a debug option in a Makefile. So I can run <br />
<br />
&gt; make debug module<br />
<br />
The only solution I have found now is to use debug-module for every module I have.<br />
<br />
Anyone knows? :)</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/linux-programming/">Linux Programming</category>
			<dc:creator>daghenningsorbo</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/linux-programming/121677-makefile.html</guid>
		</item>
		<item>
			<title>Script File</title>
			<link>http://cboard.cprogramming.com/linux-programming/121660-script-file.html</link>
			<pubDate>Mon, 16 Nov 2009 01:24:21 GMT</pubDate>
			<description>---Quote--- 
  
My teacher gave us this assigment and he is very vague on his questions. But the question reads write the largest script file that calculates the smallest of three integer numbers that are read from the keyboard. Make it able to recongnize some input errors. I guess he does care...</description>
			<content:encoded><![CDATA[<div><div style="margin:20px; margin-top:5px; ">
	<div class="smallfont" style="margin-bottom:2px">Quote:</div>
	<table cellpadding="1" cellspacing="0" border="0" width="100%">
	<tr>
		<td class="alt2">
			<hr />
			
				My teacher gave us this assigment and he is very vague on his questions. But the question reads write the largest script file that calculates the smallest of three integer numbers that are read from the keyboard. Make it able to recongnize some input errors. I guess he does care what type of errors they are as long as they can be read. The problem is I don't know at all how to do that part of the assigment.
			
			<hr />
		</td>
	</tr>
	</table>
</div><div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">#This program accepts three numbers and shows the largest of them<br />
#<br />
echo<br />
echo &quot;Enter three numbers and I will show you the largest of them&gt;&gt; \c&quot;<br />
read num1 num2 num3<br />
if test &quot;$num1&quot; -gt &quot;$num2&quot; -a &quot;$num1&quot; -gt &quot;$num3&quot;<br />
then<br />
&nbsp;  echo &quot;The largest number is: $num1&quot;<br />
elif test &quot;$num2&quot; -gt &quot;$num1&quot; -a &quot;$num2&quot; -gt&nbsp; &quot;$num3&quot;<br />
then<br />
&nbsp;  echo &quot;The largest number is:$num2&quot;<br />
else<br />
&nbsp; echo &quot;The largest number is:$num3&quot;<br />
fi<br />
echo &quot;done!&quot;<br />
echo<br />
exit 0</code><hr />
</div></div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/linux-programming/">Linux Programming</category>
			<dc:creator>victory1</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/linux-programming/121660-script-file.html</guid>
		</item>
		<item>
			<title>segfault if I call func from a lib, why?</title>
			<link>http://cboard.cprogramming.com/linux-programming/121576-segfault-if-i-call-func-lib-why.html</link>
			<pubDate>Fri, 13 Nov 2009 14:33:43 GMT</pubDate>
			<description><![CDATA[hi every1, 
perhaps some one be able to help me in that worst deal... 
actually I use libiptc & libxtables from netfilter project and have got this trace.... 
it happening every time if I do to call function from those libraries, e.g xtables_error(), xtables_find_target(), add_command() and any...]]></description>
			<content:encoded><![CDATA[<div>hi every1,<br />
perhaps some one be able to help me in that worst deal...<br />
actually I use libiptc &amp; libxtables from netfilter project and have got this trace....<br />
it happening every time if I do to call function from those libraries, e.g xtables_error(), xtables_find_target(), add_command() and any other..., but unfortunately everywhere I has segfault.<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">==21005== Invalid read of size 4<br />
==21005==&nbsp; &nbsp; at 0x4050D4B: xtables_find_target (xtables.c:626)<br />
==21005==&nbsp; &nbsp; by 0x804C723: main (in /home/quant/table)<br />
==21005==&nbsp; Address 0x4 is not stack'd, malloc'd or (recently) free'd<br />
==21005==<br />
==21005== Process terminating with default action of signal 11 (SIGSEGV)<br />
==21005==&nbsp; Access not within mapped region at address 0x4<br />
==21005==&nbsp; &nbsp; at 0x4050D4B: xtables_find_target (xtables.c:626)<br />
==21005==&nbsp; &nbsp; by 0x804C723: main (in /home/quant/table)<br />
--21005-- REDIR: 0x40c4790 (free) redirected to 0x4022ad0 (free)<br />
==21005==<br />
==21005== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 19 from 1)</code><hr />
</div>there... how i do configuration libs after building and installation.<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">./configure --prefix=/usr/local --enable-devel --enable-libipq --enable-static</code><hr />
</div></div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/linux-programming/">Linux Programming</category>
			<dc:creator>quantt</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/linux-programming/121576-segfault-if-i-call-func-lib-why.html</guid>
		</item>
		<item>
			<title>Capturing stderr from an execv()ed process</title>
			<link>http://cboard.cprogramming.com/linux-programming/121461-capturing-stderr-execv-ed-process.html</link>
			<pubDate>Tue, 10 Nov 2009 14:45:53 GMT</pubDate>
			<description><![CDATA[I'm trying to capture the stderr from a process which is being called by execv(). Instead, however, it seems to be writing to a descriptor that isn't even opened in this process. The short description of what I'm trying to do is I'm first creating a pipe. Then through clever use of close() and...]]></description>
			<content:encoded><![CDATA[<div>I'm trying to capture the stderr from a process which is being called by execv(). Instead, however, it seems to be writing to a descriptor that isn't even opened in this process. The short description of what I'm trying to do is I'm first creating a pipe. Then through clever use of close() and dup() I'm making the write end of the pipe STDERR_FILENO (which is 2, I believe). Then I'm calling fork() and in the child I'm calling execv(). However, the output from this process is going to the original STDERR_FILENO, not the pipe!<br />
A longer explanation follows:<br />
First, in my process I'm changing the stderr descriptor to a file<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">close(STDERR_FILENO);<br />
int des = open(&quot;stderr.txt&quot;, &quot;wt&quot;);<br />
assert(des == STDERR_FILENO);//trust me, it works</code><hr />
</div>Then later in my program:<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">int fds[2];<br />
pipe(fds);<br />
int desBackupStderr = dup(STDERR_FILENO);//this is now a stderr<br />
close(STDERR_FILENO);<br />
int desPipeWrite = dup(fds[1]);<br />
assert(desPipeWrite == STDERR_FILENO);//trust me<br />
switch(fork()) {<br />
&nbsp; &nbsp; case 0://child<br />
&nbsp; &nbsp; &nbsp; &nbsp; close(desBackupStderr);//this process no longer has ANY descriptor open to the file stderr.txt<br />
&nbsp; &nbsp; &nbsp; &nbsp; CaptureLSOF();//this captures lsof -p getpid() to a file, which proves the above axiom<br />
&nbsp; &nbsp; &nbsp; &nbsp; const char *p = &quot;this should make it to the read-end of the pipe&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; write(STDERR_FILENO, p, strlen(p));//this did make it into the pipe!<br />
&nbsp; &nbsp; &nbsp; &nbsp; execv(blah, bLah);<br />
&nbsp; &nbsp; &nbsp; &nbsp; assert(false);//never happens<br />
&nbsp; &nbsp; default://parent<br />
&nbsp; &nbsp; &nbsp; &nbsp;  close(STDERR_FILENO);//closing write end of the pipe in the parent<br />
&nbsp; &nbsp; &nbsp; &nbsp;  int des = dup(desBackupStderr);<br />
&nbsp; &nbsp; &nbsp; &nbsp;  assert(des == STDERR_FILENO);//trust me<br />
}</code><hr />
</div>Of course, I also close unnecessary duplicate descriptors for tidiness, but I left that out of here for simplicity. What I find hard to understand is that the call to execv() has writes to the stderr going to the file stderr.txt, even though the file written by CaptureLSOF() proves that that process does not have anything open to that file. The code also proves that writes to STDERR_FILENO do make it into the pipe. It's as if the program called by execv() gets a hold the descriptor to stderr.txt through the group process id, or the parent process id? I dunno, I'm grasping at straws.<br />
FWIW, the program execv() is calling is sendmail (a la Postfix). I don't know what difference that could make.<br />
<br />
Edit - It is also worth pointing out that I have another pipe opened, whose read end is connected to the stdin of the child process. Everything I write to the pipe from the parent <i>does</i> make it to the stdin of the child process.</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/linux-programming/">Linux Programming</category>
			<dc:creator>Angus</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/linux-programming/121461-capturing-stderr-execv-ed-process.html</guid>
		</item>
		<item>
			<title><![CDATA[CLI & 56k Usage Questions]]></title>
			<link>http://cboard.cprogramming.com/linux-programming/121426-cli-56k-usage-questions.html</link>
			<pubDate>Mon, 09 Nov 2009 18:06:11 GMT</pubDate>
			<description><![CDATA[I have a few questions for you guys. I haven't programmed for a while, but I used to do a lot of socket programming (windows and unix sockets), ddos tools and file servers, etc. I've also done opengl in c++ for video games, and a lot of scripting for the web (msql, perl, php, etc). I'm still...]]></description>
			<content:encoded><![CDATA[<div>I have a few questions for you guys. I haven't programmed for a while, but I used to do a lot of socket programming (windows and unix sockets), ddos tools and file servers, etc. I've also done opengl in c++ for video games, and a lot of scripting for the web (msql, perl, php, etc). I'm still learning shellcode and reading books on it. <br />
<br />
Either way, there aren't many tech jobs in my area. <br />
<br />
I'm proposing an application to my company in two to three months. My main register workstation operates on some linux/unix distro (don't know which), but I need to find a dialup application, and program a separate application which would automatically dial into the store's intranet switch somewhere over in Ohio, and we would have access to their inventory system and online catalog for customers. Here's the thing..we're still on 56k. I have no issues working in lower bandwidth, but I've never done much in this regard.<br />
<br />
1. How can I find out what specific distro &amp; shell version I'm using? I can offer command line prompt results if you ask.<br />
2. Can you recommend any resources or particular techniques / methods of accomplishing this goal? I don't expect a raise out of this, but I might get a nice IT position when it goes through. <br />
<br />
I'm still a college student, so a job like that would be nice.</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/linux-programming/">Linux Programming</category>
			<dc:creator>mezmiro2005</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/linux-programming/121426-cli-56k-usage-questions.html</guid>
		</item>
		<item>
			<title>Viewing a buffer when using std::string advice.</title>
			<link>http://cboard.cprogramming.com/linux-programming/121333-viewing-buffer-when-using-std-string-advice.html</link>
			<pubDate>Fri, 06 Nov 2009 01:24:04 GMT</pubDate>
			<description><![CDATA[I have a task to do about the std::string datatype.  
 
To do the task I need to use the KDevelop IDE and be able to find the size of the buffer being used when performing operations upon strings, but never having used KDevelop before, I'm at a complete loss. 
 
Could anyone be so kind as to give...]]></description>
			<content:encoded><![CDATA[<div>I have a task to do about the std::string datatype. <br />
<br />
To do the task I need to use the KDevelop IDE and be able to find the size of the buffer being used when performing operations upon strings, but never having used KDevelop before, I'm at a complete loss.<br />
<br />
Could anyone be so kind as to give me some direction as how to go about viewing a buffer which is in use? Can it's contents be viewed within a window of the IDE, or would I have to call functions to 'cout' details about the buffer being used?<br />
<br />
I'm at a complete loss about this, so any info is really appreciated.<br />
<br />
Many many thanks.</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/linux-programming/">Linux Programming</category>
			<dc:creator>Swerve</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/linux-programming/121333-viewing-buffer-when-using-std-string-advice.html</guid>
		</item>
		<item>
			<title>Offline C++ documentation</title>
			<link>http://cboard.cprogramming.com/linux-programming/121256-offline-cplusplus-documentation.html</link>
			<pubDate>Tue, 03 Nov 2009 20:49:38 GMT</pubDate>
			<description><![CDATA[I looked, but haven't been able to find downloadable C++ library documentation (preferably in HTML and/or man page format). Since I spend a lot of time offline, online resources like cppreference.com won't help me too much.I've saved many cppreference.com pages, but it isn't the same. :) I also...]]></description>
			<content:encoded><![CDATA[<div>I looked, but haven't been able to find downloadable C++ library documentation (preferably in HTML and/or man page format). Since I spend a lot of time offline, online resources like cppreference.com won't help me too much.I've saved many cppreference.com pages, but it isn't the same. :) I also tried installing the libstdc++6-4.3.-doc package, but that just seems to have developer documentation, not API reference.<br />
<br />
Is there any C++ documentation (particularly for the STL) that I can download? Thanks.</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/linux-programming/">Linux Programming</category>
			<dc:creator>dwks</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/linux-programming/121256-offline-cplusplus-documentation.html</guid>
		</item>
		<item>
			<title>C bufferoverflow question. can anyone solve it?</title>
			<link>http://cboard.cprogramming.com/linux-programming/121244-c-bufferoverflow-question-can-anyone-solve.html</link>
			<pubDate>Tue, 03 Nov 2009 10:06:43 GMT</pubDate>
			<description><![CDATA[Consider the following C program: 
 
Code: 
--------- 
void func(char * str) 
{ 
char buff[16]; 
strcpy(buff,str); 
} 
void main(int argc, char * argv[])]]></description>
			<content:encoded><![CDATA[<div>Consider the following C program:<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">void func(char * str)<br />
{<br />
char buff[16];<br />
strcpy(buff,str);<br />
}<br />
void main(int argc, char * argv[])<br />
{<br />
int check = 1;<br />
func(argv);<br />
if(check == 1)<br />
{<br />
printf(“check should be 1 (%d)\n”,check);<br />
} else<br />
{<br />
Printf(“check should not be 1 (%d)\n”,check);<br />
}<br />
}</code><hr />
</div>Q1. Mount buffer overflow attack on the given program and corrupt the variable “check” with the value 25.<br />
<br />
After the buffer overflow attack the output of the program should be the following:<br />
<br />
check should not be 1 (25)<br />
<br />
Q2. Mount buffer overflow attack on the given program and bypass the “if” condition.<br />
<br />
After the buffer overflow attack the output of the program should be the following:<br />
check should not be 1 (1)<br />
<br />
Q3. Increase the size of the buffer “buff” to as much as you want. Mount a buffer overflow attack and make the program execute a shell (“/bin/bash”).</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/linux-programming/">Linux Programming</category>
			<dc:creator>asdfgh</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/linux-programming/121244-c-bufferoverflow-question-can-anyone-solve.html</guid>
		</item>
		<item>
			<title>Identifying sparse files programatically in C</title>
			<link>http://cboard.cprogramming.com/linux-programming/121243-identifying-sparse-files-programatically-c.html</link>
			<pubDate>Tue, 03 Nov 2009 09:22:42 GMT</pubDate>
			<description>How would I identify sparse files through a C program ?I know that for a sparse file, its real size would be less than that returned by stat(). How would I get the real size ? 
 
Thanks</description>
			<content:encoded><![CDATA[<div>How would I identify sparse files through a C program ?I know that for a sparse file, its real size would be less than that returned by stat(). How would I get the real size ?<br />
<br />
Thanks</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/linux-programming/">Linux Programming</category>
			<dc:creator>rohan_ak1</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/linux-programming/121243-identifying-sparse-files-programatically-c.html</guid>
		</item>
		<item>
			<title>how to install openoffice in rhel5</title>
			<link>http://cboard.cprogramming.com/linux-programming/121242-how-install-openoffice-rhel5.html</link>
			<pubDate>Tue, 03 Nov 2009 06:34:09 GMT</pubDate>
			<description>how to install openoffice in rhel5 
 
anybody can help me?</description>
			<content:encoded><![CDATA[<div>how to install openoffice in rhel5<br />
<br />
anybody can help me?</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/linux-programming/">Linux Programming</category>
			<dc:creator>nkrao123@gmail.</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/linux-programming/121242-how-install-openoffice-rhel5.html</guid>
		</item>
		<item>
			<title>posix sockets in c</title>
			<link>http://cboard.cprogramming.com/linux-programming/121131-posix-sockets-c.html</link>
			<pubDate>Fri, 30 Oct 2009 16:25:08 GMT</pubDate>
			<description><![CDATA[I'm trying to setup a connection between a client and a server using sockets. 
I'm doing: 
 
test.h: 
--------- 
 
Code: 
--------- 
#include <stdio.h> 
#include <stdlib.h>]]></description>
			<content:encoded><![CDATA[<div>I'm trying to setup a connection between a client and a server using sockets.<br />
I'm doing:<br />
<br />
test.h:<br />
---------<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">#include &lt;stdio.h&gt;<br />
#include &lt;stdlib.h&gt;<br />
#include &lt;string.h&gt;<br />
#include &lt;unistd.h&gt;<br />
#include &lt;errno.h&gt;<br />
#include &lt;signal.h&gt;<br />
<br />
#include &lt;sys/types.h&gt;<br />
#include &lt;sys/socket.h&gt;<br />
#include &lt;sys/ipc.h&gt;<br />
#include &lt;sys/shm.h&gt;<br />
<br />
#define MYSOCKET &quot;/tmp/mysocket&quot;<br />
#define LISENQ 20<br />
<br />
void error(char *msg)<br />
{<br />
&nbsp; &nbsp; perror(msg);<br />
&nbsp; &nbsp; exit(1);<br />
}</code><hr />
</div>server.c:<br />
----------<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">#include &quot;test.h&quot;<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; struct sockaddr serveraddr, clientaddr;<br />
&nbsp; &nbsp; int sd, sd_new;<br />
&nbsp; &nbsp; socklen_t serverlen, clientlen;<br />
&nbsp; &nbsp; char buf[256];<br />
<br />
&nbsp; &nbsp; sd = socket(AF_UNIX, SOCK_STREAM, 0);<br />
&nbsp; &nbsp; if (sd &lt; 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; error(&quot;server socket failure&quot;);<br />
<br />
&nbsp; &nbsp; bzero(&amp;serveraddr, sizeof(serveraddr));<br />
&nbsp; &nbsp; bzero(&amp;clientaddr, sizeof(clientaddr));<br />
<br />
&nbsp; &nbsp; serveraddr.sa_family = AF_UNIX;<br />
&nbsp; &nbsp; strcpy(serveraddr.sa_data, MYSOCKET);<br />
&nbsp; &nbsp; serverlen = sizeof(serveraddr.sa_family) + strlen(serveraddr.sa_data);<br />
&nbsp; &nbsp; clientlen = sizeof(clientaddr.sa_family) + strlen(clientaddr.sa_data);<br />
<br />
&nbsp; &nbsp; unlink(MYSOCKET);<br />
<br />
&nbsp; &nbsp; if (bind(sd, (struct sockaddr *)&amp;serveraddr, serverlen) &lt; 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; error(&quot;server bind failure&quot;);<br />
<br />
&nbsp; &nbsp; if (listen(sd, LISENQ) &lt; 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; error(&quot;server listen failure&quot;);<br />
<br />
&nbsp; &nbsp; for(;;)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; sd_new = accept(sd, (struct sockaddr *)&amp;clientaddr, &amp;clientlen);<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (sd_new &lt; 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; error(&quot;server accept failure&quot;);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (fork() == 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; read(sd_new, buf, sizeof(buf));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Got msg: %s&quot;, buf);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; close(sd_new);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit(0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; close (sd);<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; return 0;<br />
}</code><hr />
</div>client:<br />
-------<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">#include &quot;test.h&quot;<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; struct sockaddr serveraddr;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int sd;<br />
&nbsp; &nbsp; &nbsp; &nbsp; socklen_t serverlen;<br />
&nbsp; &nbsp; &nbsp; &nbsp; char buf[256];<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; sd = socket(AF_UNIX, SOCK_STREAM, 0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (sd &lt; 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; error(&quot;client socket failure&quot;);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; serveraddr.sa_family = AF_UNIX;<br />
&nbsp; &nbsp; &nbsp; &nbsp; strcpy(serveraddr.sa_data, MYSOCKET);<br />
&nbsp; &nbsp; &nbsp; &nbsp; serverlen = sizeof(serveraddr.sa_family) + strlen(serveraddr.sa_data);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (connect(sd, (struct sockaddr *)&amp;serveraddr, serverlen) &lt; 0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; error(&quot;client connect failure&quot;);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; puts(&quot;client connected!&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; while(1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;&gt;&gt; &quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;%s&quot;, &amp;buf);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; write(sd, buf, sizeof(buf));<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; close(sd);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}</code><hr />
</div>- server runs and waits<br />
- client runs and stops with message : client connect failure: Success<br />
 and crashes the server with msg: Got msg: &#65533;&#1162;&#65533;server accept failure: Bad file descriptor<br />
<br />
need some advice please</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/linux-programming/">Linux Programming</category>
			<dc:creator>tsiknas</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/linux-programming/121131-posix-sockets-c.html</guid>
		</item>
		<item>
			<title>Replacing System Calls in 2.6 (opinions from the kernel hackers here?)</title>
			<link>http://cboard.cprogramming.com/linux-programming/121087-replacing-system-calls-2-6-opinions-kernel-hackers-here.html</link>
			<pubDate>Thu, 29 Oct 2009 02:47:54 GMT</pubDate>
			<description><![CDATA[Hey all, 
 
So it's been a while since I posted. In what little time I've had for personal projects I've been doing a lot of reading. I'll probably get back to actual coding pretty soon (this is still part of my very long-term project to make my own distro) - and one snag I'm gonna have to solve...]]></description>
			<content:encoded><![CDATA[<div>Hey all,<br />
<br />
So it's been a while since I posted. In what little time I've had for personal projects I've been doing a lot of reading. I'll probably get back to actual coding pretty soon (this is still part of my very long-term project to make my own distro) - and one snag I'm gonna have to solve pretty early on is replacing some system calls. It used to be nice and easy, apparently (and I got my hopes up before finding out about this change), but the system call table is no longer exported (as of 2.6).<br />
<br />
I've been looking around, and it sounds like I have a few other options. If you have any opinions - please share! Despite all the reading, I still feel very new to this. Also, if I'm missing a good solution, please let me know.<br />
<br />
1. There's a kernel patch that will export the table anyway, but I'd really like to avoid the idea of needing a recompiled kernel in order to actually use this part of my code. Doing this part at run-time is a big priority of mine - so I hope it's possible.<br />
<br />
2. I've seen several algorithms for calculating the location of the call table. It's extremely hacky, and only works on x86 (not that I care about that part, really). Any opinions on this? I haven't tried it, but would that be reliable? I'm okay with hacky code as long as it's reliable! (edit: after some more searching I've found that this is NOT reliable. Some of the items used in tracking down the call table have moved, and I'm sure any future similiar algorithm would have the same vulnerability)<br />
<br />
3. I've heard a couple of people recommend security modules for intercepting system calls, but haven't heard much about them before. Is this worth investigating further? To me it sounds the hooks just let you know when a system call is called. It doesn't actually let you override that call entirely. Am I wrong? And if so, what do you recommend for learning about them? Online information seems to be scarce in that area.<br />
<br />
Thanks for any advice!</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/linux-programming/">Linux Programming</category>
			<dc:creator>sean</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/linux-programming/121087-replacing-system-calls-2-6-opinions-kernel-hackers-here.html</guid>
		</item>
		<item>
			<title>Joining consecutive lines</title>
			<link>http://cboard.cprogramming.com/linux-programming/121064-joining-consecutive-lines.html</link>
			<pubDate>Wed, 28 Oct 2009 11:04:40 GMT</pubDate>
			<description>Hi *, 
 
Can anyone tell me if there is an unix utility to join two consecutive lines ? 
 
ex: 
 
$ cat  file 
a 
1 
b</description>
			<content:encoded><![CDATA[<div>Hi *,<br />
<br />
Can anyone tell me if there is an unix utility to join two consecutive lines ?<br />
<br />
ex:<br />
<br />
$ cat  file<br />
a<br />
1<br />
b<br />
2<br />
c<br />
3<br />
<br />
output should be :<br />
a 1<br />
b 2<br />
c 3<br />
<br />
Thanks,<br />
14341</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/linux-programming/">Linux Programming</category>
			<dc:creator>14341</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/linux-programming/121064-joining-consecutive-lines.html</guid>
		</item>
	</channel>
</rss>
