2 * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
4 * Copyright (C) 2002-2010 Aleph One Ltd.
5 * for Toby Churchill Ltd and Brightstar Engineering
7 * Created by Charles Manning <charles@aleph1.co.uk>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU Lesser General Public License version 2.1 as
11 * published by the Free Software Foundation.
13 * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
24 static void print_xattrib_val(const char *path, const char *name)
29 n = getxattr(path,name,buffer,sizeof(buffer));
31 uint8_t *b = (uint8_t *)buffer;
33 printf("%d bytes:",n);
41 printf(" Novalue result %d\n",n);
44 static void list_xattr(const char *path)
51 list_len = listxattr(path,list,sizeof(list));
52 printf("xattribs for %s, result is %d\n",path,list_len);
54 len = strlen(list + n);
55 printf("\"%s\" value ",list+n);
56 print_xattrib_val(path,list + n);
63 void basic_xattr_test(const char *mountpt)
77 h = open(name,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
83 printf("Add an attribute\n");
85 result = setxattr(name,"foo",&val1,sizeof(val1),0);
86 printf("wrote attribute foo: result %d\n",result);
88 printf("Add an attribute\n");
90 result = setxattr(name,"bar",&val1,sizeof(val1),0);
91 printf("wrote attribute bar: result %d\n",result);
94 printf("Get non-existanrt attribute\n");
95 print_xattrib_val(name,"not here");
97 printf("Delete non existing attribute\n");
98 removexattr(name,"not here");
101 printf("Remove foo\n");
102 removexattr(name,"foo");
105 printf("Remove bar\n");
106 removexattr(name,"bar");
113 int simulate_power_failure;
115 int main(int argc, char *argv[])
117 basic_xattr_test("/mnt/");