yaffs Refactorisation first phase
[yaffs2.git] / direct / python / README.txt
1 Using python with yaffsfs
2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
3
4 Herewith a brief session showing yaffs direct being accessed from python.
5
6 I tried SWIG first, but ctypes turned out to be way, way easier...
7
8 Thanks to the people on NZPUG mailing list that helped with the exercise.
9
10 Build libyaffsfs.so with the accompanying Makefile.
11
12 $ make libyaffsfs.so
13
14 $ python
15 Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41) 
16 [GCC 4.3.3] on linux2
17 Type "help", "copyright", "credits" or "license" for more information.
18 >>> from yaffsfs import *
19 >>> yaffs_StartUp()
20 0
21 >>> yaffs_mount("/yaffs2")
22 yaffs: Mounting /yaffs2
23 yaffs: yaffs_GutsInitialise()
24 yaffs_ScanBackwards starts  intstartblk 1 intendblk 256...
25 0 blocks to be sorted...
26 ...done
27 yaffs_ScanBackwards ends
28
29 Block summary
30 0 blocks have illegal states
31 Unknown 0 blocks
32 Needs scanning 0 blocks
33 Scanning 0 blocks
34 Empty 256 blocks
35 Allocating 0 blocks
36 Full 0 blocks
37 Dirty 0 blocks
38 Checkpoint 0 blocks
39 Collecting 0 blocks
40 Dead 0 blocks
41
42 yaffs: yaffs_GutsInitialise() done.
43
44 0
45 >>> yaffs_open("/yaffs2/xx",66,0666)
46 yaffs: Tnodes added
47 Allocated block 1, seq  4097, 255 left
48 0
49 >>> yaffs_write(0,"abcdefg",5)
50 5
51 >>> b = create_string_buffer("",100)
52 >>> yaffs_lseek(0,0,0)
53 0
54 >>> yaffs_read(0,b,100)
55 5
56 >>> print b.value
57 abcde