RCoreFile-reduction: kill RCoreFile->rwx

This commit is contained in:
condret 2014-10-08 13:27:33 +02:00
parent 9504a0ef6b
commit 65d8b20d05
4 changed files with 12 additions and 13 deletions

View file

@ -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);

View file

@ -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)

View file

@ -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;

View file

@ -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;