static void
do_msghdr(struct tcb *tcp, struct msghdr *msg, unsigned long data_size)
{
	tprintf("{msg_name(%d)=", msg->msg_namelen);
	printsock(tcp, (long)msg->msg_name, msg->msg_namelen);

	tprintf(", msg_iov(%lu)=", (unsigned long)msg->msg_iovlen);
	tprint_iov_upto(tcp, (unsigned long)msg->msg_iovlen,
		   (unsigned long)msg->msg_iov, 1, data_size);

#ifdef HAVE_STRUCT_MSGHDR_MSG_CONTROL
	tprintf(", msg_controllen=%lu", (unsigned long)msg->msg_controllen);
	if (msg->msg_controllen)
		printcmsghdr(tcp, (unsigned long) msg->msg_control,
			     msg->msg_controllen);
	tprints(", msg_flags=");
	printflags(msg_flags, msg->msg_flags, "MSG_???");
#else /* !HAVE_STRUCT_MSGHDR_MSG_CONTROL */
	tprintf("msg_accrights=%#lx, msg_accrightslen=%u",
		(unsigned long) msg->msg_accrights, msg->msg_accrightslen);
#endif /* !HAVE_STRUCT_MSGHDR_MSG_CONTROL */
	tprints("}");
}
Beispiel #2
0
int
sys_splice(struct tcb *tcp)
{
	if (entering(tcp)) {
		/* int fd_in */
		printfd(tcp, tcp->u_arg[0]);
		tprints(", ");
		/* loff_t *off_in */
		print_loff_t(tcp, tcp->u_arg[1]);
		tprints(", ");
		/* int fd_out */
		printfd(tcp, tcp->u_arg[2]);
		tprints(", ");
		/* loff_t *off_out */
		print_loff_t(tcp, tcp->u_arg[3]);
		tprints(", ");
		/* size_t len */
		tprintf("%lu, ", tcp->u_arg[4]);
		/* unsigned int flags */
		printflags(splice_flags, tcp->u_arg[5], "SPLICE_F_???");
	}
	return 0;
}
static void
decode_mmsg(struct tcb *tcp, unsigned long msg_len)
{
	/* mmsgvec */
	if (syserror(tcp)) {
		tprintf("%#lx", tcp->u_arg[1]);
	} else {
		unsigned int len = tcp->u_rval;
		unsigned int i;

		tprints("{");
		for (i = 0; i < len; ++i) {
			if (i)
				tprints(", ");
			printmmsghdr(tcp, tcp->u_arg[1], i, msg_len);
		}
		tprints("}");
	}
	/* vlen */
	tprintf(", %u, ", (unsigned int) tcp->u_arg[2]);
	/* flags */
	printflags(msg_flags, tcp->u_arg[3], "MSG_???");
}
Beispiel #4
0
void
print_xquota_statv(int rc, void *ptr, void *arg)
{
	struct fs_quota_statv *qs = ptr;
	long out_arg = (long) arg;

	if (((rc != 0) && out_arg) || (out_arg > 1)) {
		printf("%p", qs);
		return;
	}

	PRINT_FIELD_D("{", qs, qs_version);

# if VERBOSE
	printf(", qs_flags=");
	printflags(xfs_quota_flags, qs->qs_flags, "XFS_QUOTA_???");
	PRINT_FIELD_U(", ", qs, qs_incoredqs);
	PRINT_FIELD_U(", qs_uquota={", &qs->qs_uquota, qfs_ino);
	PRINT_FIELD_U(", ", &qs->qs_uquota, qfs_nblks);
	PRINT_FIELD_U(", ", &qs->qs_uquota, qfs_nextents);
	PRINT_FIELD_U("}, qs_gquota={", &qs->qs_gquota, qfs_ino);
	PRINT_FIELD_U(", ", &qs->qs_gquota, qfs_nblks);
	PRINT_FIELD_U(", ", &qs->qs_gquota, qfs_nextents);
	PRINT_FIELD_U("}, qs_pquota={", &qs->qs_pquota, qfs_ino);
	PRINT_FIELD_U(", ", &qs->qs_pquota, qfs_nblks);
	PRINT_FIELD_U(", ", &qs->qs_pquota, qfs_nextents);
	PRINT_FIELD_D("}, ", qs, qs_btimelimit);
	PRINT_FIELD_D(", ", qs, qs_itimelimit);
	PRINT_FIELD_D(", ", qs, qs_rtbtimelimit);
	PRINT_FIELD_U(", ", qs, qs_bwarnlimit);
	PRINT_FIELD_U(", ", qs, qs_iwarnlimit);
# else
	printf(", ...");
# endif /* !VERBOSE */
	printf("}");
}
Beispiel #5
0
static int
decode_poll(struct tcb *tcp, long pts)
{
    struct pollfd fds;
    unsigned nfds;
    unsigned long size, start, cur, end, abbrev_end;
    int failed = 0;

    if (entering(tcp)) {
        nfds = tcp->u_arg[1];
        size = sizeof(fds) * nfds;
        start = tcp->u_arg[0];
        end = start + size;
        if (nfds == 0 || size / sizeof(fds) != nfds || end < start) {
            tprintf("%#lx, %d, ",
                    tcp->u_arg[0], nfds);
            return 0;
        }
        if (abbrev(tcp)) {
            abbrev_end = start + max_strlen * sizeof(fds);
            if (abbrev_end < start)
                abbrev_end = end;
        } else {
            abbrev_end = end;
        }
        tprints("[");
        for (cur = start; cur < end; cur += sizeof(fds)) {
            if (cur > start)
                tprints(", ");
            if (cur >= abbrev_end) {
                tprints("...");
                break;
            }
            if (umoven(tcp, cur, sizeof fds, (char *) &fds) < 0) {
                tprints("?");
                failed = 1;
                break;
            }
            if (fds.fd < 0) {
                tprintf("{fd=%d}", fds.fd);
                continue;
            }
            tprints("{fd=");
            printfd(tcp, fds.fd);
            tprints(", events=");
            printflags(pollflags, fds.events, "POLL???");
            tprints("}");
        }
        tprints("]");
        if (failed)
            tprintf(" %#lx", start);
        tprintf(", %d, ", nfds);
        return 0;
    } else {
        static char outstr[1024];
        char *outptr;
#define end_outstr (outstr + sizeof(outstr))
        const char *flagstr;

        if (syserror(tcp))
            return 0;
        if (tcp->u_rval == 0) {
            tcp->auxstr = "Timeout";
            return RVAL_STR;
        }

        nfds = tcp->u_arg[1];
        size = sizeof(fds) * nfds;
        start = tcp->u_arg[0];
        end = start + size;
        if (nfds == 0 || size / sizeof(fds) != nfds || end < start)
            return 0;
        if (abbrev(tcp)) {
            abbrev_end = start + max_strlen * sizeof(fds);
            if (abbrev_end < start)
                abbrev_end = end;
        } else {
            abbrev_end = end;
        }

        outptr = outstr;

        for (cur = start; cur < end; cur += sizeof(fds)) {
            if (umoven(tcp, cur, sizeof fds, (char *) &fds) < 0) {
                if (outptr < end_outstr - 2)
                    *outptr++ = '?';
                failed = 1;
                break;
            }
            if (!fds.revents)
                continue;
            if (outptr == outstr) {
                *outptr++ = '[';
            } else {
                if (outptr < end_outstr - 3)
                    outptr = stpcpy(outptr, ", ");
            }
            if (cur >= abbrev_end) {
                if (outptr < end_outstr - 4)
                    outptr = stpcpy(outptr, "...");
                break;
            }
            if (outptr < end_outstr - (sizeof("{fd=%d, revents=") + sizeof(int)*3) + 1)
                outptr += sprintf(outptr, "{fd=%d, revents=", fds.fd);
            flagstr = sprintflags("", pollflags, fds.revents);
            if (outptr < end_outstr - (strlen(flagstr) + 2)) {
                outptr = stpcpy(outptr, flagstr);
                *outptr++ = '}';
            }
        }
        if (failed)
            return 0;

        if (outptr != outstr /* && outptr < end_outstr - 1 (always true)*/)
            *outptr++ = ']';

        *outptr = '\0';
        if (pts) {
            if (outptr < end_outstr - (10 + TIMESPEC_TEXT_BUFSIZE)) {
                outptr = stpcpy(outptr, outptr == outstr ? "left " : ", left ");
                sprint_timespec(outptr, tcp, pts);
            }
        }

        if (outptr == outstr)
            return 0;

        tcp->auxstr = outstr;
        return RVAL_STR;
#undef end_outstr
    }
}
Beispiel #6
0
int
sys_query_module(struct tcb *tcp)
{
	if (entering(tcp)) {
		printstr(tcp, tcp->u_arg[0], -1);
		tprintf(", ");
		printxval(which, tcp->u_arg[1], "QM_???");
		tprintf(", ");
	} else {
		size_t ret;

		if (!verbose(tcp) || syserror(tcp) ||
		    umove(tcp, tcp->u_arg[4], &ret) < 0) {
			tprintf("%#lx, %lu, %#lx", tcp->u_arg[2],
				tcp->u_arg[3], tcp->u_arg[4]);
		} else if (tcp->u_arg[1]==QM_INFO) {
			struct module_info	mi;
			if (umove(tcp, tcp->u_arg[2], &mi) < 0) {
				tprintf("%#lx, ", tcp->u_arg[2]);
			} else {
				tprintf("{address=%#lx, size=%lu, flags=",
					mi.addr, mi.size);
				printflags(modflags, mi.flags, "MOD_???");
				tprintf(", usecount=%lu}, ", mi.usecount);
			}
			tprintf("%Zu", ret);
		} else if ((tcp->u_arg[1]==QM_MODULES) ||
			   (tcp->u_arg[1]==QM_DEPS) ||
			   (tcp->u_arg[1]==QM_REFS)) {
			tprintf("{");
			if (!abbrev(tcp)) {
				char*	data	= malloc(tcp->u_arg[3]);
				char*	mod	= data;
				size_t	idx;

				if (!data) {
					fprintf(stderr, "out of memory\n");
					tprintf(" /* %Zu entries */ ", ret);
				} else {
					if (umoven(tcp, tcp->u_arg[2],
						tcp->u_arg[3], data) < 0) {
						tprintf(" /* %Zu entries */ ", ret);
					} else {
						for (idx=0; idx<ret; idx++) {
							tprintf("%s%s",
								(idx ? ", " : ""),
								mod);
							mod += strlen(mod)+1;
						}
					}
					free(data);
				}
			} else
				tprintf(" /* %Zu entries */ ", ret);
			tprintf("}, %Zu", ret);
		} else if (tcp->u_arg[1]==QM_SYMBOLS) {
			tprintf("{");
			if (!abbrev(tcp)) {
				char*			data	= malloc(tcp->u_arg[3]);
				struct module_symbol*	sym	= (struct module_symbol*)data;
				size_t			idx;

				if (!data) {
					fprintf(stderr, "out of memory\n");
					tprintf(" /* %Zu entries */ ", ret);
				} else {
					if (umoven(tcp, tcp->u_arg[2],
						tcp->u_arg[3], data) < 0) {
						tprintf(" /* %Zu entries */ ", ret);
					} else {
						for (idx=0; idx<ret; idx++) {
							tprintf("%s{name=%s, value=%lu}",
								(idx ? " " : ""),
								data+(long)sym->name,
								sym->value);
							sym++;
						}
					}
					free(data);
				}
			} else
				tprintf(" /* %Zu entries */ ", ret);
			tprintf("}, %Zd", ret);
		} else {
			printstr(tcp, tcp->u_arg[2], tcp->u_arg[3]);
			tprintf(", %#lx", tcp->u_arg[4]);
		}
	}
	return 0;
}
Beispiel #7
0
void csc_dorollbackchan_real(DBConn *dbconn, void *arg) {
  nick *np=getnickbynumeric((unsigned long)arg);
  reguser *rup, *crup1, *crup2;
  chanindex *cip = NULL;
  regchan *rcp=NULL;
  regchanuser *rcup;
  unsigned int userID, channelID, targetID;
  time_t changetime, authtime;
  flag_t oldflags, newflags;
  DBResult *pgres;
  int j, newuser;
  char fbuf[18];

  if(!dbconn)
    return;

  pgres=dbgetresult(dbconn);

  if (!dbquerysuccessful(pgres)) {
    Error("chanserv", ERR_ERROR, "Error loading chanlev history data.");
    return;
  }

  if (dbnumfields(pgres) != 7) {
    Error("chanserv", ERR_ERROR, "Chanlev history data format error.");
    dbclear(pgres);
    return;
  }

  if (!np) {
    Error("chanserv", ERR_ERROR, "No nick pointer in rollback.");
    dbclear(pgres);
    return;
  }
  if (!(rup=getreguserfromnick(np)) || !UHasOperPriv(rup)) {
    Error("chanserv", ERR_ERROR, "No reguser pointer or oper privs in rollback.");
    dbclear(pgres);
    return;
  }

  while(dbfetchrow(pgres)) {
    userID=strtoul(dbgetvalue(pgres, 0), NULL, 10);
    channelID=strtoul(dbgetvalue(pgres, 1), NULL, 10);

    if (!rcp) {
      for (j=0; j<CHANNELHASHSIZE && !rcp; j++) {
        for (cip=chantable[j]; cip && !rcp; cip=cip->next) {
          if (!cip->exts[chanservext])
            continue;

          if (((regchan*)cip->exts[chanservext])->ID == channelID)
            rcp=(regchan*)cip->exts[chanservext];
        }
      }

      if (!rcp) {
        Error("chanserv", ERR_ERROR, "No regchan pointer or oper privs in rollback.");
        dbclear(pgres);
        return;
      }

      cip=rcp->index;

      chanservsendmessage(np, "Attempting to roll back %s:", cip->name->content);
    }
    targetID=strtoul(dbgetvalue(pgres, 2), NULL, 10);
    changetime=strtoul(dbgetvalue(pgres, 3), NULL, 10);
    authtime=strtoul(dbgetvalue(pgres, 4), NULL, 10);
    oldflags=strtoul(dbgetvalue(pgres, 5), NULL, 10);
    newflags=strtoul(dbgetvalue(pgres, 6), NULL, 10);
    strncpy(fbuf, printflags(newflags, rcuflags), 17);
    fbuf[17]='\0';
    crup1=findreguserbyID(userID);
    crup2=findreguserbyID(targetID);

    if (!crup2) {
      chanservsendmessage(np, "Affected user (ID: %d) is no longer in database, continuing...", targetID);
      continue;
    }

    if (!(rcup=findreguseronchannel(rcp, crup2))) {
      rcup=getregchanuser();
      rcup->user=crup2;
      rcup->chan=rcp;
      rcup->flags=0;
      rcup->changetime=time(NULL);
      rcup->usetime=0;
      rcup->info=NULL;
      newuser=1;
    }
    else
      newuser=0;
    csdb_chanlevhistory_insert(rcp, np, rcup->user, rcup->flags, oldflags);
    rcup->flags=oldflags;
    chanservsendmessage(np, "%s user flags for %s (%s -> %s)", newflags?oldflags?"Restoring":"Deleting":"Readding",
      crup2->username, fbuf, printflags(oldflags, rcuflags));

    if (rcup->flags) {
      if (newuser) {
        addregusertochannel(rcup);
        csdb_createchanuser(rcup);
      }
      else
        csdb_updatechanuser(rcup);
    }
    else {
      if (!newuser) {
        csdb_deletechanuser(rcup);
        delreguserfromchannel(rcp, crup2);
      }

      freesstring(rcup->info);
      freeregchanuser(rcup);
      rcup=NULL;

      for (j=0; j<REGCHANUSERHASHSIZE; j++)
        if (rcp->regusers[j])
          break;

      if (j==REGCHANUSERHASHSIZE) {
        cs_log(np, "DELCHAN %s (Cleared chanlev from rollback)", cip->name->content);
        chanservsendmessage(np, "Rollback cleared chanlev list, channel deleted.");
        rcp=NULL;
      }
    }
  }
  chanservstdmessage(np, QM_DONE);

  dbclear(pgres);
}
Beispiel #8
0
int print_ccache (kim_ccache in_ccache, int *out_found_valid_tgt)
{
    kim_error err = 0;
    kim_credential_iterator iterator = NULL;
    kim_identity ccache_identity = NULL;
    kim_string type = NULL;
    kim_string name = NULL;
    kim_string ccache_identity_string = NULL;
    int found_tickets = 0;

    *out_found_valid_tgt = 0;
    
    if (!err) {
        err = kim_ccache_get_type (in_ccache, &type);
        printiferr (err, "while getting the ccache type");
    }
    
    if (!err) {
        err = kim_ccache_get_name (in_ccache, &name);
        printiferr (err, "while getting the ccache name");
    }
    
    if (!err) {
        err = kim_ccache_get_client_identity (in_ccache, &ccache_identity);
        printiferr (err, "while getting the ccache principal");
   }
    
    if (!err) {
        err = kim_identity_get_display_string (ccache_identity, 
                                               &ccache_identity_string);
        printiferr (err, "while unparsing the ccache principal name");
    }
    
    if (!err) {
        printmsg ("Kerberos 5 ticket cache: '%s:%s'\nDefault principal: %s\n\n",
                  type, name, ccache_identity_string);
        printmsg ("Valid Starting");
        printfiller (' ', get_timestamp_width () - sizeof ("Valid Starting") + 3);
        printmsg ("Expires");
        printfiller (' ', get_timestamp_width () - sizeof ("Expires") + 3);
        printmsg ("Service Principal\n");
        
        err = kim_credential_iterator_create (&iterator, in_ccache);
    }
    
    while (!err) {
        kim_credential credential = NULL;
        kim_identity client = NULL;
        kim_identity service = NULL;
        kim_string client_string = NULL;
        kim_string service_string = NULL;
        krb5_creds *creds = NULL;
        int extra_field = 0;
        
        err = kim_credential_iterator_next (iterator, &credential);
        if (!err && !credential) { break; }
        
        if (!err) {
            err = kim_credential_get_client_identity (credential, &client);
            printiferr (err, "while getting the client principal");
        }

        if (!err) {
            err = kim_identity_get_display_string (client, &client_string);
            printiferr (err, "while unparsing the client principal name");
        }
        
        if (!err) {
            err = kim_credential_get_service_identity (credential, &service);
            printiferr (err, "while getting the service principal");
        }
        
        if (!err) {
            err = kim_identity_get_display_string (service, &service_string);
            printiferr (err, "while unparsing the service principal name");
        }
        
        if (!err) {
            err = kim_credential_get_krb5_creds (credential, kcontext, &creds);
            printiferr (err, "while getting krb5 creds");
        }
                
	if (!err && krb5_is_config_principal(kcontext, creds->server))
	    goto next;

        if (!err) {
            found_tickets = 1;
            
            printtime (creds->times.starttime ? creds->times.starttime : creds->times.authtime);
            printmsg ("  ");
            printtime (creds->times.endtime);
            printmsg ("  ");
            printmsg ("%s\n", service_string);
            
            if (strcmp (ccache_identity_string, client_string)) {
                if (!extra_field) {
                    printmsg ("\t");
                }
                printmsg ("for client %s", client_string);
                extra_field++;
            }
            
            if (creds->ticket_flags & TKT_FLG_RENEWABLE) {
                printmsg (extra_field ? ", " : "\t");
                printmsg ("renew until ");
                printtime (creds->times.renew_till);
                extra_field += 2;
            }
            
            if (extra_field > 2) {
                printmsg ("\n");
                extra_field = 0;
            }
            
            if (show_flags) {
                printmsg (extra_field ? ", " : "\t");
                printflags (creds->ticket_flags);
                extra_field++;
            }
            
            if (extra_field > 2) {
                printmsg ("\n");
                extra_field = 0;
            }
            
            if (show_enctypes) {
                krb5_ticket *ticket_rep;
                
                if (krb5_decode_ticket (&creds->ticket, &ticket_rep) == 0) {
                    if (!extra_field) {
                        printmsg ("\t");
                    } else {
                        printmsg (", ");
                    }
                    printmsg ("Etype (skey, tkt): %s, ", 
                              enctype_to_string (creds->keyblock.enctype));
                    printmsg ("%s ", 
                              enctype_to_string (ticket_rep->enc_part.enctype));
                    extra_field++;
                    
                    krb5_free_ticket (kcontext, ticket_rep);
                }
            }
            
            if (extra_field) {
                printmsg ("\n");
            }
            
            if (show_address_list) {
                printmsg ("\tAddresses: ");
                if (!creds->addresses || !creds->addresses[0]) {
                    printmsg ("(none)\n");
                } else {
                    int i;
                    
                    for (i = 0; creds->addresses[i]; i++) {
                        if (i > 0) {
                            printmsg (", ");
                        }
                        printaddress (*creds->addresses[i]);
                    }
                    printmsg ("\n");
                }
            }
            if (extra_field) {
                printmsg ("\n");
            }
            
        }
        
        if (!err) {
            kim_boolean is_tgt = 0;
            kim_credential_state state;
            
            err = kim_credential_is_tgt (credential, &is_tgt);
            printiferr (err, "while checking if creds are valid");
           
            if (!err) {
                err = kim_credential_get_state (credential, &state);
            }
            
            if (!err && is_tgt && state == kim_credentials_state_valid) { 
                *out_found_valid_tgt = 1;
            }
        }
        
    next:
        if (creds) { krb5_free_creds (kcontext, creds); }
        kim_string_free (&client_string);
        kim_string_free (&service_string);
        kim_identity_free (&client);
        kim_identity_free (&service);
        kim_credential_free (&credential);
    }
        
    kim_string_free (&type);
    kim_string_free (&name);
    kim_string_free (&ccache_identity_string);
    kim_identity_free (&ccache_identity);
    kim_credential_iterator_free (&iterator);
    
    if (!err) {
        if (!found_tickets) {
            printerr ("No Kerberos 5 tickets in credentials cache\n");
        } else {
            printmsg ("\n");
        }
    }

    return err;
}
Beispiel #9
0
/* todo: add RELINK status */
int spcmd_splitlist(void *source, int cargc, char **cargv) {
  nick *np = (nick*)source;
  int i;
  splitserver srv;

  if (splitlist.cursi == 0) {
    controlreply(np, "There currently aren't any registered splits.");

    return CMD_OK;
  }

  controlreply(np, "Server Status Split for");

  for (i = 0; i < splitlist.cursi; i++) {
    srv = ((splitserver*)splitlist.content)[i];

    controlreply(np, "%s M.I.A. %s (%s)", srv.name->content, longtoduration(getnettime() - srv.ts, 1), printflags(srv.type, servertypeflags));
  }

  controlreply(np, "--- End of splitlist");
  
  return CMD_OK;
}
Beispiel #10
0
int
ptp_ioctl(struct tcb *tcp, const unsigned int code, const long arg)
{
	if (!verbose(tcp))
		return RVAL_DECODED;

	switch (code) {
	case PTP_EXTTS_REQUEST: {
		struct ptp_extts_request extts;

		tprints(", ");
		if (umove_or_printaddr(tcp, arg, &extts))
			break;

		tprintf("{index=%d, flags=", extts.index);
		printflags(ptp_flags_options, extts.flags, "PTP_???");
		tprints("}");
		break;
	}

	case PTP_PEROUT_REQUEST: {
		struct ptp_perout_request perout;

		tprints(", ");
		if (umove_or_printaddr(tcp, arg, &perout))
			break;

		tprintf("{start={%" PRId64 ", %" PRIu32 "}"
			   ", period={%" PRId64 ", %" PRIu32 "}"
			   ", index=%d, flags=",
			(int64_t)perout.start.sec, perout.start.nsec,
			(int64_t)perout.period.sec, perout.period.nsec,
			perout.index);
		printflags(ptp_flags_options, perout.flags, "PTP_???");
		tprints("}");
		break;
	}

	case PTP_ENABLE_PPS:
		tprintf(", %ld", arg);
		break;

	case PTP_SYS_OFFSET: {
		struct ptp_sys_offset sysoff;

		if (entering(tcp)) {
			tprints(", ");
			if (umove_or_printaddr(tcp, arg, &sysoff))
				break;

			tprintf("{n_samples=%u", sysoff.n_samples);
			return 1;
		} else {
			unsigned int n_samples, i;

			if (syserror(tcp)) {
				tprints("}");
				break;
			}

			tprints(", ");
			if (umove(tcp, arg, &sysoff) < 0) {
				tprints("???}");
				break;
			}

			tprints("ts=[");
			n_samples = sysoff.n_samples > PTP_MAX_SAMPLES ?
				PTP_MAX_SAMPLES : sysoff.n_samples;
			for (i = 0; i < 2 * n_samples + 1; ++i) {
				if (i > 0)
					tprints(", ");
				tprintf("{%" PRId64 ", %" PRIu32 "}",
					(int64_t)sysoff.ts[i].sec,
					sysoff.ts[i].nsec);
			}
			if (sysoff.n_samples > PTP_MAX_SAMPLES)
				tprints(", ...");
			tprints("]}");
			break;
		}
	}
	case PTP_CLOCK_GETCAPS: {
		struct ptp_clock_caps caps;

		if (entering(tcp))
			return 0;

		tprints(", ");
		if (umove_or_printaddr(tcp, arg, &caps))
			break;

		tprintf("{max_adj=%d, n_alarm=%d, n_ext_ts=%d, n_per_out=%d, pps=%d}",
			caps.max_adj, caps.n_alarm, caps.n_ext_ts,
			caps.n_per_out, caps.pps);
		break;
	}

	default:
		return RVAL_DECODED;
	}

	return RVAL_DECODED | 1;
}
Beispiel #11
0
int
sys_rt_sigaction(struct tcb *tcp)
{
	struct new_sigaction sa;
	sigset_t sigset;
	long addr;
	int r;

	if (entering(tcp)) {
		printsignal(tcp->u_arg[0]);
		tprints(", ");
		addr = tcp->u_arg[1];
	} else
		addr = tcp->u_arg[2];

	if (addr == 0) {
		tprints("NULL");
		goto after_sa;
	}
	if (!verbose(tcp)) {
		tprintf("%#lx", addr);
		goto after_sa;
	}
#if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
	if (current_wordsize != sizeof(sa.sa_flags) && current_wordsize == 4) {
		struct new_sigaction32 sa32;
		r = umove(tcp, addr, &sa32);
		if (r >= 0) {
			memset(&sa, 0, sizeof(sa));
			sa.__sa_handler = (void*)(unsigned long)sa32.__sa_handler;
			sa.sa_flags     = sa32.sa_flags;
			sa.sa_restorer  = (void*)(unsigned long)sa32.sa_restorer;
			/* Kernel treats sa_mask as an array of longs.
			 * For 32-bit process, "long" is uint32_t, thus, for example,
			 * 32th bit in sa_mask will end up as bit 0 in sa_mask[1].
			 * But for (64-bit) kernel, 32th bit in sa_mask is
			 * 32th bit in 0th (64-bit) long!
			 * For little-endian, it's the same.
			 * For big-endian, we swap 32-bit words.
			 */
			sa.sa_mask[0] = sa32.sa_mask[0] + ((long)(sa32.sa_mask[1]) << 32);
		}
	} else
#endif
	{
		r = umove(tcp, addr, &sa);
	}
	if (r < 0) {
		tprints("{...}");
		goto after_sa;
	}
	/* Architectures using function pointers, like
	 * hppa, may need to manipulate the function pointer
	 * to compute the result of a comparison. However,
	 * the __sa_handler function pointer exists only in
	 * the address space of the traced process, and can't
	 * be manipulated by strace. In order to prevent the
	 * compiler from generating code to manipulate
	 * __sa_handler we cast the function pointers to long. */
	if ((long)sa.__sa_handler == (long)SIG_ERR)
		tprints("{SIG_ERR, ");
	else if ((long)sa.__sa_handler == (long)SIG_DFL)
		tprints("{SIG_DFL, ");
	else if ((long)sa.__sa_handler == (long)SIG_IGN)
		tprints("{SIG_IGN, ");
	else
		tprintf("{%#lx, ", (long) sa.__sa_handler);
	/* Questionable code below.
	 * Kernel won't handle sys_rt_sigaction
	 * with wrong sigset size (just returns EINVAL)
	 * therefore tcp->u_arg[3(4)] _must_ be NSIG / 8 here,
	 * and we always use smaller memcpy. */
	sigemptyset(&sigset);
#if defined(SPARC) || defined(SPARC64)
	if (tcp->u_arg[4] <= sizeof(sigset))
		memcpy(&sigset, &sa.sa_mask, tcp->u_arg[4]);
#else
	if (tcp->u_arg[3] <= sizeof(sigset))
		memcpy(&sigset, &sa.sa_mask, tcp->u_arg[3]);
#endif
	else
		memcpy(&sigset, &sa.sa_mask, sizeof(sigset));
	printsigmask(&sigset, 1);
	tprints(", ");
	printflags(sigact_flags, sa.sa_flags, "SA_???");
#ifdef SA_RESTORER
	if (sa.sa_flags & SA_RESTORER)
		tprintf(", %p", sa.sa_restorer);
#endif
	tprints("}");

 after_sa:
	if (entering(tcp))
		tprints(", ");
	else
#if defined(SPARC) || defined(SPARC64)
		tprintf(", %#lx, %lu", tcp->u_arg[3], tcp->u_arg[4]);
#elif defined(ALPHA)
		tprintf(", %lu, %#lx", tcp->u_arg[3], tcp->u_arg[4]);
#else
		tprintf(", %lu", tcp->u_arg[3]);
#endif
	return 0;
}
Beispiel #12
0
static void
decode_new_sigaction(struct tcb *tcp, long addr)
{
	struct new_sigaction sa;
	int r;

	if (!addr) {
		tprints("NULL");
		return;
	}
	if (!verbose(tcp) || (exiting(tcp) && syserror(tcp))) {
		tprintf("%#lx", addr);
		return;
	}
#if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
	if (current_wordsize != sizeof(sa.sa_flags) && current_wordsize == 4) {
		struct new_sigaction32 sa32;
		r = umove(tcp, addr, &sa32);
		if (r >= 0) {
			memset(&sa, 0, sizeof(sa));
			sa.__sa_handler = (void*)(unsigned long)sa32.__sa_handler;
			sa.sa_flags     = sa32.sa_flags;
			sa.sa_restorer  = (void*)(unsigned long)sa32.sa_restorer;
			/* Kernel treats sa_mask as an array of longs.
			 * For 32-bit process, "long" is uint32_t, thus, for example,
			 * 32th bit in sa_mask will end up as bit 0 in sa_mask[1].
			 * But for (64-bit) kernel, 32th bit in sa_mask is
			 * 32th bit in 0th (64-bit) long!
			 * For little-endian, it's the same.
			 * For big-endian, we swap 32-bit words.
			 */
			sa.sa_mask[0] = sa32.sa_mask[0] + ((long)(sa32.sa_mask[1]) << 32);
		}
	} else
#endif
	{
		r = umove(tcp, addr, &sa);
	}
	if (r < 0) {
		tprints("{...}");
		return;
	}
	/* Architectures using function pointers, like
	 * hppa, may need to manipulate the function pointer
	 * to compute the result of a comparison. However,
	 * the __sa_handler function pointer exists only in
	 * the address space of the traced process, and can't
	 * be manipulated by strace. In order to prevent the
	 * compiler from generating code to manipulate
	 * __sa_handler we cast the function pointers to long. */
	if ((long)sa.__sa_handler == (long)SIG_ERR)
		tprints("{SIG_ERR, ");
	else if ((long)sa.__sa_handler == (long)SIG_DFL)
		tprints("{SIG_DFL, ");
	else if ((long)sa.__sa_handler == (long)SIG_IGN)
		tprints("{SIG_IGN, ");
	else
		tprintf("{%#lx, ", (long) sa.__sa_handler);
	/*
	 * Sigset size is in tcp->u_arg[4] (SPARC)
	 * or in tcp->u_arg[3] (all other),
	 * but kernel won't handle sys_rt_sigaction
	 * with wrong sigset size (just returns EINVAL instead).
	 * We just fetch the right size, which is NSIG / 8.
	 */
	tprintsigmask_val("", sa.sa_mask);
	tprints(", ");

	printflags(sigact_flags, sa.sa_flags, "SA_???");
#ifdef SA_RESTORER
	if (sa.sa_flags & SA_RESTORER)
		tprintf(", %p", sa.sa_restorer);
#endif
	tprints("}");
}
Beispiel #13
0
int mtd_ioctl(struct tcb *tcp, long code, long arg)
{
	struct mtd_info_user minfo;
	struct erase_info_user einfo;
	struct erase_info_user64 einfo64;
	struct mtd_oob_buf mbuf;
	struct mtd_oob_buf64 mbuf64;
	struct region_info_user rinfo;
	struct otp_info oinfo;
	struct mtd_ecc_stats estat;
	struct mtd_write_req mreq;
	struct nand_oobinfo ninfo;
	struct nand_ecclayout_user nlay;
	int i, j;

	if (entering(tcp))
		return 0;

	switch (code) {

	case MEMGETINFO:
		if (!verbose(tcp) || umove(tcp, arg, &minfo) < 0)
			return 0;

		tprints(", {type=");
		printxval(mtd_type_options, minfo.type, "MTD_???");
		tprints(", flags=");
		printflags(mtd_flags_options, minfo.flags, "MTD_???");
		tprintf(", size=%#" PRIx32 ", erasesize=%#" PRIx32,
			minfo.size, minfo.erasesize);
		tprintf(", writesize=%#" PRIx32 ", oobsize=%#" PRIx32,
			minfo.writesize, minfo.oobsize);
		tprintf(", padding=%#" PRIx64 "}",
			(uint64_t) minfo.padding);
		return 1;

	case MEMERASE:
	case MEMLOCK:
	case MEMUNLOCK:
	case MEMISLOCKED:
		if (!verbose(tcp) || umove(tcp, arg, &einfo) < 0)
			return 0;

		tprintf(", {start=%#" PRIx32 ", length=%#" PRIx32 "}",
			einfo.start, einfo.length);
		return 1;

	case MEMERASE64:
		if (!verbose(tcp) || umove(tcp, arg, &einfo64) < 0)
			return 0;

		tprintf(", {start=%#" PRIx64 ", length=%#" PRIx64 "}",
			(uint64_t) einfo64.start, (uint64_t) einfo64.length);
		return 1;

	case MEMWRITEOOB:
	case MEMREADOOB:
		if (!verbose(tcp) || umove(tcp, arg, &mbuf) < 0)
			return 0;

		tprintf(", {start=%#" PRIx32 ", length=%#" PRIx32 ", ptr=...}",
			mbuf.start, mbuf.length);
		return 1;

	case MEMWRITEOOB64:
	case MEMREADOOB64:
		if (!verbose(tcp) || umove(tcp, arg, &mbuf64) < 0)
			return 0;

		tprintf(", {start=%#" PRIx64 ", length=%#" PRIx64 ", ptr=...}",
			(uint64_t) mbuf64.start, (uint64_t) mbuf64.length);
		return 1;

	case MEMGETREGIONINFO:
		if (!verbose(tcp) || umove(tcp, arg, &rinfo) < 0)
			return 0;

		tprintf(", {offset=%#" PRIx32 ", erasesize=%#" PRIx32,
			rinfo.offset, rinfo.erasesize);
		tprintf(", numblocks=%#" PRIx32 ", regionindex=%#" PRIx32 "}",
			rinfo.numblocks, rinfo.regionindex);
		return 1;

	case MEMGETOOBSEL:
		if (!verbose(tcp) || umove(tcp, arg, &ninfo) < 0)
			return 0;

		tprints(", {useecc=");
		printxval(mtd_nandecc_options, ninfo.useecc, "MTD_NANDECC_???");
		tprintf(", eccbytes=%#" PRIx32, ninfo.eccbytes);

		tprints(", oobfree={");
		for (i = 0; i < ARRAY_SIZE(ninfo.oobfree); ++i) {
			if (i)
				tprints("}, ");
			tprints("{");
			for (j = 0; j < ARRAY_SIZE(ninfo.oobfree[0]); ++j) {
				if (j)
					tprints(", ");
				tprintf("%#" PRIx32, ninfo.oobfree[i][j]);
			}
		}

		tprints("}}, eccpos={");
		for (i = 0; i < ARRAY_SIZE(ninfo.eccpos); ++i) {
			if (i)
				tprints(", ");
			tprintf("%#" PRIx32, ninfo.eccpos[i]);
		}

		tprints("}");
		return 1;

	case OTPGETREGIONINFO:
	case OTPLOCK:
		if (!verbose(tcp) || umove(tcp, arg, &oinfo) < 0)
			return 0;

		tprintf(", {start=%#" PRIx32 ", length=%#" PRIx32 ", locked=%" PRIu32 "}",
			oinfo.start, oinfo.length, oinfo.locked);
		return 1;

	case ECCGETLAYOUT:
		if (!verbose(tcp) || umove(tcp, arg, &nlay) < 0)
			return 0;

		tprintf(", {eccbytes=%#" PRIx32 ", eccpos={", nlay.eccbytes);
		for (i = 0; i < ARRAY_SIZE(nlay.eccpos); ++i) {
			if (i)
				tprints(", ");
			tprintf("%#" PRIx32, nlay.eccpos[i]);
		}
		tprintf("}, oobavail=%#" PRIx32 ", oobfree={", nlay.oobavail);
		for (i = 0; i < ARRAY_SIZE(nlay.oobfree); ++i) {
			if (i)
				tprints(", ");
			tprintf("{offset=%#" PRIx32 ", length=%#" PRIx32 "}",
				nlay.oobfree[i].offset, nlay.oobfree[i].length);
		}
		tprints("}");
		return 1;

	case ECCGETSTATS:
		if (!verbose(tcp) || umove(tcp, arg, &estat) < 0)
			return 0;

		tprintf(", {corrected=%#" PRIx32 ", failed=%#" PRIx32,
			estat.corrected, estat.failed);
		tprintf(", badblocks=%#" PRIx32 ", bbtblocks=%#" PRIx32 "}",
			estat.badblocks, estat.bbtblocks);
		return 1;

	case MEMWRITE:
		if (!verbose(tcp) || umove(tcp, arg, &mreq) < 0)
			return 0;

		tprintf(", {start=%#" PRIx64 ", len=%#" PRIx64,
			(uint64_t) mreq.start, (uint64_t) mreq.len);
		tprintf(", ooblen=%#" PRIx64 ", usr_data=%#" PRIx64,
			(uint64_t) mreq.ooblen, (uint64_t) mreq.usr_data);
		tprintf(", usr_oob=%#" PRIx64 ", mode=",
			(uint64_t) mreq.usr_oob);
		printxval(mtd_mode_options, mreq.mode, "MTD_OPS_???");
		tprints(", padding=...}");
		return 1;

	case OTPSELECT:
		if (!verbose(tcp) || umove(tcp, arg, &i) < 0)
			return 0;

		tprints(", [");
		printxval(mtd_otp_options, i, "MTD_OTP_???");
		tprints("]");
		return 1;

	case MEMGETBADBLOCK:
	case MEMSETBADBLOCK:
		if (!verbose(tcp))
			return 0;

		tprints(", ");
		print_loff_t(tcp, arg);
		return 1;

	case OTPGETREGIONCOUNT:
		if (!verbose(tcp) || umove(tcp, arg, &i) < 0)
			return 0;

		tprintf(", [%i]", i);
		return 1;

	case MTDFILEMODE:
		/* XXX: process return value as enum mtd_file_modes */

	case MEMGETREGIONCOUNT:
		/* These ones take simple args, so let default printer handle it */

	default:
		return 0;
	}
}
Beispiel #14
0
int
sys_ptrace(struct tcb *tcp)
{
	const struct xlat *x;
	unsigned long addr;

	if (entering(tcp)) {
		printxval(ptrace_cmds, tcp->u_arg[0], "PTRACE_???");
		tprintf(", %lu, ", tcp->u_arg[1]);

		addr = tcp->u_arg[2];
		if (tcp->u_arg[0] == PTRACE_PEEKUSER
		 || tcp->u_arg[0] == PTRACE_POKEUSER
		) {
			for (x = struct_user_offsets; x->str; x++) {
				if (x->val >= addr)
					break;
			}
			if (!x->str)
				tprintf("%#lx, ", addr);
			else if (x->val > addr && x != struct_user_offsets) {
				x--;
				tprintf("%s + %ld, ", x->str, addr - x->val);
			}
			else
				tprintf("%s, ", x->str);
		} else
		if (tcp->u_arg[0] == PTRACE_GETREGSET
		 || tcp->u_arg[0] == PTRACE_SETREGSET
		) {
			printxval(nt_descriptor_types, tcp->u_arg[2], "NT_???");
			tprints(", ");
		} else
			tprintf("%#lx, ", addr);


		switch (tcp->u_arg[0]) {
#ifndef IA64
		case PTRACE_PEEKDATA:
		case PTRACE_PEEKTEXT:
		case PTRACE_PEEKUSER:
			break;
#endif
		case PTRACE_CONT:
		case PTRACE_SINGLESTEP:
		case PTRACE_SYSCALL:
		case PTRACE_DETACH:
			printsignal(tcp->u_arg[3]);
			break;
		case PTRACE_SETOPTIONS:
			printflags(ptrace_setoptions_flags, tcp->u_arg[3], "PTRACE_O_???");
			break;
		case PTRACE_SETSIGINFO: {
			printsiginfo_at(tcp, tcp->u_arg[3]);
			break;
		}
		case PTRACE_SETREGSET:
			tprint_iov(tcp, /*len:*/ 1, tcp->u_arg[3], /*as string:*/ 0);
			break;
		case PTRACE_GETSIGINFO:
		case PTRACE_GETREGSET:
			/* Don't print anything, do it at syscall return. */
			break;
		default:
			tprintf("%#lx", tcp->u_arg[3]);
			break;
		}
	} else {
		switch (tcp->u_arg[0]) {
		case PTRACE_PEEKDATA:
		case PTRACE_PEEKTEXT:
		case PTRACE_PEEKUSER:
#ifdef IA64
			return RVAL_HEX;
#else
			printnum_long(tcp, tcp->u_arg[3], "%#lx");
			break;
#endif
		case PTRACE_GETSIGINFO: {
			printsiginfo_at(tcp, tcp->u_arg[3]);
			break;
		}
		case PTRACE_GETREGSET:
			tprint_iov(tcp, /*len:*/ 1, tcp->u_arg[3], /*as string:*/ 0);
			break;
		}
	}
	return 0;
}
Beispiel #15
0
int term_ioctl(struct tcb *tcp, long code, long arg)
{
	struct termios tios;
#ifndef FREEBSD
	struct termio tio;
#else
	#define TCGETS	TIOCGETA
	#define TCSETS	TIOCSETA
	#define TCSETSW	TIOCSETAW
	#define TCSETSF	TIOCSETAF
#endif
	struct winsize ws;
#ifdef TIOCGSIZE
	struct  ttysize ts;
#endif
	int i;

	if (entering(tcp))
		return 0;

	switch (code) {

	/* ioctls with termios or termio args */

#ifdef TCGETS
	case TCGETS:
		if (syserror(tcp))
			return 0;
	case TCSETS:
	case TCSETSW:
	case TCSETSF:
		if (!verbose(tcp) || umove(tcp, arg, &tios) < 0)
			return 0;
		if (abbrev(tcp)) {
			tprintf(", {");
#ifndef FREEBSD
			printxval(baud_options, tios.c_cflag & CBAUD, "B???");
#else
			printxval(baud_options, tios.c_ispeed, "B???");
			if (tios.c_ispeed != tios.c_ospeed) {
				tprintf(" (in)");
				printxval(baud_options, tios.c_ospeed, "B???");
				tprintf(" (out)");
			}
#endif
			tprintf(" %sopost %sisig %sicanon %secho ...}",
				(tios.c_oflag & OPOST) ? "" : "-",
				(tios.c_lflag & ISIG) ? "" : "-",
				(tios.c_lflag & ICANON) ? "" : "-",
				(tios.c_lflag & ECHO) ? "" : "-");
			return 1;
		}
		tprintf(", {c_iflags=%#lx, c_oflags=%#lx, ",
			(long) tios.c_iflag, (long) tios.c_oflag);
		tprintf("c_cflags=%#lx, c_lflags=%#lx, ",
			(long) tios.c_cflag, (long) tios.c_lflag);
#if !defined(SVR4) && !defined(FREEBSD)
		tprintf("c_line=%u, ", tios.c_line);
#endif
		if (!(tios.c_lflag & ICANON))
			tprintf("c_cc[VMIN]=%d, c_cc[VTIME]=%d, ",
				tios.c_cc[VMIN], tios.c_cc[VTIME]);
		tprintf("c_cc=\"");
		for (i = 0; i < NCCS; i++)
			tprintf("\\x%02x", tios.c_cc[i]);
		tprintf("\"}");
		return 1;
#endif /* TCGETS */

#ifdef TCGETA
	case TCGETA:
		if (syserror(tcp))
			return 0;
	case TCSETA:
	case TCSETAW:
	case TCSETAF:
		if (!verbose(tcp) || umove(tcp, arg, &tio) < 0)
			return 0;
		if (abbrev(tcp)) {
			tprintf(", {");
			printxval(baud_options, tio.c_cflag & CBAUD, "B???");
			tprintf(" %sopost %sisig %sicanon %secho ...}",
				(tio.c_oflag & OPOST) ? "" : "-",
				(tio.c_lflag & ISIG) ? "" : "-",
				(tio.c_lflag & ICANON) ? "" : "-",
				(tio.c_lflag & ECHO) ? "" : "-");
			return 1;
		}
		tprintf(", {c_iflags=%#lx, c_oflags=%#lx, ",
			(long) tio.c_iflag, (long) tio.c_oflag);
		tprintf("c_cflags=%#lx, c_lflags=%#lx, ",
			(long) tio.c_cflag, (long) tio.c_lflag);
		tprintf("c_line=%u, ", tio.c_line);
#ifdef _VMIN
		if (!(tio.c_lflag & ICANON))
			tprintf("c_cc[_VMIN]=%d, c_cc[_VTIME]=%d, ",
				tio.c_cc[_VMIN], tio.c_cc[_VTIME]);
#else /* !_VMIN */
		if (!(tio.c_lflag & ICANON))
			tprintf("c_cc[VMIN]=%d, c_cc[VTIME]=%d, ",
				tio.c_cc[VMIN], tio.c_cc[VTIME]);
#endif /* !_VMIN */
		tprintf("c_cc=\"");
		for (i = 0; i < NCC; i++)
			tprintf("\\x%02x", tio.c_cc[i]);
		tprintf("\"}");
		return 1;
#endif /* TCGETA */

	/* ioctls with winsize or ttysize args */

#ifdef TIOCGWINSZ
	case TIOCGWINSZ:
		if (syserror(tcp))
			return 0;
	case TIOCSWINSZ:
		if (!verbose(tcp) || umove(tcp, arg, &ws) < 0)
			return 0;
		tprintf(", {ws_row=%d, ws_col=%d, ws_xpixel=%d, ws_ypixel=%d}",
			ws.ws_row, ws.ws_col, ws.ws_xpixel, ws.ws_ypixel);
		return 1;
#endif /* TIOCGWINSZ */

#ifdef TIOCGSIZE
	case TIOCGSIZE:
		if (syserror(tcp))
			return 0;
	case TIOCSSIZE:
		if (!verbose(tcp) || umove(tcp, arg, &ts) < 0)
			return 0;
		tprintf(", {ts_lines=%d, ts_cols=%d}",
			ts.ts_lines, ts.ts_cols);
		return 1;
#endif

	/* ioctls with a direct decodable arg */
#ifdef TCXONC
	case TCXONC:
		tprintf(", ");
		printxval(tcxonc_options, arg, "TC???");
		return 1;
#endif
#ifdef TCLFLSH
	case TCFLSH:
		tprintf(", ");
		printxval(tcflsh_options, arg, "TC???");
		return 1;
#endif

	/* ioctls with an indirect parameter displayed as modem flags */

#ifdef TIOCMGET
	case TIOCMGET:
	case TIOCMBIS:
	case TIOCMBIC:
	case TIOCMSET:
		if (umove(tcp, arg, &i) < 0)
			return 0;
		tprintf(", [");
		printflags(modem_flags, i, "TIOCM_???");
		tprintf("]");
		return 1;
#endif /* TIOCMGET */

	/* ioctls with an indirect parameter displayed in decimal */

	case TIOCSPGRP:
	case TIOCGPGRP:
#ifdef TIOCGETPGRP
	case TIOCGETPGRP:
#endif
#ifdef TIOCSETPGRP
	case TIOCSETPGRP:
#endif
#ifdef FIONREAD
	case FIONREAD:
#endif
	case TIOCOUTQ:
#ifdef FIONBIO
	case FIONBIO:
#endif
#ifdef FIOASYNC
	case FIOASYNC:
#endif
#ifdef FIOGETOWN
	case FIOGETOWN:
#endif
#ifdef FIOSETOWN
	case FIOSETOWN:
#endif
#ifdef TIOCGETD
	case TIOCGETD:
#endif
#ifdef TIOCSETD
	case TIOCSETD:
#endif
#ifdef TIOCPKT
	case TIOCPKT:
#endif
#ifdef TIOCREMOTE
	case TIOCREMOTE:
#endif
#ifdef TIOCUCNTL
	case TIOCUCNTL:
#endif
#ifdef TIOCTCNTL
	case TIOCTCNTL:
#endif
#ifdef TIOCSIGNAL
	case TIOCSIGNAL:
#endif
#ifdef TIOCSSOFTCAR
	case TIOCSSOFTCAR:
#endif
#ifdef TIOCGSOFTCAR
	case TIOCGSOFTCAR:
#endif
#ifdef TIOCISPACE
	case TIOCISPACE:
#endif
#ifdef TIOCISIZE
	case TIOCISIZE:
#endif
#ifdef TIOCSINTR
	case TIOCSINTR:
#endif
#ifdef TIOCSPTLCK
	case TIOCSPTLCK:
#endif
#ifdef TIOCGPTN
	case TIOCGPTN:
#endif
		tprintf(", ");
		printnum_int(tcp, arg, "%d");
		return 1;

	/* ioctls with an indirect parameter displayed as a char */

#ifdef TIOCSTI
	case TIOCSTI:
#endif
		tprintf(", ");
		printstr(tcp, arg, 1);
		return 1;

	/* ioctls with no parameters */

#ifdef TIOCSCTTY
	case TIOCSCTTY:
#endif
#ifdef TIOCNOTTY
	case TIOCNOTTY:
#endif
#ifdef FIOCLEX
	case FIOCLEX:
#endif
#ifdef FIONCLEX
	case FIONCLEX:
#endif
#ifdef TIOCCONS
	case TIOCCONS:
#endif
		return 1;

	/* ioctls which are unknown */

	default:
		return 0;
	}
}
int
sys_fcntl(struct tcb *tcp)
{
	if (entering(tcp)) {
		printfd(tcp, tcp->u_arg[0]);
		tprints(", ");
		printxval(fcntlcmds, tcp->u_arg[1], "F_???");
		switch (tcp->u_arg[1]) {
		case F_SETFD:
			tprints(", ");
			printflags(fdflags, tcp->u_arg[2], "FD_???");
			break;
		case F_SETOWN: case F_DUPFD:
#ifdef F_DUPFD_CLOEXEC
		case F_DUPFD_CLOEXEC:
#endif
			tprintf(", %ld", tcp->u_arg[2]);
			break;
		case F_SETFL:
			tprints(", ");
			tprint_open_modes(tcp->u_arg[2]);
			break;
		case F_SETLK: case F_SETLKW:
			tprints(", ");
			printflock(tcp, tcp->u_arg[2], 0);
			break;
#if USE_PRINTFLOCK64
		case F_SETLK64: case F_SETLKW64:
			tprints(", ");
			printflock64(tcp, tcp->u_arg[2], 0);
			break;
#endif /* USE_PRINTFLOCK64 */
#ifdef F_NOTIFY
		case F_NOTIFY:
			tprints(", ");
			printflags(notifyflags, tcp->u_arg[2], "DN_???");
			break;
#endif
#ifdef F_SETLEASE
		case F_SETLEASE:
			tprints(", ");
			printxval(lockfcmds, tcp->u_arg[2], "F_???");
			break;
#endif
		}
	}
	else {
		switch (tcp->u_arg[1]) {
		case F_DUPFD:
#ifdef F_DUPFD_CLOEXEC
		case F_DUPFD_CLOEXEC:
#endif
		case F_SETFD: case F_SETFL:
		case F_SETLK: case F_SETLKW:
		case F_SETOWN: case F_GETOWN:
#ifdef F_NOTIFY
		case F_NOTIFY:
#endif
#ifdef F_SETLEASE
		case F_SETLEASE:
#endif
			break;
		case F_GETFD:
			if (syserror(tcp) || tcp->u_rval == 0)
				return 0;
			tcp->auxstr = sprintflags("flags ", fdflags, tcp->u_rval);
			return RVAL_HEX|RVAL_STR;
		case F_GETFL:
			if (syserror(tcp))
				return 0;
			tcp->auxstr = sprint_open_modes(tcp->u_rval);
			return RVAL_HEX|RVAL_STR;
		case F_GETLK:
			tprints(", ");
			printflock(tcp, tcp->u_arg[2], 1);
			break;
#if USE_PRINTFLOCK64
		case F_GETLK64:
			tprints(", ");
			printflock64(tcp, tcp->u_arg[2], 1);
			break;
#endif
#ifdef F_GETLEASE
		case F_GETLEASE:
			if (syserror(tcp))
				return 0;
			tcp->auxstr = xlookup(lockfcmds, tcp->u_rval);
			return RVAL_HEX|RVAL_STR;
#endif
		default:
			tprintf(", %#lx", tcp->u_arg[2]);
			break;
		}
	}
	return 0;
}
Beispiel #17
0
static void
decode_cmd_data(struct tcb *tcp, u_int32_t cmd, unsigned long data)
{
	switch (cmd)
	{
		case Q_GETQUOTA:
		case Q_SETQUOTA:
		{
			struct if_dqblk dq;

			if (cmd == Q_GETQUOTA && syserror(tcp))
			{
				tprintf("%#lx", data);
				break;
			}
			if (umove(tcp, data, &dq) < 0)
			{
				tprintf("{???} %#lx", data);
				break;
			}
			tprintf("{bhardlimit=%" PRIu64 ", ", dq.dqb_bhardlimit);
			tprintf("bsoftlimit=%" PRIu64 ", ", dq.dqb_bsoftlimit);
			tprintf("curspace=%" PRIu64 ", ", dq.dqb_curspace);
			tprintf("ihardlimit=%" PRIu64 ", ", dq.dqb_ihardlimit);
			tprintf("isoftlimit=%" PRIu64 ", ", dq.dqb_isoftlimit);
			tprintf("curinodes=%" PRIu64 ", ", dq.dqb_curinodes);
			if (!abbrev(tcp))
			{
				tprintf("btime=%" PRIu64 ", ", dq.dqb_btime);
				tprintf("itime=%" PRIu64 ", ", dq.dqb_itime);
				tprintf("valid=");
				printflags(if_dqblk_valid,
					   dq.dqb_valid, "QIF_???");
				tprintf("}");
			} else
				tprintf("...}");
			break;
		}
		case Q_V1_GETQUOTA:
		case Q_V1_SETQUOTA:
		{
			struct v1_dqblk dq;

			if (cmd == Q_V1_GETQUOTA && syserror(tcp))
			{
				tprintf("%#lx", data);
				break;
			}
			if (umove(tcp, data, &dq) < 0)
			{
				tprintf("{???} %#lx", data);
				break;
			}
			tprintf("{bhardlimit=%u, ", dq.dqb_bhardlimit);
			tprintf("bsoftlimit=%u, ", dq.dqb_bsoftlimit);
			tprintf("curblocks=%u, ", dq.dqb_curblocks);
			tprintf("ihardlimit=%u, ", dq.dqb_ihardlimit);
			tprintf("isoftlimit=%u, ", dq.dqb_isoftlimit);
			tprintf("curinodes=%u, ", dq.dqb_curinodes);
			tprintf("btime=%lu, ", dq.dqb_btime);
			tprintf("itime=%lu}", dq.dqb_itime);
			break;
		}
		case Q_V2_GETQUOTA:
		case Q_V2_SETQUOTA:
		{
			struct v2_dqblk dq;

			if (cmd == Q_V2_GETQUOTA && syserror(tcp))
			{
				tprintf("%#lx", data);
				break;
			}
			if (umove(tcp, data, &dq) < 0)
			{
				tprintf("{???} %#lx", data);
				break;
			}
			tprintf("{ihardlimit=%u, ", dq.dqb_ihardlimit);
			tprintf("isoftlimit=%u, ", dq.dqb_isoftlimit);
			tprintf("curinodes=%u, ", dq.dqb_curinodes);
			tprintf("bhardlimit=%u, ", dq.dqb_bhardlimit);
			tprintf("bsoftlimit=%u, ", dq.dqb_bsoftlimit);
			tprintf("curspace=%" PRIu64 ", ", dq.dqb_curspace);
			tprintf("btime=%lu, ", dq.dqb_btime);
			tprintf("itime=%lu}", dq.dqb_itime);
			break;
		}
		case Q_XGETQUOTA:
		case Q_XSETQLIM:
		{
			struct xfs_dqblk dq;

			if (cmd == Q_XGETQUOTA && syserror(tcp))
			{
				tprintf("%#lx", data);
				break;
			}
			if (umove(tcp, data, &dq) < 0)
			{
				tprintf("{???} %#lx", data);
				break;
			}
			tprintf("{version=%d, ", dq.d_version);
			tprintf("flags=");
			printflags(xfs_dqblk_flags,
				   dq.d_flags, "XFS_???_QUOTA");
			tprintf(", fieldmask=%#x, ", dq.d_fieldmask);
			tprintf("id=%u, ", dq.d_id);
			tprintf("blk_hardlimit=%" PRIu64 ", ", dq.d_blk_hardlimit);
			tprintf("blk_softlimit=%" PRIu64 ", ", dq.d_blk_softlimit);
			tprintf("ino_hardlimit=%" PRIu64 ", ", dq.d_ino_hardlimit);
			tprintf("ino_softlimit=%" PRIu64 ", ", dq.d_ino_softlimit);
			tprintf("bcount=%" PRIu64 ", ", dq.d_bcount);
			tprintf("icount=%" PRIu64 ", ", dq.d_icount);
			if (!abbrev(tcp))
			{
				tprintf("itimer=%d, ", dq.d_itimer);
				tprintf("btimer=%d, ", dq.d_btimer);
				tprintf("iwarns=%u, ", dq.d_iwarns);
				tprintf("bwarns=%u, ", dq.d_bwarns);
				tprintf("rtbcount=%" PRIu64 ", ", dq.d_rtbcount);
				tprintf("rtbtimer=%d, ", dq.d_rtbtimer);
				tprintf("rtbwarns=%u}", dq.d_rtbwarns);
			} else
				tprintf("...}");
			break;
		}
		case Q_GETFMT:
		{
			u_int32_t fmt;

			if (syserror(tcp))
			{
				tprintf("%#lx", data);
				break;
			}
			if (umove(tcp, data, &fmt) < 0)
			{
				tprintf("{???} %#lx", data);
				break;
			}
			tprintf("{");
			printxval(quota_formats, fmt, "QFMT_VFS_???");
			tprintf("}");
			break;
		}
		case Q_GETINFO:
		case Q_SETINFO:
		{
			struct if_dqinfo dq;

			if (cmd == Q_GETINFO && syserror(tcp))
			{
				tprintf("%#lx", data);
				break;
			}
			if (umove(tcp, data, &dq) < 0)
			{
				tprintf("{???} %#lx", data);
				break;
			}
			tprintf("{bgrace=%" PRIu64 ", ", dq.dqi_bgrace);
			tprintf("igrace=%" PRIu64 ", ", dq.dqi_igrace);
			tprintf("flags=%#x, ", dq.dqi_flags);
			tprintf("valid=");
			printflags(if_dqinfo_valid, dq.dqi_valid, "IIF_???");
			tprintf("}");
			break;
		}
		case Q_V2_GETINFO:
		case Q_V2_SETINFO:
		{
			struct v2_dqinfo dq;

			if (cmd == Q_V2_GETINFO && syserror(tcp))
			{
				tprintf("%#lx", data);
				break;
			}
			if (umove(tcp, data, &dq) < 0)
			{
				tprintf("{???} %#lx", data);
				break;
			}
			tprintf("{bgrace=%u, ", dq.dqi_bgrace);
			tprintf("igrace=%u, ", dq.dqi_igrace);
			tprintf("flags=%#x, ", dq.dqi_flags);
			tprintf("blocks=%u, ", dq.dqi_blocks);
			tprintf("free_blk=%u, ", dq.dqi_free_blk);
			tprintf("free_entry=%u}", dq.dqi_free_entry);
			break;
		}
		case Q_V1_GETSTATS:
		{
			struct v1_dqstats dq;

			if (syserror(tcp))
			{
				tprintf("%#lx", data);
				break;
			}
			if (umove(tcp, data, &dq) < 0)
			{
				tprintf("{???} %#lx", data);
				break;
			}
			tprintf("{lookups=%u, ", dq.lookups);
			tprintf("drops=%u, ", dq.drops);
			tprintf("reads=%u, ", dq.reads);
			tprintf("writes=%u, ", dq.writes);
			tprintf("cache_hits=%u, ", dq.cache_hits);
			tprintf("allocated_dquots=%u, ", dq.allocated_dquots);
			tprintf("free_dquots=%u, ", dq.free_dquots);
			tprintf("syncs=%u}", dq.syncs);
			break;
		}
		case Q_V2_GETSTATS:
		{
			struct v2_dqstats dq;

			if (syserror(tcp))
			{
				tprintf("%#lx", data);
				break;
			}
			if (umove(tcp, data, &dq) < 0)
			{
				tprintf("{???} %#lx", data);
				break;
			}
			tprintf("{lookups=%u, ", dq.lookups);
			tprintf("drops=%u, ", dq.drops);
			tprintf("reads=%u, ", dq.reads);
			tprintf("writes=%u, ", dq.writes);
			tprintf("cache_hits=%u, ", dq.cache_hits);
			tprintf("allocated_dquots=%u, ", dq.allocated_dquots);
			tprintf("free_dquots=%u, ", dq.free_dquots);
			tprintf("syncs=%u, ", dq.syncs);
			tprintf("version=%u}", dq.version);
			break;
		}
		case Q_XGETQSTAT:
		{
			struct xfs_dqstats dq;

			if (syserror(tcp))
			{
				tprintf("%#lx", data);
				break;
			}
			if (umove(tcp, data, &dq) < 0)
			{
				tprintf("{???} %#lx", data);
				break;
			}
			tprintf("{version=%d, ", dq.qs_version);
			if (abbrev(tcp))
			{
				tprintf("...}");
				break;
			}
			tprintf("flags=");
			printflags(xfs_quota_flags,
				   dq.qs_flags, "XFS_QUOTA_???");
			tprintf(", incoredqs=%u, ", dq.qs_incoredqs);
			tprintf("u_ino=%" PRIu64 ", ", dq.qs_uquota.qfs_ino);
			tprintf("u_nblks=%" PRIu64 ", ", dq.qs_uquota.qfs_nblks);
			tprintf("u_nextents=%u, ", dq.qs_uquota.qfs_nextents);
			tprintf("g_ino=%" PRIu64 ", ", dq.qs_gquota.qfs_ino);
			tprintf("g_nblks=%" PRIu64 ", ", dq.qs_gquota.qfs_nblks);
			tprintf("g_nextents=%u, ", dq.qs_gquota.qfs_nextents);
			tprintf("btimelimit=%d, ", dq.qs_btimelimit);
			tprintf("itimelimit=%d, ", dq.qs_itimelimit);
			tprintf("rtbtimelimit=%d, ", dq.qs_rtbtimelimit);
			tprintf("bwarnlimit=%u, ", dq.qs_bwarnlimit);
			tprintf("iwarnlimit=%u}", dq.qs_iwarnlimit);
			break;
		}
		case Q_XQUOTAON:
		{
			u_int32_t flag;

			if (umove(tcp, data, &flag) < 0)
			{
				tprintf("{???} %#lx", data);
				break;
			}
			tprintf("{");
			printflags(xfs_quota_flags, flag, "XFS_QUOTA_???");
			tprintf("}");
			break;
		}
		default:
			tprintf("%#lx", data);
			break;
	}
}
Beispiel #18
0
int
sys_fcntl(struct tcb *tcp)
{
	if (entering(tcp)) {
		tprintf("%ld, ", tcp->u_arg[0]);
		printxval(fcntlcmds, tcp->u_arg[1], "F_???");
		switch (tcp->u_arg[1]) {
		case F_SETFD:
			tprintf(", ");
			printflags(fdflags, tcp->u_arg[2], "FD_???");
			break;
		case F_SETOWN: case F_DUPFD:
#ifdef F_DUPFD_CLOEXEC
		case F_DUPFD_CLOEXEC:
#endif
			tprintf(", %ld", tcp->u_arg[2]);
			break;
		case F_SETFL:
			tprintf(", ");
			tprint_open_modes(tcp->u_arg[2]);
			break;
		case F_SETLK: case F_SETLKW:
#ifdef F_FREESP
		case F_FREESP:
#endif
			tprintf(", ");
			printflock(tcp, tcp->u_arg[2], 0);
			break;
#if _LFS64_LARGEFILE
#ifdef F_FREESP64
		case F_FREESP64:
#endif
		/* Linux glibc defines SETLK64 as SETLK,
		   even though the kernel has different values - as does Solaris. */
#if defined(F_SETLK64) && F_SETLK64 + 0 != F_SETLK
		case F_SETLK64:
#endif
#if defined(F_SETLKW64) && F_SETLKW64 + 0 != F_SETLKW
		case F_SETLKW64:
#endif
			tprintf(", ");
			printflock64(tcp, tcp->u_arg[2], 0);
			break;
#endif
#ifdef F_NOTIFY
		case F_NOTIFY:
			tprintf(", ");
			printflags(notifyflags, tcp->u_arg[2], "DN_???");
			break;
#endif
#ifdef F_SETLEASE
		case F_SETLEASE:
			tprintf(", ");
			printxval(lockfcmds, tcp->u_arg[2], "F_???");
			break;
#endif
		}
	}
	else {
		switch (tcp->u_arg[1]) {
		case F_DUPFD:
#ifdef F_DUPFD_CLOEXEC
		case F_DUPFD_CLOEXEC:
#endif
		case F_SETFD: case F_SETFL:
		case F_SETLK: case F_SETLKW:
		case F_SETOWN: case F_GETOWN:
#ifdef F_NOTIFY
		case F_NOTIFY:
#endif
#ifdef F_SETLEASE
		case F_SETLEASE:
#endif
			break;
		case F_GETFD:
			if (syserror(tcp) || tcp->u_rval == 0)
				return 0;
			tcp->auxstr = sprintflags("flags ", fdflags, tcp->u_rval);
			return RVAL_HEX|RVAL_STR;
		case F_GETFL:
			if (syserror(tcp))
				return 0;
			tcp->auxstr = sprint_open_modes(tcp->u_rval);
			return RVAL_HEX|RVAL_STR;
		case F_GETLK:
			tprintf(", ");
			printflock(tcp, tcp->u_arg[2], 1);
			break;
#if _LFS64_LARGEFILE
#if defined(F_GETLK64) && F_GETLK64+0!=F_GETLK
		case F_GETLK64:
#endif
			tprintf(", ");
			printflock64(tcp, tcp->u_arg[2], 1);
			break;
#endif
#ifdef F_GETLEASE
		case F_GETLEASE:
			if (syserror(tcp))
				return 0;
			tcp->auxstr = xlookup(lockfcmds, tcp->u_rval);
			return RVAL_HEX|RVAL_STR;
#endif
		default:
			tprintf(", %#lx", tcp->u_arg[2]);
			break;
		}
	}
	return 0;
}
Beispiel #19
0
static void
decode_old_sigaction(struct tcb *tcp, long addr)
{
	struct old_sigaction sa;
	int r;

	if (!addr) {
		tprints("NULL");
		return;
	}
	if (!verbose(tcp) || (exiting(tcp) && syserror(tcp))) {
		tprintf("%#lx", addr);
		return;
	}

#if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
	if (current_wordsize != sizeof(sa.__sa_handler) && current_wordsize == 4) {
		struct old_sigaction32 sa32;
		r = umove(tcp, addr, &sa32);
		if (r >= 0) {
			memset(&sa, 0, sizeof(sa));
			sa.__sa_handler = (void*)(uintptr_t)sa32.__sa_handler;
			sa.sa_flags = sa32.sa_flags;
			sa.sa_restorer = (void*)(uintptr_t)sa32.sa_restorer;
			sa.sa_mask = sa32.sa_mask;
		}
	} else
#endif
	{
		r = umove(tcp, addr, &sa);
	}
	if (r < 0) {
		tprints("{...}");
		return;
	}

	/* Architectures using function pointers, like
	 * hppa, may need to manipulate the function pointer
	 * to compute the result of a comparison. However,
	 * the __sa_handler function pointer exists only in
	 * the address space of the traced process, and can't
	 * be manipulated by strace. In order to prevent the
	 * compiler from generating code to manipulate
	 * __sa_handler we cast the function pointers to long. */
	if ((long)sa.__sa_handler == (long)SIG_ERR)
		tprints("{SIG_ERR, ");
	else if ((long)sa.__sa_handler == (long)SIG_DFL)
		tprints("{SIG_DFL, ");
	else if ((long)sa.__sa_handler == (long)SIG_IGN)
		tprints("{SIG_IGN, ");
	else
		tprintf("{%#lx, ", (long) sa.__sa_handler);
#ifdef MIPS
	tprintsigmask_addr("", sa.sa_mask);
#else
	tprintsigmask_val("", sa.sa_mask);
#endif
	tprints(", ");
	printflags(sigact_flags, sa.sa_flags, "SA_???");
#ifdef SA_RESTORER
	if (sa.sa_flags & SA_RESTORER)
		tprintf(", %p", sa.sa_restorer);
#endif
	tprints("}");
}
Beispiel #20
0
int
ptp_ioctl(struct tcb *tcp, const unsigned int code, long arg)
{
	if (!verbose(tcp))
		return 0;

	switch (code) {
		case PTP_CLOCK_GETCAPS: /* decode on exit */
		{
			struct ptp_clock_caps caps;

			if (entering(tcp) || syserror(tcp) ||
			    umove(tcp, arg, &caps) < 0)
				return 0;

			tprintf(", {max_adj=%d, n_alarm=%d, n_ext_ts=%d, n_per_out=%d, pps=%d}",
				caps.max_adj, caps.n_alarm, caps.n_ext_ts,
				caps.n_per_out, caps.pps);
			return 1;
		}

		case PTP_EXTTS_REQUEST: /* decode on enter */
		{
			struct ptp_extts_request extts;

			if (exiting(tcp))
				return 1;
			if (umove(tcp, arg, &extts) < 0) {
				tprintf(", %#lx", arg);
				return 0;
			}
			tprintf(", {index=%d, flags=", extts.index);
			printflags(ptp_flags_options, extts.flags, "PTP_???");
			tprints("}");
			return 1;
		}

		case PTP_PEROUT_REQUEST: /* decode on enter */
		{
			struct ptp_perout_request perout;

			if (exiting(tcp))
				return 1;
			if (umove(tcp, arg, &perout) < 0) {
				tprintf(", %#lx", arg);
				return 0;
			}

			tprintf(", {start={%" PRId64 ", %" PRIu32 "}"
				   ", period={%" PRId64 ", %" PRIu32 "}"
				   ", index=%d, flags=",
				(int64_t)perout.start.sec, perout.start.nsec,
				(int64_t)perout.period.sec, perout.period.nsec,
				perout.index);
			printflags(ptp_flags_options, perout.flags, "PTP_???");
			tprints("}");
			return 1;
		}

		case PTP_ENABLE_PPS: /* decode on enter */
			if (entering(tcp))
				tprintf(", %ld", arg);
			return 1;

		case PTP_SYS_OFFSET: /* decode on exit */
		{
			struct ptp_sys_offset sysoff;
			unsigned int i;

			if (entering(tcp) || umove(tcp, arg, &sysoff) < 0)
				return 0;

			tprintf(", {n_samples=%u, ts={", sysoff.n_samples);
			if (syserror(tcp)) {
				tprints("...}}");
				return 1;
			}
			if (sysoff.n_samples > PTP_MAX_SAMPLES)
				sysoff.n_samples = PTP_MAX_SAMPLES;
			tprintf("{%" PRId64 ", %" PRIu32 "}",
				(int64_t)sysoff.ts[0].sec, sysoff.ts[0].nsec);
			for (i = 1; i < 2*sysoff.n_samples+1; ++i)
				tprintf(", {%" PRId64 ", %" PRIu32 "}",
					(int64_t)sysoff.ts[i].sec, sysoff.ts[i].nsec);
			tprints("}}");
			return 1;
		}

		default: /* decode on exit */
			return 0;
	}
}
Beispiel #21
0
int
mtd_ioctl(struct tcb *tcp, const unsigned int code, const long arg)
{
	if (!verbose(tcp))
		return RVAL_DECODED;

	switch (code) {
	case MEMERASE:
	case MEMLOCK:
	case MEMUNLOCK:
	case MEMISLOCKED: {
		struct erase_info_user einfo;

		tprints(", ");
		if (umove_or_printaddr(tcp, arg, &einfo))
			break;

		tprintf("{start=%#" PRIx32 ", length=%#" PRIx32 "}",
			einfo.start, einfo.length);
		break;
	}

	case MEMERASE64: {
		struct erase_info_user64 einfo64;

		tprints(", ");
		if (umove_or_printaddr(tcp, arg, &einfo64))
			break;

		tprintf("{start=%#" PRIx64 ", length=%#" PRIx64 "}",
			(uint64_t) einfo64.start, (uint64_t) einfo64.length);
		break;
	}

	case MEMWRITEOOB:
	case MEMREADOOB: {
		struct mtd_oob_buf mbuf;

		tprints(", ");
		if (umove_or_printaddr(tcp, arg, &mbuf))
			break;

		tprintf("{start=%#" PRIx32 ", length=%#" PRIx32 ", ptr=...}",
			mbuf.start, mbuf.length);
		break;
	}

	case MEMWRITEOOB64:
	case MEMREADOOB64: {
		struct mtd_oob_buf64 mbuf64;

		tprints(", ");
		if (umove_or_printaddr(tcp, arg, &mbuf64))
			break;

		tprintf("{start=%#" PRIx64 ", length=%#" PRIx64 ", ptr=...}",
			(uint64_t) mbuf64.start, (uint64_t) mbuf64.length);
		break;
	}

	case MEMGETREGIONINFO: {
		struct region_info_user rinfo;

		if (entering(tcp)) {
			tprints(", ");
			if (umove_or_printaddr(tcp, arg, &rinfo))
				break;
			tprintf("{regionindex=%#x", rinfo.regionindex);
			return 1;
		} else {
			if (syserror(tcp)) {
				tprints("}");
				break;
			}
			if (umove(tcp, arg, &rinfo) < 0) {
				tprints(", ???}");
				break;
			}
			tprintf(", offset=%#x, erasesize=%#x, numblocks=%#x}",
				rinfo.offset, rinfo.erasesize, rinfo.numblocks);
			break;
		}
	}

	case OTPLOCK: {
		struct otp_info oinfo;

		tprints(", ");
		if (umove_or_printaddr(tcp, arg, &oinfo))
			break;

		tprintf("{start=%#" PRIx32 ", length=%#" PRIx32 ", locked=%" PRIu32 "}",
			oinfo.start, oinfo.length, oinfo.locked);
		break;
	}

	case MEMWRITE: {
		struct mtd_write_req mreq;

		tprints(", ");
		if (umove_or_printaddr(tcp, arg, &mreq))
			break;

		tprintf("{start=%#" PRIx64 ", len=%#" PRIx64,
			(uint64_t) mreq.start, (uint64_t) mreq.len);
		tprintf(", ooblen=%#" PRIx64 ", usr_data=%#" PRIx64,
			(uint64_t) mreq.ooblen, (uint64_t) mreq.usr_data);
		tprintf(", usr_oob=%#" PRIx64 ", mode=",
			(uint64_t) mreq.usr_oob);
		printxval(mtd_mode_options, mreq.mode, "MTD_OPS_???");
		tprints(", padding=...}");
		break;
	}

	case OTPSELECT: {
		unsigned int i;

		tprints(", ");
		if (umove_or_printaddr(tcp, arg, &i))
			break;

		tprints("[");
		printxval(mtd_otp_options, i, "MTD_OTP_???");
		tprints("]");
		break;
	}

	case MTDFILEMODE:
		tprints(", ");
		printxval(mtd_file_mode_options, arg, "MTD_FILE_MODE_???");
		break;

	case MEMGETBADBLOCK:
	case MEMSETBADBLOCK:
		tprints(", ");
		print_loff_t(tcp, arg);
		break;

	case MEMGETINFO: {
		struct mtd_info_user minfo;

		if (entering(tcp))
			return 0;

		tprints(", ");
		if (umove_or_printaddr(tcp, arg, &minfo))
			break;

		tprints("{type=");
		printxval(mtd_type_options, minfo.type, "MTD_???");
		tprints(", flags=");
		printflags(mtd_flags_options, minfo.flags, "MTD_???");
		tprintf(", size=%#" PRIx32 ", erasesize=%#" PRIx32,
			minfo.size, minfo.erasesize);
		tprintf(", writesize=%#" PRIx32 ", oobsize=%#" PRIx32,
			minfo.writesize, minfo.oobsize);
		tprintf(", padding=%#" PRIx64 "}",
			(uint64_t) minfo.padding);
		break;
	}

	case MEMGETOOBSEL: {
		struct nand_oobinfo ninfo;
		unsigned int i;

		if (entering(tcp))
			return 0;

		tprints(", ");
		if (umove_or_printaddr(tcp, arg, &ninfo))
			break;

		tprints("{useecc=");
		printxval(mtd_nandecc_options, ninfo.useecc, "MTD_NANDECC_???");
		tprintf(", eccbytes=%#" PRIx32, ninfo.eccbytes);

		tprints(", oobfree={");
		for (i = 0; i < ARRAY_SIZE(ninfo.oobfree); ++i) {
			unsigned int j;

			if (i)
				tprints("}, ");
			tprints("{");
			for (j = 0; j < ARRAY_SIZE(ninfo.oobfree[0]); ++j) {
				if (j)
					tprints(", ");
				tprintf("%#" PRIx32, ninfo.oobfree[i][j]);
			}
		}

		tprints("}}, eccpos={");
		for (i = 0; i < ARRAY_SIZE(ninfo.eccpos); ++i) {
			if (i)
				tprints(", ");
			tprintf("%#" PRIx32, ninfo.eccpos[i]);
		}

		tprints("}");
		break;
	}

	case OTPGETREGIONINFO: {
		struct otp_info oinfo;

		if (entering(tcp))
			return 0;

		tprints(", ");
		if (umove_or_printaddr(tcp, arg, &oinfo))
			break;

		tprintf("{start=%#" PRIx32 ", length=%#" PRIx32 ", locked=%" PRIu32 "}",
			oinfo.start, oinfo.length, oinfo.locked);
		break;
	}

	case ECCGETLAYOUT: {
		struct nand_ecclayout_user nlay;
		unsigned int i;

		if (entering(tcp))
			return 0;

		tprints(", ");
		if (umove_or_printaddr(tcp, arg, &nlay))
			break;

		tprintf("{eccbytes=%#" PRIx32 ", eccpos={", nlay.eccbytes);
		for (i = 0; i < ARRAY_SIZE(nlay.eccpos); ++i) {
			if (i)
				tprints(", ");
			tprintf("%#" PRIx32, nlay.eccpos[i]);
		}
		tprintf("}, oobavail=%#" PRIx32 ", oobfree={", nlay.oobavail);
		for (i = 0; i < ARRAY_SIZE(nlay.oobfree); ++i) {
			if (i)
				tprints(", ");
			tprintf("{offset=%#" PRIx32 ", length=%#" PRIx32 "}",
				nlay.oobfree[i].offset, nlay.oobfree[i].length);
		}
		tprints("}");
		break;
	}

	case ECCGETSTATS: {
		struct mtd_ecc_stats estat;

		if (entering(tcp))
			return 0;

		tprints(", ");
		if (umove_or_printaddr(tcp, arg, &estat))
			break;

		tprintf("{corrected=%#" PRIx32 ", failed=%#" PRIx32,
			estat.corrected, estat.failed);
		tprintf(", badblocks=%#" PRIx32 ", bbtblocks=%#" PRIx32 "}",
			estat.badblocks, estat.bbtblocks);
		break;
	}

	case OTPGETREGIONCOUNT:
		if (entering(tcp))
			return 0;

		tprints(", ");
		printnum_int(tcp, arg, "%u");
		break;

	case MEMGETREGIONCOUNT:
		if (entering(tcp))
			return 0;

		tprints(", ");
		printnum_int(tcp, arg, "%d");
		break;

	default:
		return RVAL_DECODED;
	}

	return RVAL_DECODED | 1;
}
Beispiel #22
0
int
sys_move_pages(struct tcb *tcp)
{
	if (entering(tcp)) {
		unsigned long npages = tcp->u_arg[1];
		tprintf("%ld, %lu, ", tcp->u_arg[0], npages);
		if (tcp->u_arg[2] == 0)
			tprints("NULL, ");
		else {
			unsigned int i;
			long puser = tcp->u_arg[2];
			tprints("{");
			for (i = 0; i < npages; ++i) {
				void *p;
				if (i > 0)
					tprints(", ");
				if (umove(tcp, puser, &p) < 0) {
					tprints("???");
					break;
				}
				tprintf("%p", p);
				puser += sizeof(void *);
			}
			tprints("}, ");
		}
		if (tcp->u_arg[3] == 0)
			tprints("NULL, ");
		else {
			unsigned int i;
			long nodeuser = tcp->u_arg[3];
			tprints("{");
			for (i = 0; i < npages; ++i) {
				int node;
				if (i > 0)
					tprints(", ");
				if (umove(tcp, nodeuser, &node) < 0) {
					tprints("???");
					break;
				}
				tprintf("%#x", node);
				nodeuser += sizeof(int);
			}
			tprints("}, ");
		}
	}
	if (exiting(tcp)) {
		unsigned long npages = tcp->u_arg[1];
		if (tcp->u_arg[4] == 0)
			tprints("NULL, ");
		else {
			unsigned int i;
			long statususer = tcp->u_arg[4];
			tprints("{");
			for (i = 0; i < npages; ++i) {
				int status;
				if (i > 0)
					tprints(", ");
				if (umove(tcp, statususer, &status) < 0) {
					tprints("???");
					break;
				}
				tprintf("%#x", status);
				statususer += sizeof(int);
			}
			tprints("}, ");
		}
		printflags(move_pages_flags, tcp->u_arg[5], "MPOL_???");
	}
	return 0;
}
void printdata()
{
	int fi=0 , fj=0;			
	struct stream *stream_print;
	struct packet *packet_print;
	stream_print=stream_head;
	while(stream_print != NULL)
	{
		//printf("indise printdata");		
		printf("\n\nst_no=%d ",stream_print->st_no);
		printf("\tsrc_ip=%s ",stream_print->src_ip);
		printf("\tsrc_port=%d ",stream_print->src_port);
		printf("\t dest_ip=%s ",stream_print->dst_ip);	
		printf("\tdest_port=%d \n",stream_print->dst_port);
	

	if(d_value!=0)
	{
		packet_print=stream_print->link;
		while(packet_print != NULL )
		{

			printf(" %s ",packet_print->timestamp);				
			
			//strcpy(f,packet_print->flags)
			fi=0 , fj=0;			
			for(fi=3;fi<6;fi++)
			{
				s[fj]=packet_print->flags[fi];
				fj++;
			}
			s[fj]='\0';
			//fi=atoi(f)						
//			printf("f %cis %c ds%cf",s[0] ,s[1],s[2]);			
			printflags();
			printf("seq=%d  ",packet_print->seq_no);
			printf("acq=%d ",packet_print->acq_no);
			printf("len=%d  ",packet_print->hdr_len);
			//printf("flags=%s ",packet_print->flags);
			printf("win=%d  ",packet_print->win_size);
			//printf("win_size_cal=%d ",packet_print->win_size_cal);
			printf("scale=%d ",packet_print->win_scale);
			printf("nxt_seq=%d  ",packet_print->nxt_seq);
			//printf("dup_ack=%d  ",packet_print->dup_ack);
			//printf("dup_ack_num=%d ",packet_print->dup_ack_num);
		//	printf(" %s   ",packet_print->expert_msg);
			//printf(" %s   ",packet_print->timestamp);				
			if(!strcmp(packet_print->rx_num,"client"))			
			{
				printf("==>> ");			
			}
			else if(!strcmp(packet_print->rx_num,"server"))			
			{
				printf("<<== ");			
			}
						
			printf("\n");
			//printf("lpcb no=%s \n",packet_print->lpcb_no);
				
			packet_print=packet_print->next;
		}
		
	}	stream_print=stream_print->snext;
		
	}

}	
Beispiel #24
0
int loop_ioctl(struct tcb *tcp, long code, long arg)
{
	struct loop_info info;
	struct loop_info64 info64;
	char *s = (char*)alloca((LO_NAME_SIZE + LO_KEY_SIZE) * 4);

	if (entering(tcp))
		return 0;

	switch (code) {

	case LOOP_SET_STATUS:
	case LOOP_GET_STATUS:
		if (!verbose(tcp) || umove(tcp, arg, &info) < 0)
			return 0;

		tprintf(", {number=%d", info.lo_number);

		if (!abbrev(tcp)) {
			tprintf(", device=%#lx, inode=%lu, rdevice=%#lx",
				(unsigned long) info.lo_device,
				info.lo_inode,
				(unsigned long) info.lo_rdevice);
		}

		tprintf(", offset=%#x", info.lo_offset);

		if (!abbrev(tcp) || info.lo_encrypt_type != LO_CRYPT_NONE) {
			tprints(", encrypt_type=");
			printxval(loop_crypt_type_options, info.lo_encrypt_type,
				"LO_CRYPT_???");
			tprintf(", encrypt_key_size=%d", info.lo_encrypt_key_size);
		}

		tprints(", flags=");
		printflags(loop_flags_options, info.lo_flags, "LO_FLAGS_???");

		string_quote(info.lo_name, s, -1, LO_NAME_SIZE);
		tprintf(", name=%s", s);

		if (!abbrev(tcp) || info.lo_encrypt_type != LO_CRYPT_NONE) {
			string_quote((const char*) info.lo_encrypt_key, s, 0, LO_KEY_SIZE);
			tprintf(", encrypt_key=%s", s);
		}

		if (!abbrev(tcp))
			tprintf(", init={%#lx, %#lx}"
				", reserved={%#x, %#x, %#x, %#x}}",
				info.lo_init[0], info.lo_init[1],
				info.reserved[0], info.reserved[1],
				info.reserved[2], info.reserved[3]);
		else
			tprints(", ...}");

		return 1;

	case LOOP_SET_STATUS64:
	case LOOP_GET_STATUS64:
		if (!verbose(tcp) || umove(tcp, arg, &info64) < 0)
			return 0;

		tprints(", {");

		if (!abbrev(tcp)) {
			tprintf("device=%" PRIu64 ", inode=%" PRIu64 ", "
				"rdevice=%" PRIu64 ", offset=%#" PRIx64 ", "
				"sizelimit=%" PRIu64 ", number=%" PRIu32,
				(uint64_t) info64.lo_device,
				(uint64_t) info64.lo_inode,
				(uint64_t) info64.lo_rdevice,
				(uint64_t) info64.lo_offset,
				(uint64_t) info64.lo_sizelimit,
				(uint32_t) info64.lo_number);
		} else {
			tprintf("offset=%#" PRIx64 ", number=%" PRIu32,
				(uint64_t) info64.lo_offset,
				(uint32_t) info64.lo_number);
		}

		if (!abbrev(tcp) || info64.lo_encrypt_type != LO_CRYPT_NONE) {
			tprints(", encrypt_type=");
			printxval(loop_crypt_type_options, info64.lo_encrypt_type,
				"LO_CRYPT_???");
			tprintf(", encrypt_key_size=%" PRIu32,
				info64.lo_encrypt_key_size);
		}

		tprints(", flags=");
		printflags(loop_flags_options, info64.lo_flags, "LO_FLAGS_???");

		string_quote((const char*) info64.lo_file_name, s, -1, LO_NAME_SIZE);
		tprintf(", file_name=%s", s);

		if (!abbrev(tcp) || info64.lo_encrypt_type != LO_CRYPT_NONE) {
			string_quote((const char*) info64.lo_crypt_name, s, -1, LO_NAME_SIZE);
			tprintf(", crypt_name=%s", s);
			string_quote((const char*) info64.lo_encrypt_key, s, 0, LO_KEY_SIZE);
			tprintf(", encrypt_key=%s", s);
		}

		if (!abbrev(tcp))
			tprintf(", init={%#" PRIx64 ", %#" PRIx64 "}}",
				(uint64_t) info64.lo_init[0],
				(uint64_t) info64.lo_init[1]);
		else
			tprints(", ...}");

		return 1;

	case LOOP_CLR_FD:
#ifdef LOOP_SET_CAPACITY
	case LOOP_SET_CAPACITY:
#endif
#ifdef LOOP_CTL_GET_FREE
	/* newer loop-control stuff */
	case LOOP_CTL_GET_FREE:
#endif
		/* Takes no arguments */
		return 1;

	case LOOP_SET_FD:
	case LOOP_CHANGE_FD:
#ifdef LOOP_CTL_ADD
	/* newer loop-control stuff */
	case LOOP_CTL_ADD:
	case LOOP_CTL_REMOVE:
#endif
		/* These take simple args, so let default printer handle it */

	default:
		return 0;
	}
}
Beispiel #25
0
int
proc_ioctl(struct tcb *tcp, int code, int arg)
{
	int val;
	prstatus_t status;
	prrun_t run;

	if (entering(tcp))
		return 0;

	switch (code) {
	case PIOCSTATUS:
	case PIOCSTOP:
	case PIOCWSTOP:
		if (arg == 0)
			tprintf(", NULL");
		else if (syserror(tcp))
			tprintf(", %#x", arg);
		else if (umove(tcp, arg, &status) < 0)
			tprintf(", {...}");
		else {
			tprintf(", {pr_flags=");
			printflags(proc_status_flags, status.pr_flags, "PR_???");
			if (status.pr_why) {
				tprintf(", pr_why=");
				printxval(proc_status_why, status.pr_why,
					  "PR_???");
			}
			switch (status.pr_why) {
			case PR_SIGNALLED:
			case PR_JOBCONTROL:
				tprintf(", pr_what=");
				printsignal(status.pr_what);
				break;
			case PR_FAULTED:
				tprintf(", pr_what=%d", status.pr_what);
				break;
			case PR_SYSENTRY:
			case PR_SYSEXIT:
				tprintf(", pr_what=SYS_%s",
					sysent[status.pr_what].sys_name);
				break;
			}
			tprintf(", ...}");
		}
		return 1;
	case PIOCRUN:
		if (arg == 0)
			tprintf(", NULL");
		else if (umove(tcp, arg, &run) < 0)
			tprintf(", {...}");
		else {
			tprintf(", {pr_flags=");
			printflags(proc_run_flags, run.pr_flags, "PR???");
			tprintf(", ...}");
		}
		return 1;
#ifdef PIOCSET
	case PIOCSET:
	case PIOCRESET:
		if (umove(tcp, arg, &val) < 0)
			tprintf(", [?]");
		else {
			tprintf(", [");
			printflags(proc_status_flags, val, "PR_???");
			tprintf("]");
		}
		return 1;
#endif /* PIOCSET */
	case PIOCKILL:
	case PIOCUNKILL:
		/* takes a pointer to a signal */
		if (umove(tcp, arg, &val) < 0)
			tprintf(", [?]");
		else {
			tprintf(", [");
			printsignal(val);
			tprintf("]");
		}
		return 1;
	case PIOCSFORK:
	case PIOCRFORK:
	case PIOCSRLC:
	case PIOCRRLC:
		/* doesn't take an arg */
		return 1;
	default:
		/* ad naseum */
		return 0;
	}
}
Beispiel #26
0
static void
print_ifreq(struct tcb *const tcp, const unsigned int code,
	    const kernel_ulong_t arg, const struct_ifreq *const ifr)
{
	switch (code) {
	case SIOCSIFADDR:
	case SIOCGIFADDR:
		PRINT_IFREQ_ADDR(tcp, ifr, ifr_addr);
		break;
	case SIOCSIFDSTADDR:
	case SIOCGIFDSTADDR:
		PRINT_IFREQ_ADDR(tcp, ifr, ifr_dstaddr);
		break;
	case SIOCSIFBRDADDR:
	case SIOCGIFBRDADDR:
		PRINT_IFREQ_ADDR(tcp, ifr, ifr_broadaddr);
		break;
	case SIOCSIFNETMASK:
	case SIOCGIFNETMASK:
		PRINT_IFREQ_ADDR(tcp, ifr, ifr_netmask);
		break;
	case SIOCSIFHWADDR:
	case SIOCGIFHWADDR: {
		/* XXX Are there other hardware addresses
		   than 6-byte MACs?  */
		const unsigned char *bytes =
			(unsigned char *) &ifr->ifr_hwaddr.sa_data;
		tprintf("ifr_hwaddr=%02x:%02x:%02x:%02x:%02x:%02x",
			bytes[0], bytes[1], bytes[2],
			bytes[3], bytes[4], bytes[5]);
		break;
	}
	case SIOCSIFFLAGS:
	case SIOCGIFFLAGS:
		tprints("ifr_flags=");
		printflags(iffflags, (unsigned short) ifr->ifr_flags, "IFF_???");
		break;
	case SIOCSIFMETRIC:
	case SIOCGIFMETRIC:
		tprintf("ifr_metric=%d", ifr->ifr_metric);
		break;
	case SIOCSIFMTU:
	case SIOCGIFMTU:
		tprintf("ifr_mtu=%d", ifr->ifr_mtu);
		break;
	case SIOCSIFSLAVE:
	case SIOCGIFSLAVE:
		tprints("ifr_slave=");
		print_ifname(ifr->ifr_slave);
		break;
	case SIOCSIFTXQLEN:
	case SIOCGIFTXQLEN:
		tprintf("ifr_qlen=%d", ifr->ifr_qlen);
		break;
	case SIOCSIFMAP:
	case SIOCGIFMAP:
		tprintf("ifr_map={mem_start=%#" PRI_klx ", "
			"mem_end=%#" PRI_klx ", base_addr=%#x, "
			"irq=%u, dma=%u, port=%u}",
			(kernel_ulong_t) ifr->ifr_map.mem_start,
			(kernel_ulong_t) ifr->ifr_map.mem_end,
			(unsigned) ifr->ifr_map.base_addr,
			(unsigned) ifr->ifr_map.irq,
			(unsigned) ifr->ifr_map.dma,
			(unsigned) ifr->ifr_map.port);
		break;
	}
}
Beispiel #27
0
static int
decode_cmd_data(struct tcb *tcp, uint32_t cmd, unsigned long data)
{
	switch (cmd) {
		case Q_GETQUOTA:
			if (entering(tcp))
				return 0;
		case Q_SETQUOTA:
		{
			struct if_dqblk dq;

			if (umove_or_printaddr(tcp, data, &dq))
				break;
			tprintf("{bhardlimit=%" PRIu64 ", ", dq.dqb_bhardlimit);
			tprintf("bsoftlimit=%" PRIu64 ", ", dq.dqb_bsoftlimit);
			tprintf("curspace=%" PRIu64 ", ", dq.dqb_curspace);
			tprintf("ihardlimit=%" PRIu64 ", ", dq.dqb_ihardlimit);
			tprintf("isoftlimit=%" PRIu64 ", ", dq.dqb_isoftlimit);
			tprintf("curinodes=%" PRIu64 ", ", dq.dqb_curinodes);
			if (!abbrev(tcp)) {
				tprintf("btime=%" PRIu64 ", ", dq.dqb_btime);
				tprintf("itime=%" PRIu64 ", ", dq.dqb_itime);
				tprints("valid=");
				printflags(if_dqblk_valid,
					   dq.dqb_valid, "QIF_???");
				tprints("}");
			} else
				tprints("...}");
			break;
		}
		case Q_GETNEXTQUOTA:
		{
			struct if_nextdqblk dq;

			if (entering(tcp))
				return 0;
			if (umove_or_printaddr(tcp, data, &dq))
				break;
			tprintf("{bhardlimit=%" PRIu64 ", ", dq.dqb_bhardlimit);
			tprintf("bsoftlimit=%" PRIu64 ", ", dq.dqb_bsoftlimit);
			tprintf("curspace=%" PRIu64 ", ", dq.dqb_curspace);
			tprintf("ihardlimit=%" PRIu64 ", ", dq.dqb_ihardlimit);
			tprintf("isoftlimit=%" PRIu64 ", ", dq.dqb_isoftlimit);
			tprintf("curinodes=%" PRIu64 ", ", dq.dqb_curinodes);
			if (!abbrev(tcp)) {
				tprintf("btime=%" PRIu64 ", ", dq.dqb_btime);
				tprintf("itime=%" PRIu64 ", ", dq.dqb_itime);
				tprints("valid=");
				printflags(if_dqblk_valid,
					   dq.dqb_valid, "QIF_???");
				tprintf(", id=%u}", dq.dqb_id);
			} else
				tprintf("id=%u, ...}", dq.dqb_id);
			break;
		}
		case Q_V1_GETQUOTA:
			if (entering(tcp))
				return 0;
		case Q_V1_SETQUOTA:
		{
			struct v1_dqblk dq;

			if (umove_or_printaddr(tcp, data, &dq))
				break;
			tprintf("{bhardlimit=%u, ", dq.dqb_bhardlimit);
			tprintf("bsoftlimit=%u, ", dq.dqb_bsoftlimit);
			tprintf("curblocks=%u, ", dq.dqb_curblocks);
			tprintf("ihardlimit=%u, ", dq.dqb_ihardlimit);
			tprintf("isoftlimit=%u, ", dq.dqb_isoftlimit);
			tprintf("curinodes=%u, ", dq.dqb_curinodes);
			tprintf("btime=%lu, ", (long) dq.dqb_btime);
			tprintf("itime=%lu}", (long) dq.dqb_itime);
			break;
		}
		case Q_V2_GETQUOTA:
			if (entering(tcp))
				return 0;
		case Q_V2_SETQUOTA:
		{
			struct v2_dqblk dq;

			if (umove_or_printaddr(tcp, data, &dq))
				break;
			tprintf("{ihardlimit=%u, ", dq.dqb_ihardlimit);
			tprintf("isoftlimit=%u, ", dq.dqb_isoftlimit);
			tprintf("curinodes=%u, ", dq.dqb_curinodes);
			tprintf("bhardlimit=%u, ", dq.dqb_bhardlimit);
			tprintf("bsoftlimit=%u, ", dq.dqb_bsoftlimit);
			tprintf("curspace=%" PRIu64 ", ", dq.dqb_curspace);
			tprintf("btime=%lu, ", (long) dq.dqb_btime);
			tprintf("itime=%lu}", (long) dq.dqb_itime);
			break;
		}
		case Q_XGETQUOTA:
		case Q_XGETNEXTQUOTA:
			if (entering(tcp))
				return 0;
		case Q_XSETQLIM:
		{
			struct xfs_dqblk dq;

			if (umove_or_printaddr(tcp, data, &dq))
				break;
			tprintf("{version=%d, ", dq.d_version);
			tprints("flags=");
			printflags(xfs_dqblk_flags,
				   (uint8_t) dq.d_flags, "XFS_???_QUOTA");
			tprintf(", fieldmask=%#x, ", dq.d_fieldmask);
			tprintf("id=%u, ", dq.d_id);
			tprintf("blk_hardlimit=%" PRIu64 ", ", dq.d_blk_hardlimit);
			tprintf("blk_softlimit=%" PRIu64 ", ", dq.d_blk_softlimit);
			tprintf("ino_hardlimit=%" PRIu64 ", ", dq.d_ino_hardlimit);
			tprintf("ino_softlimit=%" PRIu64 ", ", dq.d_ino_softlimit);
			tprintf("bcount=%" PRIu64 ", ", dq.d_bcount);
			tprintf("icount=%" PRIu64 ", ", dq.d_icount);
			if (!abbrev(tcp)) {
				tprintf("itimer=%d, ", dq.d_itimer);
				tprintf("btimer=%d, ", dq.d_btimer);
				tprintf("iwarns=%u, ", dq.d_iwarns);
				tprintf("bwarns=%u, ", dq.d_bwarns);
				tprintf("rtbcount=%" PRIu64 ", ", dq.d_rtbcount);
				tprintf("rtbtimer=%d, ", dq.d_rtbtimer);
				tprintf("rtbwarns=%u}", dq.d_rtbwarns);
			} else
				tprints("...}");
			break;
		}
		case Q_GETFMT:
		{
			uint32_t fmt;

			if (entering(tcp))
				return 0;
			if (umove_or_printaddr(tcp, data, &fmt))
				break;
			tprints("[");
			printxval(quota_formats, fmt, "QFMT_VFS_???");
			tprints("]");
			break;
		}
		case Q_GETINFO:
			if (entering(tcp))
				return 0;
		case Q_SETINFO:
		{
			struct if_dqinfo dq;

			if (umove_or_printaddr(tcp, data, &dq))
				break;
			tprintf("{bgrace=%" PRIu64 ", ", dq.dqi_bgrace);
			tprintf("igrace=%" PRIu64 ", ", dq.dqi_igrace);
			tprints("flags=");
			printflags(if_dqinfo_flags, dq.dqi_flags, "DQF_???");
			tprints(", valid=");
			printflags(if_dqinfo_valid, dq.dqi_valid, "IIF_???");
			tprints("}");
			break;
		}
		case Q_V2_GETINFO:
			if (entering(tcp))
				return 0;
		case Q_V2_SETINFO:
		{
			struct v2_dqinfo dq;

			if (umove_or_printaddr(tcp, data, &dq))
				break;
			tprintf("{bgrace=%u, ", dq.dqi_bgrace);
			tprintf("igrace=%u, ", dq.dqi_igrace);
			tprints("flags=");
			printflags(if_dqinfo_flags, dq.dqi_flags, "DQF_???");
			tprintf(", blocks=%u, ", dq.dqi_blocks);
			tprintf("free_blk=%u, ", dq.dqi_free_blk);
			tprintf("free_entry=%u}", dq.dqi_free_entry);
			break;
		}
		case Q_V1_GETSTATS:
		{
			struct v1_dqstats dq;

			if (entering(tcp))
				return 0;
			if (umove_or_printaddr(tcp, data, &dq))
				break;
			tprintf("{lookups=%u, ", dq.lookups);
			tprintf("drops=%u, ", dq.drops);
			tprintf("reads=%u, ", dq.reads);
			tprintf("writes=%u, ", dq.writes);
			tprintf("cache_hits=%u, ", dq.cache_hits);
			tprintf("allocated_dquots=%u, ", dq.allocated_dquots);
			tprintf("free_dquots=%u, ", dq.free_dquots);
			tprintf("syncs=%u}", dq.syncs);
			break;
		}
		case Q_V2_GETSTATS:
		{
			struct v2_dqstats dq;

			if (entering(tcp))
				return 0;
			if (umove_or_printaddr(tcp, data, &dq))
				break;
			tprintf("{lookups=%u, ", dq.lookups);
			tprintf("drops=%u, ", dq.drops);
			tprintf("reads=%u, ", dq.reads);
			tprintf("writes=%u, ", dq.writes);
			tprintf("cache_hits=%u, ", dq.cache_hits);
			tprintf("allocated_dquots=%u, ", dq.allocated_dquots);
			tprintf("free_dquots=%u, ", dq.free_dquots);
			tprintf("syncs=%u, ", dq.syncs);
			tprintf("version=%u}", dq.version);
			break;
		}
		case Q_XGETQSTAT:
		{
			struct xfs_dqstats dq;

			if (entering(tcp))
				return 0;
			if (umove_or_printaddr(tcp, data, &dq))
				break;
			tprintf("{version=%d, ", dq.qs_version);
			if (abbrev(tcp)) {
				tprints("...}");
				break;
			}
			tprints("flags=");
			printflags(xfs_quota_flags,
				   dq.qs_flags, "XFS_QUOTA_???");
			tprintf(", incoredqs=%u, ", dq.qs_incoredqs);
			tprintf("u_ino=%" PRIu64 ", ", dq.qs_uquota.qfs_ino);
			tprintf("u_nblks=%" PRIu64 ", ", dq.qs_uquota.qfs_nblks);
			tprintf("u_nextents=%u, ", dq.qs_uquota.qfs_nextents);
			tprintf("g_ino=%" PRIu64 ", ", dq.qs_gquota.qfs_ino);
			tprintf("g_nblks=%" PRIu64 ", ", dq.qs_gquota.qfs_nblks);
			tprintf("g_nextents=%u, ", dq.qs_gquota.qfs_nextents);
			tprintf("btimelimit=%d, ", dq.qs_btimelimit);
			tprintf("itimelimit=%d, ", dq.qs_itimelimit);
			tprintf("rtbtimelimit=%d, ", dq.qs_rtbtimelimit);
			tprintf("bwarnlimit=%u, ", dq.qs_bwarnlimit);
			tprintf("iwarnlimit=%u}", dq.qs_iwarnlimit);
			break;
		}
		case Q_XGETQSTATV:
		{
			struct fs_quota_statv dq;

			if (entering(tcp))
				return 0;
			if (umove_or_printaddr(tcp, data, &dq))
				break;
			tprintf("{version=%d, ", dq.qs_version);
			if (abbrev(tcp)) {
				tprints("...}");
				break;
			}
			tprints("flags=");
			printflags(xfs_quota_flags,
				   dq.qs_flags, "XFS_QUOTA_???");
			tprintf(", incoredqs=%u, ", dq.qs_incoredqs);
			tprintf("u_ino=%" PRIu64 ", ", dq.qs_uquota.qfs_ino);
			tprintf("u_nblks=%" PRIu64 ", ", dq.qs_uquota.qfs_nblks);
			tprintf("u_nextents=%u, ", dq.qs_uquota.qfs_nextents);
			tprintf("g_ino=%" PRIu64 ", ", dq.qs_gquota.qfs_ino);
			tprintf("g_nblks=%" PRIu64 ", ", dq.qs_gquota.qfs_nblks);
			tprintf("g_nextents=%u, ", dq.qs_gquota.qfs_nextents);
			tprintf("p_ino=%" PRIu64 ", ", dq.qs_pquota.qfs_ino);
			tprintf("p_nblks=%" PRIu64 ", ", dq.qs_pquota.qfs_nblks);
			tprintf("p_nextents=%u, ", dq.qs_pquota.qfs_nextents);
			tprintf("btimelimit=%d, ", dq.qs_btimelimit);
			tprintf("itimelimit=%d, ", dq.qs_itimelimit);
			tprintf("rtbtimelimit=%d, ", dq.qs_rtbtimelimit);
			tprintf("bwarnlimit=%u, ", dq.qs_bwarnlimit);
			tprintf("iwarnlimit=%u}", dq.qs_iwarnlimit);
			break;
		}
		case Q_XQUOTAON:
		case Q_XQUOTAOFF:
		{
			uint32_t flag;

			if (umove_or_printaddr(tcp, data, &flag))
				break;
			tprints("[");
			printflags(xfs_quota_flags, flag, "XFS_QUOTA_???");
			tprints("]");
			break;
		}
		default:
			printaddr(data);
			break;
	}
	return RVAL_DECODED;
}
Beispiel #28
0
int spcmd_splitadd(void *source, int cargc, char **cargv) {
  nick *np = (nick*)source;
  unsigned long long num;
  char *end;
  flag_t servertype = 0;
  char *servername;
  size_t servernamelen;
  time_t splittime;
  server fake;

  if (cargc < 1) {
      controlreply(np, "Usage: splitadd <servername> [+flags] [split time as unix timestamp]");
      return CMD_ERROR;
  }

  servername = cargv[0];
  servernamelen = strlen(servername);

  if (findserver(servername) != -1) {
    controlreply(np, "Server %s is linked right now, refusing to add split.",
        servername);
    return CMD_ERROR;
  }

  if (doessplitalreadyexist(servername)) {
    controlreply(np, "There is a split for %s already.", servername);
    return CMD_ERROR;
  }

  if (servernamelen > SERVERLEN) {
    controlreply(np, "Server name %s is too long (max: %d characters)",
        servername, SERVERLEN);
    return CMD_ERROR;
  }

  /* Handle flags */
  if (cargc > 1) {
    if (setflags(&servertype, (flag_t)-1, cargv[1], servertypeflags,
          REJECT_UNKNOWN) != REJECT_NONE) {
      controlreply(np, "Flag string %s contained invalid flags.", cargv[1]);
      return CMD_ERROR;
    }
  } else {
    /* Set up a fake server for getservertype. */
    memset(&fake, 0, sizeof(fake));

    fake.name = getsstring(servername, servernamelen);
    servertype = getservertype(&fake);
    freesstring(fake.name);
  }

  /* Handle timestamp */
  if (cargc < 3) {
    splittime = getnettime();
  } else {
    errno = 0;
    num = strtoull(cargv[2], &end, 10);
    if (errno == ERANGE) {
      controlreply(np, "%s is out of range for a timestamp.", cargv[2]);
      return CMD_ERROR;
    }

    /* Truncation may happen here. 
     * However, there's no way to get the max time_t value, so we'll just try to
     * find out after the fact.
     */
    splittime = (time_t)num;

    if ((unsigned long long)splittime < num) {
      controlreply(np, "Tried to use %llu as split time value, but it's too "
          "large for the system to handle", num);
      return CMD_ERROR;
    }
  }

  sp_addsplit(servername, splittime, servertype);
  controlreply(np, "Added split for %s (%s ago) with flags %s.",
      servername, longtoduration(getnettime() - splittime, 1),
      printflags(servertype, servertypeflags));

  return CMD_OK;
}