Path: blob/master/tools/context/stat-key.c
19848 views
/*1* Given a filename, outputs a 32bit key for use in2* context keyed payload encoding. The key is derived from3* XOR-ing the st_size and st_mtime fields of the4* relevant struct stat for this file.5*6* Author: Dimitris Glynos <dimitris at census-labs.com>7*/89#include <stdio.h>10#include <sys/stat.h>11#include <sys/types.h>12#include <unistd.h>1314int main(int argc, char *argv[])15{16char *filename;17struct stat stat_buf;1819if (argc != 2) {20fprintf(stderr, "usage: %s <filename>\n", argv[0]);21return 1;22}2324filename = argv[1];2526if (stat(filename, &stat_buf) == -1) {27perror("error while stat(2)-ing file");28return 1;29}3031printf("%#.8lx\n", stat_buf.st_mtime ^ stat_buf.st_size);32return 0;33}343536