2 * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
4 * Copyright (C) 2002-2011 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.
23 #include <sys/xattr.h>
25 static void print_xattrib_val(const char *path, const char *name)
30 n = getxattr(path,name,buffer,sizeof(buffer));
32 uint8_t *b = (uint8_t *)buffer;
34 printf("%d bytes:",n);
42 printf(" Novalue result %d\n",n);
45 static void list_xattr(const char *path)
52 list_len = listxattr(path,list,sizeof(list));
53 printf("xattribs for %s, result is %d\n",path,list_len);
55 len = strlen(list + n);
56 printf("\"%s\" value ",list+n);
57 print_xattrib_val(path,list + n);
64 void basic_xattr_test(const char *mountpt)
76 h = open(name,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
82 printf("Add an attribute\n");
84 result = setxattr(name,"foo",&val1,sizeof(val1),0);
85 printf("wrote attribute foo: result %d\n",result);
87 printf("Add an attribute\n");
89 result = setxattr(name,"bar",&val1,sizeof(val1),0);
90 printf("wrote attribute bar: result %d\n",result);
93 printf("Get non-existanrt attribute\n");
94 print_xattrib_val(name,"not here");
96 printf("Delete non existing attribute\n");
97 removexattr(name,"not here");
100 printf("Remove foo\n");
101 removexattr(name,"foo");
104 printf("Remove bar\n");
105 removexattr(name,"bar");
112 int simulate_power_failure;
114 int main(int argc, char *argv[])
116 basic_xattr_test("/mnt/");