]> Chaos Git - corbenik/ctrulib.git/commitdiff
fsInit fix
authorsmea <smealum@gmail.com>
Mon, 25 Aug 2014 05:50:57 +0000 (22:50 -0700)
committersmea <smealum@gmail.com>
Mon, 25 Aug 2014 05:50:57 +0000 (22:50 -0700)
libctru/source/services/fs.c
libctru/source/srv.c

index 566cc43280a1b10d0ef762e9d5bf17cb41b3b917..cdd2f31a3f115752ce04f7530f2113ccbd4bff1a 100644 (file)
@@ -14,6 +14,9 @@
 /*! FSUSER handle */
 static Handle fsuHandle;
 
+// used to determine whether or not we should do FSUSER_Initialize on fsuHandle
+Handle __get_handle_from_list(char* name);
+
 /*! Initialize FS service
  *
  *  @returns error
@@ -21,7 +24,10 @@ static Handle fsuHandle;
 Result
 fsInit(void)
 {
-       return srvGetServiceHandle(&fsuHandle, "fs:USER");
+       Result ret;
+       if((ret=srvGetServiceHandle(&fsuHandle, "fs:USER"))!=0)return ret;
+       if(__get_handle_from_list("fs:USER")==0)ret=FSUSER_Initialize(NULL);
+       return ret;
 }
 
 /*! Deinitialize FS service
@@ -62,7 +68,12 @@ Result
 FSUSER_Initialize(Handle* handle)
 {
        if(!handle)
+       {
+               // don't run command if we got handle from the list
                handle = &fsuHandle;
+               if(fsuHandle != 0 && __get_handle_from_list("fs:USER")==0)
+                       return 0;
+       }
 
        u32 *cmdbuf = getThreadCommandBuffer();
 
index 0f957c77093da50e038191ae5eb52d6b6943882c..40f98d6a66ddaabd3188a5674b20398689c9f969 100644 (file)
@@ -47,7 +47,7 @@ static int __name_cmp(const char* a, const char* b) {
        return 0;
 }
 
-static Handle __get_handle_from_list(char* name) {
+Handle __get_handle_from_list(char* name) {
        if((u32)__service_ptr == 0)
                return 0;