From a92e6f3ea8c0632cc510cfec57bafdaf34c0601c Mon Sep 17 00:00:00 2001 From: Pavel Machek Date: Sun, 27 Sep 1998 19:27:58 +0000 Subject: [PATCH] Changed license to LGPL, added passing of vfs * (acting as self), so we can do OOP-like trics. --- vfs/COPYING.LGPL | 482 ++++++++++++++++++++++++++++++++++++++++++ vfs/ChangeLog | 13 ++ vfs/container.c | 14 +- vfs/extfs.c | 221 +++++++++---------- vfs/extfs.h | 4 - vfs/fish.c | 123 ++++------- vfs/ftpfs.c | 53 +++-- vfs/local.c | 61 ++++-- vfs/mcfs.c | 117 +++++----- vfs/names.c | 12 +- vfs/sfs.c | 162 +++++++------- vfs/shared_ftp_fish.c | 49 ++--- vfs/shared_tar_ext.c | 13 +- vfs/tar.c | 55 +++-- vfs/tcputil.c | 15 +- vfs/undelfs.c | 46 ++-- vfs/utilvfs.c | 15 +- vfs/vfs.c | 170 ++++++++------- vfs/vfs.h | 122 +++++------ 19 files changed, 1134 insertions(+), 613 deletions(-) create mode 100644 vfs/COPYING.LGPL diff --git a/vfs/COPYING.LGPL b/vfs/COPYING.LGPL new file mode 100644 index 000000000..bf50f20de --- /dev/null +++ b/vfs/COPYING.LGPL @@ -0,0 +1,482 @@ + GNU LIBRARY GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the library GPL. It is + numbered 2 because it goes with version 2 of the ordinary GPL.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Library General Public License, applies to some +specially designated Free Software Foundation software, and to any +other libraries whose authors decide to use it. You can use it for +your libraries, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if +you distribute copies of the library, or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link a program with the library, you must provide +complete object files to the recipients so that they can relink them +with the library, after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + Our method of protecting your rights has two steps: (1) copyright +the library, and (2) offer you this license which gives you legal +permission to copy, distribute and/or modify the library. + + Also, for each distributor's protection, we want to make certain +that everyone understands that there is no warranty for this free +library. If the library is modified by someone else and passed on, we +want its recipients to know that what they have is not the original +version, so that any problems introduced by others will not reflect on +the original authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that companies distributing free +software will individually obtain patent licenses, thus in effect +transforming the program into proprietary software. To prevent this, +we have made it clear that any patent must be licensed for everyone's +free use or not licensed at all. + + Most GNU software, including some libraries, is covered by the ordinary +GNU General Public License, which was designed for utility programs. This +license, the GNU Library General Public License, applies to certain +designated libraries. This license is quite different from the ordinary +one; be sure to read it in full, and don't assume that anything in it is +the same as in the ordinary license. + + The reason we have a separate public license for some libraries is that +they blur the distinction we usually make between modifying or adding to a +program and simply using it. Linking a program with a library, without +changing the library, is in some sense simply using the library, and is +analogous to running a utility program or application program. However, in +a textual and legal sense, the linked executable is a combined work, a +derivative of the original library, and the ordinary General Public License +treats it as such. + + Because of this blurred distinction, using the ordinary General +Public License for libraries did not effectively promote software +sharing, because most developers did not use the libraries. We +concluded that weaker conditions might promote sharing better. + + However, unrestricted linking of non-free programs would deprive the +users of those programs of all benefit from the free status of the +libraries themselves. This Library General Public License is intended to +permit developers of non-free programs to use free libraries, while +preserving your freedom as a user of such programs to change the free +libraries that are incorporated in them. (We have not seen how to achieve +this as regards changes in header files, but we have achieved it as regards +changes in the actual functions of the Library.) The hope is that this +will lead to faster development of free libraries. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, while the latter only +works together with the library. + + Note that it is possible for a library to be covered by the ordinary +General Public License rather than by this special one. + + GNU LIBRARY GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library which +contains a notice placed by the copyright holder or other authorized +party saying it may be distributed under the terms of this Library +General Public License (also called "this License"). Each licensee is +addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also compile or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + c) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + d) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the source code distributed need not include anything that is normally +distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Library General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307 USA. + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/vfs/ChangeLog b/vfs/ChangeLog index 1e3cff1da..5ad849c1c 100644 --- a/vfs/ChangeLog +++ b/vfs/ChangeLog @@ -1,3 +1,16 @@ +Sun Sep 27 16:16:52 1998 Pavel Machek + + * COPYING.LGPL, all over the code: code is now under Library + General Public License (instead of GPL), so non-free applications + can link to it. + +Wed Sep 23 22:37:40 1998 Pavel Machek + + * all over the code: added (vfs *) as first argument for functions + that have no other way to know what fs they belong to. This will + be used by object-like tricks, which will allow us to do real + code-sharing: I do not like #including of .c files. + 1998-09-25 Miguel de Icaza * shared_ftp_fish.c: Addaed prototypes for linear_start, linear_read, diff --git a/vfs/container.c b/vfs/container.c index 3aedef491..a26aa106f 100644 --- a/vfs/container.c +++ b/vfs/container.c @@ -3,18 +3,18 @@ Written by: 1995 Ching Hui (mr854307@cs.nthu.edu.tw) - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License + as published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + GNU Library General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include diff --git a/vfs/extfs.c b/vfs/extfs.c index 094612643..088518aad 100644 --- a/vfs/extfs.c +++ b/vfs/extfs.c @@ -4,18 +4,18 @@ Written by: 1995 Jakub Jelinek Rewritten by: 1998 Pavel Machek - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License + as published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + GNU Library General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include @@ -60,7 +60,7 @@ static char *extfs_prefixes [MAXEXTFS]; static char extfs_need_archive [MAXEXTFS]; static int extfs_no = 0; -void extfs_fill_names (void (*func)(char *)) +void extfs_fill_names (vfs *me, void (*func)(char *)) { struct archive *a = first_archive; char *name; @@ -434,7 +434,7 @@ static char *get_path_mangle (char *inname, struct archive **archive, int is_dir parent = xmalloc (sizeof (struct vfs_stamping), "vfs stamping"); parent->v = v; parent->next = 0; - parent->id = (*v->getid) (archive_name, &(parent->parent)); + parent->id = (*v->getid) (v, archive_name, &(parent->parent)); } vfs_add_noncurrent_stamps (&extfs_vfs_ops, (vfsid) parc, parent); vfs_rm_parents (parent); @@ -576,7 +576,7 @@ void extfs_run (char *file) free(p); } -static void *extfs_open (char *file, int flags, int mode) +static void *extfs_open (vfs *me, char *file, int flags, int mode) { struct pseudofile *extfs_info; struct archive *archive; @@ -698,7 +698,7 @@ static int extfs_close (void *data) parent = xmalloc (sizeof (struct vfs_stamping), "vfs stamping"); parent->v = v; parent->next = 0; - parent->id = (*v->getid) (file->archive->name, &(parent->parent)); + parent->id = (*v->getid) (v, file->archive->name, &(parent->parent)); } vfs_add_noncurrent_stamps (&extfs_vfs_ops, (vfsid) (file->archive), parent); vfs_rm_parents (parent); @@ -712,7 +712,7 @@ static int extfs_close (void *data) #define RECORDSIZE 512 #include "shared_tar_ext.c" -static int extfs_chmod (char *path, int mode) +static int extfs_chmod (vfs *me, char *path, int mode) { return 0; } @@ -725,7 +725,7 @@ static int extfs_write (void *data, char *buf, int nbyte) return write (file->local_handle, buf, nbyte); } -static int extfs_chdir (char *path) +static int extfs_chdir (vfs *me, char *path) { struct archive *archive; char *q, *res; @@ -758,7 +758,7 @@ static int extfs_lseek (void *data, off_t offset, int whence) return lseek (file->local_handle, offset, whence); } -static vfsid extfs_getid (char *path, struct vfs_stamping **parent) +static vfsid extfs_getid (vfs *me, char *path, struct vfs_stamping **parent) { struct archive *archive; vfs *v; @@ -772,7 +772,7 @@ static vfsid extfs_getid (char *path, struct vfs_stamping **parent) free(p); if (archive->name){ v = vfs_type (archive->name); - id = (*v->getid) (archive->name, &par); + id = (*v->getid) (v, archive->name, &par); if (id != (vfsid)-1) { *parent = xmalloc (sizeof (struct vfs_stamping), "vfs stamping"); (*parent)->v = v; @@ -834,10 +834,10 @@ static void extfs_free (vfsid id) free_archive (archive); } -static char *extfs_getlocalcopy (char *path) +static char *extfs_getlocalcopy (vfs *me, char *path) { struct pseudofile *fp = - (struct pseudofile *) extfs_open (path, O_RDONLY, 0); + (struct pseudofile *) extfs_open (me, path, O_RDONLY, 0); char *p; if (fp == NULL) @@ -852,10 +852,10 @@ static char *extfs_getlocalcopy (char *path) return p; } -static void extfs_ungetlocalcopy (char *path, char *local, int has_changed) +static void extfs_ungetlocalcopy (vfs *me, char *path, char *local, int has_changed) { struct pseudofile *fp = - (struct pseudofile *) extfs_open (path, O_WRONLY, 0); + (struct pseudofile *) extfs_open (me, path, O_WRONLY, 0); if (fp == NULL) return; @@ -867,12 +867,103 @@ static void extfs_ungetlocalcopy (char *path, char *local, int has_changed) } else { /* Should not happen */ extfs_close ((void *) fp); - mc_def_ungetlocalcopy (path, local, has_changed); + mc_def_ungetlocalcopy (me, path, local, has_changed); } } -vfs extfs_vfs_ops = + +#include "../src/profile.h" +int extfs_init (vfs *me) { + FILE *cfg; + char *mc_extfsini; + + mc_extfsini = concat_dir_and_file (mc_home, "extfs/extfs.ini"); + cfg = fopen (mc_extfsini, "r"); + free (mc_extfsini); + + if (!cfg) { + fprintf( stderr, "Warning: " LIBDIR "extfs/extfs.ini not found\n" ); + return 0; + } + + extfs_no = 0; + while ( extfs_no < MAXEXTFS ) { + char key[256]; + char *c; + + if (!fgets( key, 250, cfg )) + break; + + /* Handle those with a trailing ':', those flag that the + * file system does not require an archive to work + */ + + if (*key == '[') { + /* We may not use vfs_die() message or message_1s or similar, + * UI is not initialized at this time and message would not + * appear on screen. */ + fprintf( stderr, "Warning: You need to update your " LIBDIR "extfs/extfs.ini file.\n" ); + fclose(cfg); + return 0; + } + if (*key == '#') + continue; + + if ((c = strchr( key, '\n'))) + *c = 0; + c = &key [strlen (key)-1]; + extfs_need_archive [extfs_no] = !(*c==':'); + if (*c==':') *c = 0; + if (!(*key)) + continue; + + extfs_prefixes [extfs_no] = strdup (key); + extfs_no++; + } + fclose(cfg); + return 1; +} + +int extfs_which (vfs *me, char *path) +{ + int i; + + for (i = 0; i < extfs_no; i++) + if (!strcmp (path, extfs_prefixes [i])) + return i; + return -1; +} + +char *extfs_get_prefix (int idx) +{ + return extfs_prefixes [idx]; +} + +void extfs_done (vfs *me) +{ + int i; + + for (i = 0; i < extfs_no; i++ ) + free (extfs_prefixes [i]); + extfs_no = 0; + if (extfs_current_dir) + free (extfs_current_dir); + extfs_current_dir = 0; +} + +vfs extfs_vfs_ops = { + NULL, /* This is place of next pointer */ + "Extended filesystems", + F_EXEC, /* flags */ + NULL, /* prefix */ + NULL, /* data */ + 0, /* errno */ + extfs_init, + extfs_done, + extfs_fill_names, + extfs_which, + extfs_open, extfs_close, extfs_read, @@ -914,91 +1005,7 @@ vfs extfs_vfs_ops = NULL, /* mkdir */ NULL, NULL, - NULL, NULL - -#ifdef HAVE_MMAP - , NULL, - NULL -#endif + +MMAPNULL }; - -#include "../src/profile.h" -void extfs_init (void) -{ - FILE *cfg; - char *mc_extfsini; - - mc_extfsini = concat_dir_and_file (mc_home, "extfs/extfs.ini"); - cfg = fopen (mc_extfsini, "r"); - free (mc_extfsini); - - if (!cfg) { - fprintf( stderr, "Warning: " LIBDIR "extfs/extfs.ini not found\n" ); - return; - } - - extfs_no = 0; - while ( extfs_no < MAXEXTFS ) { - char key[256]; - char *c; - - if (!fgets( key, 250, cfg )) - break; - - /* Handle those with a trailing ':', those flag that the - * file system does not require an archive to work - */ - - if (*key == '[') { - /* We may not use vfs_die() message or message_1s or similar, - * UI is not initialized at this time and message would not - * appear on screen. */ - fprintf( stderr, "Warning: You need to update your " LIBDIR "extfs/extfs.ini file.\n" ); - fclose(cfg); - return; - } - if (*key == '#') - continue; - - if ((c = strchr( key, '\n'))) - *c = 0; - c = &key [strlen (key)-1]; - extfs_need_archive [extfs_no] = !(*c==':'); - if (*c==':') *c = 0; - if (!(*key)) - continue; - - extfs_prefixes [extfs_no] = strdup (key); - extfs_no++; - } - fclose(cfg); -} - -int extfs_which (char *path) -{ - int i; - - for (i = 0; i < extfs_no; i++) - if (!strcmp (path, extfs_prefixes [i])) - return i; - return -1; -} - -char *extfs_get_prefix (int idx) -{ - return extfs_prefixes [idx]; -} - -void extfs_done (void) -{ - int i; - - for (i = 0; i < extfs_no; i++ ) - free (extfs_prefixes [i]); - extfs_no = 0; - if (extfs_current_dir) - free (extfs_current_dir); - extfs_current_dir = 0; -} - diff --git a/vfs/extfs.h b/vfs/extfs.h index 8f666f336..fc620c9db 100644 --- a/vfs/extfs.h +++ b/vfs/extfs.h @@ -67,12 +67,8 @@ struct archive { struct archive *next; }; -void extfs_init (void); -void extfs_fill_names (void (*func)(char *)); -int extfs_prefix_to_type (char *path); char *extfs_get_prefix (int fstype); char *extfs_analysis (char *path, char **arc_name, int *fstype, int is_dir); void extfs_run (char *path); -void extfs_done (void); typedef struct archive extfs_archive; /* Do _not_ use this inside extfs.c */ diff --git a/vfs/fish.c b/vfs/fish.c index 0ce4c4a9e..b68da6a50 100644 --- a/vfs/fish.c +++ b/vfs/fish.c @@ -7,18 +7,18 @@ Derived from ftpfs.c. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License + as published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + GNU Library General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* @@ -207,7 +207,7 @@ pipeopen(struct connection *bucket, char *path, char *argv[]) if (pipe(fileset1)<0) vfs_die("Could not pipe(): %m."); if (pipe(fileset2)<0) vfs_die("Could not pipe(): %m."); - if (res = fork()) { + if ((res = fork())) { if (res<0) vfs_die("Could not fork(): %m."); /* We are the parent */ close(fileset1[0]); @@ -363,6 +363,10 @@ static char *fish_get_current_directory(struct connection *bucket) ERRNOR (EIO, NULL); } +static void my_forget (char *path) +{ +} + #define X "fish" #define X_myname "/#sh:" #define X_vfs_ops fish_vfs_ops @@ -376,11 +380,11 @@ static char* get_path (struct connection **bucket, char *path) { char *res; - if (res = s_get_path (bucket, path, "/#sh:")) + if ((res = s_get_path (bucket, path, "/#sh:"))) return res; - if (res = s_get_path (bucket, path, "/#ssh:")) + if ((res = s_get_path (bucket, path, "/#ssh:"))) return res; - if (res = s_get_path (bucket, path, "/#rsh:")) { + if ((res = s_get_path (bucket, path, "/#rsh:"))) { qflags((*bucket)) |= FISH_FLAG_RSH; return res; } @@ -649,7 +653,7 @@ linear_abort (struct direntry *fe) print_vfs_message( "Aborting transfer..." ); do { - n = MIN(8192, fe->total - fe->got); + n = VFS_MIN(8192, fe->total - fe->got); if (n) if ((n = read(qsockr(fe->bucket), buffer, n)) < 0) return; @@ -665,7 +669,7 @@ static int linear_read (struct direntry *fe, void *buf, int len) { int n = 0; - len = MIN( fe->total - fe->got, len ); + len = VFS_MIN( fe->total - fe->got, len ); while (len && ((n = read (qsockr(fe->bucket), buf, len))<0)) { if ((errno == EINTR) && !got_interrupt()) continue; @@ -679,7 +683,7 @@ linear_read (struct direntry *fe, void *buf, int len) ERRNOR (errno, n); } -static int +static void linear_close (struct direntry *fe) { if (fe->total != fe->got) @@ -688,9 +692,7 @@ linear_close (struct direntry *fe) int fish_ctl (void *data, int ctlop, int arg) { - int n = 0; struct filp *fp = data; - int v; switch (ctlop) { case MCCTL_IS_NOTREADY: { @@ -719,11 +721,14 @@ send_fish_command(struct connection *bucket, char *cmd, int flags) return 0; } -void -fish_init (void) +int +fish_init (vfs *me) { connections_list = linklist_init(); +#if 0 logfile = fopen ("/tmp/talk.fish", "w+"); +#endif + return 1; } #define PREFIX \ @@ -737,7 +742,7 @@ fish_init (void) free(remote_path); \ return send_fish_command(bucket, buf, flags); -int fish_chmod (char *path, int mode) +int fish_chmod (vfs *me, char *path, int mode) { PREFIX sprintf(buf, "#CHMOD %4.4o %s\nchmod %4.4o %s; echo '### 000'\n", @@ -747,7 +752,7 @@ int fish_chmod (char *path, int mode) } #define FISH_OP(name, chk, string) \ -int fish_##name (char *path1, char *path2) \ +int fish_##name (vfs *me, char *path1, char *path2) \ { \ char buf[120]; \ char *remote_path1 = NULL, *remote_path2 = NULL; \ @@ -769,7 +774,7 @@ FISH_OP(rename, XTEST, "#RENAME %s %s\nmv %s %s; echo '*** 000'" ); FISH_OP(link, XTEST, "#LINK %s %s\nln %s %s; echo '*** 000'" ); FISH_OP(symlink, , "#SYMLINK %s %s\nln -s %s %s; echo '*** 000'" ); -int fish_chown (char *path, int owner, int group) +int fish_chown (vfs *me, char *path, int owner, int group) { char *sowner, *sgroup; PREFIX @@ -787,84 +792,39 @@ int fish_chown (char *path, int owner, int group) POSTFIX(OPT_FLUSH) } -static int fish_unlink (char *path) +static int fish_unlink (vfs *me, char *path) { PREFIX sprintf(buf, "#DELE %s\nrm -f %s; echo '### 000'\n", remote_path, remote_path); POSTFIX(OPT_FLUSH); } -static int fish_mkdir (char *path, mode_t mode) +static int fish_mkdir (vfs *me, char *path, mode_t mode) { PREFIX sprintf(buf, "#MKD %s\nmkdir %s; echo '### 000'\n", remote_path, remote_path); POSTFIX(OPT_FLUSH); } -static int fish_rmdir (char *path) +static int fish_rmdir (vfs *me, char *path) { PREFIX sprintf(buf, "#RMD %s\nrmdir %s; echo '### 000'\n", remote_path, remote_path); POSTFIX(OPT_FLUSH); } -void fish_set_debug (char *file) -{ -} - -void fish_forget (char *file) -{ -#if 0 - struct linklist *l; - char *host, *user, *pass, *rp; - int port; - -#ifndef BROKEN_PATHS - if (strncmp (file, "/#sh:", 5)) - return; /* Normal: consider cd /bla/#ftp */ -#else - if (!(file = strstr (file, "/#sh:"))) - return; -#endif - - file += 6; - if (!(rp = fish_get_host_and_username (file, &host, &user, &port, &pass))) { - free (host); - free (user); - if (pass) - wipe_password (pass); - return; - } - - /* we do not care about the path actually */ - free (rp); - - for (l = connections_list->next; l != connections_list; l = l->next){ - struct connection *bucket = l->data; - - if ((strcmp (host, qhost (bucket)) == 0) && - (strcmp (user, quser (bucket)) == 0) && - (port == qport (bucket))){ - - /* close socket: the child owns it now */ - close (bucket->sock); - bucket->sock = -1; - - /* reopen the connection */ - bucket->sock = fish_open_socket (bucket); - if (bucket->sock != -1) - login_server (bucket, pass); - break; - } - } - free (host); - free (user); - if (pass) - wipe_password (pass); -#endif -} - vfs fish_vfs_ops = { + NULL, /* This is place of next pointer */ + "FIles tranferred over SHell", + F_EXEC, /* flags */ + "sh:", /* prefix */ + NULL, /* data */ + 0, /* errno */ + fish_init, + fish_done, + fish_fill_names, + NULL, + s_open, s_close, s_read, @@ -905,8 +865,7 @@ vfs fish_vfs_ops = { fish_mkdir, fish_rmdir, fish_ctl, - s_setctl, - fish_forget + s_setctl #ifdef HAVE_MMAP , NULL, NULL diff --git a/vfs/ftpfs.c b/vfs/ftpfs.c index 3fa6946ad..83d3c56e4 100644 --- a/vfs/ftpfs.c +++ b/vfs/ftpfs.c @@ -7,18 +7,18 @@ 1997 Norbert Warmuth 1998 Pavel Machek - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License + as published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + GNU Library General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* FTPfs TODO: @@ -1380,7 +1380,7 @@ linear_start(struct direntry *fe) return 1; } -static int +static void linear_abort (struct direntry *fe) { my_abort(fe->bucket, fe->data_sock); @@ -1409,7 +1409,7 @@ linear_read (struct direntry *fe, void *buf, int len) ERRNOR (errno, n); } -static int +static void linear_close (struct direntry *fe) { if (fe->data_sock != -1) @@ -1418,9 +1418,7 @@ linear_close (struct direntry *fe) int ftpfs_ctl (void *data, int ctlop, int arg) { - int n = 0; struct filp *fp = data; - int v; switch (ctlop) { case MCCTL_IS_NOTREADY: { @@ -1481,14 +1479,15 @@ ftpfs_init_passwd(void) endpwent (); } -void -ftpfs_init () +int +ftpfs_init (vfs *me) { connections_list = linklist_init(); ftpfs_directory_timeout = FTPFS_DIRECTORY_TIMEOUT; + return 1; } -int ftpfs_chmod (char *path, int mode) +int ftpfs_chmod (vfs *me, char *path, int mode) { char buf[40]; @@ -1496,7 +1495,7 @@ int ftpfs_chmod (char *path, int mode) return send_ftp_command(path, buf, OPT_IGNORE_ERROR | OPT_FLUSH); } -int ftpfs_chown (char *path, int owner, int group) +int ftpfs_chown (vfs *me, char *path, int owner, int group) { #if 0 my_errno = EPERM; @@ -1508,7 +1507,7 @@ int ftpfs_chown (char *path, int owner, int group) #endif } -static int ftpfs_unlink (char *path) +static int ftpfs_unlink (vfs *me, char *path) { return send_ftp_command(path, "DELE %s", OPT_FLUSH); } @@ -1544,18 +1543,18 @@ __ftpfs_chdir (struct connection *bucket ,char *remote_path) return r; } -static int ftpfs_rename (char *path1, char *path2) +static int ftpfs_rename (vfs *me, char *path1, char *path2) { send_ftp_command(path1, "RNFR %s", OPT_FLUSH); return send_ftp_command(path2, "RNTO %s", OPT_FLUSH); } -static int ftpfs_mkdir (char *path, mode_t mode) +static int ftpfs_mkdir (vfs *me, char *path, mode_t mode) { return send_ftp_command(path, "MKD %s", OPT_FLUSH); } -static int ftpfs_rmdir (char *path) +static int ftpfs_rmdir (vfs *me, char *path) { return send_ftp_command(path, "RMD %s", OPT_FLUSH); } @@ -1565,7 +1564,7 @@ void ftpfs_set_debug (char *file) logfile = fopen (file, "w+"); } -void ftpfs_forget (char *file) +static void my_forget (char *file) { struct linklist *l; char *host, *user, *pass, *rp; @@ -1616,6 +1615,17 @@ void ftpfs_forget (char *file) } vfs ftpfs_vfs_ops = { + NULL, /* This is place of next pointer */ + "File Tranfer Protocol (ftp)", + F_NET, /* flags */ + "ftp:", /* prefix */ + NULL, /* data */ + 0, /* errno */ + ftpfs_init, + ftpfs_done, + ftpfs_fill_names, + NULL, + s_open, s_close, s_read, @@ -1656,8 +1666,7 @@ vfs ftpfs_vfs_ops = { ftpfs_mkdir, ftpfs_rmdir, ftpfs_ctl, - s_setctl, - ftpfs_forget + s_setctl #ifdef HAVE_MMAP , NULL, NULL diff --git a/vfs/local.c b/vfs/local.c index d143a1715..ac92e0151 100644 --- a/vfs/local.c +++ b/vfs/local.c @@ -18,7 +18,7 @@ * saves both computer's memory and my work. * */ -static void *local_open (char *file, int flags, int mode) +static void *local_open (vfs *me, char *file, int flags, int mode) { int *local_info; int fd; @@ -64,12 +64,12 @@ int local_close (void *data) return close (fd); } -int local_errno (void) +int local_errno (vfs *me) { return errno; } -static void *local_opendir (char *dirname) +static void *local_opendir (vfs *me, char *dirname) { DIR **local_info; DIR *dir; @@ -109,12 +109,12 @@ static int local_closedir (void *data) return i; } -static int local_stat (char *path, struct stat *buf) +static int local_stat (vfs *me, char *path, struct stat *buf) { return stat (path, buf); } -static int local_lstat (char *path, struct stat *buf) +static int local_lstat (vfs *me, char *path, struct stat *buf) { #ifndef HAVE_STATLSTAT return lstat (path,buf); @@ -128,32 +128,32 @@ int local_fstat (void *data, struct stat *buf) return fstat (*((int *) data), buf); } -static int local_chmod (char *path, int mode) +static int local_chmod (vfs *me, char *path, int mode) { return chmod (path, mode); } -static int local_chown (char *path, int owner, int group) +static int local_chown (vfs *me, char *path, int owner, int group) { return chown (path, owner, group); } -static int local_utime (char *path, struct utimbuf *times) +static int local_utime (vfs *me, char *path, struct utimbuf *times) { return utime (path, times); } -static int local_readlink (char *path, char *buf, int size) +static int local_readlink (vfs *me, char *path, char *buf, int size) { return readlink (path, buf, size); } -static int local_unlink (char *path) +static int local_unlink (vfs *me, char *path) { return unlink (path); } -static int local_symlink (char *n1, char *n2) +static int local_symlink (vfs *me, char *n1, char *n2) { return symlink (n1, n2); } @@ -179,12 +179,12 @@ static int local_write (void *data, char *buf, int nbyte) return n; } -static int local_rename (char *a, char *b) +static int local_rename (vfs *me, char *a, char *b) { return rename (a, b); } -static int local_chdir (char *path) +static int local_chdir (vfs *me, char *path) { return chdir (path); } @@ -196,27 +196,27 @@ int local_lseek (void *data, off_t offset, int whence) return lseek (fd, offset, whence); } -static int local_mknod (char *path, int mode, int dev) +static int local_mknod (vfs *me, char *path, int mode, int dev) { return mknod (path, mode, dev); } -static int local_link (char *p1, char *p2) +static int local_link (vfs *me, char *p1, char *p2) { return link (p1, p2); } -static int local_mkdir (char *path, mode_t mode) +static int local_mkdir (vfs *me, char *path, mode_t mode) { return mkdir (path, mode); } -static int local_rmdir (char *path) +static int local_rmdir (vfs *me, char *path) { return rmdir (path); } -static vfsid local_getid (char *path, struct vfs_stamping **parent) +static vfsid local_getid (vfs *me, char *path, struct vfs_stamping **parent) { *parent = NULL; return (vfsid) -1; /* We do not free local fs stuff at all */ @@ -231,30 +231,46 @@ static void local_free (vfsid id) { } -static char *local_getlocalcopy (char *path) +static char *local_getlocalcopy (vfs *me, char *path) { return strdup (path); } -static void local_ungetlocalcopy (char *path, char *local, int has_changed) +static void local_ungetlocalcopy (vfs *me, char *path, char *local, int has_changed) { } #ifdef HAVE_MMAP -static caddr_t local_mmap (caddr_t addr, size_t len, int prot, int flags, void *data, off_t offset) +static caddr_t local_mmap (vfs *me, caddr_t addr, size_t len, int prot, int flags, void *data, off_t offset) { int fd = * (int *)data; return mmap (addr, len, prot, flags, fd, offset); } -static int local_munmap (caddr_t addr, size_t len, void *data) +static int local_munmap (vfs *me, caddr_t addr, size_t len, void *data) { return munmap (addr, len); } #endif +static int local_which(vfs *me, char *path) +{ + return 0; /* Every path which other systems do not like is expected to be ours */ +} + vfs local_vfs_ops = { + NULL, /* This is place of next pointer */ + "Local filesystem", + 0, /* flags */ + NULL, /* prefix */ + NULL, /* data */ + 0, /* errno */ + NULL, + NULL, + NULL, + local_which, + local_open, local_close, local_read, @@ -295,7 +311,6 @@ vfs local_vfs_ops = { local_mkdir, local_rmdir, - NULL, NULL, NULL #ifdef HAVE_MMAP diff --git a/vfs/mcfs.c b/vfs/mcfs.c index c4be8de32..b6508fb5e 100644 --- a/vfs/mcfs.c +++ b/vfs/mcfs.c @@ -6,18 +6,18 @@ Andrej Borsenkow Norbert Warmuth - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License + as published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + GNU Library General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include @@ -83,7 +83,7 @@ char *mcfs_get_host_and_username (char *path, char **host, char **user, return get_host_and_username (path, host, user, port, 0, 0, pass); } -void mcfs_fill_names (void (*func)(char *)) +void mcfs_fill_names (vfs *me, void (*func)(char *)) { int i; char *name; @@ -455,7 +455,7 @@ static char *mcfs_gethome (mcfs_connection *mc) } /* The callbacks */ -static void *mcfs_open (char *file, int flags, int mode) +static void *mcfs_open (vfs *me, char *file, int flags, int mode) { char *remote_file; mcfs_connection *mc; @@ -549,7 +549,7 @@ static int mcfs_close (void *data) return result; } -static int mcfs_errno (void) +static int mcfs_errno (vfs *me) { return mcfs_errno_var; } @@ -568,7 +568,7 @@ typedef struct { dir_entry *current; } opendir_info; -static void *mcfs_opendir (char *dirname) +static void *mcfs_opendir (vfs *me, char *dirname) { opendir_info *mcfs_info; mcfs_connection *mc; @@ -817,12 +817,12 @@ static int mcfs_stat_cmd (int cmd, char *path, struct stat *buf) return the_error (-1, EIO); } -static int mcfs_stat (char *path, struct stat *buf) +static int mcfs_stat (vfs *me, char *path, struct stat *buf) { return mcfs_stat_cmd (MC_STAT, path, buf); } -static int mcfs_lstat (char *path, struct stat *buf) +static int mcfs_lstat (vfs *me, char *path, struct stat *buf) { int path_len = strlen (path); int entry_len = strlen (mcfs_readdir_data.dent.d_name); @@ -859,17 +859,17 @@ int mcfs_fstat (void *data, struct stat *buf) return the_error (-1, EIO); } -int mcfs_chmod (char *path, int mode) +int mcfs_chmod (vfs *me, char *path, int mode) { return mcfs_rpc_path_int (MC_CHMOD, path, mode); } -int mcfs_chown (char *path, int owner, int group) +int mcfs_chown (vfs *me, char *path, int owner, int group) { return mcfs_rpc_path_int_int (MC_CHOWN, path, owner, group); } -int mcfs_utime (char *path, struct utimbuf *times) +int mcfs_utime (vfs *me, char *path, struct utimbuf *times) { mcfs_connection *mc; int status; @@ -902,7 +902,7 @@ int mcfs_utime (char *path, struct utimbuf *times) return (status); } -static int mcfs_readlink (char *path, char *buf, int size) +static int mcfs_readlink (vfs *me, char *path, char *buf, int size) { char *remote_file, *stat_str; int status, error; @@ -927,22 +927,22 @@ static int mcfs_readlink (char *path, char *buf, int size) return strlen (buf); } -int mcfs_unlink (char *path) +int mcfs_unlink (vfs *me, char *path) { return mcfs_rpc_path (MC_UNLINK, path); } -int mcfs_symlink (char *n1, char *n2) +int mcfs_symlink (vfs *me, char *n1, char *n2) { return mcfs_rpc_two_paths (MC_SYMLINK, n1, n2); } -int mcfs_rename (char *a, char *b) +int mcfs_rename (vfs *me, char *a, char *b) { return mcfs_rpc_two_paths (MC_RENAME, a, b); } -static int mcfs_chdir (char *path) +static int mcfs_chdir (vfs *me, char *path) { char *remote_dir; mcfs_connection *mc; @@ -984,22 +984,22 @@ int mcfs_lseek (void *data, off_t offset, int whence) return mcfs_handle_simple_error (sock, 1); } -int mcfs_mknod (char *path, int mode, int dev) +int mcfs_mknod (vfs *me, char *path, int mode, int dev) { return mcfs_rpc_path_int_int (MC_MKNOD, path, mode, dev); } -int mcfs_mkdir (char *path, mode_t mode) +int mcfs_mkdir (vfs *me, char *path, mode_t mode) { return mcfs_rpc_path_int (MC_MKDIR, path, mode); } -int mcfs_rmdir (char *path) +int mcfs_rmdir (vfs *me, char *path) { return mcfs_rpc_path (MC_RMDIR, path); } -int mcfs_link (char *p1, char *p2) +int mcfs_link (vfs *me, char *p1, char *p2) { return mcfs_rpc_two_paths (MC_LINK, p1, p2); } @@ -1007,7 +1007,7 @@ int mcfs_link (char *p1, char *p2) /* We do not free anything right now: we free resources when we run * out of them */ -static vfsid mcfs_getid (char *p, struct vfs_stamping **parent) +static vfsid mcfs_getid (vfs *me, char *p, struct vfs_stamping **parent) { *parent = NULL; @@ -1024,28 +1024,19 @@ static void mcfs_free (vfsid id) /* FIXME: Should not be empty */ } -static char *mcfs_getlocalcopy (char *path) -{ - return mc_def_getlocalcopy (path); -} - -static void mcfs_ungetlocalcopy (char *path, char *local, int has_changed) -{ - mc_def_ungetlocalcopy (path, local, has_changed); -} - /* Gives up on a socket and reopnes the connection, the child own the socket * now */ -void -mcfs_forget (char *path) +static void +my_forget (char *path) { char *host, *user, *pass, *p; int port, i, vers; - - if (strncmp (path, "mc:", 3) != 0) - return; - path += 3; + + if (strncmp (path, "/#mc:", 5)) { + vfs_die( "Mcfs: this should not happen.\n" ); + } + path += 5; if (path[0] == '/' && path[1] == '/') path += 2; @@ -1075,19 +1066,29 @@ mcfs_forget (char *path) wipe_password (pass); } -#ifdef HAVE_MMAP -caddr_t mcfs_mmap (caddr_t addr, size_t len, int prot, int flags, void *data, off_t offset) +static int +mcfs_setctl (vfs *me, char *path, int ctlop, char *arg) { - return (caddr_t)-1; /* We do not mmap to far away */ + switch (ctlop) { + case MCCTL_FORGET_ABOUT: + my_forget(path); + return 0; + } + return 0; } -int mcfs_munmap (caddr_t addr, size_t len, void *data) -{ - return -1; -} -#endif - vfs mcfs_vfs_ops = { + NULL, /* This is place of next pointer */ + "Midnight Commander's private remote filesystem", + F_NET, /* flags */ + "mcfs:", /* prefix */ + NULL, /* data */ + 0, /* errno */ + NULL, + NULL, + mcfs_fill_names, + NULL, + mcfs_open, mcfs_close, mcfs_read, @@ -1122,17 +1123,15 @@ vfs mcfs_vfs_ops = { mcfs_nothingisopen, mcfs_free, - mcfs_getlocalcopy, - mcfs_ungetlocalcopy, + NULL, + NULL, mcfs_mkdir, mcfs_rmdir, NULL, - NULL, - mcfs_forget -#ifdef HAVE_MMAP - , mcfs_mmap, - mcfs_munmap -#endif + mcfs_setctl + +MMAPNULL }; +/* FIXME: should add mc_setctl() and make it call mcfs_forget */ diff --git a/vfs/names.c b/vfs/names.c index 489cef385..e82354cc0 100644 --- a/vfs/names.c +++ b/vfs/names.c @@ -3,19 +3,17 @@ From GNU Tar. -GNU Tar is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) +GNU Tar is free software; you can redistribute it and/or modify it +under the terms of the GNU Library General Public License as published +by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Tar is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. +GNU Library General Public License for more details. -You should have received a copy of the GNU General Public License -along with GNU Tar; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + */ /* * Look up user and/or group names. diff --git a/vfs/sfs.c b/vfs/sfs.c index 39f66dcdc..3cc50c585 100644 --- a/vfs/sfs.c +++ b/vfs/sfs.c @@ -24,7 +24,7 @@ #include "vfs.h" -char *shell = "/bin/bash"; +char *shell = "/bin/sh"; struct cachedfile { char *name, *cache; @@ -49,7 +49,7 @@ static int uptodate( char *name, char *cache ) return 1; } -static int vfmake( char *name, char *cache ) +static int vfmake( vfs *me, char *name, char *cache ) { char *inpath, *op; int w; @@ -58,7 +58,7 @@ static int vfmake( char *name, char *cache ) int was_percent = 0; vfs_split( name, &inpath, &op ); - if ((w = sfs_which( op )) == -1) + if ((w = (*me->which)( me, op )) == -1) vfs_die( "This cannot happen... Hopefully.\n" ); if ((sfs_flags[w] & F_1) || (!strcmp( name, "/" ))) ; else return -1; @@ -95,7 +95,7 @@ static int vfmake( char *name, char *cache ) } #define CUR (*cur) -static char *redirect( char *name ) +static char *redirect( vfs *me, char *name ) { struct cachedfile *cur = head; uid_t uid = vfs_uid; @@ -114,7 +114,7 @@ static char *redirect( char *name ) } cache = tempnam( NULL, "sfs" ); xname = strdup( name ); - if (!vfmake( name, cache )) { + if (!vfmake( me, name, cache )) { cur = xmalloc( sizeof(struct cachedfile), "SFS cache" ); cur->name = xname; cur->cache = strdup(cache); @@ -133,9 +133,9 @@ static char *redirect( char *name ) return "/I_MUST_NOT_EXIST"; } -#define REDIR path = redirect( path ); +#define REDIR path = redirect( me, path ); -static void *sfs_open (char *path, int flags, int mode) +static void *sfs_open (vfs *me, char *path, int flags, int mode) { int *sfs_info; int fd; @@ -151,13 +151,13 @@ static void *sfs_open (char *path, int flags, int mode) return sfs_info; } -static int sfs_stat (char *path, struct stat *buf) +static int sfs_stat (vfs *me, char *path, struct stat *buf) { REDIR; return stat (path, buf); } -static int sfs_lstat (char *path, struct stat *buf) +static int sfs_lstat (vfs *me, char *path, struct stat *buf) { REDIR; #ifndef HAVE_STATLSTAT @@ -167,31 +167,31 @@ static int sfs_lstat (char *path, struct stat *buf) #endif } -static int sfs_chmod (char *path, int mode) +static int sfs_chmod (vfs *me, char *path, int mode) { REDIR; return chmod (path, mode); } -static int sfs_chown (char *path, int owner, int group) +static int sfs_chown (vfs *me, char *path, int owner, int group) { REDIR; return chown (path, owner, group); } -static int sfs_utime (char *path, struct utimbuf *times) +static int sfs_utime (vfs *me, char *path, struct utimbuf *times) { REDIR; return utime (path, times); } -static int sfs_readlink (char *path, char *buf, int size) +static int sfs_readlink (vfs *me, char *path, char *buf, int size) { REDIR; return readlink (path, buf, size); } -static vfsid sfs_getid (char *path, struct vfs_stamping **parent) +static vfsid sfs_getid (vfs *me, char *path, struct vfs_stamping **parent) { /* FIXME: what should I do? */ vfs *v; vfsid id; @@ -212,7 +212,7 @@ static vfsid sfs_getid (char *path, struct vfs_stamping **parent) { char *path2 = strdup( path ); v = vfs_split (path2, NULL, NULL); - id = (*v->getid) (path2, &par); + id = (*v->getid) (v, path2, &par); free( path2 ); } @@ -243,7 +243,7 @@ static void sfs_free (vfsid id) } #undef CUR -void sfs_fill_names (void (*func)(char *)) +static void sfs_fill_names (vfs *me, void (*func)(char *)) { struct cachedfile *cur = head; @@ -258,25 +258,25 @@ static int sfs_nothingisopen (vfsid id) return 0; } -static char *sfs_getlocalcopy (char *path) +static char *sfs_getlocalcopy (vfs *me, char *path) { REDIR; return strdup (path); } -static void sfs_ungetlocalcopy (char *path, char *local, int has_changed) +static void sfs_ungetlocalcopy (vfs *me, char *path, char *local, int has_changed) { } #ifdef HAVE_MMAP -static caddr_t sfs_mmap (caddr_t addr, size_t len, int prot, int flags, void *data, off_t offset) +static caddr_t sfs_mmap (vfs *me, caddr_t addr, size_t len, int prot, int flags, void *data, off_t offset) { int fd = * (int *)data; return mmap (addr, len, prot, flags, fd, offset); } -static int sfs_munmap (caddr_t addr, size_t len, void *data) +static int sfs_munmap (vfs *me, caddr_t addr, size_t len, void *data) { return munmap (addr, len); } @@ -285,65 +285,15 @@ static int sfs_munmap (caddr_t addr, size_t len, void *data) extern int local_close (void *data); extern int local_read (void *data, char *buffer, int count); extern int local_fstat (void *data, struct stat *buf); -extern int local_errno (void); +extern int local_errno (vfs *me); extern int local_lseek (void *data, off_t offset, int whence); -vfs sfs_vfs_ops = { - sfs_open, - local_close, - local_read, - NULL, - - NULL, - NULL, - NULL, - NULL, - NULL, - - sfs_stat, - sfs_lstat, - local_fstat, - - sfs_chmod, - sfs_chown, - sfs_utime, - - sfs_readlink, - NULL, - NULL, - NULL, - - NULL, - NULL, - local_errno, - local_lseek, - NULL, - - sfs_getid, - sfs_nothingisopen, - sfs_free, - - sfs_getlocalcopy, - sfs_ungetlocalcopy, - - NULL, - NULL, - - NULL, - NULL, - NULL -#ifdef HAVE_MMAP - ,sfs_mmap, - sfs_munmap -#endif -}; - -void sfs_init (void) +int sfs_init (vfs *me) { FILE *cfg = fopen( LIBDIR "extfs/sfs.ini", "r" ); if (!cfg) { fprintf( stderr, "Warning: " LIBDIR "extfs/sfs.ini not found\n" ); - return; + return 0; } sfs_no = 0; @@ -389,9 +339,10 @@ void sfs_init (void) sfs_no++; } fclose(cfg); + return 1; } -void sfs_done (void) +void sfs_done (vfs *me) { int i; for (i=0; ilinkname); } - -static int s_chdir (char *path) +static int s_chdir (vfs *me, char *path) { char *remote_path; struct connection *bucket; @@ -729,8 +731,7 @@ static int s_lseek (void *data, off_t offset, int whence) return lseek(fp->local_handle, offset, whence); } - -static vfsid s_getid (char *p, struct vfs_stamping **parent) +static vfsid s_getid (vfs *me, char *p, struct vfs_stamping **parent) { struct connection *bucket; char *remote_path; @@ -758,9 +759,9 @@ static void s_free (vfsid id) linklist_delete(connections_list, bucket); } -static char *s_getlocalcopy (char *path) +static char *s_getlocalcopy (vfs *me, char *path) { - struct filp *fp = (struct filp *) s_open (path, O_RDONLY, 0); + struct filp *fp = (struct filp *) s_open (me, path, O_RDONLY, 0); char *p; if (fp == NULL) @@ -776,9 +777,9 @@ static char *s_getlocalcopy (char *path) return p; } -static void s_ungetlocalcopy (char *path, char *local, int has_changed) +static void s_ungetlocalcopy (vfs *me, char *path, char *local, int has_changed) { - struct filp *fp = (struct filp *) s_open (path, O_WRONLY, 0); + struct filp *fp = (struct filp *) s_open (me, path, O_WRONLY, 0); if (fp == NULL) return; @@ -790,12 +791,12 @@ static void s_ungetlocalcopy (char *path, char *local, int has_changed) } else { /* Should not happen */ s_close ((void *) fp); - mc_def_ungetlocalcopy (path, local, has_changed); + mc_def_ungetlocalcopy (me, path, local, has_changed); } } void -X_done(void) +X_done(vfs *me) { linklist_destroy(connections_list, connection_destructor); connections_list = NULL; diff --git a/vfs/shared_tar_ext.c b/vfs/shared_tar_ext.c index b9b3ce3a7..83b8c68dd 100644 --- a/vfs/shared_tar_ext.c +++ b/vfs/shared_tar_ext.c @@ -108,12 +108,12 @@ static struct entry *find_entry (struct entry *dir, char *name, int make_dirs, i } -static int s_errno (void) +static int s_errno (vfs *me) { return my_errno; } -static void * s_opendir (char *dirname) +static void * s_opendir (vfs *me, char *dirname) { struct archive *archive; char *q; @@ -219,9 +219,6 @@ static int s_internal_stat (char *path, struct stat *buf, int resolve) char *q; struct entry *entry; struct inode *inode; -char debugbuf[10240]; -strcpy( debugbuf, path ); - if ((q = get_path_mangle (path, &archive, 0, 0)) == NULL) return -1; @@ -235,12 +232,12 @@ strcpy( debugbuf, path ); return 0; } -static int s_stat (char *path, struct stat *buf) +static int s_stat (vfs *me, char *path, struct stat *buf) { return s_internal_stat (path, buf, 1); } -static int s_lstat (char *path, struct stat *buf) +static int s_lstat (vfs *me, char *path, struct stat *buf) { return s_internal_stat (path, buf, 0); } @@ -255,7 +252,7 @@ static int s_fstat (void *data, struct stat *buf) return 0; } -static int s_readlink (char *path, char *buf, int size) +static int s_readlink (vfs *me, char *path, char *buf, int size) { struct archive *archive; char *q; diff --git a/vfs/tar.c b/vfs/tar.c index 1d725349a..dca5643d9 100644 --- a/vfs/tar.c +++ b/vfs/tar.c @@ -4,18 +4,18 @@ Written by: 1995 Jakub Jelinek Rewritten by: 1998 Pavel Machek - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License + as published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + GNU Library General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include @@ -85,7 +85,7 @@ static struct stat hstat; /* Stat struct corresponding */ static char *current_file_name, *current_link_name; static struct entry *find_entry (struct entry *dir, char *name, int make_dirs, int make_file); -void tarfs_fill_names (void (*func)(char *)) +void tarfs_fill_names (vfs *me, void (*func)(char *)) { struct archive *a = first_archive; char *name; @@ -820,7 +820,7 @@ static char *get_path_mangle (char *inname, struct archive **archive, int is_dir parent = xmalloc (sizeof (struct vfs_stamping), "vfs stamping"); parent->v = v; parent->next = 0; - parent->id = (*v->getid) (archive_name, &(parent->parent)); + parent->id = (*v->getid) (v, archive_name, &(parent->parent)); } vfs_add_noncurrent_stamps (&tarfs_vfs_ops, (vfsid) parc, parent); vfs_rm_parents (parent); @@ -892,7 +892,7 @@ struct pseudofile { static struct entry *find_entry (struct entry *dir, char *name, int make_dirs, int make_file); -static void *tar_open (char *file, int flags, int mode) +static void *tar_open (vfs *me, char *file, int flags, int mode) { struct pseudofile *tar_info; struct archive *archive; @@ -984,7 +984,7 @@ static int tar_close (void *data) parent = xmalloc (sizeof (struct vfs_stamping), "vfs stamping"); parent->v = v; parent->next = 0; - parent->id = (*v->getid) (file->archive->name, &(parent->parent)); + parent->id = (*v->getid) (v, file->archive->name, &(parent->parent)); } vfs_add_noncurrent_stamps (&tarfs_vfs_ops, (vfsid) (file->archive), parent); vfs_rm_parents (parent); @@ -997,17 +997,17 @@ static int tar_close (void *data) #include "shared_tar_ext.c" -static int tar_chmod (char *path, int mode) +static int tar_chmod (vfs *me, char *path, int mode) { /* Fixme: are you sure? IMO this is guaranteed to fail */ return chmod (path, mode); } -static int tar_chown (char *path, int owner, int group) +static int tar_chown (vfs *me, char *path, int owner, int group) { /* Fixme: are you sure? IMO this is guaranteed to fail */ return chown (path, owner, group); } -static int tar_chdir (char *path) +static int tar_chdir (vfs *me, char *path) { struct archive *archive; char *q; @@ -1046,7 +1046,7 @@ static int tar_lseek (void *data, off_t offset, int whence) return file->pos; } -static vfsid tar_getid (char *path, struct vfs_stamping **parent) +static vfsid tar_getid (vfs *me, char *path, struct vfs_stamping **parent) { struct archive *archive; vfs *v; @@ -1059,7 +1059,7 @@ static vfsid tar_getid (char *path, struct vfs_stamping **parent) return (vfsid) -1; free(p); v = vfs_type (archive->name); - id = (*v->getid) (archive->name, &par); + id = (*v->getid) (v, archive->name, &par); if (id != (vfsid)-1) { *parent = xmalloc (sizeof (struct vfs_stamping), "vfs stamping"); (*parent)->v = v; @@ -1120,7 +1120,7 @@ static void tar_free (vfsid id) free_archive (archive); } -static char *tar_getlocalcopy (char *path) +static char *tar_getlocalcopy (vfs *me, char *path) { struct archive *archive; char *p, *q; @@ -1138,21 +1138,37 @@ static char *tar_getlocalcopy (char *path) if (entry->inode->local_filename != NULL) return entry->inode->local_filename; - p = mc_def_getlocalcopy (buf); + p = mc_def_getlocalcopy (me, buf); if (p != NULL) { entry->inode->local_filename = p; } return p; } -static void tar_ungetlocalcopy (char *path, char *local, int has_changed) +static void tar_ungetlocalcopy (vfs *me, char *path, char *local, int has_changed) { /* We do just nothing. (We are read only and do not need to free local, since it will be freed when tar archive will be freed */ } +int tarfs_init(vfs *me) +{ + return 1; +} + vfs tarfs_vfs_ops = { + NULL, /* This is place of next pointer */ + "TApe aRchiver decompressor", + 0, /* flags */ + "utar", /* prefix */ + NULL, /* data */ + 0, /* errno */ + tarfs_init, + NULL, + tarfs_fill_names, + NULL, + tar_open, tar_close, tar_read, @@ -1193,7 +1209,6 @@ vfs tarfs_vfs_ops = NULL, /* mkdir */ NULL, NULL, - NULL, NULL #ifdef HAVE_MMAP , NULL, diff --git a/vfs/tcputil.c b/vfs/tcputil.c index 3a08de590..3853fc981 100644 --- a/vfs/tcputil.c +++ b/vfs/tcputil.c @@ -3,19 +3,20 @@ Copyright (C) 1995, 1996 Miguel de Icaza - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License + as published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + GNU Library General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + #include #include #include diff --git a/vfs/undelfs.c b/vfs/undelfs.c index 98c65bace..539a4ea9e 100644 --- a/vfs/undelfs.c +++ b/vfs/undelfs.c @@ -10,18 +10,18 @@ Written by: 1995 Miguel de Icaza. 1997 Norbert Warmuth. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License + as published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + GNU Library General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Assumptions: @@ -274,7 +274,7 @@ void com_err (const char *str, long err_code, const char *s2, ...) } static void * -undelfs_opendir (char *dirname) +undelfs_opendir (vfs *me, char *dirname) { char *file, *f; @@ -386,7 +386,7 @@ typedef struct { /* We do not support lseek */ static void * -undelfs_open (char *fname, int flags, int mode) +undelfs_open (vfs *me, char *fname, int flags, int mode) { char *file, *f; ino_t inode, i; @@ -560,7 +560,7 @@ do_stat (int inode_index, struct stat *buf) } static int -undelfs_lstat(char *path, struct stat *buf) +undelfs_lstat(vfs *me, char *path, struct stat *buf) { int inode_index; char *file, *f; @@ -598,9 +598,9 @@ undelfs_lstat(char *path, struct stat *buf) } static int -undelfs_stat(char *path, struct stat *buf) +undelfs_stat(vfs *me, char *path, struct stat *buf) { - return undelfs_lstat (path, buf); + return undelfs_lstat (me, path, buf); } @@ -613,7 +613,7 @@ undelfs_fstat (void *vfs_info, struct stat *buf) } static int -undelfs_chdir(char *path) +undelfs_chdir(vfs *me, char *path) { char *file, *f; int fd; @@ -645,7 +645,7 @@ undelfs_lseek(void *vfs_info, off_t offset, int whence) } static vfsid -undelfs_getid(char *path, struct vfs_stamping **parent) +undelfs_getid(vfs *me, char *path, struct vfs_stamping **parent) { char *ext2_fname, *file; @@ -673,6 +673,17 @@ undelfs_free(vfsid id) } vfs undelfs_vfs_ops = { + NULL, /* This is place of next pointer */ + "Undelete filesystem for ext2", + 0, /* flags */ + "undel:", /* prefix */ + NULL, /* data */ + 0, /* errno */ + NULL, + NULL, + NULL, /* fill_names */ + NULL, + undelfs_open, undelfs_close, undelfs_read, @@ -713,10 +724,7 @@ vfs undelfs_vfs_ops = { NULL, NULL, NULL, - NULL, NULL -#ifdef HAVE_MMAP - , NULL, - NULL -#endif + +MMAPNULL }; diff --git a/vfs/utilvfs.c b/vfs/utilvfs.c index 9814b19fe..1de214b84 100644 --- a/vfs/utilvfs.c +++ b/vfs/utilvfs.c @@ -4,19 +4,20 @@ Copyright (C) 1995, 1996 Miguel de Icaza - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License + as published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + GNU Library General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + #ifndef test_get_host_and_username #include #endif diff --git a/vfs/vfs.c b/vfs/vfs.c index adf2e9b6f..8f701e520 100644 --- a/vfs/vfs.c +++ b/vfs/vfs.c @@ -5,18 +5,18 @@ 1995 Jakub Jelinek 1998 Pavel Machek - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License + as published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + GNU Library General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Warning: funtions like extfs_lstat() have right to destroy any @@ -103,31 +103,39 @@ static int get_bucket (void) return 0; /* Shut up, stupid gcc */ } +static vfs *vfs_list = &local_vfs_ops; /* It _has_ to be the first */ + +#define FOR_ALL_VFS for (vfs=vfs_list; vfs; vfs=vfs->next) + +int vfs_register( vfs *vfs ) +{ + int res = (vfs->init) ? (*vfs->init)(vfs) : 1; + if (!res) return 0; + vfs->next = vfs_list; + vfs_list = vfs; +#if 0 + fprintf( stderr, "VFS %s successfully registered\n", vfs->name ); +#endif + return 1; +} + vfs *vfs_type_from_op (char *path) { -#ifdef USE_NETCODE - if (!(vfs_flags & FL_NO_MCFS) && !strncmp (path, "mc:", 3)) - return &mcfs_vfs_ops; - if (!(vfs_flags & FL_NO_FTPFS) && !strncmp (path, "ftp:", 4)) - return &ftpfs_vfs_ops; -#endif -#ifdef USE_EXT2FSLIB - if (!(vfs_flags & FL_NO_UNDELFS) && !strncmp (path, "undel:", 6)) - return &undelfs_vfs_ops; -#endif - if (!(vfs_flags & FL_NO_FISH) && !strncmp (path, "sh:", 3)) - return &fish_vfs_ops; - if (!(vfs_flags & FL_NO_FISH) && !strncmp (path, "ssh:", 4)) - return &fish_vfs_ops; - if (!(vfs_flags & FL_NO_FISH) && !strncmp (path, "rsh:", 4)) - return &fish_vfs_ops; - if (!(vfs_flags & FL_NO_TARFS) && !strcmp (path, "utar")) - return &tarfs_vfs_ops; - if (!(vfs_flags & FL_NO_EXTFS) && extfs_which (path) != -1) - return &extfs_vfs_ops; - if (!(vfs_flags & FL_NO_SFS) && sfs_which (path) != -1) - return &sfs_vfs_ops; - return NULL; + vfs *vfs; + FOR_ALL_VFS { + if (vfs == &local_vfs_ops) /* local catches all */ + return NULL; + if (vfs->which) { + if ((*vfs->which) (vfs, path) != -1) + return vfs; + else + continue; + } + if (!strncmp (path, vfs->prefix, strlen (vfs->prefix))) + return vfs; + } + vfs_die( "No local in vfs list?" ); + return NULL; /* shut up stupid gcc */ } int path_magic( char *path ) @@ -298,7 +306,7 @@ void vfs_rmstamp (vfs *v, vfsid id, int removeparents) static int ferrno (vfs *vfs) { - return vfs->ferrno ? (*vfs->ferrno)() : EOPNOTSUPP; + return vfs->ferrno ? (*vfs->ferrno)(vfs) : EOPNOTSUPP; /* Hope that error message is obscure enough ;-) */ } @@ -320,7 +328,7 @@ int mc_open (char *file, int flags, ...) if (!vfs->open) vfs_die( "VFS must support open.\n" ); - info = (*vfs->open) (file, flags, mode); /* open must be supported */ + info = (*vfs->open) (vfs, file, flags, mode); /* open must be supported */ free (file); if (!info){ errno = ferrno (vfs); @@ -375,7 +383,7 @@ int mc_setctl (char *path, int ctlop, char *arg) path = vfs_canon (path); vfs = vfs_type (path); - result = vfs->setctl ? (*vfs->setctl)(path, ctlop, arg) : 0; + result = vfs->setctl ? (*vfs->setctl)(vfs, path, ctlop, arg) : 0; free (path); return result; } @@ -420,7 +428,7 @@ DIR *mc_opendir (char *dirname) dirname = vfs_canon (dirname); vfs = vfs_type (dirname); - info = vfs->opendir ? (*vfs->opendir)(dirname) : NULL; + info = vfs->opendir ? (*vfs->opendir)(vfs, dirname) : NULL; free (dirname); if (p) free (p); @@ -491,8 +499,8 @@ int mc_closedir (DIR *dirp) return result; } -MC_NAMEOP (stat, (char *path, struct stat *buf), (vfs_name (path), buf)) -MC_NAMEOP (lstat, (char *path, struct stat *buf), (vfs_name (path), buf)) +MC_NAMEOP (stat, (char *path, struct stat *buf), (vfs, vfs_name (path), buf)) +MC_NAMEOP (lstat, (char *path, struct stat *buf), (vfs, vfs_name (path), buf)) MC_HANDLEOP (fstat, (int handle, struct stat *buf), (vfs_info (handle), buf)) /* @@ -535,12 +543,12 @@ char *mc_get_current_wd (char *buffer, int size) return buffer; } -MC_NAMEOP (chmod, (char *path, int mode), (vfs_name (path), mode)) -MC_NAMEOP (chown, (char *path, int owner, int group), (vfs_name (path), owner, group)) -MC_NAMEOP (utime, (char *path, struct utimbuf *times), (vfs_name (path), times)) -MC_NAMEOP (readlink, (char *path, char *buf, int bufsiz), (vfs_name (path), buf, bufsiz)) -MC_NAMEOP (unlink, (char *path), (vfs_name (path))) -MC_NAMEOP (symlink, (char *name1, char *path), (vfs_name (name1), vfs_name (path))) +MC_NAMEOP (chmod, (char *path, int mode), (vfs, vfs_name (path), mode)) +MC_NAMEOP (chown, (char *path, int owner, int group), (vfs, vfs_name (path), owner, group)) +MC_NAMEOP (utime, (char *path, struct utimbuf *times), (vfs, vfs_name (path), times)) +MC_NAMEOP (readlink, (char *path, char *buf, int bufsiz), (vfs, vfs_name (path), buf, bufsiz)) +MC_NAMEOP (unlink, (char *path), (vfs, vfs_name (path))) +MC_NAMEOP (symlink, (char *name1, char *path), (vfs, vfs_name (name1), vfs_name (path))) #define MC_RENAMEOP(name) \ int mc_##name (char *name1, char *name2) \ @@ -558,7 +566,7 @@ int mc_##name (char *name1, char *name2) \ return -1; \ } \ \ - result = vfs->name ? (*vfs->name)(vfs_name (name1), vfs_name (name2)) : -1; \ + result = vfs->name ? (*vfs->name)(vfs, vfs_name (name1), vfs_name (name2)) : -1; \ free (name1); \ free (name2); \ if (result == -1) \ @@ -679,7 +687,7 @@ vfsid vfs_ncs_getid (vfs *nvfs, char *dir, struct vfs_stamping **par) dir = copy_strings (dir, "/", NULL); freeit = 1; } - nvfsid = (*nvfs->getid)(dir, par); + nvfsid = (*nvfs->getid)(nvfs, dir, par); if (freeit) free (dir); return nvfsid; @@ -826,7 +834,7 @@ int mc_chdir (char *path) current_dir = vfs_canon (path); current_vfs = vfs_type (current_dir); b = strdup (current_dir); - result = (*current_vfs->chdir) ? (*current_vfs->chdir)(vfs_name (b)) : -1; + result = (*current_vfs->chdir) ? (*current_vfs->chdir)(current_vfs, vfs_name (b)) : -1; free (b); if (result == -1){ errno = ferrno (current_vfs); @@ -907,9 +915,9 @@ void vfs_setup_wd (void) return; } -MC_NAMEOP (mkdir, (char *path, mode_t mode), (vfs_name (path), mode)) -MC_NAMEOP (rmdir, (char *path), (vfs_name (path))) -MC_NAMEOP (mknod, (char *path, int mode, int dev), (vfs_name (path), mode, dev)) +MC_NAMEOP (mkdir, (char *path, mode_t mode), (vfs, vfs_name (path), mode)) +MC_NAMEOP (rmdir, (char *path), (vfs, vfs_name (path))) +MC_NAMEOP (mknod, (char *path, int mode, int dev), (vfs, vfs_name (path), mode, dev)) #ifdef HAVE_MMAP struct mc_mmapping { @@ -930,7 +938,7 @@ mc_mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t offset) return (caddr_t) -1; vfs = vfs_op (fd); - result = vfs->mmap ? (*vfs->mmap)(addr, len, prot, flags, vfs_info (fd), offset) : (caddr_t)-1; + result = vfs->mmap ? (*vfs->mmap)(vfs, addr, len, prot, flags, vfs_info (fd), offset) : (caddr_t)-1; if (result == (caddr_t)-1){ errno = ferrno (vfs); return (caddr_t)-1; @@ -955,7 +963,7 @@ int mc_munmap (caddr_t addr, size_t len) else mcm2->next = mcm->next; if (*mcm->vfs->munmap) - (*mcm->vfs->munmap)(addr, len, mcm->vfs_info); + (*mcm->vfs->munmap)(mcm->vfs, addr, len, mcm->vfs_info); free (mcm); return 0; } @@ -965,7 +973,7 @@ int mc_munmap (caddr_t addr, size_t len) #endif -char *mc_def_getlocalcopy (char *filename) +char *mc_def_getlocalcopy (vfs *vfs, char *filename) { char *tmp; int fdin, fdout, i; @@ -1002,15 +1010,15 @@ char *mc_getlocalcopy (char *path) path = vfs_canon (path); vfs = vfs_type (path); - result = vfs->getlocalcopy ? (*vfs->getlocalcopy)(vfs_name (path)) : - mc_def_getlocalcopy (vfs_name (path)); + result = vfs->getlocalcopy ? (*vfs->getlocalcopy)(vfs, vfs_name (path)) : + mc_def_getlocalcopy (vfs, vfs_name (path)); free (path); if (!result) errno = ferrno (vfs); return result; } -void mc_def_ungetlocalcopy (char *filename, char *local, int has_changed) +void mc_def_ungetlocalcopy (vfs *vfs, char *filename, char *local, int has_changed) { if (has_changed){ int fdin, fdout, i; @@ -1047,8 +1055,8 @@ void mc_ungetlocalcopy (char *path, char *local, int has_changed) path = vfs_canon (path); vfs = vfs_type (path); - vfs->ungetlocalcopy ? (*vfs->ungetlocalcopy)(vfs_name (path), local, has_changed) : - mc_def_ungetlocalcopy (vfs_name (path), local, has_changed); + vfs->ungetlocalcopy ? (*vfs->ungetlocalcopy)(vfs, vfs_name (path), local, has_changed) : + mc_def_ungetlocalcopy (vfs, vfs_name (path), local, has_changed); free (path); } @@ -1090,14 +1098,24 @@ void vfs_init (void) current_mday = t->tm_mday; current_mon = t->tm_mon; current_year = t->tm_year; - + + /* We do not want to register local_vfs_ops */ + #ifdef USE_NETCODE tcp_init(); - ftpfs_init(); + vfs_register (&ftpfs_vfs_ops); + vfs_register (&mcfs_vfs_ops); #endif - fish_init (); - extfs_init (); - sfs_init (); + + vfs_register (&fish_vfs_ops); + vfs_register (&extfs_vfs_ops); + vfs_register (&sfs_vfs_ops); + vfs_register (&tarfs_vfs_ops); + +#ifdef USE_EXT2FSLIB + vfs_register (&undelfs_vfs_ops); +#endif + vfs_setup_wd (); } @@ -1131,6 +1149,7 @@ void vfs_shut_path (char *p) void vfs_shut (void) { struct vfs_stamping *stamp, *st; + vfs *vfs; for (stamp = stamps, stamps = 0; stamp != NULL;){ (*stamp->v->free)(stamp->id); @@ -1145,12 +1164,9 @@ void vfs_shut (void) if (current_dir) free (current_dir); - extfs_done (); - sfs_done(); -#ifdef USE_NETCODE - fish_done(); - ftpfs_done(); -#endif + FOR_ALL_VFS + if (vfs->done) + (*vfs->done) (vfs); } /* These ones grab information from the VFS @@ -1158,14 +1174,10 @@ void vfs_shut (void) */ void vfs_fill_names (void (*func)(char *)) { -#ifdef USE_NETCODE - mcfs_fill_names (func); - ftpfs_fill_names (func); - fish_fill_names (func); -#endif - tarfs_fill_names (func); - extfs_fill_names (func); - sfs_fill_names (func); + vfs *vfs; + FOR_ALL_VFS + if (vfs->fill_names) + (*vfs->fill_names) (vfs, func); } /* Following stuff (parse_ls_lga) is used by ftpfs and extfs */ @@ -1564,13 +1576,7 @@ int parse_ls_lga (char *p, struct stat *s, char **filename, char **linkname) void vfs_force_expire (char *pathname) { - vfs *vfs; - - pathname = vfs_canon (pathname); - vfs = vfs_type (pathname); - if (vfs->forget_about) - (*vfs->forget_about) (pathname); - free (pathname); + mc_setctl( pathname, MCCTL_FORGET_ABOUT, NULL ); } void diff --git a/vfs/vfs.h b/vfs/vfs.h index fc3f15d41..204a551e3 100644 --- a/vfs/vfs.h +++ b/vfs/vfs.h @@ -1,17 +1,6 @@ #ifndef __VFS_H #define __VFS_H -#ifdef VFS_STANDALONE -#undef USE_EXT2FSLIB -#else -#define BROKEN_PATHS -/* - * We should really only allow /#ftp/ tree to export ftp, but midnight's users may - * like to be able to cd .. to get back where there were before ftp. How to solve? - * Ok, we'll allow /any/path/#ftp/ to access ftp tree. Broken, yes. - */ -#endif - #if !defined(SCO_FLAVOR) || !defined(_SYS_SELECT_H) # include /* alex: this redefines struct timeval */ #endif /* SCO_FLAVOR */ @@ -30,58 +19,81 @@ struct utimbuf { #include #endif +#ifdef VFS_STANDALONE +#undef USE_EXT2FSLIB +#else +#define BROKEN_PATHS +/* + * We should really only allow /#ftp/ tree to export ftp, but midnight's users may + * like to be able to cd .. to get back where there were before ftp. How to solve? + * Ok, we'll allow /any/path/#ftp/ to access ftp tree. Broken, yes. + */ +#endif + /* Our virtual file system layer */ typedef void * vfsid; struct vfs_stamping; - typedef struct { - void *(*open)(char *fname, int flags, int mode); + typedef struct vfs { + struct vfs *next; + char *name; /* "FIles over SHell" */ + int flags; +#define F_EXEC 1 +#define F_NET 2 + char *prefix; /* "#fish:" */ + void *data; /* this is for filesystem's own use */ + int errno; + int (*init)(struct vfs *me); /* 1..initialized succesfully */ + void (*done)(struct vfs *me); + void (*fill_names)(struct vfs *me, void (*)(char *)); + int (*which)(struct vfs *me, char *path); /* Returns '-1' if this path does not belong to this filesystem */ + + void *(*open)(struct vfs *me, char *fname, int flags, int mode); int (*close)(void *vfs_info); int (*read)(void *vfs_info, char *buffer, int count); int (*write)(void *vfs_info, char *buf, int count); - void *(*opendir)(char *dirname); + void *(*opendir)(struct vfs *me, char *dirname); void *(*readdir)(void *vfs_info); int (*closedir)(void *vfs_info); - int (*telldir)(void *dir); - void (*seekdir)(void *dir, int offset); + int (*telldir)(void *vfs_info); + void (*seekdir)(void *vfs_info, int offset); - int (*stat)(char *path, struct stat *buf); - int (*lstat)(char *path, struct stat *buf); + int (*stat)(struct vfs *me, char *path, struct stat *buf); + int (*lstat)(struct vfs *me, char *path, struct stat *buf); int (*fstat)(void *vfs_info, struct stat *buf); - int (*chmod)(char *path, int mode); - int (*chown)(char *path, int owner, int group); - int (*utime)(char *path, struct utimbuf *times); + int (*chmod)(struct vfs *me, char *path, int mode); + int (*chown)(struct vfs *me, char *path, int owner, int group); + int (*utime)(struct vfs *me, char *path, struct utimbuf *times); - int (*readlink)(char *path, char *buf, int size); - int (*symlink)(char *n1, char *n2); - int (*link)(char *p1, char *p2); - int (*unlink)(char *path); - int (*rename)(char *p1, char *p2); - int (*chdir)(char *path); - int (*ferrno)(void); + int (*readlink)(struct vfs *me, char *path, char *buf, int size); + int (*symlink)(struct vfs *me, char *n1, char *n2); + int (*link)(struct vfs *me, char *p1, char *p2); + int (*unlink)(struct vfs *me, char *path); + int (*rename)(struct vfs *me, char *p1, char *p2); + int (*chdir)(struct vfs *me, char *path); + int (*ferrno)(struct vfs *me); int (*lseek)(void *vfs_info, off_t offset, int whence); - int (*mknod)(char *path, int mode, int dev); + int (*mknod)(struct vfs *me, char *path, int mode, int dev); - vfsid (*getid)(char *path, struct vfs_stamping **parent); + vfsid (*getid)(struct vfs *me, char *path, struct vfs_stamping **parent); int (*nothingisopen)(vfsid id); void (*free)(vfsid id); - char *(*getlocalcopy)(char *filename); - void (*ungetlocalcopy)(char *filename, char *local, int has_changed); + char *(*getlocalcopy)(struct vfs *me, char *filename); + void (*ungetlocalcopy)(struct vfs *me, char *filename, char *local, int has_changed); - int (*mkdir)(char *path, mode_t mode); - int (*rmdir)(char *path); + int (*mkdir)(struct vfs *me, char *path, mode_t mode); + int (*rmdir)(struct vfs *me, char *path); int (*ctl)(void *vfs_info, int ctlop, int arg); - int (*setctl)(char *path, int ctlop, char *arg); - void (*forget_about)(char *path); + int (*setctl)(struct vfs *me, char *path, int ctlop, char *arg); #ifdef HAVE_MMAP - caddr_t (*mmap)(caddr_t addr, size_t len, int prot, int flags, void *vfs_info, off_t offset); - int (*munmap)(caddr_t addr, size_t len, void *vfs_info); + caddr_t (*mmap)(struct vfs *me, caddr_t addr, size_t len, int prot, int flags, void *vfs_info, off_t offset); + int (*munmap)(struct vfs *me, caddr_t addr, size_t len, void *vfs_info); #endif } vfs; @@ -139,15 +151,6 @@ struct utimbuf { /* Required for the vfs_canon routine */ char *tarfs_analysis (char *inname, char **archive, int is_dir); - void ftpfs_init(void); - void fish_init(void); - void sfs_init(void); - void ftpfs_done(void); - void sfs_done(void); - void fish_done(void); - int extfs_which (char *path); - int sfs_which (char *path); - void ftpfs_set_debug (char *file); #ifdef USE_NETCODE void ftpfs_hint_reread(int reread); @@ -156,12 +159,6 @@ struct utimbuf { # define ftpfs_flushdir() # define ftpfs_hint_reread(x) #endif - /* They fill the file system names */ - void mcfs_fill_names (void (*)(char *)); - void ftpfs_fill_names (void (*)(char *)); - void tarfs_fill_names (void (*)(char *)); - void fish_fill_names (void (*)(char *)); - void sfs_fill_names (void (*)(char *)); /* Only the routines outside of the VFS module need the emulation macros */ @@ -196,8 +193,8 @@ struct utimbuf { int mc_mkdir (char *path, mode_t mode); char *mc_getlocalcopy (char *filename); void mc_ungetlocalcopy (char *filename, char *local, int has_changed); - char *mc_def_getlocalcopy (char *filename); - void mc_def_ungetlocalcopy (char *filename, char *local, int has_changed); + char *mc_def_getlocalcopy (vfs *vfs, char *filename); + void mc_def_ungetlocalcopy (vfs *vfs, char *filename, char *local, int has_changed); int mc_ctl (int fd, int ctlop, int arg); int mc_setctl (char *path, int ctlop, char *arg); #ifdef HAVE_MMAP @@ -307,6 +304,8 @@ int parse_filedate(int idx, time_t *t); extern void vfs_die (char *msg); extern char *vfs_get_password (char *msg); +void print_vfs_stats (char *fs_name, char *action, char *file_name, int have, int need); + #define MCCTL_SETREMOTECOPY 0 #define MCCTL_ISREMOTECOPY 1 #define MCCTL_REMOTECOPYCHUNK 2 @@ -314,6 +313,7 @@ extern char *vfs_get_password (char *msg); #define MCCTL_FLUSHDIR 4 /* Unreferenced */ #define MCCTL_REMOVELOCALCOPY 5 #define MCCTL_IS_NOTREADY 6 +#define MCCTL_FORGET_ABOUT 7 /* Return codes from the ${fs}_ctl routine */ @@ -371,11 +371,13 @@ extern void mc_vfs_done( void ); * cases (ftp transfer). -- pavel@ucw.cz */ -#ifndef MIN -#define MIN(a,b) ((a)<(b) ? (a) : (b)) -#endif -#ifndef MAX -#define MAX(a,b) ((a)<(b) ? (b) : (a)) +#define VFS_MIN(a,b) ((a)<(b) ? (a) : (b)) +#define VFS_MAX(a,b) ((a)<(b) ? (b) : (a)) + +#ifdef HAVE_MMAP +#define MMAPNULL , NULL, NULL +#else +#define MMAPNULL #endif #endif /* __VFS_H */