bug-parted
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

devfs fixes


From: Yura Umanets
Subject: devfs fixes
Date: Wed, 18 Jul 2001 19:47:06 +0300
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.2) Gecko/20010628

More devfs fixes. See ChangeLog.
diff -r --unified ./parted-1.5.3-pre1-old/ChangeLog 
./parted-1.5.3-pre1/ChangeLog
--- ./parted-1.5.3-pre1-old/ChangeLog   Wed Jul 18 19:37:42 2001
+++ ./parted-1.5.3-pre1/ChangeLog       Wed Jul 18 19:36:12 2001
@@ -7,22 +7,6 @@
 -----------------------------------------------------------------------------
 1.5.x
 -----------------------------------------------------------------------------
-July 18th 2001 - Yury Umanets <address@hidden>
-* check whether the device isn't symbol link to real device. 
-This help to avoid duplication of the devices after ped_device_probe_all
-when devfs is using. Now parted will be uses real device.
-* added "path" field to PedPartition struct. Therefore we don't need create
-partition path every time when we need it by 
-sprintf("%s%d", dev->path, part->num) construction.
-* more changes to avoid invalid partition path when devfs is used. This fixes 
-problem when device path is /dev/ide/host0/bus0/target0/lun0/disc, 
-and partition path is /dev/ide/host0/bus0/target0/lun0/disc1, ... Now 
partition 
-path is /dev/ide/host0/bus0/target0/lun0/part1, ...
-
-July 18th 2001 - Yury Umanets <address@hidden>
-* updated swap_probe to avoid segfault.
-* updated _add_history_unique and _readline to avoid compiller warnings 
-that cause error when -Werror is turned on.
 
 July 13th 2001 - Andrew Clausen <address@hidden>
 * hacked /usr/share/aclocal/gettext.m4, replacing ac_given_srcdir with
Only in ./parted-1.5.3-pre1: ChangeLog.orig
Only in ./parted-1.5.3-pre1: ChangeLog.rej
Only in ./parted-1.5.3-pre1-old: Makefile
Only in ./parted-1.5.3-pre1-old: config.h
Only in ./parted-1.5.3-pre1-old: config.log
Only in ./parted-1.5.3-pre1-old: config.status
Only in ./parted-1.5.3-pre1-old/debug: Makefile
Only in ./parted-1.5.3-pre1-old/debug/clearfat: Makefile
Only in ./parted-1.5.3-pre1-old/debug/test: Makefile
diff -r --unified ./parted-1.5.3-pre1-old/doc/API ./parted-1.5.3-pre1/doc/API
--- ./parted-1.5.3-pre1-old/doc/API     Wed Jul 18 18:26:36 2001
+++ ./parted-1.5.3-pre1/doc/API Wed Jun 13 08:04:21 2001
@@ -556,7 +556,6 @@
        PedPartition*           prev;
        PedPartition*           next;
 
-       char*                   path;
        PedGeometry             geom;
        int                     num;
 
Only in ./parted-1.5.3-pre1-old/doc: Makefile
Only in ./parted-1.5.3-pre1-old/include: Makefile
Only in ./parted-1.5.3-pre1-old/include/parted: Makefile
diff -r --unified ./parted-1.5.3-pre1-old/include/parted/disk.h 
./parted-1.5.3-pre1/include/parted/disk.h
--- ./parted-1.5.3-pre1-old/include/parted/disk.h       Wed Jul 18 18:26:54 2001
+++ ./parted-1.5.3-pre1/include/parted/disk.h   Wed Jul 11 07:01:32 2001
@@ -63,7 +63,6 @@
        PedPartition*           prev;
        PedPartition*           next;
 
-       char*                   path;
        PedDisk*                disk;
        PedGeometry             geom;
        int                     num;
Only in ./parted-1.5.3-pre1-old/intl: Makefile
Only in ./parted-1.5.3-pre1-old/libparted: Makefile
diff -r --unified ./parted-1.5.3-pre1-old/libparted/device.c 
./parted-1.5.3-pre1/libparted/device.c
--- ./parted-1.5.3-pre1-old/libparted/device.c  Wed Jul 18 15:10:16 2001
+++ ./parted-1.5.3-pre1/libparted/device.c      Fri Jun 22 04:05:58 2001
@@ -23,9 +23,6 @@
 
 #include <string.h>
 #include <stdlib.h>
