At "strncpy(pathname,fullname,pathname_length);" we're getting a segfault and we're not quite sure why. In our case checked with gdb at the time filename is test25.txt and pathname_length is 6 and fullname is /test/test25.txt. Any Suggestions?
Code:
#include <Kernel.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
static const String PROGRAM_NAME = "rm";
int main(int argc,char **argv)
{
Kernel::initialize();
DirectoryEntry *directoryEntry = new DirectoryEntry();
int x=0;
int status = 0;
String fullname = argv[1];
String filename = strrchr(fullname,'/')+1;
String pathname;
size_t pathname_length = strlen(fullname) - strlen(filename);
fprintf(stderr,"pathname_length:%d\n",pathname_length);
strncpy(pathname,fullname,pathname_length);
...
...
If you need any more information to help us let us know. Thanks!