This is an old revision of the document!


SDK Script mount-media.are

mount-media.are
/* DESC: This script can be used to mount an USB storage stick.
 * Copyright (C) 2012 NetModule AG, Switzerland
 */
 
device = "usb0";
mntpoint = "/mnt/media/usb0";
 
ret = nb_media_mount(device);
if (ret == 0) {
    printf("Successfully mounted usb0\n");
}
else {
  printf("Unable to mount usb0 (rc %d)\n", ret);
}
 
printf("\nMounted media:\n");
mounted = nb_media_getmount();
printf("%s\n", mounted);
 
 
printf("Files at %s:\n\n", mntpoint);
 
handle = opendir(mntpoint);
if (handle != -1) {
    while ((entry = readdir(handle))) {
        if (left(entry, 1) == ".") continue;
        printf("%s\n", entry);
    }
    closedir(handle);
} else {
    printf("cannot open directory %s", mntpoint);
}
 
nb_media_umount(device);
 
exit(0);