yaffs Added more tests to direct/timothy_tests/quick_tests
[yaffs2.git] / direct / python / examples.py
index ac2c48c3a911d95c29a9cd6d963f4b1a8177b2e1..155e770036410c190bc943d57c7e4e3ed3b596b5 100644 (file)
@@ -1,3 +1,17 @@
+##
+## YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
+##
+## Copyright (C) 2002-2010 Aleph One Ltd.
+##   for Toby Churchill Ltd and Brightstar Engineering
+##
+## Created by Charles Manning <charles@aleph1.co.uk>
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License version 2 as
+## published by the Free Software Foundation.
+##
+
+
 from yaffsfs import *
 
 def yaffs_ls(dname):
@@ -17,10 +31,12 @@ def yaffs_ls(dname):
 
             if isFile :
                 print "File ",se.d_ino, hex(perms), st.st_size, fullname
-            if isDir :
+            elif isDir :
                 print "Dir  ",se.d_ino, hex(perms), fullname
                 yaffs_ls(fullname)
-                
+            else :
+               print "Other (",hex(st.st_mode),") ",se.d_ino, hex(perms), fullname
+
             sep = yaffs_readdir(dc)
         yaffs_closedir(dc)
         return 0
@@ -45,13 +61,39 @@ def yaffs_mkfile(fname,fsize):
     else :
         return -1
 
+def yaffs_link_test(dir):
+    fnamea = dir + '/aaa'
+    fnameb = dir + '/bbb'
+    yaffs_unlink(fnamea)
+    fd = yaffs_open(fnamea,66,0666)
+    yaffs_link(fnamea,fnameb)
+    yaffs_ls(dir)
+    yaffs_unlink(fnamea)
+    yaffs_ls(dir)
+    yaffs_unlink(fnameb)
+
+def yaffs_o_excl_test(dir):
+    fname = dir + '/aaa'
+    yaffs_unlink(fname)
+    fd = yaffs_open(fname, 66, 0666)
+    yaffs_close(fd)
+    print "Created ", fname, " result ", fd
+    fdx = yaffs_open(fname, 0301, 0666)
+    print "Attempt to create with O_EXCL existing file returned ", fdx
+    yaffs_unlink(fname)
+    fdx = yaffs_open(fname, 0301, 0666)
+    print "Attempt to create with O_EXCL non-existing file returned ", fdx
+
+    
 root = "/yaffs2"
 
-yaffs_StartUp()
+yaffs_start_up()
 yaffs_mount(root)
 
 yaffs_mkdir(root+"/dd",0666)
 
-yaffs_open(root+"/dd/111",66,0666)
+h = yaffs_open(root+"/dd/111",66,0666)
+yaffs_close(h)
 
 yaffs_ls(root)
+