Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 41130 | Differences between
and this patch

Collapse All | Expand All

(-)a/reiserfsprogs/debugreiserfs/unpack.c (-1 / +1 lines)
Lines 616-622 Link Here
616
	/* only one non-option argument is permitted */
616
	/* only one non-option argument is permitted */
617
	print_usage_and_exit();
617
	print_usage_and_exit();
618
618
619
    if (misc_device_mounted(argv[optind], 0))
619
    if (misc_device_mounted(argv[optind]) > 0)
620
	reiserfs_panic ("%s seems mounted, umount it first\n", argv[optind]);
620
	reiserfs_panic ("%s seems mounted, umount it first\n", argv[optind]);
621
  
621
  
622
    fd = open (argv[optind], O_RDWR | O_LARGEFILE);
622
    fd = open (argv[optind], O_RDWR | O_LARGEFILE);
(-)a/reiserfsprogs/fsck/fsck.h (+1 lines)
Lines 408-413 Link Here
408
struct fsck_data {
408
struct fsck_data {
409
    unsigned short mode; /* check, rebuild, etc*/
409
    unsigned short mode; /* check, rebuild, etc*/
410
    unsigned long options;
410
    unsigned long options;
411
    unsigned long mounted;
411
412
412
    struct rebuild_info rebuild;
413
    struct rebuild_info rebuild;
413
    struct check_info check;
414
    struct check_info check;
(-)a/reiserfsprogs/fsck/main.c (-9 / +11 lines)
Lines 746-755 Link Here
746
746
747
    mark_filesystem_consistent (fs);
747
    mark_filesystem_consistent (fs);
748
    clear_buffer_do_not_flush (fs->fs_super_bh);
748
    clear_buffer_do_not_flush (fs->fs_super_bh);
749
    
749
750
    if (misc_device_mounted(fs->fs_file_name, MF_RO)) {
750
    if (fsck_data(fs)->mounted == MF_RO) {
751
	reiserfs_warning(stderr, "\nThe partition is mounted ro. It is better "
751
	reiserfs_warning(stderr, "\nThe partition is mounted ro. It "
752
			 "to umount and mount it again.\n\n");
752
			 "is better to umount and mount it again.\n\n");
753
	ret = EXIT_REBOOT;
753
	ret = EXIT_REBOOT;
754
    }
754
    }
755
755
Lines 764-781 Link Here
764
}
764
}
765
765
766
/* check umounted or read-only mounted filesystems only */
766
/* check umounted or read-only mounted filesystems only */
767
void prepare_fs_for_check(reiserfs_filsys_t * fs) {
767
static void prepare_fs_for_check(reiserfs_filsys_t * fs) {
768
    /* The method could be called from auto_check already. */
768
    /* The method could be called from auto_check already. */
769
    if (fs->fs_flags == O_RDWR) 
769
    if (fs->fs_flags == O_RDWR) 
770
	return;
770
	return;
771
771
772
    reiserfs_reopen (fs, O_RDWR);
772
    reiserfs_reopen (fs, O_RDWR);
773
    
773
    
774
    if (misc_device_mounted(fs->fs_file_name, 0)) {
774
    fsck_data(fs)->mounted = misc_device_mounted(fs->fs_file_name);
775
	if (!misc_device_mounted(fs->fs_file_name, MF_RO)) {
775
    
776
    if (fsck_data(fs)->mounted > 0) {
777
	if (fsck_data(fs)->mounted == MF_RW) {
776
	    fsck_progress ("Partition %s is mounted with write permissions, "
778
	    fsck_progress ("Partition %s is mounted with write permissions, "
777
		"cannot check it\n", fs->fs_file_name);
779
		"cannot check it\n", fs->fs_file_name);
778
	    reiserfs_close (fs);
780
	    reiserfs_close(fs);
779
	    exit(EXIT_USER);
781
	    exit(EXIT_USER);
780
	}
782
	}
781
	
783
	
Lines 1093-1099 Link Here
1093
	stage_report (5, fs);
1095
	stage_report (5, fs);
1094
1096
1095
	if (fsck_mode(fs) != FSCK_CHECK) {
1097
	if (fsck_mode(fs) != FSCK_CHECK) {
1096
		if (misc_device_mounted(fs->fs_file_name, MF_RO)) {
1098
		if (misc_device_mounted(fs->fs_file_name) == MF_RO) {
1097
			reiserfs_warning(stderr, "\nThe partition is mounted ro. It is better "
1099
			reiserfs_warning(stderr, "\nThe partition is mounted ro. It is better "
1098
					 "to umount and mount it again.\n\n");
1100
					 "to umount and mount it again.\n\n");
1099
			retval = EXIT_REBOOT;
1101
			retval = EXIT_REBOOT;
(-)a/reiserfsprogs/include/misc.h (-4 / +4 lines)
Lines 35-43 Link Here
35
char * kdevname (int dev);
35
char * kdevname (int dev);
36
36
37
typedef enum mount_flags {
37
typedef enum mount_flags {
38
	MF_MOUNTED	= 0x1,
38
	MF_NOT_MOUNTED  = 0x0,
39
	MF_RO		= 0x2,
39
	MF_RO		= 0x1,
40
	MF_RW		= 0x4
40
	MF_RW		= 0x2
41
} mount_flags_t;
41
} mount_flags_t;
42
42
43
typedef struct mount_hint {
43
typedef struct mount_hint {
Lines 47-53 Link Here
47
} mount_hint_t;
47
} mount_hint_t;
48
48
49
struct mntent *misc_mntent(char *device);
49
struct mntent *misc_mntent(char *device);
50
int misc_device_mounted(char *device, __u32 options);
50
int misc_device_mounted(char *device);
51
	
51
	
52
void misc_print_credit(FILE *out);
52
void misc_print_credit(FILE *out);
53
53
(-)a/reiserfsprogs/lib/misc.c (-29 / +6 lines)
Lines 328-373 Link Here
328
	return (!proc && !path) ? INVAL_PTR : NULL;
328
	return (!proc && !path) ? INVAL_PTR : NULL;
329
}
329
}
330
330
331
static int callback_misc_mounted(char *device, __u32 options) {
331
int misc_device_mounted(char *device) {
332
	fprintf(stderr, "Could not figure out, is '%s' '%s' mounted?",
333
		device, options & MF_RO ? "RO" : options & MF_RW ? "RW" : "");
334
	return (user_confirmed (stderr, " (Yes)", "Yes\n"));
335
}
336
337
int misc_device_mounted(char *device, __u32 options) {
338
	struct mntent *mnt;
332
	struct mntent *mnt;
339
	
333
	
340
	/* Check for the "/" first to avoid any possible problem with 
334
	/* Check for the "/" first to avoid any possible problem with 
341
	   reflecting the root fs info in mtab files. */
335
	   reflecting the root fs info in mtab files. */
342
	if (misc_root_mounted(device)) {
336
	if (misc_root_mounted(device) == 1) {
343
		if (options & MF_RO)
337
		return misc_file_ro("/") ? MF_RO : MF_RW;
344
			return misc_file_ro(device);
345
346
		if (options & MF_RW)
347
			return !misc_file_ro(device);
348
349
		return 1;
350
	}
338
	}
351
	
339
	
352
	/* Lookup the mount entry. */
340
	/* Lookup the mount entry. */
353
	if ((mnt = misc_mntent(device)) == NULL) {
341
	if ((mnt = misc_mntent(device)) == NULL) {
354
		return 0;
342
		return MF_NOT_MOUNTED;
355
	} else if (mnt == INVAL_PTR) {
343
	} else if (mnt == INVAL_PTR) {
356
		goto error;
344
		return 0;
357
	}
345
	}
358
346
359
	if (options & MF_RO)
347
	return hasmntopt(mnt, MNTOPT_RO) ? MF_RO : MF_RW;
360
		return hasmntopt(mnt, MNTOPT_RO) != 0;
361
	
362
	if (options & MF_RW)
363
		return hasmntopt(mnt, MNTOPT_RW) != 0;
364
	
365
	return 1;
366
	
367
 error:
368
	/* Failed to lookup in /proc/mounts and /etc/mtab. 
369
	   Check if the "/" first and ask the user then. */
370
	return callback_misc_mounted(device, options);
371
}
348
}
372
349
373
char buf1 [100];
350
char buf1 [100];
(-)a/reiserfsprogs/reiserfscore/reiserfslib.c (-1 / +1 lines)
Lines 1197-1203 Link Here
1197
    dev_t rdev;
1197
    dev_t rdev;
1198
1198
1199
1199
1200
    if (misc_device_mounted(device_name, 0)) {
1200
    if (misc_device_mounted(device_name) > 0) {
1201
	/* device looks mounted */
1201
	/* device looks mounted */
1202
	reiserfs_warning (stderr, "'%s' looks mounted.", device_name);
1202
	reiserfs_warning (stderr, "'%s' looks mounted.", device_name);
1203
	check_forcing_ask_confirmation (force);
1203
	check_forcing_ask_confirmation (force);
(-)a/reiserfsprogs/resize_reiserfs/resize_reiserfs.c (-2 / +2 lines)
Lines 152-158 Link Here
152
    }
152
    }
153
153
154
    if (new_size < get_sb_block_count(fs->fs_ondisk_sb)) {
154
    if (new_size < get_sb_block_count(fs->fs_ondisk_sb)) {
155
	if (misc_device_mounted(fs->fs_file_name, 0)) {
155
	if (misc_device_mounted(fs->fs_file_name) > 0) {
156
	    reiserfs_warning (stderr, "Can't shrink filesystem on-line.\n\n");
156
	    reiserfs_warning (stderr, "Can't shrink filesystem on-line.\n\n");
157
	    return 1;
157
	    return 1;
158
	}
158
	}
Lines 276-282 Link Here
276
    if (resizer_check_fs_size(fs, block_count_new))
276
    if (resizer_check_fs_size(fs, block_count_new))
277
	return 1;
277
	return 1;
278
278
279
    if (misc_device_mounted(devname, 0)) {
279
    if (misc_device_mounted(devname) > 0) {
280
	reiserfs_close(fs);
280
	reiserfs_close(fs);
281
	error = resize_fs_online(devname, block_count_new);
281
	error = resize_fs_online(devname, block_count_new);
282
	reiserfs_warning(stderr, "\n\nresize_reiserfs: On-line resizing %s.\n\n",
282
	reiserfs_warning(stderr, "\n\nresize_reiserfs: On-line resizing %s.\n\n",
(-)a/reiserfsprogs/tune/tune.c (-1 / +1 lines)
Lines 467-473 Link Here
467
       --no-journal-available has been specified by user */
467
       --no-journal-available has been specified by user */
468
468
469
    /* make sure filesystem is not mounted */
469
    /* make sure filesystem is not mounted */
470
    if (misc_device_mounted(fs->fs_file_name, 0)) {
470
    if (misc_device_mounted(fs->fs_file_name) > 0) {
471
	/* fixme: it can not be mounted, btw */
471
	/* fixme: it can not be mounted, btw */
472
        message ("Reiserfstune is not allowed to be run on mounted filesystem.");
472
        message ("Reiserfstune is not allowed to be run on mounted filesystem.");
473
	reiserfs_close (fs);
473
	reiserfs_close (fs);

Return to bug 41130