예제 #1
0
int main(void)
{
    struct timespec t;
    struct in_addr server;
    int res;

    printf(
            "rfc868_time_test\n"
            "Press any key to continue...\n");
    getchar();

    clock_gettime(CLOCK_REALTIME, &t);
    print_timespec(&t);

    server.s_addr = rfc868_timeserver_get();
    printf("RFC868 server: %s\n", inet_ntoa(server));
    res = rfc868_gettime(&t);
    if (res == 0)
    {
        print_timespec(&t);
    }
    else
    {
        perror("rfc868_gettime");
    }

    return 0;
}
예제 #2
0
파일: time.c 프로젝트: michaelhood/strace
int
sys_nanosleep(struct tcb *tcp)
{
	if (entering(tcp)) {
		print_timespec(tcp, tcp->u_arg[0]);
		tprints(", ");
	} else {
		/* Second (returned) timespec is only significant
		 * if syscall was interrupted. On success, we print
		 * only its address, since kernel doesn't modify it,
		 * and printing the value may show uninitialized data.
		 */
		switch (tcp->u_error) {
		default:
			/* Not interrupted (slept entire interval) */
			if (tcp->u_arg[1]) {
				tprintf("%#lx", tcp->u_arg[1]);
				break;
			}
			/* Fall through: print_timespec(NULL) prints "NULL" */
		case ERESTARTSYS:
		case ERESTARTNOINTR:
		case ERESTARTNOHAND:
		case ERESTART_RESTARTBLOCK:
			/* Interrupted */
			print_timespec(tcp, tcp->u_arg[1]);
		}
	}
	return 0;
}
예제 #3
0
static void print_inode_item(struct extent_buffer *eb,
		struct btrfs_inode_item *ii)
{
	char flags_str[256];

