From 65d8b20d052d229fe670ce04e094889c7227e8b4 Mon Sep 17 00:00:00 2001 From: condret Date: Wed, 8 Oct 2014 13:27:33 +0200 Subject: [PATCH] RCoreFile-reduction: kill RCoreFile->rwx --- libr/core/cmd_info.c | 16 +++++++++------- libr/core/file.c | 4 +--- libr/core/visual.c | 4 ++-- libr/include/r_core.h | 1 - 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/libr/core/cmd_info.c b/libr/core/cmd_info.c index d27c84d7fa..dc018cd0a5 100644 --- a/libr/core/cmd_info.c +++ b/libr/core/cmd_info.c @@ -44,11 +44,12 @@ static void r_core_file_info (RCore *core, int mode) { if (cf && mode == R_CORE_BIN_JSON) { r_cons_printf ("\"file\":\"%s\"", fn); if (dbg) dbg = R_IO_WRITE | R_IO_EXEC; - if (cf->desc) + if (cf->desc) { r_cons_printf (",\"fd\":%d", cf->desc->fd); - r_cons_printf (",\"size\":%"PFMT64d, r_io_desc_size (core->io, cf->desc)); - r_cons_printf (",\"mode\":\"%s\"", r_str_rwx_i ( - cf->rwx | dbg)); + r_cons_printf (",\"size\":%"PFMT64d, r_io_desc_size (core->io, cf->desc)); + r_cons_printf (",\"mode\":\"%s\"", r_str_rwx_i ( + cf->desc->flags & 7 )); + } r_cons_printf (",\"block\":%d", core->blocksize); if (cf->desc) r_cons_printf (",\"uri\":\"%s\"", cf->desc->uri); @@ -65,10 +66,11 @@ static void r_core_file_info (RCore *core, int mode) { //r_cons_printf ("# Core file info\n"); r_cons_printf ("file\t%s\n", fn); if (dbg) dbg = R_IO_WRITE | R_IO_EXEC; - if (cf->desc) + if (cf->desc) { r_cons_printf ("fd\t%d\n", cf->desc->fd); - r_cons_printf ("size\t0x%"PFMT64x"\n", r_io_desc_size (core->io, cf->desc)); - r_cons_printf ("mode\t%s\n", r_str_rwx_i (cf->rwx | dbg)); + r_cons_printf ("size\t0x%"PFMT64x"\n", r_io_desc_size (core->io, cf->desc)); + r_cons_printf ("mode\t%s\n", r_str_rwx_i (cf->desc->flags & 7 )); + } r_cons_printf ("block\t0x%x\n", core->blocksize); if (cf->desc) r_cons_printf ("uri\t%s\n", cf->desc->uri); diff --git a/libr/core/file.c b/libr/core/file.c index 69e6d5b8ef..c88b010c8f 100644 --- a/libr/core/file.c +++ b/libr/core/file.c @@ -41,7 +41,7 @@ R_API int r_core_file_reopen(RCore *core, const char *args, int perm) { } newpid = odesc ? odesc->fd : -1; - if (!perm) perm = core->file->rwx; + if (!perm) perm = odesc ? odesc->flags : 0; //maybe (odesc->flags & 7) path = strdup (ofilepath); if (isdebug) { @@ -540,7 +540,6 @@ R_API RCoreFile *r_core_file_open_many(RCore *r, const char *file, int flags, ut fh->alive = 1; fh->core = r; fh->desc = fd; - fh->rwx = flags; r->file = fh; r->io->plugin = fd->plugin; // XXX - load addr should be at a set offset @@ -620,7 +619,6 @@ R_API RCoreFile *r_core_file_open(RCore *r, const char *file, int flags, ut64 lo fh->alive = 1; fh->core = r; fh->desc = fd; - fh->rwx = flags; cp = r_config_get (r->config, "cmd.open"); if (cp && *cp) diff --git a/libr/core/visual.c b/libr/core/visual.c index c632102072..6c02a713ab 100644 --- a/libr/core/visual.c +++ b/libr/core/visual.c @@ -603,7 +603,7 @@ R_API int r_core_visual_cmd(RCore *core, int ch) { } break; case 'a': - if (core->file && !(core->file->rwx & 2)) { + if (core->file && core->file->desc && !(core->file->desc->flags & 2)) { r_cons_printf ("\nFile has been opened in read-only mode. Use -w flag\n"); r_cons_any_key (); return R_TRUE; @@ -746,7 +746,7 @@ R_API int r_core_visual_cmd(RCore *core, int ch) { break; case 'i': case 'I': - if (core->file && !(core->file->rwx & 2)) { + if (core->file && core->file->desc &&!(core->file->desc->flags & 2)) { r_cons_printf ("\nFile has been opened in read-only mode. Use -w flag\n"); r_cons_any_key (); return R_TRUE; diff --git a/libr/include/r_core.h b/libr/include/r_core.h index 52931d4d83..fcf836e312 100644 --- a/libr/include/r_core.h +++ b/libr/include/r_core.h @@ -74,7 +74,6 @@ typedef struct r_core_log_t { typedef struct r_core_file_t { RIOMap *map; - int rwx; int dbg; RIODesc *desc; RBinBind binb;