Ejemplo n.º 1
0
static int
efifs_stat(struct open_file *f, struct stat *sb)
{
	EFI_FILE *file = f->f_fsdata;
	union fileinfo fi;
	EFI_STATUS status;
	UINTN sz;

	if (file == NULL)
		return (EBADF);

	bzero(sb, sizeof(*sb));

	sz = sizeof(fi);
	status = file->GetInfo(file, &fi_guid, &sz, &fi);
	if (EFI_ERROR(status))
		return (efi_status_to_errno(status));

	sb->st_mode = S_IRUSR | S_IRGRP | S_IROTH;
	if ((fi.info.Attribute & EFI_FILE_READ_ONLY) == 0)
		sb->st_mode |= S_IWUSR | S_IWGRP | S_IWOTH;
	if (fi.info.Attribute & EFI_FILE_DIRECTORY)
		sb->st_mode |= S_IFDIR;
	else
		sb->st_mode |= S_IFREG;
	sb->st_nlink = 1;
	sb->st_atime = efi_time(&fi.info.LastAccessTime);
	sb->st_mtime = efi_time(&fi.info.ModificationTime);
	sb->st_ctime = efi_time(&fi.info.CreateTime);
	sb->st_size = fi.info.FileSize;
	sb->st_blocks = fi.info.PhysicalSize / S_BLKSIZE;
	sb->st_blksize = S_BLKSIZE;
	sb->st_birthtime = sb->st_ctime;
	return (0);
}
Ejemplo n.º 2
0
int
EFI_GetTimeOfDay(
	OUT struct timeval *tp,
	OUT struct timezone *tzp
	)
{
	EFI_TIME		EfiTime;
	EFI_TIME_CAPABILITIES	Capabilities;
	EFI_STATUS		Status;

	/*
	//  Get time from EFI
	*/

	Status = RS->GetTime(&EfiTime, &Capabilities);
	if (EFI_ERROR(Status))
		return (-1);

	/*
	//  Convert to UNIX time (ie seconds since the epoch
	*/

	tp->tv_sec  = efi_time( &EfiTime );
	tp->tv_usec = 0; /* EfiTime.Nanosecond * 1000; */

	/*
	//  Do something with the timezone if needed
	*/

	if (tzp) {
		tzp->tz_minuteswest =
			EfiTime.TimeZone == EFI_UNSPECIFIED_TIMEZONE ? 0 : EfiTime.TimeZone;
		/*
		//  This isn't quit right since it doesn't deal with EFI_TIME_IN_DAYLIGHT
		*/
		tzp->tz_dsttime =
			EfiTime.Daylight & EFI_TIME_ADJUST_DAYLIGHT ? 1 : 0;
	}

	return (0);
}