Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
diff -r bc704c9af6d6 user/test/iattr.c --- a/user/test/iattr.c Tue Sep 02 10:17:39 2008 -0700 +++ b/user/test/iattr.c Tue Sep 02 11:00:56 2008 -0700 @@ -32,11 +32,28 @@ return need; } +int attr_check(void *attrs, unsigned size) +{ + void *limit = attrs + size; + unsigned head; + while (attrs < limit - 1) + { + attrs = decode16(attrs, &head); + kind = head >> 12; + if (kind < ATTR_MINIMUM || kind > ATTR_MAXIMUM) + return 0; + if (attrs + atsize[kind] > limit) + return 0; + attrs += atsize[kind]; + } + return 1; +} + void *encode_attrs(SB, void *attrs, unsigned size, struct inode *inode) { //printf("encode %u attr bytes\n", size); void *limit = attrs + size - 3; - for (int kind = 0; kind < 32; kind++) { + for (int kind = 0; kind < 16; kind++) { if (!(inode->present & (1 << kind))) continue; if (attrs >= limit) @@ -144,6 +161,12 @@ #ifndef main #ifndef iattr_included_from_ileaf + +void test_attrencoding() +{ + // do something cool +} + int main(int argc, char *argv[]) { SB = &(struct sb){ .version = 0 }; diff -r bc704c9af6d6 user/test/tux3.h --- a/user/test/tux3.h Tue Sep 02 10:17:39 2008 -0700 +++ b/user/test/tux3.h Tue Sep 02 11:00:56 2008 -0700 @@ -231,11 +231,13 @@ block_t balloc(SB); enum atkind { + ATTR_MINIMUM = 6, MODE_OWNER_ATTR = 6, DATA_BTREE_ATTR = 7, CTIME_SIZE_ATTR = 8, LINK_COUNT_ATTR = 9, MTIME_ATTR = 10, + ATTR_MAXIMUM = 10, }; enum atbit {
This paste will be private.
From the Design Piracy series on my blog: