#!/usr/bin/python
+##
+## 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 Timothy Manning <timothy@yaffs.net>
+##
+## 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.
+##
+
import Tkinter as tk
from yaffsfs import *
#import examples
import ctypes
+from operator import itemgetter
-yaffs_StartUp()
+yaffs_start_up()
yaffs_mount("/yaffs2/")
root_window =tk.Tk()
root_window.title("YAFFS Browser")
length_of_file=yaffs_lseek(self.yaffs_handle, 0, 2) ##seeks to the end of the file
yaffs_lseek(self.yaffs_handle, 0, 0)## returns the handle to the front of th file
print "length of file to be opened:", length_of_file
- if isLink==True:
+ if isLink==True and False ==True : ##this alows the symlink to be edited and is no longer used. to renable it delete "and False ==True"
print "opening symlink"
self.file_contents=ctypes.create_string_buffer(1000)
yaffs_readlink(self.file_path,self.file_contents,1000)
def load_dir():
global current_directory_dict
print "loading a new directory*******************************************************************"
+ ##deleate current items in text box
name_list_box.delete(0, tk.END)
current_directory_dict=yaffs_ls(mount_list_text_variable.get())
print "new directory", current_directory_dict
+
+
+
##copy directory into file box
for x in range(0,len(current_directory_dict)):
- name_list_box.insert(x,(current_directory_dict[x]["inodes"]+" "+ current_directory_dict[x]["type"]+" "+ current_directory_dict[x]["size"]+" "+ current_directory_dict[x]["path"]+" "+current_directory_dict[x]["extra_data"]))
+ permissions_string=""
+ if current_directory_dict[x]["permissions"] & yaffs_S_IREAD:
+ permissions_string ='r'
+ else :
+ permissions_string ='-'
+ if current_directory_dict[x]["permissions"] & yaffs_S_IWRITE:
+ permissions_string+='w'
+ else :
+ permissions_string+='-'
+ name_list_box.insert(x,(current_directory_dict[x]["inodes"]+" "+permissions_string+" "+ current_directory_dict[x]["type"]+" "+ current_directory_dict[x]["size"]+" "+ current_directory_dict[x]["path"]+" "+current_directory_dict[x]["extra_data"]))
name_list_box.grid(column=0, row=1)
return current_directory_dict
-
+
+def remount_yaffs():
+ ##this isn't working. somethihg need to be changed in the config of the simulator to release the handle of the emfile
+ print "remounting yaffs"
+ print"unmounting yaffs:", yaffs_unmount("yaffs2/")
+ print "mounting yaffs", yaffs_mount("/yaffs2/")
+ load_dir()
+
def load_file(link=0):
global open_windows_list
open_windows_list.append(editor(link))
def load_command(self=0):
- global current_directory_dict
+ global current_directory_dictls
+
print "you loaded a file/dir/link"
x=name_list_box.curselection()
x=int(x[0])
fullname = dname + se.d_name
st = yaffs_stat_struct()
result = yaffs_lstat(fullname,byref(st))
- perms = st.st_mode & 0777
+ #perms = st.st_mode & 0777
+ perms = st.st_mode
ftype = st.st_mode & yaffs_S_IFMT
isFile = True if ftype == yaffs_S_IFREG else False
isDir = True if ftype == yaffs_S_IFDIR else False
isSymlink= True if ftype == yaffs_S_IFLNK else False
if isFile :
- ls_dict.append ({"type" :"file", "inodes" : str(se.d_ino), "permissions" : str(hex(perms)), "size": str(st.st_size), "path": fullname,"extra_data":""})
+ ls_dict.append ({"type" :"file", "inodes" : str(se.d_ino), "permissions" : perms, "size": str(st.st_size), "path": fullname,"extra_data":""})
print "file st.st_mode:", st.st_mode
elif isDir :
print "dir st.st_mode:", st.st_mode
- ls_dict.append({"type":"dir", "inodes" :str(se.d_ino), "permissions":str( hex(perms)),"size":"0", "path": fullname+"/", "extra_data":""})
+ ls_dict.append({"type":"dir", "inodes" :str(se.d_ino), "permissions":perms,"size":"0", "path": fullname+"/", "extra_data":""})
elif isSymlink:
print "symlink st.st_mode:", st.st_mode
file_contents=ctypes.create_string_buffer(30)
print "string", string, "###"
- ls_dict.append ({"type" :"link", "inodes" : str(se.d_ino), "permissions" : str(hex(perms)), "size": str(st.st_size), "path": fullname, "extra_data":"> "+string})
+ ls_dict.append ({"type" :"link", "inodes" : str(se.d_ino), "permissions" : perms, "size": str(st.st_size), "path": fullname, "extra_data":"> "+string})
else :
print "unknown st.st_mode:", st.st_mode
- ls_dict.append({ "type":"Other", "inodes":str(se.d_ino), "permissions":str( hex(perms)), "size":"0", "path": fullname,"extra_data":""})
+ ls_dict.append({ "type":"Other", "inodes":str(se.d_ino), "permissions":perms, "size":"0", "path": fullname,"extra_data":""})
sep = yaffs_readdir(dc)
yaffs_closedir(dc)
- return ls_dict
+ return sorted(ls_dict,key=itemgetter("path"))
else:
print "Could not open directory"
return -1
output=yaffs_rmdir(path)
print "rmdir output:", output
-
-
load_dir()
browser_file_menu=tk.Menu(browser_menu_bar)
browser_file_menu.add_command(label="Reload", command=load_dir)
+browser_file_menu.add_command(label="Remount yaffs", command=remount_yaffs)
+
#browser_file_menu.add_command(label="Open")
#browser_file_menu.add_command(label="Save")
browser_menu_bar.add_cascade(label="File", menu=browser_file_menu)