Download presentation
Presentation is loading. Please wait.
1
OLPC and Mono The Sugar Datastore
Torello Querci OLPC-Italia Paris 15th November 2008
2
Outline Activity Isolation Rainbow How to access and share files
Datastore What to do with it Mono bindings How to search data How to write data
3
Activity Isolation Rainbow
Rainbow implements the isolation shell implicitly described in the Bitfrost security specification. This means that it isolates activities (and eventually system services) that it is asked to run from one another and the rest of the system.
4
Activity Isolation Rainbow
Rainbow implements this isolation by generating a new uid (and perhaps a new gid) for each program it is asked to run. Running each activity as a separate user means that standard Unix access checks can be used as the primary 'gate' to control the visibility of activity-driven side-effects like reading from or writing to files or devices or signaling other processes.
5
Activity Isolation How to access to files
Activity can access to its own files Activity can access to system files world readable Activity cannot access to files owned by other activity When activity is closed all its files (except configuration files) will be destroyed
6
Activity Isolation How to access to files
Since each activity is run as a different user, it gets a different home directory on each invocation. In release 8.2, the home directory for an activity equals the $SUGAR_ACTIVITY_ROOT/instance/ directory. For data such as config files to survive and be accessible by all future activity invocations, they must not be stored in $HOME but rather $SUGAR_ACTIVITY_ROOT/data/ should be used.
7
Activity Isolation How to share files
All writing to the file system is restricted to subdirectories of the path given in the SUGAR_ACTIVITY_ROOT environment variable. $SUGAR_ACTIVITY_ROOT/instance/ is used similar to a /var/tmp directory. It is unique per instance. It is used for transfer to and from the datastore. This directory is deleted when the activity exits
8
Datastore How does it work?
Datastore is a service that use DBus to communicate with the client application
9
Datastore What to do with it
10
Datastore The Mono Bindings
user activity sugar framework user C# code Datastore Service sugar-sharp low-level API sugar-sharp high-level API NDesk-DBus assembly DBUS
11
Datastore bindings How can use it?
On Sugar-sharp there is two way to use datastore: 1 – using low level API you can invoke directly the Dbus methods and signals 2 – using high level API the datastore is made easy
12
Datastore bindings Why low level API
Need a mapping for DBus methods and signals Since there is low level API everyone can use it
13
Datastore bindings Why high level API
Low level API is not so easy to use Python Activities use high level API to manage the datastore, it is easier to use the same interface
14
Datastore bindings How to search
Dictionary<String,object> query=new Dictionary<String,object>(); query.Add("monkeys_memory","true"); ArrayList result=null; result = Datastore.find(query); if (result!=null && result.Count>0) { System.Console.Out.WriteLine("count="+result.Count); DSObject dsObj; IEnumerator en=result.GetEnumerator(); while (en.MoveNext()) { dsObj=(DSObject) en.Current; System.Console.Out.WriteLine("OBJ_ID="+dsObj.object_id.ToString()); System.Console.Out.WriteLine("FILE_PATH="+dsObj.FilePath); foreach (String key in dsObj.Metadata.Keys()) { System.Console.Out.WriteLine(key+" value="+dsObj.Metadata.get(key,null).ToString()); }
15
Datastore bindings How to write 1/2
String tmpDir=System.Environment.GetEnvironmentVariable("SUGAR_ACTIVITY_ROOT"); tmpDir += "/instance"; UnixFileInfo t = new UnixFileInfo(tmpDir+"/test.txt"); StreamWriter sw = new StreamWriter(t.FullName); sw.WriteLine("This is only a simple "); sw.WriteLine("textfile that need to be stored on datastore"); sw.Close(); Step 1 – Write something on a file
16
Datastore bindings How to write 2/2
DSObject dsobject=Datastore.Create(); // Write any metadata (here we specifically set the title of the file and // specify that this is a plain text file). dsobject.Metadata.setItem("title","Monkey's Memory Activity"); dsobject.Metadata.setItem("mime_type","text/plain"); dsobject.Metadata.setItem("monkeys_memory","true"); dsobject.FilePath=t.FullName; Datastore.write(dsobject); Step 2 – Ask datastore to store it
17
And now .....
18
Hack, hack, hack ....
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.