~xdavidwu/saf-cephfs

03395b4552c43b06bd2e725767a5d652a286a320 — xdavidwu 3 years ago 709a7bc
DocumentsProvider: set up ceph on create
1 files changed, 27 insertions(+), 19 deletions(-)

M src/main/java/org/safcephfs/CephFSDocumentsProvider.java
M src/main/java/org/safcephfs/CephFSDocumentsProvider.java => src/main/java/org/safcephfs/CephFSDocumentsProvider.java +27 -19
@@ 140,6 140,31 @@ public class CephFSDocumentsProvider extends DocumentsProvider {
		return null;
	}

	private boolean setupCeph() {
		SharedPreferences settings = PreferenceManager
			.getDefaultSharedPreferences(getContext());
		mon = settings.getString("mon", "");
		key = settings.getString("key", "");
		id = settings.getString("id", "");
		path = settings.getString("path", "");
		cm = new CephMount(id);
		cm.conf_set("mon_host", mon);
		cm.conf_set("key", key);
		checkPermissions = settings.getBoolean("permissions", true);
		if (!checkPermissions) {
			cm.conf_set("client_permissions", "false");
		}
		try {
			cm.mount(path);
		} catch (IOException e) { // from jni
			Message msg = lthread.handler.obtainMessage();
			msg.obj = "SAF CephFS: unable to mount root: " + e.toString();
			lthread.handler.sendMessage(msg);
			return false;
		}
		return true;
	}

	@Override
	public boolean onCreate() {
		sm = (StorageManager) getContext()


@@ 150,6 175,7 @@ public class CephFSDocumentsProvider extends DocumentsProvider {
		ioThread.start();
		ioHandler = new Handler(ioThread.getLooper());
		uid = Process.myUid();
		setupCeph();
		return true;
	}



@@ 305,25 331,7 @@ public class CephFSDocumentsProvider extends DocumentsProvider {
	public Cursor queryRoots(String[] projection)
			throws FileNotFoundException {
		MatrixCursor result = new MatrixCursor(projection != null ? projection : DEFAULT_ROOT_PROJECTION);
		SharedPreferences settings = PreferenceManager
			.getDefaultSharedPreferences(getContext());
		mon = settings.getString("mon", "");
		key = settings.getString("key", "");
		id = settings.getString("id", "");
		path = settings.getString("path", "");
		cm = new CephMount(id);
		cm.conf_set("mon_host", mon);
		cm.conf_set("key", key);
		checkPermissions = settings.getBoolean("permissions", true);
		if (!checkPermissions) {
			cm.conf_set("client_permissions", "false");
		}
		try {
			cm.mount(path);
		} catch (IOException e) { // from jni
			Message msg = lthread.handler.obtainMessage();
			msg.obj = "SAF CephFS: unable to mount root: " + e.toString();
			lthread.handler.sendMessage(msg);
		if (!setupCeph()) {
			return result;
		}
		CephStatVFS csvfs = new CephStatVFS();