From d256fad4bb191f8e4f5bb32ffcaa5e8cc8b34625 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Sat, 20 Jan 2007 02:04:51 +0000 Subject: [PATCH] \o/ \o/ This is the mighty GoogleFS for BeOS, now also for Haiku. \o/ \o/ Quick, before I loose googlefs.h again (bloody /bin/deres which overwrites foo.h for foo.rsrc !!!!) A makefile is provided for BeOS/Zeta, the Jamfile currently only builds for Haiku. The makefile.ufs is for UserlandFS. The source code is quite messy, beware. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19873 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../kernel/file_systems/googlefs/Jamfile | 20 + .../file_systems/googlefs/README.googlefs.txt | 29 + .../kernel/file_systems/googlefs/_APP_ | 1 + .../kernel/file_systems/googlefs/attr2c | 10 + .../kernel/file_systems/googlefs/attrs.c | 273 +++ .../kernel/file_systems/googlefs/attrs.h | 45 + .../kernel/file_systems/googlefs/attrs.txt | 33 + .../kernel/file_systems/googlefs/bin/google | 2 + .../kernel/file_systems/googlefs/bin/imlucky | 2 + .../file_systems/googlefs/bookmark.mime | 33 + .../file_systems/googlefs/config/googlefs | 15 + .../kernel/file_systems/googlefs/fsproto.h | 250 +++ .../googlefs/google-ext-search.html | 140 ++ .../kernel/file_systems/googlefs/google.src | 29 + .../file_systems/googlefs/google_icon.c | 175 ++ .../file_systems/googlefs/google_request.c | 212 ++ .../file_systems/googlefs/google_request.h | 37 + .../kernel/file_systems/googlefs/googlefs.c | 1801 +++++++++++++++++ .../file_systems/googlefs/googlefs.docs.txt | 10 + .../kernel/file_systems/googlefs/googlefs.h | 131 ++ .../file_systems/googlefs/googlefs_res.rdef | 88 + .../kernel/file_systems/googlefs/http_cnx.c | 235 +++ .../kernel/file_systems/googlefs/http_cnx.h | 31 + .../kernel/file_systems/googlefs/ksocket.h | 114 ++ .../kernel/file_systems/googlefs/lists.c | 80 + .../kernel/file_systems/googlefs/lists.h | 29 + .../kernel/file_systems/googlefs/lists2.c | 99 + .../kernel/file_systems/googlefs/lists2.h | 28 + .../kernel/file_systems/googlefs/lock.h | 52 + .../kernel/file_systems/googlefs/makefile | 133 ++ .../kernel/file_systems/googlefs/makefile.ufs | 134 ++ .../kernel/file_systems/googlefs/makezip.sh | 9 + .../file_systems/googlefs/parse_google_html.c | 253 +++ .../kernel/file_systems/googlefs/query.c | 181 ++ .../kernel/file_systems/googlefs/query.h | 57 + .../kernel/file_systems/googlefs/ringbuff.c | 133 ++ .../kernel/file_systems/googlefs/ringbuff.h | 18 + .../kernel/file_systems/googlefs/settings.c | 50 + .../kernel/file_systems/googlefs/settings.h | 13 + .../file_systems/googlefs/string_utils.c | 153 ++ .../file_systems/googlefs/string_utils.h | 16 + .../kernel/file_systems/googlefs/vnidpool.c | 96 + .../kernel/file_systems/googlefs/vnidpool.h | 18 + 43 files changed, 5268 insertions(+) create mode 100644 src/add-ons/kernel/file_systems/googlefs/Jamfile create mode 100644 src/add-ons/kernel/file_systems/googlefs/README.googlefs.txt create mode 120000 src/add-ons/kernel/file_systems/googlefs/_APP_ create mode 100755 src/add-ons/kernel/file_systems/googlefs/attr2c create mode 100644 src/add-ons/kernel/file_systems/googlefs/attrs.c create mode 100644 src/add-ons/kernel/file_systems/googlefs/attrs.h create mode 100644 src/add-ons/kernel/file_systems/googlefs/attrs.txt create mode 100755 src/add-ons/kernel/file_systems/googlefs/bin/google create mode 100755 src/add-ons/kernel/file_systems/googlefs/bin/imlucky create mode 100644 src/add-ons/kernel/file_systems/googlefs/bookmark.mime create mode 100644 src/add-ons/kernel/file_systems/googlefs/config/googlefs create mode 100644 src/add-ons/kernel/file_systems/googlefs/fsproto.h create mode 100644 src/add-ons/kernel/file_systems/googlefs/google-ext-search.html create mode 100644 src/add-ons/kernel/file_systems/googlefs/google.src create mode 100644 src/add-ons/kernel/file_systems/googlefs/google_icon.c create mode 100644 src/add-ons/kernel/file_systems/googlefs/google_request.c create mode 100644 src/add-ons/kernel/file_systems/googlefs/google_request.h create mode 100644 src/add-ons/kernel/file_systems/googlefs/googlefs.c create mode 100644 src/add-ons/kernel/file_systems/googlefs/googlefs.docs.txt create mode 100644 src/add-ons/kernel/file_systems/googlefs/googlefs.h create mode 100644 src/add-ons/kernel/file_systems/googlefs/googlefs_res.rdef create mode 100644 src/add-ons/kernel/file_systems/googlefs/http_cnx.c create mode 100644 src/add-ons/kernel/file_systems/googlefs/http_cnx.h create mode 100644 src/add-ons/kernel/file_systems/googlefs/ksocket.h create mode 100644 src/add-ons/kernel/file_systems/googlefs/lists.c create mode 100644 src/add-ons/kernel/file_systems/googlefs/lists.h create mode 100644 src/add-ons/kernel/file_systems/googlefs/lists2.c create mode 100644 src/add-ons/kernel/file_systems/googlefs/lists2.h create mode 100644 src/add-ons/kernel/file_systems/googlefs/lock.h create mode 100644 src/add-ons/kernel/file_systems/googlefs/makefile create mode 100644 src/add-ons/kernel/file_systems/googlefs/makefile.ufs create mode 100755 src/add-ons/kernel/file_systems/googlefs/makezip.sh create mode 100644 src/add-ons/kernel/file_systems/googlefs/parse_google_html.c create mode 100644 src/add-ons/kernel/file_systems/googlefs/query.c create mode 100644 src/add-ons/kernel/file_systems/googlefs/query.h create mode 100644 src/add-ons/kernel/file_systems/googlefs/ringbuff.c create mode 100644 src/add-ons/kernel/file_systems/googlefs/ringbuff.h create mode 100644 src/add-ons/kernel/file_systems/googlefs/settings.c create mode 100644 src/add-ons/kernel/file_systems/googlefs/settings.h create mode 100644 src/add-ons/kernel/file_systems/googlefs/string_utils.c create mode 100644 src/add-ons/kernel/file_systems/googlefs/string_utils.h create mode 100644 src/add-ons/kernel/file_systems/googlefs/vnidpool.c create mode 100644 src/add-ons/kernel/file_systems/googlefs/vnidpool.h diff --git a/src/add-ons/kernel/file_systems/googlefs/Jamfile b/src/add-ons/kernel/file_systems/googlefs/Jamfile new file mode 100644 index 0000000000..fdf1a27e92 --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/Jamfile @@ -0,0 +1,20 @@ +SubDir HAIKU_TOP src add-ons kernel file_systems googlefs ; + +UsePrivateHeaders kernel ; + +#SubDirCcFlags -DTRACK_FILENAME ; +#SubDirCcFlags -DDEBUG_GOOGLEFS=1 ; + +KernelAddon googlefs : + attrs.c + google_icon.c + google_request.c + googlefs.c + http_cnx.c + lists2.c + parse_google_html.c + query.c + settings.c + string_utils.c + vnidpool.c +; diff --git a/src/add-ons/kernel/file_systems/googlefs/README.googlefs.txt b/src/add-ons/kernel/file_systems/googlefs/README.googlefs.txt new file mode 100644 index 0000000000..fb5df39d6c --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/README.googlefs.txt @@ -0,0 +1,29 @@ +Welcome to the Google™ FileSystem for BeOS™, Zeta™ and Haiku™. +Copyright© 2004, 2005, François Revol. +Google is a trademark of Google,Inc. +BeOS is a trademark of PalmSource. +Zeta is a trademark of yellowTAB GmbH. +Haiku is a trademark of Haiku Inc. + + +REQUIRES BONE + +mkdir /google; ndmount googlefs /google + +Use "Search Google" query template in this folder to ask google anything. + +or: + +query -v /google '((name=="*QUESTION*")&&(BEOS:TYPE=="application/x-vnd.Be-bookmark"))' +where QUESTION is what you want to ask google. (googlefs currently filters queries to only answer those) +( you will want to pipe that to catattr: +query -v /google '((name=="*site:bebits.com bone*")&&(BEOS:TYPE=="application/x-vnd.Be-bookmark"))' | xargs catattr META:url +note that won't work with sync_unlink true in the settings) + +Included are 2 scripts, google and imlucky that runs such a query using the arguments given on the command line. + +An addon for Ingo Weinhold's UserlandFS is provided, compiled with debug printouts, so you can see it at work. +To use it, startUserlandFSServer and run: +ufs_mount googlefs /dev/zero /google + +Enjoy. \ No newline at end of file diff --git a/src/add-ons/kernel/file_systems/googlefs/_APP_ b/src/add-ons/kernel/file_systems/googlefs/_APP_ new file mode 120000 index 0000000000..8ca1583101 --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/_APP_ @@ -0,0 +1 @@ +/boot/home/config/bin/UserlandFSServer \ No newline at end of file diff --git a/src/add-ons/kernel/file_systems/googlefs/attr2c b/src/add-ons/kernel/file_systems/googlefs/attr2c new file mode 100755 index 0000000000..a5ac610b2e --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/attr2c @@ -0,0 +1,10 @@ +#!/bin/sh + +if [ $# -lt 2 ]; then + echo "attr2c attrname file" + exit 1 +fi +#for R5 catattr +/bin/catattr "$1" "$2" | tail +2 | cut -c 10-57 | sed 's/,/, 0x/g;s/ / 0x/;s/ *//;s/$/,/' +#for zeta ?? +#catattr "$1" "$2" | tail +2 | cut -c 10-57 | sed 's/,/, 0x/g;s/ / 0x/;s/ *//;s/$/,/' diff --git a/src/add-ons/kernel/file_systems/googlefs/attrs.c b/src/add-ons/kernel/file_systems/googlefs/attrs.c new file mode 100644 index 0000000000..382f628a40 --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/attrs.c @@ -0,0 +1,273 @@ +#include +#include "googlefs.h" + +#define SZSTR(s) sizeof(s), s +#define SZTAB(s) sizeof(s), s + +extern const char google_icon_M[]; +extern const char google_icon_L[]; + + +struct attr_entry root_folder_attrs[] = { +{ "BEOS:TYPE", /*B_MIME_STRING_TYPE*/'MIMS', SZSTR("application/x-vnd.Be-directory") }, +{ "BEOS:M:STD_ICON", 'MICN', 16*16, google_icon_M }, +{ "BEOS:L:STD_ICON", 'ICON', 32*32, google_icon_L }, +//{ "BEOS:EMBLEMS", 'CSTR', SZSTR("palm") }, +{ NULL, 0, 0, NULL } /* end of list */ +}; + +static uint8 folders_attrs_1[] = { + 0x52, 0x56, 0xf2, 0x4f, 0x15, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x54, 0x69, 0x74, 0x6c, + 0x65, 0x00, 0x00, 0x00, 0x20, 0x42, 0x00, 0x00, 0x02, 0x43, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, + 0x00, 0x00, 0x4d, 0x45, 0x54, 0x41, 0x3a, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x00, 0x52, 0x7d, 0xfb, + 0x77, 0x52, 0x54, 0x53, 0x43, 0x00, 0x01, 0x52, 0x56, 0xf2, 0x4f, 0x15, 0x00, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x55, 0x52, 0x4c, 0x00, 0x00, 0x00, 0x39, 0x43, 0x00, 0x00, 0x2a, 0x43, 0x00, + 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x4d, 0x45, 0x54, 0x41, 0x3a, 0x75, 0x72, 0x6c, 0x00, + 0x52, 0x54, 0x5b, 0xe3, 0x52, 0x54, 0x53, 0x43, 0x00, 0x01, 0x52, 0x56, 0xf2, 0x4f, 0x15, 0x00, + 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x4b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x73, 0x00, 0x00, + 0x00, 0xb9, 0x43, 0x00, 0x00, 0x02, 0x43, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x4d, + 0x45, 0x54, 0x41, 0x3a, 0x6b, 0x65, 0x79, 0x77, 0x00, 0x52, 0xdc, 0xf3, 0xdb, 0x52, 0x54, 0x53, + 0x43, 0x00, 0x01, 0x52, 0x56, 0xf2, 0x4f, 0x15, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x4d, + 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x00, 0x00, 0xc0, 0x00, 0x44, 0x00, 0x00, 0x16, 0x43, + 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x2f, 0x6d, 0x6f, + 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x00, 0x45, 0x6d, 0x4b, 0x5d, 0x45, 0x4d, 0x49, 0x54, 0x01, + 0x00, 0x52, 0x56, 0xf2, 0x4f, 0x15, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x47, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x20, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x00, 0x00, 0x00, 0x2a, 0x44, 0x00, 0x00, + 0xa0, 0x41, 0x01, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x47, 0x4f, 0x4f, 0x47, 0x4c, 0x45, + 0x3a, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x00, 0x47, 0xde, 0xef, 0xfc, 0x47, 0x4e, 0x4f, 0x4c, 0x00, + 0x01 }; +static uint8 folders_attrs_2[] = { + 0x52, 0xf5, 0x5e, 0x6f, 0x0a, 0x00, 0x00, 0x00, 0x74, 0x73, 0x6c, 0x54, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x47, 0xde, 0xef, 0xfc, 0x47, 0x4e, 0x4f, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01 }; +struct attr_entry folders_attrs[] = { +{ "BEOS:TYPE", /*B_MIME_STRING_TYPE*/'MIMS', SZSTR("application/x-vnd.Be-directory") }, +{ "_trk/columns_le", 'RAWT', SZTAB(folders_attrs_1) }, +{ "_trk/viewstate_le", 'RAWT', SZTAB(folders_attrs_2) }, +{ "", 'RAWT', SZTAB(folders_attrs_2) }, +{ NULL, 0, 0, NULL } /* end of list */ +}; + +struct attr_entry bookmark_attrs[] = { +{ "BEOS:TYPE", /*B_MIME_STRING_TYPE*/'MIMS', SZSTR("application/x-vnd.Be-bookmark") }, +{ NULL, 0, 0, NULL } /* end of list */ +}; + +/* for debugging */ +static int32 fake_bm_attr_1 = 1; +struct attr_entry fake_bookmark_attrs[] = { +{ "BEOS:TYPE", /*B_MIME_STRING_TYPE*/'MIMS', SZSTR("application/x-vnd.Be-bookmark") }, +{ "META:title", 'CSTR', SZSTR("Plop!") }, +{ "META:url", 'CSTR', SZSTR("http://127.0.0.1/") }, +{ "META:keyw", 'CSTR', SZSTR("plop") }, +//{ "GOOGLE:order", 'LONG', sizeof(int32), &fake_bm_attr_1 }, +{ NULL, 0, 0, NULL } /* end of list */ +}; + +static uint8 template_1_attrs_1 = 1; +static int32 template_1_attrs_2 = 1; +static uint8 template_1_attrs_3[] = { + 0x31, 0x42, 0x4F, 0x46, 0x01, 0x00, 0x00, 0x98, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x0F, 0x47, 0x4E, 0x4F, 0x4C, 0x04, 0x0C, 0x63, 0x72, 0x65, 0x61, 0x74, 0x69, 0x6F, 0x6E, + 0x44, 0x61, 0x74, 0x65, 0x51, 0xEA, 0xC7, 0x41, 0x0F, 0x47, 0x4E, 0x4C, 0x4C, 0x08, 0x08, 0x63, + 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, + 0x52, 0x54, 0x53, 0x43, 0x08, 0x0A, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x4E, 0x61, 0x6D, 0x65, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x41, 0x0B, 0x52, 0x54, 0x53, 0x43, 0x10, 0x0A, 0x76, + 0x6F, 0x6C, 0x75, 0x6D, 0x65, 0x4E, 0x61, 0x6D, 0x65, 0x07, 0x00, 0x00, 0x00, 0x47, 0x6F, 0x6F, + 0x67, 0x6C, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0x52, 0x54, 0x53, 0x43, 0x10, 0x07, + 0x66, 0x73, 0x68, 0x4E, 0x61, 0x6D, 0x65, 0x09, 0x00, 0x00, 0x00, 0x67, 0x6F, 0x6F, 0x67, 0x6C, + 0x65, 0x66, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static int32 template_1_attrs_4 = 0x4662796E; +static uint8 template_1_attrs_5[] = { + 0x00, 0x00, 0x06, 0xEC, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 }; +static int32 template_1_attrs_6 = 0x00000027; +static int32 template_1_attrs_7 = 0x00000000; +static uint8 template_1_attrs_8[] = { + 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x82, 0x43, 0x00, 0x00, 0xA0, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xE0, 0x9F, 0x44, 0x00, 0xC0, 0x7F, 0x44, 0xFF, 0xFF, 0xFF, 0xFF }; +static uint8 template_1_attrs_9[] = { + 0x00, 0x00, 0x00, 0x00, 0x58, 0x10, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x44, + 0x00, 0x00, 0x0c, 0x44 }; +static uint8 template_1_attrs_10[] = { + 0x52, 0x56, 0xf2, 0x4f, 0x15, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x54, 0x69, 0x74, 0x6c, + 0x65, 0x00, 0x00, 0x00, 0x20, 0x42, 0x00, 0x00, 0x50, 0x43, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, + 0x00, 0x00, 0x4d, 0x45, 0x54, 0x41, 0x3a, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x00, 0x52, 0x7d, 0xfb, + 0x77, 0x52, 0x54, 0x53, 0x43, 0x00, 0x01, 0x52, 0x56, 0xf2, 0x4f, 0x15, 0x00, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x55, 0x52, 0x4c, 0x00, 0x00, 0x80, 0x83, 0x43, 0x00, 0x80, 0x85, 0x43, 0x00, + 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x4d, 0x45, 0x54, 0x41, 0x3a, 0x75, 0x72, 0x6c, 0x00, + 0x52, 0x54, 0x5b, 0xe3, 0x52, 0x54, 0x53, 0x43, 0x00, 0x01, 0x52, 0x56, 0xf2, 0x4f, 0x15, 0x00, + 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x4b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x73, 0x00, 0x00, + 0x40, 0x08, 0x44, 0x00, 0x00, 0x02, 0x43, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x4d, + 0x45, 0x54, 0x41, 0x3a, 0x6b, 0x65, 0x79, 0x77, 0x00, 0x52, 0xdc, 0xf3, 0xdb, 0x52, 0x54, 0x53, + 0x43, 0x00, 0x01, 0x52, 0x56, 0xf2, 0x4f, 0x15, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x4d, + 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x00, 0x00, 0x80, 0x2c, 0x44, 0x00, 0x00, 0x16, 0x43, + 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x2f, 0x6d, 0x6f, + 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x00, 0x45, 0x6d, 0x4b, 0x5d, 0x45, 0x4d, 0x49, 0x54, 0x01, + 0x00, 0x52, 0x56, 0xf2, 0x4f, 0x15, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x47, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x20, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x00, 0x00, 0xc0, 0x55, 0x44, 0x00, 0x00, + 0x70, 0x41, 0x01, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x47, 0x4f, 0x4f, 0x47, 0x4c, 0x45, + 0x3a, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x00, 0x47, 0xde, 0xef, 0xfc, 0x47, 0x4e, 0x4f, 0x4c, 0x00, + 0x00 }; +static uint8 template_1_attrs_11[] = { + 0x52, 0xf5, 0x5e, 0x6f, 0x0a, 0x00, 0x00, 0x00, 0x74, 0x73, 0x6c, 0x54, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x47, 0xde, 0xef, 0xfc, 0x47, 0x4e, 0x4f, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01 }; +struct attr_entry template_1_attrs[] = { +{ "BEOS:TYPE", /*B_MIME_STRING_TYPE*/'MIMS', SZSTR("application/x-vnd.Be-queryTemplate") }, +{ "_trk/qrystr", 'CSTR', SZSTR("((name==\"*[aA][nN][yY] [qQ][uU][eE][sS][tT][iI][oO][nN] [yY][oO][uU]\\'[dD] [lL][iI][kK][eE] [tT][oO] [aA][sS][kK] [gG][oO][oO][gG][lL][eE] ?*\")&&(BEOS:TYPE==\"application/x-vnd.Be-bookmark\"))") }, +{ "_trk/queryDynamicDate", 'BOOL', 1, &template_1_attrs_1 }, +{ "_trk/recentQuery", 'LONG', sizeof(int32), &template_1_attrs_2 }, +{ "_trk/qryvol1", 'MSGG', SZTAB(template_1_attrs_3) }, +{ "_trk/qryinitmime", 'CSTR', SZSTR("Bookmark") }, +{ "_trk/qryinitmode", 'LONG', sizeof(int32), &template_1_attrs_4 }, +{ "_trk/qrymoreoptions_le", 'RAWT', SZTAB(template_1_attrs_5) }, +{ "_trk/qryinitstr", 'CSTR', SZSTR("Any question you'd like to ask google ?") }, +{ "_trk/focusedView", 'CSTR', SZSTR("TextControl") }, +{ "_trk/focusedSelEnd", 'LONG', sizeof(int32), &template_1_attrs_6 }, +{ "_trk/focusedSelStart", 'LONG', sizeof(int32), &template_1_attrs_7 }, +{ "_trk/xtpinfo_le", 'RAWT', SZTAB(template_1_attrs_8) }, +{ "_trk/pinfo_le", 'RAWT', SZTAB(template_1_attrs_9) }, +{ "_trk/columns_le", 'RAWT', SZTAB(folders_attrs_1)/*SZTAB(template_1_attrs_10)*/ }, +{ "_trk/viewstate_le", 'RAWT', SZTAB(template_1_attrs_11) }, +{ NULL, 0, 0, NULL } /* end of list */ +}; + +static int32 text_attrs_1 = 0x0000FFFF; +static int32 text_attrs_2 = 0x00000000; +static uint8 text_attrs_3 = 1; +static uint8 text_attrs_4[] = { + 0x41, 0x6c, 0x69, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, + 0x53, 0x77, 0x69, 0x73, 0x37, 0x32, 0x31, 0x20, 0x42, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x52, 0x6f, 0x6d, 0x61, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x41, 0x60, 0x00, 0x00, 0x42, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x28, 0x53, 0x77, 0x69, 0x73, 0x37, 0x32, 0x31, 0x20, 0x42, 0x54, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x52, 0x6f, 0x6d, 0x61, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x41, 0x60, 0x00, 0x00, 0x42, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x29, 0x53, 0x77, 0x69, 0x73, 0x37, 0x32, 0x31, 0x20, + 0x42, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x52, 0x6f, 0x6d, 0x61, 0x6e, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x60, 0x00, 0x00, 0x42, 0xb4, 0x00, 0x00, + 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x53, 0x77, 0x69, 0x73, + 0x37, 0x32, 0x31, 0x20, 0x42, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x52, 0x6f, 0x6d, 0x61, + 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x60, 0x00, 0x00, + 0x42, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, + 0x53, 0x77, 0x69, 0x73, 0x37, 0x32, 0x31, 0x20, 0x42, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x52, 0x6f, 0x6d, 0x61, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x41, 0x20, 0x00, 0x00, 0x42, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00 }; +struct attr_entry text_attrs[] = { +{ "BEOS:TYPE", /*B_MIME_STRING_TYPE*/'MIMS', SZSTR("text/plain") }, +{ "be:encoding", 'LONG', sizeof(int32), &text_attrs_1 }, +{ "alignment", 'LONG', sizeof(int32), &text_attrs_2 }, +{ "wrap", 'BOOL', sizeof(uint8), &text_attrs_3 }, +{ "styles", 'RAWT', SZTAB(text_attrs_4) }, +{ NULL, 0, 0, NULL } /* end of list */ +}; + +char *readmestr = \ +"Welcome to the Google™ FileSystem for BeOS™, Zeta™ and Haiku™. +Copyright© 2004, 2005, François Revol. +Google is a trademark of Google,Inc. +BeOS is a trademark of PalmSource. +Zeta is a trademark of yellowTAB GmbH. +Haiku is a trademark of Haiku Inc. + +Use \"Search Google\" query template in this folder to ask google anything. +"; + +struct attr_entry mailto_me_bookmark_attrs[] = { +{ "BEOS:TYPE", /*B_MIME_STRING_TYPE*/'MIMS', SZSTR("application/x-person") }, +{ "META:email", 'CSTR', SZSTR("revol@free.fr") }, +{ "META:name", 'CSTR', SZSTR("François Revol") }, +{ "META:country", 'CSTR', SZSTR("France") }, +{ "META:nickname", 'CSTR', SZSTR("mmu_man") }, +{ "META:company", 'CSTR', SZSTR("yellowTAB GmbH") }, +{ "META:url", 'CSTR', SZSTR("") }, +{ "META:group", 'CSTR', SZSTR("") }, +{ "IM:connections", 'CSTR', SZSTR("icq:77792625") }, +#if 0 +{ "BEOS:TYPE", /*B_MIME_STRING_TYPE*/'MIMS', SZSTR("application/x-vnd.Be-bookmark") }, +{ "META:title", 'CSTR', SZSTR("Report googlefs bugs") }, +{ "META:url", 'CSTR', SZSTR("mailto:revol@free.fr"/*"&subject=googlefs bug report""&body=Hi, I found a bug in GoogleFS."*/) }, +{ "META:keyw", 'CSTR', SZSTR("googlefs") }, +//{ "GOOGLE:order", 'LONG', sizeof(int32), &fake_bm_attr_1 }, +#endif +{ NULL, 0, 0, NULL } /* end of list */ +}; + +#if 0 +File: Search Google a +Type Size Name Value +---------- ---------- ---------------------------------- ----------------------------------------------------------------- +'MIMS' 35 "BEOS:TYPE" "application/x-vnd.Be-queryTemplate" +STRING 191 "_trk/qrystr" "((name==\"*[aA][nN][yY] [qQ][uU][eE][sS][tT][iI][oO][nN] [yY][o" + "O][uU]\\'[dD] [lL][iI][kK][eE] [tT][oO] [aA][sS][kK] [gG][oO][o" + "O][gG][lL][eE] ?*\")&&(BEOS:TYPE==\"application/x-vnd.Be-bookma" + "rk\"))" +BOOL 1 "_trk/queryDynamicDate" TRUE +INT32 4 "_trk/recentQuery" 1 0x00000001 + 01 0F 47 4E 4F 4C 04 0C-63 72 65 61 74 69 6F 6E ..GNOL..creation + 44 61 74 65 51 EA C7 41-0F 47 4E 4C 4C 08 08 63 DateQ..A.GNLL..c + 61 70 61 63 69 74 79 00-00 00 00 00 00 00 00 0B apacity......... + 52 54 53 43 08 0A 64 65-76 69 63 65 4E 61 6D 65 RTSC..deviceName + 01 00 00 00 00 00 70 41-0B 52 54 53 43 10 0A 76 ......pA.RTSC..v + 6F 6C 75 6D 65 4E 61 6D-65 07 00 00 00 47 6F 6F olumeName....Goo + 67 6C 65 00 00 00 00 00-00 0B 52 54 53 43 10 07 gle.......RTSC.. + 66 73 68 4E 61 6D 65 09-00 00 00 67 6F 6F 67 6C fshName....googl + 65 66 73 00 00 00 00 00- efs..... +STRING 9 "_trk/qryinitmime" "Bookmark" +INT32 4 "_trk/qryinitmode" 1180858734 0x4662796E +RAW 36 "_trk/qrymoreoptions_le" 00 00 06 EC 00 00 00 00-01 00 00 00 00 00 00 00 ................ + 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ + 00 00 00 00 - .... +STRING 40 "_trk/qryinitstr" "Any question you'd like to ask google ?" +STRING 12 "_trk/focusedView" "TextControl" +INT32 4 "_trk/focusedSelEnd" 39 0x00000027 +INT32 4 "_trk/focusedSelStart" 0 0x00000000 +RAW 60 "_trk/xtpinfo_le" FF FF FF FF 00 00 00 00-00 00 00 00 00 00 00 00 ................ + 00 00 00 00 00 00 00 00-00 00 00 00 01 00 00 00 ................ + 00 00 82 43 00 00 A0 42-00 00 00 00 00 00 00 00 ...C...B........ + 00 E0 9F 44 00 C0 7F 44-FF FF FF FF ...D...D.... +#endif +#if 0 +, 0x41, 0x6E, 0x79, 0x20, 0x71, 0x75, 0x65, 0x73-74, 0x69, 0x6F, 0x6E, 0x20, 0x79, 0x6F, 0x75 +, 0x27, 0x64, 0x20, 0x6C, 0x69, 0x6B, 0x65, 0x20-74, 0x6F, 0x20, 0x61, 0x73, 0x6B, 0x20, 0x67 +, 0x6F, 0x6F, 0x67, 0x6C, 0x65, 0x20, 0x3F, 0x00-, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x +, 0x54, 0x65, 0x78, 0x74, 0x43, 0x6F, 0x6E, 0x74-72, 0x6F, 0x6C, 0x00, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x +, 0x27, 0x00, 0x00, 0x00, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x-, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x +, 0x00, 0x00, 0x00, 0x00, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x-, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x +#endif diff --git a/src/add-ons/kernel/file_systems/googlefs/attrs.h b/src/add-ons/kernel/file_systems/googlefs/attrs.h new file mode 100644 index 0000000000..417b89b36c --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/attrs.h @@ -0,0 +1,45 @@ + +, 0xValue, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x +, 0x----------------------------------------------- +, 0x61, 0x70, 0x70, 0x6C, 0x69, 0x63, 0x61, 0x74-69, 0x6F, 0x6E, 0x2F, 0x78, 0x2D, 0x76, 0x6E +, 0x64, 0x2E, 0x42, 0x65, 0x2D, 0x71, 0x75, 0x65-72, 0x79, 0x54, 0x65, 0x6D, 0x70, 0x6C, 0x61 +, 0x74, 0x65, 0x00, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x-, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x +, 0x28, 0x28, 0x6E, 0x61, 0x6D, 0x65, 0x3D, 0x3D-22, 0x2A, 0x5B, 0x61, 0x41, 0x5D, 0x5B, 0x6E +, 0x4E, 0x5D, 0x5B, 0x79, 0x59, 0x5D, 0x20, 0x5B-71, 0x51, 0x5D, 0x5B, 0x75, 0x55, 0x5D, 0x5B +, 0x65, 0x45, 0x5D, 0x5B, 0x73, 0x53, 0x5D, 0x5B-74, 0x54, 0x5D, 0x5B, 0x69, 0x49, 0x5D, 0x5B +, 0x6F, 0x4F, 0x5D, 0x5B, 0x6E, 0x4E, 0x5D, 0x20-5B, 0x79, 0x59, 0x5D, 0x5B, 0x6F, 0x4F, 0x5D +, 0x5B, 0x75, 0x55, 0x5D, 0x5C, 0x27, 0x5B, 0x64-44, 0x5D, 0x20, 0x5B, 0x6C, 0x4C, 0x5D, 0x5B +, 0x69, 0x49, 0x5D, 0x5B, 0x6B, 0x4B, 0x5D, 0x5B-65, 0x45, 0x5D, 0x20, 0x5B, 0x74, 0x54, 0x5D +, 0x5B, 0x6F, 0x4F, 0x5D, 0x20, 0x5B, 0x61, 0x41-5D, 0x5B, 0x73, 0x53, 0x5D, 0x5B, 0x6B, 0x4B +, 0x5D, 0x20, 0x5B, 0x67, 0x47, 0x5D, 0x5B, 0x6F-4F, 0x5D, 0x5B, 0x6F, 0x4F, 0x5D, 0x5B, 0x67 +, 0x47, 0x5D, 0x5B, 0x6C, 0x4C, 0x5D, 0x5B, 0x65-45, 0x5D, 0x20, 0x3F, 0x2A, 0x22, 0x29, 0x26 +, 0x26, 0x28, 0x42, 0x45, 0x4F, 0x53, 0x3A, 0x54-59, 0x50, 0x45, 0x3D, 0x3D, 0x22, 0x61, 0x70 +, 0x70, 0x6C, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6F-6E, 0x2F, 0x78, 0x2D, 0x76, 0x6E, 0x64, 0x2E +, 0x42, 0x65, 0x2D, 0x62, 0x6F, 0x6F, 0x6B, 0x6D-61, 0x72, 0x6B, 0x22, 0x29, 0x29, 0x00, 0x, 0x, 0x +, 0xFD, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x-, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x +, 0x01, 0x00, 0x00, 0x00, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x-, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x +, 0x31, 0x42, 0x4F, 0x46, 0x01, 0x00, 0x00, 0x98-98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +, 0x01, 0x0F, 0x47, 0x4E, 0x4F, 0x4C, 0x04, 0x0C-63, 0x72, 0x65, 0x61, 0x74, 0x69, 0x6F, 0x6E +, 0x44, 0x61, 0x74, 0x65, 0x51, 0xEA, 0xC7, 0x41-0F, 0x47, 0x4E, 0x4C, 0x4C, 0x08, 0x08, 0x63 +, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x00-00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B +, 0x52, 0x54, 0x53, 0x43, 0x08, 0x0A, 0x64, 0x65-76, 0x69, 0x63, 0x65, 0x4E, 0x61, 0x6D, 0x65 +, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x41-0B, 0x52, 0x54, 0x53, 0x43, 0x10, 0x0A, 0x76 +, 0x6F, 0x6C, 0x75, 0x6D, 0x65, 0x4E, 0x61, 0x6D-65, 0x07, 0x00, 0x00, 0x00, 0x47, 0x6F, 0x6F +, 0x67, 0x6C, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00-00, 0x0B, 0x52, 0x54, 0x53, 0x43, 0x10, 0x07 +, 0x66, 0x73, 0x68, 0x4E, 0x61, 0x6D, 0x65, 0x09-00, 0x00, 0x00, 0x67, 0x6F, 0x6F, 0x67, 0x6C +, 0x65, 0x66, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00-, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x +, 0x42, 0x6F, 0x6F, 0x6B, 0x6D, 0x61, 0x72, 0x6B-00, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x +, 0x6E, 0x79, 0x62, 0x46, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x-, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x +, 0x00, 0x00, 0x06, 0xEC, 0x00, 0x00, 0x00, 0x00-01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00-00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +, 0x00, 0x00, 0x00, 0x00, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x-, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x +, 0x41, 0x6E, 0x79, 0x20, 0x71, 0x75, 0x65, 0x73-74, 0x69, 0x6F, 0x6E, 0x20, 0x79, 0x6F, 0x75 +, 0x27, 0x64, 0x20, 0x6C, 0x69, 0x6B, 0x65, 0x20-74, 0x6F, 0x20, 0x61, 0x73, 0x6B, 0x20, 0x67 +, 0x6F, 0x6F, 0x67, 0x6C, 0x65, 0x20, 0x3F, 0x00-, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x +, 0x54, 0x65, 0x78, 0x74, 0x43, 0x6F, 0x6E, 0x74-72, 0x6F, 0x6C, 0x00, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x +, 0x27, 0x00, 0x00, 0x00, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x-, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x +, 0x00, 0x00, 0x00, 0x00, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x-, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x +, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00-00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00-00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 +, 0x00, 0x00, 0x82, 0x43, 0x00, 0x00, 0xA0, 0x42-00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +, 0x00, 0xE0, 0x9F, 0x44, 0x00, 0xC0, 0x7F, 0x44-FF, 0xFF, 0xFF, 0xFF, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x diff --git a/src/add-ons/kernel/file_systems/googlefs/attrs.txt b/src/add-ons/kernel/file_systems/googlefs/attrs.txt new file mode 100644 index 0000000000..eb805c8ce3 --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/attrs.txt @@ -0,0 +1,33 @@ +File: Search Google a +Type Size Name Value +---------- ---------- ---------------------------------- ----------------------------------------------------------------- +'MIMS' 35 "BEOS:TYPE" "application/x-vnd.Be-queryTemplate" +STRING 191 "_trk/qrystr" "((name==\"*[aA][nN][yY] [qQ][uU][eE][sS][tT][iI][oO][nN] [yY][o" + "O][uU]\\'[dD] [lL][iI][kK][eE] [tT][oO] [aA][sS][kK] [gG][oO][o" + "O][gG][lL][eE] ?*\")&&(BEOS:TYPE==\"application/x-vnd.Be-bookma" + "rk\"))" +BOOL 1 "_trk/queryDynamicDate" TRUE +INT32 4 "_trk/recentQuery" 1 0x00000001 +MESSAGE 152 "_trk/qryvol1" 31 42 4F 46 01 00 00 98-98 00 00 00 00 00 00 00 1BOF............ + 01 0F 47 4E 4F 4C 04 0C-63 72 65 61 74 69 6F 6E ..GNOL..creation + 44 61 74 65 51 EA C7 41-0F 47 4E 4C 4C 08 08 63 DateQ..A.GNLL..c + 61 70 61 63 69 74 79 00-00 00 00 00 00 00 00 0B apacity......... + 52 54 53 43 08 0A 64 65-76 69 63 65 4E 61 6D 65 RTSC..deviceName + 01 00 00 00 00 00 70 41-0B 52 54 53 43 10 0A 76 ......pA.RTSC..v + 6F 6C 75 6D 65 4E 61 6D-65 07 00 00 00 47 6F 6F olumeName....Goo + 67 6C 65 00 00 00 00 00-00 0B 52 54 53 43 10 07 gle.......RTSC.. + 66 73 68 4E 61 6D 65 09-00 00 00 67 6F 6F 67 6C fshName....googl + 65 66 73 00 00 00 00 00- efs..... +STRING 9 "_trk/qryinitmime" "Bookmark" +INT32 4 "_trk/qryinitmode" 1180858734 0x4662796E +RAW 36 "_trk/qrymoreoptions_le" 00 00 06 EC 00 00 00 00-01 00 00 00 00 00 00 00 ................ + 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ + 00 00 00 00 - .... +STRING 40 "_trk/qryinitstr" "Any question you'd like to ask google ?" +STRING 12 "_trk/focusedView" "TextControl" +INT32 4 "_trk/focusedSelEnd" 39 0x00000027 +INT32 4 "_trk/focusedSelStart" 0 0x00000000 +RAW 60 "_trk/xtpinfo_le" FF FF FF FF 00 00 00 00-00 00 00 00 00 00 00 00 ................ + 00 00 00 00 00 00 00 00-00 00 00 00 01 00 00 00 ................ + 00 00 82 43 00 00 A0 42-00 00 00 00 00 00 00 00 ...C...B........ + 00 E0 9F 44 00 C0 7F 44-FF FF FF FF ...D...D.... diff --git a/src/add-ons/kernel/file_systems/googlefs/bin/google b/src/add-ons/kernel/file_systems/googlefs/bin/google new file mode 100755 index 0000000000..c0f099f95e --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/bin/google @@ -0,0 +1,2 @@ +#!/bin/sh +query -v /google/ '((name=="*'"$*"'*")&&(BEOS:TYPE=="application/x-vnd.Be-bookmark"))' | xargs catattr META:url diff --git a/src/add-ons/kernel/file_systems/googlefs/bin/imlucky b/src/add-ons/kernel/file_systems/googlefs/bin/imlucky new file mode 100755 index 0000000000..639343c2ca --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/bin/imlucky @@ -0,0 +1,2 @@ +#!/bin/sh +query -v /google/ '((name=="*'"$*"'*")&&(BEOS:TYPE=="application/x-vnd.Be-bookmark"))' | xargs catattr META:url | head -1 diff --git a/src/add-ons/kernel/file_systems/googlefs/bookmark.mime b/src/add-ons/kernel/file_systems/googlefs/bookmark.mime new file mode 100644 index 0000000000..958b89d02e --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/bookmark.mime @@ -0,0 +1,33 @@ +/bin/setmime -set application/x-vnd.Be-bookmark -short "Bookmark" -long "Bookmark for a web page." -preferredAppSig application/x-vnd.Be-NPOS \ + -attribute "META:url" -attrName "URL" \ + -attrType 'CSTR' -attrWidth 170 -attrAlignment left \ + -attrViewable 1 -attrEditable 1 -attrExtra 0 \ + -attribute "META:keyw" -attrName "Keywords" \ + -attrType 'CSTR' -attrWidth 130 -attrAlignment left \ + -attrViewable 1 -attrEditable 1 -attrExtra 0 \ + -attribute "META:title" -attrName "Title" \ + -attrType 'CSTR' -attrWidth 130 -attrAlignment left \ + -attrViewable 1 -attrEditable 1 -attrExtra 0 \ + -attribute "GOOGLE:order" -attrName "Google order" \ + -attrType 'LONG' -attrWidth 40 -attrAlignment right \ + -attrViewable 1 -attrEditable 1 -attrExtra 0 \ + -miniIcon ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000ffffffffffffffffffffffff00003f1b0000ffffffff\ +ffffffffff001b1c3f3f3f1b0000ffffffffffffff0000111b1c3f3f3f1b0000ffffff00002d2c0000111b1c3f000e5dffff003f00002d2c2d00001b000f5d00\ +ffff003f1b1c00002d2c2d000f5d00ffff001b3f3f3f1b1c00002d2c000011ffff001b1c3f3f3f3f1b00002c2d2d0000005d00001c1b3f3f000e5d00002d2c00\ +00005d1c00001c000f5d00ffff00003fffff00005d1b000f5d00ffffffffffffffffffff00005d5d00ffffffffffffffffffffffffff0000ffffffffffffffff \ + -largeIcon ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\ +ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\ +ffffffffffffffffffffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff003f0000ffffffffffffffffffffff\ +ffffffffffffffffffffffffffffffff001b1c3f3f0000ffffffffffffffffffffffffffffffffffffffffffff0000003f191a1b1c3f3f0000ffffffffffffff\ +ffffffffffffffffffffffff003f3f3f3f3f3f191a1b1c3f3f0000ffffffffffffffffffffffffffffffff001b1c1b3f3f3f3f3f3f191a1b1c3f3f000000ffff\ +ffffffffffffffffffff000000151b1c1c3f3f3f3f3f3f191a1b1c3f3f0000ffffffffffffffffffffff002b2a0000151b1c1c3f3f3f3f3f3f191a1b1c0000ff\ +ffffffffffffffffff00302c2d2b2a0000151b1c1c3f3f3f3f1b1c00001b00ffffffffffffffff00000000302f2c2d2b2b0100151c1b1c3f1b00001c0f005d00\ +ffffffffffff001b1c0f0f0000302f2c2d2b2b0100151c1b001c0f0f005d00ffffffffffff001b1c1b1c1c0f0e00002f302c2d2b2a000016000f1b005d000fff\ +ffffffff003f3f3f3f1b1c1b1c0f0f00002f302c2d2b2a00001b005d000fffffffffffff003f3f3f3f3f3f1b1c1b1c0f0f00002f302b313132005d000fffffff\ +ffffff003f3f3f3f3f3f3f3f3f1b1c1b1c0f0f00002f32313200000fffffffffffffff001b3f3f3f3f3f3f3f3f3f3f1b1c1b1c1c00003231320000000f0fffff\ +ffff003f1b3f1b3f3f3f3f3f3f3f3f3f3f1b000000000031312d2b2a00000f0fff00003f3f3f1b3f3f3f3f3f3f3f3f3f3f000e0f1c000031312c2d2c2b2b0000\ +ff1b0000003f3f1b1c3f3f3f3f3f3f3f000e1c3f005d000000002d2c2d2d000fff00003f3f00003f3f1b1c3f3f3f3f3f001b3f005d00000effff00002d2c00ff\ +005d5d00003f3f00003f3f1b1c3f3f001b3f005d000effffffffffff000000ffff00005d5d00003f3f00003f3f1b3f001b005d000fffffffffffffffffffffff\ +ffffff00005d5d00003f3f00003f001b005d000fffffffffffffffffffffffffffffffffff00005d5d00003f3f001b005d000fffffffffffffffffffffffffff\ +ffffffffffffff00005d5d00003f005d000effffffffffffffffffffffffffffffffffffffffffffff00005d5d005d000effffffffffffffffffffffffffffff\ +ffffffffffffffffffffff00005d000effffffffffffffffffffffffffffffffffffffffffffffffffffffffff000effffffffffffffffffffffffffffffffff diff --git a/src/add-ons/kernel/file_systems/googlefs/config/googlefs b/src/add-ons/kernel/file_systems/googlefs/config/googlefs new file mode 100644 index 0000000000..6e84f13333 --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/config/googlefs @@ -0,0 +1,15 @@ +# googlefs configuration file +# + +# IP of the google server to query +server 66.102.11.99 + +# max number of vnodes allowed in the fs (to limit RAM usage) +# 10 <= allowed <= 1000000 +max_nodes 5000 + +# maximum number of results to ask google for +max_results 50 + +# delete result entries on last query close +sync_unlink 0 diff --git a/src/add-ons/kernel/file_systems/googlefs/fsproto.h b/src/add-ons/kernel/file_systems/googlefs/fsproto.h new file mode 100644 index 0000000000..f0d6421275 --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/fsproto.h @@ -0,0 +1,250 @@ +#ifndef _FSPROTO_H +#define _FSPROTO_H + +//#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef dev_t nspace_id; +typedef ino_t vnode_id; + +/* UGLY UGLY UGLY */ +#ifndef _DRIVERS_H +struct selectsync; +typedef struct selectsync selectsync; +#endif + + +/* + * PUBLIC PART OF THE FILE SYSTEM PROTOCOL + */ + +#define WSTAT_MODE 0x0001 +#define WSTAT_UID 0x0002 +#define WSTAT_GID 0x0004 +#define WSTAT_SIZE 0x0008 +#define WSTAT_ATIME 0x0010 +#define WSTAT_MTIME 0x0020 +#define WSTAT_CRTIME 0x0040 + +#define WFSSTAT_NAME 0x0001 + +#define B_ENTRY_CREATED 1 +#define B_ENTRY_REMOVED 2 +#define B_ENTRY_MOVED 3 +#define B_STAT_CHANGED 4 +#define B_ATTR_CHANGED 5 +#define B_DEVICE_MOUNTED 6 +#define B_DEVICE_UNMOUNTED 7 + +#define B_STOP_WATCHING 0x0000 +#define B_WATCH_NAME 0x0001 +#define B_WATCH_STAT 0x0002 +#define B_WATCH_ATTR 0x0004 +#define B_WATCH_DIRECTORY 0x0008 + +/* UGLY UGLY UGLY - that goes to Drivers.h too */ +#ifndef SELECT_READ +#define SELECT_READ 1 +#define SELECT_WRITE 2 +#define SELECT_EXCEPTION 3 +#endif + +#define B_CUR_FS_API_VERSION 2 + +struct attr_info; +struct index_info; + +typedef int op_read_vnode(void *ns, vnode_id vnid, char r, void **node); +typedef int op_write_vnode(void *ns, void *node, char r); +typedef int op_remove_vnode(void *ns, void *node, char r); +typedef int op_secure_vnode(void *ns, void *node); + +typedef int op_walk(void *ns, void *base, const char *file, char **newpath, + vnode_id *vnid); + +typedef int op_access(void *ns, void *node, int mode); + +typedef int op_create(void *ns, void *dir, const char *name, + int omode, int perms, vnode_id *vnid, void **cookie); +typedef int op_mkdir(void *ns, void *dir, const char *name, int perms); +typedef int op_symlink(void *ns, void *dir, const char *name, + const char *path); +typedef int op_link(void *ns, void *dir, const char *name, void *node); + +typedef int op_rename(void *ns, void *olddir, const char *oldname, + void *newdir, const char *newname); +typedef int op_unlink(void *ns, void *dir, const char *name); +typedef int op_rmdir(void *ns, void *dir, const char *name); + +typedef int op_readlink(void *ns, void *node, char *buf, size_t *bufsize); + +typedef int op_opendir(void *ns, void *node, void **cookie); +typedef int op_closedir(void *ns, void *node, void *cookie); +typedef int op_rewinddir(void *ns, void *node, void *cookie); +typedef int op_readdir(void *ns, void *node, void *cookie, long *num, + struct dirent *buf, size_t bufsize); + +typedef int op_open(void *ns, void *node, int omode, void **cookie); +typedef int op_close(void *ns, void *node, void *cookie); +typedef int op_free_cookie(void *ns, void *node, void *cookie); +typedef int op_read(void *ns, void *node, void *cookie, off_t pos, void *buf, + size_t *len); +typedef int op_write(void *ns, void *node, void *cookie, off_t pos, + const void *buf, size_t *len); +typedef int op_readv(void *ns, void *node, void *cookie, off_t pos, const iovec *vec, + size_t count, size_t *len); +typedef int op_writev(void *ns, void *node, void *cookie, off_t pos, const iovec *vec, + size_t count, size_t *len); +typedef int op_ioctl(void *ns, void *node, void *cookie, int cmd, void *buf, + size_t len); +typedef int op_setflags(void *ns, void *node, void *cookie, int flags); + +typedef int op_rstat(void *ns, void *node, struct stat *); +typedef int op_wstat(void *ns, void *node, struct stat *, long mask); +typedef int op_fsync(void *ns, void *node); + +typedef int op_select(void *ns, void *node, void *cookie, uint8 event, + uint32 ref, selectsync *sync); +typedef int op_deselect(void *ns, void *node, void *cookie, uint8 event, + selectsync *sync); + +typedef int op_initialize(const char *devname, void *parms, size_t len); +typedef int op_mount(nspace_id nsid, const char *devname, ulong flags, + void *parms, size_t len, void **data, vnode_id *vnid); +typedef int op_unmount(void *ns); +typedef int op_sync(void *ns); +typedef int op_rfsstat(void *ns, struct fs_info *); +typedef int op_wfsstat(void *ns, struct fs_info *, long mask); + + +typedef int op_open_attrdir(void *ns, void *node, void **cookie); +typedef int op_close_attrdir(void *ns, void *node, void *cookie); +typedef int op_rewind_attrdir(void *ns, void *node, void *cookie); +typedef int op_read_attrdir(void *ns, void *node, void *cookie, long *num, + struct dirent *buf, size_t bufsize); +typedef int op_remove_attr(void *ns, void *node, const char *name); +typedef int op_rename_attr(void *ns, void *node, const char *oldname, + const char *newname); +typedef int op_stat_attr(void *ns, void *node, const char *name, + struct attr_info *buf); + +typedef int op_write_attr(void *ns, void *node, const char *name, int type, + const void *buf, size_t *len, off_t pos); +typedef int op_read_attr(void *ns, void *node, const char *name, int type, + void *buf, size_t *len, off_t pos); + +typedef int op_open_indexdir(void *ns, void **cookie); +typedef int op_close_indexdir(void *ns, void *cookie); +typedef int op_rewind_indexdir(void *ns, void *cookie); +typedef int op_read_indexdir(void *ns, void *cookie, long *num, + struct dirent *buf, size_t bufsize); +typedef int op_create_index(void *ns, const char *name, int type, int flags); +typedef int op_remove_index(void *ns, const char *name); +typedef int op_rename_index(void *ns, const char *oldname, + const char *newname); +typedef int op_stat_index(void *ns, const char *name, struct index_info *buf); + +typedef int op_open_query(void *ns, const char *query, ulong flags, + port_id port, long token, void **cookie); +typedef int op_close_query(void *ns, void *cookie); +typedef int op_read_query(void *ns, void *cookie, long *num, + struct dirent *buf, size_t bufsize); + +typedef struct vnode_ops { + op_read_vnode (*read_vnode); + op_write_vnode (*write_vnode); + op_remove_vnode (*remove_vnode); + op_secure_vnode (*secure_vnode); + op_walk (*walk); + op_access (*access); + op_create (*create); + op_mkdir (*mkdir); + op_symlink (*symlink); + op_link (*link); + op_rename (*rename); + op_unlink (*unlink); + op_rmdir (*rmdir); + op_readlink (*readlink); + op_opendir (*opendir); + op_closedir (*closedir); + op_free_cookie (*free_dircookie); + op_rewinddir (*rewinddir); + op_readdir (*readdir); + op_open (*open); + op_close (*close); + op_free_cookie (*free_cookie); + op_read (*read); + op_write (*write); + op_readv (*readv); + op_writev (*writev); + op_ioctl (*ioctl); + op_setflags (*setflags); + op_rstat (*rstat); + op_wstat (*wstat); + op_fsync (*fsync); + op_initialize (*initialize); + op_mount (*mount); + op_unmount (*unmount); + op_sync (*sync); + op_rfsstat (*rfsstat); + op_wfsstat (*wfsstat); + op_select (*select); + op_deselect (*deselect); + op_open_indexdir (*open_indexdir); + op_close_indexdir (*close_indexdir); + op_free_cookie (*free_indexdircookie); + op_rewind_indexdir (*rewind_indexdir); + op_read_indexdir (*read_indexdir); + op_create_index (*create_index); + op_remove_index (*remove_index); + op_rename_index (*rename_index); + op_stat_index (*stat_index); + op_open_attrdir (*open_attrdir); + op_close_attrdir (*close_attrdir); + op_free_cookie (*free_attrdircookie); + op_rewind_attrdir (*rewind_attrdir); + op_read_attrdir (*read_attrdir); + op_write_attr (*write_attr); + op_read_attr (*read_attr); + op_remove_attr (*remove_attr); + op_rename_attr (*rename_attr); + op_stat_attr (*stat_attr); + op_open_query (*open_query); + op_close_query (*close_query); + op_free_cookie (*free_querycookie); + op_read_query (*read_query); +} vnode_ops; + +extern _IMPEXP_KERNEL int new_path(const char *path, char **copy); +extern _IMPEXP_KERNEL void free_path(char *p); + +extern _IMPEXP_KERNEL int notify_listener(int op, nspace_id nsid, + vnode_id vnida, vnode_id vnidb, + vnode_id vnidc, const char *name); +extern _IMPEXP_KERNEL void notify_select_event(selectsync *sync, uint32 ref); +extern _IMPEXP_KERNEL int send_notification(port_id port, long token, + ulong what, long op, nspace_id nsida, + nspace_id nsidb, vnode_id vnida, + vnode_id vnidb, vnode_id vnidc, + const char *name); +extern _IMPEXP_KERNEL int get_vnode(nspace_id nsid, vnode_id vnid, void **data); +extern _IMPEXP_KERNEL int put_vnode(nspace_id nsid, vnode_id vnid); +extern _IMPEXP_KERNEL int new_vnode(nspace_id nsid, vnode_id vnid, void *data); +extern _IMPEXP_KERNEL int remove_vnode(nspace_id nsid, vnode_id vnid); +extern _IMPEXP_KERNEL int unremove_vnode(nspace_id nsid, vnode_id vnid); +extern _IMPEXP_KERNEL int is_vnode_removed(nspace_id nsid, vnode_id vnid); + + +extern _EXPORT vnode_ops fs_entry; +extern _EXPORT int32 api_version; + +#endif diff --git a/src/add-ons/kernel/file_systems/googlefs/google-ext-search.html b/src/add-ons/kernel/file_systems/googlefs/google-ext-search.html new file mode 100644 index 0000000000..204055098a --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/google-ext-search.html @@ -0,0 +1,140 @@ +Google Search: google api help "frequently asked" -plop + +
Go to Google Home  
Web    Images    GroupsNew!    News    Froogle    more »
  
  Advanced Search
  Preferences    
