Differences

This shows you the differences between two versions of the page.

Link to this comparison view

sdk:scripts:mount-media [2015/05/05 15:04] – external edit 127.0.0.1sdk:scripts:mount-media [2022/09/05 12:08] (current) schmitt
Line 2: Line 2:
 <code c mount-media.are> <code c mount-media.are>
 /* DESC: This script can be used to mount an USB storage stick. /* DESC: This script can be used to mount an USB storage stick.
- * Copyright (C) 2012 NetModule AG, Switzerland+ * Copyright (C) 2012-2016 NetModule AG, Switzerland
  */  */
  
-device = "usb0"; +device = "usb0"; // or storage0 
-mntpoint = "/mnt/media/usb0";+mntpoint = sprintf("/mnt/media/%s", device);
  
 +printf("Mounting '%s'", device);
 ret = nb_media_mount(device); ret = nb_media_mount(device);
 if (ret == 0) { if (ret == 0) {
-    printf("Successfully mounted usb0\n"); +    printf("Successfully mounted %s\n", device); 
-} +} else { 
-else { +    printf("Unable to mount %s (rc %d)\n", ret, device); 
-  printf("Unable to mount usb0 (rc %d)\n", ret);+    exit(1);
 } }
  
Line 19: Line 20:
 mounted = nb_media_getmount(); mounted = nb_media_getmount();
 printf("%s\n", mounted); printf("%s\n", mounted);
- 
  
 printf("Files at %s:\n\n", mntpoint); printf("Files at %s:\n\n", mntpoint);
- 
 handle = opendir(mntpoint); handle = opendir(mntpoint);
 if (handle != -1) { if (handle != -1) {
Line 34: Line 33:
 } }
  
 +
 +printf("Umounting '%s'", device);
 nb_media_umount(device); nb_media_umount(device);
  
 exit(0); exit(0);
 +
  
 </code> </code>