mirror of
https://github.com/linux-msm/rmtfs.git
synced 2026-04-09 15:02:31 +02:00
storage: Rename caller to "remote fd"
The caller (and caller_id) are really "remote file descriptors", so rename them based on this. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
This commit is contained in:
66
storage.c
66
storage.c
@@ -14,7 +14,7 @@ struct partition {
|
|||||||
const char *actual;
|
const char *actual;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct caller {
|
struct rmtfd {
|
||||||
unsigned id;
|
unsigned id;
|
||||||
unsigned node;
|
unsigned node;
|
||||||
int fd;
|
int fd;
|
||||||
@@ -32,7 +32,7 @@ static const struct partition partition_table[] = {
|
|||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct caller caller_handles[MAX_CALLERS];
|
static struct rmtfd rmtfds[MAX_CALLERS];
|
||||||
|
|
||||||
int storage_open(const char *storage_root)
|
int storage_open(const char *storage_root)
|
||||||
{
|
{
|
||||||
@@ -42,8 +42,8 @@ int storage_open(const char *storage_root)
|
|||||||
storage_dir = storage_root;
|
storage_dir = storage_root;
|
||||||
|
|
||||||
for (i = 0; i < MAX_CALLERS; i++) {
|
for (i = 0; i < MAX_CALLERS; i++) {
|
||||||
caller_handles[i].id = i;
|
rmtfds[i].id = i;
|
||||||
caller_handles[i].fd = -1;
|
rmtfds[i].fd = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -53,7 +53,7 @@ int storage_get(unsigned node, const char *path)
|
|||||||
{
|
{
|
||||||
char *fspath;
|
char *fspath;
|
||||||
const struct partition *part;
|
const struct partition *part;
|
||||||
struct caller *caller = NULL;
|
struct rmtfd *rmtfd = NULL;
|
||||||
size_t pathlen;
|
size_t pathlen;
|
||||||
int saved_errno;
|
int saved_errno;
|
||||||
int fd;
|
int fd;
|
||||||
@@ -70,20 +70,20 @@ int storage_get(unsigned node, const char *path)
|
|||||||
found:
|
found:
|
||||||
/* Check if this node already has the requested path open */
|
/* Check if this node already has the requested path open */
|
||||||
for (i = 0; i < MAX_CALLERS; i++) {
|
for (i = 0; i < MAX_CALLERS; i++) {
|
||||||
if (caller_handles[i].fd != -1 &&
|
if (rmtfds[i].fd != -1 &&
|
||||||
caller_handles[i].node == node &&
|
rmtfds[i].node == node &&
|
||||||
caller_handles[i].partition == part)
|
rmtfds[i].partition == part)
|
||||||
return caller_handles[i].id;
|
return rmtfds[i].id;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < MAX_CALLERS; i++) {
|
for (i = 0; i < MAX_CALLERS; i++) {
|
||||||
if (caller_handles[i].fd == -1) {
|
if (rmtfds[i].fd == -1) {
|
||||||
caller = &caller_handles[i];
|
rmtfd = &rmtfds[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!caller) {
|
if (!rmtfd) {
|
||||||
fprintf(stderr, "[storage] out of free caller handles\n");
|
fprintf(stderr, "[storage] out of free rmtfd handles\n");
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,57 +98,57 @@ found:
|
|||||||
return -saved_errno;
|
return -saved_errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
caller->node = node;
|
rmtfd->node = node;
|
||||||
caller->fd = fd;
|
rmtfd->fd = fd;
|
||||||
caller->partition = part;
|
rmtfd->partition = part;
|
||||||
|
|
||||||
return caller->id;
|
return rmtfd->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
int storage_put(unsigned node, int caller_id)
|
int storage_put(unsigned node, int caller_id)
|
||||||
{
|
{
|
||||||
struct caller *caller;
|
struct rmtfd *rmtfd;
|
||||||
|
|
||||||
if (caller_id >= MAX_CALLERS)
|
if (caller_id >= MAX_CALLERS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
caller = &caller_handles[caller_id];
|
rmtfd = &rmtfds[caller_id];
|
||||||
if (caller->node != node)
|
if (rmtfd->node != node)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
close(caller->fd);
|
close(rmtfd->fd);
|
||||||
caller->fd = -1;
|
rmtfd->fd = -1;
|
||||||
caller->partition = NULL;
|
rmtfd->partition = NULL;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int storage_get_handle(unsigned node, int caller_id)
|
int storage_get_handle(unsigned node, int caller_id)
|
||||||
{
|
{
|
||||||
struct caller *caller;
|
struct rmtfd *rmtfd;
|
||||||
|
|
||||||
if (caller_id >= MAX_CALLERS)
|
if (caller_id >= MAX_CALLERS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
caller = &caller_handles[caller_id];
|
rmtfd = &rmtfds[caller_id];
|
||||||
if (caller->node != node)
|
if (rmtfd->node != node)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
return caller->fd;
|
return rmtfd->fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
int storage_get_error(unsigned node, int caller_id)
|
int storage_get_error(unsigned node, int caller_id)
|
||||||
{
|
{
|
||||||
struct caller *caller;
|
struct rmtfd *rmtfd;
|
||||||
|
|
||||||
if (caller_id >= MAX_CALLERS)
|
if (caller_id >= MAX_CALLERS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
caller = &caller_handles[caller_id];
|
rmtfd = &rmtfds[caller_id];
|
||||||
if (caller->node != node)
|
if (rmtfd->node != node)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
return caller->dev_error;
|
return rmtfd->dev_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
void storage_close(void)
|
void storage_close(void)
|
||||||
@@ -156,8 +156,8 @@ void storage_close(void)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < MAX_CALLERS; i++) {
|
for (i = 0; i < MAX_CALLERS; i++) {
|
||||||
if (caller_handles[i].fd >= 0)
|
if (rmtfds[i].fd >= 0)
|
||||||
close(caller_handles[i].fd);
|
close(rmtfds[i].fd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user