1999-03-08 Miguel de Icaza <miguel@nuclecu.unam.mx>
* gutil.c (my_system_get_child_pid): reset SIGPIPE to a sensible value. (my_system_get_child_pid): Close also stdin/stdout/stderr * gdesktop.c (is_mountable): Allow user-nfs devices to be mounted
Этот коммит содержится в:
родитель
66293f72cd
Коммит
83818189e0
@ -5,7 +5,7 @@ AC_INIT(create_vcs)
|
||||
AC_CONFIG_HEADER(config.h)
|
||||
|
||||
PACKAGE=mc
|
||||
VERSION=4.5.23
|
||||
VERSION=4.5.24
|
||||
AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
|
||||
AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
|
||||
AC_SUBST(VERSION)
|
||||
|
@ -1,3 +1,10 @@
|
||||
1999-03-08 Miguel de Icaza <miguel@nuclecu.unam.mx>
|
||||
|
||||
* gutil.c (my_system_get_child_pid): reset SIGPIPE to a sensible
|
||||
value.
|
||||
(my_system_get_child_pid): Close also stdin/stdout/stderr
|
||||
|
||||
* gdesktop.c (is_mountable): Allow user-nfs devices to be mounted
|
||||
1999-03-08 Federico Mena Quintero <federico@nuclecu.unam.mx>
|
||||
|
||||
* gscreen.c (can_drop_on_clist): New function to figure out if the
|
||||
|
@ -922,18 +922,11 @@ is_mountable (char *filename, file_entry *fe, int *is_mounted, char **point)
|
||||
if (!S_ISLNK (fe->buf.st_mode))
|
||||
return FALSE;
|
||||
|
||||
if (stat (filename, &s) == -1)
|
||||
return FALSE;
|
||||
mode = s.st_mode;
|
||||
|
||||
if (!S_ISBLK (mode))
|
||||
return FALSE;
|
||||
|
||||
len = readlink (filename, buffer, sizeof (buffer));
|
||||
if (len == -1)
|
||||
return FALSE;
|
||||
buffer [len] = 0;
|
||||
|
||||
buffer [len] = 0;
|
||||
|
||||
p = is_block_device_mountable (buffer);
|
||||
if (!p)
|
||||
return FALSE;
|
||||
@ -1006,6 +999,20 @@ static char *eject_known_locations [] = {
|
||||
gboolean
|
||||
is_ejectable (char *filename)
|
||||
{
|
||||
char *buf;
|
||||
int size, retval;
|
||||
|
||||
if (gnome_metadata_get (filename, "device-is-ejectable", &size, &buf) == 0){
|
||||
if (*buf)
|
||||
retval = TRUE;
|
||||
else
|
||||
retval = FALSE;
|
||||
g_free (buf);
|
||||
|
||||
if (retval)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (find_command (eject_known_locations))
|
||||
return TRUE;
|
||||
else
|
||||
|
@ -96,11 +96,13 @@ void free (void *ptr);
|
||||
|
||||
typedef struct {
|
||||
char *devname;
|
||||
|
||||
char *mount_point;
|
||||
|
||||
/* This is just a good guess */
|
||||
enum {
|
||||
TYPE_UNKNOWN,
|
||||
TYPE_CDROM
|
||||
TYPE_CDROM,
|
||||
TYPE_NFS
|
||||
} type;
|
||||
} devname_info_t;
|
||||
|
||||
@ -126,7 +128,7 @@ option_has_user (char *str)
|
||||
* g_strdup()ed string with the mount point
|
||||
*/
|
||||
char *
|
||||
is_block_device_mountable (char *devname)
|
||||
is_block_device_mountable (char *mount_point)
|
||||
{
|
||||
FILE *f;
|
||||
struct mntent *mnt;
|
||||
@ -140,8 +142,15 @@ is_block_device_mountable (char *devname)
|
||||
return NULL;
|
||||
|
||||
while ((mnt = getmntent (f))){
|
||||
if (strcmp (mnt->mnt_fsname, devname) != 0)
|
||||
continue;
|
||||
if (strcmp (mnt->mnt_dir, mount_point) != 0){
|
||||
|
||||
/*
|
||||
* This second test is for compatibility with older
|
||||
* desktops that might be using this
|
||||
*/
|
||||
if (strcmp (mnt->mnt_dir, mount_point) != 0)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (option_has_user (mnt->mnt_opts)){
|
||||
retval = g_strdup (mnt->mnt_dir);
|
||||
@ -164,7 +173,7 @@ is_block_device_mounted (char *filename)
|
||||
return FALSE;
|
||||
|
||||
while ((mnt = getmntent (f))){
|
||||
if (strcmp (mnt->mnt_fsname, filename) == 0)
|
||||
if (strcmp (mnt->mnt_dir, filename) == 0)
|
||||
retval = TRUE;
|
||||
}
|
||||
endmntent (f);
|
||||
@ -188,10 +197,14 @@ get_mountable_devices (void)
|
||||
|
||||
dit = g_new0 (devname_info_t, 1);
|
||||
dit->devname = g_strdup (mnt->mnt_fsname);
|
||||
dit->mount_point = g_strdup (mnt->mnt_dir);
|
||||
dit->type = TYPE_UNKNOWN;
|
||||
|
||||
if (strcmp (mnt->mnt_type, "iso9660") == 0)
|
||||
dit->type = TYPE_CDROM;
|
||||
|
||||
if (strcmp (mnt->mnt_type, "nfs") == 0)
|
||||
dit->type = TYPE_NFS;
|
||||
|
||||
list = g_list_prepend (list, dit);
|
||||
}
|
||||
@ -203,7 +216,7 @@ get_mountable_devices (void)
|
||||
#else
|
||||
|
||||
char *
|
||||
is_block_device_mountable (char *devname)
|
||||
is_block_device_mountable (char *mount_point)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@ -215,7 +228,7 @@ get_mountable_devices (void)
|
||||
}
|
||||
|
||||
gboolean
|
||||
is_block_device_mounted (char *devname)
|
||||
is_block_device_mounted (char *mount_point)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@ -261,12 +274,13 @@ desktop_cleanup_devices (void)
|
||||
|
||||
/* Creates the desktop link for the specified device */
|
||||
static void
|
||||
create_device_link (char *dev_name, char *short_dev_name, char *caption, char *icon)
|
||||
create_device_link (char *dev_name, char *short_dev_name, char *caption, char *icon, gboolean ejectable)
|
||||
{
|
||||
char *full_name;
|
||||
char *icon_full;
|
||||
char type = 'D';
|
||||
|
||||
char ejectable_c = ejectable;
|
||||
|
||||
icon_full = g_concat_dir_and_file (ICONDIR, icon);
|
||||
full_name = g_concat_dir_and_file (desktop_directory, short_dev_name);
|
||||
if (mc_symlink (dev_name, full_name) != 0) {
|
||||
@ -280,6 +294,7 @@ create_device_link (char *dev_name, char *short_dev_name, char *caption, char *i
|
||||
|
||||
gnome_metadata_set (full_name, "icon-filename", strlen (icon_full) + 1, icon_full);
|
||||
gnome_metadata_set (full_name, "icon-caption", strlen (caption) + 1, caption);
|
||||
gnome_metadata_set (full_name, "device-is-ejectable", 1, &ejectable_c);
|
||||
gnome_metadata_set (full_name, "is-desktop-device", 1, &type); /* hack a boolean value */
|
||||
|
||||
g_free (full_name);
|
||||
@ -295,7 +310,8 @@ setup_devices (void)
|
||||
int hd_count;
|
||||
int cdrom_count;
|
||||
int generic_count;
|
||||
|
||||
int nfs_count;
|
||||
|
||||
list = get_mountable_devices ();
|
||||
|
||||
hd_count = 0;
|
||||
@ -311,19 +327,27 @@ setup_devices (void)
|
||||
char *icon;
|
||||
int count;
|
||||
char buffer[128];
|
||||
gboolean release_format;
|
||||
gboolean ejectable;
|
||||
|
||||
|
||||
dev_name = dit->devname;
|
||||
short_dev_name = x_basename (dev_name);
|
||||
|
||||
release_format = FALSE;
|
||||
ejectable = FALSE;
|
||||
|
||||
/* Create the format/icon/count. This could use better heuristics. */
|
||||
if (dit->type == TYPE_CDROM){
|
||||
format = _("CD-ROM %d");
|
||||
icon = "i-cdrom.png";
|
||||
count = cdrom_count++;
|
||||
ejectable = TRUE;
|
||||
} else if (strncmp (short_dev_name, "fd", 2) == 0) {
|
||||
format = _("Floppy %d");
|
||||
icon = "i-floppy.png";
|
||||
count = floppy_count++;
|
||||
ejectable = TRUE;
|
||||
} else if (strncmp (short_dev_name, "hd", 2) == 0
|
||||
|| strncmp (short_dev_name, "sd", 2) == 0) {
|
||||
format = _("Disk %d");
|
||||
@ -333,6 +357,12 @@ setup_devices (void)
|
||||
format = _("CD-ROM %d");
|
||||
icon = "i-cdrom.png";
|
||||
count = cdrom_count++;
|
||||
ejectable = TRUE;
|
||||
} else if (dit->type == TYPE_NFS){
|
||||
release_format = TRUE;
|
||||
format = g_strdup_printf (_("NFS dir %s"), dit->mount_point);
|
||||
icon = "i-blockdev.png";
|
||||
count = nfs_count++;
|
||||
} else {
|
||||
format = _("Device %d");
|
||||
icon = "i-blockdev.png";
|
||||
@ -340,13 +370,19 @@ setup_devices (void)
|
||||
}
|
||||
|
||||
g_snprintf (buffer, sizeof (buffer), format, count);
|
||||
if (release_format){
|
||||
g_free (format);
|
||||
format = NULL;
|
||||
}
|
||||
|
||||
/* Create the actual link */
|
||||
|
||||
create_device_link (dev_name, short_dev_name, buffer, icon);
|
||||
create_device_link (dit->mount_point, short_dev_name, buffer, icon, ejectable);
|
||||
|
||||
g_free (dit->devname);
|
||||
g_free (dit->mount_point);
|
||||
g_free (dit);
|
||||
|
||||
}
|
||||
|
||||
g_list_free (list);
|
||||
|
@ -407,13 +407,18 @@ create_actions (GtkWidget *menu, WPanel *panel,
|
||||
if (fe){
|
||||
v = is_mountable (fullname, fe, &is_mounted, NULL);
|
||||
file_entry_free (fe);
|
||||
|
||||
if (!v){
|
||||
g_free (fullname);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!is_ejectable (fullname)){
|
||||
g_free (fullname);
|
||||
continue;
|
||||
}
|
||||
g_free (fullname);
|
||||
|
||||
if (!v)
|
||||
continue;
|
||||
|
||||
if (!is_ejectable (fullname))
|
||||
continue;
|
||||
} else {
|
||||
g_free (fullname);
|
||||
continue;
|
||||
|
@ -137,12 +137,34 @@ int my_system_get_child_pid (int flags, const char *shell, const char *command,
|
||||
}
|
||||
if (*pid == 0){
|
||||
const int top = max_open_files ();
|
||||
struct sigaction default_pipe;
|
||||
|
||||
sigaction (SIGINT, &save_intr, NULL);
|
||||
sigaction (SIGQUIT, &save_quit, NULL);
|
||||
|
||||
for (i = 3; i < top; i++)
|
||||
/*
|
||||
* reset sigpipe
|
||||
*/
|
||||
default_pipe.sa_handler = SIG_DFL;
|
||||
sigemptyset (&default_pipe.sa_mask);
|
||||
default_pipe.sa_flags = 0;
|
||||
|
||||
sigaction (SIGPIPE, &default_pipe, NULL);
|
||||
|
||||
for (i = 0; i < top; i++)
|
||||
close (i);
|
||||
|
||||
/* Setup the file descriptor for the child */
|
||||
|
||||
/* stdin */
|
||||
open ("/dev/null");
|
||||
|
||||
/* stdout */
|
||||
open ("/dev/null");
|
||||
|
||||
/* stderr */
|
||||
open ("/dev/null");
|
||||
|
||||
if (!(flags & EXECUTE_WAIT))
|
||||
*pid = fork ();
|
||||
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user