+ +
 Web Results 1 - 50 of about 12,800 English pages over the past 3 months for google api help "frequently asked" -plop. (0.40 seconds) 
 
    Sponsored Links
Google Help
Better Understand Your Results &
Learn Fun Facts Too. Get More Info!
www.GoogleStore.com
See your message here...

Google Web APIs - FAQ
... a custom Java client library, documentation on how to use the ... You can find it at +http://api.google.com/GoogleSearch.wsdl ... need to get started is in googleapi.jar ... +
www.google.com/apis/api_faq.html - 29k - Cached - Similar pages

SEO Count - Keyword Ranking Tool - Frequently Asked Questions
Frequently Asked Questions. ... that Google only indexes the www version to help increase +Page ... Since the Google API provides results for UTF-8 Encoding we are able ... +
www.seocount.com/faq.php - 16k - Cached - Similar pages

eBay Hacks - Frequently Asked Questions
... If you need help getting started with eBay, you'd ... is concerned with programming and +the eBay API; that leaves ... 5.36934319 × 10 41 Joules, as reported by Google ... +
www.ebayhacks.com/exec/show/book_faq - 8k - 5 Dec 2004 - Cached - Similar pages

Free SOAP Resources, freeprogrammingresources.com
... The Google API is used as an example. ... Tutorials, Links FAQs. ... This page explains how +to get started editing the home page of your Manila site using SOAP to make ... +
www.freeprogrammingresources.com/soap.html - Similar pages

FAQ: SEO Search Engine Optimization Frequently Asked Questions
... come from the Top25Web.com server, and it is using the Google API which was recently +made available by Google. ... Post a message in our forums for more help! ... +
www.top25web.com/faq.html - 15k - Cached - Similar pages

Among Other Things » Google API Cocoa framework
... to be using the Google API for something ... NetBSD/dreamcast NetBSD/dreamcast: How to +use NetBSD/dreamcast NetBSD/dreamcast Frequently Asked Questions The ... +
interalia.org/archives/2003/ 03/24/google-api-cocoa-framework - 48k - Cached - Similar pages

Google Guide: Useful Links
... www.googleguide.com/searchLeader.html; Google's Online Help: Google Help Central - +www.google.com/help/; ... Google Web API - www.google.com/apis/ API stands ... +
www.googleguide.com/links.html - 12k - 6 Dec 2004 - Cached - Similar pages

FAQ: Very Frequently Asked Questions (with answers) v1.29
... some of the questions that are most frequently asked in comp ... Google search: +<URL:http://groups.google.com/groups ... URLs contain information on how to reinstate ... +
www.codecomments.com/Clipper/message320018.html - 23k - Cached - Similar pages

comp.lang.prolog Frequently Asked Questions
... For details on how to join or send in contributions, check ... readers who would be glad +to help people making a ... Yes, there are: Google Groups has archives of news ... +
www.codecomments.com/Prolog/message321541.html - 42k - Cached - Similar pages
[ More results from www.codecomments.com ]

Frequently Asked Questions
... Frequently Asked Questions. ... Since the API is entirely modular, we are looking for +people who can help fix bugs or add enhancements to the project. ... +
open.echomine.org/cowiki/20.html - 36k - Cached - Similar pages

Chat11.com: SEM - Paid Inclusion Doesn't Seem To Be Helping
... Google, ... I Thought Paid Inclusion Would Help, So Why Are My Pages Not Ranked Better? ... +Our Tutorial About How To Increase Visitors To Your Website. ... +
www.chat11.com/ SEM_-_Paid_Inclusion_Doesn't_Seem_To_Be_Helping - 17k - Cached - Similar pages

Data Transformation Services for SQL Server 2005: Frequently Asked ...
... Tuesday, November 23, 2004. .: Home Articles/Tutorials SQL_Server : Data Transformation +Services for SQL Server 2005: Frequently Asked Design Questions. ... +
www.wwwcoder.com/main/parentid/ 191/site/3373/68/default.aspx - 47k - Cached - Similar pages

Programming Articles on webservices.xml.com
... month's XML Endpoints column, Rich Salz explains how to process SOAP ... Google's Gaffe. +By Paul Prescod Paul Prescod explains why moving its API to use ... +
webservices.xml.com/programming/ - 38k - 5 Dec 2004 - Cached - Similar pages

HTML Help FAQs
... This is a nice site found using Google: ... Borland Delphi and HH. Free code examples +show you how to program the HTML Help API via Borland Delphi. ... +
www.helpware.net/FAR/far_faq.htm - 101k - 5 Dec 2004 - Cached - Similar pages

Ruminations
... Frequently Asked Questions, Getting Started with Radio UserLand, Tips, and Tutorials. ... +Using the Google API with Radio and Frontier - How to make requests ... +
ruminations.weblogger.com/ - 27k - 5 Dec 2004 - Cached - Similar pages

Google launches its Deskbar API
... a big difference in your rankings and our most popular ** How To ** section The ... Deskbar +API can be found here: http://deskbar.google.com/help/api/index.html ... +
news-01.rankforsales.com/news-bf/889-seo-nov-22-04.html - 18k - 6 Dec 2004 - Cached - Similar pages

Java FAQ - Frequently Asked Questions
... Search google. ... The JAI API is the subject of discussion in this Sun sponsored mailing ... +Java FAQ is written and maintained by Andrew Thompson, with help from the ... +
www.physci.org/codes/javafaq.jsp - 53k - Cached - Similar pages

Frequently Asked Questions - comp.lang.java.gui
... first document has requested a notice that he is not a help desk for ... 7.10 Java 3D +API. ... see news:comp.lang.java.3d http://groups.google.com/groups?group=comp.lang ... +
www.physci.org/guifaq.jsp - 44k - Cached - Similar pages

GoogleDuel - About
... Asked Questions (FAQ) An old Frequently Asked Questions list ... sample source code which +illustrates how to use the ... SOAP library to call the Google API from PHP. ... +
www.googleduel.com/about.php - 12k - Cached - Similar pages

Search engine articles, tools, links and resources
... Search Engine Help by Highrankings Search Engine Features Chart ... top Guide to frames +usage How to Optimize a ... Enumeration Google Count - uses Google API Go Rank ... +
www.bearcanyonseo.com/tips_links.html - 29k - Cached - Similar pages

OpenOffice.org FAQ
... Most Frequently Asked Questions On using OpenOffice.org software in ... printing with +the binaries, the help system, licensing ... API FAQ Questions and answers on the ... +
www.openoffice.org/faq.html - 10k - Cached - Similar pages

hey Google - don't auto-update my toolbar!
Google Toolbar, Desktop Search, and API Topics. ... Google, there is absolutely no need +for this. ... Asked Questions section of the toolbar help: http://toolbar.google ... +
www.webmasterworld.com/forum80/457-9-10.htm - Similar pages

hey Google - don't auto-update my toolbar!
Google Toolbar, Desktop Search, and API Topics. ... then the very first link is to the +toolbar help page. ... If Google is willing to support use of the toolbar without ... +
www.webmasterworld.com/forum80/457-10-10.htm - Similar pages
[ More results from www.webmasterworld.com ]

Michel Olagnon's Fortran 90 List
... programs and Microsoft Windows Open Database Connectivity (ODBC) API. ... 3.7 - Other +places for Help on Fortran 90. ... ftp.cs.unm.edu; Free Software; How to get Fortran ... +
www.kcl.ac.uk/kis/support/cc/fortran/engfaq.html - 56k - Cached - Similar pages

Frequently Asked Questions - Confluence
... exporting, searchable attachments, a comprehensive remote API, easy installation ... +starting up to tell it how to use its ... If you need help with a particular server ... +
confluence.atlassian.com/ display/DOC/Frequently+Asked+Questions - 35k - 5 Dec 2004 - Cached - Similar pages

Frequently Asked Questions - Confluence
... I figured-out how to add an inline image. ... page hierachies, page subscription, online +help, WebDAV file storage, a more comprehensive remote API... ... +
confluence.atlassian.com/display/DOC/ Frequently+Asked+Questions?focusedCommentId=11067 - 72k - Cached - Similar pages
[ More results from confluence.atlassian.com ]

Bookmarks for bradg@videotron.ca
... The Mother of All Search Engines Google SEARCH.COM ... J2EE API Java(TM) SE Platform +Documentation Servlets ... Franck Allimant - Accueil (Win JDK Help Files) Getting ... +
pages.videotron.com/gbradet/home_bm.htm - 30k - Cached - Similar pages

Resources for Java server-side developers: CLDC - Bluetooth API ...
... Applications by Qusay H. Mahmoud This two-part series of articles will show you +how to use J2ME ... Home > J2ME Technologies > CLDC - Bluetooth API (JSR-82). Google, ... +
www.java201.com/resources/browse/126-all.html - 13k - Cached - Similar pages

Vivísimo // Frequently Asked Questions
... just a small sampling of who we can help: Researchers; Support ... well we work on top +of the Google Appliance ... delivered as aC software library with an API; they run ... +
vivisimo.com/html/faq - 31k - Cached - Similar pages

DataPower: Technical Resources
... Headers DataPower chief security architect Rich Salz explains how to process SOAP ... +of WSDL, with particular reference to the new Google web services API. ... +
www.datapower.com/xmldev/tech_resources.html - 19k - 5 Dec 2004 - Cached - Similar pages

Search Results | MySmartChannels
... Search Google, ... MySmartChannels I agree that actually trying out the different SQL +functions on a computer will help with the ... Is there an API to MySmartChannels? ... +
myst-technology.com/mysmartchannels/ public/search?q=mysmartchannels&scheme=standalone - 101k - Cached - Similar pages

Macromedia -UltraDevTechNotes:UltraDev Technical FAQ (Frequently ...
... Printable instructions on how to create objects and server behaviors using UltraDev's +JavaScript API are available ... Search powered by Powered by Google. +
www.macromedia.com/support/ ultradev/ts/documents/ultradev_faq.htm - 28k - Cached - Similar pages

Mensniche.com Forum - Main Forum
... SG Forum - Great Resource; need help; PPC Results; 404 Traffic; www.volume ... Meta Tags +Optimization; Pre-Sell; Google PageRank, & How to Get It; Nice Google API tool ... +
mensniche.com/forum/archive/index.php/f-2.html - 15k - Cached - Similar pages

Bookshare.org - Book Information
... new Google API, including how to build and modify scripts that can become custom +business applications based on Google. Google Hacks contains 100 tips, tricks ... +
www.bookshare.org/web/SingleTitle. html?submittitleid=19778 - 18k - Cached - Similar pages

Bookshare.org - Books by Author
... advanced search interface and the new Google API, including how ... Google Hacks contains +100 tips, tricks and scripts ... tips, tricks, and tools to help serious Mac ... +
www.bookshare.org/web/ BooksByAuthor.html?author_id=10726 - 29k - Cached - Similar pages

page87 - links
... PHP Implementation of the Google Web API System 26 ... Promotion Google ranking tips +Google's AdWords Advertising Program How to Advertise Responsibly ... +
www.page87.net/links/ - 70k - Cached - Similar pages

April 2002 | iWalt.com
... It’s an AppleScript which calls the Google API and gets the top result for your +query. ... Frequently Asked Questions. ... Help define the site. =-). ... +
www.iwalt.com/weblog/2002/04/ - 39k - Cached - Similar pages

Java Programming FAQs and Tutorials: Learning Java
... Search the Web: Google. ... Tutorials, online courses and more, to help you pass your +Java certification ... Learning how to generate high-quality printouts of components ... +
www.apl.jhu.edu/~hall/java/FAQs-and-Tutorials.html - 21k - Cached - Similar pages

Keyword density research report - Best Practices Search Engine ...
... everything come from the Google API? Did Google have to approve this? If so, +do you have any tips on getting API applications approved? ... +
www.ihelpyouservices.com/forums/ showthread.php?s=&threadid=13023 - 63k - Cached - Similar pages

