- strcpy(symlinkname, "../");
- strncat(symlinkname, filename, sizeof(symlinkname) - 4);
+ if (first_name[0] == linkname[0])
+ strncpy(symlinkname, first_name, sizeof(symlinkname) - 1);
+ else {
+ strcpy(symlinkname, "../");
+ strncat(symlinkname, filename, sizeof(symlinkname) - 4);
+ }