Skip to content
Snippets Groups Projects
Commit 0dc13af1 authored by Moe Jette's avatar Moe Jette
Browse files

Add logic to print contents of open file in debug mode to

help determine what the file is.
parent a20fe795
No related branches found
No related tags found
No related merge requests found
...@@ -23,8 +23,10 @@ ...@@ -23,8 +23,10 @@
* with SLURM; if not, write to the Free Software Foundation, Inc., * with SLURM; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
\*****************************************************************************/ \*****************************************************************************/
#include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> /* exit() prototype is here */ #include <stdlib.h> /* exit() prototype is here */
#include <string.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <time.h> #include <time.h>
...@@ -48,12 +50,28 @@ main (int argc, char **argv) ...@@ -48,12 +50,28 @@ main (int argc, char **argv)
continue; continue;
printf("FAILED: File descriptor %d is open\n", i); printf("FAILED: File descriptor %d is open\n", i);
#if _DEBUG #if _DEBUG
printf(" st_mode: 0%o\n",(int) buf.st_mode); {
printf(" st_uid: %d\n", (int) buf.st_uid); char data[64];
printf(" st_gid: %d\n", (int) buf.st_gid); int j;
printf(" st_size: %d\n", (int) buf.st_size); size_t data_size;
printf(" st_ino: %d\n", (int) buf.st_ino);
printf(" st_dev: %d\n", (int) buf.st_dev); printf(" st_mode: 0%o\n",(int) buf.st_mode);
printf(" st_uid: %d\n", (int) buf.st_uid);
printf(" st_gid: %d\n", (int) buf.st_gid);
printf(" st_size: %d\n", (int) buf.st_size);
printf(" st_ino: %d\n", (int) buf.st_ino);
printf(" st_dev: %d\n", (int) buf.st_dev);
lseek(i, 0, SEEK_SET);
data_size = read(i, data, 64);
if (data_size < 0)
printf(" read error: %s", strerror(errno));
else {
printf(" bytes read: %d\n", (int) data_size);
for (j=0; j<data_size; j++)
printf(" data[%d]:0x%x\n", j, data[j]);
}
}
#endif #endif
} }
exit(0); exit(0);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment