1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
#define FUSE_USE_VERSION 26
#include <string.h>
#include <stdarg.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <fuse.h>
#include <tcl.h>
#define APPFS_DEBUG(x...) { fprintf(stderr, "%i:%s: ", __LINE__, __func__); fprintf(stderr, x); fprintf(stderr, "\n"); }
Tcl_Interp *interp;
typedef enum {
APPFS_OS_UNKNOWN,
|
>
>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#define FUSE_USE_VERSION 26
#include <string.h>
#include <stdarg.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <fuse.h>
#include <tcl.h>
#define APPFS_CACHEDIR "/tmp/appfs-cache"
#define APPFS_DEBUG(x...) { fprintf(stderr, "%i:%s: ", __LINE__, __func__); fprintf(stderr, x); fprintf(stderr, "\n"); }
Tcl_Interp *interp;
typedef enum {
APPFS_OS_UNKNOWN,
|
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
|
static int appfs_getfile(const char *hostname, const char *sha1) {
}
static int appfs_getmanifest(const char *hostname, const char *sha1) {
}
static int appfs_getattr(const char *path, struct stat *stbuf) {
int res = 0;
APPFS_DEBUG("Enter (path = %s, ...)", path);
memset(stbuf, 0, sizeof(struct stat));
stbuf->st_mode = S_IFDIR | 0755;
stbuf->st_nlink = 2;
return res;
}
static int appfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi) {
APPFS_DEBUG("Enter (path = %s, ...)", path);
filler(buf, ".", NULL, 0);
filler(buf, "..", NULL, 0);
return 0;
}
static int appfs_open(const char *path, struct fuse_file_info *fi) {
return(-ENOENT);
}
static int appfs_read(const char *path, char *buf, size_t size, off_t offset, struct fuse_file_info *fi) {
return(-ENOENT);
}
#ifdef APPFS_TEST_DRIVER
static int appfs_test_driver(void) {
struct appfs_package *packages;
int packages_count = 0;
packages = appfs_getindex("rkeene.org", &packages_count);
if (packages == NULL || packages_count == 0) {
fprintf(stderr, "Unable to fetch package index from rkeene.org.\n");
return(1);
}
return(0);
}
#endif
static struct fuse_operations appfs_oper = {
.getattr = appfs_getattr,
.readdir = appfs_readdir,
.open = appfs_open,
.read = appfs_read,
};
int main(int argc, char **argv) {
int tcl_ret;
interp = Tcl_CreateInterp();
if (interp == NULL) {
fprintf(stderr, "Unable to create Tcl Interpreter. Aborting.\n");
return(1);
|
|
|
|
|
|
|
|
|
>
|
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
|
static int appfs_getfile(const char *hostname, const char *sha1) {
}
static int appfs_getmanifest(const char *hostname, const char *sha1) {
}
static int appfs_fuse_getattr(const char *path, struct stat *stbuf) {
int res = 0;
APPFS_DEBUG("Enter (path = %s, ...)", path);
memset(stbuf, 0, sizeof(struct stat));
stbuf->st_mode = S_IFDIR | 0755;
stbuf->st_nlink = 2;
return res;
}
static int appfs_fuse_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi) {
APPFS_DEBUG("Enter (path = %s, ...)", path);
filler(buf, ".", NULL, 0);
filler(buf, "..", NULL, 0);
return 0;
}
static int appfs_fuse_open(const char *path, struct fuse_file_info *fi) {
return(-ENOENT);
}
static int appfs_fuse_read(const char *path, char *buf, size_t size, off_t offset, struct fuse_file_info *fi) {
return(-ENOENT);
}
#ifdef APPFS_TEST_DRIVER
static int appfs_test_driver(void) {
struct appfs_package *packages;
int packages_count = 0;
packages = appfs_getindex("rkeene.org", &packages_count);
if (packages == NULL || packages_count == 0) {
fprintf(stderr, "Unable to fetch package index from rkeene.org.\n");
return(1);
}
return(0);
}
#endif
static struct fuse_operations appfs_oper = {
.getattr = appfs_fuse_getattr,
.readdir = appfs_fuse_readdir,
.open = appfs_fuse_open,
.read = appfs_fuse_read
};
int main(int argc, char **argv) {
const char *cachedir = APPFS_CACHEDIR;
int tcl_ret;
interp = Tcl_CreateInterp();
if (interp == NULL) {
fprintf(stderr, "Unable to create Tcl Interpreter. Aborting.\n");
return(1);
|
234
235
236
237
238
239
240
241
242
243
244
245
246
247
|
}
tcl_ret = Tcl_Eval(interp, ""
#include "appfs.tcl.h"
"");
if (tcl_ret != TCL_OK) {
fprintf(stderr, "Unable to initialize Tcl AppFS script. Aborting.\n");
return(1);
}
tcl_ret = appfs_Tcl_Eval(interp, 1, "::appfs::init");
if (tcl_ret != TCL_OK) {
fprintf(stderr, "Unable to initialize Tcl AppFS script (::appfs::init). Aborting.\n");
|
>
>
>
>
>
>
>
|
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
|
}
tcl_ret = Tcl_Eval(interp, ""
#include "appfs.tcl.h"
"");
if (tcl_ret != TCL_OK) {
fprintf(stderr, "Unable to initialize Tcl AppFS script. Aborting.\n");
fprintf(stderr, "Tcl Error is: %s\n", Tcl_GetStringResult(interp));
return(1);
}
if (Tcl_SetVar(interp, "::appfs::cachedir", cachedir, TCL_GLOBAL_ONLY) == NULL) {
fprintf(stderr, "Unable to set cache directory. This should never fail.\n");
return(1);
}
tcl_ret = appfs_Tcl_Eval(interp, 1, "::appfs::init");
if (tcl_ret != TCL_OK) {
fprintf(stderr, "Unable to initialize Tcl AppFS script (::appfs::init). Aborting.\n");
|