コード例 #1
0
ファイル: utime.c プロジェクト: apprisi/illumos-gate
static int
get_timespec_vattr(timespec_t *tsptr, struct vattr *vattr, int *flags)
{
	timespec_t ts[2];
	timespec_t now;
	uint_t mask;

	if (tsptr != NULL) {
		if (get_udatamodel() == DATAMODEL_NATIVE) {
			if (copyin(tsptr, ts, sizeof (ts)))
				return (EFAULT);
		} else {
			timespec32_t ts32[2];

			if (copyin(tsptr, ts32, sizeof (ts32)))
				return (EFAULT);
			TIMESPEC32_TO_TIMESPEC(&ts[0], &ts32[0]);
			TIMESPEC32_TO_TIMESPEC(&ts[1], &ts32[1]);
		}
		if (ts[0].tv_nsec == UTIME_NOW || ts[1].tv_nsec == UTIME_NOW)
			gethrestime(&now);
		mask = 0;
		if (ts[0].tv_nsec == UTIME_OMIT) {
			ts[0].tv_nsec = 0;
		} else {
			mask |= AT_ATIME;
			if (ts[0].tv_nsec == UTIME_NOW)
				ts[0] = now;
			else if (ts[0].tv_nsec < 0 || ts[0].tv_nsec >= NANOSEC)
				return (EINVAL);
		}
		if (ts[1].tv_nsec == UTIME_OMIT) {
			ts[1].tv_nsec = 0;
		} else {
			mask |= AT_MTIME;
			if (ts[1].tv_nsec == UTIME_NOW)
				ts[1] = now;
			else if (ts[1].tv_nsec < 0 || ts[1].tv_nsec >= NANOSEC)
				return (EINVAL);
		}
		vattr->va_atime = ts[0];
		vattr->va_mtime = ts[1];
		vattr->va_mask = mask;
		*flags = ATTR_UTIME;
	} else {
		gethrestime(&now);
		vattr->va_atime = now;
		vattr->va_mtime = now;
		vattr->va_mask = AT_ATIME | AT_MTIME;
		*flags = 0;
	}

	return (0);
}
コード例 #2
0
ファイル: xstat.c プロジェクト: andreiw/polaris
void
show_stat32(private_t *pri, long offset)
{
	struct stat32 statb;
	timestruc_t ts;

	if (offset != NULL &&
	    Pread(Proc, &statb, sizeof (statb), offset) == sizeof (statb)) {
		(void) printf(
		    "%s    d=0x%.8X i=%-5u m=0%.6o l=%-2u u=%-5u g=%-5u",
		    pri->pname,
		    statb.st_dev,
		    statb.st_ino,
		    statb.st_mode,
		    statb.st_nlink,
		    statb.st_uid,
		    statb.st_gid);

		switch (statb.st_mode & S_IFMT) {
		case S_IFCHR:
		case S_IFBLK:
			(void) printf(" rdev=0x%.8X\n", statb.st_rdev);
			break;
		default:
			(void) printf(" sz=%u\n", statb.st_size);
			break;
		}

		TIMESPEC32_TO_TIMESPEC(&ts, &statb.st_atim);
		prtimestruc(pri, "at = ", &ts);
		TIMESPEC32_TO_TIMESPEC(&ts, &statb.st_mtim);
		prtimestruc(pri, "mt = ", &ts);
		TIMESPEC32_TO_TIMESPEC(&ts, &statb.st_ctim);
		prtimestruc(pri, "ct = ", &ts);

		(void) printf(
		    "%s    bsz=%-5d blks=%-5d fs=%.*s\n",
		    pri->pname,
		    statb.st_blksize,
		    statb.st_blocks,
		    _ST_FSTYPSZ,
		    statb.st_fstype);
	}
}
コード例 #3
0
ファイル: pr_stat.c プロジェクト: apprisi/illumos-gate
/*
 * in case of 64-bit *stat() and *stat64 library call and 32-bit subject
 * process convert 64-bit struct stat/stat64 into 32-bit struct stat64
 */
static void
stat64_32_to_n(struct stat64_32 *src, struct stat *dest)
{
	(void) memset(dest, 0, sizeof (*dest));
	dest->st_dev = DEVEXPL(src->st_dev);
	dest->st_ino = (ino_t)src->st_ino;
	dest->st_mode = (mode_t)src->st_mode;
	dest->st_nlink = (nlink_t)src->st_nlink;
	dest->st_uid = (uid_t)src->st_uid;
	dest->st_gid = (gid_t)src->st_gid;
	dest->st_rdev = DEVEXPL(src->st_rdev);
	dest->st_size = (off_t)src->st_size;
	TIMESPEC32_TO_TIMESPEC(&dest->st_atim, &src->st_atim);
	TIMESPEC32_TO_TIMESPEC(&dest->st_mtim, &src->st_mtim);
	TIMESPEC32_TO_TIMESPEC(&dest->st_ctim, &src->st_ctim);
	dest->st_blksize = (blksize_t)src->st_blksize;
	dest->st_blocks = (blkcnt_t)src->st_blocks;
	(void) memcpy(dest->st_fstype, src->st_fstype,
	    sizeof (dest->st_fstype));
}
コード例 #4
0
ファイル: lwp_timer.c プロジェクト: andreiw/polaris
int
lwp_timer_copyin(lwp_timer_t *lwptp, timespec_t *tsp)
{
	timespec_t now;
	int error = 0;

	if (tsp == NULL)	/* not really an error, just need to bzero() */
		goto err;
	lwptp->lwpt_timecheck = timechanged; /* do this before gethrestime() */
	gethrestime(&now);		/* do this before copyin() */
	if (curproc->p_model == DATAMODEL_NATIVE) {
		if (copyin(tsp, &lwptp->lwpt_rqtime, sizeof (timespec_t))) {
			error = EFAULT;
			goto err;
		}
	} else {
		timespec32_t ts32;
		if (copyin(tsp, &ts32, sizeof (timespec32_t))) {
			error = EFAULT;
			goto err;
		}
		TIMESPEC32_TO_TIMESPEC(&lwptp->lwpt_rqtime, &ts32);
	}
	if (itimerspecfix(&lwptp->lwpt_rqtime)) {
		error = EINVAL;
		goto err;
	}
	/*
	 * Unless the requested timeout is zero,
	 * get the precise future (absolute) time at
	 * which we are to time out and return ETIME.
	 * We must not return ETIME before that time.
	 */
	if (lwptp->lwpt_rqtime.tv_sec == 0 && lwptp->lwpt_rqtime.tv_nsec == 0) {
		bzero(lwptp, sizeof (lwp_timer_t));
		lwptp->lwpt_imm_timeout = 1;
	} else {
		lwptp->lwpt_thread = curthread;
		lwptp->lwpt_tsp = tsp;
		lwptp->lwpt_time_error = 0;
		lwptp->lwpt_id = 0;
		lwptp->lwpt_imm_timeout = 0;
		timespecadd(&lwptp->lwpt_rqtime, &now);
	}
	return (0);
err:
	bzero(lwptp, sizeof (lwp_timer_t));
	lwptp->lwpt_time_error = error;
	return (error);
}