aboutsummaryrefslogtreecommitdiff
path: root/src/ext/getattr.c
blob: b6e0341a5653c253c63025baa8a4bbfbbb69fa9a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/*
 * getattr.c - FUSE getattr function
 *
 *  Created on: Mar 14, 2012
 *      Author: mg
 *
 *
 *	 Get file attributes.
 *
 * Similar to stat().  The 'st_dev' and 'st_blksize' fields are
 * ignored.	 The 'st_ino' field is ignored except if the 'use_ino'
 * mount option is given.
 */

#include <sys/stat.h>
//#include <string.h>
//#include <errno.h>
#include <fuse.h>
#include <gnunet-fuse.h>

int gn_getattr(const char *path, struct stat *stbuf)
{
	int ret = 0;
	//GNUNET_break (0);
	memset(stbuf, 0, sizeof(struct stat));

	if(strcmp(path, "/home/mg/gnunet-fuse5/gnunet-fuse/src/ext/mount") == 0)
	{
	stbuf->st_mode = S_IFDIR | 0755;
	stbuf->st_nlink = 1; // changed from 2
	}


	/*
	else if(strcmp(path, directory) == 0)
	{
		stbuf->st_mode = S_IFDIR | 0755;
		stbuf->st_nlink = 1;
	}



	else if(strcmp(path, "/probe/mal") == 0)
	{
		stbuf->st_mode = S_IFREG | 0444;
				stbuf->st_nlink = 1;
				stbuf->st_size = strlen("/probe/mal/inhalt");
	}

	*/

	else return -ENOENT;

	return ret;




}


































/*
static const char *archive_path = "/";
static const char *archive_str = "/Archive\n";

static const char *britney_path = "/Britney Spears";
static const char *britney_str = "Britney Spears\n";

static const char *britney_br_path = "/Britney Spears/Britney";
static const char *britney_br_str = "Britney\n";

static const char *b_br_1_path = "/Britney Spears/Britney/I'm a Slave 4 U";
	static const char *b_br_1_str = "3:23 U\n";


int gn_getattr(const char *path, struct stat *stbuf)
{

int res = 0;

	memset(stbuf, 0, sizeof(struct stat));

	if(strcmp(path, "/") == 0) {	//attr. fuer  parent vz
		stbuf->st_mode = S_IFDIR | 0755;
		stbuf->st_nlink = 3;
		}

	else if(strcmp(path, britney_path) == 0) { //attr. fuer unterverzeichnis Britney
	        stbuf->st_mode = S_IFDIR | 0755;
	        stbuf->st_nlink = 3;
	    }

	else if(strcmp(path, britney_br_path) == 0) {  //Attribute fuer UnterUnterverzeichnis Britney
        stbuf->st_mode = S_IFDIR | 0755;
	    stbuf->st_nlink = 1;

	    }
	 else if(strcmp(path, b_br_1_path) == 0 ){  //Songnummer 1
	     stbuf->st_mode = S_IFREG | 0444;
	     stbuf->st_nlink = 1;
	     stbuf->st_size = strlen(b_br_1_str);
	     }

	else res = -ENOENT;

	return res;
}

*/