int process_command(int argc, char* cmd, char** argv) { if (argc >= 1 && !strcmp(cmd, "cat")) { return process_cat(argv[0]); } else if (argc >= 1 && !strcmp(cmd, "realcat")) { return process_real_cat(argv[0]); } else if (argc >= 1 && !strcmp(cmd, "hash")) { size_t hash_len = 0u; uint8_t hash[EVP_MAX_MD_SIZE]; if (process_hash(argv[0], hash, &hash_len)) { return 1; } for (size_t i = 0; i < hash_len; i++) { printf("%02x", hash[i]); } printf(" %s\n", argv[0]); return 0; } else if (argc >= 2 && !strcmp(cmd, "verify")) { return process_verify(argv[0], argv[1]); } else { printf("ERROR: invalid command (%s)\n", cmd); return 1; } }
/** * fivm_open_verify - verify file against to the hash table * @file: pointer to the file to be verify * @mask: * * Return 0 on success, an error code on failure. */ static int _fivm_open_verify(struct file *file,const char *pathname, int mask) { int rc; if (!file || !pathname) return 0; rc = process_verify(file, (char *)pathname); return rc; }
/** * fivm_file_mmap * @file: pointer to the file to be verify * @prot: contains the protection that will be applied by the kernel. * * Return 0 on success, an error code on failure. */ static int _fivm_mmap_verify(struct file *file, unsigned long prot) { int rc; if (!file ) return 0; rc = process_verify(file,(char *)file->f_dentry->d_name.name) ; return rc; }