-#include <sys/stat.h>
-#include <limits.h>
-#include <unistd.h>
 
 static PedDevice*      devices = NULL;
 
@@ -69,26 +66,14 @@
 void
 _ped_device_probe (char* path)
 {
-       struct stat stat_buff;
+       PedDevice*      dev;
 
        PED_ASSERT (path != NULL, return);
 
        ped_exception_fetch_all ();
-       if (!lstat(path, &stat_buff)) {
-           if (S_ISLNK(stat_buff.st_mode)) {
-               char link_target[_POSIX_PATH_MAX + 1];
-               memset(link_target, 0, sizeof(link_target));
-               if (readlink(path, link_target, _POSIX_PATH_MAX)) {
-                   char real_path[_POSIX_PATH_MAX + 1];
-                   sprintf(real_path, "/dev/%s", link_target);
-                   if (!ped_device_get(real_path))
-                       ped_exception_catch ();
-               }           
-           } else {
-               if (!ped_device_get (path))
-                   ped_exception_catch ();
-           }
-       }
+       dev = ped_device_get (path);
+       if (!dev)
+               ped_exception_catch ();
        ped_exception_leave_all ();
 }
 
@@ -115,28 +100,15 @@
 ped_device_get (const char* path)
 {
        PedDevice*      walk;
-       struct stat     stat_buff;
-       char            walk_path[_POSIX_PATH_MAX + 1];
 
        PED_ASSERT (path != NULL, return NULL);
-       
-       strcpy(walk_path, path);
-       if (!lstat(path, &stat_buff)) {
-           if (S_ISLNK(stat_buff.st_mode)) {
-               char link_target[_POSIX_PATH_MAX + 1];
-               memset(link_target, 0, sizeof(link_target));
-               if (readlink(path, link_target, _POSIX_PATH_MAX))
-                   sprintf(walk_path, "/dev/%s", link_target);
-           }
-       }
-
 
        for (walk = devices; walk != NULL; walk = walk->next) {
-               if (!strcmp (walk->path, walk_path))
+               if (!strcmp (walk->path, path))
                        return walk;
        }
 
-       walk = _arch_device_new (walk_path);
+       walk = _arch_device_new (path);
        if (!walk)
                return NULL;
        _device_register (walk);
diff -r --unified ./parted-1.5.3-pre1-old/libparted/device_linux.c 
./parted-1.5.3-pre1/libparted/device_linux.c
--- ./parted-1.5.3-pre1-old/libparted/device_linux.c    Wed Jul 18 18:57:18 2001
+++ ./parted-1.5.3-pre1/libparted/device_linux.c        Fri Jun 22 04:04:53 2001
@@ -34,7 +34,6 @@
 #include <linux/hdreg.h>
 #include <linux/unistd.h>
 #include <scsi/scsi.h>
-#include <limits.h>
 
 #include <libintl.h>
 #if ENABLE_NLS
@@ -613,34 +612,29 @@
 _flush_cache (PedDevice* dev)
 {
        LinuxSpecific*  arch_specific = LINUX_SPECIFIC (dev);
-       int i;
-       char *last_slash;
+       int             i;
+       char*           name;
 
        if (dev->read_only)
                return;
 
        ioctl (arch_specific->fd, BLKFLSBUF);
 
-       last_slash = strrchr(dev->path, '/');
-       for (i = 1; i < 16; i++) {
-           int fd;
-           char path[_POSIX_PATH_MAX + 1];
-           memset(path, 0, sizeof(path));
-           
-           if (strcmp(last_slash + 1, "disc") == 0) {
-               char dev_path[_POSIX_PATH_MAX + 1];
-               memset(dev_path, 0, sizeof(dev_path));
-               
-               strncpy(dev_path, dev->path, (int)(last_slash - dev->path));
-               sprintf(path, "%s/part%d", dev_path, i);
-           } else
-               sprintf(path, "%s%d", dev->path, i);
-           fd = open (path, O_WRONLY, 0);
-           if (fd == -1)
-               continue;
-           ioctl (fd, BLKFLSBUF);
-           close (fd);
+       name = (char*) ped_malloc (strlen (dev->path) + 3);
+       if (!name)
+               return;
+
+       for (i = 0; i < 16; i++) {
+               int     fd;
+               sprintf (name, "%s%d", dev->path, i);
+               fd = open (name, O_WRONLY, 0);
+               if (fd == -1)
+                       continue;
+               ioctl (fd, BLKFLSBUF);
+               close (fd);
        }
+
+       ped_free (name);
 }
 
 int
diff -r --unified ./parted-1.5.3-pre1-old/libparted/disk.c 
./parted-1.5.3-pre1/libparted/disk.c
--- ./parted-1.5.3-pre1-old/libparted/disk.c    Wed Jul 18 18:54:24 2001
+++ ./parted-1.5.3-pre1/libparted/disk.c        Tue Jul 10 13:16:43 2001
@@ -33,7 +33,6 @@
 #include <errno.h>
 #include <string.h>
 #include <unistd.h>
-#include <limits.h>
 #include <sys/ioctl.h>
 #include <sys/stat.h>
 
@@ -47,7 +46,6 @@
                                   PedPartition* part);
 static int _disk_raw_remove (PedDisk* disk, PedPartition* part);
 static int _disk_raw_add (PedDisk* disk, PedPartition* part);
-static void _disk_update_partition_path(PedDisk *disk, PedPartition 
*partition);
 
 static PedDiskType*    disk_types = NULL;
 
@@ -124,34 +122,6 @@
        return walk;
 }
 
