diff options
Diffstat (limited to 'xlators/experimental/fdl/src/dump-tmpl.c')
-rw-r--r-- | xlators/experimental/fdl/src/dump-tmpl.c | 223 |
1 files changed, 106 insertions, 117 deletions
diff --git a/xlators/experimental/fdl/src/dump-tmpl.c b/xlators/experimental/fdl/src/dump-tmpl.c index 32b0fef6af3..d19f6589e66 100644 --- a/xlators/experimental/fdl/src/dump-tmpl.c +++ b/xlators/experimental/fdl/src/dump-tmpl.c @@ -14,150 +14,140 @@ * Returns 0 if the string is ASCII printable * * and -1 if it's not ASCII printable * */ -int str_isprint (char *s) +int +str_isprint(char *s) { - int ret = -1; + int ret = -1; - if (!s) - goto out; + if (!s) + goto out; - while (s[0] != '\0') { - if (!isprint(s[0])) - goto out; - else - s++; - } + while (s[0] != '\0') { + if (!isprint(s[0])) + goto out; + else + s++; + } - ret = 0; + ret = 0; out: - return ret; + return ret; } #pragma fragment DICT - { - int key_len, data_len; - char *key_ptr; - char *key_val; - printf ("@ARGNAME@ = dict {\n"); - for (;;) { - key_len = *((int *)new_meta); - new_meta += sizeof(int); - if (!key_len) { - break; - } - key_ptr = new_meta; - new_meta += key_len; - data_len = *((int *)new_meta); - key_val = new_meta + sizeof(int); - new_meta += sizeof(int) + data_len; - if (str_isprint(key_val)) - printf (" %s = <%d bytes>\n", - key_ptr, data_len); - else - printf (" %s = %s <%d bytes>\n", - key_ptr, key_val, data_len); - } - printf ("}\n"); +{ + int key_len, data_len; + char *key_ptr; + char *key_val; + printf("@ARGNAME@ = dict {\n"); + for (;;) { + key_len = *((int *)new_meta); + new_meta += sizeof(int); + if (!key_len) { + break; } + key_ptr = new_meta; + new_meta += key_len; + data_len = *((int *)new_meta); + key_val = new_meta + sizeof(int); + new_meta += sizeof(int) + data_len; + if (str_isprint(key_val)) + printf(" %s = <%d bytes>\n", key_ptr, data_len); + else + printf(" %s = %s <%d bytes>\n", key_ptr, key_val, data_len); + } + printf("}\n"); +} #pragma fragment DOUBLE - printf ("@ARGNAME@ = @FORMAT@\n", *((uint64_t *)new_meta), - *((uint64_t *)new_meta)); - new_meta += sizeof(uint64_t); +printf("@ARGNAME@ = @FORMAT@\n", *((uint64_t *)new_meta), + *((uint64_t *)new_meta)); +new_meta += sizeof(uint64_t); #pragma fragment GFID - printf ("@ARGNAME@ = <gfid %s>\n", uuid_utoa(*((uuid_t *)new_meta))); - new_meta += 16; +printf("@ARGNAME@ = <gfid %s>\n", uuid_utoa(*((uuid_t *)new_meta))); +new_meta += 16; #pragma fragment INTEGER - printf ("@ARGNAME@ = @FORMAT@\n", *((uint32_t *)new_meta), - *((uint32_t *)new_meta)); - new_meta += sizeof(uint32_t); +printf("@ARGNAME@ = @FORMAT@\n", *((uint32_t *)new_meta), + *((uint32_t *)new_meta)); +new_meta += sizeof(uint32_t); #pragma fragment LOC - printf ("@ARGNAME@ = loc {\n"); - printf (" gfid = %s\n", uuid_utoa(*((uuid_t *)new_meta))); - new_meta += 16; - printf (" pargfid = %s\n", uuid_utoa(*((uuid_t *)new_meta))); - new_meta += 16; - if (*(new_meta++)) { - printf (" name = %s\n", new_meta); - new_meta += (strlen(new_meta) + 1); - } - printf ("}\n"); +printf("@ARGNAME@ = loc {\n"); +printf(" gfid = %s\n", uuid_utoa(*((uuid_t *)new_meta))); +new_meta += 16; +printf(" pargfid = %s\n", uuid_utoa(*((uuid_t *)new_meta))); +new_meta += 16; +if (*(new_meta++)) { + printf(" name = %s\n", new_meta); + new_meta += (strlen(new_meta) + 1); +} +printf("}\n"); #pragma fragment STRING - if (*(new_meta++)) { - printf ("@ARGNAME@ = %s\n", new_meta); - new_meta += (strlen(new_meta) + 1); - } +if (*(new_meta++)) { + printf("@ARGNAME@ = %s\n", new_meta); + new_meta += (strlen(new_meta) + 1); +} #pragma fragment VECTOR - { - size_t len = *((size_t *)new_meta); - new_meta += sizeof(len); - printf ("@ARGNAME@ = <%zu bytes>\n", len); - new_data += len; - } +{ + size_t len = *((size_t *)new_meta); + new_meta += sizeof(len); + printf("@ARGNAME@ = <%zu bytes>\n", len); + new_data += len; +} #pragma fragment IATT - { - ia_prot_t *myprot = ((ia_prot_t *)new_meta); - printf ("@ARGNAME@ = iatt {\n"); - printf (" ia_prot = %c%c%c", - myprot->suid ? 'S' : '-', - myprot->sgid ? 'S' : '-', - myprot->sticky ? 'T' : '-'); - printf ("%c%c%c", - myprot->owner.read ? 'r' : '-', - myprot->owner.write ? 'w' : '-', - myprot->owner.exec ? 'x' : '-'); - printf ("%c%c%c", - myprot->group.read ? 'r' : '-', - myprot->group.write ? 'w' : '-', - myprot->group.exec ? 'x' : '-'); - printf ("%c%c%c\n", - myprot->other.read ? 'r' : '-', - myprot->other.write ? 'w' : '-', - myprot->other.exec ? 'x' : '-'); - new_meta += sizeof(ia_prot_t); - uint32_t *myints = (uint32_t *)new_meta; - printf (" ia_uid = %u\n", myints[0]); - printf (" ia_gid = %u\n", myints[1]); - printf (" ia_atime = %u.%09u\n", myints[2], myints[3]); - printf (" ia_mtime = %u.%09u\n", myints[4], myints[5]); - new_meta += sizeof(*myints) * 6; - } +{ + ia_prot_t *myprot = ((ia_prot_t *)new_meta); + printf("@ARGNAME@ = iatt {\n"); + printf(" ia_prot = %c%c%c", myprot->suid ? 'S' : '-', + myprot->sgid ? 'S' : '-', myprot->sticky ? 'T' : '-'); + printf("%c%c%c", myprot->owner.read ? 'r' : '-', + myprot->owner.write ? 'w' : '-', myprot->owner.exec ? 'x' : '-'); + printf("%c%c%c", myprot->group.read ? 'r' : '-', + myprot->group.write ? 'w' : '-', myprot->group.exec ? 'x' : '-'); + printf("%c%c%c\n", myprot->other.read ? 'r' : '-', + myprot->other.write ? 'w' : '-', myprot->other.exec ? 'x' : '-'); + new_meta += sizeof(ia_prot_t); + uint32_t *myints = (uint32_t *)new_meta; + printf(" ia_uid = %u\n", myints[0]); + printf(" ia_gid = %u\n", myints[1]); + printf(" ia_atime = %u.%09u\n", myints[2], myints[3]); + printf(" ia_mtime = %u.%09u\n", myints[4], myints[5]); + new_meta += sizeof(*myints) * 6; +} #pragma fragment FOP -void -fdl_dump_@NAME@ (char **old_meta, char **old_data) +void fdl_dump_ @NAME @(char **old_meta, char **old_data) { - char *new_meta = *old_meta; - char *new_data = *old_data; + char *new_meta = *old_meta; + char *new_data = *old_data; - /* TBD: word size/endianness */ -@FUNCTION_BODY@ + /* TBD: word size/endianness */ + @FUNCTION_BODY @ *old_meta = new_meta; - *old_data = new_data; + *old_data = new_data; } #pragma fragment CASE - case GF_FOP_@UPNAME@: - printf ("=== GF_FOP_@UPNAME@\n"); - fdl_dump_@NAME@ (&new_meta, &new_data); - break; +case GF_FOP_ @UPNAME @: + printf("=== GF_FOP_@UPNAME@\n"); + fdl_dump_ @NAME @(&new_meta, &new_data); + break; #pragma fragment EPILOG -int -fdl_dump (char **old_meta, char **old_data) -{ - char *new_meta = *old_meta; - char *new_data = *old_data; - static glfs_t *fs = NULL; - int recognized = 1; - event_header_t *eh; + int + fdl_dump(char **old_meta, char **old_data) + { + char *new_meta = *old_meta; + char *new_data = *old_data; + static glfs_t *fs = NULL; + int recognized = 1; + event_header_t *eh; /* * We don't really call anything else in GFAPI, but this is the most @@ -165,23 +155,22 @@ fdl_dump (char **old_meta, char **old_data) * or glusterfsd initialize (e.g. setting up THIS). */ if (!fs) { - fs = glfs_new ("dummy"); + fs = glfs_new("dummy"); } eh = (event_header_t *)new_meta; - new_meta += sizeof (*eh); + new_meta += sizeof(*eh); /* TBD: check event_type instead of assuming NEW_REQUEST */ switch (eh->fop_type) { -@SWITCH_BODY@ + @SWITCH_BODY @ - default: - printf ("unknown fop %u\n", eh->fop_type); - recognized = 0; + default : printf("unknown fop %u\n", eh->fop_type); + recognized = 0; } *old_meta = new_meta; *old_data = new_data; return recognized; -} + } |