~ubuntu-branches/ubuntu/natty/util-linux/natty

« back to all changes in this revision

Viewing changes to mount/umount.c

  • Committer: Colin Watson
  • Author(s): Surbhi Palande
  • Date: 2011-01-26 16:54:03 UTC
  • Revision ID: cjwatson@canonical.com-20110126165403-xdau1lr2h4392164
Fixes a segfault on umount, caused due to an empty mtab entry.
(LP: #579858)

Show diffs side-by-side

added added

removed removed

Lines of Context:
253
253
                res = mount(spec, node, NULL,
254
254
                            MS_MGC_VAL | MS_REMOUNT | MS_RDONLY, NULL);
255
255
                if (res == 0) {
256
 
                        struct my_mntent remnt;
257
256
                        fprintf(stderr,
258
257
                                _("umount: %s busy - remounted read-only\n"),
259
258
                                spec);
260
 
                        remnt.mnt_type = remnt.mnt_fsname = NULL;
261
 
                        remnt.mnt_dir = xstrdup(node);
262
 
                        remnt.mnt_opts = xstrdup("ro");
263
 
                        if (!nomtab)
 
259
                        if (mc && !nomtab) {
 
260
                                /* update mtab if the entry is there */
 
261
                                struct my_mntent remnt;
 
262
                                remnt.mnt_fsname = mc->m.mnt_fsname;
 
263
                                remnt.mnt_dir = mc->m.mnt_dir;
 
264
                                remnt.mnt_type = mc->m.mnt_type;
 
265
                                remnt.mnt_opts = "ro";
 
266
                                remnt.mnt_freq = 0;
 
267
                                remnt.mnt_passno = 0;
264
268
                                update_mtab(node, &remnt);
 
269
                        }
265
270
                        return 0;
266
271
                } else if (errno != EBUSY) {    /* hmm ... */
267
272
                        perror("remount");