* extfs.c (open_archive): Use open_error_pipe() and close_error_pipe()
to prevent stderr from extfs scripts pollute the screen. (extfs_cmd): New function to run extfs scripts and handle stderr in one place. (extfs_open): Use extfs_cmd(). (extfs_close): Likewise. (extfs_unlink): Likewise. (extfs_mkdir): Likewise. (extfs_rmdir): Likewise.
Этот коммит содержится в:
родитель
30503bef51
Коммит
474ff43316
@ -1,3 +1,15 @@
|
|||||||
|
2002-12-01 Andrew V. Samoilov <sav@bcs.zp.ua>
|
||||||
|
|
||||||
|
* extfs.c (open_archive): Use open_error_pipe() and close_error_pipe()
|
||||||
|
to prevent stderr from extfs scripts pollute the screen.
|
||||||
|
(extfs_cmd): New function to run extfs scripts and handle stderr in one
|
||||||
|
place.
|
||||||
|
(extfs_open): Use extfs_cmd().
|
||||||
|
(extfs_close): Likewise.
|
||||||
|
(extfs_unlink): Likewise.
|
||||||
|
(extfs_mkdir): Likewise.
|
||||||
|
(extfs_rmdir): Likewise.
|
||||||
|
|
||||||
2002-12-01 Pavel Roskin <proski@gnu.org>
|
2002-12-01 Pavel Roskin <proski@gnu.org>
|
||||||
|
|
||||||
* extfs/Makefile.am: Add uzip to EXTFS_OUT.
|
* extfs/Makefile.am: Add uzip to EXTFS_OUT.
|
||||||
|
142
vfs/extfs.c
142
vfs/extfs.c
@ -229,7 +229,9 @@ static FILE *open_archive (int fstype, char *name, struct archive **pparc)
|
|||||||
if (tmp)
|
if (tmp)
|
||||||
g_free (tmp);
|
g_free (tmp);
|
||||||
g_free (mc_extfsdir);
|
g_free (mc_extfsdir);
|
||||||
|
open_error_pipe ();
|
||||||
result = popen (cmd, "r");
|
result = popen (cmd, "r");
|
||||||
|
close_error_pipe (1, NULL);
|
||||||
g_free (cmd);
|
g_free (cmd);
|
||||||
if (result == NULL) {
|
if (result == NULL) {
|
||||||
if (local_name != NULL && uses_archive)
|
if (local_name != NULL && uses_archive)
|
||||||
@ -563,6 +565,38 @@ static char *get_archive_name (struct archive *archive)
|
|||||||
return archive_name;
|
return archive_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Don't pass localname as NULL */
|
||||||
|
static int
|
||||||
|
extfs_cmd (const char *extfs_cmd, struct archive *archive,
|
||||||
|
struct entry *entry, const char *localname)
|
||||||
|
{
|
||||||
|
char *file;
|
||||||
|
char *quoted_file;
|
||||||
|
char *archive_name;
|
||||||
|
char *mc_extfsdir;
|
||||||
|
char *cmd;
|
||||||
|
int retval;
|
||||||
|
|
||||||
|
file = get_path_from_entry (entry);
|
||||||
|
quoted_file = name_quote (file, 0);
|
||||||
|
g_free (file);
|
||||||
|
archive_name = name_quote (get_archive_name (archive), 0);
|
||||||
|
|
||||||
|
mc_extfsdir = concat_dir_and_file (mc_home, "extfs" PATH_SEP_STR);
|
||||||
|
cmd = g_strconcat (mc_extfsdir, extfs_prefixes[archive->fstype],
|
||||||
|
extfs_cmd, archive_name, " ", quoted_file, " ",
|
||||||
|
localname, NULL);
|
||||||
|
g_free (quoted_file);
|
||||||
|
g_free (mc_extfsdir);
|
||||||
|
g_free (archive_name);
|
||||||
|
|
||||||
|
open_error_pipe ();
|
||||||
|
retval = my_system (EXECUTE_AS_SHELL, shell, cmd);
|
||||||
|
g_free (cmd);
|
||||||
|
close_error_pipe (1, NULL);
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
static void extfs_run (char *file)
|
static void extfs_run (char *file)
|
||||||
{
|
{
|
||||||
struct archive *archive;
|
struct archive *archive;
|
||||||
@ -590,7 +624,6 @@ static void *extfs_open (vfs *me, char *file, int flags, int mode)
|
|||||||
struct pseudofile *extfs_info;
|
struct pseudofile *extfs_info;
|
||||||
struct archive *archive;
|
struct archive *archive;
|
||||||
char *q;
|
char *q;
|
||||||
char *mc_extfsdir;
|
|
||||||
struct entry *entry;
|
struct entry *entry;
|
||||||
int local_handle;
|
int local_handle;
|
||||||
int created = 0;
|
int created = 0;
|
||||||
@ -607,40 +640,26 @@ static void *extfs_open (vfs *me, char *file, int flags, int mode)
|
|||||||
return NULL;
|
return NULL;
|
||||||
if ((entry = my_resolve_symlinks (entry)) == NULL)
|
if ((entry = my_resolve_symlinks (entry)) == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (S_ISDIR (entry->inode->mode)) ERRNOR (EISDIR, NULL);
|
|
||||||
if (entry->inode->local_filename == NULL) {
|
|
||||||
char *cmd;
|
|
||||||
char *archive_name, *p;
|
|
||||||
|
|
||||||
{
|
if (S_ISDIR (entry->inode->mode)) ERRNOR (EISDIR, NULL);
|
||||||
|
|
||||||
|
if (entry->inode->local_filename == NULL) {
|
||||||
|
|
||||||
int handle;
|
int handle;
|
||||||
handle = mc_mkstemps (&entry->inode->local_filename, "extfs", NULL);
|
handle = mc_mkstemps (&entry->inode->local_filename, "extfs", NULL);
|
||||||
|
|
||||||
if (handle == -1)
|
if (handle == -1)
|
||||||
return NULL;
|
return NULL;
|
||||||
close (handle);
|
close (handle);
|
||||||
}
|
|
||||||
p = get_path_from_entry (entry);
|
|
||||||
q = name_quote (p, 0);
|
|
||||||
g_free (p);
|
|
||||||
archive_name = name_quote (get_archive_name (archive), 0);
|
|
||||||
|
|
||||||
mc_extfsdir = concat_dir_and_file (mc_home, "extfs/");
|
if (extfs_cmd
|
||||||
cmd = g_strconcat (mc_extfsdir, extfs_prefixes [archive->fstype],
|
(" copyout ", archive, entry, entry->inode->local_filename)
|
||||||
" copyout ",
|
&& !created) {
|
||||||
archive_name,
|
|
||||||
" ", q, " ", entry->inode->local_filename, NULL);
|
|
||||||
g_free (q);
|
|
||||||
g_free (mc_extfsdir);
|
|
||||||
g_free (archive_name);
|
|
||||||
if (my_system (EXECUTE_AS_SHELL, shell, cmd) && !created){
|
|
||||||
free (entry->inode->local_filename);
|
free (entry->inode->local_filename);
|
||||||
entry->inode->local_filename = NULL;
|
entry->inode->local_filename = NULL;
|
||||||
g_free (cmd);
|
|
||||||
my_errno = EIO;
|
my_errno = EIO;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
g_free (cmd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
local_handle = open (entry->inode->local_filename, NO_LINEAR(flags),
|
local_handle = open (entry->inode->local_filename, NO_LINEAR(flags),
|
||||||
@ -676,30 +695,9 @@ static int extfs_close (void *data)
|
|||||||
|
|
||||||
/* Commit the file if it has changed */
|
/* Commit the file if it has changed */
|
||||||
if (file->has_changed) {
|
if (file->has_changed) {
|
||||||
struct archive *archive;
|
if (extfs_cmd (" copyin ", file->archive, file->entry,
|
||||||
char *archive_name, *file_name;
|
file->entry->inode->local_filename))
|
||||||
char *cmd;
|
|
||||||
char *mc_extfsdir;
|
|
||||||
char *p;
|
|
||||||
|
|
||||||
archive = file->archive;
|
|
||||||
archive_name = name_quote (get_archive_name (archive), 0);
|
|
||||||
p = get_path_from_entry (file->entry);
|
|
||||||
file_name = name_quote (p, 0);
|
|
||||||
g_free (p);
|
|
||||||
|
|
||||||
mc_extfsdir = concat_dir_and_file (mc_home, "extfs/");
|
|
||||||
cmd = g_strconcat (mc_extfsdir,
|
|
||||||
extfs_prefixes [archive->fstype],
|
|
||||||
" copyin ", archive_name, " ",
|
|
||||||
file_name, " ",
|
|
||||||
file->entry->inode->local_filename, NULL);
|
|
||||||
g_free (archive_name);
|
|
||||||
g_free (file_name);
|
|
||||||
g_free (mc_extfsdir);
|
|
||||||
if (my_system (EXECUTE_AS_SHELL, shell, cmd))
|
|
||||||
errno_code = EIO;
|
errno_code = EIO;
|
||||||
g_free (cmd);
|
|
||||||
{
|
{
|
||||||
struct stat file_status;
|
struct stat file_status;
|
||||||
if (stat (file->entry->inode->local_filename, &file_status) != 0)
|
if (stat (file->entry->inode->local_filename, &file_status) != 0)
|
||||||
@ -1012,10 +1010,7 @@ static int extfs_unlink (vfs *me, char *file)
|
|||||||
{
|
{
|
||||||
struct archive *archive;
|
struct archive *archive;
|
||||||
char *q;
|
char *q;
|
||||||
char *mc_extfsdir;
|
|
||||||
struct entry *entry;
|
struct entry *entry;
|
||||||
char *cmd;
|
|
||||||
char *archive_name, *p;
|
|
||||||
|
|
||||||
if ((q = get_path_mangle (file, &archive, 0, 0)) == NULL)
|
if ((q = get_path_mangle (file, &archive, 0, 0)) == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
@ -1026,23 +1021,10 @@ static int extfs_unlink (vfs *me, char *file)
|
|||||||
return -1;
|
return -1;
|
||||||
if (S_ISDIR (entry->inode->mode)) ERRNOR (EISDIR, -1);
|
if (S_ISDIR (entry->inode->mode)) ERRNOR (EISDIR, -1);
|
||||||
|
|
||||||
p = get_path_from_entry (entry);
|
if (extfs_cmd (" rm ", archive, entry, "")){
|
||||||
q = name_quote (p, 0);
|
|
||||||
g_free (p);
|
|
||||||
archive_name = name_quote (get_archive_name (archive), 0);
|
|
||||||
|
|
||||||
mc_extfsdir = concat_dir_and_file (mc_home, "extfs/");
|
|
||||||
cmd = g_strconcat (mc_extfsdir, extfs_prefixes [archive->fstype],
|
|
||||||
" rm ", archive_name, " ", q, NULL);
|
|
||||||
g_free (q);
|
|
||||||
g_free (mc_extfsdir);
|
|
||||||
g_free (archive_name);
|
|
||||||
if (my_system (EXECUTE_AS_SHELL, shell, cmd)){
|
|
||||||
g_free (cmd);
|
|
||||||
my_errno = EIO;
|
my_errno = EIO;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
g_free (cmd);
|
|
||||||
remove_entry (entry);
|
remove_entry (entry);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -1052,10 +1034,7 @@ static int extfs_mkdir (vfs *me, char *path, mode_t mode)
|
|||||||
{
|
{
|
||||||
struct archive *archive;
|
struct archive *archive;
|
||||||
char *q;
|
char *q;
|
||||||
char *mc_extfsdir;
|
|
||||||
struct entry *entry;
|
struct entry *entry;
|
||||||
char *cmd;
|
|
||||||
char *archive_name, *p;
|
|
||||||
|
|
||||||
if ((q = get_path_mangle (path, &archive, 0, 0)) == NULL)
|
if ((q = get_path_mangle (path, &archive, 0, 0)) == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
@ -1068,24 +1047,11 @@ static int extfs_mkdir (vfs *me, char *path, mode_t mode)
|
|||||||
return -1;
|
return -1;
|
||||||
if (!S_ISDIR (entry->inode->mode)) ERRNOR (ENOTDIR, -1);
|
if (!S_ISDIR (entry->inode->mode)) ERRNOR (ENOTDIR, -1);
|
||||||
|
|
||||||
p = get_path_from_entry (entry);
|
if (extfs_cmd (" mkdir ", archive, entry, "")){
|
||||||
q = name_quote (p, 0);
|
|
||||||
g_free (p);
|
|
||||||
archive_name = name_quote (get_archive_name (archive), 0);
|
|
||||||
|
|
||||||
mc_extfsdir = concat_dir_and_file (mc_home, "extfs/");
|
|
||||||
cmd = g_strconcat (mc_extfsdir, extfs_prefixes [archive->fstype],
|
|
||||||
" mkdir ", archive_name, " ", q, NULL);
|
|
||||||
g_free (q);
|
|
||||||
g_free (mc_extfsdir);
|
|
||||||
g_free (archive_name);
|
|
||||||
if (my_system (EXECUTE_AS_SHELL, shell, cmd)){
|
|
||||||
g_free (cmd);
|
|
||||||
my_errno = EIO;
|
my_errno = EIO;
|
||||||
remove_entry (entry);
|
remove_entry (entry);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
g_free (cmd);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1094,10 +1060,7 @@ static int extfs_rmdir (vfs *me, char *path)
|
|||||||
{
|
{
|
||||||
struct archive *archive;
|
struct archive *archive;
|
||||||
char *q;
|
char *q;
|
||||||
char *mc_extfsdir;
|
|
||||||
struct entry *entry;
|
struct entry *entry;
|
||||||
char *cmd;
|
|
||||||
char *archive_name, *p;
|
|
||||||
|
|
||||||
if ((q = get_path_mangle (path, &archive, 0, 0)) == NULL)
|
if ((q = get_path_mangle (path, &archive, 0, 0)) == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
@ -1108,23 +1071,10 @@ static int extfs_rmdir (vfs *me, char *path)
|
|||||||
return -1;
|
return -1;
|
||||||
if (!S_ISDIR (entry->inode->mode)) ERRNOR (ENOTDIR, -1);
|
if (!S_ISDIR (entry->inode->mode)) ERRNOR (ENOTDIR, -1);
|
||||||
|
|
||||||
p = get_path_from_entry (entry);
|
if (extfs_cmd (" rmdir ", archive, entry, "")){
|
||||||
q = name_quote (p, 0);
|
|
||||||
g_free (p);
|
|
||||||
archive_name = name_quote (get_archive_name (archive), 0);
|
|
||||||
|
|
||||||
mc_extfsdir = concat_dir_and_file (mc_home, "extfs/");
|
|
||||||
cmd = g_strconcat (mc_extfsdir, extfs_prefixes [archive->fstype],
|
|
||||||
" rmdir ", archive_name, " ", q, NULL);
|
|
||||||
g_free (q);
|
|
||||||
g_free (mc_extfsdir);
|
|
||||||
g_free (archive_name);
|
|
||||||
if (my_system (EXECUTE_AS_SHELL, shell, cmd)){
|
|
||||||
g_free (cmd);
|
|
||||||
my_errno = EIO;
|
my_errno = EIO;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
g_free (cmd);
|
|
||||||
remove_entry (entry);
|
remove_entry (entry);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user