Android-x86
Fork
Faire un don

  • R/O
  • HTTP
  • SSH
  • HTTPS

system-vold: Commit

system/vold


Commit MetaInfo

Révisioneac9c08a5392535f9eafb65c922344e4ccc29466 (tree)
l'heure2010-12-16 16:18:13
AuteurChih-Wei Huang <cwhuang@linu...>
CommiterChih-Wei Huang

Message de Log

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

Change Summary

Modification

--- 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
@@ -171,22 +171,34 @@ static int process_config(VolumeManager *vm) {
171171 FILE *fp;
172172 int n = 0;
173173 char line[255];
174-
175- if (!(fp = fopen("/etc/vold.fstab", "r"))) {
176- const char *sdcard = 0;
177- if ((fp = fopen("/proc/cmdline", "r"))) {
178- while (fscanf(fp, "%s", line) > 0) {
179- if (!strncmp(line, "SDCARD=", 7)) {
180- sdcard = line + 7;
181- break;
174+ Volume *vol = 0;
175+
176+ if ((fp = fopen("/proc/cmdline", "r"))) {
177+ while (fscanf(fp, "%s", line) > 0) {
178+ if (!strncmp(line, "SDCARD=", 7)) {
179+ const char *sdcard = line + 7;
180+ if (*sdcard) {
181+ // FIXME: should not hardcode the label and mount_point
182+ if ((vol = new AutoVolume(vm, "sdcard", "/mnt/sdcard", sdcard))) {
183+ vm->addVolume(vol);
184+ break;
185+ }
182186 }
183187 }
184- fclose(fp);
185188 }
186- // FIXME: should not hardcode the label and mount_point
187- AutoVolume *dv = new AutoVolume(vm, "sdcard", "/mnt/sdcard", sdcard);
188- vm->addVolume(dv);
189- return 0;
189+ fclose(fp);
190+ }
191+
192+ if (!(fp = fopen("/etc/vold.fstab", "r"))) {
193+ // no volume added yet, create a AutoVolume object
194+ // to mount USB/MMC/SD automatically
195+ if (!vol) {
196+ // FIXME: should not hardcode the label and mount_point
197+ vol = new AutoVolume(vm, "sdcard", "/mnt/sdcard");
198+ if (vol)
199+ vm->addVolume(vol);
200+ }
201+ return vol ? 0 : -ENOMEM;
190202 }
191203
192204 while(fgets(line, sizeof(line), fp)) {
@@ -221,20 +233,28 @@ static int process_config(VolumeManager *vm) {
221233 SLOGE("Error parsing partition");
222234 goto out_syntax;
223235 }
224- if (int idx = (strcmp(part, "auto") ? atoi(part) : -1)) {
225- dv = new DirectVolume(vm, label, mount_point, idx);
226- } else {
236+ int idx = (strcmp(part, "auto") ? atoi(part) : -1);
237+ if (!idx) {
227238 SLOGE("Partition must either be 'auto' or 1 based index instead of '%s'", part);
228239 goto out_syntax;
229240 }
230241
242+ const char *sdcard = 0;
231243 while (char *sysfs_path = strtok_r(NULL, delim, &save_ptr)) {
244+ if ((sdcard = strncmp(sysfs_path, "SDCARD=", 7) ? 0 : sysfs_path + 7))
245+ break;
246+ if (!dv) {
247+ dv = new DirectVolume(vm, label, mount_point, idx);
248+ }
232249 if (dv->addPath(sysfs_path)) {
233250 SLOGE("Failed to add devpath %s to volume %s", sysfs_path,
234251 label);
235252 goto out_fail;
236253 }
237254 }
255+ if (!dv) {
256+ dv = new AutoVolume(vm, label, mount_point, sdcard);
257+ }
238258 vm->addVolume(dv);
239259 } else if (!strcmp(type, "map_mount")) {
240260 } else {
Afficher sur ancien navigateur de dépôt.