socsvn commit: r239245 - soc2012/gpf/pefs_kmod/sbin/pefs
gpf at FreeBSD.org
gpf at FreeBSD.org
Tue Jul 10 18:20:23 UTC 2012
Author: gpf
Date: Tue Jul 10 18:20:20 2012
New Revision: 239245
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239245
Log:
code refactoring for userland code (mostly stylistic changes)
Modified:
soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c
soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.h
Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c
==============================================================================
--- soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c Tue Jul 10 17:32:52 2012 (r239244)
+++ soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c Tue Jul 10 18:20:20 2012 (r239245)
@@ -57,7 +57,7 @@
#include "pefs_ctl.h"
-#define PEFS_INTEGRITY_DEBUG
+//#define PEFS_INTEGRITY_DEBUG
#if defined (PEFS_INTEGRITY_DEBUG)
#define dprintf(a) printf a
#else
@@ -72,15 +72,21 @@
#define PEFS_HASH_BYTE_ALIGNMENT 512
#define PEFS_EXTRA_TABLE_SIZE 15
+/* tail that contains a single file's checksums */
TAILQ_HEAD(checksum_head, checksum);
+/* tail that contains all file headers that require integrity checking */
TAILQ_HEAD(file_header_head, file_header);
+/* tail for all the file_headers that refere to the same inode */
TAILQ_HEAD(hardlink_fh_head, file_header);
+/* RB tree for hardlink counters */
RB_HEAD(hardlink_head, hardlink_counter);
RB_PROTOTYPE(hardlink_head, hardlink_counter, hardlink_entries, pefs_rb_cmp);
-#define PEFS_CFH_SIZE 16 /* on disk size of .pefs.checksum's unique file header */
-#define PEFS_FH_SIZE 16 /* on disk size of a single file header (also a bucket in cuckoo hashing) */
+/* on disk size of .pefs.checksum's unique file header */
+#define PEFS_CFH_SIZE 16
+/* on disk size of a single file header (also a bucket in cuckoo hashing) */
+#define PEFS_FH_SIZE 16
/* this struct is used to check if all hardlinks for a given inode are supplied by the user */
struct hardlink_counter {
@@ -206,7 +212,8 @@
else {
/* feed parent directory to ioctl() */
strlcpy(xsl.pxsl_filename, fhp->filename, sizeof(xsl.pxsl_filename));
- xsl.pxsl_namelen = strnlen(xsl.pxsl_filename, sizeof(xsl.pxsl_filename));
+ xsl.pxsl_namelen = strnlen(xsl.pxsl_filename,
+ sizeof(xsl.pxsl_filename));
error = ioctl(fhp->pfd, PEFS_GETSLINKCTEXT, &xsl);
if (error != 0) {
@@ -216,7 +223,8 @@
dprintf(("read %d bytes from kernel\n\n", xsl.pxsl_slink_len));
dprintf(("printing contents of buf:"));
- for (i=0; i < (int)xsl.pxsl_slink_len; i++) dprintf(("%c", xsl.pxsl_slink[i]));
+ for (i=0; i < (int)xsl.pxsl_slink_len; i++)
+ dprintf(("%c", xsl.pxsl_slink[i]));
dprintf(("!\n"));
buf = xsl.pxsl_slink;
buf_len = xsl.pxsl_slink_len;
@@ -378,16 +386,18 @@
}
static int
-pefs_allocate_hash_table(struct cuckoo_hash_table *chtp, uint32_t nelements, int alloc_flag)
+pefs_allocate_hash_table(struct cuckoo_hash_table *chtp, uint32_t nelements,
+ int alloc_flag)
{
uint32_t i;
if (alloc_flag == PEFS_EXTEND) {
/*
- * spending 15% more space for each table lowers the chance to fall into an
- * infinite loop during cuckoo insertion to about 1.5%.
+ * spending 15% more space for each table lowers the chance to fall into
+ * an infinite loop during cuckoo insertion to about 1.5%.
*/
- chtp->size = pefs_next_prime(nelements + ((nelements * PEFS_EXTRA_TABLE_SIZE)/100));
+ chtp->size = pefs_next_prime(nelements +
+ ((nelements * PEFS_EXTRA_TABLE_SIZE)/100));
chtp->nelements = nelements;
if (chtp->size < chtp->nelements) {
pefs_warn("numeric overflow while computing hash table size");
@@ -398,7 +408,7 @@
chtp->size = nelements;
chtp->nelements = nelements;
}
- /* reallocate the hash tables in case of infinite loop during cuckoo insert */
+ /* re-alloc the hash tables in case of infinite loop during cuckoo insert */
else if (alloc_flag == PEFS_REALLOC) {
chtp->size = pefs_next_prime(chtp->size + 1);
if (chtp->size < chtp->nelements) {
@@ -527,7 +537,8 @@
{
uint32_t nbucket;
- nbucket = fnv_64_buf(&(fhp->file_id), sizeof(fhp->file_id), FNV1_64_INIT) % chtp->size;
+ nbucket = fnv_64_buf(&(fhp->file_id), sizeof(fhp->file_id), FNV1_64_INIT) %
+ chtp->size;
dprintf(("hash2: goto bucket %d\n", nbucket));
return (nbucket);
@@ -573,7 +584,7 @@
res = pefs_cuckoo_lookup(chtp, elem);
if (res != NULL) {
pefs_warn("file identifier collision detected between files: %s & %s",
- res->path, elem->path);
+ res->path, elem->path);
return (PEFS_ERR_EXIST);
}
@@ -619,7 +630,6 @@
fhp = chtp->buckets1[i].fhp;
dprintf(("\nbucket %d with element: %d\n", i, fhp == NULL ? 0 : 1));
if (fhp != NULL) {
- //dprintf(("\tpath=%s\tid = %llu\tnhashes = %d\n", fhp->path, fhp->file_id, fhp->nhashes));
dprintf(("\tid = %llu\tnhashes = %d\n", fhp->file_id, fhp->nhashes));
if (fhp->path[0] == '/')
dprintf(("\tpath = %s\n", fhp->path));
@@ -637,7 +647,6 @@
fhp = chtp->buckets2[i].fhp;
dprintf(("\nbucket %d with element: %d\n", i, fhp == NULL ? 0 : 1));
if (fhp != NULL) {
- //dprintf(("\tpath=%s\tid = %llu\tnhashes = %d\n", fhp->path, fhp->file_id, fhp->nhashes));
dprintf(("\tid = %llu\tnhashes = %d\n", fhp->file_id, fhp->nhashes));
if (fhp->path[0] == '/')
dprintf(("\tpath = %s\n", fhp->path));
@@ -683,7 +692,8 @@
r = pefs_name_pton(enc, enc_len, buf, buf_len);
if (r <= 0) {
- pefs_warn("failed to extract file id from encrypted filename: %s", fhp->filename);
+ pefs_warn("failed to extract file id from encrypted filename: %s",
+ fhp->filename);
error = PEFS_ERR_GENERIC;
}
else {
@@ -707,7 +717,8 @@
fhp->file_id = be64toh(temp);
}
else
- pefs_warn("failed to fetch file id from kernel for filename: %s", fhp->filename);
+ pefs_warn("failed to fetch file id from kernel for filename: %s",
+ fhp->filename);
return (error);
}
@@ -773,8 +784,8 @@
if (error == 0) {
res = pefs_cuckoo_lookup(chtp, &targetfh);
if (res == NULL)
- pefs_warn("target file %s of symlink %s was not found in inputlist",
- targetfh.path, fhp->path);
+ pefs_warn("target file %s of symlink %s was not "
+ "found in inputlist", targetfh.path, fhp->path);
}
pefs_close_file(&targetfh);
}
@@ -807,7 +818,8 @@
RB_FOREACH(hlcp, hardlink_head, hlc_headp) {
if (hlcp->total_links > hlcp->links_found) {
- pefs_warn("%d hard link(s) of total %d were found in input list for file with inode: %d",
+ pefs_warn("%d hard link(s) of total %d were found in input list "
+ "for file with inode: %d",
hlcp->links_found, hlcp->total_links, hlcp->inode);
i = 1;
TAILQ_FOREACH(fhp, &(hlcp->file_headers), fh_hardlink_entries) {
@@ -818,7 +830,8 @@
}
static int
-pefs_rb_insert(struct hardlink_head *hlc_headp, struct file_header *fhp, struct stat *sbp)
+pefs_rb_insert(struct hardlink_head *hlc_headp, struct file_header *fhp,
+ struct stat *sbp)
{
struct hardlink_counter find, *res, *new_hlcp;
@@ -873,7 +886,8 @@
/* open a file and perform various semantic checks on it */
static int
-pefs_open_semantic_checks(struct file_header *fhp, struct statfs *fsp, struct hardlink_head *hlc_headp, int flags)
+pefs_open_semantic_checks(struct file_header *fhp, struct statfs *fsp,
+ struct hardlink_head *hlc_headp, int flags)
{
char dirbuf[MAXPATHLEN + 1], namebuf[MAXNAMLEN + 1];
char sbuf[MAXPATHLEN + 1];
@@ -902,7 +916,8 @@
}
strlcpy(fhp->filename, namep, sizeof(fhp->filename));
- dprintf(("path = %s!\ndirname = %s!\nbasename =%s!\n", fhp->path, fhp->dirpath, fhp->filename));
+ dprintf(("path = %s!\ndirname = %s!\nbasename =%s!\n", fhp->path,
+ fhp->dirpath, fhp->filename));
if (lstat(fhp->path, &sb) != 0) {
warn("cannot stat file %s", fhp->path);
@@ -924,10 +939,10 @@
/*
* Target_path can be used to tell if user has supplied target_file
- * in input file-list, since symlinks are not traversed. User will have to
- * provide fullpaths for both symlink & target file if he wants integrity
- * checking for both. However, we will print warning messages in case
- * target file is not provided in user supplied input list.
+ * in input file-list, since symlinks are not traversed. User will have
+ * to provide fullpaths for both symlink & target file if he wants
+ * integrity checking for both. However, we will print warning messages
+ * in case target file is not provided in user supplied input list.
*
* Target referes to the file immediately pointed to by our symlink, not
* the final target of a possible symlink chain.
@@ -941,13 +956,15 @@
sbuf[nchars] = '\0';
/* turn relative paths to absolute paths */
- if (sbuf[0] != '/' && (flags & PEFS_UNMOUNTED) == 0 && (flags & PEFS_NOKEY) == 0)
- snprintf(fhp->target_path, target_path_size, "%s/%s", fhp->dirpath, sbuf);
+ if (sbuf[0] != '/' && (flags & PEFS_UNMOUNTED) == 0 &&
+ (flags & PEFS_NOKEY) == 0)
+ snprintf(fhp->target_path, target_path_size, "%s/%s",
+ fhp->dirpath, sbuf);
else
strlcpy(fhp->target_path, sbuf, target_path_size);
/*
- * The only semantic check that is performed on target file is an attempt
+ * The only semantic check that's performed on target file is an attempt
* to lstat() the file, in order to make sure the file exists. This is
* intentional since target file is allowed to reside on a different
* filesystem or in the same filesystem, but not be a regular file or a
@@ -1047,17 +1064,19 @@
* the checksum file.
* A) For each file entry:
* A1) semantic checks:
- * A1a) file should reside in pefs filesystem & file should be regular file.
+ * A1a) file should reside in pefs filesystem & file should be
+ * regular file or symbolic link.
* A1b) if symlink, acquire and save the absolute path of the symlink's
- * target. Try to lstat() the target but don't do anything else.
- * A1c) If hardlink, save a reference to this file entry in our rb tree.
- * rb-tree uses inodes as keys and is used in part C to print warnings.
+ * target. Try to lstat() the target but don't do anything else.
+ * A1c) If hardlink, save a reference to this file entry in our
+ * rb tree that uses i-node numbers as keys and is used in
+ * part 'C' to print warnings.
* A1d) Open and store file descriptors to file & parent_directory.
- * A2) the file_id is retrieved.
+ * A2) the file_id is retrieved. (filename MAC)
* A3) list of checksums is computed for the file's 4k blocks.
* A4) file entry is added to universal fh_head.
- * B) Print warnings for hardlinks if the number of links found in inputlist isn't
- * equal to the number of total inode links.
+ * B) Print warnings for hardlinks if the number of links found in inputlist
+ * isn't equal to the number of total inode links.
* C) Hash tables are allocated.
* D) Cuckoo insertion:
* We try to populate our hash tables using the cuckoo algorithm. Should we fall
@@ -1181,7 +1200,8 @@
return (PEFS_ERR_IO);
}
- bytes = write(fdout, &(cfhp->offset_to_hash_table), sizeof(cfhp->offset_to_hash_table));
+ bytes = write(fdout, &(cfhp->offset_to_hash_table),
+ sizeof(cfhp->offset_to_hash_table));
if (bytes != sizeof(cfhp->offset_to_hash_table)) {
warn("error writing to .pefs.checksum");
return (PEFS_ERR_IO);
@@ -1198,7 +1218,8 @@
}
static int
-pefs_write_file_header(int fdout, struct file_header *fhp, uint32_t *buckets_offset)
+pefs_write_file_header(int fdout, struct file_header *fhp,
+ uint32_t *buckets_offset)
{
uint64_t file_id;
uint32_t nhashes, offset_to_checksums;
@@ -1213,7 +1234,8 @@
(*buckets_offset)+= sizeof(nhashes);
offset_to_checksums = htole32(fhp->offset_to_checksums);
- bytes = pwrite(fdout, &offset_to_checksums, sizeof(offset_to_checksums), *buckets_offset);
+ bytes = pwrite(fdout, &offset_to_checksums,
+ sizeof(offset_to_checksums), *buckets_offset);
if (bytes != sizeof(offset_to_checksums)) {
warn("error writing to .pefs.checksum");
return (PEFS_ERR_IO);
@@ -1240,8 +1262,9 @@
fhp = bp->fhp;
if (fhp == NULL) {
/*
- * XXXgpf: empty files are not allowed so nhashes == 0 symbolizes an empty bucket.
- * perhaps a bitmap would be better? or we could steal a bit from some data member?
+ * XXXgpf: empty files are not allowed so nhashes == 0 symbolizes
+ * an empty bucket. perhaps a bitmap would be better? or we could
+ * steal a bit from some data member?
*/
emptyfh.nhashes = 0;
emptyfh.file_id = 0;
@@ -1253,7 +1276,8 @@
}
static int
-pefs_write_hash(int fdout, struct checksum *csp, uint32_t *hashes_offset, uint8_t hash_len)
+pefs_write_hash(int fdout, struct checksum *csp, uint32_t *hashes_offset,
+ uint8_t hash_len)
{
int bytes;
@@ -1271,14 +1295,15 @@
* All data member writes are done separately so as to avoid alignment problems.
* Writes are always in little endian byte order.
*
- * First 16 bytes of .pefs.checksum are filled with .pefs.checksum's file header.
- * Right after this header lies the 'index' part of our database. This index is later
- * kept in kernel memory.
+ * First 16 bytes of .pefs.checksum are filled with .pefs.checksum's file
+ * header. Right after this header lies the 'index' part of our database.
+ * This index is later kept in kernel memory.
*
* Index:
- * Both hash tables of cuckoo algorithm are written to the file sequentially. The
- * first hash table corresponds to hash1() and the second hash table to hash2().
- * Each bucket (cell) of a hash table contains at most one entry(=file_header).
+ * Both hash tables of cuckoo algorithm are written to the file sequentially.
+ * The first hash table corresponds to hash1() and the second hash table to
+ * hash2(). Each bucket (cell) of a hash table contains at most one
+ * entry(=file_header).
* The size of an entry is 16 bytes.
*
* hash table entries end at the following offset:
@@ -1287,11 +1312,12 @@
* Checksums:
* The last part of .pefs.checksum is filled with the actual checksums.
* The offset where the first checksum starts is a 512 aligned address.
- * Each hash table file header entry contains an offset that points to the beginning
- * of a chain of checksums for that particular file's 4k blocks.
+ * Each hash table file header entry contains an offset that points to the
+ * beginning of a chain of checksums for that particular file's 4k blocks.
*/
static int
-pefs_write_checksum_file(int fdout, struct checksum_file_header *cfhp, struct cuckoo_hash_table *chtp)
+pefs_write_checksum_file(int fdout, struct checksum_file_header *cfhp,
+ struct cuckoo_hash_table *chtp)
{
struct bucket *bp;
struct checksum *csp;
@@ -1310,7 +1336,8 @@
hashes_offset = buckets_offset;
hashes_offset+= chtp->size * PEFS_FH_SIZE * 2;
if (hashes_offset % PEFS_HASH_BYTE_ALIGNMENT != 0)
- hashes_offset+= PEFS_HASH_BYTE_ALIGNMENT - (hashes_offset % PEFS_HASH_BYTE_ALIGNMENT);
+ hashes_offset+= PEFS_HASH_BYTE_ALIGNMENT - (hashes_offset %
+ PEFS_HASH_BYTE_ALIGNMENT);
for (i = 0; i < chtp->size; i++) {
bp = &chtp->buckets1[i];
@@ -1323,7 +1350,8 @@
fhp = bp->fhp;
if (fhp != NULL) {
TAILQ_FOREACH(csp, &(fhp->checksums), checksum_entries) {
- error = pefs_write_hash(fdout, csp, &hashes_offset, cfhp->hash_len);
+ error = pefs_write_hash(fdout, csp, &hashes_offset,
+ cfhp->hash_len);
if (error != 0)
return (error);
}
@@ -1341,7 +1369,8 @@
fhp = bp->fhp;
if (fhp != NULL) {
TAILQ_FOREACH(csp, &(fhp->checksums), checksum_entries) {
- error = pefs_write_hash(fdout, csp, &hashes_offset, cfhp->hash_len);
+ error = pefs_write_hash(fdout, csp, &hashes_offset,
+ cfhp->hash_len);
if (error != 0)
return (error);
}
@@ -1352,8 +1381,8 @@
}
static void
-pefs_init_checksum_file_header(struct checksum_file_header *cfhp, const char *algo,
- uint8_t hash_len, struct cuckoo_hash_table *chtp)
+pefs_init_checksum_file_header(struct checksum_file_header *cfhp,
+ const char *algo, uint8_t hash_len, struct cuckoo_hash_table *chtp)
{
cfhp->hash_len = hash_len;
cfhp->hash_table_size = chtp->size;
@@ -1363,8 +1392,8 @@
/*
* If .pefs.checksum is created inside pefs mounted fs, then it will obtain an
- * encrypted filename & encrypted data, which is unacceptable. User should create
- * checksum file outside of filesystem and then copy it by hand.
+ * encrypted filename & encrypted data, which is unacceptable. User should
+ * create checksum file outside of filesystem and then copy it by hand.
*/
static int
pefs_open_checksum_file(int *fdp, char *fsroot, char *csm_path)
@@ -1403,12 +1432,14 @@
}
/*
- * An in memory database is created from entries in fpin. This database is later written
- * to file ".pefs.checksum" which is created under csm_path. algo is used as a cryptographic
- * hash function that produces checksums for 4k blocks of each file.
+ * An in memory database is created from entries in fpin. This database is
+ * later written to file ".pefs.checksum" which is created under csm_path.
+ * algo is used as a cryptographic hash function that produces checksums
+ * for 4k blocks of each file.
*/
int
-pefs_create_checksum_file(FILE *fpin, char *fsroot, char *csm_path, const char *algo)
+pefs_create_checksum_file(FILE *fpin, char *fsroot, char *csm_path,
+ const char *algo)
{
struct cuckoo_hash_table checksum_hash_table;
struct checksum_file_header cfh;
@@ -1480,7 +1511,8 @@
return (PEFS_ERR_IO);
}
- bytes = read(fdin, &(cfhp->offset_to_hash_table), sizeof(cfhp->offset_to_hash_table));
+ bytes = read(fdin, &(cfhp->offset_to_hash_table),
+ sizeof(cfhp->offset_to_hash_table));
if (bytes != sizeof(cfhp->offset_to_hash_table)) {
warn("error reading from .pefs.checksum");
return (PEFS_ERR_IO);
@@ -1494,14 +1526,17 @@
cfhp->hash_table_size = le32toh(hash_table_size);
dprintf(("+++printing checksum file header info+++\n"));
- dprintf(("version %X\nhash_len %d\nhash_algo %s\n", cfhp->version, cfhp->hash_len, cfhp->hash_algo));
- dprintf(("offset to hash table %d\nhash table size %d\n", cfhp->offset_to_hash_table, cfhp->hash_table_size));
+ dprintf(("version %X\nhash_len %d\nhash_algo %s\n",
+ cfhp->version, cfhp->hash_len, cfhp->hash_algo));
+ dprintf(("offset to hash table %d\nhash table size %d\n",
+ cfhp->offset_to_hash_table, cfhp->hash_table_size));
return (0);
}
static int
-pefs_read_file_header(int fdin, struct file_header *fhp, uint32_t *buckets_offset)
+pefs_read_file_header(int fdin, struct file_header *fhp,
+ uint32_t *buckets_offset)
{
uint64_t file_id;
uint32_t nhashes, offset_to_checksums;
@@ -1515,7 +1550,8 @@
fhp->nhashes = le32toh(nhashes);
(*buckets_offset)+= sizeof(nhashes);
- bytes = pread(fdin, &offset_to_checksums, sizeof(offset_to_checksums), *buckets_offset);
+ bytes = pread(fdin, &offset_to_checksums, sizeof(offset_to_checksums),
+ *buckets_offset);
if (bytes != sizeof(offset_to_checksums)) {
warn("error reading from .pefs.checksum");
return (PEFS_ERR_IO);
@@ -1533,7 +1569,8 @@
//dprintf(("\nfile header offset = %d\n", *fh_offset));
//dprintf(("\n++priting file header info++\n"));
- //dprintf(("nhashes %d\noffset_to_checksums %u\n", fhp->nhashes, fhp->offset_to_checksums));
+ //dprintf(("nhashes %d\noffset_to_checksums %u\n",
+ //fhp->nhashes, fhp->offset_to_checksums));
//dprintf(("file id %llu\n", fhp->file_id));
return (0);
@@ -1566,7 +1603,8 @@
}
static int
-pefs_read_hash(int fdin, struct checksum *csp, uint32_t *hashes_offset, uint8_t hash_len)
+pefs_read_hash(int fdin, struct checksum *csp, uint32_t *hashes_offset,
+ uint8_t hash_len)
{
int bytes;
@@ -1591,7 +1629,8 @@
/* Create in memory checksum database by reading .pefs.checksum file. */
static int
-pefs_read_checksum_file(int fdin, struct checksum_file_header *cfhp, struct cuckoo_hash_table *chtp)
+pefs_read_checksum_file(int fdin, struct checksum_file_header *cfhp,
+ struct cuckoo_hash_table *chtp)
{
struct bucket *bp;
struct checksum *csp;
@@ -1624,7 +1663,8 @@
return (PEFS_ERR_SYS);
}
- error = pefs_read_hash(fdin, csp, &hashes_offset, cfhp->hash_len);
+ error = pefs_read_hash(fdin, csp, &hashes_offset,
+ cfhp->hash_len);
if (error != 0)
return (error);
@@ -1655,7 +1695,8 @@
return (PEFS_ERR_SYS);
}
- error = pefs_read_hash(fdin, csp, &hashes_offset, cfhp->hash_len);
+ error = pefs_read_hash(fdin, csp, &hashes_offset,
+ cfhp->hash_len);
if (error != 0)
return (error);
@@ -1668,7 +1709,8 @@
}
static int
-pefs_compare_checksums(struct file_header *fhp, struct file_header *indexfhp, uint8_t hash_len)
+pefs_compare_checksums(struct file_header *fhp, struct file_header *indexfhp,
+ uint8_t hash_len)
{
struct checksum *csp1, *csp2;
uint32_t i;
@@ -1678,7 +1720,8 @@
error = 0;
if (fhp->nhashes != indexfhp->nhashes) {
- pefs_warn("number of hashes differ between on disk file and %s values for file %s: %u vs %u",
+ pefs_warn("number of hashes differ between on disk file and %s values "
+ "for file %s: %u vs %u",
PEFS_FILE_CHECKSUM, fhp->path, fhp->nhashes, indexfhp->nhashes);
error = PEFS_ERR_CHECKSUM;
}
@@ -1689,7 +1732,8 @@
while (csp1 != NULL && csp2 != NULL) {
cmp = memcmp(csp1->hash, csp2->hash, hash_len);
if (cmp != 0) {
- pefs_warn("checksum no: %u differs between on disk file and %s values for file %s",
+ pefs_warn("checksum no: %u differs between on disk file and %s "
+ "values for file %s",
i, PEFS_FILE_CHECKSUM, fhp->path);
error = PEFS_ERR_CHECKSUM;
}
@@ -1702,12 +1746,13 @@
}
/*
- * Traverse the entire filesystem and for every regular file or symbolic link, look it up in
- * .pefs.checksum index and verify its checksums.
+ * Traverse the entire filesystem and for every regular file or symbolic link,
+ * look it up in .pefs.checksum index and verify its checksums.
*/
static int
-pefs_traverse_fs(struct cuckoo_hash_table *chtp, const EVP_MD *md, uint8_t hash_len, DIR *dirp,
- char *path, struct statfs *fsp, struct hardlink_head *hlc_headp, struct file_header_head *fh_headp,
+pefs_traverse_fs(struct cuckoo_hash_table *chtp, const EVP_MD *md,
+ uint8_t hash_len, DIR *dirp, char *path, struct statfs *fsp,
+ struct hardlink_head *hlc_headp, struct file_header_head *fh_headp,
int flags, int *checksum_error)
{
char tmpath[MAXPATHLEN];
@@ -1721,8 +1766,10 @@
sdp = readdir(dirp);
if (sdp != NULL) {
/* XXXgpf: [TODO] Need to pay special attention to these files */
- if (strcmp(sdp->d_name, "..") == 0 || strcmp(sdp->d_name, ".") == 0 ||
- strcmp(sdp->d_name, ".pefs.db") == 0 || strcmp(sdp->d_name, ".pefs.conf") == 0 ||
+ if (strcmp(sdp->d_name, "..") == 0 ||
+ strcmp(sdp->d_name, ".") == 0 ||
+ strcmp(sdp->d_name, ".pefs.db") == 0 ||
+ strcmp(sdp->d_name, ".pefs.conf") == 0 ||
strcmp(sdp->d_name, ".pefs.checksum") == 0)
continue;
@@ -1737,7 +1784,7 @@
return (PEFS_ERR_SYS);
}
error = pefs_traverse_fs(chtp, md, hash_len, dirtmp, tmpath,
- fsp, hlc_headp, fh_headp, flags, checksum_error);
+ fsp, hlc_headp, fh_headp, flags, checksum_error);
if (error != 0) {
closedir(dirp);
return (PEFS_ERR_SYS);
@@ -1745,10 +1792,11 @@
break;
/*
* Look up the file and verify its checksums.
- * Total number of checksums should be the same and checksums should match.
+ * Total number of checksums should be the same and checksums
+ * should match.
* Also, take notice of hardlinks & symlink warnings.
- * After the traversal is done, we must have found all of our entries in the
- * checksum file.
+ * After the traversal is done, we must have found all of our
+ * entries in the checksum file.
*/
/* FALLTHROUGH */
case DT_REG:
@@ -1847,7 +1895,8 @@
fhp = chtp->buckets1[i].fhp;
if (fhp != NULL)
if (fhp->found != 1) {
- pefs_warn("file with file id %llu was not found in filesystem but exists in %s",
+ pefs_warn("file with file id %llu was not found in "
+ "filesystem but exists in %s",
fhp->file_id, PEFS_FILE_CHECKSUM);
error = PEFS_ERR_NOENT;
}
@@ -1857,7 +1906,8 @@
fhp = chtp->buckets2[i].fhp;
if (fhp != NULL)
if (fhp->found != 1) {
- pefs_warn("file with file id %llu was not found in filesystem but exists in %s",
+ pefs_warn("file with file id %llu was not found in "
+ "filesystem but exists in %s",
fhp->file_id, PEFS_FILE_CHECKSUM);
error = PEFS_ERR_NOENT;
}
@@ -1924,7 +1974,8 @@
goto out;
}
- error = pefs_traverse_fs(&cht, md, hash_len, dirp, fsroot, &fs, &hlc_head, &fh_head, flags, &checksum_error);
+ error = pefs_traverse_fs(&cht, md, hash_len, dirp, fsroot, &fs, &hlc_head,
+ &fh_head, flags, &checksum_error);
if (error != 0)
goto out;
Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.h
==============================================================================
--- soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.h Tue Jul 10 17:32:52 2012 (r239244)
+++ soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.h Tue Jul 10 18:20:20 2012 (r239245)
@@ -98,10 +98,12 @@
int pefs_key_decrypt(struct pefs_xkeyenc *xe,
const struct pefs_xkey *xk_parent);
uintmax_t pefs_keyid_as_int(char *keyid);
-int pefs_create_checksum_file(FILE *fpin, char *fsroot, char *csm_path, const char *algo);
+int pefs_create_checksum_file(FILE *fpin, char *fsroot, char *csm_path,
+ const char *algo);
int pefs_verify_checksum(int fdin, char *fsroot, int flags);
-int pefs_name_pton(char const *src, size_t srclen, u_char *target, size_t targsize);
+int pefs_name_pton(char const *src, size_t srclen, u_char *target,
+ size_t targsize);
const char * pefs_alg_name(struct pefs_xkey *xk);
void pefs_alg_list(FILE *stream);
More information about the svn-soc-all
mailing list