Magellan Linux

Diff of /trunk/mkinitrd-magellan/klibc/usr/kinit/do_mounts.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1121 by niro, Sat Sep 1 22:45:15 2007 UTC revision 1122 by niro, Wed Aug 18 21:11:40 2010 UTC
# Line 33  const char *mount_block(const char *sour Line 33  const char *mount_block(const char *sour
33   int fd;   int fd;
34    
35   if (type) {   if (type) {
36   DEBUG(("kinit: trying to mount %s on %s with type %s\n",   dprintf("kinit: trying to mount %s on %s with type %s\n",
37         source, target, type));   source, target, type);
38   int rv = mount(source, target, type, flags, data);   int rv = mount(source, target, type, flags, data);
39   /* Mount readonly if necessary */   /* Mount readonly if necessary */
40   if (rv == -1 && errno == EACCES && !(flags & MS_RDONLY))   if (rv == -1 && errno == EACCES && !(flags & MS_RDONLY))
# Line 52  const char *mount_block(const char *sour Line 52  const char *mount_block(const char *sour
52   close(fd);   close(fd);
53    
54   if (!err && type) {   if (!err && type) {
55   DEBUG(("kinit: %s appears to be a %s filesystem\n",   dprintf("kinit: %s appears to be a %s filesystem\n",
56         source, type));   source, type);
57   type = mount_block(source, target, type, flags, data);   type = mount_block(source, target, type, flags, data);
58   if (type)   if (type)
59   return type;   return type;
60   }   }
61   }   }
62    
63   DEBUG(("kinit: failed to identify filesystem %s, trying all\n",   dprintf("kinit: failed to identify filesystem %s, trying all\n",
64         source));   source);
65    
66   fsbytes = readfile("/proc/filesystems", &fslist);   fsbytes = readfile("/proc/filesystems", &fslist);
67    
# Line 139  mount_block_root(int argc, char *argv[], Line 139  mount_block_root(int argc, char *argv[],
139   return 0;   return 0;
140  }  }
141    
142    static int
143    mount_roots(int argc, char *argv[], const char *root_dev_name)
144    {
145     char *roots = strdup(root_dev_name);
146     char *root;
147     const char *sep = ",";
148     char *saveptr;
149     int ret = -ESRCH;
150    
151     root = strtok_r(roots, sep, &saveptr);
152     while (root) {
153     dev_t root_dev;
154    
155     dprintf("kinit: trying to mount %s\n", root);
156     root_dev = name_to_dev_t(root);
157     ret = mount_root(argc, argv, root_dev, root);
158     if (!ret)
159     break;
160     root = strtok_r(NULL, sep, &saveptr);
161     }
162     free(roots);
163     return ret;
164    }
165    
166  int  int
167  mount_root(int argc, char *argv[], dev_t root_dev, const char *root_dev_name)  mount_root(int argc, char *argv[], dev_t root_dev, const char *root_dev_name)
168  {  {
# Line 147  mount_root(int argc, char *argv[], dev_t Line 171  mount_root(int argc, char *argv[], dev_t
171   const char *type = get_arg(argc, argv, "rootfstype=");   const char *type = get_arg(argc, argv, "rootfstype=");
172    
173   if (get_flag(argc, argv, "rw") > get_flag(argc, argv, "ro")) {   if (get_flag(argc, argv, "rw") > get_flag(argc, argv, "ro")) {
174   DEBUG(("kinit: mounting root rw\n"));   dprintf("kinit: mounting root rw\n");
175   flags &= ~MS_RDONLY;   flags &= ~MS_RDONLY;
176   }   }
177    
# Line 183  int do_mounts(int argc, char *argv[]) Line 207  int do_mounts(int argc, char *argv[])
207   const char *load_ramdisk = get_arg(argc, argv, "load_ramdisk=");   const char *load_ramdisk = get_arg(argc, argv, "load_ramdisk=");
208   dev_t root_dev = 0;   dev_t root_dev = 0;
209    
210   DEBUG(("kinit: do_mounts\n"));   dprintf("kinit: do_mounts\n");
211    
212   if (root_delay) {   if (root_delay) {
213   int delay = atoi(root_delay);   int delay = atoi(root_delay);
# Line 205  int do_mounts(int argc, char *argv[]) Line 229  int do_mounts(int argc, char *argv[])
229   root_dev = (dev_t) rootdev;   root_dev = (dev_t) rootdev;
230   }   }
231    
232   DEBUG(("kinit: root_dev = %s\n", bdevname(root_dev)));   dprintf("kinit: root_dev = %s\n", bdevname(root_dev));
233    
234   if (initrd_load(argc, argv, root_dev)) {   if (initrd_load(argc, argv, root_dev)) {
235   DEBUG(("initrd loaded\n"));   dprintf("initrd loaded\n");
236   return 0;   return 0;
237   }   }
238    
239   if (load_ramdisk && atoi(load_ramdisk)) {   if (load_ramdisk && atoi(load_ramdisk)) {
240   if (ramdisk_load(argc, argv, root_dev))   if (ramdisk_load(argc, argv))
241   root_dev = Root_RAM0;   root_dev = Root_RAM0;
242   }   }
243    
244     if (root_dev == Root_MULTI)
245     return mount_roots(argc, argv, root_dev_name);
246   return mount_root(argc, argv, root_dev, root_dev_name);   return mount_root(argc, argv, root_dev, root_dev_name);
247  }  }

Legend:
Removed from v.1121  
changed lines
  Added in v.1122