Damn tar archiver MAHHHH -> printf's

This commit is contained in:
Pentium44 2021-06-29 21:18:00 -07:00
parent 0e12919bb3
commit 76c042e0cb

View File

@ -687,11 +687,15 @@ int format_tar_data(struct tar_t * entry, const char * filename, const char verb
memset(entry, 0, sizeof(struct tar_t)); memset(entry, 0, sizeof(struct tar_t));
strcpy(entry -> original_name, filename); strcpy(entry -> original_name, filename);
strcpy(entry -> name, filename + move); strcpy(entry -> name, filename + move);
printf("Structure sizes: %d %d %d %d %d\n", sizeof(entry -> mode),
sizeof(entry -> uid), sizeof(entry -> gid), sizeof(entry -> size), sizeof(entry -> mtime));
snprintf(entry -> mode, sizeof(entry -> mode), "%07o", st.st_mode & 0777); snprintf(entry -> mode, sizeof(entry -> mode), "%07o", st.st_mode & 0777);
snprintf(entry -> uid, sizeof(entry -> uid), "%07o", st.st_uid); snprintf(entry -> uid, sizeof(entry -> uid), "%07o", st.st_uid);
snprintf(entry -> gid, sizeof(entry -> gid), "%07o", st.st_gid); snprintf(entry -> gid, sizeof(entry -> gid), "%07o", st.st_gid);
snprintf(entry -> size, sizeof(entry -> size), "%011o", (int) st.st_size); snprintf(entry -> size, sizeof(entry -> size), "%011o", (int) st.st_size);
snprintf(entry -> mtime, sizeof(entry -> mtime), "%011o", (int) st.st_mtime); snprintf(entry -> mtime, sizeof(entry -> mtime), "%011o", (int) st.st_mtime);
printf("%07o%07o%07o%011o%011o\n", st.st_mode & 0777, st.st_uid, st.st_gid,
(int) st.st_size, (int) st.st_mtime);
strncpy(entry -> group, "None", 5); // default value strncpy(entry -> group, "None", 5); // default value
memcpy(entry -> ustar, "ustar \x00", 8); memcpy(entry -> ustar, "ustar \x00", 8);