mirror of
https://git.openafs.org/openafs.git
synced 2025-01-18 15:00:12 +00:00
usd: Add USD_IOCTL() is seekable check
Add the USD_IOCTL_ISSEEKABLE verb to USD_IOCTL() to check if USD_SEEK() can be used on usd file handles. Change-Id: I72f4509f39c82ec0ca4c0983b4c804e490b97ea0 Reviewed-on: https://gerrit.openafs.org/14777 Reviewed-by: Cheyenne Wills <cwills@sinenomine.net> Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net> Reviewed-by: Andrew Deason <adeason@sinenomine.net> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
This commit is contained in:
parent
60425f1e8f
commit
ba27ac6f04
@ -139,6 +139,11 @@ extern int usd_StandardOutput(usd_handle_t * usdP);
|
||||
|
||||
#define USD_IOCTL_GETBLKSIZE 9
|
||||
|
||||
/*
|
||||
* IsSeekable(int *arg) -- returns non-zero if USD_SEEK() can be used.
|
||||
*/
|
||||
#define USD_IOCTL_ISSEEKABLE 10
|
||||
|
||||
typedef struct {
|
||||
int tp_op; /* tape operation */
|
||||
int tp_count; /* tape operation count argument */
|
||||
|
@ -137,6 +137,7 @@ usd_FileIoctl(usd_handle_t usd, int req, void *arg)
|
||||
case USD_IOCTL_GETTYPE:
|
||||
case USD_IOCTL_GETDEV:
|
||||
case USD_IOCTL_GETSIZE:
|
||||
case USD_IOCTL_ISSEEKABLE:
|
||||
#ifdef O_LARGEFILE
|
||||
code = fstat64(fd, &info);
|
||||
#else /* O_LARGEFILE */
|
||||
@ -257,6 +258,11 @@ usd_FileIoctl(usd_handle_t usd, int req, void *arg)
|
||||
#endif /* AFS_AIX_ENV */
|
||||
break;
|
||||
|
||||
case USD_IOCTL_ISSEEKABLE:
|
||||
*(int *)arg = !S_ISFIFO(info.st_mode) && !S_ISSOCK(info.st_mode)
|
||||
&& !S_ISCHR(info.st_mode);
|
||||
break;
|
||||
|
||||
default:
|
||||
return EINVAL;
|
||||
}
|
||||
|
@ -154,12 +154,13 @@ usd_DeviceIoctl(usd_handle_t usd, int req, void *arg)
|
||||
DWORD result;
|
||||
DWORD hiPart;
|
||||
int code = 0;
|
||||
int mode = 0;
|
||||
int seekable = 0;
|
||||
|
||||
switch (req) {
|
||||
case USD_IOCTL_GETTYPE:
|
||||
case USD_IOCTL_ISSEEKABLE:
|
||||
{
|
||||
int mode;
|
||||
|
||||
BY_HANDLE_FILE_INFORMATION info;
|
||||
DISK_GEOMETRY geom;
|
||||
DWORD nbytes;
|
||||
@ -174,7 +175,6 @@ usd_DeviceIoctl(usd_handle_t usd, int req, void *arg)
|
||||
sizeof(geom), &nbytes, NULL))
|
||||
diskError = GetLastError();
|
||||
|
||||
mode = 0;
|
||||
if ((fileError == ERROR_INVALID_PARAMETER
|
||||
|| fileError == ERROR_INVALID_FUNCTION)
|
||||
&& diskError == 0) {
|
||||
@ -199,9 +199,10 @@ usd_DeviceIoctl(usd_handle_t usd, int req, void *arg)
|
||||
k = (afs_uint32) size;
|
||||
usd->privateData = (void *)k;
|
||||
}
|
||||
} else if (diskError == ERROR_INVALID_PARAMETER && fileError == 0)
|
||||
} else if (diskError == ERROR_INVALID_PARAMETER && fileError == 0) {
|
||||
mode = S_IFREG; /* a regular file */
|
||||
else {
|
||||
seekable = 1;
|
||||
} else {
|
||||
/* check to see if device is a tape drive */
|
||||
result = GetTapeStatus(fd);
|
||||
|
||||
@ -214,9 +215,14 @@ usd_DeviceIoctl(usd_handle_t usd, int req, void *arg)
|
||||
|
||||
if (!mode)
|
||||
return EINVAL;
|
||||
*(int *)arg = mode;
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
switch (req) {
|
||||
case USD_IOCTL_GETTYPE:
|
||||
*(int *)arg = mode;
|
||||
break;
|
||||
|
||||
case USD_IOCTL_GETDEV:
|
||||
return EINVAL;
|
||||
@ -372,6 +378,10 @@ usd_DeviceIoctl(usd_handle_t usd, int req, void *arg)
|
||||
*((long *)arg) = (long)4096;
|
||||
return 0;
|
||||
|
||||
case USD_IOCTL_ISSEEKABLE:
|
||||
*(int *)arg = seekable;
|
||||
break;
|
||||
|
||||
default:
|
||||
return EINVAL;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user