int read_tarfs_file(char * fileName, char *binary_tarfs_start, char* binary_tarfs_end) { //printk("Indisde : %s",fileName); int found_file = 0; struct posix_header_ustar *tar_p = (struct posix_header_ustar *) (binary_tarfs_start); // print_posix_header(tar_p); //printk("\n Binary Start %x", binary_tarfs_start); // printk("\n Binary End %x", binary_tarfs_end); char *temp = binary_tarfs_start; // int size = octal_decimal(atoi(tar_p->size)); while (temp < binary_tarfs_end) { if (matchString(tar_p->name, fileName) == 0) { found_file = 1; return found_file; } int size = octal_decimal(atoi(tar_p->size)); int padding = 0; if (size % 512 != 0) { padding = 512 - size % 512; } temp = temp + 512 + size + padding; tar_p = (struct posix_header_ustar *) temp; // print_posix_header(tar_p); // printk("\n temp : %x",temp); } return found_file; }
/** * call-seq: * hdfs.chgrp(path, mode=644) -> retval * * Changes the mode of the supplied path. Returns True if successful; raises * a DFSException if this fails. */ VALUE HDFS_File_System_chmod(int argc, VALUE* argv, VALUE self) { FSData* data = get_FSData(self); VALUE path, mode; rb_scan_args(argc, argv, "11", &path, &mode); // Sets default mode if none is supplied. short hdfs_mode = NIL_P(mode) ? HDFS_DEFAULT_MODE : octal_decimal(NUM2INT(mode)); if (hdfsChmod(data->fs, StringValuePtr(path), hdfs_mode) == -1) { rb_raise(e_dfs_exception, "Failed to chmod path %s to mode %d: %s", StringValuePtr(path), decimal_octal(hdfs_mode), get_error(errno)); return Qnil; } return Qtrue; }
/* Code Reference : My Previous Submission */ int get_elf_file(char *binary_tarfs_start, char * filename, char* binary_tarfs_end) { int found_file = 0; struct posix_header_ustar *tar_p = (struct posix_header_ustar *) (binary_tarfs_start); // print_posix_header(tar_p); // printk("\n Binary Start %x", binary_tarfs_start); //printk("\n Binary End %x", binary_tarfs_end); char *temp = binary_tarfs_start; // int size = octal_decimal(atoi(tar_p->size)); while (temp < binary_tarfs_end) { if (matchString(tar_p->name, filename) == 0) { found_file = 1; break; // return found_file; } int size = octal_decimal(atoi(tar_p->size)); int padding = 0; if (size % 512 != 0) { padding = 512 - size % 512; } temp = temp + 512 + size + padding; tar_p = (struct posix_header_ustar *) temp; print_posix_header(tar_p); // printk("\n temp : %x",temp); } if (found_file == 0) { return 0; } else { temp = temp + 512; } // printk("\n size : %d",atoi(tar_p->size) ); // printk("\n Header:"); elf_start = (uint64_t) temp; // printk("\n temp: %x",temp); parse_ELF(temp, atoi(tar_p->size), &exeFormat, &pdr); //printk("\n exe format :%d", Parse_ELF_Executable(temp, atoi(tar_p->size),&exeFormat,&pdr)); return 1; }
uint64_t get_next_pointer(uint64_t previous) { struct posix_header_ustar *tar_p = (struct posix_header_ustar *) previous; char *temp = (char*) previous; // print_posix_header(tar_p); int size = octal_decimal(atoi(tar_p->size)); int padding = 0; if (size % 512 != 0) { padding = 512 - size % 512; } temp = temp + 512 + size + padding; struct posix_header_ustar *next = (struct posix_header_ustar *) temp; // char *next_f = (char *) next->name; // print_posix_header(next); return ((uint64_t) next); }
/* Code Reference : My Previous Submission */ int get_next_file(uint64_t previous, uint64_t base) { struct posix_header_ustar *start = (struct posix_header_ustar *) base; //print_posix_header(start); char *start_f = (char *) start->name; char *temp_start_f = (char *) start->name; char *temp = (char*) previous; struct posix_header_ustar *tar_p = (struct posix_header_ustar *) previous; char *previous_f = (char *) tar_p->name; print_posix_header(tar_p); int size = octal_decimal(atoi(tar_p->size)); int padding = 0; if (size % 512 != 0) { padding = 512 - size % 512; } temp = temp + 512 + size + padding; struct posix_header_ustar *next = (struct posix_header_ustar *) temp; char *next_f = (char *) next->name; if (contains(next_f, start_f)) { while (*next_f == *start_f) { next_f++; start_f++; } // printk("\n %s \n", next_f); char next_file_name[50] = { 0 }; int i = 0; while (*next_f != '\0') { if (*next_f == '/') { break; } next_file_name[i] = *next_f; next_f++; i++; } next_file_name[i] = '\0'; // printk("%s",next_file_name); // printk("\n %s ", temp_start_f); if (matchString(previous_f, temp_start_f) == 0) { // printk("\n Matced"); return 3; } while (*previous_f == *temp_start_f) { previous_f++; temp_start_f++; } // printk("\n sss: %s ", previous_f); char previous_file_name[50] = { 0 }; i = 0; while (*previous_f != '\0') { if (*previous_f == '/') { break; } previous_file_name[i] = *previous_f; previous_f++; i++; } previous_file_name[i] = '\0'; // printk(" %s",previous_file_name); if (matchString(previous_file_name, next_file_name) == 0) { // printk("\n Matced"); return 2; } else { // printk("\n Didinot match"); return 3; } // return 1; } else { return 1; } return 0; }