Deleting a line from a file

Saket Sinha saket.sinha89 at gmail.com
Wed May 14 12:43:51 EDT 2014


Please find response inline.

On Wed, May 14, 2014 at 9:44 PM,  <Valdis.Kletnieks at vt.edu> wrote:
> On Wed, 14 May 2014 21:27:06 +0530, Saket Sinha said:
>
>>      char newFileName[PATH_MAX];
>
>>      tabFileNew = setmntent(newFileName, "w");
>
> And what is the new file name? You have random trash on the stack here.

int removeEntryFromFSTAB(const char * fullPath, const char * fileName);
I am sending /etc/fstab in fileName to this function and the path to
be deleted in fullPath


NOW
 char newFileName[PATH_MAX];
......
.......
 rename(newFileName, fileName));


I am taking a new file, writing my entries to it and then replacing it
with original file. I don't find anything wrong with that

> (Note that this is C 101 - if you can't debug this on your own, you
> probably shouldn't be messing with filesystem code until you have more
> C experience)
>
Sorry but I haven't been able to debug that. I admit it.

Regards,
Saket Sinha



More information about the Kernelnewbies mailing list