2 * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
4 * Copyright (C) 2002-2018 Aleph One Ltd.
6 * Created by Charles Manning <charles@aleph1.co.uk>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License version 2.1 as
10 * published by the Free Software Foundation.
12 * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
22 #include <sys/xattr.h>
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)
75 h = open(name,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
81 printf("Add an attribute\n");
83 result = setxattr(name,"foo",&val1,sizeof(val1),0);
84 printf("wrote attribute foo: result %d\n",result);
86 printf("Add an attribute\n");
88 result = setxattr(name,"bar",&val1,sizeof(val1),0);
89 printf("wrote attribute bar: result %d\n",result);
92 printf("Get non-existanrt attribute\n");
93 print_xattrib_val(name,"not here");
95 printf("Delete non existing attribute\n");
96 removexattr(name,"not here");
99 printf("Remove foo\n");
100 removexattr(name,"foo");
103 printf("Remove bar\n");
104 removexattr(name,"bar");
111 int simulate_power_failure;
113 int main(int argc, char *argv[])
115 basic_xattr_test("/mnt/");