-static void
-_disk_update_partition_path(PedDisk *disk, PedPartition *partition)
-{
-    char *last_slash;
-    char partition_path[_POSIX_PATH_MAX + 1];
-    
-    if (!disk || !partition) return;
-    
-    last_slash = strrchr(disk->dev->path, '/');
-    if (!last_slash) return;
-    
-    memset(partition_path, 0, sizeof(partition_path));
-       
-    if (strcmp((char *)(last_slash + 1), "disc") == 0) {
-       /* Devfs specific stuff */
-       char dev_path[_POSIX_PATH_MAX + 1];
-       memset(dev_path, 0, sizeof(dev_path));
-           
-       strncpy(dev_path, disk->dev->path, (int)(last_slash - disk->dev->path));
-       sprintf(partition_path, "%s/part%d", dev_path, partition->num);
-    } else
-       /* Linux standard device stuff */
-       sprintf(partition_path, "%s%d", disk->dev->path, partition->num);
-    if (partition->path)
-        ped_free(partition->path);
-    partition->path = strdup(partition_path);
-}
-
 PedDisk*
 ped_disk_new (PedDevice* dev)
 {
@@ -783,7 +753,6 @@
        if (!part)
                goto error;
 
-       part->path = NULL;
        if (fs_type || part->type == PED_PARTITION_EXTENDED) {
                if (!ped_partition_set_system (part, fs_type))
                        goto error_destroy_part;
@@ -802,8 +771,7 @@
        PED_ASSERT (part != NULL, return);
        PED_ASSERT (part->disk != NULL, return);
        PED_ASSERT (part->disk->type->ops->partition_new != NULL, return);
-       if (part->path)
-           ped_free(part->path);
+
        part->disk->type->ops->partition_destroy (part);
 }
 
@@ -1014,11 +982,14 @@
 static int
 _partition_is_root_device (const PedPartition* part)
 {
+       char            part_name [256];
        unsigned int    root_dev;
        struct stat     part_stat;
        FILE*           proc_real_root_dev;
 
-       if (stat (part->path, &part_stat))
+       sprintf (part_name, "%s%d", part->disk->dev->path, part->num);
+
+       if (stat (part_name, &part_stat))
                goto error;
 
        proc_real_root_dev = fopen ("/proc/sys/kernel/real-root-dev", "r");
@@ -1085,6 +1056,7 @@
 static int
 _partition_is_mounted (const PedPartition* part)
 {
+       char            part_name [256];/* XXX: Allocate this dynamically */
        int             status;
 
        PED_ASSERT (part != NULL, return 0);
@@ -1092,16 +1064,18 @@
        if (part->num == -1)
                goto error;
 
+       sprintf (part_name, "%s%d", part->disk->dev->path, part->num);
+
 #ifdef linux
        if (_partition_is_root_device (part))
                return 1;
 
-       status = _check_mount_table_is_busy ("/proc/mounts", part->path);
+       status = _check_mount_table_is_busy ("/proc/mounts", part_name);
        if (status == 1)
                return 1;
 
        if (status != -1) {
-               status = _check_mount_table_is_busy ("/proc/swaps", part->path);
+               status = _check_mount_table_is_busy ("/proc/swaps", part_name);
                if (status != -1)
                        return status;
        }
@@ -1111,7 +1085,7 @@
        if (part->disk->dev->type == PED_DEVICE_FILE)
                return 0;
 
-       status = _check_mount_table_is_busy ("/etc/mtab", part->path);
+       status = _check_mount_table_is_busy ("/etc/mtab", part_name);
        if (status != -1)
                return status;
 
@@ -1551,7 +1525,6 @@
                goto error;
 
        _disk_pop_update_mode (disk);
-       _disk_update_partition_path(disk, part);
        if (!_disk_check_sanity (disk))
                return 0;
        return 1;
Only in ./parted-1.5.3-pre1-old/libparted/fs_ext2: Makefile
Only in ./parted-1.5.3-pre1-old/libparted/fs_fat: Makefile
Only in ./parted-1.5.3-pre1-old/libparted/fs_hfs: Makefile
Only in ./parted-1.5.3-pre1-old/libparted/fs_jfs: Makefile
Only in ./parted-1.5.3-pre1-old/libparted/fs_linux_swap: Makefile
diff -r --unified ./parted-1.5.3-pre1-old/libparted/fs_linux_swap/linux_swap.c 
./parted-1.5.3-pre1/libparted/fs_linux_swap/linux_swap.c
--- ./parted-1.5.3-pre1-old/libparted/fs_linux_swap/linux_swap.c        Wed Jul 
18 13:00:03 2001
+++ ./parted-1.5.3-pre1/libparted/fs_linux_swap/linux_swap.c    Thu Jul  5 
12:41:36 2001
@@ -128,7 +128,7 @@
        PedGeometry*    probed_geom;
        PedSector       length;
 
-       if (!(fs = swap_open (geom)))
+       if (!swap_open (geom))
                goto error;
        fs_info = SWAP_SPECIFIC (fs);
 
Only in ./parted-1.5.3-pre1-old/libparted/fs_ntfs: Makefile
Only in ./parted-1.5.3-pre1-old/libparted/fs_reiserfs: Makefile
Only in ./parted-1.5.3-pre1-old/libparted/fs_ufs: Makefile
Only in ./parted-1.5.3-pre1-old/libparted/fs_xfs: Makefile
Only in ./parted-1.5.3-pre1-old: libtool
Only in ./parted-1.5.3-pre1-old/parted: Makefile
diff -r --unified ./parted-1.5.3-pre1-old/parted/ui.c 
./parted-1.5.3-pre1/parted/ui.c
--- ./parted-1.5.3-pre1-old/parted/ui.c Wed Jul 18 13:00:03 2001
+++ ./parted-1.5.3-pre1/parted/ui.c     Tue Jul 10 00:24:44 2001
@@ -151,12 +151,8 @@
        HIST_ENTRY*     last_entry = current_history ();
        if (!strlen (line))
                return;
-       if (!last_entry || strcmp (last_entry->line, line)) {
-               char line_buffer[strlen(line) + 1];
-               memset(line_buffer, 0, sizeof(line_buffer));
-               strcpy(line_buffer, line);
-               add_history (line_buffer);
-       }       
+       if (!last_entry || strcmp (last_entry->line, line))
+               add_history (line);
 }
 #endif /* HAVE_LIBREADLINE */
 
@@ -179,9 +175,7 @@
 _readline (const char* prompt, const StrList* possibilities)
 {
        char*           line;
-#ifdef HAVE_LIBREADLINE
-       char            prompt_buffer[strlen(prompt) + 1];
-#endif
+
        readline_state.possibilities = possibilities;
        readline_state.cur_pos = NULL;
        readline_state.in_readline = 1;
@@ -190,9 +184,7 @@
                return NULL;
 
 #ifdef HAVE_LIBREADLINE
-       memset(prompt_buffer, 0, sizeof(prompt_buffer));
-       strcpy(prompt_buffer, prompt);
-       line = readline (prompt_buffer);
+       line = readline (prompt);
        if (line)
                _add_history_unique (line);
 #else
Only in ./parted-1.5.3-pre1-old/po: Makefile
Only in ./parted-1.5.3-pre1-old/po: Makefile.in
Only in ./parted-1.5.3-pre1-old: stamp-h

reply via email to

[Prev in Thread] Current Thread [Next in Thread]