Android-x86
Fork
Donation

  • R/O
  • HTTP
  • SSH
  • HTTPS

system-vold: Commit

system/vold


Commit MetaInfo

Revisiónb8937899cd7af91c16db6a805ef264f203c97a2a (tree)
Tiempo2011-08-04 18:25:10
AutorChih-Wei Huang <cwhuang@linu...>
CommiterChih-Wei Huang

Log Message

vold: extend the syntax of vold.fstab

Now vold.fstab can accept the following:

dev_mount sdcard /mnt/sdcard auto <devpath> // use normal DirectVolume
dev_mount sdcard /mnt/sdcard auto SDCARD=dev_node // use AutoVolume for specified device node
dev_mount sdcard /mnt/sdcard auto // use AutoVolume to mount USB/MMC/SD automatically

Cambiar Resumen

Diferencia incremental

--- a/AutoVolume.h
+++ b/AutoVolume.h
@@ -22,7 +22,7 @@
2222
2323 class AutoVolume : public DirectVolume {
2424 public:
25- AutoVolume(VolumeManager *vm, const char *label, const char *mount_point, const char *part_name);
25+ AutoVolume(VolumeManager *vm, const char *label, const char *mount_point, const char *part_name = 0);
2626 virtual ~AutoVolume();
2727
2828 protected:
--- a/main.cpp
+++ b/main.cpp
@@ -145,22 +145,34 @@ static int process_config(VolumeManager *vm) {
145145 FILE *fp;
146146 int n = 0;
147147 char line[255];
148-
149- if (!(fp = fopen("/etc/vold.fstab", "r"))) {
150- const char *sdcard = 0;
151- if ((fp = fopen("/proc/cmdline", "r"))) {
152- while (fscanf(fp, "%s", line) > 0) {
153- if (!strncmp(line, "SDCARD=", 7)) {
154- sdcard = line + 7;
155- break;
148+ Volume *vol = 0;
149+
150+ if ((fp = fopen("/proc/cmdline", "r"))) {
151+ while (fscanf(fp, "%s", line) > 0) {
152+ if (!strncmp(line, "SDCARD=", 7)) {
153+ const char *sdcard = line + 7;
154+ if (*sdcard) {
155+ // FIXME: should not hardcode the label and mount_point
156+ if ((vol = new AutoVolume(vm, "sdcard", "/mnt/sdcard", sdcard))) {
157+ vm->addVolume(vol);
158+ break;
159+ }
156160 }
157161 }
158- fclose(fp);
159162 }
160- // FIXME: should not hardcode the label and mount_point
161- AutoVolume *dv = new AutoVolume(vm, "sdcard", "/mnt/sdcard", sdcard);
162- vm->addVolume(dv);
163- return 0;
163+ fclose(fp);
164+ }
165+
166+ if (!(fp = fopen("/etc/vold.fstab", "r"))) {
167+ // no volume added yet, create a AutoVolume object
168+ // to mount USB/MMC/SD automatically
169+ if (!vol) {
170+ // FIXME: should not hardcode the label and mount_point
171+ vol = new AutoVolume(vm, "sdcard", "/mnt/sdcard");
172+ if (vol)
173+ vm->addVolume(vol);
174+ }
175+ return vol ? 0 : -ENOMEM;
164176 }
165177
166178 while(fgets(line, sizeof(line), fp)) {
@@ -195,20 +207,28 @@ static int process_config(VolumeManager *vm) {
195207 SLOGE("Error parsing partition");
196208 goto out_syntax;
197209 }
198- if (int idx = (strcmp(part, "auto") ? atoi(part) : -1)) {
199- dv = new DirectVolume(vm, label, mount_point, idx);
200- } else {
210+ int idx = (strcmp(part, "auto") ? atoi(part) : -1);
211+ if (!idx) {
201212 SLOGE("Partition must either be 'auto' or 1 based index instead of '%s'", part);
202213 goto out_syntax;
203214 }
204215
216+ const char *sdcard = 0;
205217 while (char *sysfs_path = strtok_r(NULL, delim, &save_ptr)) {
218+ if ((sdcard = strncmp(sysfs_path, "SDCARD=", 7) ? 0 : sysfs_path + 7))
219+ break;
220+ if (!dv) {
221+ dv = new DirectVolume(vm, label, mount_point, idx);
222+ }
206223 if (dv->addPath(sysfs_path)) {
207224 SLOGE("Failed to add devpath %s to volume %s", sysfs_path,
208225 label);
209226 goto out_fail;
210227 }
211228 }
229+ if (!dv) {
230+ dv = new AutoVolume(vm, label, mount_point, sdcard);
231+ }
212232 vm->addVolume(dv);
213233 } else if (!strcmp(type, "map_mount")) {
214234 } else {
Show on old repository browser