-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e634ab8
commit ffef81a
Showing
6 changed files
with
81 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* @file tarball.h | ||
* @author Pradosh ([email protected]) | ||
* @brief | ||
* @version 0.1 | ||
* @date 2023-12-30 | ||
* | ||
* @copyright Copyright (c) Pradosh 2023 | ||
* | ||
*/ | ||
#include <basics.h> | ||
|
||
#define block_size 512 | ||
|
||
struct tarball_header { | ||
char name[100]; | ||
char mode[8]; | ||
char owner[8]; | ||
char group[8]; | ||
char size[12]; | ||
char mtime[12]; | ||
char checksum[8]; | ||
char type; | ||
char linkname[100]; | ||
char magic[6]; | ||
char version[2]; | ||
char owner_name[32]; | ||
char group_name[32]; | ||
char dev_major[8]; | ||
char dev_minor[8]; | ||
char prefix[155]; | ||
}; | ||
|
||
void extract_tarball(int64* tarball_addr); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* @file tarball.c | ||
* @author Pradosh ([email protected]) | ||
* @brief | ||
* @version 0.1 | ||
* @date 2023-12-30 | ||
* | ||
* @copyright Copyright (c) Pradosh 2023 | ||
* | ||
*/ | ||
#include <archive/tarball.h> | ||
|
||
char* filenames[2 KiB]; | ||
char* file_datas[2 KiB]; | ||
|
||
int counter; | ||
|
||
void extract_tarball(int64* tarball_addr) { | ||
uintptr_t addr = (uintptr_t)tarball_addr; | ||
|
||
while (1) { | ||
if(counter >= 2 KiB){ | ||
error("You reached number of file limits of 2 KiB!", __FILE__); | ||
break; | ||
} | ||
struct tarball_header *header = (struct tar_header *)addr; | ||
|
||
if (header->name[0] == '\0') { | ||
break; | ||
} | ||
|
||
unsigned int size = strtol(header->size, NULL, 8); | ||
|
||
char *filename = header->name; | ||
char *contents = (char *)(addr + block_size); | ||
|
||
filenames[counter] = filename; | ||
file_datas[counter] = file_datas; | ||
|
||
addr += block_size + ((size + block_size - 1) / block_size) * block_size; | ||
counter++; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters