diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-06-06 11:45:03 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-06-06 11:45:03 +0000 |
commit | 1ba3d12a23b3715e813ca26c418f5942a73399ab (patch) | |
tree | f7edd81d1a36701b9f0c320d2718fcc66fadac9f | |
parent | 71eacc6a3ee0003df1485d15c44e9b7306105d48 (diff) | |
download | gnunet-fuse-1ba3d12a23b3715e813ca26c418f5942a73399ab.tar.gz gnunet-fuse-1ba3d12a23b3715e813ca26c418f5942a73399ab.zip |
-removing old 0.8 code
27 files changed, 0 insertions, 3145 deletions
diff --git a/gnunet-fuse-0.8/AUTHORS b/gnunet-fuse-0.8/AUTHORS deleted file mode 100644 index 5b093b5..0000000 --- a/gnunet-fuse-0.8/AUTHORS +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | David Barksdale <amatus@gnu.org> | ||
diff --git a/gnunet-fuse-0.8/COPYING b/gnunet-fuse-0.8/COPYING deleted file mode 100644 index 623b625..0000000 --- a/gnunet-fuse-0.8/COPYING +++ /dev/null | |||
@@ -1,340 +0,0 @@ | |||
1 | GNU GENERAL PUBLIC LICENSE | ||
2 | Version 2, June 1991 | ||
3 | |||
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc. | ||
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
6 | Everyone is permitted to copy and distribute verbatim copies | ||
7 | of this license document, but changing it is not allowed. | ||
8 | |||
9 | Preamble | ||
10 | |||
11 | The licenses for most software are designed to take away your | ||
12 | freedom to share and change it. By contrast, the GNU General Public | ||
13 | License is intended to guarantee your freedom to share and change free | ||
14 | software--to make sure the software is free for all its users. This | ||
15 | General Public License applies to most of the Free Software | ||
16 | Foundation's software and to any other program whose authors commit to | ||
17 | using it. (Some other Free Software Foundation software is covered by | ||
18 | the GNU Library General Public License instead.) You can apply it to | ||
19 | your programs, too. | ||
20 | |||
21 | When we speak of free software, we are referring to freedom, not | ||
22 | price. Our General Public Licenses are designed to make sure that you | ||
23 | have the freedom to distribute copies of free software (and charge for | ||
24 | this service if you wish), that you receive source code or can get it | ||
25 | if you want it, that you can change the software or use pieces of it | ||
26 | in new free programs; and that you know you can do these things. | ||
27 | |||
28 | To protect your rights, we need to make restrictions that forbid | ||
29 | anyone to deny you these rights or to ask you to surrender the rights. | ||
30 | These restrictions translate to certain responsibilities for you if you | ||
31 | distribute copies of the software, or if you modify it. | ||
32 | |||
33 | For example, if you distribute copies of such a program, whether | ||
34 | gratis or for a fee, you must give the recipients all the rights that | ||
35 | you have. You must make sure that they, too, receive or can get the | ||
36 | source code. And you must show them these terms so they know their | ||
37 | rights. | ||
38 | |||
39 | We protect your rights with two steps: (1) copyright the software, and | ||
40 | (2) offer you this license which gives you legal permission to copy, | ||
41 | distribute and/or modify the software. | ||
42 | |||
43 | Also, for each author's protection and ours, we want to make certain | ||
44 | that everyone understands that there is no warranty for this free | ||
45 | software. If the software is modified by someone else and passed on, we | ||
46 | want its recipients to know that what they have is not the original, so | ||
47 | that any problems introduced by others will not reflect on the original | ||
48 | authors' reputations. | ||
49 | |||
50 | Finally, any free program is threatened constantly by software | ||
51 | patents. We wish to avoid the danger that redistributors of a free | ||
52 | program will individually obtain patent licenses, in effect making the | ||
53 | program proprietary. To prevent this, we have made it clear that any | ||
54 | patent must be licensed for everyone's free use or not licensed at all. | ||
55 | |||
56 | The precise terms and conditions for copying, distribution and | ||
57 | modification follow. | ||
58 | |||
59 | GNU GENERAL PUBLIC LICENSE | ||
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | ||
61 | |||
62 | 0. This License applies to any program or other work which contains | ||
63 | a notice placed by the copyright holder saying it may be distributed | ||
64 | under the terms of this General Public License. The "Program", below, | ||
65 | refers to any such program or work, and a "work based on the Program" | ||
66 | means either the Program or any derivative work under copyright law: | ||
67 | that is to say, a work containing the Program or a portion of it, | ||
68 | either verbatim or with modifications and/or translated into another | ||
69 | language. (Hereinafter, translation is included without limitation in | ||
70 | the term "modification".) Each licensee is addressed as "you". | ||
71 | |||
72 | Activities other than copying, distribution and modification are not | ||
73 | covered by this License; they are outside its scope. The act of | ||
74 | running the Program is not restricted, and the output from the Program | ||
75 | is covered only if its contents constitute a work based on the | ||
76 | Program (independent of having been made by running the Program). | ||
77 | Whether that is true depends on what the Program does. | ||
78 | |||
79 | 1. You may copy and distribute verbatim copies of the Program's | ||
80 | source code as you receive it, in any medium, provided that you | ||
81 | conspicuously and appropriately publish on each copy an appropriate | ||
82 | copyright notice and disclaimer of warranty; keep intact all the | ||
83 | notices that refer to this License and to the absence of any warranty; | ||
84 | and give any other recipients of the Program a copy of this License | ||
85 | along with the Program. | ||
86 | |||
87 | You may charge a fee for the physical act of transferring a copy, and | ||
88 | you may at your option offer warranty protection in exchange for a fee. | ||
89 | |||
90 | 2. You may modify your copy or copies of the Program or any portion | ||
91 | of it, thus forming a work based on the Program, and copy and | ||
92 | distribute such modifications or work under the terms of Section 1 | ||
93 | above, provided that you also meet all of these conditions: | ||
94 | |||
95 | a) You must cause the modified files to carry prominent notices | ||
96 | stating that you changed the files and the date of any change. | ||
97 | |||
98 | b) You must cause any work that you distribute or publish, that in | ||
99 | whole or in part contains or is derived from the Program or any | ||
100 | part thereof, to be licensed as a whole at no charge to all third | ||
101 | parties under the terms of this License. | ||
102 | |||
103 | c) If the modified program normally reads commands interactively | ||
104 | when run, you must cause it, when started running for such | ||
105 | interactive use in the most ordinary way, to print or display an | ||
106 | announcement including an appropriate copyright notice and a | ||
107 | notice that there is no warranty (or else, saying that you provide | ||
108 | a warranty) and that users may redistribute the program under | ||
109 | these conditions, and telling the user how to view a copy of this | ||
110 | License. (Exception: if the Program itself is interactive but | ||
111 | does not normally print such an announcement, your work based on | ||
112 | the Program is not required to print an announcement.) | ||
113 | |||
114 | These requirements apply to the modified work as a whole. If | ||
115 | identifiable sections of that work are not derived from the Program, | ||
116 | and can be reasonably considered independent and separate works in | ||
117 | themselves, then this License, and its terms, do not apply to those | ||
118 | sections when you distribute them as separate works. But when you | ||
119 | distribute the same sections as part of a whole which is a work based | ||
120 | on the Program, the distribution of the whole must be on the terms of | ||
121 | this License, whose permissions for other licensees extend to the | ||
122 | entire whole, and thus to each and every part regardless of who wrote it. | ||
123 | |||
124 | Thus, it is not the intent of this section to claim rights or contest | ||
125 | your rights to work written entirely by you; rather, the intent is to | ||
126 | exercise the right to control the distribution of derivative or | ||
127 | collective works based on the Program. | ||
128 | |||
129 | In addition, mere aggregation of another work not based on the Program | ||
130 | with the Program (or with a work based on the Program) on a volume of | ||
131 | a storage or distribution medium does not bring the other work under | ||
132 | the scope of this License. | ||
133 | |||
134 | 3. You may copy and distribute the Program (or a work based on it, | ||
135 | under Section 2) in object code or executable form under the terms of | ||
136 | Sections 1 and 2 above provided that you also do one of the following: | ||
137 | |||
138 | a) Accompany it with the complete corresponding machine-readable | ||
139 | source code, which must be distributed under the terms of Sections | ||
140 | 1 and 2 above on a medium customarily used for software interchange; or, | ||
141 | |||
142 | b) Accompany it with a written offer, valid for at least three | ||
143 | years, to give any third party, for a charge no more than your | ||
144 | cost of physically performing source distribution, a complete | ||
145 | machine-readable copy of the corresponding source code, to be | ||
146 | distributed under the terms of Sections 1 and 2 above on a medium | ||
147 | customarily used for software interchange; or, | ||
148 | |||
149 | c) Accompany it with the information you received as to the offer | ||
150 | to distribute corresponding source code. (This alternative is | ||
151 | allowed only for noncommercial distribution and only if you | ||
152 | received the program in object code or executable form with such | ||
153 | an offer, in accord with Subsection b above.) | ||
154 | |||
155 | The source code for a work means the preferred form of the work for | ||
156 | making modifications to it. For an executable work, complete source | ||
157 | code means all the source code for all modules it contains, plus any | ||
158 | associated interface definition files, plus the scripts used to | ||
159 | control compilation and installation of the executable. However, as a | ||
160 | special exception, the source code distributed need not include | ||
161 | anything that is normally distributed (in either source or binary | ||
162 | form) with the major components (compiler, kernel, and so on) of the | ||
163 | operating system on which the executable runs, unless that component | ||
164 | itself accompanies the executable. | ||
165 | |||
166 | If distribution of executable or object code is made by offering | ||
167 | access to copy from a designated place, then offering equivalent | ||
168 | access to copy the source code from the same place counts as | ||
169 | distribution of the source code, even though third parties are not | ||
170 | compelled to copy the source along with the object code. | ||
171 | |||
172 | 4. You may not copy, modify, sublicense, or distribute the Program | ||
173 | except as expressly provided under this License. Any attempt | ||
174 | otherwise to copy, modify, sublicense or distribute the Program is | ||
175 | void, and will automatically terminate your rights under this License. | ||
176 | However, parties who have received copies, or rights, from you under | ||
177 | this License will not have their licenses terminated so long as such | ||
178 | parties remain in full compliance. | ||
179 | |||
180 | 5. You are not required to accept this License, since you have not | ||
181 | signed it. However, nothing else grants you permission to modify or | ||
182 | distribute the Program or its derivative works. These actions are | ||
183 | prohibited by law if you do not accept this License. Therefore, by | ||
184 | modifying or distributing the Program (or any work based on the | ||
185 | Program), you indicate your acceptance of this License to do so, and | ||
186 | all its terms and conditions for copying, distributing or modifying | ||
187 | the Program or works based on it. | ||
188 | |||
189 | 6. Each time you redistribute the Program (or any work based on the | ||
190 | Program), the recipient automatically receives a license from the | ||
191 | original licensor to copy, distribute or modify the Program subject to | ||
192 | these terms and conditions. You may not impose any further | ||
193 | restrictions on the recipients' exercise of the rights granted herein. | ||
194 | You are not responsible for enforcing compliance by third parties to | ||
195 | this License. | ||
196 | |||
197 | 7. If, as a consequence of a court judgment or allegation of patent | ||
198 | infringement or for any other reason (not limited to patent issues), | ||
199 | conditions are imposed on you (whether by court order, agreement or | ||
200 | otherwise) that contradict the conditions of this License, they do not | ||
201 | excuse you from the conditions of this License. If you cannot | ||
202 | distribute so as to satisfy simultaneously your obligations under this | ||
203 | License and any other pertinent obligations, then as a consequence you | ||
204 | may not distribute the Program at all. For example, if a patent | ||
205 | license would not permit royalty-free redistribution of the Program by | ||
206 | all those who receive copies directly or indirectly through you, then | ||
207 | the only way you could satisfy both it and this License would be to | ||
208 | refrain entirely from distribution of the Program. | ||
209 | |||
210 | If any portion of this section is held invalid or unenforceable under | ||
211 | any particular circumstance, the balance of the section is intended to | ||
212 | apply and the section as a whole is intended to apply in other | ||
213 | circumstances. | ||
214 | |||
215 | It is not the purpose of this section to induce you to infringe any | ||
216 | patents or other property right claims or to contest validity of any | ||
217 | such claims; this section has the sole purpose of protecting the | ||
218 | integrity of the free software distribution system, which is | ||
219 | implemented by public license practices. Many people have made | ||
220 | generous contributions to the wide range of software distributed | ||
221 | through that system in reliance on consistent application of that | ||
222 | system; it is up to the author/donor to decide if he or she is willing | ||
223 | to distribute software through any other system and a licensee cannot | ||
224 | impose that choice. | ||
225 | |||
226 | This section is intended to make thoroughly clear what is believed to | ||
227 | be a consequence of the rest of this License. | ||
228 | |||
229 | 8. If the distribution and/or use of the Program is restricted in | ||
230 | certain countries either by patents or by copyrighted interfaces, the | ||
231 | original copyright holder who places the Program under this License | ||
232 | may add an explicit geographical distribution limitation excluding | ||
233 | those countries, so that distribution is permitted only in or among | ||
234 | countries not thus excluded. In such case, this License incorporates | ||
235 | the limitation as if written in the body of this License. | ||
236 | |||
237 | 9. The Free Software Foundation may publish revised and/or new versions | ||
238 | of the General Public License from time to time. Such new versions will | ||
239 | be similar in spirit to the present version, but may differ in detail to | ||
240 | address new problems or concerns. | ||
241 | |||
242 | Each version is given a distinguishing version number. If the Program | ||
243 | specifies a version number of this License which applies to it and "any | ||
244 | later version", you have the option of following the terms and conditions | ||
245 | either of that version or of any later version published by the Free | ||
246 | Software Foundation. If the Program does not specify a version number of | ||
247 | this License, you may choose any version ever published by the Free Software | ||
248 | Foundation. | ||
249 | |||
250 | 10. If you wish to incorporate parts of the Program into other free | ||
251 | programs whose distribution conditions are different, write to the author | ||
252 | to ask for permission. For software which is copyrighted by the Free | ||
253 | Software Foundation, write to the Free Software Foundation; we sometimes | ||
254 | make exceptions for this. Our decision will be guided by the two goals | ||
255 | of preserving the free status of all derivatives of our free software and | ||
256 | of promoting the sharing and reuse of software generally. | ||
257 | |||
258 | NO WARRANTY | ||
259 | |||
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY | ||
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN | ||
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES | ||
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED | ||
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS | ||
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE | ||
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, | ||
268 | REPAIR OR CORRECTION. | ||
269 | |||
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING | ||
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR | ||
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, | ||
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING | ||
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED | ||
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY | ||
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER | ||
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE | ||
278 | POSSIBILITY OF SUCH DAMAGES. | ||
279 | |||
280 | END OF TERMS AND CONDITIONS | ||
281 | |||
282 | How to Apply These Terms to Your New Programs | ||
283 | |||
284 | If you develop a new program, and you want it to be of the greatest | ||
285 | possible use to the public, the best way to achieve this is to make it | ||
286 | free software which everyone can redistribute and change under these terms. | ||
287 | |||
288 | To do so, attach the following notices to the program. It is safest | ||
289 | to attach them to the start of each source file to most effectively | ||
290 | convey the exclusion of warranty; and each file should have at least | ||
291 | the "copyright" line and a pointer to where the full notice is found. | ||
292 | |||
293 | <one line to give the program's name and a brief idea of what it does.> | ||
294 | Copyright (C) <year> <name of author> | ||
295 | |||
296 | This program is free software; you can redistribute it and/or modify | ||
297 | it under the terms of the GNU General Public License as published by | ||
298 | the Free Software Foundation; either version 2 of the License, or | ||
299 | (at your option) any later version. | ||
300 | |||
301 | This program is distributed in the hope that it will be useful, | ||
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
304 | GNU General Public License for more details. | ||
305 | |||
306 | You should have received a copy of the GNU General Public License | ||
307 | along with this program; if not, write to the Free Software | ||
308 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
309 | |||
310 | |||
311 | Also add information on how to contact you by electronic and paper mail. | ||
312 | |||
313 | If the program is interactive, make it output a short notice like this | ||
314 | when it starts in an interactive mode: | ||
315 | |||
316 | Gnomovision version 69, Copyright (C) year name of author | ||
317 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. | ||
318 | This is free software, and you are welcome to redistribute it | ||
319 | under certain conditions; type `show c' for details. | ||
320 | |||
321 | The hypothetical commands `show w' and `show c' should show the appropriate | ||
322 | parts of the General Public License. Of course, the commands you use may | ||
323 | be called something other than `show w' and `show c'; they could even be | ||
324 | mouse-clicks or menu items--whatever suits your program. | ||
325 | |||
326 | You should also get your employer (if you work as a programmer) or your | ||
327 | school, if any, to sign a "copyright disclaimer" for the program, if | ||
328 | necessary. Here is a sample; alter the names: | ||
329 | |||
330 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program | ||
331 | `Gnomovision' (which makes passes at compilers) written by James Hacker. | ||
332 | |||
333 | <signature of Ty Coon>, 1 April 1989 | ||
334 | Ty Coon, President of Vice | ||
335 | |||
336 | This General Public License does not permit incorporating your program into | ||
337 | proprietary programs. If your program is a subroutine library, you may | ||
338 | consider it more useful to permit linking proprietary applications with the | ||
339 | library. If this is what you want to do, use the GNU Library General | ||
340 | Public License instead of this License. | ||
diff --git a/gnunet-fuse-0.8/ChangeLog b/gnunet-fuse-0.8/ChangeLog deleted file mode 100644 index 6eaf1e3..0000000 --- a/gnunet-fuse-0.8/ChangeLog +++ /dev/null | |||
@@ -1,34 +0,0 @@ | |||
1 | 2008-06-13 Christian Grothoff <christian@grothoff.org> 0.8.0 | ||
2 | * Release version | ||
3 | 2007-12-20 Christian Grothoff <christian@grothoff.org> 0.7.3 | ||
4 | * Release version | ||
5 | 2007-07-29 David Barksdale <amatus@gnu.org> 0.7.2b | ||
6 | * Release version | ||
7 | 2007-07-26 David Barksdale <amatus@gnu.org> 0.7.2-5 | ||
8 | * Finished support for truncate | ||
9 | 2007-07-17 David Barksdale <amatus@gnu.org> 0.7.2-4 | ||
10 | * Added support for renaming files | ||
11 | 2007-07-12 David Barksdale <amatus@gnu.org> 0.7.2-3 | ||
12 | * Added support for unlinking files, creating directories, and removing | ||
13 | directories | ||
14 | 2007-07-12 David Barksdale <amatus@gnu.org> 0.7.2-2 | ||
15 | * Added support for creating and modifying files | ||
16 | 2007-06-18 David Barksdale <amatus@gnu.org> 0.7.2-1 | ||
17 | * Modified configure script to better detect compatability with GNUnet | ||
18 | 2007-06-18 David Barksdale <amatus@gnu.org> 0.7.2 | ||
19 | * Gratuitous version incrementation | ||
20 | 2007-06-12 David Barksdale <amatus@gnu.org> 0.6 | ||
21 | * Cleaned up fuse command line option passing (in a manner of speaking) | ||
22 | * Added an implicit "-o ro" so the mount shows up as read-only (for now) | ||
23 | * Added support for interrupting read operations | ||
24 | 2007-06-10 David Barksdale <amatus@gnu.org> 0.5 | ||
25 | * Added .uri.<file> files which read the uri of <file> | ||
26 | 2007-06-08 David Barksdale <amatus@gnu.org> 0.4 | ||
27 | * Added .uri files which read the uri of the containing directory | ||
28 | 2007-05-30 David Barksdale <amatus@gnu.org> 0.3 | ||
29 | * Added support for ECRS_downloadPartialFile (requires GNUnet > 0.7.1c) | ||
30 | 2007-05-29 David Barksdale <amatus@gnu.org> 0.2 | ||
31 | * Fixed ref-counting bug in gn_dirent_find | ||
32 | * Added legal stuff to source files | ||
33 | 2007-05-28 David Barksdale <amatus@gnu.org> 0.1 | ||
34 | * Initial version | ||
diff --git a/gnunet-fuse-0.8/Makefile.am b/gnunet-fuse-0.8/Makefile.am deleted file mode 100644 index 0583db3..0000000 --- a/gnunet-fuse-0.8/Makefile.am +++ /dev/null | |||
@@ -1,24 +0,0 @@ | |||
1 | bin_PROGRAMS = gnunet-fs | ||
2 | gnunet_fs_SOURCES = \ | ||
3 | directory.c \ | ||
4 | dirent.c \ | ||
5 | file.c \ | ||
6 | getattr.c \ | ||
7 | main.c \ | ||
8 | mkdir.c \ | ||
9 | mknod.c \ | ||
10 | open.c \ | ||
11 | read.c \ | ||
12 | readdir.c \ | ||
13 | release.c \ | ||
14 | rename.c \ | ||
15 | rmdir.c \ | ||
16 | special_file.c \ | ||
17 | truncate.c \ | ||
18 | unlink.c \ | ||
19 | utimens.c \ | ||
20 | write.c \ | ||
21 | gnfs.h \ | ||
22 | gettext.h | ||
23 | |||
24 | gnunet_fs_CPPFLAGS = -DFUSE_USE_VERSION=26 -D_REENTRANT | ||
diff --git a/gnunet-fuse-0.8/NEWS b/gnunet-fuse-0.8/NEWS deleted file mode 100644 index 38a7ad0..0000000 --- a/gnunet-fuse-0.8/NEWS +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | see ChangeLog | ||
diff --git a/gnunet-fuse-0.8/README b/gnunet-fuse-0.8/README deleted file mode 100644 index 0895a8c..0000000 --- a/gnunet-fuse-0.8/README +++ /dev/null | |||
@@ -1,38 +0,0 @@ | |||
1 | gnunet-fuse - FUSE filesystem for GNUnet | ||
2 | |||
3 | Summary | ||
4 | ======= | ||
5 | You need the URI of a file with the mime-type of application/gnunet-directory. | ||
6 | You can either publish a directory with gnunet-insert or do a search for the | ||
7 | mime-type. To mount the URI use the following command. | ||
8 | |||
9 | $ echo gnunet://ecrs/chk/XXXX/YYYY.NNNN > uri_file | ||
10 | $ gnunet-fs uri_file /mnt | ||
11 | |||
12 | Where gnunet://ecrs/chk/XXXX/YYYY.NNNN is the URI and /mnt is the mount point. | ||
13 | |||
14 | Usage | ||
15 | ===== | ||
16 | gnunet-fuse [OPTIONS] <URI FILE> <PATH> | ||
17 | Arguments mandatory for long options are also mandatory for short options. | ||
18 | -h, --help print this help | ||
19 | -c, --config=FILENAME use configuration file FILENAME | ||
20 | -L, --log=LOGLEVEL configure logging to use LOGLEVEL | ||
21 | -l, --logfile=FILE set logfile name | ||
22 | -a, --anonymity=LEVEL set the desired LEVEL of sender-anonymity | ||
23 | -p, --priority=LEVEL set the desired LEVEL of priority | ||
24 | -u, --uri-files Make .uri files visible | ||
25 | -x, --Xfuse Escape fuse option | ||
26 | |||
27 | Example use of -x option: | ||
28 | $ gnunet-fs -x-o -xfsname=GNUnet <URI> <path> | ||
29 | Mounts <URI> at <path> and passes "-o fsname=GNUnet" as fuse options. | ||
30 | |||
31 | Special Files | ||
32 | ============= | ||
33 | Each directory contains the following special files. These files are read-only | ||
34 | and aren't actually part of the directory, they are generated on-the-fly by | ||
35 | gnunet-fs. | ||
36 | |||
37 | .uri - contains the URI of the directory | ||
38 | .uri.<file> - contains the URI of the file named <file> in the directory | ||
diff --git a/gnunet-fuse-0.8/configure.ac b/gnunet-fuse-0.8/configure.ac deleted file mode 100644 index 05c6884..0000000 --- a/gnunet-fuse-0.8/configure.ac +++ /dev/null | |||
@@ -1,62 +0,0 @@ | |||
1 | AC_INIT(gnunet-fuse, 0.8.0c) | ||
2 | AM_INIT_AUTOMAKE | ||
3 | AM_CONFIG_HEADER(config.h) | ||
4 | |||
5 | AC_PROG_CC | ||
6 | AM_PROG_CC_C_O | ||
7 | AC_C_CHAR_UNSIGNED | ||
8 | |||
9 | export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH | ||
10 | |||
11 | PKG_CHECK_MODULES(GLIB, [glib-2.0]) | ||
12 | PKG_CHECK_MODULES(FUSE, [fuse >= 2.6]) | ||
13 | |||
14 | # test for GNUnet core | ||
15 | gnunet=0 | ||
16 | AC_MSG_CHECKING([for GNUnet core]) | ||
17 | AC_ARG_WITH(gnunet, | ||
18 | [ --with-gnunet=PFX Base of GNUnet installation], | ||
19 | [AC_MSG_RESULT([$with_gnunet]) | ||
20 | case $with_gnunet in | ||
21 | no) | ||
22 | ;; | ||
23 | yes) | ||
24 | AC_CHECK_HEADERS(GNUnet/gnunet_ecrs_lib.h, | ||
25 | AC_CHECK_LIB([gnunetecrs], [GNUNET_ECRS_file_download_partial], | ||
26 | gnunet=1)) | ||
27 | ;; | ||
28 | *) | ||
29 | LDFLAGS="-L$with_gnunet/lib $LDFLAGS" | ||
30 | LIBPATH="$with_gnunet/lib $LIBPATH" | ||
31 | CPPFLAGS="-I$with_gnunet/include $CPPFLAGS" | ||
32 | CFLAGS="-I$with_gnunet/include $CFLAGS" | ||
33 | INCLUDEPATH="$with_gnunet/include $INCLUDEPATH" | ||
34 | AC_CHECK_HEADERS(GNUnet/gnunet_ecrs_lib.h, | ||
35 | AC_CHECK_LIB([gnunetecrs], [GNUNET_ECRS_file_download_partial], | ||
36 | EXT_LIB_PATH="-L$with_gnunet/lib $EXT_LIB_PATH" | ||
37 | gnunet=1)) | ||
38 | ;; | ||
39 | esac | ||
40 | ], | ||
41 | [AC_MSG_RESULT([--with-gnunet not specified]) | ||
42 | AC_CHECK_HEADERS(GNUnet/gnunet_ecrs_lib.h, | ||
43 | AC_CHECK_LIB([gnunetecrs], [GNUNET_ECRS_file_download_partial], | ||
44 | gnunet=1))]) | ||
45 | if test "$gnunet" != 1 | ||
46 | then | ||
47 | AC_MSG_ERROR([gnunet-fuse requires GNUnet]) | ||
48 | fi | ||
49 | AC_CHECK_HEADERS([GNUnet/gnunet_util.h GNUnet/gnunet_getoption_lib.h],, | ||
50 | AC_MSG_ERROR([compiling gnunet-fuse requires GNUnet core headers] | ||
51 | )) | ||
52 | |||
53 | AC_CHECK_LIB(gnunetutil,GNUNET_init,, | ||
54 | AC_MSG_ERROR([gnunet-fuse requires GNUnet-Util])) | ||
55 | AC_CHECK_LIB(gnunetecrs,GNUNET_ECRS_file_download_partial,, | ||
56 | AC_MSG_ERROR([gnunet-fuse requires ECRS])) | ||
57 | |||
58 | CFLAGS="$CFLAGS -Wall -W $GLIB_CFLAGS $FUSE_CFLAGS" | ||
59 | LIBS="$LIBS $GLIB_LIBS $FUSE_LIBS" | ||
60 | |||
61 | AC_CONFIG_FILES([Makefile]) | ||
62 | AC_OUTPUT | ||
diff --git a/gnunet-fuse-0.8/directory.c b/gnunet-fuse-0.8/directory.c deleted file mode 100644 index 47d6e98..0000000 --- a/gnunet-fuse-0.8/directory.c +++ /dev/null | |||
@@ -1,429 +0,0 @@ | |||
1 | /* | ||
2 | * directory.c - stuff you want to do with directories | ||
3 | * | ||
4 | * This file is part of gnunet-fuse. | ||
5 | * Copyright (C) 2007 David Barksdale | ||
6 | * | ||
7 | * gnunet-fuse is free software; you can redistribute it and/or | ||
8 | * modify if under the terms of version 2 of the GNU General Public License | ||
9 | * as published by the Free Software Foundation. | ||
10 | * | ||
11 | * gnunet-fuse is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | */ | ||
20 | |||
21 | #include <sys/mman.h> | ||
22 | #include <unistd.h> | ||
23 | #include <string.h> | ||
24 | #include <errno.h> | ||
25 | #include <glib.h> | ||
26 | #include <GNUnet/gnunet_ecrs_lib.h> | ||
27 | #include "gnfs.h" | ||
28 | |||
29 | static void dpcb(unsigned long long totalBytes, | ||
30 | unsigned long long completedBytes, GNUNET_CronTime eta, | ||
31 | unsigned long long lastBlockOffset, const char *lastBlock, | ||
32 | unsigned int lastBlockSize, void *cls) | ||
33 | { | ||
34 | (void)totalBytes; | ||
35 | (void)completedBytes; | ||
36 | (void)eta; | ||
37 | memcpy((char *)cls + lastBlockOffset, lastBlock, lastBlockSize); | ||
38 | } | ||
39 | |||
40 | static int tt(void *cls) | ||
41 | { | ||
42 | (void)cls; | ||
43 | if(closing) | ||
44 | return GNUNET_OK; | ||
45 | if(fuse_interrupted()) | ||
46 | return GNUNET_SYSERR; | ||
47 | return GNUNET_OK; | ||
48 | } | ||
49 | |||
50 | static int dir_cache_cb(const GNUNET_ECRS_FileInfo *fi, const GNUNET_HashCode *key, | ||
51 | int isRoot, void *data) | ||
52 | { | ||
53 | struct dirent *de, *deparent = data; | ||
54 | gchar *filename, *path, *newpath, type; | ||
55 | size_t len, rlen; | ||
56 | |||
57 | (void)key; | ||
58 | |||
59 | if(isRoot == GNUNET_YES) | ||
60 | return GNUNET_OK; | ||
61 | |||
62 | /* Figure out the filename and type from metadata */ | ||
63 | filename = GNUNET_meta_data_get_by_type(fi->meta, EXTRACTOR_FILENAME); | ||
64 | if(filename == NULL) | ||
65 | { | ||
66 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_USER | GNUNET_GE_WARNING, | ||
67 | "%s: dirent has no filename\n", __FUNCTION__); | ||
68 | return GNUNET_OK; | ||
69 | } | ||
70 | len = strlen(filename); | ||
71 | if(GNUNET_meta_data_test_for_directory(fi->meta) == GNUNET_YES) | ||
72 | { | ||
73 | if(filename[len - 1] == '/' || filename[len - 1] == '\\') | ||
74 | filename[len - 1] = '\0'; | ||
75 | type = DE_DIR; | ||
76 | } | ||
77 | else | ||
78 | type = DE_FILE; | ||
79 | |||
80 | /* Create newpath, the path to this entry */ | ||
81 | path = gn_dirent_path_get(deparent); | ||
82 | rlen = strlen(path); | ||
83 | newpath = GNUNET_malloc(rlen + len + 1); | ||
84 | strcpy(newpath, path); | ||
85 | if(path[rlen - 1] != G_DIR_SEPARATOR) | ||
86 | strcat(newpath, G_DIR_SEPARATOR_S); | ||
87 | GNUNET_free(path); | ||
88 | strcat(newpath, filename); | ||
89 | |||
90 | /* Create a new dirent for this entry only if one doesn't already exist | ||
91 | * and the only place that can be is in the cache */ | ||
92 | de = gn_dirent_get(newpath); | ||
93 | if(de == NULL) | ||
94 | { | ||
95 | de = gn_dirent_new(newpath, fi->uri, fi->meta, type); | ||
96 | |||
97 | /* Add it to the cache (creates its own ref)*/ | ||
98 | /* NB: the lock on deparent is enough to guarantee that another | ||
99 | * thread hasn't added this dirent to the cache in the time | ||
100 | * between the above check and this insert */ | ||
101 | gn_dirent_cache_insert(de); | ||
102 | } | ||
103 | |||
104 | /* Add it to the directory's list (steals our ref)*/ | ||
105 | GNUNET_mutex_lock(de->de_path_mutex); | ||
106 | GNUNET_GE_ASSERT(ectx, | ||
107 | !g_hash_table_lookup(deparent->de_dir_hash, de->de_basename)); | ||
108 | g_hash_table_replace(deparent->de_dir_hash, de->de_basename, de); | ||
109 | GNUNET_mutex_unlock(de->de_path_mutex); | ||
110 | |||
111 | /* Clean up */ | ||
112 | GNUNET_free(filename); | ||
113 | GNUNET_free(newpath); | ||
114 | return GNUNET_OK; | ||
115 | } | ||
116 | |||
117 | static int directory_cache_locked(struct dirent *de) | ||
118 | { | ||
119 | struct GNUNET_MetaData *md; | ||
120 | void *mem; | ||
121 | int ret; | ||
122 | guint64 len; | ||
123 | |||
124 | len = GNUNET_ECRS_uri_get_file_size(de->de_fi.uri); | ||
125 | mem = GNUNET_malloc(len); | ||
126 | ret = GNUNET_ECRS_file_download_partial(ectx, cfg, de->de_fi.uri, | ||
127 | "/dev/null", 0, len, anonymity, GNUNET_YES, dpcb, mem, tt, | ||
128 | NULL); | ||
129 | if(ret != GNUNET_OK) | ||
130 | { | ||
131 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_USER | GNUNET_GE_ERROR, | ||
132 | "%s: failed to download directory\n", | ||
133 | __FUNCTION__); | ||
134 | GNUNET_free(mem); | ||
135 | return -1; | ||
136 | } | ||
137 | de->de_dir_hash = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, | ||
138 | (GDestroyNotify)gn_dirent_put); | ||
139 | GNUNET_ECRS_directory_list_contents(ectx, mem, len, NULL, &md, dir_cache_cb, de); | ||
140 | GNUNET_free(mem); | ||
141 | GNUNET_meta_data_destroy(md); | ||
142 | de->de_cached = 1; | ||
143 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_DEBUG, | ||
144 | "%s: cached %d entries\n", __FUNCTION__, | ||
145 | g_hash_table_size(de->de_dir_hash)); | ||
146 | return 0; | ||
147 | } | ||
148 | |||
149 | struct dir_foreach_data | ||
150 | { | ||
151 | gn_dir_foreach_callback cb; | ||
152 | void *data; | ||
153 | }; | ||
154 | |||
155 | static gboolean dir_foreach_callback(gpointer key, gpointer value, | ||
156 | gpointer data) | ||
157 | { | ||
158 | struct dirent *de = value; | ||
159 | struct dir_foreach_data *d = data; | ||
160 | |||
161 | (void)key; | ||
162 | return d->cb(de, d->data) == -1; | ||
163 | } | ||
164 | |||
165 | /* | ||
166 | * Call cb for each element in a directory | ||
167 | */ | ||
168 | int gn_directory_foreach(struct dirent *de, gn_dir_foreach_callback cb, | ||
169 | void *data) | ||
170 | { | ||
171 | struct dir_foreach_data d; | ||
172 | int ret = 0; | ||
173 | |||
174 | if(de->de_type != DE_DIR) | ||
175 | return -1; | ||
176 | if(GNUNET_semaphore_down(de->de_sema, GNUNET_YES) == GNUNET_SYSERR) | ||
177 | return -1; | ||
178 | if(!de->de_cached) | ||
179 | { | ||
180 | ret = directory_cache_locked(de); | ||
181 | if(ret == -1) | ||
182 | goto out; | ||
183 | } | ||
184 | d.cb = cb; | ||
185 | d.data = data; | ||
186 | g_hash_table_find(de->de_dir_hash, dir_foreach_callback, &d); | ||
187 | out: | ||
188 | GNUNET_semaphore_up(de->de_sema); | ||
189 | return ret; | ||
190 | } | ||
191 | |||
192 | /* | ||
193 | * Finds 'filename' in directory 'de' and returns a reference or NULL | ||
194 | */ | ||
195 | struct dirent *gn_directory_find(struct dirent *de, const gchar *filename) | ||
196 | { | ||
197 | struct dirent *ret = NULL; | ||
198 | |||
199 | if(de->de_type != DE_DIR) | ||
200 | return NULL; | ||
201 | if(GNUNET_semaphore_down(de->de_sema, GNUNET_YES) == GNUNET_SYSERR) | ||
202 | return NULL; | ||
203 | if(!de->de_cached) | ||
204 | { | ||
205 | if(directory_cache_locked(de) == -1) | ||
206 | goto out; | ||
207 | } | ||
208 | ret = g_hash_table_lookup(de->de_dir_hash, filename); | ||
209 | if(ret != NULL) | ||
210 | gn_dirent_ref(ret); | ||
211 | out: | ||
212 | GNUNET_semaphore_up(de->de_sema); | ||
213 | return ret; | ||
214 | } | ||
215 | |||
216 | int gn_directory_insert(struct dirent *de, struct dirent *dechild) | ||
217 | { | ||
218 | /* Lock our path */ | ||
219 | if(gn_lock_path(de) == -1) | ||
220 | return -1; | ||
221 | |||
222 | /* Cache ourselfs (because we're going to become dirty) */ | ||
223 | if(!de->de_cached) | ||
224 | { | ||
225 | if(directory_cache_locked(de) == -1) | ||
226 | { | ||
227 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_DEBUG, | ||
228 | "%s: failed to cache parent dir\n", | ||
229 | __FUNCTION__); | ||
230 | gn_unlock_path(de, GN_UNLOCK_CLEAN); | ||
231 | return -1; | ||
232 | } | ||
233 | } | ||
234 | |||
235 | /* If we're already in there, bail out */ | ||
236 | GNUNET_mutex_lock(dechild->de_path_mutex); | ||
237 | if(g_hash_table_lookup(de->de_dir_hash, dechild->de_basename)) | ||
238 | { | ||
239 | GNUNET_mutex_unlock(dechild->de_path_mutex); | ||
240 | gn_unlock_path(de, GN_UNLOCK_CLEAN); | ||
241 | return -1; | ||
242 | } | ||
243 | |||
244 | /* Insert the child in our de_dir_hash */ | ||
245 | gn_dirent_ref(dechild); | ||
246 | g_hash_table_replace(de->de_dir_hash, dechild->de_basename, dechild); | ||
247 | GNUNET_mutex_unlock(dechild->de_path_mutex); | ||
248 | |||
249 | /* Cache the dirent */ | ||
250 | gn_dirent_cache_insert(dechild); | ||
251 | |||
252 | /* Mark our path dirty */ | ||
253 | gn_unlock_path(de, GN_UNLOCK_ALL_DIRTY); | ||
254 | return 0; | ||
255 | } | ||
256 | |||
257 | int gn_directory_remove(struct dirent *de, struct dirent *dechild) | ||
258 | { | ||
259 | /* Lock our path */ | ||
260 | if(gn_lock_path(de) == -1) | ||
261 | return -1; | ||
262 | |||
263 | /* Cache ourselfs (because we're going to become dirty) */ | ||
264 | if(!de->de_cached) | ||
265 | { | ||
266 | if(directory_cache_locked(de) == -1) | ||
267 | { | ||
268 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_ERROR, | ||
269 | "%s: failed to cache parent dir\n", | ||
270 | __FUNCTION__); | ||
271 | goto out_err; | ||
272 | } | ||
273 | } | ||
274 | |||
275 | /* Remove from dir_hash */ | ||
276 | GNUNET_mutex_lock(dechild->de_path_mutex); | ||
277 | if(!g_hash_table_remove(de->de_dir_hash, dechild->de_basename)) | ||
278 | { | ||
279 | GNUNET_mutex_unlock(dechild->de_path_mutex); | ||
280 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_ERROR, | ||
281 | "%s: not found in dir_hash\n", | ||
282 | __FUNCTION__); | ||
283 | goto out_err; | ||
284 | } | ||
285 | GNUNET_mutex_unlock(dechild->de_path_mutex); | ||
286 | |||
287 | /* Remove from dirent cache */ | ||
288 | gn_dirent_cache_remove(dechild); | ||
289 | |||
290 | /* Mark our path dirty */ | ||
291 | gn_unlock_path(de, GN_UNLOCK_ALL_DIRTY); | ||
292 | return 0; | ||
293 | out_err: | ||
294 | gn_unlock_path(de, GN_UNLOCK_CLEAN); | ||
295 | return -1; | ||
296 | } | ||
297 | |||
298 | static void upcb(unsigned long long totalBytes, | ||
299 | unsigned long long completedBytes, GNUNET_CronTime eta, | ||
300 | void *closure) | ||
301 | { | ||
302 | (void)totalBytes; | ||
303 | (void)completedBytes; | ||
304 | (void)eta; | ||
305 | (void)closure; | ||
306 | } | ||
307 | |||
308 | struct dir_upload_data | ||
309 | { | ||
310 | GNUNET_ECRS_FileInfo *fis; | ||
311 | int count; | ||
312 | int failed; | ||
313 | }; | ||
314 | |||
315 | static gboolean dir_upload_callback(gpointer key, gpointer value, gpointer data) | ||
316 | { | ||
317 | struct dirent *de = value; | ||
318 | struct dir_upload_data *d = data; | ||
319 | int ret = 0; | ||
320 | |||
321 | (void)key; | ||
322 | if(GNUNET_semaphore_down(de->de_sema, GNUNET_YES) == GNUNET_SYSERR) | ||
323 | { | ||
324 | d->failed = 1; | ||
325 | return 1; | ||
326 | } | ||
327 | if(de->de_dirty) | ||
328 | { | ||
329 | if(de->de_type == DE_FILE) | ||
330 | { | ||
331 | if(de->de_fi.uri == NULL) | ||
332 | { | ||
333 | goto out; | ||
334 | } | ||
335 | } | ||
336 | else | ||
337 | { | ||
338 | if(gn_directory_upload_locked(de) == -1) | ||
339 | { | ||
340 | d->failed = 1; | ||
341 | ret = 1; | ||
342 | goto out; | ||
343 | } | ||
344 | } | ||
345 | } | ||
346 | d->fis[d->count].uri = GNUNET_ECRS_uri_duplicate(de->de_fi.uri); | ||
347 | d->fis[d->count].meta = GNUNET_meta_data_duplicate(de->de_fi.meta); | ||
348 | d->count++; | ||
349 | out: | ||
350 | GNUNET_semaphore_up(de->de_sema); | ||
351 | return ret; | ||
352 | } | ||
353 | |||
354 | /* | ||
355 | * Make a directory clean, de_sema must be locked | ||
356 | */ | ||
357 | int gn_directory_upload_locked(struct dirent *de) | ||
358 | { | ||
359 | int i, ret, fd; | ||
360 | char *buf, filename[] = GN_MKSTEMP_FILE; | ||
361 | unsigned long long len; | ||
362 | struct GNUNET_ECRS_URI *uri; | ||
363 | struct dir_upload_data d; | ||
364 | |||
365 | /* We may be already clean */ | ||
366 | if(!de->de_dirty) | ||
367 | return 0; | ||
368 | |||
369 | /* Collect FileInfo from hash table and make a GNUnet directory */ | ||
370 | d.fis = GNUNET_malloc(g_hash_table_size(de->de_dir_hash) * sizeof(*d.fis)); | ||
371 | d.count = 0; | ||
372 | d.failed = 0; | ||
373 | g_hash_table_find(de->de_dir_hash, dir_upload_callback, &d); | ||
374 | if(d.failed) | ||
375 | { | ||
376 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_ERROR, | ||
377 | "%s: failed\n", __FUNCTION__); | ||
378 | return -1; | ||
379 | } | ||
380 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_DEBUG, | ||
381 | "%s: creating dir of %d elements\n", __FUNCTION__, d.count); | ||
382 | ret = GNUNET_ECRS_directory_create(ectx, &buf, &len, d.count, d.fis, | ||
383 | de->de_fi.meta); | ||
384 | for(i = 0; i < d.count; i++) | ||
385 | { | ||
386 | GNUNET_ECRS_uri_destroy(d.fis[i].uri); | ||
387 | GNUNET_meta_data_destroy(d.fis[i].meta); | ||
388 | } | ||
389 | GNUNET_free(d.fis); | ||
390 | if(ret == GNUNET_SYSERR) | ||
391 | { | ||
392 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_ERROR, | ||
393 | "%s: GNUNET_ECRS_directory_create failed\n", | ||
394 | __FUNCTION__); | ||
395 | return -1; | ||
396 | } | ||
397 | |||
398 | /* Write the GNUnet directory out to a file and upload it */ | ||
399 | fd = mkstemp(filename); | ||
400 | if(fd == -1) | ||
401 | { | ||
402 | GNUNET_GE_LOG_STRERROR_FILE(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | ||
403 | | GNUNET_GE_ERROR, "mkstemp", filename); | ||
404 | return -1; | ||
405 | } | ||
406 | write(fd, buf, len); | ||
407 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_DEBUG, | ||
408 | "%s: wrote to %lld bytes to '%s'\n", __FUNCTION__, len, | ||
409 | filename); | ||
410 | ret = GNUNET_ECRS_file_upload(ectx, cfg, filename, GNUNET_NO, anonymity, priority, | ||
411 | -1, upcb, NULL, tt, NULL, &uri); | ||
412 | close(fd); | ||
413 | unlink(filename); | ||
414 | if(ret == GNUNET_SYSERR) | ||
415 | { | ||
416 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_ERROR, | ||
417 | "%s: GNUNET_ECRS_file_upload failed\n", __FUNCTION__); | ||
418 | return -1; | ||
419 | } | ||
420 | |||
421 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_DEBUG, | ||
422 | "%s: done\n", __FUNCTION__); | ||
423 | /* Update the dirent info with our new URI and mark it clean */ | ||
424 | if(de->de_fi.uri != NULL) | ||
425 | GNUNET_ECRS_uri_destroy(de->de_fi.uri); | ||
426 | de->de_fi.uri = uri; | ||
427 | de->de_dirty = 0; | ||
428 | return 0; | ||
429 | } | ||
diff --git a/gnunet-fuse-0.8/dirent.c b/gnunet-fuse-0.8/dirent.c deleted file mode 100644 index f44fa0b..0000000 --- a/gnunet-fuse-0.8/dirent.c +++ /dev/null | |||
@@ -1,385 +0,0 @@ | |||
1 | /* | ||
2 | * dirent.c - stuff for directory entries | ||
3 | * | ||
4 | * This file is part of gnunet-fuse. | ||
5 | * Copyright (C) 2007 David Barksdale | ||
6 | * | ||
7 | * gnunet-fuse is free software; you can redistribute it and/or | ||
8 | * modify if under the terms of version 2 of the GNU General Public License | ||
9 | * as published by the Free Software Foundation. | ||
10 | * | ||
11 | * gnunet-fuse is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | */ | ||
20 | |||
21 | #include <unistd.h> | ||
22 | #include <glib.h> | ||
23 | #include <string.h> | ||
24 | #include <errno.h> | ||
25 | #include "gnfs.h" | ||
26 | |||
27 | GHashTable *path_hash; | ||
28 | struct GNUNET_Semaphore *path_sema; | ||
29 | |||
30 | /* | ||
31 | * Reference a dirent, call gn_dirent_put when finished | ||
32 | */ | ||
33 | void gn_dirent_ref(struct dirent *de) | ||
34 | { | ||
35 | GNUNET_mutex_lock(de->de_refs_mutex); | ||
36 | de->de_refs++; | ||
37 | GNUNET_mutex_unlock(de->de_refs_mutex); | ||
38 | } | ||
39 | |||
40 | /* | ||
41 | * Reference a dirent from the cache, call gn_dirent_put when finished with it | ||
42 | */ | ||
43 | struct dirent *gn_dirent_get(const gchar *path) | ||
44 | { | ||
45 | struct dirent *de; | ||
46 | |||
47 | if(GNUNET_semaphore_down(path_sema, GNUNET_YES) == GNUNET_SYSERR) | ||
48 | return NULL; | ||
49 | de = g_hash_table_lookup(path_hash, path); | ||
50 | if(de != NULL) | ||
51 | gn_dirent_ref(de); | ||
52 | GNUNET_semaphore_up(path_sema); | ||
53 | return de; | ||
54 | } | ||
55 | |||
56 | /* | ||
57 | * Release a reference to a dirent | ||
58 | */ | ||
59 | void gn_dirent_put(struct dirent *de) | ||
60 | { | ||
61 | GNUNET_mutex_lock(de->de_refs_mutex); | ||
62 | de->de_refs--; | ||
63 | if(de->de_refs >= 1) | ||
64 | { | ||
65 | GNUNET_mutex_unlock(de->de_refs_mutex); | ||
66 | return; | ||
67 | } | ||
68 | GNUNET_mutex_unlock(de->de_refs_mutex); | ||
69 | GNUNET_mutex_destroy(de->de_path_mutex); | ||
70 | GNUNET_free(de->de_path); | ||
71 | GNUNET_mutex_destroy(de->de_refs_mutex); | ||
72 | GNUNET_semaphore_destroy(de->de_sema); | ||
73 | if(de->de_fi.uri != NULL) | ||
74 | GNUNET_ECRS_uri_destroy(de->de_fi.uri); | ||
75 | if(de->de_fi.meta != NULL) | ||
76 | GNUNET_meta_data_destroy(de->de_fi.meta); | ||
77 | if(de->de_type == DE_DIR) | ||
78 | { | ||
79 | if(de->de_cached) | ||
80 | { | ||
81 | g_hash_table_destroy(de->de_dir_hash); | ||
82 | } | ||
83 | } | ||
84 | else | ||
85 | { | ||
86 | if(de->de_cached) | ||
87 | { | ||
88 | close(de->de_fd); | ||
89 | unlink(de->de_filename); | ||
90 | GNUNET_free(de->de_filename); | ||
91 | } | ||
92 | } | ||
93 | GNUNET_free(de); | ||
94 | } | ||
95 | |||
96 | char *gn_dirent_path_get(struct dirent *de) | ||
97 | { | ||
98 | char *ret; | ||
99 | |||
100 | GNUNET_mutex_lock(de->de_path_mutex); | ||
101 | ret = GNUNET_strdup(de->de_path); | ||
102 | GNUNET_mutex_unlock(de->de_path_mutex); | ||
103 | return ret; | ||
104 | } | ||
105 | |||
106 | /* | ||
107 | * DON'T call this if the dirent is ref'd by a hash | ||
108 | */ | ||
109 | void gn_dirent_path_set(struct dirent *de, const char *path) | ||
110 | { | ||
111 | GNUNET_mutex_lock(de->de_path_mutex); | ||
112 | GNUNET_free(de->de_path); | ||
113 | de->de_path = GNUNET_strdup(path); | ||
114 | de->de_basename = strrchr(de->de_path, G_DIR_SEPARATOR) + 1; | ||
115 | GNUNET_mutex_unlock(de->de_path_mutex); | ||
116 | } | ||
117 | |||
118 | void gn_dirent_cache_init(void) | ||
119 | { | ||
120 | path_hash = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, | ||
121 | (GDestroyNotify)gn_dirent_put); | ||
122 | path_sema = GNUNET_semaphore_create(1); | ||
123 | } | ||
124 | |||
125 | /* | ||
126 | * Create a new dirent with a reference, path and uri are copied | ||
127 | */ | ||
128 | struct dirent *gn_dirent_new(const gchar *path, struct GNUNET_ECRS_URI *uri, | ||
129 | struct GNUNET_MetaData *meta, gchar type) | ||
130 | { | ||
131 | struct dirent *de; | ||
132 | |||
133 | de = GNUNET_malloc(sizeof(*de)); | ||
134 | de->de_path_mutex = GNUNET_mutex_create(0); | ||
135 | de->de_path = GNUNET_strdup(path); | ||
136 | de->de_basename = strrchr(de->de_path, G_DIR_SEPARATOR) + 1; | ||
137 | de->de_refs_mutex = GNUNET_mutex_create(0); | ||
138 | de->de_refs = 1; | ||
139 | de->de_type = type; | ||
140 | de->de_sema = GNUNET_semaphore_create(1); | ||
141 | if(uri != NULL) | ||
142 | { | ||
143 | de->de_dirty = 0; | ||
144 | de->de_cached = 0; | ||
145 | de->de_fi.uri = GNUNET_ECRS_uri_duplicate(uri); | ||
146 | } | ||
147 | else | ||
148 | { | ||
149 | de->de_dirty = 1; | ||
150 | de->de_cached = 1; | ||
151 | if(type == DE_FILE) | ||
152 | { | ||
153 | char filename[] = GN_MKSTEMP_FILE; | ||
154 | |||
155 | de->de_fd = mkstemp(filename); | ||
156 | de->de_filename = GNUNET_strdup(filename); | ||
157 | } | ||
158 | else | ||
159 | { | ||
160 | de->de_dir_hash = g_hash_table_new_full(g_str_hash, | ||
161 | g_str_equal, NULL, | ||
162 | (GDestroyNotify)gn_dirent_put); | ||
163 | } | ||
164 | } | ||
165 | if(meta == NULL) | ||
166 | de->de_fi.meta = GNUNET_meta_data_create(); | ||
167 | else | ||
168 | de->de_fi.meta = GNUNET_meta_data_duplicate(meta); | ||
169 | return de; | ||
170 | } | ||
171 | |||
172 | /* | ||
173 | * Add a dirent to the cache | ||
174 | */ | ||
175 | void gn_dirent_cache_insert(struct dirent *de) | ||
176 | { | ||
177 | /* TODO: Here we need to see if the cache has gotten too big and empty | ||
178 | * it. | ||
179 | * XXX: But what about diry entries?? */ | ||
180 | if(GNUNET_semaphore_down(path_sema, GNUNET_YES) == GNUNET_SYSERR) | ||
181 | return; | ||
182 | GNUNET_mutex_lock(de->de_path_mutex); | ||
183 | GNUNET_GE_ASSERT(ectx, !g_hash_table_lookup(path_hash, de->de_path)); | ||
184 | g_hash_table_replace(path_hash, de->de_path, de); | ||
185 | GNUNET_mutex_unlock(de->de_path_mutex); | ||
186 | gn_dirent_ref(de); | ||
187 | GNUNET_semaphore_up(path_sema); | ||
188 | } | ||
189 | |||
190 | /* | ||
191 | * Remove a dirent from the cache | ||
192 | */ | ||
193 | void gn_dirent_cache_remove(struct dirent *de) | ||
194 | { | ||
195 | if(GNUNET_semaphore_down(path_sema, GNUNET_YES) == GNUNET_SYSERR) | ||
196 | return; | ||
197 | /* This is safe because we still hold a ref */ | ||
198 | GNUNET_mutex_lock(de->de_path_mutex); | ||
199 | g_hash_table_remove(path_hash, de->de_path); | ||
200 | GNUNET_mutex_unlock(de->de_path_mutex); | ||
201 | GNUNET_semaphore_up(path_sema); | ||
202 | } | ||
203 | |||
204 | /* | ||
205 | * Call 'cb' for each element in 'path', treats the empty string as "/" | ||
206 | */ | ||
207 | int gn_path_foreach(const gchar *path, gn_dir_foreach_callback cb, void *data) | ||
208 | { | ||
209 | struct dirent *de, *next_de; | ||
210 | size_t len, plen; | ||
211 | gchar *ppath, *filename; | ||
212 | |||
213 | /* Start de off at the root */ | ||
214 | de = root_de; | ||
215 | gn_dirent_ref(de); | ||
216 | |||
217 | /* Allocate partial path buffer */ | ||
218 | len = strlen(path); | ||
219 | ppath = GNUNET_malloc(len + 1); | ||
220 | plen = 0; | ||
221 | |||
222 | /* Loop through each path element */ | ||
223 | for( ; ; ) | ||
224 | { | ||
225 | /* Do callback for current element */ | ||
226 | if(cb(de, data)) | ||
227 | break; | ||
228 | |||
229 | /* Do we have any more work to do? */ | ||
230 | if(plen >= len || path[plen + 1] == '\0' | ||
231 | || path[plen + 1] == G_DIR_SEPARATOR) | ||
232 | { | ||
233 | break; | ||
234 | } | ||
235 | |||
236 | /* Save pointer to ppath end */ | ||
237 | filename = &ppath[plen + 1]; | ||
238 | |||
239 | /* Cat next path component */ | ||
240 | ppath[plen] = G_DIR_SEPARATOR; | ||
241 | for(plen++; path[plen] != '\0' && path[plen] != G_DIR_SEPARATOR; | ||
242 | plen++) | ||
243 | { | ||
244 | ppath[plen] = path[plen]; | ||
245 | } | ||
246 | ppath[plen] = '\0'; | ||
247 | |||
248 | /* Look it up in the cache first */ | ||
249 | next_de = gn_dirent_get(ppath); | ||
250 | |||
251 | /* If we found it then continue */ | ||
252 | if(next_de != NULL) | ||
253 | { | ||
254 | gn_dirent_put(de); | ||
255 | de = next_de; | ||
256 | continue; | ||
257 | } | ||
258 | |||
259 | /* We need to find it by listing its parent directory, de */ | ||
260 | next_de = gn_directory_find(de, filename); | ||
261 | |||
262 | /* Not found? */ | ||
263 | if(next_de == NULL) | ||
264 | { | ||
265 | gn_dirent_put(de); | ||
266 | de = NULL; | ||
267 | break; | ||
268 | } | ||
269 | |||
270 | /* Continue to the next path element */ | ||
271 | gn_dirent_put(de); | ||
272 | de = next_de; | ||
273 | } | ||
274 | |||
275 | /* Done */ | ||
276 | GNUNET_free(ppath); | ||
277 | if(de == NULL) | ||
278 | return -1; | ||
279 | gn_dirent_put(de); | ||
280 | return 0; | ||
281 | } | ||
282 | |||
283 | static gboolean dirent_find_callback(struct dirent *de, void *data) | ||
284 | { | ||
285 | struct dirent **d = data; | ||
286 | |||
287 | if(*d != NULL) | ||
288 | gn_dirent_put(*d); | ||
289 | *d = de; | ||
290 | gn_dirent_ref(*d); | ||
291 | return 0; | ||
292 | } | ||
293 | |||
294 | /* | ||
295 | * Retrieve a dirent with a reference given it's (normalized) path. | ||
296 | */ | ||
297 | struct dirent *gn_dirent_find(const gchar *path) | ||
298 | { | ||
299 | struct dirent *de = NULL; | ||
300 | |||
301 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_DEBUG, | ||
302 | "%s: called for '%s'\n", __FUNCTION__, path); | ||
303 | if(gn_path_foreach(path, dirent_find_callback, &de) == -1) | ||
304 | { | ||
305 | if(de != NULL) | ||
306 | gn_dirent_put(de); | ||
307 | return NULL; | ||
308 | } | ||
309 | return de; | ||
310 | } | ||
311 | |||
312 | static gboolean lock_path_callback(struct dirent *de, void *data) | ||
313 | { | ||
314 | struct dirent **detmp = data; | ||
315 | |||
316 | if(GNUNET_semaphore_down(de->de_sema, GNUNET_YES) == -1) | ||
317 | return 1; | ||
318 | gn_dirent_ref(de); | ||
319 | *detmp = de; | ||
320 | return 0; | ||
321 | } | ||
322 | |||
323 | /* | ||
324 | * Locks each element in a path. | ||
325 | */ | ||
326 | int gn_lock_path(struct dirent *de) | ||
327 | { | ||
328 | struct dirent *detmp = NULL; | ||
329 | char *path; | ||
330 | |||
331 | path = gn_dirent_path_get(de); | ||
332 | if(gn_path_foreach(path, lock_path_callback, &detmp) == -1) | ||
333 | { | ||
334 | GNUNET_free(path); | ||
335 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_ERROR, | ||
336 | "%s: failed!\n", __FUNCTION__); | ||
337 | /* Back out all the locks we aquired */ | ||
338 | if(detmp != NULL) | ||
339 | gn_unlock_path(detmp, GN_UNLOCK_CLEAN); | ||
340 | return -1; | ||
341 | } | ||
342 | GNUNET_free(path); | ||
343 | return 0; | ||
344 | } | ||
345 | |||
346 | struct unlock_path_data | ||
347 | { | ||
348 | int dirty; | ||
349 | struct dirent *de; | ||
350 | }; | ||
351 | |||
352 | static gboolean unlock_path_callback(struct dirent *de, void *data) | ||
353 | { | ||
354 | struct unlock_path_data *d = data; | ||
355 | |||
356 | if(d->dirty == GN_UNLOCK_ALL_DIRTY) | ||
357 | de->de_dirty = 1; | ||
358 | else if(d->dirty == GN_UNLOCK_ANCESTORS_DIRTY && de != d->de) | ||
359 | de->de_dirty = 1; | ||
360 | GNUNET_semaphore_up(de->de_sema); | ||
361 | gn_dirent_put(de); | ||
362 | return 0; | ||
363 | } | ||
364 | |||
365 | /* | ||
366 | * Un-lock each element in a path and set the dirty state | ||
367 | */ | ||
368 | int gn_unlock_path(struct dirent *de, int dirty) | ||
369 | { | ||
370 | struct unlock_path_data d; | ||
371 | char *path; | ||
372 | |||
373 | d.dirty = dirty; | ||
374 | d.de = de; | ||
375 | path = gn_dirent_path_get(de); | ||
376 | if(gn_path_foreach(path, unlock_path_callback, &d) == -1) | ||
377 | { | ||
378 | GNUNET_free(path); | ||
379 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_ERROR, | ||
380 | "%s: failed!\n", __FUNCTION__); | ||
381 | return -1; | ||
382 | } | ||
383 | GNUNET_free(path); | ||
384 | return 0; | ||
385 | } | ||
diff --git a/gnunet-fuse-0.8/file.c b/gnunet-fuse-0.8/file.c deleted file mode 100644 index 2f8ece3..0000000 --- a/gnunet-fuse-0.8/file.c +++ /dev/null | |||
@@ -1,126 +0,0 @@ | |||
1 | /* | ||
2 | * file.c - operations on files | ||
3 | * | ||
4 | * This file is part of gnunet-fuse. | ||
5 | * Copyright (C) 2007 David Barksdale | ||
6 | * | ||
7 | * gnunet-fuse is free software; you can redistribute it and/or | ||
8 | * modify if under the terms of version 2 of the GNU General Public License | ||
9 | * as published by the Free Software Foundation. | ||
10 | * | ||
11 | * gnunet-fuse is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | */ | ||
20 | |||
21 | #include <sys/mman.h> | ||
22 | #include <unistd.h> | ||
23 | #include <string.h> | ||
24 | #include <errno.h> | ||
25 | #include <glib.h> | ||
26 | #include <GNUnet/gnunet_ecrs_lib.h> | ||
27 | #include "gnfs.h" | ||
28 | |||
29 | static int tt(void *cls) | ||
30 | { | ||
31 | (void)cls; | ||
32 | if(closing) | ||
33 | return GNUNET_OK; | ||
34 | if(fuse_interrupted()) | ||
35 | return GNUNET_SYSERR; | ||
36 | return GNUNET_OK; | ||
37 | } | ||
38 | |||
39 | static void upcb(unsigned long long totalBytes, | ||
40 | unsigned long long completedBytes, GNUNET_CronTime eta, | ||
41 | void *closure) | ||
42 | { | ||
43 | (void)totalBytes; | ||
44 | (void)completedBytes; | ||
45 | (void)eta; | ||
46 | (void)closure; | ||
47 | } | ||
48 | |||
49 | static void dpcb(unsigned long long totalBytes, | ||
50 | unsigned long long completedBytes, GNUNET_CronTime eta, | ||
51 | unsigned long long lastBlockOffset, const char *lastBlock, | ||
52 | unsigned int lastBlockSize, void *cls) | ||
53 | { | ||
54 | (void)totalBytes; | ||
55 | (void)completedBytes; | ||
56 | (void)eta; | ||
57 | (void)lastBlockOffset; | ||
58 | (void)lastBlock; | ||
59 | (void)lastBlockSize; | ||
60 | (void)cls; | ||
61 | } | ||
62 | |||
63 | /* | ||
64 | * Download a file for writing, de_sema must be held. | ||
65 | */ | ||
66 | int gn_file_download_locked(struct dirent *de) | ||
67 | { | ||
68 | char filename[] = GN_MKSTEMP_FILE; | ||
69 | |||
70 | /* We may already be cached */ | ||
71 | if(de->de_cached) | ||
72 | return 0; | ||
73 | |||
74 | /* Do the download */ | ||
75 | de->de_fd = mkstemp(filename); | ||
76 | if(de->de_fd == -1) | ||
77 | { | ||
78 | GNUNET_GE_LOG_STRERROR_FILE(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | ||
79 | | GNUNET_GE_ERROR, "mkstemp", filename); | ||
80 | return -1; | ||
81 | } | ||
82 | de->de_filename = GNUNET_strdup(filename); | ||
83 | |||
84 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_DEBUG, | ||
85 | "%s: downloading '%s'\n", __FUNCTION__, de->de_filename); | ||
86 | if(GNUNET_ECRS_file_download(ectx, cfg, de->de_fi.uri, filename, anonymity, | ||
87 | dpcb, NULL, tt, NULL) == GNUNET_SYSERR) | ||
88 | { | ||
89 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_ERROR, | ||
90 | "%s: download failed\n", __FUNCTION__); | ||
91 | close(de->de_fd); | ||
92 | unlink(de->de_filename); | ||
93 | GNUNET_free(de->de_filename); | ||
94 | return -1; | ||
95 | } | ||
96 | |||
97 | /* Mark ourselves cached */ | ||
98 | de->de_cached = 1; | ||
99 | return 0; | ||
100 | } | ||
101 | |||
102 | int gn_file_upload_locked(struct dirent *de) | ||
103 | { | ||
104 | struct GNUNET_ECRS_URI *uri; | ||
105 | |||
106 | /* If we're not dirty then we're done */ | ||
107 | if(!de->de_dirty) | ||
108 | return 0; | ||
109 | |||
110 | if(GNUNET_ECRS_file_upload(ectx, cfg, de->de_filename, GNUNET_NO, anonymity, priority, | ||
111 | -1, upcb, NULL, tt, NULL, &uri) == GNUNET_SYSERR) | ||
112 | { | ||
113 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_ERROR, | ||
114 | "%s: upload failed\n", __FUNCTION__); | ||
115 | return -1; | ||
116 | } | ||
117 | if(de->de_fi.uri != NULL) | ||
118 | GNUNET_ECRS_uri_destroy(de->de_fi.uri); | ||
119 | de->de_fi.uri = uri; | ||
120 | de->de_cached = 0; | ||
121 | de->de_dirty = 0; | ||
122 | close(de->de_fd); | ||
123 | unlink(de->de_filename); | ||
124 | GNUNET_free(de->de_filename); | ||
125 | return 0; | ||
126 | } | ||
diff --git a/gnunet-fuse-0.8/getattr.c b/gnunet-fuse-0.8/getattr.c deleted file mode 100644 index 716e3ad..0000000 --- a/gnunet-fuse-0.8/getattr.c +++ /dev/null | |||
@@ -1,86 +0,0 @@ | |||
1 | /* | ||
2 | * getattr.c - FUSE getattr function | ||
3 | * | ||
4 | * This file is part of gnunet-fuse. | ||
5 | * Copyright (C) 2007 David Barksdale | ||
6 | * | ||
7 | * gnunet-fuse is free software; you can redistribute it and/or | ||
8 | * modify if under the terms of version 2 of the GNU General Public License | ||
9 | * as published by the Free Software Foundation. | ||
10 | * | ||
11 | * gnunet-fuse is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | */ | ||
20 | |||
21 | #include <sys/stat.h> | ||
22 | #include <string.h> | ||
23 | #include <errno.h> | ||
24 | #include <fuse.h> | ||
25 | #include "gnfs.h" | ||
26 | |||
27 | int gn_getattr(const char *path, struct stat *stbuf) | ||
28 | { | ||
29 | struct dirent *de; | ||
30 | int ret = 0; | ||
31 | |||
32 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_DEBUG, "%s: for '%s'\n", | ||
33 | __FUNCTION__, path); | ||
34 | |||
35 | /* Check to see if this is a special file */ | ||
36 | if(gn_exists_special_file(path)) | ||
37 | { | ||
38 | memset(stbuf, 0, sizeof(*stbuf)); | ||
39 | stbuf->st_mode = 0555 | S_IFREG; | ||
40 | stbuf->st_nlink = 1; | ||
41 | /* sysfs uses 4096 for variable sized files */ | ||
42 | stbuf->st_size = 4096; | ||
43 | return 0; | ||
44 | } | ||
45 | |||
46 | /* Fill in dirent stat info */ | ||
47 | de = gn_dirent_find(path); | ||
48 | if(de == NULL) | ||
49 | { | ||
50 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_USER | GNUNET_GE_DEBUG, | ||
51 | "%s: could not find path '%s'\n", __FUNCTION__, path); | ||
52 | return -ENOENT; | ||
53 | } | ||
54 | |||
55 | /* If it's a cached file just call stat */ | ||
56 | if(GNUNET_semaphore_down(de->de_sema, GNUNET_YES) == GNUNET_SYSERR) | ||
57 | { | ||
58 | gn_dirent_put(de); | ||
59 | return -EIO; | ||
60 | } | ||
61 | if(de->de_cached && de->de_type == DE_FILE) | ||
62 | { | ||
63 | ret = stat(de->de_filename, stbuf); | ||
64 | if(ret == -1) | ||
65 | { | ||
66 | ret = -errno; | ||
67 | GNUNET_GE_LOG_STRERROR(ectx, GNUNET_GE_BULK | GNUNET_GE_USER | GNUNET_GE_ERROR, | ||
68 | "stat"); | ||
69 | goto out; | ||
70 | } | ||
71 | goto out; | ||
72 | } | ||
73 | |||
74 | memset(stbuf, 0, sizeof(*stbuf)); | ||
75 | stbuf->st_mode = 0777; | ||
76 | stbuf->st_mode |= de->de_type == DE_DIR ? S_IFDIR : S_IFREG; | ||
77 | stbuf->st_nlink = 1; | ||
78 | if(de->de_fi.uri != NULL) | ||
79 | stbuf->st_size = GNUNET_ECRS_uri_get_file_size(de->de_fi.uri); | ||
80 | else | ||
81 | stbuf->st_size = 0; | ||
82 | out: | ||
83 | GNUNET_semaphore_up(de->de_sema); | ||
84 | gn_dirent_put(de); | ||
85 | return ret; | ||
86 | } | ||
diff --git a/gnunet-fuse-0.8/gettext.h b/gnunet-fuse-0.8/gettext.h deleted file mode 100644 index 4c87311..0000000 --- a/gnunet-fuse-0.8/gettext.h +++ /dev/null | |||
@@ -1,6 +0,0 @@ | |||
1 | #ifndef _GETTEXT_H_ | ||
2 | #define _GETTEXT_H_ | ||
3 | |||
4 | #define gettext_noop(x) x | ||
5 | |||
6 | #endif /* _GETTEXT_H_ */ | ||
diff --git a/gnunet-fuse-0.8/gnfs.h b/gnunet-fuse-0.8/gnfs.h deleted file mode 100644 index e8d0336..0000000 --- a/gnunet-fuse-0.8/gnfs.h +++ /dev/null | |||
@@ -1,139 +0,0 @@ | |||
1 | /* | ||
2 | * gnfs.h - types and stuff | ||
3 | * | ||
4 | * This file is part of gnunet-fuse. | ||
5 | * Copyright (C) 2007 David Barksdale | ||
6 | * | ||
7 | * gnunet-fuse is free software; you can redistribute it and/or | ||
8 | * modify if under the terms of version 2 of the GNU General Public License | ||
9 | * as published by the Free Software Foundation. | ||
10 | * | ||
11 | * gnunet-fuse is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | */ | ||
20 | |||
21 | #ifndef _GNFS_H_ | ||
22 | #define _GNFS_H_ | ||
23 | |||
24 | #include <sys/types.h> | ||
25 | #include <sys/stat.h> | ||
26 | #include <glib.h> | ||
27 | #include <fuse.h> | ||
28 | #include <GNUnet/gnunet_util_boot.h> | ||
29 | #include <GNUnet/gnunet_ecrs_lib.h> | ||
30 | |||
31 | /* Some gnunet macros need these */ | ||
32 | #define _(x) x | ||
33 | #define STRERROR strerror | ||
34 | |||
35 | #define URI_FILE ".uri" | ||
36 | #define URI_LEN 4 | ||
37 | #define GN_MKSTEMP_FILE "/tmp/gnfs.XXXXXX" | ||
38 | #define GN_EMPTY_FILE_URI "gnunet://ecrs/chk/00000000000000000000000000000000" \ | ||
39 | "00000000000000000000000000000000000000000000000000000000000000000000" \ | ||
40 | "000.0000000000000000000000000000000000000000000000000000000000000000" \ | ||
41 | "000000000000000000000000000000000000000.0" | ||
42 | |||
43 | struct dirent | ||
44 | { | ||
45 | /* de_path_mutex protects de_path and de_basename */ | ||
46 | struct GNUNET_Mutex *de_path_mutex; | ||
47 | gchar *de_path; | ||
48 | gchar *de_basename; | ||
49 | /* de_refs_mutex protects de_refs */ | ||
50 | struct GNUNET_Mutex *de_refs_mutex; | ||
51 | gint de_refs; | ||
52 | gchar de_type; | ||
53 | #define DE_FILE 'f' | ||
54 | #define DE_DIR 'd' | ||
55 | /* de_sema protects everything below */ | ||
56 | struct GNUNET_Semaphore *de_sema; | ||
57 | /* Cached entries have their entire contents in memory or on disk */ | ||
58 | gboolean de_cached; | ||
59 | /* Dirty entires have been changed and not published in GNUnet (implies | ||
60 | * cached) */ | ||
61 | gboolean de_dirty; | ||
62 | GNUNET_ECRS_FileInfo de_fi; | ||
63 | union | ||
64 | { | ||
65 | /* For cached directories */ | ||
66 | GHashTable *de_dir_hash; | ||
67 | /* For cached files */ | ||
68 | struct | ||
69 | { | ||
70 | gint de_fd; | ||
71 | gchar *de_filename; | ||
72 | }; | ||
73 | }; | ||
74 | }; | ||
75 | |||
76 | typedef gboolean (*gn_dir_foreach_callback)(struct dirent *de, void *data); | ||
77 | |||
78 | extern struct GNUNET_GC_Configuration *cfg; | ||
79 | extern struct GNUNET_GE_Context *ectx; | ||
80 | extern int closing; | ||
81 | extern unsigned int anonymity; | ||
82 | extern unsigned int priority; | ||
83 | extern int uri_files; | ||
84 | extern struct dirent *root_de; | ||
85 | |||
86 | /* dirent.c */ | ||
87 | struct dirent *gn_dirent_new(const gchar *path, struct GNUNET_ECRS_URI *uri, | ||
88 | struct GNUNET_MetaData *meta, gchar type); | ||
89 | struct dirent *gn_dirent_get(const gchar *path); | ||
90 | void gn_dirent_ref(struct dirent *de); | ||
91 | void gn_dirent_put(struct dirent *de); | ||
92 | char *gn_dirent_path_get(struct dirent *de); | ||
93 | void gn_dirent_path_set(struct dirent *de, const char *path); | ||
94 | void gn_dirent_cache_init(void); | ||
95 | void gn_dirent_cache_insert(struct dirent *de); | ||
96 | void gn_dirent_cache_remove(struct dirent *de); | ||
97 | struct dirent *gn_dirent_find(const gchar *path); | ||
98 | int gn_lock_path(struct dirent *de); | ||
99 | int gn_unlock_path(struct dirent *de, int dirty); | ||
100 | #define GN_UNLOCK_CLEAN 0 | ||
101 | #define GN_UNLOCK_ALL_DIRTY 1 | ||
102 | #define GN_UNLOCK_ANCESTORS_DIRTY 2 | ||
103 | |||
104 | /* directory.c */ | ||
105 | int gn_directory_foreach(struct dirent *de, gn_dir_foreach_callback cb, | ||
106 | void *data); | ||
107 | struct dirent *gn_directory_find(struct dirent *de, const gchar *filename); | ||
108 | int gn_directory_insert(struct dirent *de, struct dirent *dechild); | ||
109 | int gn_directory_remove(struct dirent *de, struct dirent *dechild); | ||
110 | int gn_directory_upload_locked(struct dirent *de); | ||
111 | |||
112 | /* file.c */ | ||
113 | int gn_file_download_locked(struct dirent *de); | ||
114 | int gn_file_upload_locked(struct dirent *de); | ||
115 | |||
116 | /* FUSE function files */ | ||
117 | int gn_getattr(const char *path, struct stat *stbuf); | ||
118 | int gn_mknod(const char *path, mode_t mode, dev_t rdev); | ||
119 | int gn_mkdir(const char *path, mode_t mode); | ||
120 | int gn_unlink(const char *path); | ||
121 | int gn_rmdir(const char *path); | ||
122 | int gn_rename(const char *from, const char *to); | ||
123 | int gn_truncate(const char *path, off_t size); | ||
124 | int gn_open(const char *path, struct fuse_file_info *fi); | ||
125 | int gn_read(const char *path, char *buf, size_t size, off_t offset, | ||
126 | struct fuse_file_info *fi); | ||
127 | int gn_write(const char *path, const char *buf, size_t size, off_t offset, | ||
128 | struct fuse_file_info *fi); | ||
129 | int gn_release(const char *path, struct fuse_file_info *fi); | ||
130 | int gn_readdir(const char *path, void *buf, fuse_fill_dir_t filler, | ||
131 | off_t offset, struct fuse_file_info *fi); | ||
132 | int gn_utimens(const char *path, const struct timespec ts[2]); | ||
133 | |||
134 | /* special_file.c */ | ||
135 | char *gn_dirname(const char *path, char **file); | ||
136 | int gn_exists_special_file(const char *path); | ||
137 | char *gn_get_special_file(const char *path); | ||
138 | |||
139 | #endif /* _GNFS_H_ */ | ||
diff --git a/gnunet-fuse-0.8/main.c b/gnunet-fuse-0.8/main.c deleted file mode 100644 index edafe4e..0000000 --- a/gnunet-fuse-0.8/main.c +++ /dev/null | |||
@@ -1,232 +0,0 @@ | |||
1 | /* | ||
2 | * main.c - program start | ||
3 | * | ||
4 | * This file is part of gnunet-fuse. | ||
5 | * Copyright (C) 2007 David Barksdale | ||
6 | * | ||
7 | * gnunet-fuse is free software; you can redistribute it and/or | ||
8 | * modify if under the terms of version 2 of the GNU General Public License | ||
9 | * as published by the Free Software Foundation. | ||
10 | * | ||
11 | * gnunet-fuse is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | */ | ||
20 | |||
21 | #include <stdio.h> | ||
22 | #include <string.h> | ||
23 | #include <unistd.h> | ||
24 | #include <errno.h> | ||
25 | #include <glib.h> | ||
26 | #include <fuse.h> | ||
27 | #include <GNUnet/gnunet_directories.h> | ||
28 | #include <GNUnet/gnunet_util.h> | ||
29 | #include <GNUnet/gnunet_ecrs_lib.h> | ||
30 | #include "gnfs.h" | ||
31 | #include "gettext.h" | ||
32 | |||
33 | struct GNUNET_GC_Configuration *cfg; | ||
34 | struct GNUNET_GE_Context *ectx; | ||
35 | static char *cfgFilename = GNUNET_DEFAULT_CLIENT_CONFIG_FILE; | ||
36 | static char *cfgLogfile = "/tmp/gnunet_fuse.log"; | ||
37 | |||
38 | /* Flag to indicate that we are shutting down */ | ||
39 | int closing = 0; | ||
40 | |||
41 | /* Level of anonymity for downloading and uploading files */ | ||
42 | unsigned int anonymity = 1; | ||
43 | |||
44 | /* Priority for uploaded files */ | ||
45 | unsigned int priority = 1000; | ||
46 | |||
47 | /* Flag for including .uri files in readdir() */ | ||
48 | int uri_files = 0; | ||
49 | |||
50 | /* argv and argc to pass to fuse, filled in by main and getopt_configure_argv */ | ||
51 | char **fuse_argv; | ||
52 | int fuse_argc; | ||
53 | |||
54 | /* Root directory entry, currently used by the dirent cache when asked for / */ | ||
55 | int root_fd; | ||
56 | struct dirent *root_de; | ||
57 | |||
58 | int getopt_configure_argv(GNUNET_CommandLineProcessorContext *ctx, void *scls, | ||
59 | const char *cmdLineOption, const char *value) | ||
60 | { | ||
61 | (void)ctx; | ||
62 | (void)scls; | ||
63 | (void)cmdLineOption; | ||
64 | |||
65 | fuse_argv[fuse_argc] = (char *)value; | ||
66 | fuse_argc++; | ||
67 | fuse_argv[fuse_argc] = NULL; | ||
68 | return GNUNET_OK; | ||
69 | } | ||
70 | |||
71 | static struct fuse_operations fops = | ||
72 | { | ||
73 | .getattr = gn_getattr, | ||
74 | .mknod = gn_mknod, | ||
75 | .mkdir = gn_mkdir, | ||
76 | .unlink = gn_unlink, | ||
77 | .rmdir = gn_rmdir, | ||
78 | .rename = gn_rename, | ||
79 | .truncate = gn_truncate, | ||
80 | .open = gn_open, | ||
81 | .read = gn_read, | ||
82 | .write = gn_write, | ||
83 | .release = gn_release, | ||
84 | .readdir = gn_readdir, | ||
85 | .utimens = gn_utimens, | ||
86 | }; | ||
87 | |||
88 | static struct GNUNET_CommandLineOption gn_options[] = | ||
89 | { | ||
90 | GNUNET_COMMAND_LINE_OPTION_HELP("GNUnet filesystem"), | ||
91 | GNUNET_COMMAND_LINE_OPTION_CFG_FILE(&cfgFilename), /* -c */ | ||
92 | GNUNET_COMMAND_LINE_OPTION_LOGGING, /* -L */ | ||
93 | { 'l', "logfile", "FILE", "set logfile name", 1, | ||
94 | &GNUNET_getopt_configure_set_string, &cfgLogfile }, | ||
95 | { 'a', "anonymity", "LEVEL", | ||
96 | "set the desired LEVEL of sender-anonymity", 1, | ||
97 | &GNUNET_getopt_configure_set_uint, &anonymity }, | ||
98 | { 'p', "priority", "LEVEL", | ||
99 | "set the desired LEVEL of priority", 1, | ||
100 | &GNUNET_getopt_configure_set_uint, &priority }, | ||
101 | { 'u', "uri-files", NULL, "Make .uri files visible", 0, | ||
102 | &GNUNET_getopt_configure_set_one, &uri_files }, | ||
103 | { 'x', "Xfuse", NULL, "Escape fuse option", 1, | ||
104 | &getopt_configure_argv, NULL }, | ||
105 | GNUNET_COMMAND_LINE_OPTION_END, | ||
106 | }; | ||
107 | |||
108 | int main(int argc, char **argv) | ||
109 | { | ||
110 | int i, ret; | ||
111 | struct GNUNET_ECRS_URI *uri; | ||
112 | char *buf; | ||
113 | |||
114 | /* Initialize fuse options */ | ||
115 | fuse_argc = 1; | ||
116 | fuse_argv = GNUNET_malloc(sizeof(char *) * argc); | ||
117 | fuse_argv[0] = argv[0]; | ||
118 | fuse_argv[1] = NULL; | ||
119 | |||
120 | /* Parse gnunet options */ | ||
121 | i = GNUNET_init(argc, argv, | ||
122 | "gnunet-fuse [OPTIONS] <URI FILE> <MOUNT-POINT>", | ||
123 | &cfgFilename, gn_options, &ectx, &cfg); | ||
124 | if(i == -1) | ||
125 | { | ||
126 | ret = -1; | ||
127 | goto quit; | ||
128 | } | ||
129 | |||
130 | /* Set up log file */ | ||
131 | GNUNET_disk_directory_create_for_file(ectx, cfgLogfile); | ||
132 | ectx = GNUNET_GE_create_context_logfile(ectx, GNUNET_GE_ALL, cfgLogfile, NULL, GNUNET_YES, 0); | ||
133 | GNUNET_GE_setDefaultContext(ectx); | ||
134 | |||
135 | /* There should be exactly two extra arguments */ | ||
136 | if(i + 2 != argc) | ||
137 | { | ||
138 | printf("You must specify a URI to mount and mountpoint\n"); | ||
139 | ret = -1; | ||
140 | goto quit; | ||
141 | } | ||
142 | |||
143 | /* Set URI as our root directory entry */ | ||
144 | gn_dirent_cache_init(); | ||
145 | if(GNUNET_disk_file_test(ectx, argv[i]) == GNUNET_YES) | ||
146 | { | ||
147 | unsigned long long len; | ||
148 | char *uribuf; | ||
149 | |||
150 | root_fd = GNUNET_disk_file_open(ectx, argv[i], O_RDWR | O_SYNC); | ||
151 | if(root_fd == -1) | ||
152 | { | ||
153 | printf("Unable to open URI file: %s\n", argv[i]); | ||
154 | ret = -1; | ||
155 | goto quit; | ||
156 | } | ||
157 | if(GNUNET_disk_file_size(ectx, argv[i], &len, GNUNET_YES) == GNUNET_SYSERR) | ||
158 | { | ||
159 | printf("Unable to determine URI file size\n"); | ||
160 | ret = -1; | ||
161 | goto out_close_root; | ||
162 | } | ||
163 | uribuf = GNUNET_malloc(len + 1); | ||
164 | read(root_fd, uribuf, len); | ||
165 | uribuf[len] = '\0'; | ||
166 | uri = GNUNET_ECRS_string_to_uri(ectx, uribuf); | ||
167 | GNUNET_free(uribuf); | ||
168 | if(uri == NULL) | ||
169 | { | ||
170 | printf("URI cannot be parsed\n"); | ||
171 | ret = -1; | ||
172 | goto out_close_root; | ||
173 | } | ||
174 | if(!GNUNET_ECRS_uri_test_chk(uri)) | ||
175 | { | ||
176 | struct GNUNET_ECRS_URI *new_uri; | ||
177 | |||
178 | new_uri = GNUNET_ECRS_uri_get_content_uri_from_loc(uri); | ||
179 | if(new_uri == NULL) | ||
180 | { | ||
181 | printf("URI cannot be mounted\n"); | ||
182 | ret = -1; | ||
183 | goto out_close_root; | ||
184 | } | ||
185 | GNUNET_ECRS_uri_destroy(uri); | ||
186 | uri = new_uri; | ||
187 | } | ||
188 | root_de = gn_dirent_new(G_DIR_SEPARATOR_S, uri, NULL, DE_DIR); | ||
189 | GNUNET_ECRS_uri_destroy(uri); | ||
190 | } | ||
191 | else | ||
192 | { | ||
193 | /* In the case where the file does not exist, let's mount an | ||
194 | * empty directory and create the file to store its URI */ | ||
195 | root_fd = GNUNET_disk_file_open(ectx, argv[i], O_RDWR | O_SYNC | ||
196 | | O_CREAT, 0666); | ||
197 | if(root_fd == -1) | ||
198 | { | ||
199 | printf("Unable to create URI file: %s\n", argv[i]); | ||
200 | ret = -1; | ||
201 | goto quit; | ||
202 | } | ||
203 | root_de = gn_dirent_new(G_DIR_SEPARATOR_S, NULL, NULL, DE_DIR); | ||
204 | } | ||
205 | |||
206 | /* Add mount point as the last fuse option */ | ||
207 | fuse_argv = GNUNET_realloc(fuse_argv, sizeof(char *) * (fuse_argc + 2)); | ||
208 | fuse_argv[fuse_argc] = argv[i + 1]; | ||
209 | fuse_argc++; | ||
210 | fuse_argv[fuse_argc] = NULL; | ||
211 | |||
212 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_USER | GNUNET_GE_DEBUG, "calling fuse_main\n"); | ||
213 | ret = fuse_main(fuse_argc, fuse_argv, &fops, NULL); | ||
214 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_USER | GNUNET_GE_DEBUG, "fuse_main returned\n"); | ||
215 | |||
216 | /* Save root uri */ | ||
217 | closing = 1; | ||
218 | buf = gn_get_special_file(G_DIR_SEPARATOR_S URI_FILE); | ||
219 | if(buf != NULL) | ||
220 | { | ||
221 | ftruncate(root_fd, 0); | ||
222 | lseek(root_fd, SEEK_SET, 0); | ||
223 | write(root_fd, buf, strlen(buf)); | ||
224 | GNUNET_free(buf); | ||
225 | } | ||
226 | out_close_root: | ||
227 | GNUNET_disk_file_close(ectx, argv[i], root_fd); | ||
228 | quit: | ||
229 | GNUNET_free(fuse_argv); | ||
230 | GNUNET_fini(ectx, cfg); | ||
231 | return ret; | ||
232 | } | ||
diff --git a/gnunet-fuse-0.8/mkdir.c b/gnunet-fuse-0.8/mkdir.c deleted file mode 100644 index 472c5cd..0000000 --- a/gnunet-fuse-0.8/mkdir.c +++ /dev/null | |||
@@ -1,71 +0,0 @@ | |||
1 | /* | ||
2 | * mkdir.c - FUSE mkdir function | ||
3 | * | ||
4 | * This file is part of gnunet-fuse. | ||
5 | * Copyright (C) 2007 David Barksdale | ||
6 | * | ||
7 | * gnunet-fuse is free software; you can redistribute it and/or | ||
8 | * modify if under the terms of version 2 of the GNU General Public License | ||
9 | * as published by the Free Software Foundation. | ||
10 | * | ||
11 | * gnunet-fuse is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | */ | ||
20 | |||
21 | #include <string.h> | ||
22 | #include <errno.h> | ||
23 | #include <sys/types.h> | ||
24 | #include <sys/stat.h> | ||
25 | #include <fuse.h> | ||
26 | #include "gnfs.h" | ||
27 | |||
28 | int gn_mkdir(const char *path, mode_t mode) | ||
29 | { | ||
30 | struct dirent *de, *newde; | ||
31 | struct GNUNET_MetaData *meta; | ||
32 | char *parent, *file; | ||
33 | int ret; | ||
34 | |||
35 | (void)mode; | ||
36 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_DEBUG, "%s: for '%s'\n", | ||
37 | __FUNCTION__, path); | ||
38 | |||
39 | /* Check for special file */ | ||
40 | if(gn_exists_special_file(path)) | ||
41 | return -EEXIST; | ||
42 | |||
43 | /* Check for existing file */ | ||
44 | de = gn_dirent_find(path); | ||
45 | if(de != NULL) | ||
46 | { | ||
47 | gn_dirent_put(de); | ||
48 | return -EEXIST; | ||
49 | } | ||
50 | |||
51 | /* Create new directory */ | ||
52 | parent = gn_dirname(path, &file); | ||
53 | de = gn_dirent_find(parent); | ||
54 | if(de == NULL) | ||
55 | { | ||
56 | GNUNET_free(parent); | ||
57 | return -ENOENT; | ||
58 | } | ||
59 | meta = GNUNET_meta_data_create(); | ||
60 | GNUNET_meta_data_insert(meta, EXTRACTOR_FILENAME, file); | ||
61 | GNUNET_meta_data_insert(meta, EXTRACTOR_MIMETYPE, GNUNET_DIRECTORY_MIME); | ||
62 | newde = gn_dirent_new(path, NULL, meta, DE_DIR); | ||
63 | GNUNET_meta_data_destroy(meta); | ||
64 | ret = gn_directory_insert(de, newde); | ||
65 | gn_dirent_put(de); | ||
66 | gn_dirent_put(newde); | ||
67 | GNUNET_free(parent); | ||
68 | if(ret == -1) | ||
69 | return -EIO; | ||
70 | return 0; | ||
71 | } | ||
diff --git a/gnunet-fuse-0.8/mknod.c b/gnunet-fuse-0.8/mknod.c deleted file mode 100644 index e4119de..0000000 --- a/gnunet-fuse-0.8/mknod.c +++ /dev/null | |||
@@ -1,77 +0,0 @@ | |||
1 | /* | ||
2 | * mknod.c - FUSE mknod function | ||
3 | * | ||
4 | * This file is part of gnunet-fuse. | ||
5 | * Copyright (C) 2007 David Barksdale | ||
6 | * | ||
7 | * gnunet-fuse is free software; you can redistribute it and/or | ||
8 | * modify if under the terms of version 2 of the GNU General Public License | ||
9 | * as published by the Free Software Foundation. | ||
10 | * | ||
11 | * gnunet-fuse is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | */ | ||
20 | |||
21 | #include <string.h> | ||
22 | #include <errno.h> | ||
23 | #include <sys/types.h> | ||
24 | #include <sys/stat.h> | ||
25 | #include <fuse.h> | ||
26 | #include "gnfs.h" | ||
27 | |||
28 | int gn_mknod(const char *path, mode_t mode, dev_t rdev) | ||
29 | { | ||
30 | struct dirent *de, *newde; | ||
31 | struct GNUNET_ECRS_URI *uri; | ||
32 | struct GNUNET_MetaData *meta; | ||
33 | char *parent, *file; | ||
34 | int ret; | ||
35 | |||
36 | (void)rdev; | ||
37 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_DEBUG, "%s: for '%s'\n", | ||
38 | __FUNCTION__, path); | ||
39 | |||
40 | /* We only support regular files */ | ||
41 | if(!S_ISREG(mode)) | ||
42 | return -ENOTSUP; | ||
43 | |||
44 | /* Check for special file */ | ||
45 | if(gn_exists_special_file(path)) | ||
46 | return -EEXIST; | ||
47 | |||
48 | /* Check for existing file */ | ||
49 | de = gn_dirent_find(path); | ||
50 | if(de != NULL) | ||
51 | { | ||
52 | gn_dirent_put(de); | ||
53 | return -EEXIST; | ||
54 | } | ||
55 | |||
56 | /* Create new file */ | ||
57 | parent = gn_dirname(path, &file); | ||
58 | de = gn_dirent_find(parent); | ||
59 | if(de == NULL) | ||
60 | { | ||
61 | GNUNET_free(parent); | ||
62 | return -ENOENT; | ||
63 | } | ||
64 | uri = GNUNET_ECRS_string_to_uri(ectx, GN_EMPTY_FILE_URI); | ||
65 | meta = GNUNET_meta_data_create(); | ||
66 | GNUNET_meta_data_insert(meta, EXTRACTOR_FILENAME, file); | ||
67 | GNUNET_free(parent); | ||
68 | newde = gn_dirent_new(path, uri, meta, DE_FILE); | ||
69 | GNUNET_meta_data_destroy(meta); | ||
70 | GNUNET_ECRS_uri_destroy(uri); | ||
71 | ret = gn_directory_insert(de, newde); | ||
72 | gn_dirent_put(de); | ||
73 | gn_dirent_put(newde); | ||
74 | if(ret == -1) | ||
75 | return -EIO; | ||
76 | return 0; | ||
77 | } | ||
diff --git a/gnunet-fuse-0.8/open.c b/gnunet-fuse-0.8/open.c deleted file mode 100644 index 738b21f..0000000 --- a/gnunet-fuse-0.8/open.c +++ /dev/null | |||
@@ -1,60 +0,0 @@ | |||
1 | /* | ||
2 | * open.c - FUSE open function | ||
3 | * | ||
4 | * This file is part of gnunet-fuse. | ||
5 | * Copyright (C) 2007 David Barksdale | ||
6 | * | ||
7 | * gnunet-fuse is free software; you can redistribute it and/or | ||
8 | * modify if under the terms of version 2 of the GNU General Public License | ||
9 | * as published by the Free Software Foundation. | ||
10 | * | ||
11 | * gnunet-fuse is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | */ | ||
20 | |||
21 | #include <string.h> | ||
22 | #include <errno.h> | ||
23 | #include <sys/types.h> | ||
24 | #include <sys/stat.h> | ||
25 | #include <fuse.h> | ||
26 | #include "gnfs.h" | ||
27 | |||
28 | int gn_open(const char *path, struct fuse_file_info *fi) | ||
29 | { | ||
30 | struct dirent *de; | ||
31 | |||
32 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_DEBUG, "%s: for '%s'\n", | ||
33 | __FUNCTION__, path); | ||
34 | |||
35 | /* Check for special file */ | ||
36 | if(gn_exists_special_file(path)) | ||
37 | { | ||
38 | if(fi->flags & O_WRONLY) | ||
39 | return -EACCES; | ||
40 | if((fi->flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) | ||
41 | return -EEXIST; | ||
42 | return 0; | ||
43 | } | ||
44 | |||
45 | /* Check for existing file */ | ||
46 | de = gn_dirent_find(path); | ||
47 | if(de == NULL) | ||
48 | return -ENOENT; | ||
49 | if(de->de_type != DE_FILE) | ||
50 | { | ||
51 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_DEBUG, | ||
52 | "%s: not a file\n", __FUNCTION__); | ||
53 | gn_dirent_put(de); | ||
54 | return -ENOENT; | ||
55 | } | ||
56 | gn_dirent_put(de); | ||
57 | if((fi->flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) | ||
58 | return -EEXIST; | ||
59 | return 0; | ||
60 | } | ||
diff --git a/gnunet-fuse-0.8/read.c b/gnunet-fuse-0.8/read.c deleted file mode 100644 index 8aa6000..0000000 --- a/gnunet-fuse-0.8/read.c +++ /dev/null | |||
@@ -1,168 +0,0 @@ | |||
1 | /* | ||
2 | * read.c - FUSE read function | ||
3 | * | ||
4 | * This file is part of gnunet-fuse. | ||
5 | * Copyright (C) 2007 David Barksdale | ||
6 | * | ||
7 | * gnunet-fuse is free software; you can redistribute it and/or | ||
8 | * modify if under the terms of version 2 of the GNU General Public License | ||
9 | * as published by the Free Software Foundation. | ||
10 | * | ||
11 | * gnunet-fuse is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | */ | ||
20 | |||
21 | #define _XOPEN_SOURCE 500 | ||
22 | #include <string.h> | ||
23 | #include <errno.h> | ||
24 | #include <unistd.h> | ||
25 | #include <fuse.h> | ||
26 | #include "gnfs.h" | ||
27 | |||
28 | struct read_data | ||
29 | { | ||
30 | char *buf; | ||
31 | guint size; | ||
32 | guint64 offset; | ||
33 | }; | ||
34 | |||
35 | static void dpcb(unsigned long long totalBytes, | ||
36 | unsigned long long completedBytes, GNUNET_CronTime eta, | ||
37 | unsigned long long lastBlockOffset, const char *lastBlock, | ||
38 | unsigned int lastBlockSize, void *cls) | ||
39 | { | ||
40 | struct read_data *d = cls; | ||
41 | guint64 block_end = lastBlockOffset + lastBlockSize; | ||
42 | guint64 buf_end = d->offset + d->size; | ||
43 | |||
44 | (void)totalBytes; | ||
45 | (void)completedBytes; | ||
46 | (void)eta; | ||
47 | |||
48 | /* Check if this block is entirely before the buffer */ | ||
49 | if(block_end < d->offset) | ||
50 | return; | ||
51 | |||
52 | /* Check if this block is entirely after the buffer */ | ||
53 | if(lastBlockOffset > buf_end) | ||
54 | return; | ||
55 | |||
56 | /* Chop off residue at beginning of block */ | ||
57 | if(lastBlockOffset < d->offset) | ||
58 | { | ||
59 | lastBlock += d->offset - lastBlockOffset; | ||
60 | lastBlockSize -= d->offset - lastBlockOffset; | ||
61 | lastBlockOffset = d->offset; | ||
62 | } | ||
63 | /* Chop off residue at end of block */ | ||
64 | if(block_end > buf_end) | ||
65 | { | ||
66 | lastBlockSize -= block_end - buf_end; | ||
67 | } | ||
68 | memcpy(d->buf + (lastBlockOffset - d->offset), lastBlock, | ||
69 | lastBlockSize); | ||
70 | } | ||
71 | |||
72 | static int tt(void *cls) | ||
73 | { | ||
74 | (void)cls; | ||
75 | return fuse_interrupted() ? GNUNET_SYSERR : GNUNET_OK; | ||
76 | } | ||
77 | |||
78 | int gn_read(const char *path, char *buf, size_t size, off_t offset, | ||
79 | struct fuse_file_info *fi) | ||
80 | { | ||
81 | struct dirent *de; | ||
82 | struct read_data d; | ||
83 | char *special; | ||
84 | int ret; | ||
85 | ssize_t slen; | ||
86 | guint64 len; | ||
87 | |||
88 | (void)fi; | ||
89 | |||
90 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_DEBUG, | ||
91 | "%s: called for '%s' %u bytes %lld offset\n", __FUNCTION__, | ||
92 | path, size, offset); | ||
93 | |||
94 | /* Check for special file */ | ||
95 | special = gn_get_special_file(path); | ||
96 | if(special != NULL) | ||
97 | { | ||
98 | slen = strlen(special); | ||
99 | if(offset >= slen) | ||
100 | { | ||
101 | GNUNET_free(special); | ||
102 | return 0; | ||
103 | } | ||
104 | if( ((ssize_t) (offset + size)) > slen) | ||
105 | { | ||
106 | size = slen - offset; | ||
107 | } | ||
108 | memcpy(buf, special + offset, size); | ||
109 | GNUNET_free(special); | ||
110 | return size; | ||
111 | } | ||
112 | |||
113 | /* Lookup dirent for path */ | ||
114 | de = gn_dirent_find(path); | ||
115 | if(de == NULL) | ||
116 | { | ||
117 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_DEBUG, | ||
118 | "%s: file not found\n", __FUNCTION__); | ||
119 | return -ENOENT; | ||
120 | } | ||
121 | if(de->de_type != DE_FILE) | ||
122 | { | ||
123 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_DEBUG, | ||
124 | "%s: not a file\n", __FUNCTION__); | ||
125 | size = -ENOENT; | ||
126 | goto out; | ||
127 | } | ||
128 | if(GNUNET_semaphore_down(de->de_sema, GNUNET_YES) == GNUNET_SYSERR) | ||
129 | { | ||
130 | size = -EIO; | ||
131 | goto out; | ||
132 | } | ||
133 | if(de->de_cached) | ||
134 | { | ||
135 | slen = pread(de->de_fd, buf, size, offset); | ||
136 | if(slen == -1) | ||
137 | size = -errno; | ||
138 | else | ||
139 | size = slen; | ||
140 | goto out_sema_up; | ||
141 | } | ||
142 | len = GNUNET_ECRS_uri_get_file_size(de->de_fi.uri); | ||
143 | if((guint64)offset >= len) | ||
144 | { | ||
145 | size = 0; | ||
146 | goto out_sema_up; | ||
147 | } | ||
148 | if((guint64)offset + size > len) | ||
149 | { | ||
150 | size = len - offset; | ||
151 | } | ||
152 | d.buf = buf; | ||
153 | d.size = size; | ||
154 | d.offset = offset; | ||
155 | ret = GNUNET_ECRS_file_download_partial(ectx, cfg, de->de_fi.uri, "/dev/null", | ||
156 | offset, size, anonymity, GNUNET_YES, dpcb, &d, tt, NULL); | ||
157 | if(ret != GNUNET_OK) | ||
158 | { | ||
159 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_USER | GNUNET_GE_ERROR, | ||
160 | "%s: failed to download file\n", __FUNCTION__); | ||
161 | size = -ENODATA; | ||
162 | } | ||
163 | out_sema_up: | ||
164 | GNUNET_semaphore_up(de->de_sema); | ||
165 | out: | ||
166 | gn_dirent_put(de); | ||
167 | return size; | ||
168 | } | ||
diff --git a/gnunet-fuse-0.8/readdir.c b/gnunet-fuse-0.8/readdir.c deleted file mode 100644 index a85db9b..0000000 --- a/gnunet-fuse-0.8/readdir.c +++ /dev/null | |||
@@ -1,113 +0,0 @@ | |||
1 | /* | ||
2 | * readdir.c - FUSE readdir function | ||
3 | * | ||
4 | * This file is part of gnunet-fuse. | ||
5 | * Copyright (C) 2007 David Barksdale | ||
6 | * | ||
7 | * gnunet-fuse is free software; you can redistribute it and/or | ||
8 | * modify if under the terms of version 2 of the GNU General Public License | ||
9 | * as published by the Free Software Foundation. | ||
10 | * | ||
11 | * gnunet-fuse is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | */ | ||
20 | |||
21 | #define _LARGEFILE64_SOURCE | ||
22 | #include <sys/types.h> | ||
23 | #include <sys/mman.h> | ||
24 | #include <fcntl.h> | ||
25 | #include <unistd.h> | ||
26 | #include <string.h> | ||
27 | #include <errno.h> | ||
28 | #include <glib.h> | ||
29 | #include <fuse.h> | ||
30 | #include <GNUnet/gnunet_ecrs_lib.h> | ||
31 | #include "gnfs.h" | ||
32 | |||
33 | struct readdir_callback_data | ||
34 | { | ||
35 | fuse_fill_dir_t filler; | ||
36 | void *buf; | ||
37 | const char *prefix; | ||
38 | }; | ||
39 | |||
40 | static int readdir_callback(struct dirent *de, void *data) | ||
41 | { | ||
42 | struct readdir_callback_data *d = data; | ||
43 | |||
44 | (void)de; | ||
45 | |||
46 | if(d->prefix != NULL) | ||
47 | { | ||
48 | char *buf = GNUNET_malloc(strlen(d->prefix) + strlen(de->de_basename) | ||
49 | + 1); | ||
50 | |||
51 | sprintf(buf, "%s%s", d->prefix, de->de_basename); | ||
52 | d->filler(d->buf, buf, NULL, 0); | ||
53 | GNUNET_free(buf); | ||
54 | } | ||
55 | else | ||
56 | { | ||
57 | d->filler(d->buf, de->de_basename, NULL, 0); | ||
58 | } | ||
59 | return GNUNET_OK; | ||
60 | } | ||
61 | |||
62 | int gn_readdir(const char *path, void *buf, fuse_fill_dir_t filler, | ||
63 | off_t offset, struct fuse_file_info *fi) | ||
64 | { | ||
65 | struct dirent *de; | ||
66 | int ret = 0; | ||
67 | struct readdir_callback_data d; | ||
68 | |||
69 | (void)offset; | ||
70 | (void)fi; | ||
71 | |||
72 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_DEBUG, "readdir for '%s'\n", | ||
73 | path); | ||
74 | de = gn_dirent_find(path); | ||
75 | if(de == NULL) | ||
76 | { | ||
77 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_DEBUG, | ||
78 | "readdir: file not found\n"); | ||
79 | return -ENOENT; | ||
80 | } | ||
81 | if(de->de_type != DE_DIR) | ||
82 | { | ||
83 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_DEBUG, | ||
84 | "readdir: not a directory\n"); | ||
85 | gn_dirent_put(de); | ||
86 | ret = -ENOENT; | ||
87 | goto out; | ||
88 | } | ||
89 | filler(buf, ".", NULL, 0); | ||
90 | filler(buf, "..", NULL, 0); | ||
91 | if(uri_files) | ||
92 | { | ||
93 | filler(buf, URI_FILE, NULL, 0); | ||
94 | d.filler = filler; | ||
95 | d.buf = buf; | ||
96 | d.prefix = ".uri."; | ||
97 | ret = gn_directory_foreach(de, readdir_callback, &d); | ||
98 | if(ret == -1) | ||
99 | { | ||
100 | ret = -ENOENT; | ||
101 | goto out; | ||
102 | } | ||
103 | } | ||
104 | d.filler = filler; | ||
105 | d.buf = buf; | ||
106 | d.prefix = NULL; | ||
107 | ret = gn_directory_foreach(de, readdir_callback, &d); | ||
108 | if(ret == -1) | ||
109 | ret = -ENOENT; | ||
110 | out: | ||
111 | gn_dirent_put(de); | ||
112 | return ret; | ||
113 | } | ||
diff --git a/gnunet-fuse-0.8/release.c b/gnunet-fuse-0.8/release.c deleted file mode 100644 index 29254f9..0000000 --- a/gnunet-fuse-0.8/release.c +++ /dev/null | |||
@@ -1,63 +0,0 @@ | |||
1 | /* | ||
2 | * release.c - FUSE release function | ||
3 | * | ||
4 | * This file is part of gnunet-fuse. | ||
5 | * Copyright (C) 2007 David Barksdale | ||
6 | * | ||
7 | * gnunet-fuse is free software; you can redistribute it and/or | ||
8 | * modify if under the terms of version 2 of the GNU General Public License | ||
9 | * as published by the Free Software Foundation. | ||
10 | * | ||
11 | * gnunet-fuse is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | */ | ||
20 | |||
21 | #include <fuse.h> | ||
22 | #include "gnfs.h" | ||
23 | |||
24 | int gn_release(const char *path, struct fuse_file_info *fi) | ||
25 | { | ||
26 | struct dirent *de; | ||
27 | int dirty = GN_UNLOCK_CLEAN; | ||
28 | |||
29 | (void)fi; | ||
30 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_DEBUG, "%s: for '%s'\n", | ||
31 | __FUNCTION__, path); | ||
32 | |||
33 | /* Don't do anything for special files */ | ||
34 | if(gn_exists_special_file(path)) | ||
35 | return 0; | ||
36 | |||
37 | /* If it doesn't exist we don't care */ | ||
38 | de = gn_dirent_find(path); | ||
39 | if(de == NULL) | ||
40 | return 0; | ||
41 | if(de->de_type != DE_FILE) | ||
42 | { | ||
43 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_DEBUG, | ||
44 | "%s: not a file\n", __FUNCTION__); | ||
45 | gn_dirent_put(de); | ||
46 | return 0; | ||
47 | } | ||
48 | |||
49 | /* Lock our path */ | ||
50 | if(gn_lock_path(de) == -1) | ||
51 | return 0; | ||
52 | |||
53 | /* Un-dirty ourselfs */ | ||
54 | if(gn_file_upload_locked(de) == 0) | ||
55 | { | ||
56 | /* Now we must mark every containing directory dirty */ | ||
57 | dirty = GN_UNLOCK_ANCESTORS_DIRTY; | ||
58 | } | ||
59 | |||
60 | gn_unlock_path(de, dirty); | ||
61 | gn_dirent_put(de); | ||
62 | return 0; | ||
63 | } | ||
diff --git a/gnunet-fuse-0.8/rename.c b/gnunet-fuse-0.8/rename.c deleted file mode 100644 index d8e6e3b..0000000 --- a/gnunet-fuse-0.8/rename.c +++ /dev/null | |||
@@ -1,135 +0,0 @@ | |||
1 | /* | ||
2 | * rename.c - FUSE rename function | ||
3 | * | ||
4 | * This file is part of gnunet-fuse. | ||
5 | * Copyright (C) 2007 David Barksdale | ||
6 | * | ||
7 | * gnunet-fuse is free software; you can redistribute it and/or | ||
8 | * modify if under the terms of version 2 of the GNU General Public License | ||
9 | * as published by the Free Software Foundation. | ||
10 | * | ||
11 | * gnunet-fuse is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | */ | ||
20 | |||
21 | #include <string.h> | ||
22 | #include <errno.h> | ||
23 | #include <sys/types.h> | ||
24 | #include <sys/stat.h> | ||
25 | #include <fuse.h> | ||
26 | #include "gnfs.h" | ||
27 | |||
28 | static gboolean rename_callback(struct dirent *de, void *data) | ||
29 | { | ||
30 | int *empty = data; | ||
31 | |||
32 | (void)de; | ||
33 | *empty = 0; | ||
34 | return 1; | ||
35 | } | ||
36 | |||
37 | int gn_rename(const char *from, const char *to) | ||
38 | { | ||
39 | struct dirent *from_de, *to_de, *from_parent_de, *to_parent_de; | ||
40 | char *from_parent, *from_file, *to_parent, *to_file; | ||
41 | int ret = 0, empty = 1; | ||
42 | |||
43 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_DEBUG, "%s: '%s' to '%s'\n", | ||
44 | __FUNCTION__, from, to); | ||
45 | |||
46 | /* Check for special file */ | ||
47 | if(gn_exists_special_file(from) || gn_exists_special_file(to)) | ||
48 | return -EACCES; | ||
49 | |||
50 | /* Make sure 'from' exists */ | ||
51 | from_de = gn_dirent_find(from); | ||
52 | if(from_de == NULL) | ||
53 | return -ENOENT; | ||
54 | |||
55 | /* We need to check some things before we remove 'from' */ | ||
56 | to_de = gn_dirent_find(to); | ||
57 | if(to_de != NULL) | ||
58 | { | ||
59 | if(from_de->de_type == DE_FILE && to_de->de_type == DE_DIR) | ||
60 | { | ||
61 | ret = -EISDIR; | ||
62 | goto out; | ||
63 | } | ||
64 | if(from_de->de_type == DE_DIR && to_de->de_type == DE_FILE) | ||
65 | { | ||
66 | ret = -ENOTDIR; | ||
67 | goto out; | ||
68 | } | ||
69 | if(to_de->de_type == DE_DIR) | ||
70 | { | ||
71 | gn_directory_foreach(to_de, rename_callback, &empty); | ||
72 | if(!empty) | ||
73 | { | ||
74 | ret = -ENOTEMPTY; | ||
75 | goto out; | ||
76 | } | ||
77 | } | ||
78 | } | ||
79 | |||
80 | /* Now we can remove the 'from' */ | ||
81 | from_parent = gn_dirname(from, &from_file); | ||
82 | from_parent_de = gn_dirent_find(from_parent); | ||
83 | GNUNET_free(from_parent); | ||
84 | if(from_parent_de == NULL) | ||
85 | { | ||
86 | ret = -ENOENT; | ||
87 | goto out; | ||
88 | } | ||
89 | gn_directory_remove(from_parent_de, from_de); | ||
90 | gn_dirent_put(from_parent_de); | ||
91 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_DEBUG, "%s: removed '%s'\n", | ||
92 | __FUNCTION__, from); | ||
93 | |||
94 | /* Modify our path */ | ||
95 | gn_dirent_path_set(from_de, to); | ||
96 | |||
97 | /* Replace the 'to' */ | ||
98 | to_parent = gn_dirname(to, &to_file); | ||
99 | to_parent_de = gn_dirent_find(to_parent); | ||
100 | GNUNET_free(to_parent); | ||
101 | if(to_parent_de == NULL) | ||
102 | { | ||
103 | ret = -EIO; | ||
104 | goto out; | ||
105 | } | ||
106 | |||
107 | /* We should have some kind of directory_remove_insert for atomicity */ | ||
108 | if(to_de != NULL) | ||
109 | { | ||
110 | if(gn_directory_remove(to_parent_de, to_de) == -1) | ||
111 | { | ||
112 | gn_dirent_put(to_parent_de); | ||
113 | ret = -EIO; | ||
114 | goto out; | ||
115 | } | ||
116 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_DEBUG, | ||
117 | "%s: removed '%s'\n", __FUNCTION__, to); | ||
118 | } | ||
119 | if(gn_directory_insert(to_parent_de, from_de) == -1) | ||
120 | { | ||
121 | gn_dirent_put(to_parent_de); | ||
122 | ret = -EIO; | ||
123 | goto out; | ||
124 | } | ||
125 | gn_dirent_put(to_parent_de); | ||
126 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_DEBUG, | ||
127 | "%s: inserted '%s'\n", __FUNCTION__, to); | ||
128 | |||
129 | out: | ||
130 | if(to_de != NULL) | ||
131 | gn_dirent_put(to_de); | ||
132 | if(from_de != NULL) | ||
133 | gn_dirent_put(from_de); | ||
134 | return ret; | ||
135 | } | ||
diff --git a/gnunet-fuse-0.8/rmdir.c b/gnunet-fuse-0.8/rmdir.c deleted file mode 100644 index 0eea211..0000000 --- a/gnunet-fuse-0.8/rmdir.c +++ /dev/null | |||
@@ -1,78 +0,0 @@ | |||
1 | /* | ||
2 | * rmdir.c - FUSE rmdir function | ||
3 | * | ||
4 | * This file is part of gnunet-fuse. | ||
5 | * Copyright (C) 2007 David Barksdale | ||
6 | * | ||
7 | * gnunet-fuse is free software; you can redistribute it and/or | ||
8 | * modify if under the terms of version 2 of the GNU General Public License | ||
9 | * as published by the Free Software Foundation. | ||
10 | * | ||
11 | * gnunet-fuse is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | */ | ||
20 | |||
21 | #include <string.h> | ||
22 | #include <errno.h> | ||
23 | #include <sys/types.h> | ||
24 | #include <sys/stat.h> | ||
25 | #include <fuse.h> | ||
26 | #include "gnfs.h" | ||
27 | |||
28 | static gboolean rmdir_callback(struct dirent *de, void *data) | ||
29 | { | ||
30 | int *empty = data; | ||
31 | |||
32 | (void)de; | ||
33 | *empty = 0; | ||
34 | return 1; | ||
35 | } | ||
36 | |||
37 | int gn_rmdir(const char *path) | ||
38 | { | ||
39 | struct dirent *de, *dechild; | ||
40 | char *parent, *file; | ||
41 | int ret, empty = 1; | ||
42 | |||
43 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_DEBUG, "%s: for '%s'\n", | ||
44 | __FUNCTION__, path); | ||
45 | |||
46 | /* Check for special file */ | ||
47 | if(gn_exists_special_file(path)) | ||
48 | return -ENOTDIR; | ||
49 | |||
50 | /* Check for existing file */ | ||
51 | dechild = gn_dirent_find(path); | ||
52 | if(dechild == NULL) | ||
53 | return -ENOENT; | ||
54 | |||
55 | /* Can't rmdir a non-empty directory */ | ||
56 | gn_directory_foreach(dechild, rmdir_callback, &empty); | ||
57 | if(!empty) | ||
58 | { | ||
59 | gn_dirent_put(dechild); | ||
60 | return -ENOTEMPTY; | ||
61 | } | ||
62 | |||
63 | /* Remove directory */ | ||
64 | parent = gn_dirname(path, &file); | ||
65 | de = gn_dirent_find(parent); | ||
66 | GNUNET_free(parent); | ||
67 | if(de == NULL) | ||
68 | { | ||
69 | gn_dirent_put(dechild); | ||
70 | return -ENOENT; | ||
71 | } | ||
72 | ret = gn_directory_remove(de, dechild); | ||
73 | gn_dirent_put(dechild); | ||
74 | gn_dirent_put(de); | ||
75 | if(ret == -1) | ||
76 | return -EIO; | ||
77 | return 0; | ||
78 | } | ||
diff --git a/gnunet-fuse-0.8/special_file.c b/gnunet-fuse-0.8/special_file.c deleted file mode 100644 index 592f2cc..0000000 --- a/gnunet-fuse-0.8/special_file.c +++ /dev/null | |||
@@ -1,159 +0,0 @@ | |||
1 | /* | ||
2 | * special_file.c - special file support (like .uri) | ||
3 | * | ||
4 | * This file is part of gnunet-fuse. | ||
5 | * Copyright (C) 2007 David Barksdale | ||
6 | * | ||
7 | * gnunet-fuse is free software; you can redistribute it and/or | ||
8 | * modify if under the terms of version 2 of the GNU General Public License | ||
9 | * as published by the Free Software Foundation. | ||
10 | * | ||
11 | * gnunet-fuse is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | */ | ||
20 | |||
21 | #include <string.h> | ||
22 | #include <GNUnet/gnunet_util_string.h> | ||
23 | #include <GNUnet/gnunet_ecrs_lib.h> | ||
24 | #include "gnfs.h" | ||
25 | |||
26 | char *gn_dirname(const char *path, char **file) | ||
27 | { | ||
28 | char *parent, *slash; | ||
29 | |||
30 | parent = GNUNET_strdup(path); | ||
31 | slash = strrchr(parent, G_DIR_SEPARATOR); | ||
32 | if(slash != NULL) | ||
33 | { | ||
34 | slash[0] = '\0'; | ||
35 | slash++; | ||
36 | } | ||
37 | if(file != NULL) | ||
38 | *file = slash; | ||
39 | return parent; | ||
40 | } | ||
41 | |||
42 | /* Checks to see if path is the path to a special file */ | ||
43 | int gn_exists_special_file(const char *path) | ||
44 | { | ||
45 | struct dirent *de; | ||
46 | char *file, *parent; | ||
47 | int ret = 0; | ||
48 | |||
49 | parent = gn_dirname(path, &file); | ||
50 | |||
51 | /* Check for special file name */ | ||
52 | if(strcmp(file, URI_FILE) == 0) | ||
53 | { | ||
54 | ret = 1; | ||
55 | } | ||
56 | else if(strncmp(file, URI_FILE ".", URI_LEN + 1) == 0) | ||
57 | { | ||
58 | char *actual_file = GNUNET_malloc(strlen(path)); | ||
59 | |||
60 | /* Return URI of the file named after the .uri. */ | ||
61 | sprintf(actual_file, "%s" G_DIR_SEPARATOR_S "%s", parent, | ||
62 | &file[URI_LEN + 1]); | ||
63 | de = gn_dirent_find(actual_file); | ||
64 | GNUNET_free(actual_file); | ||
65 | if(de == NULL) | ||
66 | goto out; | ||
67 | gn_dirent_put(de); | ||
68 | ret = 1; | ||
69 | } | ||
70 | out: | ||
71 | GNUNET_free(parent); | ||
72 | return ret; | ||
73 | } | ||
74 | |||
75 | /* | ||
76 | * Returns a malloc'd string for a special file, and in the case of .uri files | ||
77 | * will sync it if it's dirty | ||
78 | */ | ||
79 | char *gn_get_special_file(const char *path) | ||
80 | { | ||
81 | struct dirent *de; | ||
82 | char *buf = NULL, *file, *parent; | ||
83 | |||
84 | parent = gn_dirname(path, &file); | ||
85 | |||
86 | /* Check for special file name */ | ||
87 | if(strcmp(file, URI_FILE) == 0) | ||
88 | { | ||
89 | /* Return URI of the 'current' directory */ | ||
90 | de = gn_dirent_find(parent); | ||
91 | if(de == NULL) | ||
92 | goto out; | ||
93 | if(GNUNET_semaphore_down(de->de_sema, GNUNET_YES) == GNUNET_SYSERR) | ||
94 | { | ||
95 | gn_dirent_put(de); | ||
96 | goto out; | ||
97 | } | ||
98 | if(de->de_dirty) | ||
99 | { | ||
100 | if(gn_directory_upload_locked(de) == -1) | ||
101 | { | ||
102 | GNUNET_semaphore_up(de->de_sema); | ||
103 | gn_dirent_put(de); | ||
104 | goto out; | ||
105 | } | ||
106 | } | ||
107 | buf = GNUNET_ECRS_uri_to_string(de->de_fi.uri); | ||
108 | GNUNET_semaphore_up(de->de_sema); | ||
109 | gn_dirent_put(de); | ||
110 | buf = GNUNET_realloc(buf, strlen(buf) + 2); | ||
111 | strcat(buf, "\n"); | ||
112 | } | ||
113 | else if(strncmp(file, URI_FILE ".", URI_LEN + 1) == 0) | ||
114 | { | ||
115 | char *actual_file = GNUNET_malloc(strlen(path)); | ||
116 | |||
117 | /* Return URI of the file named after the .uri. */ | ||
118 | sprintf(actual_file, "%s" G_DIR_SEPARATOR_S "%s", parent, | ||
119 | &file[URI_LEN + 1]); | ||
120 | de = gn_dirent_find(actual_file); | ||
121 | GNUNET_free(actual_file); | ||
122 | if(de == NULL) | ||
123 | goto out; | ||
124 | if(GNUNET_semaphore_down(de->de_sema, GNUNET_YES) == GNUNET_SYSERR) | ||
125 | { | ||
126 | gn_dirent_put(de); | ||
127 | goto out; | ||
128 | } | ||
129 | if(de->de_dirty) | ||
130 | { | ||
131 | if(de->de_type == DE_DIR) | ||
132 | { | ||
133 | if(gn_directory_upload_locked(de) == -1) | ||
134 | { | ||
135 | GNUNET_semaphore_up(de->de_sema); | ||
136 | gn_dirent_put(de); | ||
137 | goto out; | ||
138 | } | ||
139 | } | ||
140 | else | ||
141 | { | ||
142 | if(de->de_fi.uri == NULL) | ||
143 | { | ||
144 | GNUNET_semaphore_up(de->de_sema); | ||
145 | gn_dirent_put(de); | ||
146 | goto out; | ||
147 | } | ||
148 | } | ||
149 | } | ||
150 | buf = GNUNET_ECRS_uri_to_string(de->de_fi.uri); | ||
151 | GNUNET_semaphore_up(de->de_sema); | ||
152 | gn_dirent_put(de); | ||
153 | buf = GNUNET_realloc(buf, strlen(buf) + 2); | ||
154 | strcat(buf, "\n"); | ||
155 | } | ||
156 | out: | ||
157 | GNUNET_free(parent); | ||
158 | return buf; | ||
159 | } | ||
diff --git a/gnunet-fuse-0.8/truncate.c b/gnunet-fuse-0.8/truncate.c deleted file mode 100644 index 14f3340..0000000 --- a/gnunet-fuse-0.8/truncate.c +++ /dev/null | |||
@@ -1,90 +0,0 @@ | |||
1 | /* | ||
2 | * truncate.c - FUSE truncate function | ||
3 | * | ||
4 | * This file is part of gnunet-fuse. | ||
5 | * Copyright (C) 2007 David Barksdale | ||
6 | * | ||
7 | * gnunet-fuse is free software; you can redistribute it and/or | ||
8 | * modify if under the terms of version 2 of the GNU General Public License | ||
9 | * as published by the Free Software Foundation. | ||
10 | * | ||
11 | * gnunet-fuse is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | */ | ||
20 | |||
21 | #include <errno.h> | ||
22 | #include <unistd.h> | ||
23 | #include <fuse.h> | ||
24 | #include "gnfs.h" | ||
25 | |||
26 | int gn_truncate(const char *path, off_t size) | ||
27 | { | ||
28 | struct dirent *de; | ||
29 | int ret = 0, dirty = GN_UNLOCK_CLEAN; | ||
30 | |||
31 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_DEBUG, | ||
32 | "%s: called for '%s' %lld bytes\n", __FUNCTION__, path, size); | ||
33 | |||
34 | /* Check for special file */ | ||
35 | if(gn_exists_special_file(path)) | ||
36 | return -EACCES; | ||
37 | |||
38 | /* Lookup dirent for path */ | ||
39 | de = gn_dirent_find(path); | ||
40 | if(de == NULL) | ||
41 | { | ||
42 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_DEBUG, | ||
43 | "%s: file not found\n", __FUNCTION__); | ||
44 | return -ENOENT; | ||
45 | } | ||
46 | if(de->de_type != DE_FILE) | ||
47 | { | ||
48 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_DEBUG, | ||
49 | "%s: not a file\n", __FUNCTION__); | ||
50 | ret = -EISDIR; | ||
51 | goto out; | ||
52 | } | ||
53 | |||
54 | /* Lock our path */ | ||
55 | if(gn_lock_path(de) == -1) | ||
56 | { | ||
57 | ret = -EIO; | ||
58 | goto out; | ||
59 | } | ||
60 | if(!de->de_cached) | ||
61 | { | ||
62 | if(gn_file_download_locked(de) == -1) | ||
63 | { | ||
64 | ret = -EIO; | ||
65 | goto out_unlock; | ||
66 | } | ||
67 | } | ||
68 | |||
69 | /* Perform truncate */ | ||
70 | ret = ftruncate(de->de_fd, size); | ||
71 | if(ret == -1) | ||
72 | { | ||
73 | ret = -errno; | ||
74 | goto out_unlock; | ||
75 | } | ||
76 | |||
77 | /* Mark us dirty */ | ||
78 | de->de_dirty = 1; | ||
79 | |||
80 | /* Then un-mark us dirty */ | ||
81 | if(gn_file_upload_locked(de) == 0) | ||
82 | { | ||
83 | dirty = GN_UNLOCK_ANCESTORS_DIRTY; | ||
84 | } | ||
85 | out_unlock: | ||
86 | gn_unlock_path(de, GN_UNLOCK_ANCESTORS_DIRTY); | ||
87 | out: | ||
88 | gn_dirent_put(de); | ||
89 | return ret; | ||
90 | } | ||
diff --git a/gnunet-fuse-0.8/unlink.c b/gnunet-fuse-0.8/unlink.c deleted file mode 100644 index 112bbe3..0000000 --- a/gnunet-fuse-0.8/unlink.c +++ /dev/null | |||
@@ -1,68 +0,0 @@ | |||
1 | /* | ||
2 | * unlink.c - FUSE unlink function | ||
3 | * | ||
4 | * This file is part of gnunet-fuse. | ||
5 | * Copyright (C) 2007 David Barksdale | ||
6 | * | ||
7 | * gnunet-fuse is free software; you can redistribute it and/or | ||
8 | * modify if under the terms of version 2 of the GNU General Public License | ||
9 | * as published by the Free Software Foundation. | ||
10 | * | ||
11 | * gnunet-fuse is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | */ | ||
20 | |||
21 | #include <string.h> | ||
22 | #include <errno.h> | ||
23 | #include <sys/types.h> | ||
24 | #include <sys/stat.h> | ||
25 | #include <fuse.h> | ||
26 | #include "gnfs.h" | ||
27 | |||
28 | int gn_unlink(const char *path) | ||
29 | { | ||
30 | struct dirent *de, *dechild; | ||
31 | char *parent, *file; | ||
32 | int ret; | ||
33 | |||
34 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_DEBUG, "%s: for '%s'\n", | ||
35 | __FUNCTION__, path); | ||
36 | |||
37 | /* Check for special file */ | ||
38 | if(gn_exists_special_file(path)) | ||
39 | return -EPERM; | ||
40 | |||
41 | /* Check for existing file */ | ||
42 | dechild = gn_dirent_find(path); | ||
43 | if(dechild == NULL) | ||
44 | return -ENOENT; | ||
45 | |||
46 | /* Can't unlink a directory */ | ||
47 | if(dechild->de_type != DE_FILE) | ||
48 | { | ||
49 | gn_dirent_put(dechild); | ||
50 | return -EPERM; | ||
51 | } | ||
52 | |||
53 | /* Remove file from parent dir */ | ||
54 | parent = gn_dirname(path, &file); | ||
55 | de = gn_dirent_find(parent); | ||
56 | GNUNET_free(parent); | ||
57 | if(de == NULL) | ||
58 | { | ||
59 | gn_dirent_put(dechild); | ||
60 | return -ENOENT; | ||
61 | } | ||
62 | ret = gn_directory_remove(de, dechild); | ||
63 | gn_dirent_put(dechild); | ||
64 | gn_dirent_put(de); | ||
65 | if(ret == -1) | ||
66 | return -EIO; | ||
67 | return 0; | ||
68 | } | ||
diff --git a/gnunet-fuse-0.8/utimens.c b/gnunet-fuse-0.8/utimens.c deleted file mode 100644 index 317778e..0000000 --- a/gnunet-fuse-0.8/utimens.c +++ /dev/null | |||
@@ -1,72 +0,0 @@ | |||
1 | /* | ||
2 | * utimens.c - FUSE utimens function | ||
3 | * | ||
4 | * This file is part of gnunet-fuse. | ||
5 | * Copyright (C) 2007 David Barksdale | ||
6 | * | ||
7 | * gnunet-fuse is free software; you can redistribute it and/or | ||
8 | * modify if under the terms of version 2 of the GNU General Public License | ||
9 | * as published by the Free Software Foundation. | ||
10 | * | ||
11 | * gnunet-fuse is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | */ | ||
20 | |||
21 | #define _GNU_SOURCE | ||
22 | #include <sys/time.h> | ||
23 | #include <string.h> | ||
24 | #include <errno.h> | ||
25 | #include <fuse.h> | ||
26 | #include "gnfs.h" | ||
27 | |||
28 | int gn_utimens(const char *path, const struct timespec ts[2]) | ||
29 | { | ||
30 | struct dirent *de; | ||
31 | struct timeval tv[2]; | ||
32 | int ret = 0; | ||
33 | |||
34 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_DEBUG, "%s: for '%s'\n", | ||
35 | __FUNCTION__, path); | ||
36 | |||
37 | /* Check to see if this is a special file */ | ||
38 | if(gn_exists_special_file(path)) | ||
39 | return -EACCES; | ||
40 | |||
41 | /* Get file or dir */ | ||
42 | de = gn_dirent_find(path); | ||
43 | if(de == NULL) | ||
44 | return -ENOENT; | ||
45 | |||
46 | /* If it's a cached file just call utime */ | ||
47 | if(GNUNET_semaphore_down(de->de_sema, GNUNET_YES) == GNUNET_SYSERR) | ||
48 | { | ||
49 | gn_dirent_put(de); | ||
50 | return -EIO; | ||
51 | } | ||
52 | if(de->de_cached && de->de_type == DE_FILE) | ||
53 | { | ||
54 | TIMESPEC_TO_TIMEVAL(&tv[0], &ts[0]); | ||
55 | TIMESPEC_TO_TIMEVAL(&tv[1], &ts[1]); | ||
56 | ret = utimes(path, tv); | ||
57 | if(ret == -1) | ||
58 | { | ||
59 | ret = -errno; | ||
60 | GNUNET_GE_LOG_STRERROR(ectx, GNUNET_GE_BULK | GNUNET_GE_USER | GNUNET_GE_ERROR, | ||
61 | "utimes"); | ||
62 | goto out; | ||
63 | } | ||
64 | goto out; | ||
65 | } | ||
66 | |||
67 | /* For now we do nothing otherwise */ | ||
68 | out: | ||
69 | GNUNET_semaphore_up(de->de_sema); | ||
70 | gn_dirent_put(de); | ||
71 | return ret; | ||
72 | } | ||
diff --git a/gnunet-fuse-0.8/write.c b/gnunet-fuse-0.8/write.c deleted file mode 100644 index dde3dcc..0000000 --- a/gnunet-fuse-0.8/write.c +++ /dev/null | |||
@@ -1,88 +0,0 @@ | |||
1 | /* | ||
2 | * write.c - FUSE write function | ||
3 | * | ||
4 | * This file is part of gnunet-fuse. | ||
5 | * Copyright (C) 2007 David Barksdale | ||
6 | * | ||
7 | * gnunet-fuse is free software; you can redistribute it and/or | ||
8 | * modify if under the terms of version 2 of the GNU General Public License | ||
9 | * as published by the Free Software Foundation. | ||
10 | * | ||
11 | * gnunet-fuse is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | */ | ||
20 | |||
21 | #define _XOPEN_SOURCE 500 | ||
22 | #include <string.h> | ||
23 | #include <errno.h> | ||
24 | #include <unistd.h> | ||
25 | #include <fuse.h> | ||
26 | #include "gnfs.h" | ||
27 | |||
28 | int gn_write(const char *path, const char *buf, size_t size, off_t offset, | ||
29 | struct fuse_file_info *fi) | ||
30 | { | ||
31 | struct dirent *de; | ||
32 | ssize_t slen; | ||
33 | |||
34 | (void)fi; | ||
35 | |||
36 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_DEBUG, | ||
37 | "%s: called for '%s' %d bytes\n", __FUNCTION__, path, size); | ||
38 | |||
39 | /* Check for special file */ | ||
40 | if(gn_exists_special_file(path)) | ||
41 | return -EACCES; | ||
42 | |||
43 | /* Lookup dirent for path */ | ||
44 | de = gn_dirent_find(path); | ||
45 | if(de == NULL) | ||
46 | { | ||
47 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_DEBUG, | ||
48 | "%s: file not found\n", __FUNCTION__); | ||
49 | return -ENOENT; | ||
50 | } | ||
51 | if(de->de_type != DE_FILE) | ||
52 | { | ||
53 | GNUNET_GE_LOG(ectx, GNUNET_GE_BULK | GNUNET_GE_DEVELOPER | GNUNET_GE_DEBUG, | ||
54 | "%s: not a file\n", __FUNCTION__); | ||
55 | size = -ENOENT; | ||
56 | goto out; | ||
57 | } | ||
58 | |||
59 | /* We must be cached */ | ||
60 | if(GNUNET_semaphore_down(de->de_sema, GNUNET_YES) == GNUNET_SYSERR) | ||
61 | { | ||
62 | size = -EIO; | ||
63 | goto out; | ||
64 | } | ||
65 | if(!de->de_cached) | ||
66 | { | ||
67 | if(gn_file_download_locked(de) == -1) | ||
68 | { | ||
69 | size = -EIO; | ||
70 | goto out_unlock; | ||
71 | } | ||
72 | } | ||
73 | |||
74 | /* Perform write on temp file */ | ||
75 | slen = pwrite(de->de_fd, buf, size, offset); | ||
76 | if(slen == -1) | ||
77 | size = -errno; | ||
78 | else | ||
79 | size = slen; | ||
80 | |||
81 | /* Mark us dirty */ | ||
82 | de->de_dirty = 1; | ||
83 | out_unlock: | ||
84 | GNUNET_semaphore_up(de->de_sema); | ||
85 | out: | ||
86 | gn_dirent_put(de); | ||
87 | return size; | ||
88 | } | ||