1 Using python with yaffsfs
2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 Herewith a brief session showing yaffs direct being accessed from python.
6 I tried SWIG first, but ctypes turned out to be way, way easier...
8 Thanks to the people on NZPUG mailing list that helped with the exercise.
10 Build libyaffsfs.so with the accompanying Makefile.
15 Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
17 Type "help", "copyright", "credits" or "license" for more information.
18 >>> from ctypes import *
19 >>> cdll.LoadLibrary("./libyaffsfs.so")
20 <CDLL './libyaffsfs.so', handle 9ed4178 at b7d418ac>
21 >>> y = CDLL("./libyaffsfs.so")
24 >>> y.yaffs_mount("/yaffs2")
25 yaffs: Mounting /yaffs2
26 yaffs: yaffs_GutsInitialise()
27 yaffs_ScanBackwards starts intstartblk 1 intendblk 256...
28 0 blocks to be sorted...
30 yaffs_ScanBackwards ends
33 0 blocks have illegal states
35 Needs scanning 0 blocks
45 yaffs: yaffs_GutsInitialise() done.
48 >>> y.yaffs_open("/yaffs2/xx",66,0666)
50 Allocated block 1, seq 4097, 255 left
52 >>> y.yaffs_write(0,"abc",3)
54 >>> y.yaffs_lseek(0,0,0)
56 >>> b = create_string_buffer("",100)
57 >>> y.yaffs_read(0,b,100)