aboutsummaryrefslogtreecommitdiff
path: root/src/ext/read.c
blob: 32c81d1c0bdfc5cefc2e3e2b042f5bf67099f67a (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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/*
 * read.c - FUSE read function
 *
 *  Created on: Mar 14, 2012
 *      Author: mg
 *

		 Read data from an open file
 *
 * Read should return exactly the number of bytes requested except
 * on EOF or error, otherwise the rest of the data will be
 * substituted with zeroes.	 An exception to this is when the
 * 'direct_io' mount option is specified, in which case the return
 * value of the read system call will reflect the return value of
 * this operation.
 *
 * Changed in version 2.2
 */

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




int gn_read(const char *path, char *buf, size_t size, off_t offset,
		struct fuse_file_info *fi)
{
	size_t len;
	if (strcmp(path, "/home/mg/gnunet-fuse5/gnunet-fuse/src/ext/mount") == 0)
	{
		len = strlen("/home/mg/gnunet-fuse5/gnunet-fuse/src/ext/mount");

		if (offset < len)
		{
			if (offset + size > len)
				size = len - offset;
				memcpy(buf, "/" + offset, size);
		}
		else
			size = 0;

	return size;
	}




}








































/*
 *
 *

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";




size_t len;
	    (void) fi;


	    if (strcmp(path, archive_path) == 0)
	      {
		len = strlen(archive_str);
		if (offset < len)
		  {
		  if (offset + size > len)
	            size = len - offset;
		  memcpy(buf, archive_str + offset, size);
		}
		else
		  size = 0;

		return size;
	      }


	    else if(strcmp(path, britney_path) == 0)
	      {
		len = strlen(britney_str);
		if (offset < len) {
		  if (offset + size > len)
		    size = len - offset;
		  memcpy(buf, britney_str + offset, size);
		}
		else
		  size = 0;

		return size;
	      }

		else if(strcmp(path, britney_br_path) == 0) // ab hier das verzeichnis britney spears
		{
		len = strlen(britney_br_str);
		if (offset < len) {
			if (offset + size > len)
			    size = len - offset;
			  memcpy(buf, britney_br_str + offset, size);
			}
			else
			  size = 0;

			return size;
		      }

	    else if(strcmp(path, b_br_1_path) == 0) // ab hier album Britney-Lied1
	      {
		len = strlen(b_br_1_str);
		if (offset < len)
		  {
		  if (offset + size > len)
		    size = len - offset;
		  memcpy(buf, b_br_1_str + offset, size);
		}
		else
		  size = 0;

		return size;
	      }
	    else return -ENOENT;

*/