1- I wonder why you suppose rename fails always?
Please on your linux try
touch oldname.txt
ln oldname.txt newname.txt (this is hard link not symlink)
Then compile and run the file on
http://www.cplusplus.com/reference/c...cstdio/rename/
You will see that the same files will remain as they are and no perror - I was surprised by this fact - if both file names are hardlinked, rename doesnt fail
2- Full path
IT IS NOT /
is on a mount drive actually - since my embedded system is on flash, we mount it as /mnt/sram/......
Both files are on the same directory /mnt/sram
ls /mnt/sram/ -l
drwxr-xr-x 4 root root 0 Jul 18 00:49 .
drwxr-xr-x 11 root root 0 Jan 1 1970 ..
-rw------- 2 usr1 users 442 Jul 18 03:44 config
-rw------- 2 usr1 users 442 Jul 18 03:44 config.tmp
3- My rename usage is childish from cplusplus.com
char *name ="config";
char *newname =strcat (name, ".tmp");
/* I do parsing and processing here*/
result= rename( name , newname );
if ( result != 0 ) perror (return -error from www-numi.fnal.gov/offline_software/srt_public_context/WebDocs/Errors/unix_system_errors.html);
About memory, normally I have plenty of memory onf my /mnt/sram/ - besides I checked the resources of the system, 10% cpu time, 33% memory utilization normal operation
BUT:
Could you refer to that maybe?:
ONLY at the time when my code failed - the hardlink was created - that time rename had NOMEM Linux Error??
This is only duplicate-able when I:
while (p) {p = (*char) malloc(10);} And this will leave only 10 bytes data memory for rename
rename here!
Actually I tried duplicating the rename failure, by infinite looping and renaming, but still I couldn't create the hard link on normal system resources
Please advise
thanks