	memset(flags_str, 0, sizeof(flags_str));
	inode_flags_to_str(btrfs_inode_flags(eb, ii), flags_str);
	printf("\t\tinode generation %llu transid %llu size %llu nbytes %llu\n"
	       "\t\tblock group %llu mode %o links %u uid %u gid %u rdev %llu\n"
	       "\t\tsequence %llu flags 0x%llx(%s)\n",
	       (unsigned long long)btrfs_inode_generation(eb, ii),
	       (unsigned long long)btrfs_inode_transid(eb, ii),
	       (unsigned long long)btrfs_inode_size(eb, ii),
	       (unsigned long long)btrfs_inode_nbytes(eb, ii),
	       (unsigned long long)btrfs_inode_block_group(eb,ii),
	       btrfs_inode_mode(eb, ii),
	       btrfs_inode_nlink(eb, ii),
	       btrfs_inode_uid(eb, ii),
	       btrfs_inode_gid(eb, ii),
	       (unsigned long long)btrfs_inode_rdev(eb,ii),
	       (unsigned long long)btrfs_inode_flags(eb,ii),
	       (unsigned long long)btrfs_inode_sequence(eb, ii),
	       flags_str);
	print_timespec(eb, btrfs_inode_atime(ii), "\t\tatime ", "\n");
	print_timespec(eb, btrfs_inode_ctime(ii), "\t\tctime ", "\n");
	print_timespec(eb, btrfs_inode_mtime(ii), "\t\tmtime ", "\n");
	print_timespec(eb, btrfs_inode_otime(ii), "\t\totime ", "\n");
}
예제 #4
0
파일: gfjournal.c 프로젝트: ddk50/gfarm_v2
static void
print_stat(struct gfs_stat *st)
{
	printf("ino=%" GFARM_PRId64, st->st_ino);
	if (!opt_verbose)
		return;
	printf(
	    ";gen=%" GFARM_PRId64 ";mode=%d"
	    ";nlink=%" GFARM_PRId64 ";size=%" GFARM_PRId64 ";user=%s;group=%s",
	    st->st_gen, st->st_mode, st->st_nlink, st->st_size,
	    st->st_user, st->st_group);
	print_timespec("atime", &st->st_atimespec);
	print_timespec("ctime", &st->st_ctimespec);
	print_timespec("mtime", &st->st_mtimespec);
}
예제 #5
0
파일: signal.c 프로젝트: GeoffGats/strace
int sys_rt_sigtimedwait(struct tcb *tcp)
{
	if (entering(tcp)) {
		sigset_t sigset;

		if (copy_sigset_len(tcp, tcp->u_arg[0],
				    &sigset, tcp->u_arg[3]) < 0)
			tprints("[?]");
		else
			printsigmask(&sigset, 1);
		tprints(", ");
		/* This is the only "return" parameter, */
		if (tcp->u_arg[1] != 0)
			return 0;
		/* ... if it's NULL, can decode all on entry */
		tprints("NULL, ");
	}
	else if (tcp->u_arg[1] != 0) {
		/* syscall exit, and u_arg[1] wasn't NULL */
		printsiginfo_at(tcp, tcp->u_arg[1]);
		tprints(", ");
	}
	else {
		/* syscall exit, and u_arg[1] was NULL */
		return 0;
	}
	print_timespec(tcp, tcp->u_arg[2]);
	tprintf(", %d", (int) tcp->u_arg[3]);
	return 0;
};
예제 #6
0
static void
ktrtimespec(const struct timespec *tsp, int relative)
{
	printf("struct timespec { ");
	print_timespec(tsp, relative);
	printf(" }\n");
}
예제 #7
0
int sys_rt_sigtimedwait(struct tcb *tcp)
{
	/* NB: kernel requires arg[3] == NSIG / 8 */
	if (entering(tcp)) {
		print_sigset_addr_len(tcp, tcp->u_arg[0], tcp->u_arg[3]);
		tprints(", ");
		/* This is the only "return" parameter, */
		if (tcp->u_arg[1] != 0)
			return 0;
		/* ... if it's NULL, can decode all on entry */
		tprints("NULL, ");
	}
	else if (tcp->u_arg[1] != 0) {
		/* syscall exit, and u_arg[1] wasn't NULL */
		printsiginfo_at(tcp, tcp->u_arg[1]);
		tprints(", ");
	}
	else {
		/* syscall exit, and u_arg[1] was NULL */
		return 0;
	}
	print_timespec(tcp, tcp->u_arg[2]);
	tprintf(", %lu", tcp->u_arg[3]);
	return 0;
};
예제 #8
0
int
sys_ppoll(struct tcb *tcp)
{
	int rc = decode_poll(tcp, tcp->u_arg[2]);
	if (entering(tcp)) {
		print_timespec(tcp, tcp->u_arg[2]);
		tprints(", ");
		print_sigset(tcp, tcp->u_arg[3], 0);
		tprintf(", %lu", tcp->u_arg[4]);
	}
	return rc;
}
예제 #9
0
int
sys_ppoll(struct tcb *tcp)
{
    int rc = decode_poll(tcp, tcp->u_arg[2]);
    if (entering(tcp)) {
        print_timespec(tcp, tcp->u_arg[2]);
        tprints(", ");
        /* NB: kernel requires arg[4] == NSIG / 8 */
        print_sigset_addr_len(tcp, tcp->u_arg[3], tcp->u_arg[4]);
        tprintf(", %lu", tcp->u_arg[4]);
    }
    return rc;
}
예제 #10
0
static void
ktrstat(const struct stat *statp)
{
	char mode[12];
	struct passwd *pwd;
	struct group  *grp;

	/*
	 * note: ktrstruct() has already verified that statp points to a
	 * buffer exactly sizeof(struct stat) bytes long.
	 */
	printf("struct stat { ");
	strmode(statp->st_mode, mode);
	printf("dev=%d, ino=%llu, mode=%s, nlink=%u, ",
	    statp->st_dev, (unsigned long long)statp->st_ino,
	    mode, statp->st_nlink);
	if (resolv == 0 || (pwd = getpwuid(statp->st_uid)) == NULL)
		printf("uid=%u, ", statp->st_uid);
	else
		printf("uid=\"%s\", ", pwd->pw_name);
	if (resolv == 0 || (grp = getgrgid(statp->st_gid)) == NULL)
		printf("gid=%u, ", statp->st_gid);
	else
		printf("gid=\"%s\", ", grp->gr_name);
	printf("rdev=%d, ", statp->st_rdev);
	printf("atime=");
	print_timespec(&statp->st_atim, 0);
	printf(", mtime=");
	print_timespec(&statp->st_mtim, 0);
	printf(", ctime=");
	print_timespec(&statp->st_ctim, 0);
	printf(", size=%lld, blocks=%lld, blksize=%u, flags=0x%x, gen=0x%x",
	    statp->st_size, statp->st_blocks, statp->st_blksize,
	    statp->st_flags, statp->st_gen);
	printf(" }\n");
}
예제 #11
0
int
sys_recvmmsg(struct tcb *tcp)
{
	/* +5 chars are for "left " prefix */
	static char str[5 + TIMESPEC_TEXT_BUFSIZE];

	if (entering(tcp)) {
		printfd(tcp, tcp->u_arg[0]);
		tprints(", ");
		if (verbose(tcp)) {
			sprint_timespec(str, tcp, tcp->u_arg[4]);
			/* Abusing tcp->auxstr as temp storage.
			 * Will be used and freed on syscall exit.
			 */
			tcp->auxstr = strdup(str);
		} else {
			tprintf("%#lx, %ld, ", tcp->u_arg[1], tcp->u_arg[2]);
			printflags(msg_flags, tcp->u_arg[3], "MSG_???");
			tprints(", ");
			print_timespec(tcp, tcp->u_arg[4]);
		}
		return 0;
	} else {
		if (verbose(tcp)) {
			decode_mmsg(tcp, 0);
			/* timeout on entrance */
			tprintf(", %s", tcp->auxstr ? tcp->auxstr : "{...}");
			free((void *) tcp->auxstr);
			tcp->auxstr = NULL;
		}
		if (syserror(tcp))
			return 0;
		if (tcp->u_rval == 0) {
			tcp->auxstr = "Timeout";
			return RVAL_STR;
		}
		if (!verbose(tcp))
			return 0;
		/* timeout on exit */
		sprint_timespec(stpcpy(str, "left "), tcp, tcp->u_arg[4]);
		tcp->auxstr = str;
		return RVAL_STR;
	}
}
예제 #12
0
int
sys_io_getevents(struct tcb *tcp)
{
	if (entering(tcp)) {
		tprintf("%ld, %ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1],
			tcp->u_arg[2]);
	} else {
		if (tcp->u_rval == 0) {
			tprintf("{}");
		} else  {
#ifdef HAVE_LIBAIO_H
			struct io_event *events = (void *)tcp->u_arg[3];
			long i, nr = tcp->u_rval;

			for (i = 0; i < nr; i++, events++) {
				struct io_event event;

				if (i == 0)
					tprintf("{");
				else
					tprintf(", ");

				if (umove(tcp, (unsigned long)events, &event) != 0) {
					tprintf("{...}");
					continue;
				}
				tprintf("{%p, %p, %ld, %ld}", event.data,
					event.obj, event.res, event.res2);
			}
			tprintf("}, ");
#else
				tprintf("{...}");
#endif
		}

		print_timespec(tcp, tcp->u_arg[4]);
	}
	return 0;
}
예제 #13
0
파일: gfjournal.c 프로젝트: ddk50/gfarm_v2
static void
print_obj(enum journal_operation ope, void *obj)
{
	switch (ope) {
	case GFM_JOURNAL_BEGIN:
	case GFM_JOURNAL_END:
		break;
	case GFM_JOURNAL_HOST_ADD:
		print_host(obj);
		break;
	case GFM_JOURNAL_HOST_MODIFY: {
		struct db_host_modify_arg *m = obj;
		print_host(&m->hi);
		if (opt_verbose) {
			print_modflags(m->modflags, host_modflag_info);
			if (m->add_count > 0)
				print_stringlist("add_aliases",
				    m->add_aliases);
			if (m->del_count > 0)
				print_stringlist("del_aliases",
				    m->del_aliases);
		}
		break;
	}
	case GFM_JOURNAL_USER_ADD:
		print_user(obj);
		break;
	case GFM_JOURNAL_USER_MODIFY: {
		struct db_user_modify_arg *m = obj;
		print_user(&m->ui);
		if (opt_verbose)
			print_modflags(m->modflags, user_modflag_info);
		break;
	}
	case GFM_JOURNAL_GROUP_ADD:
		print_group(obj);
		break;
	case GFM_JOURNAL_GROUP_MODIFY: {
		struct db_group_modify_arg *m = obj;
		print_group(&m->gi);
		if (opt_verbose) {
			print_modflags(m->modflags, NULL);
			if (m->add_count > 0)
				print_stringlist("add_users",
				    m->add_users);
			if (m->del_count > 0)
				print_stringlist("del_users",
				    m->del_users);
		}
		break;
	}
	case GFM_JOURNAL_HOST_REMOVE:
	case GFM_JOURNAL_USER_REMOVE:
	case GFM_JOURNAL_GROUP_REMOVE:
	case GFM_JOURNAL_MDHOST_REMOVE:
		printf("name=%s", (const char *)obj);
		break;
	case GFM_JOURNAL_INODE_ADD:
	case GFM_JOURNAL_INODE_MODIFY:
		print_stat(obj);
		break;
	case GFM_JOURNAL_INODE_GEN_MODIFY:
	case GFM_JOURNAL_INODE_NLINK_MODIFY:
	case GFM_JOURNAL_INODE_SIZE_MODIFY: {
		struct db_inode_uint64_modify_arg *m = obj;
		printf("ino=%" GFARM_PRId64, m->inum);
		if (opt_verbose)
			printf(";uint64=%" GFARM_PRId64 "", m->uint64);
		break;
	}
	case GFM_JOURNAL_INODE_MODE_MODIFY: {
		struct db_inode_uint32_modify_arg *m = obj;
		printf("ino=%" GFARM_PRId64, m->inum);
		if (opt_verbose)
			printf(";uint32=%d", m->uint32);
		break;
	}
	case GFM_JOURNAL_INODE_USER_MODIFY:
	case GFM_JOURNAL_INODE_GROUP_MODIFY: {
		struct db_inode_string_modify_arg *m = obj;
		printf("ino=%" GFARM_PRId64, m->inum);
		if (opt_verbose)
			printf(";string=%s", m->string);
		break;
	}
	case GFM_JOURNAL_INODE_ATIME_MODIFY:
	case GFM_JOURNAL_INODE_MTIME_MODIFY:
	case GFM_JOURNAL_INODE_CTIME_MODIFY: {
		struct db_inode_timespec_modify_arg *m = obj;
		printf("ino=%" GFARM_PRId64, m->inum);
		if (opt_verbose)
			print_timespec("time", &m->time);
		break;
	}
	case GFM_JOURNAL_INODE_CKSUM_ADD:
	case GFM_JOURNAL_INODE_CKSUM_MODIFY: {
		struct db_inode_cksum_arg *m = obj;
		printf("ino=%" GFARM_PRId64, m->inum);
		if (opt_verbose)
			printf(";type=%s;len=%lu", m->type,
			    (unsigned long)m->len);
		break;
	}
	case GFM_JOURNAL_INODE_CKSUM_REMOVE:
	case GFM_JOURNAL_SYMLINK_REMOVE: {
		struct db_inode_inum_arg *m = obj;
		printf("ino=%" GFARM_PRId64, m->inum);
		break;
	}
	case GFM_JOURNAL_FILECOPY_ADD:
	case GFM_JOURNAL_FILECOPY_REMOVE: {
		struct db_filecopy_arg *m = obj;
		printf("ino=%" GFARM_PRId64, m->inum);
		if (opt_verbose)
			printf(";hostname=%s", m->hostname);
		break;
	}
	case GFM_JOURNAL_DEADFILECOPY_ADD:
	case GFM_JOURNAL_DEADFILECOPY_REMOVE: {
		struct db_deadfilecopy_arg *m = obj;
		printf("ino=%" GFARM_PRId64, m->inum);
		if (opt_verbose)
			printf(";igen=%" GFARM_PRId64 ";hostname=%s",
			    m->igen, m->hostname);
		break;
	}
	case GFM_JOURNAL_DIRENTRY_ADD:
	case GFM_JOURNAL_DIRENTRY_REMOVE: {
		struct db_direntry_arg *m = obj;
		printf("ino=%" GFARM_PRId64, m->dir_inum);
		if (opt_verbose)
			printf(";entry_ino=%" GFARM_PRId64
			    ";entry_name=%s;entry_len=%d",
			    m->entry_inum, m->entry_name, m->entry_len);
		break;
	}
	case GFM_JOURNAL_SYMLINK_ADD: {
		struct db_symlink_arg *m = obj;
		printf("ino=%" GFARM_PRId64, m->inum);
		if (opt_verbose)
			printf(";source_path=%s", m->source_path);
		break;
	}
	case GFM_JOURNAL_XATTR_ADD:
	case GFM_JOURNAL_XATTR_MODIFY:
	case GFM_JOURNAL_XATTR_REMOVE:
	case GFM_JOURNAL_XATTR_REMOVEALL: {
		struct db_xattr_arg *m = obj;
		printf("ino=%" GFARM_PRId64, m->inum);
		if (opt_verbose) {
			printf(";xml_mode=%d;attrname=%s;size=%lu",
			    m->xmlMode, m->attrname, (unsigned long)m->size);
			print_bin_value("value", m->value, m->size);
		}
		break;
	}
	case GFM_JOURNAL_QUOTA_ADD:
	case GFM_JOURNAL_QUOTA_MODIFY: {
		struct db_quota_arg *m = obj;
		printf("name=%s;is_group=%d", m->name, m->is_group);
		if (opt_verbose)
			print_quota(&m->quota);
		break;
	}
	case GFM_JOURNAL_QUOTA_REMOVE: {
		struct db_quota_remove_arg *m = obj;
		printf("name=%s;is_group=%d", m->name, m->is_group);
		break;
	}
	case GFM_JOURNAL_MDHOST_ADD:
		print_mdhost(obj);
		break;
	case GFM_JOURNAL_MDHOST_MODIFY: {
		struct db_mdhost_modify_arg *m = obj;
		print_mdhost(&m->ms);
		break;
	}
	case GFM_JOURNAL_FSNGROUP_MODIFY: {
		struct db_fsngroup_modify_arg *m = obj;
		print_fsngroup_modify(m->hostname, m->fsngroupname);
		break;
	}
	default:
		break;
	}
}
예제 #14
0
int main(int argc, char* argv[]) {
    int i = 0;
    char time_arg = 1;
    char expected_argc = 2;
    char stay_mode = 0;
    strcpy(PROGNAME, argv[0]);
    if (argc == 1 ||
        strcmp(argv[1], "-h") == 0 ||
        strcmp(argv[1], "--help") == 0) {
        usage(1);
        return 2;
    } else if (strcmp(argv[1], "-v") == 0 ||
               strcmp(argv[1], "--version") == 0) {
        fprintf(stderr, "%s %s\n", argv[0], VERSION);
        return 2;
    }

    if (strcmp(argv[1], "-s") == 0 ||
        strcmp(argv[1], "--stay") == 0) {
        stay_mode = 1;
        time_arg = 2;
        expected_argc = 3;
    }

    if (argc != expected_argc) {
        usage(1);
        return 2;
    }

    // we do use timespec, but we manage them ourselves
    // (we do not pass tmsec to nanosleep or the like)
    struct timespec tmsec = input_to_timespec(argv[time_arg]);
    struct nruns nr = timespec_to_nruns(tmsec);
#if defined(DEBUG) || defined(DRYMODE)
    fprintf(stderr, "abuser wants %s\n", print_timespec(tmsec));
    fprintf(stderr, "nruns: %lld runs, %s, final %s\n", nr.runs,
            print_timespec(nr.runlength), print_timespec(nr.final));
#endif

#ifndef DRYMODE
    int errno;
    errno = pbar(0, 1);
    if (errno != 0) return errno;
    for (i = 0; i < nr.runs; i++) {
        nanosleep(&nr.runlength, &nr.runlength);
        errno = pbar(i, nr.runs + 1);
        if (errno != 0) return errno;
    }
    nanosleep(&nr.final, &nr.final);
    errno = pbar(1, 1);
    if (errno != 0) return errno;
    if (stay_mode) {
        // stay mode, progressbar stays on the screen
        printf("\n");
    } else {
        // progressbar disappears at the end
        erase_pbar();
    }
#endif

    return 0;
}