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 General Public License version 2 as
11 ## published by the Free Software Foundation.
18 if dname[-1] != "/": dname = dname + "/"
19 dc = yaffs_opendir(dname)
21 sep = yaffs_readdir(dc)
24 fullname = dname + se.d_name
25 #print fullname, " ", se.d_ino," ",ord(se.d_type)
26 st = yaffs_stat_struct()
27 result = yaffs_stat(fullname,byref(st))
28 perms = st.st_mode & 0777
29 isFile = True if st.st_mode & 0x8000 else False
30 isDir = True if st.st_mode & 0x4000 else False
33 print "File ",se.d_ino, hex(perms), st.st_size, fullname
35 print "Dir ",se.d_ino, hex(perms), fullname
38 print "Other (",hex(st.st_mode),") ",se.d_ino, hex(perms), fullname
40 sep = yaffs_readdir(dc)
44 print "Could not open directory"
47 def yaffs_mkfile(fname,fsize):
48 fd = yaffs_open(fname,66, 0666)
50 b = create_string_buffer("",1024)
53 thiswrite = 1024 if fsize > 1024 else fsize
54 result = yaffs_write(fd,b,thiswrite)
57 if result != thiswrite:
64 def yaffs_link_test(dir):
68 fd = yaffs_open(fnamea,66,0666)
69 yaffs_link(fnamea,fnameb)
75 def yaffs_o_excl_test(dir):
78 fd = yaffs_open(fname, 66, 0666)
80 print "Created ", fname, " result ", fd
81 fdx = yaffs_open(fname, 0301, 0666)
82 print "Attempt to create with O_EXCL existing file returned ", fdx
84 fdx = yaffs_open(fname, 0301, 0666)
85 print "Attempt to create with O_EXCL non-existing file returned ", fdx
93 yaffs_mkdir(root+"/dd",0666)
95 h = yaffs_open(root+"/dd/111",66,0666)