Added a very simple mkindex command - can only create string indexes for now

(and added support for that function in the emulated kernel).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@11951 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2005-03-22 03:08:32 +00:00
parent dfb8cfea3f
commit 28fb0f9857
3 changed files with 54 additions and 0 deletions

View File

@ -1654,6 +1654,27 @@ do_sync(int argc, char **argv)
}
static int
do_mkindex(int argc, char **argv)
{
if (argc < 2) {
printf("usage: mkindex <index>\n");
return FS_EINVAL;
}
struct my_stat st;
status_t error = sys_rstat(true, -1, "/myfs", &st, true);
if (error == FS_OK) {
error = sys_mkindex(true, st.dev, argv[1], B_STRING_TYPE, 0);
}
if (error != FS_OK)
printf("Could not create index: %s\n", fs_strerror(error));
return error;
}
#define MAX_LIVE_QUERIES 10
void *gQueryCookie[MAX_LIVE_QUERIES] = {NULL};
char *gQueryString[MAX_LIVE_QUERIES] = {NULL};
@ -2010,6 +2031,7 @@ static cmd_entry builtin_commands[] =
{ "lat_fs", do_lat_fs, "simulate what the lmbench test lat_fs does" },
{ "create", do_create, "create N files. default is 100" },
{ "delete", do_delete, "delete N files. default is 100" },
{ "mkindex", do_mkindex, "creates an index (type is currently always string)" },
{ "query", do_query, "run a query on the file system" },
{ "startquery", do_startquery, "run a live query on the file system (up to 10)" },
{ "stopquery", do_stopquery, "stops live query N, or all of them if none is specified" },

View File

@ -2080,6 +2080,36 @@ error1:
}
int
sys_mkindex(bool kernel, dev_t device, const char *index, int type, int flags)
{
int status = FS_EINVAL;
fsystem *fs = NULL;
vnode *root = NULL;
nspace *ns;
LOCK(vnlock);
ns = nsidtons(device);
if (ns != NULL) {
fs = ns->fs;
if (fs->ops.create_index != NULL) {
status = FS_OK;
root = ns->root;
root->rcnt++;
}
}
UNLOCK(vnlock);
if (status == FS_OK) {
status = (*fs->ops.create_index)(ns->data, index, type, flags);
dec_vnode(root, FALSE);
}
TRACE("sys_mkindex() -- end: %d\n", status);
return status;
}
int
sys_open_query(bool kernel, int fd, const char *path, const char *query, ulong flags, port_id port, ulong token, void **cookie)
{

View File

@ -56,6 +56,8 @@ ssize_t sys_remove_attr(bool kernel, int fd, const char *name);
int sys_stat_attr(bool kernel, int fd, const char *path, const char *name,
my_attr_info *info);
int sys_mkindex(bool kernel, dev_t device, const char *index, int type, int flags);
int sys_open_query(bool kernel, int fd, const char *path, const char *query, ulong flags, port_id port, ulong token, void **cookie);
int sys_close_query(bool kernel, int fd, const char *path, void *cookie);
int sys_read_query(bool kernel, int fd, const char *path, void *cookie, struct my_dirent *dent,size_t bufferSize,long num);