Recommended Reading List / Answers to Frequently Asked Questions
... Guide Clark Connect Help Downloadable User Guides Webconfig API (For those ... relay +host(I can't send email) Help, I can ... Also, don't forget to google Note: All the ... +
www.clarkconnect.org/forums/showflat. php?Cat=&Board=howtos&Number=40192 - 31k - Cached - Similar pages

XMLhub.com Web Directory: Computers: Programming: Languages ...
... Microsoft: Visual FoxPro v3.0+ - Technical support forums and mutual help system +for ... Usenet microsoft.public.fox.vfp.lck-api - news: - Google Groups; Usenet ... +
www.xmlhub.com/dir/index/Computers/ Programming/Languages/Visual_FoxPro/ - 18k - Cached - Similar pages

Forum FAQ - GameDev.Net Discussion Forums
... If you're looking for API specific tutorials, here are some of the most common to +help get you ... could easily answer yourself with a quick Google search or a ... +
www.gamedev.net/community/ forums/showfaq.asp?forum_id=31 - 32k - 5 Dec 2004 - Cached - Similar pages

NDIS Frequently Asked Questions
... The Microsoft DDK help file and DDK samples, as well as ... On the other hand, the +user-mode WMI API is fairly ... useful information is to perform a Google Search on ... +
www.ndis.com/faq/QA10290101.htm - 35k - Cached - Similar pages

Managing CruiseControl With JMX - Confluence
... It is ridiculously easy to enable controling CC using the JMX (Java Mananagement +eXtensions) api. Here's what you get : ... How to enable the JMX server. ... +
confluence.public.thoughtworks.org/ display/CC/Managing+CruiseControl+With+JMX - 26k - 6 Dec 2004 - Cached - Similar pages

Post Comment
... Gone Wild General RSS Stuff Hardware Help HijackThis Logs ... And why has the Google +API stagnated for 2.5 years ... So what should Google, MSNbot and Yahoo search (to ... +
chris.pirillo.com/blog/cmd=post_comment/ article_id=119543/parent_id=165843 - 57k - Cached - Similar pages

FWE - National Headquarters - Job Search - View Job
... Northwest-Software Engineering GOOGLE - C++, Win32 API, and Linux Kernel Engineering +Opportunities POSTED: 9/30/2004 JOB TITLE: Software Engineer Google is ... +
www.fwe.org/p/p.asp?mlid=354&jid=1018 - 43k - Cached - Similar pages

Firefox Help: Firefox FAQ
... be able to find packages using Google. ... EWH32.api , printme.api and search.api from +plug_ins_disabled ... can convert the bookmarks with the help from BookmarkPriest ... +
www.mozilla.org/support/firefox/faq - 35k - 5 Dec 2004 - Cached - Similar pages

The Star Online Directory - FAQs, Help, and Tutorials
... Active Server Pages, and the Internet Server API. ... public.inetserver.iis.activeserverpages +- news: - Google Groups. Help build the largest human-edited directory ... +
directory.thestar.com.my/cat.asp?/Computers/ Programming/Internet/ASP/FAQs,_Help,_and_Tutorials/ - 15k - Cached - Similar pages

eMarketing Resources @ Spherica
... Rank Checker SEO Count Advanced API Rank Checker ... Google AdWords Keyword Suggestion +Tool Additional eTools Spider ... Index: Simple formula to help determine the ... +
www.spheri.ca/resources.html - 18k - 5 Dec 2004 - Cached - Similar pages

Building XML Web Services with .NET: Hands-On - Course FAQ
... Web services currently available include the Google API, Microsoft’s ... You learn how +to use the .NET System.Xml class ... Does this course help me prepare for the ... +
www.learningtree.com/courses/508qa.htm - 29k - Cached - Similar pages


Result Page: 

1

2

3

4

5

6

7

8

9

10

Next
+

 
+

Search within results | Language Tools | Search Tips | Dissatisfied? Help us improve


Google Home - Advertising Programs - Business Solutions - About Google

©2004 Google
diff --git a/src/add-ons/kernel/file_systems/googlefs/google.src b/src/add-ons/kernel/file_systems/googlefs/google.src new file mode 100644 index 0000000000..c11e51bf39 --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/google.src @@ -0,0 +1,29 @@ +# Mozilla/Google plug-in by amitp+mozilla@google.com + + + + + + + + + + + + diff --git a/src/add-ons/kernel/file_systems/googlefs/google_icon.c b/src/add-ons/kernel/file_systems/googlefs/google_icon.c new file mode 100644 index 0000000000..deb91a91fb --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/google_icon.c @@ -0,0 +1,175 @@ +#if 0 +/* old one */ +const char google_icon_M[] = { +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1e, 0x1b, 0xd9, 0xd9, 0x1d, 0xff, 0xff, +0xff, 0xff, 0x1d, 0x82, 0x82, 0x19, 0xff, 0xff, 0x1e, 0xd8, 0x64, 0x63, 0x63, 0xd8, 0x1b, 0xff, +0xff, 0x1a, 0x2c, 0x2d, 0x2d, 0x2c, 0xc4, 0x1d, 0x62, 0x63, 0x1c, 0x3f, 0x1e, 0x63, 0xd8, 0x1d, +0x1a, 0x2c, 0xca, 0x1a, 0x1d, 0x82, 0x2d, 0xa3, 0xd8, 0x62, 0x3f, 0x3f, 0x3f, 0x1e, 0xd8, 0x1a, +0x82, 0x2d, 0x1a, 0x3f, 0x3f, 0x3f, 0xa3, 0x2d, 0xd8, 0x62, 0x0e, 0x1e, 0x3f, 0x1f, 0xd8, 0x62, +0x82, 0x2d, 0x1d, 0x3f, 0x3f, 0x0f, 0x82, 0x2e, 0x63, 0x83, 0x0a, 0x1e, 0x3f, 0xfd, 0x64, 0x1b, +0x19, 0x2c, 0x5a, 0x3f, 0x1e, 0x0b, 0xc4, 0xeb, 0x1a, 0x64, 0xd8, 0xd9, 0xd9, 0x64, 0x83, 0xff, +0xff, 0xca, 0x2c, 0xa3, 0x5a, 0xc4, 0x2e, 0x82, 0xff, 0x1b, 0x83, 0x8a, 0x89, 0x17, 0x17, 0xff, +0xff, 0x1a, 0xa9, 0x2e, 0x2e, 0xca, 0x82, 0x17, 0xff, 0xff, 0xff, 0x17, 0x17, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0x1a, 0x1a, 0x1a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff +}; +const char google_icon_L[] = { +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1c, 0x1b, 0x1c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0x1c, 0x62, 0x63, 0xd8, 0xd8, 0xd8, 0x63, 0x62, 0x1d, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1e, 0x1e, 0x1e, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0x1a, 0xd8, 0xd8, 0xd8, 0xf8, 0xd8, 0xf8, 0xd8, 0xd8, 0x63, 0x1b, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0x1a, 0x18, 0xa3, 0xc4, 0xc4, 0xc4, 0xa9, 0x82, 0x1a, 0xff, 0xff, 0xff, +0xff, 0x1a, 0xd8, 0xd8, 0x64, 0x84, 0x83, 0x63, 0x63, 0x84, 0xf8, 0xd8, 0x63, 0x1b, 0xff, 0xff, +0xff, 0xff, 0xff, 0x1c, 0xa3, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0xc4, 0x1a, 0xff, 0xff, +0x1c, 0x63, 0xf8, 0x84, 0x83, 0x1d, 0x1f, 0x3f, 0x1f, 0x1c, 0x63, 0x64, 0xd8, 0x63, 0x1d, 0xff, +0xff, 0xff, 0x1c, 0xc4, 0x2c, 0x2c, 0x2d, 0x2e, 0x2e, 0x2e, 0x2e, 0x2c, 0x2c, 0x2c, 0x19, 0xff, +0x62, 0xd8, 0x84, 0x63, 0x1f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x1e, 0x63, 0xf8, 0xd8, 0x62, 0xff, +0xff, 0x1a, 0xa3, 0x2c, 0x2d, 0x2e, 0xa3, 0x1a, 0x1c, 0x1a, 0x82, 0x2e, 0x2d, 0x2c, 0xc4, 0x1b, +0x63, 0xf8, 0x84, 0x1d, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x1b, 0xf8, 0xd8, 0x63, 0x1a, +0xff, 0x18, 0x2c, 0x2d, 0x2f, 0x82, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x1a, 0x2d, 0x2c, 0x2c, 0xa9, +0xd8, 0x64, 0x83, 0x1f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x1e, 0xd8, 0xd8, 0x83, 0x1a, +0x1a, 0xa3, 0x2c, 0xeb, 0xa9, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x82, 0x2d, 0x2c, 0xca, +0xd8, 0x64, 0x83, 0x1f, 0x19, 0x1b, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x1f, 0xd8, 0xd8, 0x83, 0x1a, +0x1a, 0xc4, 0x2c, 0x2f, 0x61, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x1d, 0xc4, 0x2c, 0xeb, +0xd8, 0xf8, 0x83, 0x15, 0x01, 0x03, 0x1b, 0x3f, 0x3f, 0x3f, 0x3f, 0x1e, 0xd8, 0xf8, 0x83, 0x1a, +0x1a, 0xc4, 0x2c, 0x2f, 0x1c, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x1c, 0x1b, 0x1e, 0xc4, 0x2d, 0x2f, +0x83, 0xd8, 0x64, 0x0f, 0x00, 0x01, 0x19, 0x3f, 0x3f, 0x3f, 0x3f, 0xfd, 0xd8, 0x64, 0x14, 0x1a, +0x1a, 0xc4, 0x2c, 0x2d, 0xda, 0x3f, 0x3f, 0x3f, 0x3f, 0x1c, 0x04, 0x02, 0x16, 0xc4, 0x2d, 0x2f, +0x89, 0xf8, 0xd8, 0x63, 0x12, 0x15, 0x1f, 0x3f, 0x3f, 0x3f, 0xfe, 0xd8, 0xf8, 0x84, 0x18, 0xff, +0x1a, 0xa9, 0x2c, 0x2c, 0x82, 0x3f, 0x3f, 0x3f, 0x3f, 0x1b, 0x02, 0x00, 0xa9, 0x2c, 0x2e, 0x2f, +0x1a, 0x83, 0xf8, 0xf8, 0xd8, 0xfd, 0x1f, 0x1f, 0x1e, 0xfd, 0xd8, 0xf8, 0x84, 0x89, 0x1a, 0xff, +0xff, 0x82, 0x2d, 0x2c, 0x2c, 0xda, 0x3f, 0x3f, 0x3f, 0x3f, 0x17, 0x13, 0xc4, 0x2d, 0xeb, 0xa9, +0x1a, 0x1a, 0x83, 0x84, 0x64, 0xf8, 0xd8, 0xd8, 0xd8, 0xf8, 0xf8, 0x84, 0x89, 0x1b, 0xff, 0xff, +0xff, 0x1a, 0xca, 0x2d, 0x2c, 0x2c, 0x5a, 0x1e, 0x3f, 0x1f, 0xda, 0xc4, 0x2c, 0xeb, 0x2f, 0x18, +0xff, 0xff, 0x1a, 0x89, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x8a, 0x89, 0x1b, 0xff, 0xff, 0xff, +0xff, 0xff, 0x19, 0xeb, 0x2d, 0x2c, 0x2c, 0x2c, 0xc4, 0x2c, 0x2c, 0x2c, 0x2e, 0x2f, 0x13, 0xff, +0xff, 0xff, 0xff, 0x1a, 0x17, 0x89, 0x89, 0x8a, 0x89, 0x89, 0x18, 0x1a, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0x19, 0xca, 0x2e, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0xeb, 0x2f, 0x13, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1a, 0x1a, 0x1a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0x1c, 0xa9, 0xca, 0xeb, 0xeb, 0xeb, 0xca, 0xa9, 0x18, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1a, 0x1a, 0x18, 0x61, 0x1b, 0x1a, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff +}; +#endif + +// icons by ahwayakchih + +const char google_icon_M[] = { +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1b, 0xd9, 0xd9, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0x82, 0x82, 0x19, 0xff, 0xff, 0xff, 0xd8, 0x64, 0x63, 0x63, 0xd8, 0xff, 0xff, +0xff, 0xff, 0x2c, 0x2d, 0x2d, 0x2c, 0xc4, 0xff, 0x62, 0x63, 0x1c, 0x3f, 0x1e, 0x63, 0xd8, 0xff, +0xff, 0x2c, 0xca, 0x1a, 0x1d, 0x82, 0x2d, 0xa3, 0xd8, 0x62, 0x3f, 0x3f, 0x3f, 0x1e, 0xd8, 0x1a, +0x82, 0x2d, 0x1a, 0x3f, 0x3f, 0x3f, 0xa3, 0x2d, 0xd8, 0x62, 0x0e, 0x1e, 0x3f, 0x1f, 0xd8, 0x62, +0x82, 0x2d, 0x1d, 0x3f, 0x3f, 0x0f, 0x82, 0x2e, 0x63, 0x83, 0x0a, 0x1e, 0x3f, 0xfd, 0x64, 0xff, +0xff, 0x2c, 0x5a, 0x3f, 0x1e, 0x0b, 0xc4, 0xeb, 0xff, 0x64, 0xd8, 0xd9, 0xd9, 0x64, 0x83, 0xff, +0xff, 0xca, 0x2c, 0xa3, 0x5a, 0xc4, 0x2e, 0x82, 0xff, 0xff, 0x83, 0x8a, 0x89, 0x17, 0xff, 0xff, +0xff, 0xff, 0xa9, 0x2e, 0x2e, 0xca, 0x82, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff +}; + +const char google_icon_L[] = { +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x04, 0x00, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x04, 0x1b, +0x09, 0x08, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x04, 0x00, 0x04, 0x1c, +0x1b, 0x1c, 0x08, 0x09, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x04, 0x1b, 0x09, 0x08, +0x1c, 0x1c, 0x1b, 0x1c, 0x08, 0x09, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x04, 0x00, 0x04, 0x1c, 0x1b, 0x1c, +0x08, 0x09, 0x1c, 0x1b, 0x1c, 0x1b, 0x09, 0x08, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x04, 0x1b, 0x09, 0x08, 0x1c, 0x1c, +0x1b, 0x1c, 0x08, 0x09, 0x1c, 0x1b, 0x1c, 0x1b, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x04, 0x00, 0x04, 0x1c, 0x1b, 0x1c, 0x08, 0x09, +0x1c, 0x1b, 0x1c, 0x1b, 0x09, 0x08, 0x1c, 0x1c, 0x1b, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x04, 0x1b, 0x09, 0x08, 0x1c, 0x1c, 0x1b, 0x1c, +0x08, 0x09, 0x1c, 0x1b, 0x1c, 0x1b, 0x09, 0x00, 0x1c, 0x00, 0xd9, 0x00, 0x00, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x04, 0x04, 0x04, 0x1c, 0x1c, 0x1b, 0x09, 0x08, 0x1c, 0x1b, +0x1c, 0x1c, 0x08, 0x09, 0x1b, 0x1c, 0x1c, 0x00, 0x15, 0x00, 0xd1, 0xd9, 0xd9, 0x00, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x04, 0x3f, 0x08, 0x09, 0x1b, 0x1c, 0x1b, 0x1c, 0x09, 0x08, +0x1c, 0x1b, 0x1c, 0x1c, 0x08, 0x00, 0x1c, 0x00, 0x15, 0x00, 0xd1, 0xd1, 0xd9, 0x00, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0x04, 0x04, 0x04, 0x1c, 0x3f, 0x3f, 0x08, 0x09, 0x1b, 0x1c, 0x1b, 0x1c, +0x09, 0x08, 0x1c, 0x1b, 0x1c, 0x00, 0x15, 0x00, 0x15, 0x00, 0xd1, 0xd9, 0xaa, 0x01, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0x04, 0x3f, 0x08, 0x09, 0x1b, 0x1c, 0x3f, 0x3f, 0x08, 0x09, 0x1b, 0x1c, +0x1b, 0x1c, 0x09, 0x00, 0x1b, 0x00, 0x15, 0x00, 0x0f, 0x00, 0xd9, 0xaa, 0xaa, 0x00, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0x04, 0x3f, 0x3f, 0x3f, 0x08, 0x09, 0x1b, 0x1c, 0x3f, 0x3f, 0x08, 0x09, +0x1b, 0x1c, 0x1b, 0x00, 0x16, 0x00, 0x15, 0x00, 0x0f, 0xd9, 0xaa, 0xaa, 0xaa, 0x00, 0xff, 0xff, +0xff, 0xff, 0xff, 0x00, 0x04, 0x3f, 0x1b, 0x1c, 0x3f, 0x3f, 0x08, 0x09, 0x1b, 0x1c, 0x3f, 0x3f, +0x08, 0x00, 0x1c, 0x00, 0x15, 0x00, 0x0f, 0x00, 0xd9, 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0xff, 0xff, +0xff, 0xff, 0x00, 0xd9, 0x04, 0x3f, 0x1b, 0x1c, 0x1b, 0x1c, 0x3f, 0x3f, 0x08, 0x09, 0x1b, 0x1c, +0x3f, 0x00, 0x15, 0x00, 0x15, 0x00, 0x0f, 0xd9, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x0f, 0xff, +0xff, 0x00, 0xd9, 0xd1, 0x04, 0x15, 0x1a, 0x19, 0x1c, 0x1b, 0x1c, 0x1c, 0x3f, 0x3f, 0x08, 0x00, +0x1c, 0x00, 0x15, 0x00, 0x0f, 0x00, 0x63, 0xd8, 0xd8, 0xd8, 0x63, 0x62, 0xaa, 0x00, 0x0f, 0xff, +0xff, 0x00, 0xd9, 0xd9, 0x04, 0x0f, 0x15, 0x15, 0x1a, 0x19, 0x1c, 0x1c, 0x1b, 0x1c, 0x3f, 0x00, +0x15, 0x00, 0x15, 0x00, 0xd8, 0xd8, 0xd8, 0xf8, 0xd8, 0xf8, 0xd8, 0xd8, 0x63, 0x0f, 0x0f, 0xff, +0xff, 0x00, 0x83, 0x83, 0xd9, 0xd9, 0x0f, 0xa3, 0xc4, 0xc4, 0xc4, 0xa9, 0x82, 0x1c, 0x1b, 0x00, +0x15, 0x00, 0x0f, 0xd8, 0xd8, 0x64, 0x84, 0x83, 0x63, 0x63, 0x84, 0xf8, 0xd8, 0x63, 0xff, 0xff, +0xff, 0x00, 0x83, 0x83, 0x83, 0xa3, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0xc4, 0x1c, 0x00, +0x15, 0x00, 0x63, 0xf8, 0x84, 0x83, 0x1d, 0x3f, 0x3f, 0x3f, 0x1c, 0x63, 0x64, 0xd8, 0x63, 0xff, +0xff, 0x00, 0x83, 0x83, 0xc4, 0x2c, 0x2c, 0x2d, 0xeb, 0xeb, 0xeb, 0xeb, 0x2c, 0x2c, 0x2c, 0x00, +0x0f, 0x62, 0xd8, 0x84, 0x63, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x1e, 0x63, 0xf8, 0xd8, 0x62, +0xff, 0x00, 0x83, 0xa3, 0x2c, 0x2d, 0xeb, 0xa3, 0x1a, 0x1c, 0x1a, 0x82, 0xeb, 0x2d, 0x2c, 0xc4, +0x0f, 0x63, 0xf8, 0x84, 0x1d, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x1b, 0xf8, 0xd8, 0x63, +0xff, 0x00, 0x83, 0x2c, 0x2d, 0x2f, 0x82, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x1a, 0x2d, 0x2c, 0x2c, +0xa9, 0xd8, 0x64, 0x83, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x1e, 0xd8, 0xd8, 0x83, +0xff, 0x00, 0xa3, 0x2c, 0xeb, 0xa9, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x82, 0x2d, 0x2c, +0xca, 0xd8, 0x64, 0x83, 0x3f, 0x19, 0x1b, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0xd8, 0xd8, 0x83, +0xff, 0x00, 0xc4, 0x2c, 0x2f, 0x19, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x1d, 0xc4, 0x2c, +0xeb, 0xd8, 0xf8, 0x83, 0x15, 0x01, 0x03, 0x1b, 0x3f, 0x3f, 0x3f, 0x3f, 0x1e, 0xd8, 0xf8, 0x83, +0xff, 0x00, 0xc4, 0x2c, 0x2f, 0x1c, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x1c, 0x1b, 0x1e, 0xc4, 0x2d, +0x2f, 0x83, 0xd8, 0x64, 0x0f, 0x00, 0x01, 0x19, 0x3f, 0x3f, 0x3f, 0x3f, 0xfd, 0xd8, 0x64, 0x14, +0xff, 0x00, 0xc4, 0x2c, 0x2d, 0xda, 0x3f, 0x3f, 0x3f, 0x3f, 0x1c, 0x04, 0x02, 0x16, 0xc4, 0x2d, +0x2f, 0x89, 0xf8, 0xd8, 0x63, 0x12, 0x15, 0x3f, 0x3f, 0x3f, 0x3f, 0xfe, 0xd8, 0xf8, 0x84, 0x14, +0xff, 0xff, 0xa9, 0x2c, 0x2c, 0x82, 0x3f, 0x3f, 0x3f, 0x3f, 0x1b, 0x02, 0x00, 0xa9, 0x2c, 0xeb, +0x2f, 0xaa, 0x83, 0xf8, 0xf8, 0xd8, 0xfd, 0x3f, 0x3f, 0x1e, 0xfd, 0xd8, 0xf8, 0x84, 0x89, 0xff, +0xff, 0xff, 0x82, 0x2d, 0x2c, 0x2c, 0xda, 0x3f, 0x3f, 0x3f, 0x3f, 0x17, 0x13, 0xc4, 0x2d, 0xeb, +0xa9, 0x00, 0x0f, 0x83, 0x84, 0x64, 0xf8, 0xd8, 0xd8, 0xd8, 0xf8, 0xf8, 0x84, 0x89, 0xff, 0xff, +0xff, 0xff, 0xff, 0xca, 0x2d, 0x2c, 0x2c, 0x5a, 0x1e, 0x3f, 0x3f, 0xda, 0xc4, 0x2c, 0xeb, 0x2f, +0x00, 0x0f, 0x0f, 0xff, 0x89, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x8a, 0x89, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xeb, 0x2d, 0x2c, 0x2c, 0x2c, 0xc4, 0x2c, 0x2c, 0x2c, 0xeb, 0x2f, 0x00, +0x0f, 0x0f, 0xff, 0xff, 0xff, 0xff, 0x89, 0x89, 0x8a, 0x89, 0x89, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xca, 0xeb, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0xeb, 0x2f, 0x00, 0x0f, +0x0e, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xa9, 0xca, 0xeb, 0xeb, 0xeb, 0xca, 0xa9, 0x00, 0x0e, 0x0f, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff +}; diff --git a/src/add-ons/kernel/file_systems/googlefs/google_request.c b/src/add-ons/kernel/file_systems/googlefs/google_request.c new file mode 100644 index 0000000000..868fc30c3d --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/google_request.c @@ -0,0 +1,212 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include "http_cnx.h" +#include "google_request.h" +#include "lists2.h" +#include "settings.h" + +#define DO_PUBLISH +//#define FAKE_INPUT "/boot/home/devel/drivers/googlefs/log2.html" + +//#define TESTURL "http://www.google.com/search?as_q=google+api+&num=50&hl=en&ie=ISO-8859-1&btnG=Google+Search&as_epq=frequently+asked&as_oq=help&as_eq=plop&lr=lang_en&as_ft=i&as_filetype=&as_qdr=m3&as_nlo=&as_nhi=&as_occt=any&as_dt=i&as_sitesearch=" + +//#define BASEURL "http://www.google.com/search?as_q=" +//#define Q "google+api+" +//#define EXTRAURL "&num=50&hl=en&ie=ISO-8859-1&btnG=Google+Search&as_epq=frequently+asked&as_oq=help&as_eq=plop&lr=lang_en&as_ft=i&as_filetype=&as_qdr=m3&as_nlo=&as_nhi=&as_occt=any&as_dt=i&as_sitesearch=" + +#define TESTURL "http://www.google.com/search?hl=en&ie=UTF-8&num=50&q=beos" +//#define BASEURL "http://www.google.com/search?hl=en&ie=UTF-8&num=50&q=" +#define BASEURL "/search?hl=en&ie=UTF-8&oe=UTF-8" +#define FMT_NUM "&num=%u" +#define FMT_Q "&q=%s" + +/* parse_google_html.c */ +extern int google_parse_results(const char *html, size_t htmlsize, struct google_result **results); + +// move that to ksocket inlined +static kinet_aton(const char *in, struct in_addr *addr) +{ + int i; + unsigned long a; + uint32 inaddr = 0L; + const char *p = in; + for (i = 0; i < 4; i++) { + a = strtoul(p, &p, 10); + if (!p) + return -1; + inaddr = (inaddr >> 8) | ((a & 0x0ff) << 24); + *(uint32 *)addr = inaddr; + if (!*p) + return 0; + p++; + } + return 0; +} + + +status_t google_request_init() +{ + status_t err; + err = http_init(); + return err; +} + +status_t google_request_uninit() +{ + status_t err; + err = http_uninit(); + return err; +} + +status_t google_request_process(struct google_request *req) +{ + struct sockaddr_in sin; + struct http_cnx *cnx = NULL; + struct google_result *res; + int err, i, count; + size_t len; + char *p = NULL; + char *url = NULL; + + err = http_create(&cnx); + if (err) + return err; + err = ENOMEM; + req->cnx = cnx; +#ifndef FAKE_INPUT + sin.sin_len = sizeof(struct sockaddr_in); + sin.sin_family = AF_INET; + sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); + if (kinet_aton(google_server, &sin.sin_addr) < 0) + goto err_cnx; + sin.sin_port = htons(google_server_port); + err = http_connect(cnx, &sin); + dprintf("google_request: http_connect: error 0x%08lx\n", err); + if (err) + goto err_cnx; + + err = ENOMEM; + p = urlify_string(req->query_string); + if (!p) + goto err_con; + + err = ENOMEM; + url = malloc(strlen(BASEURL)+strlen(FMT_NUM)+10+strlen(FMT_Q)+strlen(p)+2); + if (!url) + goto err_url; + strcpy(url, BASEURL); + sprintf(url+strlen(url), FMT_NUM, max_results); + sprintf(url+strlen(url), FMT_Q, p); + + dprintf("google_request: final URL: %s\n", url); + + err = http_get(cnx, url); + dprintf("google_request: http_get: error 0x%08lx\n", err); + if (err < 0) + goto err_url2; + dprintf("google_request: http_get: HEADERS %d:%s\n", cnx->headerslen, cnx->headers); + //dprintf("DATA: %d:%s\n", cnx->datalen, cnx->data); + + dprintf("google_request: buffer @ %p, len %ld\n", cnx->data, cnx->datalen); + { + int fd; + // debug output + fd = open("/tmp/google.html", O_CREAT|O_TRUNC|O_RDWR, 0644); + write(fd, cnx->data, cnx->datalen); + close(fd); + } +#else + { + int fd; + struct stat st; + // debug output + fd = open(FAKE_INPUT, O_RDONLY, 0644); + if (fd < 0) + return -1; + if (fstat(fd, &st) < 0) + return -1; + cnx->datalen = st.st_size; + cnx->data = malloc(cnx->datalen); + if (!cnx->data) + return ENOMEM; + if (read(fd, cnx->data, cnx->datalen) < cnx->datalen) + return -1; + close(fd); + } +#endif /* FAKE_INPUT */ + err = count = google_parse_results(req->cnx->data, req->cnx->datalen, &req->results); + if (err < 0) + goto err_get; +#ifdef DO_PUBLISH + while ((res = SLL_DEQUEUE(req->results, next))) { + res->next = NULL; + googlefs_push_result_to_query(req, res); + } +#endif + free(url); + free(p); + /* close now */ + http_close(cnx); + + return B_OK; + + +err_get: +err_url2: + free(url); +err_url: + free(p); +err_con: + http_close(cnx); +err_cnx: + http_delete(cnx); + req->cnx = NULL; + return err; +} + +status_t google_request_process_async(struct google_request *req) +{ + return ENOSYS; +} + +status_t google_request_close(struct google_request *req) +{ + if (!req) + return EINVAL; + if (!req->cnx) + return B_OK; + http_close(req->cnx); + http_delete(req->cnx); + req->cnx = NULL; + return B_OK; +} + +status_t google_request_open(const char *query_string, struct fs_nspace *ns, struct fs_node *query_node, struct google_request **req) +{ + struct google_request *r; + if (!req) + return EINVAL; + r = malloc(sizeof(struct google_request)); + if (!r) + return ENOMEM; + memset(r, 0, sizeof(struct google_request)); + r->query_string = strdup(query_string); + r->ns = ns; + r->query_node = query_node; + *req = r; + return B_OK; +} + +status_t google_request_free(struct google_request *req) +{ + if (!req) + return EINVAL; + free(req->query_string); + free(req); +} diff --git a/src/add-ons/kernel/file_systems/googlefs/google_request.h b/src/add-ons/kernel/file_systems/googlefs/google_request.h new file mode 100644 index 0000000000..a30f5fafa4 --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/google_request.h @@ -0,0 +1,37 @@ +#ifndef _GOOGLE_REQUEST_H +#define _GOOGLE_REQUEST_H + +struct google_request { + struct google_request *next; + struct fs_nspace *ns; + struct fs_node *query_node; /* root folder for that query */ + char *query_string; + struct http_cnx *cnx; + struct google_result *results; +}; + +/* those are quite arbitrary values */ +#define GR_MAX_NAME 70 +#define GR_MAX_PROTO 16 +#define GR_MAX_URL 1024 +#define GR_MAX_SNIPSET 256 +struct google_result { + struct google_result *next; + long id; + char name[GR_MAX_NAME]; + char proto[GR_MAX_PROTO]; + char url[GR_MAX_URL]; + char snipset[GR_MAX_SNIPSET]; + char cache_url[GR_MAX_URL]; + char similar_url[GR_MAX_URL]; +}; + +extern status_t google_request_init(); +extern status_t google_request_uninit(); +extern status_t google_request_process(struct google_request *req); +extern status_t google_request_process_async(struct google_request *req); +extern status_t google_request_close(struct google_request *req); +extern status_t google_request_open(const char *query_string, struct fs_nspace *ns, struct fs_node *query_node, struct google_request **req); +extern status_t google_request_free(struct google_request *req); + +#endif /* _GOOGLE_REQUEST_H */ diff --git a/src/add-ons/kernel/file_systems/googlefs/googlefs.c b/src/add-ons/kernel/file_systems/googlefs/googlefs.c new file mode 100644 index 0000000000..5d77726a92 --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/googlefs.c @@ -0,0 +1,1801 @@ +/* + * googlefs - + * (c) 2004, 2005, François Revol, revol@free.fr + */ + +#define _BUILDING_fs 1 + +#include +#include +#include +#include +//#include +#include +#include +#include +#include +#include "query.h" +#include "googlefs.h" +#include "vnidpool.h" +#include "google_request.h" +#include "settings.h" + +/* just publish fake entries; for debugging */ +//#define NO_SEARCH + +#define DEBUG_GOOGLEFS 1 + +#if DEBUG_GOOGLEFS +#define PRINT(a) /*snooze(5000);*/ dprintf a +#else +#define PRINT(a) +#endif +#define PFS "googlefs: " + +/* needed to get /bin/df tell the mountpoint... */ +#define ALLOW_DIR_OPEN + +/* test: */ + +vint32 refcount = 0; + + +extern struct attr_entry root_folder_attrs[]; +extern struct attr_entry folders_attrs[]; +extern struct attr_entry bookmark_attrs[]; +extern struct attr_entry fake_bookmark_attrs[]; /* for debugging */ +extern struct attr_entry template_1_attrs[]; +extern struct attr_entry text_attrs[]; +extern struct attr_entry mailto_me_bookmark_attrs[]; + +extern char *readmestr; + +static int googlefs_create_gen(fs_nspace *ns, fs_node *dir, const char *name, int omode, int perms, vnode_id *vnid, fs_node **node, struct attr_entry *iattrs, bool mkdir, bool uniq); + +static void fill_default_stat(struct stat *st, nspace_id nsid, vnode_id vnid, mode_t mode) +{ + time_t tm = time(NULL); + st->st_dev = nsid; + st->st_ino = vnid; + st->st_mode = mode; + st->st_nlink = 1; + st->st_uid = 0; + st->st_gid = 0; + st->st_size = 0LL; + st->st_blksize = 1024; + st->st_atime = tm; + st->st_mtime = tm; + st->st_ctime = tm; + st->st_crtime = tm; +} + +/** Publishes some entries in the root vnode: a query template, the readme file, and a People file of the author. + */ +int googlefs_publish_static_entries(fs_nspace *ns) +{ + status_t err = B_OK; + fs_node *dir = ns->root; + fs_node *n, *dummy; + char ename[GOOGLEFS_NAME_LEN]; + char *p; + int i; + PRINT((PFS"googlefs_publish_static_entries(%ld)\n", ns->nsid)); + if (!ns || !dir) + return EINVAL; + + err = googlefs_create_gen(ns, dir, "Search Google", 0, 0444, NULL, &n, template_1_attrs, false, true); + if (err) + return err; + n->is_perm = 1; + + err = googlefs_create_gen(ns, dir, "README", 0, 0444, NULL, &n, text_attrs, false, true); + if (err) + return err; + n->is_perm = 1; + n->data = readmestr; + n->data_size = strlen(n->data);// + 1; + + err = googlefs_create_gen(ns, dir, "Author", 0, 0444, NULL, &n, mailto_me_bookmark_attrs, false, true); + if (err) + return err; + n->is_perm = 1; + + return B_OK; + +err: + PRINT((PFS"push_result_to_query: error 0x%08lx\n", err)); + return err; +} + +#ifdef __HAIKU__ +int googlefs_mount(nspace_id nsid, const char *devname, uint32 flags, + const char *parms, fs_nspace **data, vnode_id *vnid) +#else +int googlefs_mount(nspace_id nsid, const char *devname, ulong flags, + const char *parms, size_t len, fs_nspace **data, vnode_id *vnid) +#endif +{ + fs_nspace *ns; + fs_node *root; + int err; + PRINT((PFS "mount(%ld, %s, 0x%08lx, %p, , )\n", nsid, devname, flags, parms)); +#ifndef __HAIKU__ + (void) len; +#endif + + /* only allow a single mount */ + if (atomic_add(&refcount, 1)) + return EALREADY; + + err = load_settings(); + + err = google_request_init(); + if (err) + goto err_http; + + ns = malloc(sizeof(fs_nspace)); + if (!ns) + return B_NO_MEMORY; + memset(ns, 0, sizeof(fs_nspace)); + ns->nsid = nsid; + err = vnidpool_alloc(&ns->vnids, MAX_VNIDS); + if (err < 0) + return err; + err = vnidpool_get(ns->vnids, &ns->rootid); + if (err < 0) + return err; + atomic_add(&ns->nodecount, 1); + + err = new_lock(&(ns->l), "googlefs main lock"); + if (err < 0) + return err; + ns->nodes = NULL; + + /* create root dir */ + err = B_NO_MEMORY; + root = malloc(sizeof(fs_node)); + ns->root = root; + if (root) { + memset(root, 0, sizeof(fs_node)); + strcpy(root->name, "."); + root->is_perm = 1; + root->vnid = ns->rootid; + fill_default_stat(&root->st, ns->nsid, ns->rootid, 0777 | S_IFDIR); + root->attrs_indirect = root_folder_attrs; + err = new_lock(&(root->l), "googlefs root dir"); + if (err >= 0) { + *data = ns; + *vnid = ns->rootid; + ns->nodes = root; // sll_insert + err = publish_vnode(nsid, *vnid, root); + if (err == B_OK) { + googlefs_publish_static_entries(ns); + PRINT((PFS "mount() OK, nspace@ %p, id %ld, root@ %p, id %Ld\n", ns, ns->nsid, root, ns->rootid)); + return B_OK; + } + free_lock(&root->l); + } + free(root); + } + free_lock(&ns->l); + free(ns); +err_http: + atomic_add(&refcount, -1); + return err; +} + +int googlefs_unmount(fs_nspace *ns) +{ + status_t err; + struct fs_node *node; + PRINT((PFS "unmount(%ld)\n", ns->nsid)); + err = LOCK(&ns->l); + if (err) + return err; + /* anything in still in use ? */ + for (node = ns->nodes; node; node = ns->nodes) { + ns->nodes = node->nlnext; /* better cache that before we free node */ + googlefs_free_vnode(ns, node); + } + + // Unlike in BeOS, we need to put the reference to our root node ourselves +#ifdef __HAIKU__ + put_vnode(ns->nsid, ns->rootid); +#endif + + free_lock(&ns->l); + vnidpool_free(ns->vnids); + free(ns); + + google_request_uninit(); + + atomic_add(&refcount, -1); + + return B_OK; +} + +static int compare_fs_node_by_vnid(fs_node *node, vnode_id *id) +{ + return !(node->vnid == *id); +} + +int googlefs_free_vnode(fs_nspace *ns, fs_node *node) +{ + free_lock(&node->l); + atomic_add(&ns->nodecount, -1); + vnidpool_put(ns->vnids, node->vnid); + if (node->request) + google_request_free(node->request); + free(node->result); + free(node); + return 0; +} + +#ifdef __HAIKU__ +int googlefs_remove_vnode(fs_nspace *ns, char r, fs_node *node) +#else +int googlefs_remove_vnode(fs_nspace *ns, fs_node *node, char r) +#endif +{ + status_t err = B_OK; + PRINT((PFS "remove_vnode(%ld, %Ld, %s)\n", ns->nsid, node->vnid, r?"r":"!r")); + if (!r) + err = LOCK(&ns->l); + if (err) + return err; + if (node->vnid == ns->rootid) { + PRINT((PFS "asked to remove the root node!!\n")); + } + //LOCK(&node->l); + err = SLL_REMOVE(ns->nodes, nlnext, node); + /* query dirs must be removed from the query list too */ + err = SLL_REMOVE(ns->queries, qnext, node); + if (node->parent) { + LOCK(&node->parent->l); + SLL_REMOVE(node->parent->children, next, node); + UNLOCK(&node->parent->l); + } + googlefs_free_vnode(ns, node); + if (!r) + UNLOCK(&ns->l); + return err; +} + +#ifdef __HAIKU__ +int googlefs_read_vnode(fs_nspace *ns, vnode_id vnid, fs_node **node, char r) +#else +int googlefs_read_vnode(fs_nspace *ns, vnode_id vnid, char r, fs_node **node) +#endif +{ + fs_node *n; + status_t err = B_OK; + PRINT((PFS "read_vnode(%ld, %Ld, %s)\n", ns->nsid, vnid, r?"r":"!r")); + if (!r) + err = LOCK(&ns->l); + if (err) + return err; + n = (fs_node *)SLL_FIND(ns->nodes, nlnext, (sll_compare_func)compare_fs_node_by_vnid, (void *)&vnid); + if (n) + *node = n; + else + err = ENOENT; + if (!r) + UNLOCK(&ns->l); + return err; +} + +#ifdef __HAIKU__ +int googlefs_release_vnode(fs_nspace *ns, fs_node *node, char r) +#else +int googlefs_write_vnode(fs_nspace *ns, fs_node *node, char r) +#endif +{ + PRINT((PFS "write_vnode(%ld, %Ld, %s)\n", ns->nsid, node->vnid, r?"r":"!r")); + return B_OK; +} + +#ifndef __HAIKU__ +int googlefs_secure_vnode(fs_nspace *ns, fs_node *node) +{ + PRINT((PFS "secure_vnode(%ld, %Ld)\n", ns->nsid, node->vnid)); + return B_OK; +} +#endif + +static int compare_fs_node_by_name(fs_node *node, char *name) +{ + //return memcmp(node->name, name, GOOGLEFS_NAME_LEN); + PRINT((PFS"find_by_name: '%s' <> '%s'\n", node->name, name)); + return strncmp(node->name, name, GOOGLEFS_NAME_LEN); +} + +#ifdef __HAIKU__ +int googlefs_get_vnode_name(fs_nspace *ns, fs_node *node, char *buffer, size_t len) +{ + fs_node *n, *dummy; + status_t err = B_OK; + PRINT((PFS "get_vnode_name(%ld, %Ld, )\n", ns->nsid, (int64)(node?node->vnid:-1))); + strlcpy(buffer, node->name, MIN(GOOGLEFS_NAME_LEN, len)); + return B_OK; +} +#endif + +#ifdef __HAIKU__ +int googlefs_walk(fs_nspace *ns, fs_node *base, const char *file, vnode_id *vnid, int *type) +#else +int googlefs_walk(fs_nspace *ns, fs_node *base, const char *file, char **newpath, vnode_id *vnid) +#endif +{ + fs_node *n, *dummy; + status_t err = B_OK; + PRINT((PFS "walk(%ld, %Ld, %s)\n", ns->nsid, (int64)(base?base->vnid:-1), file)); + err = LOCK(&base->l); + if (err) + return err; + if (!file) { + err = EINVAL; + } else if (!strcmp(file, "..")) { + if (base && base->parent) { + *vnid = base->parent->vnid; // XXX: LOCK(&base->l) ? +#ifdef __HAIKU__ + *type = S_IFDIR; +#endif + } else + err = EINVAL; + } else if (!strcmp(file, ".")) { /* root dir */ + if (base) { // XXX: LOCK(&base->l) ? + *vnid = base->vnid; +#ifdef __HAIKU__ + *type = S_IFDIR; +#endif + } else + err = EINVAL; + } else if (base) { /* child of dir */ + n = (fs_node *)SLL_FIND(base->children, next, + (sll_compare_func)compare_fs_node_by_name, (void *)file); + if (n) { + *vnid = n->vnid; +#ifdef __HAIKU__ + *type = n->st.st_type & ~S_IUMSK; /*XXX: S_IFMT ?*/ +#endif + } else + err = ENOENT; + } else + err = ENOENT; + if (err == B_OK) { + if (get_vnode(ns->nsid, *vnid, (void **)&dummy) != 0) /* inc ref count */ + err = EINVAL; + } + UNLOCK(&base->l); + PRINT((PFS "walk() -> error 0x%08lx\n", err)); + return err; +} + +int googlefs_opendir(fs_nspace *ns, fs_node *node, fs_dir_cookie **cookie) +{ + status_t err = B_OK; + fs_dir_cookie *c; + PRINT((PFS "opendir(%ld, %Ld)\n", ns->nsid, node->vnid)); + if (!node) + return EINVAL; + if (!S_ISDIR(node->st.st_mode)) + return B_NOT_A_DIRECTORY; + err = LOCK(&node->l); + if (err) + return err; + c = malloc(sizeof(fs_dir_cookie)); + if (c) { + memset(c, 0, sizeof(fs_dir_cookie)); + c->omode = O_RDONLY; + c->type = S_IFDIR; + c->node = node; + c->dir_current = 0; + *cookie = c; + SLL_INSERT(node->opened, next, c); + UNLOCK(&node->l); + return B_OK; + } else + err = B_NO_MEMORY; + UNLOCK(&node->l); + return err; +} + +int googlefs_closedir(fs_nspace *ns, fs_node *node, fs_dir_cookie *cookie) +{ + status_t err = B_OK; + PRINT((PFS "closedir(%ld, %Ld)\n", ns->nsid, node->vnid)); + err = LOCK(&node->l); + if (err) + return err; + + SLL_REMOVE(node->opened, next, cookie); + UNLOCK(&node->l); + return err; +} + +int googlefs_rewinddir(fs_nspace *ns, fs_node *node, fs_dir_cookie *cookie) +{ + PRINT((PFS "rewinddir(%ld, %Ld)\n", ns->nsid, node->vnid)); + cookie->dir_current = 0; + return B_OK; +} + +#ifdef __HAIKU__ +int googlefs_readdir(fs_nspace *ns, fs_node *node, fs_dir_cookie *cookie, struct dirent *buf, size_t bufsize, uint32 *num) +#else +int googlefs_readdir(fs_nspace *ns, fs_node *node, fs_dir_cookie *cookie, long *num, struct dirent *buf, size_t bufsize) +#endif +{ + status_t err = B_OK; + fs_node *n = NULL; + fs_node *parent = node->parent; + int index; + PRINT((PFS "readdir(%ld, %Ld) @ %d\n", ns->nsid, node->vnid, cookie->dir_current)); + if (!node || !cookie || !num || !*num || !buf || (bufsize < (sizeof(dirent_t)+GOOGLEFS_NAME_LEN))) + return EINVAL; + err = LOCK(&node->l); + if (cookie->dir_current == 0) { /* .. */ + PRINT((PFS "readdir: giving ..\n")); + /* the VFS will correct that anyway */ + buf->d_dev = ns->nsid; + buf->d_pdev = ns->nsid; + buf->d_ino = parent?parent->vnid:ns->rootid; + buf->d_pino = (parent && parent->parent)?parent->parent->vnid:ns->rootid; + strcpy(buf->d_name, ".."); + buf->d_reclen = 2*(sizeof(dev_t)+sizeof(ino_t))+sizeof(unsigned short)+strlen(buf->d_name)+1; + cookie->dir_current++; + *num = 1; + } else if (cookie->dir_current == 1) { /* . */ + PRINT((PFS "readdir: giving .\n")); + /* the VFS will correct that anyway */ + buf->d_dev = ns->nsid; + buf->d_pdev = ns->nsid; + buf->d_ino = node->vnid; + buf->d_pino = parent?parent->vnid:ns->rootid; + strcpy(buf->d_name, "."); + buf->d_reclen = 2*(sizeof(dev_t)+sizeof(ino_t))+sizeof(unsigned short)+strlen(buf->d_name)+1; + cookie->dir_current++; + *num = 1; + } else { + index = cookie->dir_current-2; + for (n = node->children; n && index; n = n->next, index--); //XXX: care about n->hidden || n->deleted + if (n) { + PRINT((PFS "readdir: giving ino %Ld, %s\n", n->vnid, n->name)); + buf->d_dev = ns->nsid; + buf->d_pdev = ns->nsid; + buf->d_ino = n->vnid; + buf->d_pino = node->vnid; + strcpy(buf->d_name, n->name); + buf->d_reclen = 2*(sizeof(dev_t)+sizeof(ino_t))+sizeof(unsigned short)+strlen(buf->d_name)+1; + cookie->dir_current++; + *num = 1; + } else { + *num = 0; + } + } + UNLOCK(&node->l); + return B_OK; +} + +int googlefs_free_dircookie(fs_nspace *ns, fs_node *node, fs_dir_cookie *cookie) +{ + PRINT((PFS"freedircookie(%ld, %Ld)\n", ns->nsid, node?node->vnid:0LL)); + free(cookie); + return B_OK; +} + +int googlefs_rstat(fs_nspace *ns, fs_node *node, struct stat *st) +{ + status_t err = B_OK; + if (!node || !st) + return EINVAL; + err = LOCK(&node->l); + if (err) + return err; + memcpy(st, &node->st, sizeof(struct stat)); + st->st_dev = ns->nsid; + st->st_ino = node->vnid; + if (node->data_size) + st->st_size = node->data_size; + //st->st_size = 0LL; + UNLOCK(&node->l); + return err; +} + +int googlefs_rfsstat(fs_nspace *ns, struct fs_info *info) +{ + info->block_size=1024;//googlefs_BUFF_SIZE; + info->io_size=1024;//GOOGLEFS_BUFF_SIZE; + info->total_blocks=0; + info->free_blocks=0; + info->total_nodes=MAX_VNIDS; + info->free_nodes=ns->nodecount; + info->dev=ns->nsid; + info->root=ns->rootid; + info->flags=/*B_FS_IS_SHARED|*/B_FS_IS_PERSISTENT|B_FS_HAS_MIME|B_FS_HAS_ATTR|B_FS_HAS_QUERY; + strcpy (info->device_name, ""); + strcpy (info->volume_name, "Google"); + strcpy (info->fsh_name, GOOGLEFS_NAME); + return B_OK; +} + +int googlefs_open(fs_nspace *ns, fs_node *node, int omode, fs_file_cookie **cookie) +{ + status_t err = B_OK; + fs_node *dummy; + fs_file_cookie *fc; + PRINT((PFS"open(%ld, %Ld, 0x%x)\n", ns->nsid, node->vnid, omode)); + if (!node || !cookie) + return EINVAL; + +// err = LOCK(&ns->l); +// if (err) +// return err; + err = LOCK(&node->l); + if (err) + goto err_n_l; + err = EEXIST; +#ifndef ALLOW_DIR_OPEN + err = EINVAL;//EISDIR; + if (S_ISDIR(node->st.st_mode)) + goto err_malloc; +#endif + err = B_NO_MEMORY; + fc = malloc(sizeof(fs_file_cookie)); + if (!fc) + goto err_malloc; + memset(fc, 0, sizeof(fs_file_cookie)); + fc->node = node; + fc->omode = omode; + fc->type = S_IFREG; + err = SLL_INSERT(node->opened, next, fc); + if (err) + goto err_linsert; +/* err = get_vnode(ns->nsid, node->vnid, &dummy); + if (err) + goto err_getvn;*/ + //*vnid = node->vnid; + *cookie = fc; + err = B_OK; + goto all_ok; +//err_: +// put_vnode(ns->nsid, node->nsid); +err_getvn: + SLL_REMOVE(node->opened, next, fc); +err_linsert: + free(fc); +err_malloc: +all_ok: + UNLOCK(&node->l); +err_n_l: +// UNLOCK(&ns->l); + return err; +} + +int googlefs_close(fs_nspace *ns, fs_node *node, fs_file_cookie *cookie) +{ + status_t err; + PRINT((PFS"close(%ld, %Ld)\n", ns->nsid, node->vnid)); + if (!ns || !node || !cookie) + return EINVAL; + err = LOCK(&node->l); + if (err) + return err; + SLL_REMOVE(node->opened, next, cookie); + +all_ok: +err_n_l: + UNLOCK(&node->l); + return err; +} + +int googlefs_free_cookie(fs_nspace *ns, fs_node *node, fs_file_cookie *cookie) +{ + status_t err = B_OK; + PRINT((PFS"freecookie(%ld, %Ld)\n", ns->nsid, node->vnid)); + err = LOCK(&node->l); + if (err) + return err; + err = SLL_REMOVE(node->opened, next, cookie); /* just to amke sure */ +// if (err) +// goto err_n_l; + if (/*!node->is_perm &&*/ false) { /* not yet */ + err = remove_vnode(ns->nsid, node->vnid); + ns->root->st.st_mtime = time(NULL); + notify_listener(B_ENTRY_REMOVED, ns->nsid, ns->rootid, 0LL, node->vnid, NULL); + notify_listener(B_STAT_CHANGED, ns->nsid, 0LL, 0LL, ns->rootid, NULL); + } + UNLOCK(&node->l); + free(cookie); +// err = B_OK; +err_n_l: + return err; +} + +int googlefs_read(fs_nspace *ns, fs_node *node, fs_file_cookie *cookie, off_t pos, void *buf, size_t *len) +{ + status_t err = B_OK; + PRINT((PFS"read(%ld, %Ld, %Ld, %ld)\n", ns->nsid, node->vnid, pos, *len)); + if (node->data_size == 0 || !node->data) + err = ENOSYS; + if (pos < 0 || pos > node->data_size) + err = EFPOS; + if (err) { + *len = 0; + return err; + } + *len = MIN(*len, node->data_size - (long)pos); + memcpy(buf, ((char *)node->data) + pos, *len); + return B_OK; +} + +int googlefs_write(fs_nspace *ns, fs_node *node, fs_file_cookie *cookie, off_t pos, const void *buf, size_t *len) +{ + PRINT((PFS"write(%ld, %Ld, %Ld, %ld)\n", ns->nsid, node->vnid, pos, *len)); + *len = 0; + return ENOSYS; +} + +int googlefs_wstat(fs_nspace *ns, fs_node *node, struct stat *st, long mask) +{ + PRINT((PFS"wstat(%ld, %Ld, , 0x%08lx)\n", ns->nsid, node->vnid, mask)); + return ENOSYS; +} + +int googlefs_wfsstat(fs_nspace *ns, struct fs_info *info, long mask) +{ + PRINT((PFS"wfsstat(%ld, , 0x%08lx)\n", ns->nsid, mask)); + return ENOSYS; +} + +/* this one returns the created fs_node to caller (for use by query engine) */ +/** + * @param dir the dir's fs_node we mkdir in + * @param name name to mkdir (basename is uniq is set) + * @param perms create with those permissions + * @param node make this point to the fs_node if !NULL + * @param iattr indirect attributes to set if desired (must be statically allocated) + * @param mkdir create a directory instead of a file + * @param uniq choose an unique name, appending a number if required + */ +static int googlefs_create_gen(fs_nspace *ns, fs_node *dir, const char *name, int omode, int perms, vnode_id *vnid, fs_node **node, struct attr_entry *iattrs, bool mkdir, bool uniq) +{ + char newname[GOOGLEFS_NAME_LEN]; + status_t err; + fs_node *n; + int i; + PRINT((PFS"create_gen(%ld, %Ld, '%s', 0x%08lx, %c, %c)\n", ns->nsid, dir->vnid, name, omode, mkdir?'t':'f', uniq?'t':'f')); + + if (strlen(name) > GOOGLEFS_NAME_LEN-1) + return ENAMETOOLONG; + err = LOCK(&dir->l); + if (err < 0) + return err; + err = ENOTDIR; + if (!S_ISDIR(dir->st.st_mode)) + goto err_l; + n = (fs_node *)SLL_FIND(dir->children, next, + (sll_compare_func)compare_fs_node_by_name, (void *)name); + err = EEXIST; + if (n && (omode & O_EXCL) && !uniq) /* already existing entry in there! */ + goto err_l; + + strncpy(newname, name, GOOGLEFS_NAME_LEN); + newname[GOOGLEFS_NAME_LEN-1] = '\0'; + + for (i = 1; uniq && n && i < 5000; i++) { /* uniquify the name */ + //sprintf("%"#(GOOGLEFS_NAME_LEN-8)"s %05d", name, i); + strncpy(newname, name, 56); + newname[56] = '\0'; + sprintf(newname+strlen(newname), " %05d", i); + n = (fs_node *)SLL_FIND(dir->children, next, + (sll_compare_func)compare_fs_node_by_name, (void *)newname); + } + if (n && (uniq || mkdir)) /* still there! */ + goto err_l; + name = newname; + + if (n) { /* already exists, so return it */ + if (node) + *node = n; + if (vnid) + *vnid = n->vnid; + err = B_OK; + goto done; + } + err = ENOMEM; + n = malloc(sizeof(fs_node)); + if (!n) + goto err_l; + memset(n, 0, sizeof(fs_node)); + err = vnidpool_get(ns->vnids, &n->vnid); + if (err < B_OK) + goto err_m; + atomic_add(&ns->nodecount, 1); + strcpy(n->name, name); + //n->is_perm = 1; + fill_default_stat(&n->st, ns->nsid, n->vnid, (perms & ~S_IFMT) | (mkdir?S_IFDIR:S_IFREG)); + err = new_lock(&(n->l), mkdir?"googlefs dir":"googlefs file"); + if (err) + goto err_m; + err = LOCK(&ns->l); + if (err) + goto err_nl; + err = SLL_INSERT(ns->nodes, nlnext, n); + if (err) + goto err_lns; + /* _TAIL so they are in order */ + err = SLL_INSERT(dir->children, next, n); + if (err) + goto err_insnl; +// err = new_vnode(ns->nsid, n->vnid, n); +// if (err) +// goto err_ins; + n->parent = dir; + dir->st.st_nlink++; + UNLOCK(&ns->l); + n->attrs_indirect = iattrs; + notify_listener(B_ENTRY_CREATED, ns->nsid, dir->vnid, 0, n->vnid, name); + /* dosfs doesn't do that one but I believe it should */ + notify_listener(B_STAT_CHANGED, ns->nsid, 0LL, 0LL, dir->vnid, NULL); + /* give node to caller if it wants it */ + if (node) + *node = n; + if (vnid) + *vnid = n->vnid; + goto done; + +err_insnl: + SLL_REMOVE(ns->nodes, nlnext, n); +err_lns: + UNLOCK(&ns->l); +err_nl: + free_lock(&n->l); + atomic_add(&ns->nodecount, -1); +err_m: + free(n); +err_l: +done: + UNLOCK(&dir->l); + return err; +} + +int googlefs_create(fs_nspace *ns, fs_node *dir, const char *name, int omode, int perms, vnode_id *vnid, fs_file_cookie **cookie) +{ + status_t err; + fs_node *n; + PRINT((PFS"create(%ld, %Ld, '%s', 0x%08lx)\n", ns->nsid, dir->vnid, name, omode)); + /* don't let ppl mess our fs up */ + return ENOSYS; + + err = googlefs_create_gen(ns, dir, name, omode, perms, vnid, &n, NULL, false, false); + if (err) + return err; + err = googlefs_open(ns, n, omode, cookie); + return err; +} + +int googlefs_unlink(fs_nspace *ns, fs_node *dir, const char *name) +{ + status_t err; + fs_node *n; + PRINT((PFS"unlink(%ld, %Ld, %s)\n", ns->nsid, dir->vnid, name)); + //dprintf(PFS"unlink(%ld, %Ld, %s)\n", ns->nsid, dir->vnid, name); + err = LOCK(&dir->l); + if (err) + return err; + err = ENOENT; + /* no need to check for S_ISDIR */ + n = (fs_node *)SLL_FIND(dir->children, next, + (sll_compare_func)compare_fs_node_by_name, (void *)name); + if (n) { + if (n->children) + err = ENOTEMPTY; + else if (n->is_perm) + err = EROFS; + //else if (S_ISDIR(n->st.st_mode)) + // err = EISDIR; + else if (n->vnid == ns->rootid) + err = EACCES; + else { + SLL_REMOVE(dir->children, next, n); + notify_listener(B_ENTRY_REMOVED, ns->nsid, dir->vnid, 0LL, n->vnid, NULL); + notify_listener(B_STAT_CHANGED, ns->nsid, 0LL, 0LL, dir->vnid, NULL); + remove_vnode(ns->nsid, n->vnid); + err = B_OK; + } + } + UNLOCK(&dir->l); + return err; +} + +int googlefs_rmdir(fs_nspace *ns, fs_node *dir, const char *name) +{ + PRINT((PFS"rmdir(%ld, %Ld, %s)\n", ns->nsid, dir->vnid, name)); + return googlefs_unlink(ns, dir, name); +} + +static int googlefs_unlink_node_rec(fs_nspace *ns, fs_node *node) +{ + status_t err; + fs_node *n; + PRINT((PFS"googlefs_unlink_node_rec(%ld, %Ld:%s)\n", ns->nsid, node->vnid, node->name)); + if (!ns || !node) + return EINVAL; + // kill_request(); + LOCK(&node->l); + while (1) { + n = node->children; + if (!n) + break; + UNLOCK(&node->l); + err = googlefs_unlink_node_rec(ns, n); + LOCK(&node->l); + } + UNLOCK(&node->l); + err = googlefs_unlink(ns, node->parent, node->name); + return err; +} + +int googlefs_access(fs_nspace *ns, fs_node *node, int mode) +{ + PRINT((PFS"access(%ld, %Ld, 0x%x)\n", ns->nsid, node->vnid, mode)); + return B_OK; +} + +int googlefs_setflags(fs_nspace *ns, fs_node *node, fs_file_cookie *cookie, int flags) +{ + return EINVAL; +} + +#if 0 +static int googlefs_mkdir_gen(fs_nspace *ns, fs_node *dir, const char *name, int perms, fs_node **node, bool uniq) +{ + char newname[GOOGLEFS_NAME_LEN]; + status_t err; + fs_node *n; + int i; + PRINT((PFS"mkdir_gen(%ld, %Ld, '%s', 0x%08lx, %c)\n", ns->nsid, dir->vnid, name, perms, uniq?'t':'f')); + + if (strlen(name) > GOOGLEFS_NAME_LEN-1) + return ENAMETOOLONG; + err = LOCK(&dir->l); + if (err < 0) + return err; + err = ENOTDIR; + if (!S_ISDIR(dir->st.st_mode)) + goto err_l; + n = (fs_node *)SLL_FIND(dir->children, next, + (sll_compare_func)compare_fs_node_by_name, (void *)name); + err = EEXIST; + if (n && !uniq) /* already existing entry in there! */ + goto err_l; + + strncpy(newname, name, GOOGLEFS_NAME_LEN); + newname[GOOGLEFS_NAME_LEN-1] = '\0'; + for (i = 1; n && i < 5000; i++) { /* uniquify the name */ + //sprintf("%"#(GOOGLEFS_NAME_LEN-8)"s %05d", name, i); + sprintf("%56s %05d", name, i); + n = (fs_node *)SLL_FIND(dir->children, next, + (sll_compare_func)compare_fs_node_by_name, (void *)newname); + } + if (n) /* still there! */ + goto err_l; + name = newname; + + err = ENOMEM; + n = malloc(sizeof(fs_node)); + if (!n) + goto err_l; + memset(n, 0, sizeof(fs_node)); + err = vnidpool_get(ns->vnids, &n->vnid); + if (err < B_OK) + goto err_m; + atomic_add(&ns->nodecount, 1); + strcpy(n->name, name); + //n->is_perm = 1; + fill_default_stat(&n->st, ns->nsid, n->vnid, (perms & ~S_IFMT) | S_IFDIR); + err = new_lock(&(n->l), "googlefs dir"); + if (err) + goto err_m; + err = LOCK(&ns->l); + if (err) + goto err_nl; + err = SLL_INSERT(ns->nodes, nlnext, n); + if (err) + goto err_lns; + err = SLL_INSERT(dir->children, next, n); + if (err) + goto err_insnl; +// err = new_vnode(ns->nsid, n->vnid, n); +// if (err) +// goto err_ins; + n->parent = dir; + dir->st.st_nlink++; + UNLOCK(&ns->l); + n->attrs_indirect = folders_attrs; + notify_listener(B_ENTRY_CREATED, ns->nsid, dir->vnid, 0, n->vnid, name); + /* dosfs doesn't do that one but I believe it should */ + notify_listener(B_STAT_CHANGED, ns->nsid, 0LL, 0LL, dir->vnid, NULL); + /* give node to caller if it wants it */ + if (node) + *node = n; + goto done; + +err_insnl: + SLL_REMOVE(ns->nodes, nlnext, n); +err_lns: + UNLOCK(&ns->l); +err_nl: + free_lock(&n->l); + atomic_add(&ns->nodecount, -1); +err_m: + free(n); +err_l: +done: + UNLOCK(&dir->l); + return err; +} +#endif + +int googlefs_mkdir(fs_nspace *ns, fs_node *dir, const char *name, int perms) +{ + PRINT((PFS"mkdir(%ld, %Ld, '%s', 0x%08lx)\n", ns->nsid, dir->vnid, name, perms)); + return googlefs_create_gen(ns, dir, name, O_EXCL, perms, NULL, NULL, folders_attrs, true, false); +} + +/* attr stuff */ + +int googlefs_open_attrdir(fs_nspace *ns, fs_node *node, fs_attr_dir_cookie **cookie) +{ + status_t err = B_OK; + fs_attr_dir_cookie *c; + PRINT((PFS "open_attrdir(%ld, %Ld)\n", ns->nsid, node->vnid)); + if (!node) + return EINVAL; + err = LOCK(&node->l); + if (err) + return err; + c = malloc(sizeof(fs_attr_dir_cookie)); + if (c) { + memset(c, 0, sizeof(fs_attr_dir_cookie)); + c->omode = O_RDONLY; + c->type = S_ATTR_DIR; + c->node = node; + c->dir_current = 0; + *cookie = c; + SLL_INSERT(node->opened, next, c); + UNLOCK(&node->l); + return B_OK; + } else + err = B_NO_MEMORY; + UNLOCK(&node->l); + return err; +} + +int googlefs_close_attrdir(fs_nspace *ns, fs_node *node, fs_attr_dir_cookie *cookie) +{ + status_t err = B_OK; + PRINT((PFS "close_attrdir(%ld, %Ld)\n", ns->nsid, node->vnid)); + err = LOCK(&node->l); + if (err) + return err; + SLL_REMOVE(node->opened, next, cookie); + UNLOCK(&node->l); + return err; +} + +int googlefs_free_attrdircookie(fs_nspace *ns, fs_node *node, fs_attr_dir_cookie *cookie) +{ + PRINT((PFS"free_attrdircookie(%ld, %Ld)\n", ns->nsid, node->vnid)); + free(cookie); + return B_OK; +} + +int googlefs_rewind_attrdir(fs_nspace *ns, fs_node *node, fs_attr_dir_cookie *cookie) +{ + PRINT((PFS "rewind_attrdir(%ld, %Ld)\n", ns->nsid, node->vnid)); + cookie->dir_current = 0; + return B_OK; +} + +#ifdef __HAIKU__ +int googlefs_read_attrdir(fs_nspace *ns, fs_node *node, fs_attr_dir_cookie *cookie, struct dirent *buf, size_t bufsize, uint32 *num) +#else +int googlefs_read_attrdir(fs_nspace *ns, fs_node *node, fs_attr_dir_cookie *cookie, long *num, struct dirent *buf, size_t bufsize) +#endif +{ + status_t err = B_OK; + fs_node *n = NULL; + fs_node *parent = node->parent; + attr_entry *ae = NULL; + int i; + int count_indirect; + PRINT((PFS "read_attrdir(%ld, %Ld) @ %d\n", ns->nsid, node->vnid, cookie->dir_current)); + if (!node || !cookie || !num || !*num || !buf || (bufsize < (sizeof(dirent_t)+GOOGLEFS_NAME_LEN))) + return EINVAL; + err = LOCK(&node->l); + for (i = 0, count_indirect = 0; node->attrs_indirect && !ae && node->attrs_indirect[i].name; i++, count_indirect++) + if (i == cookie->dir_current) + ae = &node->attrs_indirect[i]; + for (i = 0; !ae && i < 10 && node->attrs[i].name; i++) + if (i + count_indirect == cookie->dir_current) + ae = &node->attrs[i]; + + if (ae) { + PRINT((PFS "read_attrdir: giving %s\n", ae->name)); + buf->d_dev = ns->nsid; + buf->d_pdev = ns->nsid; + buf->d_ino = node->vnid; + buf->d_pino = node->parent?node->parent->vnid:ns->rootid; + strcpy(buf->d_name, ae->name); + buf->d_reclen = 2*(sizeof(dev_t)+sizeof(ino_t))+sizeof(unsigned short)+strlen(buf->d_name)+1; + cookie->dir_current++; + *num = 1; + } else + *num = 0; + + UNLOCK(&node->l); + return B_OK; +} + +/* Haiku and BeOs differ in the way the handle attributes at the vfs layer. + BeOS uses atomic calls on the vnode, + Haiku retains the open/close/read/write semantics for attributes (loosing atomicity). + Here we don't care much though, open is used for both to factorize attribute lookup. <- TODO + _h suffixed funcs are for Haiku API, _b are for BeOS. + */ + +/* for Haiku, but also used by BeOS calls to factorize code */ +int googlefs_open_attr_h(fs_nspace *ns, fs_node *node, const char *name, int omode, fs_file_cookie **cookie) +{ + status_t err = B_OK; + fs_node *dummy; + fs_file_cookie *fc; + attr_entry *ae = NULL; + int i; + PRINT((PFS"open_attr(%ld, %Ld, %s, 0x%x)\n", ns->nsid, node->vnid, name, omode)); + if (!node || !name || !cookie) + return EINVAL; + + err = LOCK(&node->l); + if (err) + goto err_n_l; + + /* lookup attribute */ + for (i = 0; node->attrs_indirect && !ae && node->attrs_indirect[i].name; i++) + if (!strcmp(name, node->attrs_indirect[i].name)) + ae = &node->attrs_indirect[i]; + for (i = 0; !ae && i < 10 && node->attrs[i].name; i++) + if (!strcmp(name, node->attrs[i].name)) + ae = &node->attrs[i]; + + /* should check omode */ + err = ENOENT; + if (!ae) + goto err_malloc; + err = EEXIST; + + err = B_NO_MEMORY; + fc = malloc(sizeof(fs_file_cookie)); + if (!fc) + goto err_malloc; + memset(fc, 0, sizeof(fs_file_cookie)); + fc->node = node; + fc->omode = omode; + fc->type = S_ATTR; + fc->attr = ae; + err = SLL_INSERT(node->opened, next, fc); + if (err) + goto err_linsert; + + *cookie = fc; + err = B_OK; + goto all_ok; +//err_: +// put_vnode(ns->nsid, node->nsid); +err_getvn: + SLL_REMOVE(node->opened, next, fc); +err_linsert: + free(fc); +err_malloc: +all_ok: + UNLOCK(&node->l); +err_n_l: +// UNLOCK(&ns->l); + return err; +} + +int googlefs_close_attr_h(fs_nspace *ns, fs_node *node, fs_file_cookie *cookie) +{ + status_t err; + PRINT((PFS"close_attr(%ld, %Ld:%s)\n", ns->nsid, node->vnid, cookie->attr?cookie->attr->name:"?")); + if (!ns || !node || !cookie) + return EINVAL; + err = LOCK(&node->l); + if (err) + return err; + SLL_REMOVE(node->opened, next, cookie); + +all_ok: +err_n_l: + UNLOCK(&node->l); + return err; +} + +int googlefs_free_attr_cookie_h(fs_nspace *ns, fs_node *node, fs_file_cookie *cookie) +{ + status_t err = B_OK; + PRINT((PFS"free_attrcookie(%ld, %Ld:%s)\n", ns->nsid, node->vnid, cookie->attr?cookie->attr->name:"?")); + err = LOCK(&node->l); + if (err) + return err; + err = SLL_REMOVE(node->opened, next, cookie); /* just to amke sure */ +// if (err) +// goto err_n_l; + UNLOCK(&node->l); + free(cookie); +// err = B_OK; +err_n_l: + return err; +} + +#ifdef __HAIKU__ + +int googlefs_read_attr_stat_h(fs_nspace *ns, fs_node *node, fs_file_cookie *cookie, struct stat *st) +{ + status_t err = B_OK; + attr_entry *ae = cookie->attr; + PRINT((PFS"stat_attr(%ld, %Ld:%s)\n", ns->nsid, node->vnid, ae->name)); + if (!node || !st || !cookie || !cookie->attr) + return EINVAL; + memcpy(st, &node->st, sizeof(struct stat)); + st->st_type = ae->type; + st->st_size = ae->size; + err = B_OK; + return err; +} + +int googlefs_read_attr_h(fs_nspace *ns, fs_node *node, fs_file_cookie *cookie, off_t pos, void *buf, size_t *len) +{ + status_t err = B_OK; + attr_entry *ae = cookie->attr; + PRINT((PFS"read_attr(%ld, %Ld:%s)\n", ns->nsid, node->vnid, ae->name)); + if (!node || !cookie || !len || !*len) + return EINVAL; + + err = LOCK(&node->l); + + if (ae && pos < ae->size) { + memcpy(buf, (char *)ae->value + pos, MIN(*len, ae->size-pos)); + *len = MIN(*len, ae->size-pos); + err = B_OK; + } else { + *len = 0; + err = ENOENT; + } + + UNLOCK(&node->l); + return err; +} + + +#else + +int googlefs_remove_attr_b(fs_nspace *ns, fs_node *node, const char *name) +{ + PRINT((PFS"%s()\n", __FUNCTION__)); + return ENOSYS; +} + +int googlefs_rename_attr_b(fs_nspace *ns, fs_node *node, const char *oldname, const char *newname) +{ + PRINT((PFS"%s()\n", __FUNCTION__)); + return ENOSYS; +} + +int googlefs_stat_attr_b(fs_nspace *ns, fs_node *node, const char *name, struct attr_info *buf) +{ + status_t err = B_OK; + attr_entry *ae = NULL; + int i; + PRINT((PFS"stat_attr(%ld, %Ld, %s)\n", ns->nsid, node->vnid, name)); + if (!node || !name || !buf) + return EINVAL; + err = LOCK(&node->l); + for (i = 0; node->attrs_indirect && !ae && node->attrs_indirect[i].name; i++) + if (!strcmp(name, node->attrs_indirect[i].name)) + ae = &node->attrs_indirect[i]; + for (i = 0; !ae && i < 10 && node->attrs[i].name; i++) + if (!strcmp(name, node->attrs[i].name)) + ae = &node->attrs[i]; + + if (ae) { + buf->type = ae->type; + buf->size = ae->size; + err = B_OK; + } else + err = ENOENT; + + UNLOCK(&node->l); + return err; +} + +int googlefs_write_attr_b(fs_nspace *ns, fs_node *node, const char *name, int type, + const void *buf, size_t *len, off_t pos) +{ + PRINT((PFS"%s()\n", __FUNCTION__)); + *len = 0; + return ENOSYS; +} + +int googlefs_read_attr_b(fs_nspace *ns, fs_node *node, const char *name, int type, + void *buf, size_t *len, off_t pos) +{ + status_t err = B_OK; + attr_entry *ae = NULL; + int i; + PRINT((PFS"read_attr(%ld, %Ld, %s, 0x%08lx)\n", ns->nsid, node->vnid, name, type)); + if (!node || !name || !len || !*len) + return EINVAL; + err = LOCK(&node->l); + for (i = 0; node->attrs_indirect && !ae && node->attrs_indirect[i].name; i++) + if (!strcmp(name, node->attrs_indirect[i].name)) + ae = &node->attrs_indirect[i]; + for (i = 0; !ae && i < 10 && node->attrs[i].name; i++) + if (!strcmp(name, node->attrs[i].name)) + ae = &node->attrs[i]; + + if (ae && ae->type == type && pos < ae->size) { + memcpy(buf, (char *)ae->value + pos, MIN(*len, ae->size-pos)); + *len = MIN(*len, ae->size-pos); + err = B_OK; + } else { + *len = 0; + err = ENOENT; + } + + UNLOCK(&node->l); + return err; +} + +#endif + +/* query stuff */ + +static int compare_fs_node_by_recent_query_string(fs_node *node, char *query) +{ + time_t tm = time(NULL); + //return memcmp(node->name, name, GOOGLEFS_NAME_LEN); + PRINT((PFS"find_by_recent_query_string: '%s' <> '%s'\n", \ + node->request?node->request->query_string:NULL, query)); + if (!node->request || !node->request->query_string) + return -1; + /* reject if older than 5 min */ + if (node->st.st_crtime + 60 * 5 < tm) + return -1; + return strcmp(node->request->query_string, query); +} + +int googlefs_open_query(fs_nspace *ns, const char *query, ulong flags, + port_id port, long token, fs_query_cookie **cookie) +{ + status_t err = B_OK; + fs_query_cookie *c; + fs_node *qn, *n, *dummy; + const char *p; + char *qstring = NULL; + char qname[GOOGLEFS_NAME_LEN]; + bool accepted = true; + bool reused = false; + int i; + PRINT((PFS"open_query(%ld, '%s', 0x%08lx, %ld, %ld)\n", ns->nsid, query, flags, port, token)); +// if (flags & B_LIVE_QUERY) +// return ENOSYS; /* no live query yet, they are live enough anyway */ + //return ENOSYS; + if (!query || !cookie) + return EINVAL; + + // filter out queries that aren't for us, we don't want to trigger google searches when apps check for mails, ... :) + + err = B_NO_MEMORY; + c = malloc(sizeof(fs_query_cookie)); + if (!c) + return err; + memset(c, 0, sizeof(fs_query_cookie)); + c->omode = O_RDONLY; + c->type = S_IFQUERY; + c->dir_current = 0; + + err = ENOSYS; + if (strncmp(query, "((name==\"*", 10)) + accepted = false; + else { + qstring = query_unescape_string(query + 10, &p, '"'); + if (!qstring) + accepted = false; + else if (!p) + accepted = false; + else if (strcmp(p, "\")&&(BEOS:TYPE==\"application/x-vnd.Be-bookmark\"))")) + accepted = false; + else { + if (qstring[0] == '*') + strcpy(qstring+1, qstring); + if (qstring[strlen(qstring)-1] == '*') + qstring[strlen(qstring)-1] = '\0'; + if (!query_strip_bracketed_Cc(qstring)) + goto err_qs; + } + } + + if (!accepted) { + free(qstring); + /* return an empty cookie */ + *cookie = c; + return B_OK; + } + PRINT((PFS"open_query: QUERY: '%s'\n", qstring)); + /* reuse query if it's not too old */ + LOCK(&ns->l); + qn = SLL_FIND(ns->queries, qnext, + (sll_compare_func)compare_fs_node_by_recent_query_string, (void *)qstring); + UNLOCK(&ns->l); + reused = (qn != NULL); + if (reused) { + PRINT((PFS"open_query: reusing %ld:%Ld\n", ns->nsid, qn->vnid)); + err = get_vnode(ns->nsid, qn->vnid, (void **)&dummy); /* inc ref count */ + if (err) + goto err_mkdir; + /* wait for the query to complete */ + while (!qn->qcompleted) + snooze(10000); + goto reuse; + } + + /* stripped name for folder */ + strncpy(qname, qstring, GOOGLEFS_NAME_LEN); + qname[GOOGLEFS_NAME_LEN-1] = '\0'; + + /* strip out slashes */ + p = qname; + while ((p = strchr(p, '/'))) + strcpy(p, p + 1); + + /* should get/put_vnode(ns->root); around that I think... */ + err = googlefs_create_gen(ns, ns->root, qname, 0, 0755, NULL, &qn, folders_attrs, true, true); + if (err) + goto err_qs; + + err = get_vnode(ns->nsid, qn->vnid, (void **)&dummy); /* inc ref count */ + if (err) + goto err_mkdir; + +//#ifndef NO_SEARCH + + /* let's ask google */ + err = google_request_open(qstring, ns, qn, &qn->request); + if (err) + goto err_gn; + + PRINT((PFS"open_query: request_open done\n")); +#ifndef NO_SEARCH + err = google_request_process(qn->request); + if (err) + goto err_gro; + PRINT((PFS"open_query: request_process done\n")); + +#else + /* fake entries */ + for (i = 0; i < 10; i++) { + err = googlefs_create_gen(ns, qn, "B", 0, 0644, NULL, &n, fake_bookmark_attrs, false, true); + /* fake that to test sorting */ + *(int32 *)&n->attrs[1].value = i + 1; // hack + n->attrs[0].type = 'LONG'; + n->attrs[0].value = &n->attrs[1].value; + n->attrs[0].size = sizeof(int32); + n->attrs[0].name = "GOOGLE:order"; + notify_listener(B_ATTR_CHANGED, ns->nsid, 0, 0, n->vnid, n->attrs[0].name); + if (err) + goto err_gn; + } +#endif /*NO_SEARCH*/ + // + //err = google_request_close(q->request); + + LOCK(&ns->l); + SLL_INSERT(ns->queries, qnext, qn); + UNLOCK(&ns->l); +reuse: + /* put the chocolate on the cookie */ + LOCK(&qn->l); + SLL_INSERT(qn->opened, next, c); + UNLOCK(&qn->l); + qn->qcompleted = 1; /* tell other cookies we're done */ + c->node = qn; + *cookie = c; + free(qstring); + return B_OK; + +err_grp: +err_gro: + if (qn->request) + google_request_close(qn->request); +err_gn: + put_vnode(ns->nsid, qn->vnid); +err_mkdir: + if (!reused) + googlefs_unlink(ns, ns->root, qn->name); +err_qs: + free(qstring); +err_m: + free(c); + PRINT((PFS"open_query: error 0x%08lx\n", err)); + return err; +} + +int googlefs_close_query(fs_nspace *ns, fs_query_cookie *cookie) +{ + status_t err; + fs_node *q, *n; + PRINT((PFS"close_query(%ld, %Ld)\n", ns->nsid, cookie->node?cookie->node->vnid:0LL)); + //return ENOSYS; + q = cookie->node; + if (!q) + return B_OK; + // kill_request(); + LOCK(&q->l); + SLL_REMOVE(q->opened, next, cookie); + if (q->request /*&& !q->opened*/) { + err = google_request_close(q->request); + } + UNLOCK(&q->l); + /* if last cookie on the query and sync_unlink, trash all */ + if (sync_unlink_queries && !q->opened) + err = googlefs_unlink_node_rec(ns, q); + err = put_vnode(ns->nsid, q->vnid); + return err; +} + +#ifdef __HAIKU__ +/* protos are different... */ +int googlefs_free_query_cookie(fs_nspace *ns, fs_dir_cookie *cookie) +{ + PRINT((PFS"free_query_cookie(%ld)\n", ns->nsid)); + free(cookie); + return B_OK; +} +#endif + +#ifdef __HAIKU__ +int googlefs_read_query(fs_nspace *ns, fs_query_cookie *cookie, struct dirent *buf, size_t bufsize, uint32 *num) +#else +int googlefs_read_query(fs_nspace *ns, fs_query_cookie *cookie, long *num, struct dirent *buf, size_t bufsize) +#endif +{ + status_t err = B_OK; + fs_node *n = NULL; + fs_node *node = cookie->node; + int index; + PRINT((PFS"read_query(%ld, %Ld) @ %d\n", ns->nsid, node?node->vnid:0LL, cookie->dir_current)); + if (!cookie || !num || !*num || !buf || (bufsize < (sizeof(dirent_t)+GOOGLEFS_NAME_LEN))) + return EINVAL; + if (!node) { + /* a query we don't care about, just return no entries to please apps */ + *num = 0; + return B_OK; + } + //return ENOSYS; + err = LOCK(&node->l); + index = cookie->dir_current; + for (n = node->children; n && index; n = n->next, index--); + if (n) { + PRINT((PFS "read_query: giving ino %Ld, %s\n", n->vnid, n->name)); + buf->d_dev = ns->nsid; + buf->d_pdev = ns->nsid; + buf->d_ino = n->vnid; + buf->d_pino = node->vnid; + strcpy(buf->d_name, n->name); + buf->d_reclen = 2*(sizeof(dev_t)+sizeof(ino_t))+sizeof(unsigned short)+strlen(buf->d_name)+1; + cookie->dir_current++; + *num = 1; + } else { + *num = 0; + } + UNLOCK(&node->l); + return B_OK; +} + +int googlefs_push_result_to_query(struct google_request *request, struct google_result *result) +{ + status_t err = B_OK; + fs_nspace *ns = request->ns; + fs_node *qn = request->query_node; + fs_node *n, *dummy; + char ename[GOOGLEFS_NAME_LEN]; + char *p; + int i; + PRINT((PFS"push_result_to_query(%ld, %Ld, %d:'%s')\n", ns->nsid, qn->vnid, result->id, result->name)); + //dprintf(PFS"push_result_to_query(%ld, %Ld, %d:'%s')\n", ns->nsid, qn->vnid, result->id, result->name); + //return ENOSYS; + if (!ns || !qn) + return EINVAL; + + // filter out queries that aren't for us, we don't want to trigger google searches when apps check for mails, ... :) + + /* stripped name for folder */ + strncpy(ename, result->name, GOOGLEFS_NAME_LEN); + ename[GOOGLEFS_NAME_LEN-1] = '\0'; + /* strip out slashes */ + p = ename; + while ((p = strchr(p, '/'))) + *p++ = '_'; + + err = googlefs_create_gen(ns, qn, ename, 0, 0644, NULL, &n, bookmark_attrs, false, true); + if (err) + return err; + LOCK(&n->l); + n->result = result; + i = 0; + n->attrs[i].type = 'CSTR'; + n->attrs[i].value = result->name; + n->attrs[i].size = strlen(result->name)+1; + n->attrs[i].name = "META:title"; + notify_listener(B_ATTR_CHANGED, ns->nsid, 0, 0, n->vnid, n->attrs[i].name); + i++; + n->attrs[i].type = 'CSTR'; + n->attrs[i].value = result->url; + n->attrs[i].size = strlen(result->url)+1; + n->attrs[i].name = "META:url"; + notify_listener(B_ATTR_CHANGED, ns->nsid, 0, 0, n->vnid, n->attrs[i].name); + i++; + n->attrs[i].type = 'CSTR'; + n->attrs[i].value = request->query_string; + n->attrs[i].size = strlen(request->query_string)+1; + n->attrs[i].name = "META:keyw"; + notify_listener(B_ATTR_CHANGED, ns->nsid, 0, 0, n->vnid, n->attrs[i].name); + i++; + n->attrs[i].type = 'LONG'; + n->attrs[i].value = &result->id; + n->attrs[i].size = sizeof(int32); + n->attrs[i].name = "GOOGLE:order"; + notify_listener(B_ATTR_CHANGED, ns->nsid, 0, 0, n->vnid, n->attrs[i].name); + i++; + if (result->snipset[0]) { + n->attrs[i].type = 'CSTR'; + n->attrs[i].value = result->snipset; + n->attrs[i].size = strlen(result->snipset)+1; + n->attrs[i].name = "GOOGLE:excerpt"; + notify_listener(B_ATTR_CHANGED, ns->nsid, 0, 0, n->vnid, n->attrs[i].name); + i++; + } + if (result->cache_url[0]) { + n->attrs[i].type = 'CSTR'; + n->attrs[i].value = result->cache_url; + n->attrs[i].size = strlen(result->cache_url)+1; + n->attrs[i].name = "GOOGLE:cache_url"; + notify_listener(B_ATTR_CHANGED, ns->nsid, 0, 0, n->vnid, n->attrs[i].name); + i++; + } + if (result->similar_url[0]) { + n->attrs[i].type = 'CSTR'; + n->attrs[i].value = result->similar_url; + n->attrs[i].size = strlen(result->similar_url)+1; + n->attrs[i].name = "GOOGLE:similar_url"; + notify_listener(B_ATTR_CHANGED, ns->nsid, 0, 0, n->vnid, n->attrs[i].name); + i++; + } + UNLOCK(&n->l); + return B_OK; + +err: + PRINT((PFS"push_result_to_query: error 0x%08lx\n", err)); + return err; +} + +// #pragma mark - + +#ifdef __HAIKU__ + +static status_t +googlefs_std_ops(int32 op, ...) +{ + switch (op) { + case B_MODULE_INIT: + PRINT((PFS"std_ops(INIT)\n")); + return B_OK; + case B_MODULE_UNINIT: + PRINT((PFS"std_ops(UNINIT)\n")); + return B_OK; + default: + return B_ERROR; + } +} + + +static file_system_module_info sGoogleFSModule = { + { + "file_systems/googlefs" B_CURRENT_FS_API_VERSION, + 0, + googlefs_std_ops, + }, + + GOOGLEFS_PRETTY_NAME, + + // scanning + NULL, // fs_identify_partition, + NULL, // fs_scan_partition, + NULL, // fs_free_identify_partition_cookie, + NULL, // free_partition_content_cookie() + + &googlefs_mount, + &googlefs_unmount, + &googlefs_rfsstat, + NULL, + NULL, + + /* vnode operations */ + &googlefs_walk, + &googlefs_get_vnode_name, + &googlefs_read_vnode, + &googlefs_release_vnode, + &googlefs_remove_vnode, + + /* VM file access */ + NULL, // &googlefs_can_page + NULL, // &googlefs_read_pages + NULL, // &googlefs_write_pages + + NULL, // &googlefs_get_file_map, + + NULL, // &googlefs_ioctl + &googlefs_setflags, + NULL, // &googlefs_select + NULL, // &googlefs_deselect + NULL, // &googlefs_fsync + + NULL, // &googlefs_read_link, + NULL, // write link + NULL, // &googlefs_create_symlink, + + NULL, // &googlefs_link, + NULL, // &googlefs_unlink, + NULL, // &googlefs_rename, + + &googlefs_access, + &googlefs_rstat, + &googlefs_wstat, + + /* file operations */ + &googlefs_create, + &googlefs_open, + &googlefs_close, + &googlefs_free_cookie, + &googlefs_read, + NULL, // &googlefs_write, + + /* directory operations */ + &googlefs_mkdir, + &googlefs_rmdir, + &googlefs_opendir, + &googlefs_closedir, + &googlefs_free_dircookie, + &googlefs_readdir, + &googlefs_rewinddir, + + /* attribute directory operations */ + &googlefs_open_attrdir, + &googlefs_close_attrdir, + &googlefs_free_attrdircookie, + &googlefs_read_attrdir, + &googlefs_rewind_attrdir, + + /* attribute operations */ + NULL, // &googlefs_create_attr + &googlefs_open_attr_h, + &googlefs_close_attr_h, + &googlefs_free_attr_cookie_h, + &googlefs_read_attr_h, + NULL, // &googlefs_write_attr_h, + + &googlefs_read_attr_stat_h, + NULL, // &googlefs_write_attr_stat + NULL, // &googlefs_rename_attr + NULL, // &googlefs_remove_attr + + /* index directory & index operations */ + NULL, // &googlefs_open_index_dir + NULL, // &googlefs_close_index_dir + NULL, // &googlefs_free_index_dir_cookie + NULL, // &googlefs_read_index_dir + NULL, // &googlefs_rewind_index_dir + + NULL, // &googlefs_create_index + NULL, // &googlefs_remove_index + NULL, // &googlefs_stat_index + + /* query operations */ + &googlefs_open_query, + &googlefs_close_query, + &googlefs_free_query_cookie, + &googlefs_read_query, + NULL, // &googlefs_rewind_query, +}; + +module_info *modules[] = { + (module_info *)&sGoogleFSModule, + NULL, +}; + + +#else /* BeOS fsil api */ + +_EXPORT vnode_ops fs_entry = +{ + (op_read_vnode *)&googlefs_read_vnode, + (op_write_vnode *)&googlefs_write_vnode, + (op_remove_vnode *)&googlefs_remove_vnode, + (op_secure_vnode *)&googlefs_secure_vnode, + (op_walk *)&googlefs_walk, + (op_access *)&googlefs_access, + (op_create *)&googlefs_create, + (op_mkdir *)&googlefs_mkdir, + NULL, //(op_symlink *)&googlefs_symlink, + NULL, // &googlefs_link, + NULL, //(op_rename *)&googlefs_rename, + (op_unlink *)&googlefs_unlink, + (op_rmdir *)&googlefs_rmdir, + NULL, //(op_readlink *)&googlefs_readlink, + (op_opendir *)&googlefs_opendir, + (op_closedir *)&googlefs_closedir, + (op_free_cookie *)&googlefs_free_dircookie, + (op_rewinddir *)&googlefs_rewinddir, + (op_readdir *)&googlefs_readdir, + (op_open *)&googlefs_open, + (op_close *)&googlefs_close, + (op_free_cookie *)&googlefs_free_cookie, + (op_read *)&googlefs_read, + (op_write *)&googlefs_write, + NULL, // &googlefs_readv, + NULL, // &googlefs_writev, + NULL, // &googlefs_ioctl, + (op_setflags *)&googlefs_setflags, + (op_rstat *)&googlefs_rstat, + (op_wstat *)&googlefs_wstat, + NULL, // &googlefs_fsync, + NULL, // &googlefs_initialize, + (op_mount *)&googlefs_mount, + (op_unmount *)&googlefs_unmount, + NULL, // &googlefs_sync, + (op_rfsstat *)&googlefs_rfsstat, + (op_wfsstat *)&googlefs_wfsstat, + NULL, // &googlefs_select, + NULL, // &googlefs_deselect, + NULL, // &googlefs_open_indexdir, + NULL, // &googlefs_close_indexdir, + NULL, // &googlefs_free_indexdircookie, + NULL, // &googlefs_rewind_indexdir, + NULL, // &googlefs_read_indexdir, + NULL, // &googlefs_create_index, + NULL, // &googlefs_remove_index, + NULL, // &googlefs_rename_index, + NULL, // &googlefs_stat_index, + (op_open_attrdir *)&googlefs_open_attrdir, + (op_close_attrdir *)&googlefs_close_attrdir, + (op_free_cookie *)&googlefs_free_attrdircookie, + (op_rewind_attrdir *)&googlefs_rewind_attrdir, + (op_read_attrdir *)&googlefs_read_attrdir, + (op_write_attr *)&googlefs_write_attr_b, + (op_read_attr *)&googlefs_read_attr_b, + (op_remove_attr *)&googlefs_remove_attr_b, + (op_rename_attr *)&googlefs_rename_attr_b, + (op_stat_attr *)&googlefs_stat_attr_b, + (op_open_query *)&googlefs_open_query, + (op_close_query *)&googlefs_close_query, + (op_free_cookie *)&googlefs_free_dircookie,//&googlefs_free_querycookie, + (op_read_query *)&googlefs_read_query +}; + +_EXPORT int32 api_version=B_CUR_FS_API_VERSION; + +#endif + diff --git a/src/add-ons/kernel/file_systems/googlefs/googlefs.docs.txt b/src/add-ons/kernel/file_systems/googlefs/googlefs.docs.txt new file mode 100644 index 0000000000..943ab28fa1 --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/googlefs.docs.txt @@ -0,0 +1,10 @@ +====================== +pointers to docs + +parsing google results from python (+ diffs on User-Agent ?): +http://forums.devshed.com/archive/t-154742 + +perl hack: plain old XML instead of SOAP: +http://hacks.oreilly.com/pub/h/173 + +http://www.webmasterworld.com/forum10003/2856.htm diff --git a/src/add-ons/kernel/file_systems/googlefs/googlefs.h b/src/add-ons/kernel/file_systems/googlefs/googlefs.h new file mode 100644 index 0000000000..a3526441ce --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/googlefs.h @@ -0,0 +1,131 @@ +#ifndef _GOOGLEFS_H +#define _GOOGLEFS_H + +/* wrappers */ +#ifdef __HAIKU__ + +#include +#include +#include +#include +#define lock benaphore +#define new_lock benaphore_init +#define free_lock benaphore_destroy +#define LOCK benaphore_lock +#define UNLOCK benaphore_unlock +typedef dev_t nspace_id; + +#else + +#include "fsproto.h" +#include "lock.h" +#define publish_vnode new_vnode + +#endif + +#include "lists2.h" + +#include +#include +#include + +/* should be more than enough */ +//#define GOOGLEFS_NAME_LEN B_OS_NAME_LENGTH +//#define GOOGLEFS_NAME_LEN 64 /* GR_MAX_NAME */ +/* some google results are a bit more than 64 */ +#define GOOGLEFS_NAME_LEN 70 /* GR_MAX_NAME */ + +#define GOOGLEFS_NAME "googlefs" +#define GOOGLEFS_PRETTY_NAME "Google Bookmark File System" + +#define MAX_VNIDS 5000 + + +struct attr_entry { + const char *name; + uint32 type; + size_t size; + void *value; +}; + +#define ASSERT(op) if (!(op)) panic("ASSERT: %s in %s:%s", #op, __FILE__, __FUNCTION__) + +struct mount_fs_params +{ + /* no param */ +}; + +struct fs_file_cookie; + +struct fs_node +{ + struct fs_node *nlnext; /* node list */ + struct fs_node *qnext; /* query list */ + struct fs_node *next; /* next in folder */ + struct fs_node *parent, *children; + struct fs_file_cookie *opened; /* opened on this node */ + + char name[GOOGLEFS_NAME_LEN]; + vnode_id vnid; + lock l; + + int is_perm:1; /* don't delete on last close */ + int deleted:1; + int qcompleted:1; + int hidden:1; /* don't list in readdir */ + struct stat st; /* including S_IFDIR in st_mode */ + struct google_request *request; /* set on root folder for a query */ + struct google_result *result; /* for query results */ + struct attr_entry *attrs_indirect; + struct attr_entry attrs[10]; + void *data; + size_t data_size; +}; + +struct vnidpool; + +struct fs_nspace +{ + nspace_id nsid; + vnode_id rootid; + struct vnidpool *vnids; + struct fs_node *root; /* fast access for stat time change */ + struct fs_node *nodes; + struct fs_node *queries; + vint32 nodecount; /* just for statvfs() */ + + lock l; +}; + +struct fs_file_cookie +{ + struct fs_file_cookie *next; /* must stay here */ + struct fs_node *node; + int dir_current; /* current entry for readdir() */ + int omode; + int type; /* S_IF* of the *cookie* */ + struct attr_entry *attr; +}; +/* just for type */ +#define S_IFQUERY 00000070000 + +typedef struct attr_entry attr_entry; +typedef struct fs_nspace fs_nspace; +typedef struct fs_node fs_node; +typedef struct fs_file_cookie fs_file_cookie; +/* not much different */ +#define fs_dir_cookie fs_file_cookie +#define fs_attr_dir_cookie fs_file_cookie +#define fs_query_cookie fs_file_cookie + +vnode_id new_vnid(fs_nspace *ns); +int googlefs_free_vnode(fs_nspace *ns, fs_node *node); + +int googlefs_event(fs_nspace *ns, fs_node *node, int flags); + +/* used by the requester to publish entries in queries + * result = NULL to notify end of list + */ +extern int googlefs_push_result_to_query(struct google_request *request, struct google_result *result); + +#endif diff --git a/src/add-ons/kernel/file_systems/googlefs/googlefs_res.rdef b/src/add-ons/kernel/file_systems/googlefs/googlefs_res.rdef new file mode 100644 index 0000000000..74512ce08b --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/googlefs_res.rdef @@ -0,0 +1,88 @@ +/* +** googlefs.rdef +** +** Automatically generated by BResourceParser on +** Saturday, January 20, 2007 at 01:48:42. +** +*/ + + +resource(1, "BEOS:APP_VERSION") #'APPV' array { + $"0000000000000000010000000000000000000000476F6F676C65465300000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000476F6F676C65465320C2A920" + $"323030342C204672616EC3A76F6973205265766F6C0000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000" +}; + +resource(1, "BEOS:L:STD_ICON") #'ICON' array { + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFF0400FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFF041B0908FFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFF0400041C1B1C0809FFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFF041B09081C1C1B1C0809FFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFF0400041C1B1C08091C1B1C1B0908FFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFF041B09081C1C1B1C08091C1B1C1B0900FFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFF0400041C1B1C08091C1B1C1B09081C1C1B0000FFFFFFFFFF" + $"FFFFFFFFFFFFFFFF041B09081C1C1B1C08091C1B1C1B09001C00D90000FFFFFF" + $"FFFFFFFFFFFF0404041C1C1B09081C1B1C1C08091B1C1C001500D1D9D900FFFF" + $"FFFFFFFFFFFF043F08091B1C1B1C09081C1B1C1C08001C001500D1D1D900FFFF" + $"FFFFFFFF0404041C3F3F08091B1C1B1C09081C1B1C0015001500D1D9AA01FFFF" + $"FFFFFFFF043F08091B1C3F3F08091B1C1B1C09001B0015000F00D9AAAA00FFFF" + $"FFFFFFFF043F3F3F08091B1C3F3F08091B1C1B00160015000FD9AAAAAA00FFFF" + $"FFFFFF00043F1B1C3F3F08091B1C3F3F08001C0015000F00D9AAAAAAAA00FFFF" + $"FFFF00D9043F1B1C1B1C3F3F08091B1C3F00150015000FD9AAAAAAAAAA000FFF" + $"FF00D9D104151A191C1B1C1C3F3F08001C0015000F0063D8D8D86362AA000FFF" + $"FF00D9D9040F15151A191C1C1B1C3F0015001500D8D8D8F8D8F8D8D8630F0FFF" + $"FF008383D9D90FA3C4C4C4A9821C1B0015000FD8D8648483636384F8D863FFFF" + $"FF00838383A32C2C2C2C2C2C2CC41C00150063F884831D3F3F3F1C6364D863FF" + $"FF008383C42C2C2DEBEBEBEB2C2C2C000F62D884633F3F3F3F3F3F1E63F8D862" + $"FF0083A32C2DEBA31A1C1A82EB2D2CC40F63F8841D3F3F3F3F3F3F3F1BF8D863" + $"FF00832C2D2F823F3F3F3F3F1A2D2C2CA9D864833F3F3F3F3F3F3F3F1ED8D883" + $"FF00A32CEBA93F3F3F3F3F3F3F822D2CCAD864833F191B3F3F3F3F3F3FD8D883" + $"FF00C42C2F193F3F3F3F3F3F3F1DC42CEBD8F8831501031B3F3F3F3F1ED8F883" + $"FF00C42C2F1C3F3F3F3F3F1C1B1EC42D2F83D8640F0001193F3F3F3FFDD86414" + $"FF00C42C2DDA3F3F3F3F1C040216C42D2F89F8D86312153F3F3F3FFED8F88414" + $"FFFFA92C2C823F3F3F3F1B0200A92CEB2FAA83F8F8D8FD3F3F1EFDD8F88489FF" + $"FFFF822D2C2CDA3F3F3F3F1713C42DEBA9000F838464F8D8D8D8F8F88489FFFF" + $"FFFFFFCA2D2C2C5A1E3F3FDAC42CEB2F000F0FFF898484848484848A89FFFFFF" + $"FFFFFFFFEB2D2C2C2CC42C2C2CEB2F000F0FFFFFFFFF89898A8989FFFFFFFFFF" + $"FFFFFFFFFFCAEB2D2D2D2D2DEB2F000F0EFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFA9CAEBEBEBCAA9000E0FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" +}; + +resource(1, "BEOS:M:STD_ICON") #'MICN' array { + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFF1BD9D9FFFFFF" + $"FFFFFF828219FFFFFFD8646363D8FFFF" + $"FFFF2C2D2D2CC4FF62631C3F1E63D8FF" + $"FF2CCA1A1D822DA3D8623F3F3F1ED81A" + $"822D1A3F3F3FA32DD8620E1E3F1FD862" + $"822D1D3F3F0F822E63830A1E3FFD64FF" + $"FF2C5A3F1E0BC4EBFF64D8D9D96483FF" + $"FFCA2CA35AC42E82FFFF838A8917FFFF" + $"FFFFA92E2ECA82FFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" +}; + diff --git a/src/add-ons/kernel/file_systems/googlefs/http_cnx.c b/src/add-ons/kernel/file_systems/googlefs/http_cnx.c new file mode 100644 index 0000000000..b7097d398d --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/http_cnx.c @@ -0,0 +1,235 @@ +#include +#include +#include +#include +#include +#include +#include "ksocket.h" +#include +#include +#include "http_cnx.h" + +//#define TESTME + +#ifdef _KERNEL_MODE +#include +#define printf dprintf +#undef TESTME +#endif + +#define DBG "googlefs: http_cnx: " + +#define HTTPVER "1.0" + +#define GOOGLEFS_UA "GoogleFS" + +#ifdef TESTME +#define BUFSZ (128*1024) +#endif + +KSOCKET_MODULE_DECL; + +status_t http_init() +{ + return ksocket_init(); +} + +status_t http_uninit() +{ + return ksocket_cleanup(); +} + +status_t http_create(struct http_cnx **cnx) +{ + struct http_cnx *c; + int err; + c = malloc(sizeof(struct http_cnx)); + if (!c) + return ENOMEM; + memset(c, 0, sizeof(struct http_cnx)); + err = c->sock = ksocket(AF_INET, SOCK_STREAM, 0); + if (err < 0) { + free(c); + return errno; + } + *cnx = c; + return B_OK; +} + +status_t http_delete(struct http_cnx *cnx) +{ + if (!cnx) + return EINVAL; + if ((unsigned long)cnx < 0x40) { + dprintf("http: WARNING: cnx ptr = %p\n", cnx); + return B_OK; + } + if (cnx->sock >= 0) { + kclosesocket(cnx->sock); + cnx->sock = -1; + } + if (cnx->buffer) + free(cnx->buffer); + cnx->buffer = 0xaa55aa55;//XXX + free(cnx); + return B_OK; +} + +status_t http_connect(struct http_cnx *cnx, struct sockaddr_in *sin) +{ + int err; + uint32 ip; + uint16 port; + if (!sin) { + dprintf("http_connect(, NULL)!!\n"); + return EINVAL; + } + ip = sin->sin_addr.s_addr; + port = sin->sin_port; + dprintf("http_connect(, %d.%d.%d.%d:%d), sock = %ld\n", ip & 0xff, (ip >> 8) & 0xff, (ip >> 16) & 0xff, (ip >> 24) & 0xff, ntohs(port), cnx->sock); + err = kconnect(cnx->sock, (struct sockaddr *)sin, sin->sin_len); + cnx->err = 0; + if (err == -1) + return errno; + return err; +} + +status_t http_close(struct http_cnx *cnx) +{ + int err; + if (!cnx) + return EINVAL; + if (cnx->sock < 0) + return 0; + err = kclosesocket(cnx->sock); + cnx->sock = -1; + return err; +} + +status_t http_get(struct http_cnx *cnx, const char *url) +{ + char *req, *p; + int reqlen; + int len; + int err; + long headerslen = 0; + long contentlen = 0; + if (strlen(url) > 4096 - 128) + return EINVAL; + req = malloc(4096); + if (!req) + return B_NO_MEMORY; + /* no snprintf in kernel :( */ + sprintf(req, "GET %s HTTP/"HTTPVER"\nUser-Agent: " GOOGLEFS_UA "/" "0.1" "\nAccept: */*\n\n", url); + reqlen = strlen(req); + err = len = write(cnx->sock, req, reqlen); + if (len < 1) + goto err0; + reqlen = 4096; + err = len = read(cnx->sock, req, reqlen); + printf("read(sock) = %d\n", len); + //write(1, req, len); + err = B_NO_MEMORY; + if (len < 10) + goto err0; + if (!strstr(req, "\r\n\r\n")) { + if (!strstr(req, "\n\n")) /* shouldn't happen */ + goto err0; + headerslen = strstr(req, "\n\n") - req + 2; + req[headerslen-1] = '\0'; + req[headerslen-2] = '\0'; + } else { + headerslen = strstr(req, "\r\n\r\n") - req + 4; + req[headerslen-3] = '\0'; + req[headerslen-4] = '\0'; + } + if (headerslen < 2 || headerslen > 4095) + goto err0; + p = strstr(req, "HTTP/1."); + if (!p) + goto err0; + p += strlen("HTTP/1."); + if (strlen(p) < 5) + goto err0; + p += strlen("1 "); + cnx->err = strtol(p, &p, 10); + if (cnx->err < 200 || cnx->err > 299) + goto err0; + printf("REQ: %d\n", cnx->err); + contentlen = len - headerslen; +// if (!strstr(req, "\n\n") && !strstr(req, "\r\n\r\n")) +// goto err0; + while (len > 0) { + long left = reqlen - headerslen - contentlen; + if (left < 128) { + reqlen += 4096; + p = realloc(req, reqlen); + left += 4096; + if (!p) + goto err0; + req = p; + } + err = len = read(cnx->sock, req + headerslen + contentlen, left); + if (len < 0) + goto err0; + contentlen += len; + } + cnx->buffer = req; + cnx->headers = req; + cnx->headerslen = headerslen; + cnx->data = req + headerslen; + cnx->datalen = contentlen; + cnx->data[contentlen] = '\0'; /* we have at least 128 bytes allocated ahead */ + return B_OK; +err0: + if (err > -1) + err = -1; + free(req); + return err; +} + + + + + + + + + + + + + +#ifdef TESTME +//#define TESTURL "/" +//#define TESTURL "http://www.google.com/search?as_q=google+api+&num=50&hl=en&ie=ISO-8859-1&btnG=Google+Search&as_epq=frequently+asked&as_oq=help&as_eq=plop&lr=lang_en&as_ft=i&as_filetype=&as_qdr=m3&as_nlo=&as_nhi=&as_occt=any&as_dt=i&as_sitesearch=" +#define TESTURL "http://www.google.com/search?hl=en&ie=UTF-8&num=50&q=beos" +int main(int argc, char **argv) +{ + struct sockaddr_in sin; + struct http_cnx *cnx; + size_t len; + char *p; + int err; + + http_init(); + err = http_create(&cnx); + printf("error 0x%08lx\n", err); + sin.sin_len = sizeof(struct sockaddr_in); + sin.sin_family = AF_INET; + sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); + inet_aton("66.102.11.99", &sin.sin_addr); + sin.sin_port = htons(80); + err = http_connect(cnx, &sin); + printf("error 0x%08lx\n", err); + err = http_get(cnx, TESTURL); + printf("error 0x%08lx\n", err); + if (err < 0) + return 1; + printf("HEADERS %d:%s\n", cnx->headerslen, cnx->headers); + printf("DATA: %d:%s\n", cnx->datalen, cnx->data); + http_close(cnx); + http_delete(cnx); + return 0; +} +#endif diff --git a/src/add-ons/kernel/file_systems/googlefs/http_cnx.h b/src/add-ons/kernel/file_systems/googlefs/http_cnx.h new file mode 100644 index 0000000000..ece613d900 --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/http_cnx.h @@ -0,0 +1,31 @@ +#ifndef _HTTP_CNX_H +#define _HTTP_CNX_H + +struct http_cnx { + int sock; + status_t err; /* 404, ... */ + char *headers; + size_t headerslen; + char *data; + size_t datalen; + /* for bookkeeping */ + char *buffer; +}; + +struct sockaddr_in; + +extern status_t http_init(); +extern status_t http_uninit(); + +extern status_t http_create(struct http_cnx **); +extern status_t http_delete(struct http_cnx *cnx); + +extern status_t http_connect(struct http_cnx *cnx, struct sockaddr_in *sin); +extern status_t http_close(struct http_cnx *cnx); + +extern status_t http_get(struct http_cnx *cnx, const char *url); +//extern status_t http_post(struct http_cnx *cnx, const char *url); +/* read the actual data in the buffer */ +//extern status_t http_fetch_data(struct http_cnx *cnx); + +#endif /* _HTTP_CNX_H */ diff --git a/src/add-ons/kernel/file_systems/googlefs/ksocket.h b/src/add-ons/kernel/file_systems/googlefs/ksocket.h new file mode 100644 index 0000000000..0db84e9619 --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/ksocket.h @@ -0,0 +1,114 @@ +/* + * kernel-level support for sockets, includes userland support as well for testing. + * François Revol. + */ + +#ifndef _KSOCKET_H +#define _KSOCKET_H + +#include + +#ifndef _KERNEL_MODE /* userland wrapper */ + +#define ksocket socket +#define kbind bind +#define kconnect connect +#define kgetsockname getsockname +#define kgetpeername getpeername +#define kaccept accept +#define ksendmsg sendmsg +#define krecvmsg recvmsg +#define krecvfrom recvfrom +#define ksendto sendto +#define krecv recv +#define ksend send +#define klisten listen +#define kshutdown shutdown +#define kclosesocket close +#define ksocket_init() ({B_OK;}) +#define ksocket_cleanup() ({B_OK;}) +#define kmessage(fmt, ...) printf(fmt "\n", ##__VA_ARGS__) +#define KSOCKET_MODULE_DECL /* nothing */ + +#elif defined(__HAIKU__) + +/* Haiku socket module */ +#include + +extern struct socket_module_info *gSocket; +#define ksocket (gSocket->socket) +#define kbind (gSocket->bind) +#define kconnect (gSocket->connect) +#define kgetsockname (gSocket->getsockname) +#define kgetpeername (gSocket->getpeername) +#define kaccept (gSocket->accept) +//#define kaccept(_fd, _addr, _sz) ({int thesock; thesock = (gSocket->accept)(_fd, _addr, _sz); dprintf("kaccept(%d, , ) = %d\n", _fd, thesock); thesock; }) +#define ksendmsg (gSocket->sendmsg) +#define krecvmsg (gSocket->recvmsg) +#define krecvfrom (gSocket->recvfrom) +#define ksendto (gSocket->sendto) +#define krecv (gSocket->recv) +#define ksend (gSocket->send) +#define klisten (gSocket->listen) +#define kshutdown (gSocket->shutdown) +#define kclosesocket close +#define kmessage(fmt, ...) dprintf("ksocket: " fmt "\n", ##__VA_ARGS__) + +extern status_t ksocket_init (); +extern status_t ksocket_cleanup (); + +#define KSOCKET_MODULE_DECL \ +struct socket_module_info *gSocket; \ +status_t ksocket_init () { \ + return get_module(B_SOCKET_MODULE_NAME, (module_info **)&gSocket); \ +} \ + \ +status_t ksocket_cleanup () { \ + return put_module(B_SOCKET_MODULE_NAME); \ +} + +#elif defined(BONE_VERSION) + +/* BONE socket module */ +#include + +extern bone_socket_info_t *gSocket; +#define ksocket (gSocket->socket) +//#define ksocket(_fam, _typ, _pro) ({int thesock; thesock = (gSocket->socket)(_fam, _typ, _pro); dprintf("ksocket(%d, %d, %d) = %d\n", _fam, _typ, _pro, thesock); thesock;}) +#define kbind (gSocket->bind) +#define kconnect (gSocket->connect) +#define kgetsockname (gSocket->getsockname) +#define kgetpeername (gSocket->getpeername) +#define kaccept (gSocket->accept) +//#define kaccept(_fd, _addr, _sz) ({int thesock; thesock = (gSocket->accept)(_fd, _addr, _sz); dprintf("kaccept(%d, , ) = %d\n", _fd, thesock); thesock; }) +#define ksendmsg _ERROR_no_sendmsg_in_BONE +#define krecvmsg _ERROR_no_recvmsg_in_BONE +#define krecvfrom (gSocket->recvfrom) +#define ksendto (gSocket->sendto) +#define krecv (gSocket->recv) +#define ksend (gSocket->send) +#define klisten (gSocket->listen) +#define kshutdown (gSocket->shutdown) +#define kclosesocket close +#define kmessage(fmt, ...) dprintf("ksocket: " fmt "\n", ##__VA_ARGS__) + +extern status_t ksocket_init (); +extern status_t ksocket_cleanup (); + +#define KSOCKET_MODULE_DECL \ +bone_socket_info_t *gSocket; \ +status_t ksocket_init () { \ + return get_module(BONE_SOCKET_MODULE, (module_info **)&gSocket); \ +} \ + \ +status_t ksocket_cleanup () { \ + return put_module(BONE_SOCKET_MODULE); \ +} + +#else /* _KERNEL_MODE, !BONE_VERSION */ + +#error feel free to put back ksocketd support if you dare + +#endif /* _KERNEL_MODE, BONE_VERSION */ + +#endif /* _KSOCKET_H */ diff --git a/src/add-ons/kernel/file_systems/googlefs/lists.c b/src/add-ons/kernel/file_systems/googlefs/lists.c new file mode 100644 index 0000000000..43ba88e01b --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/lists.c @@ -0,0 +1,80 @@ +#include +#include "lists.h" + +void slist_init(struct _slist_entry *item) +{ + item->next = NULL; +} + +void slist_uninit(struct _slist_entry *item) +{ + item->next = NULL; +} + +struct _slist_entry *slist_find(struct _slist_entry *head, slist_compare_func func, void *id) +{ + struct _slist_entry *p = head; + if (head == NULL) + return NULL; + while (p) { + if (func(p, id) == 0) + return p; + p = p->next; + } + return NULL; +} + +status_t slist_insert_head(struct _slist_entry **head, struct _slist_entry *item) +{ + struct _slist_entry *next = NULL; + if (head == NULL || item == NULL) + return EINVAL; + if (*head) + next = *head; + item->next = next; + *head = item; + return B_OK; +} + +struct _slist_entry *slist_dequeue_tail(struct _slist_entry **head) +{ + struct _slist_entry **prev = NULL; + struct _slist_entry *curr = NULL; + if (head == NULL || *head == NULL) + return NULL; + prev = head; + curr = *head; + while (curr->next) { + prev = &(curr->next); + curr = curr->next; + } + *prev = NULL; + return curr; +} + +status_t slist_remove(struct _slist_entry **head, struct _slist_entry *item) +{ + struct _slist_entry **prev = NULL; + struct _slist_entry *curr = NULL; + if (head == NULL || *head == NULL || item == NULL) + return EINVAL; + prev = head; + curr = *head; + while (prev && curr) { + if (curr == item) { + *prev = curr->next; + curr->next = NULL; + return B_OK; + } + prev = &(curr->next); + curr = curr->next; + } + return ENOENT; +} + +struct _slist_entry *slist_next(struct _slist_entry *item) +{ + if (!item || !item->next) + return NULL; + return item->next; +} diff --git a/src/add-ons/kernel/file_systems/googlefs/lists.h b/src/add-ons/kernel/file_systems/googlefs/lists.h new file mode 100644 index 0000000000..3aa99ab73b --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/lists.h @@ -0,0 +1,29 @@ +/* good old single linked list stuff */ +/* revol@free.fr */ + +#ifndef _LISTS_H +#define _LISTS_H + +#include + +typedef struct _slist_entry { + struct _slist_entry *next; + char id[0]; +} slist_entry; + +typedef int (*slist_compare_func)(struct _slist_entry *item, void *id); + +extern void slist_init(struct _slist_entry *item); +extern void slist_uninit(struct _slist_entry *item); +extern struct _slist_entry *slist_find(struct _slist_entry *head, slist_compare_func func, void *id); +extern status_t slist_insert_head(struct _slist_entry **head, struct _slist_entry *item); +extern struct _slist_entry *slist_dequeue_tail(struct _slist_entry **head); +extern status_t slist_remove(struct _slist_entry **head, struct _slist_entry *item); +extern struct _slist_entry *slist_next(struct _slist_entry *item); + +#define LENT_TO_OBJ(_obtype, _sle, _moff) ((_obtype *)(((char *)(_sle)) - offsetof(_obtype, _moff))) +#define OBJ_TO_LENT(_obj, _member) (&((_obj)->_member)) + + +#endif /* _LISTS_H */ + diff --git a/src/add-ons/kernel/file_systems/googlefs/lists2.c b/src/add-ons/kernel/file_systems/googlefs/lists2.c new file mode 100644 index 0000000000..58e59c88e4 --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/lists2.c @@ -0,0 +1,99 @@ +#include +#include "lists2.h" + +void *sll_find(long nextoff, void *head, sll_compare_func func, void *id) +{ + void *p = head; + int count = 5000; + if (head == NULL) + return NULL; + while (p) { + if (func(p, id) == 0) + return p; + p = sll_next(nextoff, p); + if (!count--) { + dprintf("sll_find: WARNING: 5000 nodes to search ??? looks more of a loop.\n"); + return NULL; + } + } + return NULL; +} + +status_t sll_insert_head(long nextoff, void **head, void *item) +{ + void *next = NULL; + if (head == NULL || item == NULL) + return EINVAL; + if (*head) + next = *head; + *(void **)(((char *)item)+nextoff) = next; + *head = item; + return B_OK; +} + +status_t sll_insert_tail(long nextoff, void **head, void *item) +{ + void *p, *next = NULL; + if (head == NULL || item == NULL) + return EINVAL; + + if (*(void **)(((char *)item)+nextoff)) { + dprintf("sll_insert_tail: WARNING: %p->next NOT NULL\n", item); + *(void **)(((char *)item)+nextoff) = NULL; + } + + p = *head; + if (!p) { + *head = item; + return B_OK; + } + while (sll_next(nextoff, p)) + p = sll_next(nextoff, p); + *(void **)(((char *)p)+nextoff) = item; + return B_OK; +} + +void *sll_dequeue_tail(long nextoff, void **head) +{ + void **prev = NULL; + void *curr = NULL; + if (head == NULL || *head == NULL) + return NULL; + prev = head; + curr = *head; + while (sll_next(nextoff, curr)) { + prev = (void **)(((char *)curr)+nextoff); + curr = sll_next(nextoff, curr); + } + *prev = NULL; + return curr; +} + +status_t sll_remove(long nextoff, void **head, void *item) +{ + void **prev = NULL; + void *curr = NULL; + if (head == NULL || *head == NULL || item == NULL) + return EINVAL; + prev = head; + curr = *head; + while (prev && curr) { + if (curr == item) { + *prev = sll_next(nextoff, curr); + *(void **)(((char *)item)+nextoff) = NULL; + return B_OK; + } + prev = (void **)(((char *)curr)+nextoff); + curr = sll_next(nextoff, curr); + } + return ENOENT; +} + +void *sll_next(long nextoff, void *item) +{ + void *next; + if (!item) + return NULL; + next = *(void **)(((char *)item)+nextoff); + return next; +} diff --git a/src/add-ons/kernel/file_systems/googlefs/lists2.h b/src/add-ons/kernel/file_systems/googlefs/lists2.h new file mode 100644 index 0000000000..246f04482c --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/lists2.h @@ -0,0 +1,28 @@ +/* good old single linked list stuff */ +/* revol@free.fr */ + +#ifndef _LISTS2_H +#define _LISTS2_H + +typedef int (*sll_compare_func)(const void *item, void *id); + +extern void *sll_find(long nextoff, void *head, sll_compare_func func, void *id); +extern status_t sll_insert_head(long nextoff, void **head, void *item); +extern status_t sll_insert_tail(long nextoff, void **head, void *item); +extern void *sll_dequeue_tail(long nextoff, void **head); +extern status_t sll_remove(long nextoff, void **head, void *item); +extern void *sll_next(long nextoff, void *item); + +#define SLLPTROFF(type,item,nextp) ((typeof(item))(((char *)(item)) + offsetof(item, nextp))) +#define SLLITEM2PTR(type,item,nextp) ((typeof(item))(((char *)(item)) + offsetof(item, nextp))) +#define SLLPTR2ITEM(type,ptr,nextp) ((typeof(ptr))(((char *)(ptr)) - offsetof(ptr, nextp))) +#define SLLNEXT(type,item,nextp) (*(typeof(item))(((char *)(item)) + offsetof(item, nextp))) + +#define SLL_FIND(_head,_nextp,_func,_with) (typeof(_head))sll_find(offsetof(typeof(*_head),_nextp), (void *)(_head), _func, _with) +#define SLL_INSERT(_head,_nextp,_item) (typeof(_head))sll_insert_head(offsetof(typeof(*_head),_nextp), (void **)&(_head), _item) +//#define SLL_INSERT_TAIL(_head,_nextp,_item) (typeof(_head))sll_insert_tail(offsetof(typeof(*_head),_nextp), (void **)&(_head), _item) +#define SLL_INSERT_TAIL(_head,_nextp,_item) sll_insert_head(offsetof(typeof(*_head),_nextp), (void **)&(_head), _item) +#define SLL_DEQUEUE(_head,_nextp) (typeof(_head))sll_dequeue_tail(offsetof(typeof(*_head),_nextp), (void **)&(_head)) +#define SLL_REMOVE(_head,_nextp,_item) (typeof(_head))sll_remove(offsetof(typeof(*_head),_nextp), (void **)&(_head), _item) + +#endif /* _LISTS2_H */ diff --git a/src/add-ons/kernel/file_systems/googlefs/lock.h b/src/add-ons/kernel/file_systems/googlefs/lock.h new file mode 100644 index 0000000000..d407a27fd7 --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/lock.h @@ -0,0 +1,52 @@ +/* + Copyright 1999, Be Incorporated. All Rights Reserved. + This file may be used under the terms of the Be Sample Code License. +*/ + +#ifndef _LOCK_H +#define _LOCK_H + +#include + +#include + +typedef struct lock lock; +typedef struct mlock mlock; + +struct lock { + sem_id s; + long c; +}; + +struct mlock { + sem_id s; +}; + +extern _IMPEXP_KERNEL int new_lock(lock *l, const char *name); +extern _IMPEXP_KERNEL int free_lock(lock *l); + +static inline status_t LOCK(lock *l) +{ + if (atomic_add(&(l->c), -1) <= 0) + return acquire_sem(l->s); + return B_OK; +} + +static inline status_t UNLOCK(lock *l) +{ + if (atomic_add(&(l->c), 1) < 0) + return release_sem(l->s); + return B_OK; +} + + +//#define LOCK(l) if (atomic_add(&l.c, -1) <= 0) acquire_sem(l.s); +//#define UNLOCK(l) if (atomic_add(&l.c, 1) < 0) release_sem(l.s); + +extern _IMPEXP_KERNEL int new_mlock(mlock *l, long c, const char *name); +extern _IMPEXP_KERNEL int free_mlock(mlock *l); + +#define LOCKM(l,cnt) acquire_sem_etc(l.s, cnt, 0, 0) +#define UNLOCKM(l,cnt) release_sem_etc(l.s, cnt, 0) + +#endif diff --git a/src/add-ons/kernel/file_systems/googlefs/makefile b/src/add-ons/kernel/file_systems/googlefs/makefile new file mode 100644 index 0000000000..afb583c4ae --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/makefile @@ -0,0 +1,133 @@ +## BeOS Generic Makefile v2.2 ## + +## Fill in this file to specify the project being created, and the referenced +## makefile-engine will do all of the hard work for you. This handles both +## Intel and PowerPC builds of the BeOS. + +## Application Specific Settings --------------------------------------------- + +# specify the name of the binary +NAME= googlefs + +# specify the type of binary +# APP: Application +# SHARED: Shared library or add-on +# STATIC: Static library archive +# DRIVER: Kernel Driver +TYPE= DRIVER + +# add support for new Pe and Eddie features +# to fill in generic makefile + +#%{ +# @src->@ + +# specify the source files to use +# full paths or paths relative to the makefile can be included +# all files, regardless of directory, will have their object +# files created in the common object directory. +# Note that this means this makefile will not work correctly +# if two source files with the same name (source.c or source.cpp) +# are included from different directories. Also note that spaces +# in folder names do not work well with this makefile. +SRCS= vnidpool.c \ +lists2.c \ +http_cnx.c \ +parse_google_html.c \ +google_request.c \ +query.c \ +googlefs.c \ +google_icon.c \ +attrs.c \ +settings.c \ +string_utils.c + +# specify the resource files to use +# full path or a relative path to the resource file can be used. +RSRCS= + +# @<-src@ +#%} + +# end support for Pe and Eddie + +# specify additional libraries to link against +# there are two acceptable forms of library specifications +# - if your library follows the naming pattern of: +# libXXX.so or libXXX.a you can simply specify XXX +# library: libbe.so entry: be +# +# - if your library does not follow the standard library +# naming scheme you need to specify the path to the library +# and it's name +# library: my_lib.a entry: my_lib.a or path/my_lib.a +LIBS= + +# specify additional paths to directories following the standard +# libXXX.so or libXXX.a naming scheme. You can specify full paths +# or paths relative to the makefile. The paths included may not +# be recursive, so include all of the paths where libraries can +# be found. Directories where source files are found are +# automatically included. +LIBPATHS= + +# additional paths to look for system headers +# thes use the form: #include
+# source file directories are NOT auto-included here +SYSTEM_INCLUDE_PATHS = + +# additional paths to look for local headers +# thes use the form: #include "header" +# source file directories are automatically included +LOCAL_INCLUDE_PATHS = + +# specify the level of optimization that you desire +# NONE, SOME, FULL +OPTIMIZE= FULL + +# specify any preprocessor symbols to be defined. The symbols will not +# have their values set automatically; you must supply the value (if any) +# to use. For example, setting DEFINES to "DEBUG=1" will cause the +# compiler option "-DDEBUG=1" to be used. Setting DEFINES to "DEBUG" +# would pass "-DDEBUG" on the compiler's command line. +#DEFINES= _IMPEXP_KERNEL= DEBUG_GOOGLEFS=1 +DEFINES+= _IMPEXP_KERNEL= +#DEFINES+= DEBUG=1 +#DEBUG=1 + +# specify special warning levels +# if unspecified default warnings will be used +# NONE = supress all warnings +# ALL = enable all warnings +WARNINGS = ALL + +# specify whether image symbols will be created +# so that stack crawls in the debugger are meaningful +# if TRUE symbols will be created +SYMBOLS = TRUE + +# specify debug settings +# if TRUE will allow application to be run from a source-level +# debugger. Note that this will disable all optimzation. +DEBUGGER = + +# specify additional compiler flags for all files +COMPILER_FLAGS = + +# specify additional linker flags +LINKER_FLAGS = + +# specify the version of this particular item +# (for example, -app 3 4 0 d 0 -short 340 -long "340 "`echo -n -e '\302\251'`"1999 GNU GPL") +# This may also be specified in a resource. +APP_VERSION = + +# (for TYPE == DRIVER only) Specify desired location of driver in the /dev +# hierarchy. Used by the driverinstall rule. E.g., DRIVER_PATH = video/usb will +# instruct the driverinstall rule to place a symlink to your driver's binary in +# ~/add-ons/kernel/drivers/dev/video/usb, so that your driver will appear at +# /dev/video/usb when loaded. Default is "misc". +DRIVER_PATH = + +## include the makefile-engine +include $(BUILDHOME)/etc/makefile-engine diff --git a/src/add-ons/kernel/file_systems/googlefs/makefile.ufs b/src/add-ons/kernel/file_systems/googlefs/makefile.ufs new file mode 100644 index 0000000000..bb70e497aa --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/makefile.ufs @@ -0,0 +1,134 @@ +## BeOS Generic Makefile v2.2 ## + +## Fill in this file to specify the project being created, and the referenced +## makefile-engine will do all of the hard work for you. This handles both +## Intel and PowerPC builds of the BeOS. + +## Application Specific Settings --------------------------------------------- + +# specify the name of the binary +NAME= googlefs + +# specify the type of binary +# APP: Application +# SHARED: Shared library or add-on +# STATIC: Static library archive +# DRIVER: Kernel Driver +TYPE= SHARED + +# add support for new Pe and Eddie features +# to fill in generic makefile + +#%{ +# @src->@ + +# specify the source files to use +# full paths or paths relative to the makefile can be included +# all files, regardless of directory, will have their object +# files created in the common object directory. +# Note that this means this makefile will not work correctly +# if two source files with the same name (source.c or source.cpp) +# are included from different directories. Also note that spaces +# in folder names do not work well with this makefile. +SRCS= vnidpool.c \ +lists2.c \ +http_cnx.c \ +parse_google_html.c \ +google_request.c \ +query.c \ +googlefs.c \ +google_icon.c \ +attrs.c \ +settings.c \ +string_utils.c + +# specify the resource files to use +# full path or a relative path to the resource file can be used. +RSRCS= + +# @<-src@ +#%} + +# end support for Pe and Eddie + +# specify additional libraries to link against +# there are two acceptable forms of library specifications +# - if your library follows the naming pattern of: +# libXXX.so or libXXX.a you can simply specify XXX +# library: libbe.so entry: be +# +# - if your library does not follow the standard library +# naming scheme you need to specify the path to the library +# and it's name +# library: my_lib.a entry: my_lib.a or path/my_lib.a +LIBS= _APP_ socket bind + +# specify additional paths to directories following the standard +# libXXX.so or libXXX.a naming scheme. You can specify full paths +# or paths relative to the makefile. The paths included may not +# be recursive, so include all of the paths where libraries can +# be found. Directories where source files are found are +# automatically included. +LIBPATHS= + +# additional paths to look for system headers +# thes use the form: #include
+# source file directories are NOT auto-included here +SYSTEM_INCLUDE_PATHS = + +# additional paths to look for local headers +# thes use the form: #include "header" +# source file directories are automatically included +LOCAL_INCLUDE_PATHS = + +# specify the level of optimization that you desire +# NONE, SOME, FULL +OPTIMIZE= FULL + +# specify any preprocessor symbols to be defined. The symbols will not +# have their values set automatically; you must supply the value (if any) +# to use. For example, setting DEFINES to "DEBUG=1" will cause the +# compiler option "-DDEBUG=1" to be used. Setting DEFINES to "DEBUG" +# would pass "-DDEBUG" on the compiler's command line. +DEFINES= DEBUG=1 _BUILDING_fs=1 _IMPEXP_KERNEL= +#DEBUG=1 + +# specify special warning levels +# if unspecified default warnings will be used +# NONE = supress all warnings +# ALL = enable all warnings +WARNINGS = ALL + +# specify whether image symbols will be created +# so that stack crawls in the debugger are meaningful +# if TRUE symbols will be created +SYMBOLS = TRUE + +# specify debug settings +# if TRUE will allow application to be run from a source-level +# debugger. Note that this will disable all optimzation. +DEBUGGER = + +# specify additional compiler flags for all files +COMPILER_FLAGS = + +# specify additional linker flags +LINKER_FLAGS = + +# specify the version of this particular item +# (for example, -app 3 4 0 d 0 -short 340 -long "340 "`echo -n -e '\302\251'`"1999 GNU GPL") +# This may also be specified in a resource. +APP_VERSION = + +# (for TYPE == DRIVER only) Specify desired location of driver in the /dev +# hierarchy. Used by the driverinstall rule. E.g., DRIVER_PATH = video/usb will +# instruct the driverinstall rule to place a symlink to your driver's binary in +# ~/add-ons/kernel/drivers/dev/video/usb, so that your driver will appear at +# /dev/video/usb when loaded. Default is "misc". +DRIVER_PATH = + +## include the makefile-engine +include $(BUILDHOME)/etc/makefile-engine + +_APP_: + ln -s /boot/home/config/bin/UserlandFSServer _APP_ diff --git a/src/add-ons/kernel/file_systems/googlefs/makezip.sh b/src/add-ons/kernel/file_systems/googlefs/makezip.sh new file mode 100755 index 0000000000..30cf55ab97 --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/makezip.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +FILES="home/config/settings/kernel/drivers/googlefs home/config/add-ons/kernel/file_systems/googlefs home/config/add-ons/userlandfs/googlefs home/config/bin/ndmount home/config/bin/mountgooglefs home/config/bin/imlucky home/config/bin/google home/Desktop/README.googlefs.txt home/config/settings/Tracker/DefaultQueryTemplates/application_x-vnd.Be-bookmark" + +cd /boot +zip -r9 googlefs-test-bin.zip ${FILES} + + + diff --git a/src/add-ons/kernel/file_systems/googlefs/parse_google_html.c b/src/add-ons/kernel/file_systems/googlefs/parse_google_html.c new file mode 100644 index 0000000000..211405932c --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/parse_google_html.c @@ -0,0 +1,253 @@ +#include +#include +#include +#include +#include +#include +#include +#include "google_request.h" +#include "string_utils.h" + +#define TESTME + +#ifdef _KERNEL_MODE +#define printf dprintf +#undef TESTME +#endif + +#define DBG "googlefs: parse_html: " + +#ifdef TESTME +#define BUFSZ (128*1024) +#endif + +//old +//#define G_BEGIN_URL "

" +//#define G_BEGIN_NAME +#define G_END_NAME "" +#define G_BEGIN_SNIPSET /*""*/"" +#define G_END_SNIPSET "
" +#define G_BEGIN_CACHESIM " " + +int google_parse_results(const char *html, size_t htmlsize, struct google_result **results) +{ + struct google_result *res = NULL, *nres = NULL, *prev = NULL; + const char *p, *q; + char *nextresult = NULL; + long numres = 0; + long maxres = 0; + long startid = 0; + long lastid = 0; + int done = 0; + int err = ENOMEM; + + if (!html || !results) + return EINVAL; + /* sanity checks */ + printf(DBG"sanity check...\n"); + if (strstr(html, "") != html) + return EINVAL; +// p = strstr(html, "Google Search:"); + p = strstr(html, "Google"); + if (!p) return EINVAL; + p = strstr(html, "</head><body"); + if (!p) return EINVAL; + p = strstr(html, ">Results <b>"); + if (!p) return EINVAL; + p+= strlen(">Results <b>"); + startid = strtol(p, &p, 10); + if (!p) return EINVAL; + p = strstr(html, "</b> - <b>"); + p+= strlen("</b> - <b>"); + if (!p) return EINVAL; + lastid = strtol(p, &p, 10); + if (!p) return EINVAL; + maxres = lastid - startid + 1; + printf(DBG"getting %ld results (%ld to %ld)\n", maxres, startid, lastid); + + + printf(DBG"parsing...\n"); + do { + char *item; + long itemlen; + char *tmp; + int i; + nres = malloc(sizeof(struct google_result)); + if (!nres) { + // XXX: cleanup! + goto err0; + } + memset(nres, 0, sizeof(struct google_result)); + nres->id = startid + numres; //- 1; + + /* find url */ + // <p class=g><a href=URL> + if (!p) break; + if (nextresult) + p = nextresult; + else + p = strstr(p, G_BEGIN_URL); + if (!p) break; + p+= strlen(G_BEGIN_URL); + nextresult = strstr(p, G_BEGIN_URL); + //printf(DBG"[%ld] found token 1\n", numres); + item = p; + p = strstr(p, G_END_URL); + if (!p) break; + p+= strlen(G_END_URL); + //printf(DBG"[%ld] found token 2\n", numres); + itemlen = p - item - strlen(G_END_URL); + itemlen = MIN(GR_MAX_URL-1, itemlen); + strncpy(nres->url, item, itemlen); + nres->url[itemlen] = '\0'; + + /* find name */ + //<b>Google</b> Web APIs - FAQ</a><table + item = p; + p = strstr(p, G_END_NAME); + if (!p) break; + p+= strlen(G_END_NAME); + //printf(DBG"[%ld] found token 3\n", numres); + itemlen = p - item - strlen(G_END_NAME); + //itemlen = MIN(GR_MAX_NAME-1, itemlen); + itemlen = MIN(GR_MAX_NAME*4-1, itemlen); + q = malloc(itemlen+1); + if (!q) + goto err0; + strncpy(q, item, itemlen); + q[itemlen] = '\0'; + /* strip <*b> off */ + while ((tmp = strstr(q, "<b>"))) + strcpy(tmp, tmp + 3); + while ((tmp = strstr(q, "</b>"))) + strcpy(tmp, tmp + 4); + /* strip &foo; */ + tmp = unentitify_string(q); + free(q); + if (!tmp) + goto err0; + strncpy(nres->name, tmp, GR_MAX_NAME-1); + nres->name[GR_MAX_NAME-1] = '\0'; + free(tmp); + +#if 0 + /* find snipset */ + //<td class=j><font size=-1><b>...</b> a custom Java client library, documentation on <b>how</b> <b>to</b> use the <b>...</b> You can find it at http://<b>api</b>.<b>google</b>.com/GoogleSearch.wsdl <b>...</b> need to get started is in <b>googleapi</b>.jar <b>...</b> <br> + if (!p) break; + q = strstr(p, G_BEGIN_SNIPSET); + if (q && (!nextresult || (q < nextresult))) { + p = q; + p+= strlen(G_BEGIN_SNIPSET); + //printf(DBG"[%ld] found token 4\n", numres); + item = p; + p = strstr(p, G_END_SNIPSET); + if (!p) break; + p+= strlen(G_END_SNIPSET); + //printf(DBG"[%ld] found token 5\n", numres); + itemlen = p - item - strlen(G_END_SNIPSET); + itemlen = MIN(GR_MAX_URL-1, itemlen); + strncpy(nres->snipset, item, itemlen); + nres->snipset[itemlen] = '\0'; + /* strip &foo; */ + tmp = unentitify_string(nres->snipset); + if (!tmp) + break; + strncpy(nres->snipset, tmp, GR_MAX_SNIPSET-1); + nres->snipset[GR_MAX_SNIPSET-1] = '\0'; + free(tmp); + /* strip <*b> off */ + while ((tmp = strstr(nres->snipset, "<b>"))) + strcpy(tmp, tmp + 3); + while ((tmp = strstr(nres->snipset, "</b>"))) + strcpy(tmp, tmp + 4); + while ((tmp = strstr(nres->snipset, "\r"))) + strcpy(tmp, tmp + 1); + while ((tmp = strstr(nres->snipset, "\n"))) + *tmp = ' '; + } + +#endif + /* find cache/similar url */ + // <a class=fl href="http://216.239.59.104/search?q=cache:vR7BaPWutnkJ:www.google.com/apis/api_faq.html+google+api++help+%22frequently+asked%22+-plop&hl=en&lr=lang_en&ie=UTF-8">Cached</a> + for (i = 0; i < 2; i++) { + if (!p) break; + q = strstr(p, G_BEGIN_CACHESIM); + if (q && nextresult && (q > nextresult)) { + p = q; + printf(DBG"[%ld] cache/sim beyond next\n", numres); + p = nextresult; /* reset */ + } else if (q && (!nextresult || (q < nextresult))) { + int iscache; + p = q; + p+= strlen(G_BEGIN_CACHESIM); + //printf(DBG"[%ld] found token 6\n", numres); + item = p; + p = strstr(p, G_END_CACHESIM); + if (!p) break; + p+= strlen(G_END_CACHESIM); + //printf(DBG"[%ld] found token 7\n", numres); + itemlen = p - item - strlen(G_END_CACHESIM); + itemlen = MIN(GR_MAX_URL-1, itemlen); + if (!strncmp(p, "Cached", 6)) { + strncpy(nres->cache_url, item, itemlen); + nres->cache_url[itemlen] = '\0'; + } else if (!strncmp(p, "Similar", 7)) { + strncpy(nres->similar_url, item, itemlen); + nres->similar_url[itemlen] = '\0'; + } +// else +// break; + } + } + + numres++; + if (!prev) + res = nres; + else + prev->next = nres; + prev = nres; + nres = NULL; + } while (!done || numres < maxres); + *results = res; + return numres; +err0: + free(nres); + while (res) { + nres = res->next; + free(res); + res = nres; + } + return err; +} + +#ifdef TESTME +int main(int argc, char **argv) +{ + struct google_result *results; + struct google_result *tag1 = 0xaaaa5555, *res = NULL, *tag2 = 0x5555aaaa; + size_t len; + char *p; + int err; + + p = malloc(BUFSZ+8); + len = read(0, p+4, BUFSZ); + p[BUFSZ+4-1] = '\0'; + *(uint32 *)p = 0xa5a5a5a5; + *(uint32 *)(&p[BUFSZ+4]) = 0x5a5a5a5a; + err = google_parse_results(p+4, len, &results); + printf("error 0x%08lx\n", err); + if (err < 0) + return 1; + res = results; + while (res) { + printf("[%ld]:\nURL='%s'\nNAME='%s'\nSNIPSET='%s'\nCACHE='%s'\nSIMILAR='%s'\n\n", res->id, res->url, res->name, res->snipset, res->cache_url, res->similar_url); + res = res->next; + } + printf("before = 0x%08lx:0x%08lx, after = 0x%08lx:0x%08lx\n", 0xa5a5a5a5, *(uint32 *)p, 0x5a5a5a5a, *(uint32 *)(&p[BUFSZ+4])); + printf("before = 0x%08lx:0x%08lx, after = 0x%08lx:0x%08lx\n", 0xaaaa5555, tag1, 0x5555aaaa, tag2); + return 0; +} +#endif diff --git a/src/add-ons/kernel/file_systems/googlefs/query.c b/src/add-ons/kernel/file_systems/googlefs/query.c new file mode 100644 index 0000000000..d9b3e59abb --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/query.c @@ -0,0 +1,181 @@ +#include "query.h" + +//#define TESTME + +#ifdef _KERNEL_MODE +#define printf dprintf +#undef TESTME +#endif + +#ifdef TESTME +#include <stdio.h> +#endif +// ('foo'<>"bar\"")&&!(()||()) + +void free_query_tree(query_exp *tree) +{ + if (!tree) + return; + if (tree->op >= B_AND) { + free_query_tree(tree->lv.exp); + free_query_tree(tree->rv.exp); + } + free(tree->lv.str); + free(tree->rv.str); + free(tree); +} + +char *query_unescape_string(const char *q, const char **newq, char delim) +{ + int backslash = 0; + int i; + char *p, *p2; + p = malloc(10); + if (!p) + return NULL; + for (i = 0; *q; i++) { + if ((i % 10) == 9) { + p2 = realloc(p, i+10); + if (!p2) { + free(p); + return NULL;//p; + } + p = p2; + } + if (backslash) { + backslash = 0; + p[i] = *q; + } else if (*q == '\\') { + backslash = 1; + i--; + } else if (*q == '\0') { + break; + } else if (*q == delim) { + break; + } else { + p[i] = *q; + } + q++; + } + p[i] = '\0'; + if (newq) + *newq = q; + if (i) + return p; + free(p); + return NULL; +} + +char *query_strip_bracketed_Cc(char *str) +{ + char *p = str; + char c, C; + while (*p) { + if (*p == '[') { + if (p[1] && p[2] && p[3] == ']') { + c = p[1]; + C = p[2]; + //printf("cC = %c%c\n", c, C); + if (C >= 'a' && C <= 'z' && (c == C + 'A' - 'a')) + *p = C; + else if (c >= 'a' && c <= 'z' && (C == c + 'A' - 'a')) + *p = c; + if (*p != '[') { + strcpy(p+1, p + 4); + } + } + } + p++; + } + return str; +} + +enum pqs_state { + QS_UNKNOWN, + QS_PAREN, + QS_QTR, + QS_ +}; + +static const char *parse_qs_r(const char *query, query_exp *tree) +{ + int parens = 0; + return NULL; +} + +status_t query_parse(const char *query, query_exp **tree) +{ + query_exp *t; + + return B_OK; +} + +#ifdef TESTME + +const char *strqop(query_op op) +{ + switch (op) { +#define QOP(_op) case _op: return #_op + QOP(B_INVALID_OP); + QOP(B_EQ); + QOP(B_GT); + QOP(B_GE); + QOP(B_LT); + QOP(B_LE); + QOP(B_NE); + QOP(B_CONTAINS); + QOP(B_BEGINS_WITH); + QOP(B_ENDS_WITH); + QOP(B_AND); + QOP(B_OR); + QOP(B_NOT); +#undef QOP + default: return "B_?_OP"; + } +} + +#define INDC '#' + +void dump_query_tree(query_exp *tree, int indent) +{ + int i; + if (!tree) + return; + if (tree->op >= B_AND) { + for (i=0;i<indent;i++) printf("%c", INDC); + printf(": %s {\n", strqop(tree->op)); + dump_query_tree(tree->lv.exp, indent+1); + dump_query_tree(tree->rv.exp, indent+1); + for (i=0;i<indent;i++) printf("%c", INDC); + printf("}\n"); + } else { + for (i=0;i<indent;i++) printf("%c", INDC); + printf(": {%s} %s {%s}\n", tree->lv.str, strqop(tree->op), tree->rv.str); + } +} + +int main(int argc, char **argv) +{ + status_t err; + query_exp *tree; + char *p; + if (argc < 2) + return 1; +/* + err = query_parse(argv[1], &tree); + if (err) { + printf("parse_query_string: %s\n", strerror(err)); + return 1; + } + dump_query_tree(tree, 0); +*/ + if (!strncmp(argv[1], "((name==\"*", 10)) { + argv[1] += 10; + } + p = query_unescape_string(argv[1], NULL, '"'); + printf("'%s'\n", p); + query_strip_bracketed_Cc(p); + printf("'%s'\n", p); + return 0; +} +#endif diff --git a/src/add-ons/kernel/file_systems/googlefs/query.h b/src/add-ons/kernel/file_systems/googlefs/query.h new file mode 100644 index 0000000000..62e66beb70 --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/query.h @@ -0,0 +1,57 @@ +#ifndef _K_QUERY_H +#define _K_QUERY_H + +#include <OS.h> + +#ifndef _QUERY_H +/* already defined in Query.h */ +typedef enum { + B_INVALID_OP = 0, + B_EQ, + B_GT, + B_GE, + B_LT, + B_LE, + B_NE, + B_CONTAINS, + B_BEGINS_WITH, + B_ENDS_WITH, + B_AND = 0x101, + B_OR, + B_NOT, + _B_RESERVED_OP_ = 0x100000 +} query_op; +#endif + +struct query_exp; + +struct query_term { + struct query_exp *exp; + char *str; +/* uint32 type; + union { + int32 int32v; + uint32 uint32v; + int64 int64v; + uint64 uint64v; + bigtime_t bigtimev; + char *strv; + } val; +*/ +}; + +typedef struct query_exp { + query_op op; + struct query_term lv; + struct query_term rv; +} query_exp; + +/* this one dups the string */ +extern char *query_unescape_string(const char *q, const char **newq, char delim); + +/* this oen is in-place */ +extern char *query_strip_bracketed_Cc(char *str); + +extern status_t query_parse(const char *query, query_exp **tree); + +#endif /* _K_QUERY_H */ diff --git a/src/add-ons/kernel/file_systems/googlefs/ringbuff.c b/src/add-ons/kernel/file_systems/googlefs/ringbuff.c new file mode 100644 index 0000000000..a7c842dc02 --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/ringbuff.c @@ -0,0 +1,133 @@ +/* + * ring buffer funcs + * (c) 2003, François Revol, revol@free.fr + */ + +#define _BUILDING_fs 1 + +//#define TEST_RB + +#include <sys/param.h> +#ifndef TEST_RB +//#include "lock.h" +#include "googlefs.h" +#endif + +#ifdef TEST_RB +#include <OS.h> +struct ring_buffer { + size_t size; + size_t current; /* index of next byte to read */ + size_t avail; /* number of bytes in */ + unsigned char data[0]; +}; +#define ASSERT(op) if (!(op)) debugger("ASSERT: " #op " in " __FILE__ ":" __FUNCTION__) +#else +#define ASSERT(op) if (!(op)) panic("ASSERT: %s in %s:%s", #op, __FILE__, __FUNCTION__) +#endif + +void rb_init(struct ring_buffer *rb, size_t size) +{ + rb->size = size; + rb->current = 0; + rb->avail = 0; +} + +void rb_clear(struct ring_buffer *rb) +{ + rb->avail = 0; + rb->current = 0; +} + +size_t rb_can_write(struct ring_buffer *rb) +{ + if (!rb) + return 0; + return (rb->size - rb->avail); +} + +size_t rb_can_read(struct ring_buffer *rb) +{ + if (!rb) + return 0; + return rb->avail; +} + +size_t rb_write(struct ring_buffer *rb, void *data, size_t len) +{ + size_t index, towrite, written; + if (!rb) + return 0; + index = (rb->current + rb->avail) % rb->size; + towrite = rb_can_write(rb); + towrite = MIN(len, towrite); + if (towrite < 1) + return 0; + len = rb->size - index; + len = MIN(len, towrite); + memcpy(((char *)rb->data)+index, data, len); + rb->avail += len; + written = len; + if (len < towrite) { + towrite -= len; + len = MIN(towrite, rb_can_write(rb)); + index = 0; + memcpy(((char *)rb->data)+index, ((char *)data)+written, len); + rb->avail += len; + written += len; + } + ASSERT(rb->avail <= rb->size); + return written; +} + +size_t rb_read(struct ring_buffer *rb, void *data, size_t len) +{ + size_t index, toread, got; + if (!rb) + return 0; + index = rb->current; + toread = rb_can_read(rb); + toread = MIN(len, toread); + if (toread < 1) + return 0; + len = rb->size - index; + len = MIN(len, toread); + memcpy(data, ((char *)rb->data)+index, len); + rb->avail -= len; + rb->current += len; + got = len; + if (len < toread) { + toread -= len; + len = MIN(toread, rb_can_read(rb)); + index = 0; + memcpy(((char *)data)+got, ((char *)rb->data)+index, len); + rb->current = len; + rb->avail -= len; + got += len; + } + ASSERT(rb->avail <= rb->size); + return got; +} + +#ifdef TEST_RB +int main(void) +{ + struct _myrb { + struct ring_buffer rb; + char buff[10]; + } myrb; + char buffer[10]; + char obuffer[10]; + int got, tow; + rb_init(&myrb.rb, 10); + while ((got = read(0, buffer, 10))) { + int len, olen; + len = rb_write(&myrb.rb, buffer, got); + olen = rb_read(&myrb.rb, obuffer, 10); + write(1, obuffer, olen); + } + return 1; +} +#endif + + diff --git a/src/add-ons/kernel/file_systems/googlefs/ringbuff.h b/src/add-ons/kernel/file_systems/googlefs/ringbuff.h new file mode 100644 index 0000000000..ded25885bf --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/ringbuff.h @@ -0,0 +1,18 @@ +#ifndef _RINGBUFF_H +#define _RINGBUFF_H + +struct ring_buffer { + size_t size; + size_t current; /* index of next byte to read */ + size_t avail; /* number of bytes in */ + unsigned char data[0]; +}; + +void rb_init(struct ring_buffer *rb, size_t size); +void rb_clear(struct ring_buffer *rb); +size_t rb_can_write(struct ring_buffer *rb); +size_t rb_can_read(struct ring_buffer *rb); +size_t rb_write(struct ring_buffer *rb, void *data, size_t len); +size_t rb_read(struct ring_buffer *rb, void *data, size_t len); + +#endif diff --git a/src/add-ons/kernel/file_systems/googlefs/settings.c b/src/add-ons/kernel/file_systems/googlefs/settings.c new file mode 100644 index 0000000000..4b7436a935 --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/settings.c @@ -0,0 +1,50 @@ +#include <stdlib.h> +#include <driver_settings.h> +#include "settings.h" + +#define DEFAULT_GOOGLE_SERVER "66.102.11.99" +#define DEFAULT_MAX_VNODES 5000 +char google_server[20] = DEFAULT_GOOGLE_SERVER; +int google_server_port = 80; +uint32 max_vnodes = DEFAULT_MAX_VNODES; +uint32 max_results = 50; +bool sync_unlink_queries = false; + +status_t load_settings(void) +{ + void *handle; + char *val; + handle = load_driver_settings("googlefs"); + if (!handle) + return ENOENT; + + dprintf("googlefs: loaded settings\n"); + + val = get_driver_parameter(handle, "server", \ + DEFAULT_GOOGLE_SERVER, DEFAULT_GOOGLE_SERVER); + strncpy(google_server, val, 20); + google_server[20-1] = '\0'; + + val = get_driver_parameter(handle, "port", "80", "80"); + google_server_port = strtoul(val, NULL, 10); + + val = get_driver_parameter(handle, "max_nodes", "5000", "5000"); + max_vnodes = strtoul(val, NULL, 10); + max_vnodes = MIN(max_vnodes, 1000000); + max_vnodes = MAX(max_vnodes, 10); + + val = get_driver_parameter(handle, "max_results", "50", "50"); + max_results = strtoul(val, NULL, 10); + max_results = MIN(max_results, 1000); + max_results = MAX(max_results, 5); + + sync_unlink_queries = get_driver_boolean_parameter(handle, "sync_unlink", false, true); + + dprintf("googlefs: settings: server = %s\n", google_server); + dprintf("googlefs: settings: max_nodes = %lu\n", max_vnodes); + dprintf("googlefs: settings: max_results = %lu\n", max_results); + dprintf("googlefs: settings: sync_unlink = %c\n", sync_unlink_queries?'t':'f'); + unload_driver_settings(handle); + return B_OK; +} + diff --git a/src/add-ons/kernel/file_systems/googlefs/settings.h b/src/add-ons/kernel/file_systems/googlefs/settings.h new file mode 100644 index 0000000000..14a758ae2b --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/settings.h @@ -0,0 +1,13 @@ +#ifndef _SETTINGS_H +#define _SETTINGS_H + +/* settings */ +extern char google_server[20]; +extern int google_server_port; +extern uint32 max_vnodes; +extern uint32 max_results; +extern bool sync_unlink_queries; + +extern status_t load_settings(void); + +#endif /* _SETTINGS_H */ diff --git a/src/add-ons/kernel/file_systems/googlefs/string_utils.c b/src/add-ons/kernel/file_systems/googlefs/string_utils.c new file mode 100644 index 0000000000..f44ef408fc --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/string_utils.c @@ -0,0 +1,153 @@ +#include <malloc.h> +#include <string.h> +#include "string_utils.h" + +//#define TESTME + +#ifdef _KERNEL_MODE +#define printf dprintf +#undef TESTME +#endif + + + +char *urlify_string(const char *str) +{ + char *dst, *d; + const char *p; + const char *allowed = "abcdefghijklmnopqrstuvwxyz" \ + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \ + "0123456789" \ + "-_.!~*'()"; /* cf. RFC 2396 */ + const char *hex = "0123456789ABCDEF"; + if (!str) + return NULL; + // hacky, but safe + dst = malloc(strlen(str)*3); + if (!dst) + return NULL; + for (p = str, d = dst; *p; p++) { + if (strchr(allowed, *p)) + *d++ = *p; + else if (*p == ' ') { + *d++ = '+'; + } else { + /* use hex value */ + *d++ = '%'; + *d++ = hex[(*(unsigned char *)p >> 4) & 0x0F]; + *d++ = hex[(*(unsigned char *)p) & 0x0F]; + } + } + *d = '\0'; + return dst; +} + +// cf. http://www.htmlhelp.com/reference/html40/entities/ + +static const char *entities_tab[][2] = { +{ "lt", "<" }, +{ "gt", ">" }, +{ "amp", "&" }, +{ "nbsp", " " }, +{ "quot", "\"" }, +{ "raquo", "»" }, +//{ "laquo", "" }, +{ "ccedil", "ç" }, +// grave +{ "agrave", "à" }, +{ "egrave", "è" }, +// acute +//{ "aacute", "" }, +{ "eacute", "é" }, +// circ +{ "acirc", "â" }, +{ "ecirc", "ê" }, +{ "icirc", "î" }, +{ "ocirc", "ô" }, +{ "ucirc", "û" }, +{ "copy", "©" }, +{ "trade", "â„¢" }, +//{ "", "" }, +{ NULL, NULL }, +}; + +char *unentitify_string(const char *str) +{ + char *dst, *d; + const char *p; + const char *hex = "0123456789abcdef"; + int i; + if (!str) + return NULL; + // hacky, but safe + dst = malloc(strlen(str)+2); + if (!dst) + return NULL; + for (p = str, d = dst; *p; p++) { + if (*p != '&') + *d++ = *p; + /* those case convert to binary, but won't check for valid multibyte UTF-8 sequences */ + else if ((p[1] == '#') && p[2] && p[3] && (p[4] == ';') && + isdigit(p[2]) && + isdigit(p[3])) { + /* &#nn; */ + char c = ((p[2]) - '0') * 10 + + ((p[3]) - '0'); + *d++ = c; + p += 4; + } else if ((p[1] == '#') && p[2] && p[3] && p[4] && (p[5] == ';') && + isdigit(p[2]) && + isdigit(p[3]) && + isdigit(p[4])) { + /* &#nnn; */ + char c = ((p[2]) - '0') * 100 + + ((p[3]) - '0') * 10 + + ((p[4]) - '0'); + *d++ = c; + p += 5; + } else if ((p[1] == '#') && (p[2] == 'x') && p[3] && p[4] && (p[5] == ';') && + strchr(hex, tolower(p[3])) && + strchr(hex, tolower(p[4]))) { + /* &#xnn; */ + char c = (strchr(hex, tolower(p[3])) - hex) << 4 | + (strchr(hex, tolower(p[4])) - hex); + *d++ = c; + p += 5; + } else { + char buf[20]; + strncpy(buf, p+1, 20); + buf[19] = '\0'; + if (!strchr(buf, ';')) { + *d++ = *p; + continue; + } + *(strchr(buf, ';')) = '\0'; + for (i = 0; entities_tab[i][0]; i++) { + if (!strcmp(buf, entities_tab[i][0])) { + strcpy(d, entities_tab[i][1]); + d += strlen(d); + p += strlen(entities_tab[i][0]) + 1; + break; + } + } + if (!entities_tab[i][0]) /* not found */ + *d++ = '&'; + } + } + *d = '\0'; + return dst; +} + +#ifdef TESTME +int main(int argc, char **argv) +{ + char *p; + if (argc < 2) + return 1; + p = unentitify_string(argv[1]); + printf("'%s'\n", p); + free(p); + free(malloc(10)); + return 0; +} +#endif diff --git a/src/add-ons/kernel/file_systems/googlefs/string_utils.h b/src/add-ons/kernel/file_systems/googlefs/string_utils.h new file mode 100644 index 0000000000..9d54f2d246 --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/string_utils.h @@ -0,0 +1,16 @@ +#ifndef _STRING_UTILS_H +#define _STRING_UTILS_H + +/* converts a string to a format suitable for use in urls + * ex: "foo bar+" -> "foo+bar%2D" + * caller must free() result + */ +extern char *urlify_string(const char *str); + +/* converts string with html entities to regular utf-8 string + * ex: "François" -> "François" + * caller must free() result + */ +extern char *unentitify_string(const char *str); + +#endif /* _STRING_UTILS_H */ diff --git a/src/add-ons/kernel/file_systems/googlefs/vnidpool.c b/src/add-ons/kernel/file_systems/googlefs/vnidpool.c new file mode 100644 index 0000000000..e7e9027a83 --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/vnidpool.c @@ -0,0 +1,96 @@ +#include <malloc.h> +#include "vnidpool.h" + +/* primary type for the bitmap */ +#define BMT uint32 + +#define BM_BYTE(p, vnid) (p->bitmap[(vnid % p->bmsize) / sizeof(BMT)]) +#define BM_ISSET(p, vnid) (BM_BYTE(p, vnid) & (1 << (p->nextvnid % sizeof(BMT)))) +#define BM_SET(p, vnid) (BM_BYTE(p, vnid) |= (1 << (p->nextvnid % sizeof(BMT)))) +#define BM_UNSET(p, vnid) (BM_BYTE(p, vnid) &= ~(1 << (p->nextvnid % sizeof(BMT)))) + +status_t vnidpool_alloc(struct vnidpool **pool, size_t size) +{ + struct vnidpool *p; + if (size < 2) + return EINVAL; + if (!pool) + return EINVAL; + size = (size + sizeof(BMT) - 1) / sizeof(BMT); + size *= sizeof(BMT); + p = malloc(sizeof(struct vnidpool) + size / sizeof(BMT)); + if (!p) + return B_NO_MEMORY; + if (new_lock(&p->lock, "vnidpool lock") < B_OK) { + free(p); + return B_NO_MEMORY; + } + p->nextvnid = 1LL; + p->bitmap = (BMT *)(p + 1); + p->bmsize = size; + memset(p->bitmap, 0, size / sizeof(BMT)); + dprintf("vnidpool_alloc: pool @ %p, bitmap @ %p, size %d\n", p, p->bitmap, p->bmsize); + *pool = p; + return B_OK; +} + +status_t vnidpool_free(struct vnidpool *pool) { + int i; + dprintf("vnidpool_free: pool @ %p\n", pool); + if (!pool) + return EINVAL; + if (LOCK(&pool->lock) < B_OK) + return B_ERROR; + /* make sure no vnid is left in use */ + for (i = 0; i < (pool->bmsize % sizeof(BMT)); i++) { + if (pool->bitmap[i]) + dprintf("WARNING: vnidpool_free called with vnids still in use!!!\n"); + //panic("vnidpool_free: vnids still in use"); + } + free_lock(&pool->lock); + free(pool); + return B_OK; +} + +status_t vnidpool_get(struct vnidpool *pool, vnode_id *vnid) +{ + status_t err = B_ERROR; + uint32 i; + if (!pool) + return EINVAL; + if (LOCK(&pool->lock) < B_OK) + return B_ERROR; + for (i = 0; BM_ISSET(pool, pool->nextvnid) && i < pool->bmsize; pool->nextvnid++, i++) { + /* avoid 0 as vnid */ + if (!pool->nextvnid) + continue; + } + if (BM_ISSET(pool, pool->nextvnid)) + err = ENOBUFS; + else { + BM_SET(pool, pool->nextvnid); + *vnid = pool->nextvnid++; + err = B_OK; + } + UNLOCK(&pool->lock); + return err; +} + +status_t vnidpool_put(struct vnidpool *pool, vnode_id vnid) +{ + status_t err = B_ERROR; + uint32 i; + if (!pool) + return EINVAL; + if (LOCK(&pool->lock) < B_OK) + return B_ERROR; + if (!BM_ISSET(pool, vnid)) + err = EINVAL; + else { + BM_UNSET(pool, vnid); + err = B_OK; + } + UNLOCK(&pool->lock); + return err; +} + diff --git a/src/add-ons/kernel/file_systems/googlefs/vnidpool.h b/src/add-ons/kernel/file_systems/googlefs/vnidpool.h new file mode 100644 index 0000000000..c4c8521dd6 --- /dev/null +++ b/src/add-ons/kernel/file_systems/googlefs/vnidpool.h @@ -0,0 +1,18 @@ +#ifndef _VNIDPOOL_H +#define _VNIDPOOL_H + +#include "googlefs.h" + +typedef struct vnidpool { + lock lock; + vnode_id nextvnid; + uint32 *bitmap; + size_t bmsize; +} vnidpool; + +status_t vnidpool_alloc(struct vnidpool **pool, size_t size); +status_t vnidpool_free(struct vnidpool *pool); +status_t vnidpool_get(struct vnidpool *pool, vnode_id *vnid); +status_t vnidpool_put(struct vnidpool *pool, vnode_id vnid); + +#endif /* _VNIDPOOL_H */