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 General Public License version 2 as
10 ## published by the Free Software Foundation.
17 if dname[-1] != "/": dname = dname + "/"
18 dc = yaffs_opendir(dname)
20 sep = yaffs_readdir(dc)
23 fullname = dname + se.d_name
24 #print fullname, " ", se.d_ino," ",ord(se.d_type)
25 st = yaffs_stat_struct()
26 result = yaffs_stat(fullname,byref(st))
27 perms = st.st_mode & 0777
28 isFile = True if st.st_mode & 0x8000 else False
29 isDir = True if st.st_mode & 0x4000 else False
32 print "File ",se.d_ino, hex(perms), st.st_size, fullname, " times ", st.yst_atime, st.yst_ctime, st.yst_mtime
34 print "Dir ",se.d_ino, hex(perms), fullname, " times ", st.yst_atime, st.yst_ctime, st.yst_mtime
37 print "Other (",hex(st.st_mode),") ",se.d_ino, hex(perms), fullname, " times ", st.yst_atime, st.yst_ctime, st.yst_mtime
39 sep = yaffs_readdir(dc)
43 print "Could not open directory"
46 def yaffs_mkfile(fname,fsize):
47 fd = yaffs_open(fname,66, 0666)
49 b = create_string_buffer("",1024)
52 thiswrite = 1024 if fsize > 1024 else fsize
53 result = yaffs_write(fd,b,thiswrite)
56 if result != thiswrite:
63 def yaffs_link_test(dir):
67 fd = yaffs_open(fnamea,66,0666)
68 yaffs_link(fnamea,fnameb)
74 def yaffs_o_excl_test(dir):
77 fd = yaffs_open(fname, 66, 0666)
79 print "Created ", fname, " result ", fd
80 fdx = yaffs_open(fname, 0301, 0666)
81 print "Attempt to create with O_EXCL existing file returned ", fdx
83 fdx = yaffs_open(fname, 0301, 0666)
84 print "Attempt to create with O_EXCL non-existing file returned ", fdx
92 yaffs_mkdir(root+"/dd",0666)
94 h = yaffs_open(root+"/dd/111",66,0666)