diff --git a/NEWS b/NEWS index 1a51559d6..fad692d78 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,8 @@ +Current + +- Core functionality + - Device numbers are displayed correctly. + Version 4.6.1-pre2. Release candidate for 4.6.1. diff --git a/src/ChangeLog b/src/ChangeLog index 093dc3a46..b47394ccd 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,14 @@ +2005-01-17 Roland Illig + + * info.c (info_show_info): Enabled display of the device number, + for the case that the column in the directory listing is too + short. This had been disabled since 1994, for no obvious reason + and without any comment. + * screen.c (format_device_number): Added. Converts a device number + into a bounded string. + * screen.c (string_file_size): Support for larger device numbers + (and for non-Linux systems). + 2005-01-26 Roland Illig * tty.h (printwstr): Added a function to print a string diff --git a/src/info.c b/src/info.c index d11c17000..1f10f6efe 100644 --- a/src/info.c +++ b/src/info.c @@ -34,6 +34,7 @@ #include "layout.h" #include "key.h" /* is_idle() */ #include "mountlist.h" +#include "unixcompat.h" #ifndef VERSION # define VERSION "undefined" @@ -149,13 +150,12 @@ info_show_info (struct WInfo *info) case 8: widget_move (&info->widget, 8, 3); -#if 0 #ifdef HAVE_STRUCT_STAT_ST_RDEV - if (st.st_rdev) - printw ("Inode dev: major: %d, minor: %d", - st.st_rdev >> 8, st.st_rdev & 0xff); + if (S_ISCHR (st.st_mode) || S_ISBLK(st.st_mode)) + printw ("Inode dev: major: %lu, minor: %lu", + (unsigned long) major (st.st_rdev), + (unsigned long) minor (st.st_rdev)); else -#endif #endif { char buffer[10]; diff --git a/src/screen.c b/src/screen.c index ea698ce7b..a32f8bbe4 100644 --- a/src/screen.c +++ b/src/screen.c @@ -47,6 +47,7 @@ #include "menu.h" /* menubar_visible */ #define WANT_WIDGETS #include "main.h" /* the_menubar */ +#include "unixcompat.h" #define ELEMENTS(arr) ( sizeof(arr) / sizeof((arr)[0]) ) @@ -190,6 +191,31 @@ string_file_name (file_entry *fe, int len) return buffer; } +static inline int ilog10(dev_t n) +{ + int digits = 0; + do { + digits++, n /= 10; + } while (n != 0); + return digits; +} + +static void format_device_number (char *buf, size_t bufsize, dev_t dev) +{ + dev_t major_dev = major(dev); + dev_t minor_dev = minor(dev); + int major_digits = ilog10(major_dev); + int minor_digits = ilog10(minor_dev); + + g_assert(bufsize >= 1); + if (major_digits + 1 + minor_digits + 1 <= bufsize) { + g_snprintf(buf, bufsize, "%lu,%lu", (unsigned long) major_dev, + (unsigned long) minor_dev); + } else { + g_strlcpy(buf, _("[dev]"), bufsize); + } +} + /* size */ static const char * string_file_size (file_entry *fe, int len) @@ -203,9 +229,7 @@ string_file_size (file_entry *fe, int len) #ifdef HAVE_STRUCT_STAT_ST_RDEV if (S_ISBLK (fe->st.st_mode) || S_ISCHR (fe->st.st_mode)) - g_snprintf (buffer, sizeof (buffer), "%3d,%3d", - (int) ((fe->st.st_rdev >> 8) & 0xff), - (int) (fe->st.st_rdev & 0xff)); + format_device_number (buffer, len + 1, fe->st.st_rdev); else #endif { diff --git a/vfs/ChangeLog b/vfs/ChangeLog index 80072539a..f5747fd4e 100644 --- a/vfs/ChangeLog +++ b/vfs/ChangeLog @@ -1,3 +1,10 @@ +2005-01-27 Roland Illig + + * cpio.c (cpio_read_crc_head): Fixed device number handling for + non-Linux systems. + * fish.c (fish_dir_load): Likewise. + * utilvfs.c (vfs_parse_ls_lga): Likewise. + 2005-01-25 Andrew V. Samoilov * samba/Makefile.in: Remove BINDIR and SBINDIR. diff --git a/vfs/cpio.c b/vfs/cpio.c index e0381e72d..1f998251f 100644 --- a/vfs/cpio.c +++ b/vfs/cpio.c @@ -23,6 +23,7 @@ #include "vfs-impl.h" #include "gc.h" /* vfs_rmstamp */ #include "xdirentry.h" +#include "../src/unixcompat.h" enum { STATUS_START, @@ -415,13 +416,13 @@ static int cpio_read_crc_head(struct vfs_class *me, struct vfs_s_super *super) return STATUS_TRAIL; } - u.st.st_dev = (hd.c_dev << 8) + hd.c_devmin; + u.st.st_dev = makedev (hd.c_dev, hd.c_devmin); u.st.st_ino = hd.c_ino; u.st.st_mode = hd.c_mode; u.st.st_nlink = hd.c_nlink; u.st.st_uid = hd.c_uid; u.st.st_gid = hd.c_gid; - u.st.st_rdev = (hd.c_rdev << 8) + hd.c_rdevmin; + u.st.st_rdev = makedev (hd.c_rdev, hd.c_rdevmin); u.st.st_size = hd.c_filesize; u.st.st_atime = u.st.st_mtime = u.st.st_ctime = hd.c_mtime; diff --git a/vfs/fish.c b/vfs/fish.c index 4fe360743..83ad70917 100644 --- a/vfs/fish.c +++ b/vfs/fish.c @@ -46,6 +46,7 @@ #include "vfs-impl.h" #include "gc.h" /* vfs_stamp_create */ #include "tcputil.h" +#include "../src/unixcompat.h" #define FISH_DIRECTORY_TIMEOUT 30 * 60 @@ -461,7 +462,7 @@ fish_dir_load(struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path) if (sscanf(buffer+1, "%d,%d", &maj, &min) != 2) break; #ifdef HAVE_STRUCT_STAT_ST_RDEV - ST.st_rdev = (maj << 8) | min; + ST.st_rdev = makedev (maj, min); #endif } case 'L': ent->ino->linkname = g_strdup(buffer+1); diff --git a/vfs/utilvfs.c b/vfs/utilvfs.c index d1baf3678..227c1df32 100644 --- a/vfs/utilvfs.c +++ b/vfs/utilvfs.c @@ -22,6 +22,7 @@ #include "utilvfs.h" #include "vfs.h" +#include "../src/unixcompat.h" /* Extract the hostname and username from the path */ /* path is in the form: [user@]hostname:port/remote-dir, e.g.: @@ -763,7 +764,7 @@ vfs_parse_ls_lga (const char *p, struct stat *s, char **filename, goto error; } #ifdef HAVE_STRUCT_STAT_ST_RDEV - s->st_rdev = ((maj & 0xff) << 8) | (min & 0xffff00ff); + s->st_rdev = makedev (maj, min); #endif s->st_size = 0;