pax_global_header 0000666 0000000 0000000 00000000064 12557450341 0014520 g ustar 00root root 0000000 0000000 52 comment=8f06fc9d92fcea2d36491448be804c14807e292f
libnfs-libnfs-1.9.8/ 0000775 0000000 0000000 00000000000 12557450341 0014267 5 ustar 00root root 0000000 0000000 libnfs-libnfs-1.9.8/.gitignore 0000664 0000000 0000000 00000000640 12557450341 0016257 0 ustar 00root root 0000000 0000000 .*
*.h
*.c
*.in
*.la
*.a
*.lo
*.o
*.obj
*.lib
*.dll
*.ilk
*.pdb
*.ex?
*-stamp
libnfs-raw-*.x
Makefile
examples/nfsclient-raw
examples/nfsclient-sync
examples/nfsclient-async
examples/nfsclient-bcast
examples/nfsclient-listservers
aclocal.m4
autom4te.cache/
compile
config.guess
config.h.in~
config.log
config.status
config.sub
configure
depcomp
install-sh
libtool
ltmain.sh
missing
stamp-h1
libnfs.pc
!libnfs.pc.in
libnfs-libnfs-1.9.8/COPYING 0000664 0000000 0000000 00000001722 12557450341 0015324 0 ustar 00root root 0000000 0000000 Libnfs components fall under two separate licences
The library sources and include directories
===========================================
The nfs client library itself, i.e. the lib and include directories,
is licenced under GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
The protocol definition, .x, files
==================================
These are based on old RFCs and studying how wireshark dissects various packets.
These are distributed under the simplified BSD licence.
The examples directory
================================
The utility and example applications using this library, i.e. the
examples directory, are licenced under the GNU General Public License
as published by the Free Software Foundation; either version 3 of the
License, or (at your option) any later version.
To avoid any confusion, every source file contains a licence boilerplate.
libnfs-libnfs-1.9.8/LICENCE-BSD.txt 0000664 0000000 0000000 00000002661 12557450341 0016505 0 ustar 00root root 0000000 0000000 Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.
libnfs-libnfs-1.9.8/LICENCE-GPL-3.txt 0000664 0000000 0000000 00000104513 12557450341 0016656 0 ustar 00root root 0000000 0000000 GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, 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
them 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 prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If 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 convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU 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
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "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 PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state 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 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 3 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.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
Copyright (C)
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
.
libnfs-libnfs-1.9.8/LICENCE-LGPL-2.1.txt 0000664 0000000 0000000 00000063642 12557450341 0017137 0 ustar 00root root 0000000 0000000 GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
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 Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
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 and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
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 other code 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.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
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, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser 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 combine 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) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) 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.
d) 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.
e) 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 materials to be 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 with
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 Lesser 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 Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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!
libnfs-libnfs-1.9.8/Makefile.am 0000664 0000000 0000000 00000000453 12557450341 0016325 0 ustar 00root root 0000000 0000000 SUBDIRS = doc mount nfs nlm nsm portmap rquota lib include utils . $(MAYBE_EXAMPLES)
ACLOCAL_AMFLAGS = -I m4
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libnfs.pc
EXTRA_DIST = \
README \
COPYING \
LICENCE-BSD.txt \
LICENCE-GPL-3.txt \
LICENCE-LGPL-2.1.txt \
examples \
libnfs.pc.in
libnfs-libnfs-1.9.8/README 0000664 0000000 0000000 00000012752 12557450341 0015156 0 ustar 00root root 0000000 0000000 LIBNFS is a client library for accessing NFS shares over a network.
LIBNFS offers three different APIs, for different use :
1, RAW : A fully async low level RPC library for NFS protocols
This API is described in include/libnfs-raw.h
it offers a fully async interface to raw XDR encoded blobs.
This API provides very flexible and precise control of the RPC issued.
examples/nfsclient-raw.c provides examples on how to use the raw API
2, NFS ASYNC : A fully asynchronous library for high level vfs functions
This API is described by the *_async() functions in include/libnfs.h.
This API provides a fully async access to posix vfs like functions such as
stat(), read(), ...
examples/nfsclient-async.c provides examples on how to use this API
3, NFS SYNC : A synchronous library for high level vfs functions
This API is described by the *_sync() functions in include/libnfs.h.
This API provides access to posix vfs like functions such as
stat(), read(), ...
examples/nfsclient-sync.c provides examples on how to use this API
URL-FORMAT:
===========
Libnfs uses RFC2224 style URLs extended with libnfs specific url arguments some minor extensions.
The basic syntax of these URLs is :
nfs:///path[?arg=val[&arg=val]*]
Arguments supported by libnfs are :
tcp-syncnt= : Number of SYNs to send during the session establish
before failing setting up the tcp connection to the
server.
uid= : UID value to use when talking to the server.
default it 65534 on Windows and getuid() on unixen.
gid= : GID value to use when talking to the server.
default it 65534 on Windows and getgid() on unixen.
readahead= : Enable readahead for files and set the maximum amount
of readahead to .
auto-traverse-mounts=<0|1>
: Should libnfs try to traverse across nested mounts
automatically or not. Default is 1 == enabled.
Auto_traverse_mounts
====================
Normally in NFSv3 if a server has nested exports, for example if it would
export both /data and /data/tmp then a client would need to mount
both these exports as well.
The reason is because the NFSv3 protocol does not allow a client request
to return data for an object in a different filesystem/mount.
(legacy, but it is what it is. One reason for this restriction is to
guarantee that inodes are uniqe across the mounted system.)
This option, when enabled will make libnfs perform all these mounts
internally for you. This means that one libnfs mount may now have files
with duplicate inode values so if you cache files based on inode
make sure you cache files based on BOTH st.st_ino and st.st_dev.
ROOT vs NON-ROOT
================
When running as root, libnfs tries to allocate a system port for its connection
to the NFS server. When running as non-root it will use a normal
ephemeral port.
Many NFS servers default to a mode where they do not allow non-system
ports from connecting.
These servers require you use the "insecure" export option in /etc/exports
in order to allow libnfs clients to be able to connect.
Some versions of Linux support special capabilities that can be assigned to
programs to allow non-root users to bind to system ports.
This is set up by running
sudo setcap 'cap_net_bind_service=+ep' /path/to/executable
When libnfs is linked against an executable with this special capability
assigned to it, libnfs may be able to use system ports even when executing
under the privilege of a non-root user account.
This is highly non-portable so IF this works on your linux system, count
yourself lucky.
DOCUMENTATION
=============
libnfs sources ship with prebuilt manpage(s) in the doc directory.
If you change the manpage sources you need to manually regenerate the new
manpages by running
cd doc
make doc
FUSE
====
A simple FUSE filesystem built on libnfs can be found in
examples/fuse_nfs.c
Compile using : gcc fuse_nfs.c -o fuse_nfs -lfuse -lnfs
Mount using : sudo ./fuse_nfs -n nfs:/// -m
PLATFORM support
=================
This is a truly multiplatform library.
Linux: - tested with Ubuntu 10.04 - should work with others as well
Cygwin: - tested under 64bit win2k8.
MacOSX: - tested with SDK 10.4 (under Snow Leopard) - should also work with later SDKs and 64Bit
iOS: - tested with iOS SDK 4.2 - running on iOS 4.3.x
FreeBSD:- tested with 8.2
Solaris
Windows:- tested on Windows 7 64 and Windows XP 32 using Visual Studio 10 (see README.win32.txt for build instructions)
Android:
AROS: - Build with 'make -f aros/Makefile.AROS'
LD_PRELOAD
==========
examples/ld_nfs.c contains a LD_PRELOADable module that can be used to make
several standard utilities nfs aware.
It is still very incomplete but can be used for basic things such as cat and cp.
Patches to add more coverage is welcome.
Compile with :
gcc -fPIC -shared -o ld_nfs.so examples/ld_nfs.c -ldl -lnfs
Then try things like
LD_NFS_DEBUG=9 LD_PRELOAD=./ld_nfs.so cat nfs://127.0.0.1/data/tmp/foo123
LD_NFS_DEBUG=9 LD_PRELOAD=./ld_nfs.so cp nfs://127.0.0.1/data/tmp/foo123 nfs://127.0.0.1/data/tmp/foo123.copy
This is just a toy preload module. Don't open bugs if it does not work. Send
patches to make it better instead.
RELEASE TARBALLS
================
Release tarballs are available at
https://sites.google.com/site/libnfstarballs/li
MAILING LIST
============
A libnfs mailing list is available at http://groups.google.com/group/libnfs
Announcements of new versions of libnfs will be posted to this list.
libnfs-libnfs-1.9.8/aros/ 0000775 0000000 0000000 00000000000 12557450341 0015233 5 ustar 00root root 0000000 0000000 libnfs-libnfs-1.9.8/aros/Makefile.AROS 0000775 0000000 0000000 00000002737 12557450341 0017452 0 ustar 00root root 0000000 0000000 AR=ar
CC=gcc
CFLAGS=-g -O0 -DAROS=1 -D_U_=" " -DHAVE_SOCKADDR_LEN -I. -Iinclude -Iinclude/nfsc -Iaros -Infs -Imount
OBJS=lib/init.o lib/libnfs.o lib/libnfs-sync.o lib/libnfs-zdr.o lib/pdu.o lib/socket.o
OBJS+=mount/mount.o mount/libnfs-raw-mount.o
OBJS+=nfs/nfs.o nfs/nfsacl.o nfs/libnfs-raw-nfs.o
OBJS+=nlm/nlm.o nlm/libnfs-raw-nlm.o
OBJS+=portmap/portmap.o portmap/libnfs-raw-portmap.o
OBJS+=rquota/rquota.o rquota/libnfs-raw-rquota.o
OBJS+=aros/aros_compat.o
EXAMPLES=examples/nfsclient-listservers examples/nfsclient-sync examples/nfs-cp examples/nfs-ls
all: lib/libnfs.a $(EXAMPLES)
lib/libnfs.a: $(OBJS)
$(AR) cru $@ $(OBJS)
.c.o:
echo $(CC) $(CFLAGS) -c -o $@ $<
$(CC) $(CFLAGS) -c -o $@ $<
install: all
cp lib/libnfs.a GCC:lib
mkdir -p INCLUDE:nfsc
cp include/nfsc/libnfs.h INCLUDE:nfsc
cp include/nfsc/libnfs-raw.h INCLUDE:nfsc
cp include/nfsc/libnfs-zdr.h INCLUDE:nfsc
cp mount/libnfs-raw-mount.h INCLUDE:nfsc
cp nlm/libnfs-raw-nlm.h INCLUDE:nfsc
cp nfs/libnfs-raw-nfs.h INCLUDE:nfsc
cp portmap/libnfs-raw-portmap.h INCLUDE:nfsc
cp rquota/libnfs-raw-rquota.h INCLUDE:nfsc
examples/nfsclient-listservers: examples/nfsclient-listservers.c lib/libnfs.a
$(CC) $(CFLAGS) -o $@ $< lib/libnfs.a
examples/nfsclient-sync: examples/nfsclient-sync.c lib/libnfs.a
$(CC) $(CFLAGS) -o $@ $< lib/libnfs.a
examples/nfs-ls: examples/nfs-ls.c lib/libnfs.a
$(CC) $(CFLAGS) -o $@ $< lib/libnfs.a
examples/nfs-cp: examples/nfs-cp.c lib/libnfs.a
$(CC) $(CFLAGS) -o $@ $< lib/libnfs.a
libnfs-libnfs-1.9.8/aros/aros_compat.c 0000664 0000000 0000000 00000010123 12557450341 0017703 0 ustar 00root root 0000000 0000000 /*
Copyright (C) 2013 by Ronnie Sahlberg
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, see .
*/
#include
#include
#include
#include
#include
#include
#include
#include "aros_compat.h"
#include
#include
#undef poll
int aros_getnameinfo(const struct sockaddr *sa, socklen_t salen,
char *host, size_t hostlen,
char *serv, size_t servlen, int flags)
{
struct sockaddr_in *sin = (struct sockaddr_in *)sa;
if (host) {
snprintf(host, hostlen, Inet_NtoA(sin->sin_addr.s_addr));
}
return 0;
}
int aros_getaddrinfo(const char *node, const char*service,
const struct addrinfo *hints,
struct addrinfo **res)
{
struct sockaddr_in *sin;
sin = malloc(sizeof(struct sockaddr_in));
sin->sin_len = sizeof(struct sockaddr_in);
sin->sin_family=AF_INET;
/* Some error checking would be nice */
sin->sin_addr.s_addr = inet_addr(node);
sin->sin_port=0;
if (service) {
sin->sin_port=htons(atoi(service));
}
*res = malloc(sizeof(struct addrinfo));
(*res)->ai_family = AF_INET;
(*res)->ai_addrlen = sizeof(struct sockaddr_in);
(*res)->ai_addr = (struct sockaddr *)sin;
return 0;
}
void aros_freeaddrinfo(struct addrinfo *res)
{
free(res->ai_addr);
free(res);
}
int aros_inet_pton(int af, char *src, void *dst)
{
struct sockaddr_in sin;
sin.sin_addr.s_addr = inet_addr(src);
memcpy(dst, &sin.sin_addr.s_addr, sizeof(sin.sin_addr.s_addr));
return 1;
}
/* unix device numbers dont really make much sense on aros ... */
int major(int i)
{
return 1;
}
int minor(int i)
{
return 2;
}
struct Library * SocketBase = NULL;
extern int errno;
int h_errno = 0;
void aros_init_socket(void)
{
if (!(SocketBase = OpenLibrary("bsdsocket.library", 4))) {
printf("NoTCP/IP Stack available");
exit(10);
}
if (SocketBaseTags(SBTM_SETVAL(SBTC_ERRNOPTR(sizeof(errno))),
(IPTR)&errno,
SBTM_SETVAL(SBTC_HERRNOLONGPTR),
(IPTR)&h_errno, TAG_DONE)) {
printf("Failed to set ERRNO");
exit(10);
}
}
int aros_poll(struct pollfd *fds, unsigned int nfds, int timo)
{
struct timeval timeout, *toptr;
fd_set ifds, ofds, efds, *ip, *op;
unsigned int i, maxfd = 0;
int rc;
// Set up the file-descriptor sets in ifds, ofds and efds.
FD_ZERO(&ifds);
FD_ZERO(&ofds);
FD_ZERO(&efds);
for (i = 0, op = ip = 0; i < nfds; ++i)
{
fds[i].revents = 0;
if(fds[i].events & (POLLIN|POLLPRI))
{
ip = &ifds;
FD_SET(fds[i].fd, ip);
}
if(fds[i].events & POLLOUT)
{
op = &ofds;
FD_SET(fds[i].fd, op);
}
FD_SET(fds[i].fd, &efds);
if (fds[i].fd > maxfd) {
maxfd = fds[i].fd;
}
}
// Set up the timeval structure for the timeout parameter
if(timo < 0)
{
toptr = 0;
}
else
{
toptr = &timeout;
timeout.tv_sec = timo / 1000;
timeout.tv_usec = (timo - timeout.tv_sec * 1000) * 1000;
}
rc = WaitSelect(maxfd + 1, ip, op, &efds, toptr, NULL);
if(rc <= 0)
return rc;
if(rc > 0)
{
for (i = 0; i < nfds; ++i)
{
int fd = fds[i].fd;
if(fds[i].events & (POLLIN|POLLPRI) && FD_ISSET(fd, &ifds))
fds[i].revents |= POLLIN;
if(fds[i].events & POLLOUT && FD_ISSET(fd, &ofds))
fds[i].revents |= POLLOUT;
if(FD_ISSET(fd, &efds)) // Some error was detected ... should be some way to know.
fds[i].revents |= POLLHUP;
}
}
return rc;
}
libnfs-libnfs-1.9.8/aros/aros_compat.h 0000664 0000000 0000000 00000004053 12557450341 0017715 0 ustar 00root root 0000000 0000000 /*
Copyright (C) 2013 by Ronnie Sahlberg
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, see .
*/
#ifndef AROS_COMPAT_H
#define AROS_COMPAT_H
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define statvfs statfs
#define ioctl IoctlSocket
#define close CloseSocket
#define inet_pton aros_inet_pton
#define freeaddrinfo aros_freeaddrinfo
#define getnameinfo aros_getnameinfo
#define getaddrinfo aros_getaddrinfo
extern struct Library * SocketBase;
void aros_init_socket(void);
#define f_flag f_flags
#define f_favail f_ffree
/* we dont have these at all */
#define f_fsid f_spare[0]
#define f_frsize f_spare[0]
#define f_namemax f_spare[0]
#define POLLIN 0x0001 /* There is data to read */
#define POLLPRI 0x0002 /* There is urgent data to read */
#define POLLOUT 0x0004 /* Writing now will not block */
#define POLLERR 0x0008 /* Error condition */
#define POLLHUP 0x0010 /* Hung up */
#define POLLNVAL 0x0020 /* Invalid request: fd not open */
struct utimbuf {
int actime;
int modtime;
};
struct pollfd {
int fd; /* file descriptor */
short events; /* requested events */
short revents; /* returned events */
};
#define poll(x, y, z) aros_poll(x, y, z)
#endif
libnfs-libnfs-1.9.8/bootstrap 0000775 0000000 0000000 00000000036 12557450341 0016231 0 ustar 00root root 0000000 0000000 #!/bin/bash
autoreconf -vif
libnfs-libnfs-1.9.8/configure.ac 0000664 0000000 0000000 00000011124 12557450341 0016554 0 ustar 00root root 0000000 0000000 AC_PREREQ(2.50)
AC_INIT([libnfs], [1.9.8], [ronniesahlberg@gmail.com])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([-Wall foreign])
AC_CANONICAL_HOST
AC_CONFIG_MACRO_DIR([m4])
m4_pattern_allow([AM_PROG_AR])
AM_PROG_AR
# Work around stupid autoconf default cflags. pt 1
SAVE_CFLAGS="x${CFLAGS}"
AC_PROG_CC
AC_PROG_LIBTOOL
AM_PROG_CC_C_O
PKG_PROG_PKG_CONFIG
# Work around stupid autoconf default cflags. pt 2
if test "$SAVE_CFLAGS" = "x"; then
CFLAGS=""
fi
# We always want 64 bit file offsets
CFLAGS="${CFLAGS} -D_FILE_OFFSET_BITS=64"
#option: examples
AC_ARG_ENABLE([examples],
[AC_HELP_STRING([--enable-examples],
[Build example programs])],
[ENABLE_EXAMPLES=$enableval],
[ENABLE_EXAMPLES="no"])
# We need popt to compile the examples
if test x$ENABLE_EXAMPLES = xyes; then
AC_MSG_CHECKING(whether libpopt is available)
ac_save_CFLAGS="$CFLAGS"
ac_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $GLIB_CFLAGS"
LIBS="$GLIB_LIBS $LIBS -lpopt"
AC_TRY_RUN([
/*
* Just see if we can compile/link with popt
*/
#include
int main(int argc, const char *argv[])
{
struct poptOption popt_options[] = {
POPT_TABLEEND
};
poptGetContext(argv[0], argc, argv, popt_options, POPT_CONTEXT_KEEP_FIRST);
return 0;
}
], ac_cv_have_popt=yes, ac_cv_have_popt=no,
[echo $ac_n "compile with POPT. Assuming OK... $ac_c"
ac_cv_have_popt=yes])
CFLAGS="$ac_save_CFLAGS"
LIBS="$ac_save_LIBS"
if test "$ac_cv_have_popt" = yes ; then
AC_MSG_RESULT(yes)
MAYBE_EXAMPLES="examples"
else
AC_MSG_RESULT(no)
AC_MSG_NOTICE(You need libpopt to compile the sample libnfs clients.)
AC_MSG_NOTICE(Only the library will be compiled and installed.)
fi
fi
AC_SUBST(MAYBE_EXAMPLES)
WERROR_CFLAGS=""
AC_MSG_CHECKING(whether to set -Werror)
AC_ARG_ENABLE(werror, [ --disable-werror do not treat warnings as errors during build],
[ case "${enableval}" in
no)
AC_MSG_RESULT(no)
;;
*)
AC_MSG_RESULT(yes)
WERROR_CFLAGS="-Werror"
;;
esac ],
)
if test "$ac_cv_prog_gcc" = yes; then
WARN_CFLAGS="-Wall -Wshadow -Wno-write-strings -Wstrict-prototypes -Wpointer-arith -Wcast-align -Wno-strict-aliasing $WERROR_CFLAGS"
fi
AC_SUBST(WARN_CFLAGS)
case $host in
*solaris*)
AC_CHECK_HEADERS([sys/filio.h])
AC_CHECK_HEADERS([sys/sockio.h])
AC_CHECK_LIB([socket], [main], , [AC_MSG_ERROR([Can not find required library])])
AC_CHECK_LIB([nsl], [main], , [AC_MSG_ERROR([Can not find required library])])
;;
*)
;;
esac
# check for poll.h
dnl Check for poll.h
AC_CHECK_HEADERS([poll.h])
# check for unistd.h
dnl Check for unistd.h
AC_CHECK_HEADERS([unistd.h])
# check for netdb.h
dnl Check for netdb.h
AC_CHECK_HEADERS([netdb.h])
# check for utime.h
dnl Check for utime.h
AC_CHECK_HEADERS([utime.h])
# check for net/if.h
dnl Check for net/if.h
AC_CHECK_HEADERS([net/if.h])
# check for sys/time.h
dnl Check for sys/time.h
AC_CHECK_HEADERS([sys/time.h])
# check for sys/ioctl.h
dnl Check for sys/ioctl.h
AC_CHECK_HEADERS([sys/ioctl.h])
# check for sys/vfs.h
dnl Check for sys/vfs.h
AC_CHECK_HEADERS([sys/vfs.h])
# check for sys/statvfs.h
dnl Check for sys/statvfs.h
AC_CHECK_HEADERS([sys/statvfs.h])
# check for sys/socket.h
dnl Check for sys/socket.h
AC_CHECK_HEADERS([sys/socket.h])
# check for netinet/tcp.h
dnl Check for netinet/tcp.h
AC_CHECK_HEADERS([netinet/tcp.h])
# check for netinet/in.h
dnl Check for netinet/in.h
AC_CHECK_HEADERS([netinet/in.h])
# check for arpa/inet.h
dnl Check for arpa/inet.h
AC_CHECK_HEADERS([arpa/inet.h])
# check for SA_LEN
dnl Check if sockaddr data structure includes a "sa_len"
AC_CHECK_MEMBER([struct sockaddr.sa_len],
[ AC_DEFINE(HAVE_SOCKADDR_LEN,1,[Whether sockaddr struct has sa_len]) ],
[],
[
#include
#include
])
# check for sockaddr_storage
dnl Check if sockaddr structure includes a "ss_family"
AC_CHECK_MEMBER([struct sockaddr_storage.ss_family],
[ AC_DEFINE(HAVE_SOCKADDR_STORAGE,1,[Whether we have sockaddr_Storage]) ],
[],
[
#include
#include
])
AC_CHECK_MEMBERS([struct stat.st_mtim.tv_nsec])
# check where makedev is defined
AC_HEADER_MAJOR
#output
AC_CONFIG_FILES([Makefile]
[doc/Makefile]
[include/Makefile]
[lib/Makefile]
[mount/Makefile]
[nfs/Makefile]
[nlm/Makefile]
[nsm/Makefile]
[portmap/Makefile]
[rquota/Makefile]
[utils/Makefile]
[examples/Makefile]
)
AC_OUTPUT([libnfs.pc])
libnfs-libnfs-1.9.8/doc/ 0000775 0000000 0000000 00000000000 12557450341 0015034 5 ustar 00root root 0000000 0000000 libnfs-libnfs-1.9.8/doc/Makefile.am 0000664 0000000 0000000 00000001103 12557450341 0017063 0 ustar 00root root 0000000 0000000 XSLTPROC = /usr/bin/xsltproc
EXTRA_DIST = nfs-cat.1 nfs-cat.1.xml nfs-cp.1 nfs-cp.1.xml nfs-ls.1 nfs-ls.1.xml
# Manpages
man1_MANS = nfs-cat.1 nfs-cp.1 nfs-ls.1
doc:
-test -z "$(XSLTPROC)" || $(XSLTPROC) -o nfs-cat.1 http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl nfs-cat.1.xml
-test -z "$(XSLTPROC)" || $(XSLTPROC) -o nfs-cp.1 http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl nfs-cp.1.xml
-test -z "$(XSLTPROC)" || $(XSLTPROC) -o nfs-ls.1 http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl nfs-ls.1.xml
libnfs-libnfs-1.9.8/doc/nfs-cat.1 0000664 0000000 0000000 00000003242 12557450341 0016452 0 ustar 00root root 0000000 0000000 '\" t
.\" Title: nfs-cat
.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author]
.\" Generator: DocBook XSL Stylesheets v1.78.1
.\" Date: 05/24/2015
.\" Manual: nfs-cat: read a file from nfs
.\" Source: nfs-cat
.\" Language: English
.\"
.TH "NFS\-CAT" "1" "05/24/2015" "nfs\-cat" "nfs\-cat: read a file from nfs"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
nfs-cat \- Utility to read a file off NFS
.SH "SYNOPSIS"
.HP \w'\fBnfs\-cat\ \fR\ 'u
\fBnfs\-cat \fR
.SH "DESCRIPTION"
.PP
nfs\-cat is a utility to read a file off an NFS server\&.
.PP
Example: Print the content of a file:
.sp
.if n \{\
.RS 4
.\}
.nf
$ nfs\-cat nfs://127\&.0\&.0\&.1/data/tmp/foo\&.c
.fi
.if n \{\
.RE
.\}
.sp
.SH "SEE ALSO"
.PP
\m[blue]\fB\%http://github.com/sahlberg/libnfs\fR\m[]
libnfs-libnfs-1.9.8/doc/nfs-cat.1.xml 0000664 0000000 0000000 00000001676 12557450341 0017262 0 ustar 00root root 0000000 0000000
nfs-cat
1
nfs-cat
nfs-cat: read a file from nfs
nfs-cat
Utility to read a file off NFS
nfs-cat <NFS-URL>
DESCRIPTION
nfs-cat is a utility to read a file off an NFS server.
Example: Print the content of a file:
$ nfs-cat nfs://127.0.0.1/data/tmp/foo.c
SEE ALSO
libnfs-libnfs-1.9.8/doc/nfs-cp.1 0000664 0000000 0000000 00000003501 12557450341 0016303 0 ustar 00root root 0000000 0000000 '\" t
.\" Title: nfs-cp
.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author]
.\" Generator: DocBook XSL Stylesheets v1.78.1
.\" Date: 05/24/2015
.\" Manual: nfs-cp: copy files to/from an NFS share
.\" Source: nfs-cp
.\" Language: English
.\"
.TH "NFS\-CP" "1" "05/24/2015" "nfs\-cp" "nfs\-cp: copy files to/from an"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
nfs-cp \- Utility to copy files to/from and NFS server
.SH "SYNOPSIS"
.HP \w'\fBnfs\-cp\ \ \fR\ 'u
\fBnfs\-cp \fR
.SH "DESCRIPTION"
.PP
nfs\-cp is a utility to copy files to/from and NFS server\&.
.PP
Examples:
.sp
.if n \{\
.RS 4
.\}
.nf
$ nfs\-cp foo\&.c nfs://127\&.0\&.0\&.1/data/tmp/foo\&.c
$ nfs\-cp nfs://127\&.0\&.0\&.1/data/tmp/foo\&.c bob\&.c
$ nfs\-cp nfs://127\&.0\&.0\&.1/data/tmp/foo\&.c nfs://127\&.0\&.0\&.1/data/tmp/copy\-of\-foo\&.c
.fi
.if n \{\
.RE
.\}
.sp
.SH "SEE ALSO"
.PP
\m[blue]\fB\%http://github.com/sahlberg/libnfs\fR\m[]
libnfs-libnfs-1.9.8/doc/nfs-cp.1.xml 0000664 0000000 0000000 00000002104 12557450341 0017100 0 ustar 00root root 0000000 0000000
nfs-cp
1
nfs-cp
nfs-cp: copy files to/from an NFS share
nfs-cp
Utility to copy files to/from and NFS server
nfs-cp <src> <dst>
DESCRIPTION
nfs-cp is a utility to copy files to/from and NFS server.
Examples:
$ nfs-cp foo.c nfs://127.0.0.1/data/tmp/foo.c
$ nfs-cp nfs://127.0.0.1/data/tmp/foo.c bob.c
$ nfs-cp nfs://127.0.0.1/data/tmp/foo.c nfs://127.0.0.1/data/tmp/copy-of-foo.c
SEE ALSO
libnfs-libnfs-1.9.8/doc/nfs-ls.1 0000664 0000000 0000000 00000006003 12557450341 0016317 0 ustar 00root root 0000000 0000000 '\" t
.\" Title: nfs-ls
.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author]
.\" Generator: DocBook XSL Stylesheets v1.78.1
.\" Date: 05/24/2015
.\" Manual: nfs-ls: list servers, exports and directories
.\" Source: nfs-ls
.\" Language: English
.\"
.TH "NFS\-LS" "1" "05/24/2015" "nfs\-ls" "nfs\-ls: list servers, exports"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
nfs-ls \- Utility to list NFS servers, exports and directories
.SH "SYNOPSIS"
.HP \w'\fBnfs\-ls\ [\ OPTIONS\ ]\ \fR\ 'u
\fBnfs\-ls [ OPTIONS ] \fR
.HP \w'\fBnfs\-ls\fR\ 'u
\fBnfs\-ls\fR [\-R\ \-\-recursive] [\-s\ \-\-summary] [\-D\ \-\-discovery] [\-?\ \-\-help] [\-\-usage]
.SH "DESCRIPTION"
.PP
nfs\-ls is a utility to list NFS servers, exports or directories\&.
.PP
Example: List the content of a directory on the NFS server
.sp
.if n \{\
.RS 4
.\}
.nf
$ nfs\-ls nfs://127\&.0\&.0\&.1/data/tmp
\-rwxrwxr\-x 1 1000 1000 1190802 a\&.out
\-rwxr\-xr\-x 1 1000 1000 13 foo123\&.copy
\-rwxrwxrwx 1 1000 1000 8 foo123\&.writtenx
.fi
.if n \{\
.RE
.\}
.sp
.SH "OPTIONS"
.PP
\-s \-\-summary
.RS 4
Print a summary line at the end of output\&.
.RE
.PP
\-R \-\-recursive
.RS 4
Recursive listing of the specified URL\&.
.RE
.PP
\-D \-\-discovery;
.RS 4
This option is used to discover local NFS servers and to list the exports for specific servers\&.
.sp
When used with the \*(Aqnfs://\*(Aq URL the command will try to detect all local NFS servers and will list their IPs\&.
.sp
When used with a \*(Aqnfs://server\*(Aq the command will list all the exports on the specified server\&.
.sp
Example: Discover and list all local NFS servers
.sp
.if n \{\
.RS 4
.\}
.nf
$ nfs\-ls \-D nfs://
nfs://10\&.10\&.10\&.10
nfs://10\&.0\&.0\&.10
.fi
.if n \{\
.RE
.\}
.sp
Example: List the exports for a server
.sp
.if n \{\
.RS 4
.\}
.nf
$ nfs\-ls \-D nfs://10\&.10\&.10\&.10
nfs://10\&.10\&.10\&.10/foo
nfs://10\&.10\&.10\&.10/bar
.fi
.if n \{\
.RE
.\}
.sp
.RE
.PP
\-? \-\-help
.RS 4
Display basic help text\&.
.RE
.PP
\-\-usage
.RS 4
Display basic usage text\&.
.RE
.SH "SEE ALSO"
.PP
\m[blue]\fB\%http://github.com/sahlberg/libnfs\fR\m[]
libnfs-libnfs-1.9.8/doc/nfs-ls.1.xml 0000664 0000000 0000000 00000006061 12557450341 0017122 0 ustar 00root root 0000000 0000000
nfs-ls
1
nfs-ls
nfs-ls: list servers, exports and directories
nfs-ls
Utility to list NFS servers, exports and directories
nfs-ls [ OPTIONS ] <NFS-URL>
nfs-ls
-R --recursive
-s --summary
-D --discovery
-? --help
--usage
DESCRIPTION
nfs-ls is a utility to list NFS servers, exports or directories.
Example: List the content of a directory on the NFS server
$ nfs-ls nfs://127.0.0.1/data/tmp
-rwxrwxr-x 1 1000 1000 1190802 a.out
-rwxr-xr-x 1 1000 1000 13 foo123.copy
-rwxrwxrwx 1 1000 1000 8 foo123.writtenx
OPTIONS
-s --summary
Print a summary line at the end of output.
-R --recursive
Recursive listing of the specified URL.
-D --discovery;
This option is used to discover local NFS servers and to list
the exports for specific servers.
When used with the 'nfs://' URL the command will try to
detect all local NFS servers and will list their IPs.
When used with a 'nfs://server' the command will
list all the exports on the specified server.
Example: Discover and list all local NFS servers
$ nfs-ls -D nfs://
nfs://10.10.10.10
nfs://10.0.0.10
Example: List the exports for a server
$ nfs-ls -D nfs://10.10.10.10
nfs://10.10.10.10/foo
nfs://10.10.10.10/bar
-? --help
Display basic help text.
--usage
Display basic usage text.
SEE ALSO
libnfs-libnfs-1.9.8/examples/ 0000775 0000000 0000000 00000000000 12557450341 0016105 5 ustar 00root root 0000000 0000000 libnfs-libnfs-1.9.8/examples/Makefile.am 0000664 0000000 0000000 00000000621 12557450341 0020140 0 ustar 00root root 0000000 0000000 noinst_PROGRAMS = nfsclient-async nfsclient-raw nfsclient-sync nfsclient-bcast nfsclient-listservers nfs-io portmap-client
AM_CPPFLAGS = \
-I$(abs_top_srcdir)/include \
-I$(abs_top_srcdir)/include/nfsc \
-I$(abs_top_srcdir)/mount \
-I$(abs_top_srcdir)/nfs \
-I$(abs_top_srcdir)/portmap \
-I$(abs_top_srcdir)/rquota \
"-D_U_=__attribute__((unused))"
AM_LDFLAGS = ../lib/.libs/libnfs.la -lpopt
libnfs-libnfs-1.9.8/examples/fuse_nfs.c 0000664 0000000 0000000 00000015562 12557450341 0020072 0 ustar 00root root 0000000 0000000 /*
Copyright (C) by Ronnie Sahlberg 2013
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 3 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.
You should have received a copy of the GNU General Public License
along with this program; if not, see .
*/
/* A FUSE filesystem based on libnfs. */
#define FUSE_USE_VERSION 26
#define _FILE_OFFSET_BITS 64
#include
#include
#include
#include
#include
#include
#include
#include
#define discard_const(ptr) ((void *)((intptr_t)(ptr)))
struct nfs_context *nfs = NULL;
static int fuse_nfs_getattr(const char *path, struct stat *stbuf)
{
int ret = 0;
struct nfs_stat_64 nfs_st;
ret = nfs_stat64(nfs, path, &nfs_st);
stbuf->st_dev = nfs_st.nfs_dev;
stbuf->st_ino = nfs_st.nfs_ino;
stbuf->st_mode = nfs_st.nfs_mode;
stbuf->st_nlink = nfs_st.nfs_nlink;
stbuf->st_uid = nfs_st.nfs_uid;
stbuf->st_gid = nfs_st.nfs_gid;
stbuf->st_rdev = nfs_st.nfs_rdev;
stbuf->st_size = nfs_st.nfs_size;
stbuf->st_blksize = nfs_st.nfs_blksize;
stbuf->st_blocks = nfs_st.nfs_blocks;
stbuf->st_atim.tv_sec = nfs_st.nfs_atime;
stbuf->st_atim.tv_usec = nfs_st.nfs_atime_nsec / 1000;
stbuf->st_mtim.tv_sec = nfs_st.nfs_mtime;
stbuf->st_mtim.tv_usec = nfs_st.nfs_mtime_nsec / 1000;
stbuf->st_ctim.tv_sec = nfs_st.nfs_ctime;
stbuf->st_ctim.tv_usec = nfs_st.nfs_ctime_nsec / 1000;
return ret;
}
static int fuse_nfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
off_t offset, struct fuse_file_info *fi)
{
struct nfsdir *nfsdir;
struct nfsdirent *nfsdirent;
int ret = 0;
ret = nfs_opendir(nfs, path, &nfsdir);
if (ret < 0) {
return ret;
}
while ((nfsdirent = nfs_readdir(nfs, nfsdir)) != NULL) {
filler(buf, nfsdirent->name, NULL, 0);
}
return ret;
}
static int fuse_nfs_open(const char *path, struct fuse_file_info *fi)
{
int ret = 0;
struct nfsfh *nfsfh;
fi->fh = 0;
ret = nfs_open(nfs, path, fi->flags, &nfsfh);
if (ret < 0) {
return ret;
}
fi->fh = (uint64_t)nfsfh;
return ret;
}
static int fuse_nfs_release(const char *path, struct fuse_file_info *fi)
{
struct nfsfh *nfsfh = (struct nfsfh *)fi->fh;
nfs_close(nfs, nfsfh);
return 0;
}
static int fuse_nfs_read(const char *path, char *buf, size_t size,
off_t offset, struct fuse_file_info *fi)
{
int ret = 0;
struct nfsfh *nfsfh = (struct nfsfh *)fi->fh;
ret = nfs_pread(nfs, nfsfh, offset, size, buf);
return ret;
}
static int fuse_nfs_write(const char *path, const char *buf, size_t size,
off_t offset, struct fuse_file_info *fi)
{
int ret = 0;
struct nfsfh *nfsfh = (struct nfsfh *)fi->fh;
ret = nfs_pwrite(nfs, nfsfh, offset, size, discard_const(buf));
return ret;
}
static int fuse_nfs_create(const char *path, mode_t mode, struct fuse_file_info *fi)
{
int ret = 0;
struct nfsfh *nfsfh;
ret = nfs_creat(nfs, path, mode, &nfsfh);
if (ret < 0) {
return ret;
}
fi->fh = (uint64_t)nfsfh;
return ret;
}
static int fuse_nfs_utime(const char *path, struct utimbuf *times)
{
int ret = 0;
ret = nfs_utime(nfs, path, times);
if (ret < 0) {
return ret;
}
return ret;
}
static int fuse_nfs_unlink(const char *path)
{
int ret = 0;
ret = nfs_unlink(nfs, path);
if (ret < 0) {
return ret;
}
return ret;
}
static int fuse_nfs_rmdir(const char *path)
{
int ret = 0;
ret = nfs_rmdir(nfs, path);
if (ret < 0) {
return ret;
}
return ret;
}
static int fuse_nfs_mkdir(const char *path, mode_t mode)
{
int ret = 0;
ret = nfs_mkdir(nfs, path);
if (ret < 0) {
return ret;
}
ret = nfs_chmod(nfs, path, mode);
if (ret < 0) {
return ret;
}
return ret;
}
static struct fuse_operations nfs_oper = {
.create = fuse_nfs_create,
.getattr = fuse_nfs_getattr,
.mkdir = fuse_nfs_mkdir,
.open = fuse_nfs_open,
.read = fuse_nfs_read,
.readdir = fuse_nfs_readdir,
.release = fuse_nfs_release,
.rmdir = fuse_nfs_rmdir,
.unlink = fuse_nfs_unlink,
.utime = fuse_nfs_utime,
.write = fuse_nfs_write,
};
void print_usage(char *name)
{
printf("Usage: %s [-?|--help] [-n|--nfs-share=nfs-url] [-m|--mountpoint=mountpoint]\n",
name);
exit(0);
}
int main(int argc, char *argv[])
{
int ret = 0;
static struct option long_opts[] = {
{ "help", no_argument, 0, '?' },
{ "nfs-share", required_argument, 0, 'n' },
{ "mountpoint", required_argument, 0, 'm' },
{ NULL, 0, 0, 0 }
};
int c;
int opt_idx = 0;
char *url = NULL;
char *mnt = NULL;
char *server = NULL, *export = NULL, *strp;
int fuse_nfs_argc = 6;
char *fuse_nfs_argv[16] = {
"fuse-nfs",
"",
"-oallow_other",
"-odefault_permissions",
"-omax_write=32768",
"-s",
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
};
while ((c = getopt_long(argc, argv, "?hm:n:", long_opts,
&opt_idx)) > 0) {
switch (c) {
case 'h':
case '?':
print_usage(argv[0]);
return 0;
case 'm':
mnt = strdup(optarg);
break;
case 'n':
url = strdup(optarg);
break;
}
}
if (url == NULL) {
fprintf(stderr, "-n was not specified.\n");
print_usage(argv[0]);
ret = 10;
goto finished;
}
if (mnt == NULL) {
fprintf(stderr, "-m was not specified.\n");
print_usage(argv[0]);
ret = 10;
goto finished;
}
if (strncmp(url, "nfs://", 6)) {
fprintf(stderr, "Invalid URL specified.\n");
ret = 10;
goto finished;
}
server = strdup(url + 6);
if (server == NULL) {
fprintf(stderr, "Failed to strdup server string\n");
ret = 10;
goto finished;
}
if (server[0] == '/' || server[0] == '\0') {
fprintf(stderr, "Invalid server string.\n");
ret = 10;
goto finished;
}
strp = strchr(server, '/');
if (strp == NULL) {
fprintf(stderr, "Invalid URL specified.\n");
ret = 10;
goto finished;
}
export = strdup(strp);
if (export == NULL) {
fprintf(stderr, "Failed to strdup server string\n");
ret = 10;
goto finished;
}
if (export[0] != '/') {
fprintf(stderr, "Invalid export.\n");
ret = 10;
goto finished;
}
*strp = 0;
nfs = nfs_init_context();
if (nfs == NULL) {
printf("failed to init context\n");
goto finished;
}
ret = nfs_mount(nfs, server, export);
if (ret != 0) {
printf("Failed to mount nfs share : %s\n", nfs_get_error(nfs));
goto finished;
}
fuse_nfs_argv[1] = mnt;
return fuse_main(fuse_nfs_argc, fuse_nfs_argv, &nfs_oper, NULL);
finished:
if (nfs != NULL) {
nfs_destroy_context(nfs);
}
free(server);
free(export);
free(url);
free(mnt);
return ret;
}
libnfs-libnfs-1.9.8/examples/ld_nfs.c 0000664 0000000 0000000 00000037301 12557450341 0017522 0 ustar 00root root 0000000 0000000 /*
Copyright (C) 2014 by Ronnie Sahlberg
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 3 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.
You should have received a copy of the GNU General Public License
along with this program; if not, see .
*/
#define _GNU_SOURCE
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define NFS_MAX_FD 255
static int debug = 0;
#ifndef discard_const
#define discard_const(ptr) ((void *)((intptr_t)(ptr)))
#endif
#define LD_NFS_DPRINTF(level, fmt, args...) \
do { \
if ((debug) >= level) { \
fprintf(stderr,"ld_nfs: "); \
fprintf(stderr, (fmt), ##args); \
fprintf(stderr,"\n"); \
} \
} while (0);
struct nfs_fd_list {
int is_nfs;
struct nfs_context *nfs;
struct nfsfh *fh;
/* so we can reopen and emulate dup2() */
const char *path;
int flags;
mode_t mode;
};
static struct nfs_fd_list nfs_fd_list[NFS_MAX_FD];
int (*real_open)(__const char *path, int flags, mode_t mode);
int open(const char *path, int flags, mode_t mode)
{
if (!strncmp(path, "nfs:", 4)) {
struct nfs_context *nfs;
struct nfs_url *url;
struct nfsfh *fh = NULL;
int ret, fd;
LD_NFS_DPRINTF(9, "open(%s, %x, %o)", path, flags, mode);
nfs = nfs_init_context();
if (nfs == NULL) {
LD_NFS_DPRINTF(1, "Failed to create context");
errno = ENOMEM;
return -1;
}
url = nfs_parse_url_full(nfs, path);
if (url == NULL) {
LD_NFS_DPRINTF(1, "Failed to parse URL: %s\n",
nfs_get_error(nfs));
nfs_destroy_context(nfs);
errno = EINVAL;
return -1;
}
if (nfs_mount(nfs, url->server, url->path) != 0) {
LD_NFS_DPRINTF(1, "Failed to mount nfs share : %s\n",
nfs_get_error(nfs));
nfs_destroy_url(url);
nfs_destroy_context(nfs);
errno = EINVAL;
return -1;
}
if (flags & O_CREAT) {
if ((ret = nfs_creat(nfs, url->file, mode, &fh)) != 0) {
LD_NFS_DPRINTF(1, "Failed to creat nfs file : "
"%s\n", nfs_get_error(nfs));
nfs_destroy_url(url);
nfs_destroy_context(nfs);
errno = -ret;
return -1;
}
} else {
if ((ret = nfs_open(nfs, url->file, flags, &fh)) != 0) {
LD_NFS_DPRINTF(1, "Failed to open nfs file : "
"%s\n", nfs_get_error(nfs));
nfs_destroy_url(url);
nfs_destroy_context(nfs);
errno = -ret;
return -1;
}
}
fd = nfs_get_fd(nfs);
if (fd >= NFS_MAX_FD) {
LD_NFS_DPRINTF(1, "Too many files open");
nfs_destroy_url(url);
nfs_destroy_context(nfs);
errno = ENFILE;
return -1;
}
nfs_fd_list[fd].is_nfs = 1;
nfs_fd_list[fd].nfs = nfs;
nfs_fd_list[fd].fh = fh;
nfs_fd_list[fd].path = strdup(path);
nfs_fd_list[fd].flags = flags;
nfs_fd_list[fd].mode = mode;
nfs_destroy_url(url);
LD_NFS_DPRINTF(9, "open(%s) == %d", path, fd);
return fd;
}
return real_open(path, flags, mode);
}
int open64(const char *path, int flags, mode_t mode)
{
return open(path, flags | O_LARGEFILE, mode);
}
int (*real_close)(int fd);
int close(int fd)
{
if (nfs_fd_list[fd].is_nfs == 1) {
int i;
LD_NFS_DPRINTF(9, "close(%d)", fd);
nfs_fd_list[fd].is_nfs = 0;
nfs_close(nfs_fd_list[fd].nfs, nfs_fd_list[fd].fh);
nfs_fd_list[fd].fh = NULL;
nfs_destroy_context(nfs_fd_list[fd].nfs);
nfs_fd_list[fd].nfs = NULL;
free(discard_const(nfs_fd_list[fd].path));
nfs_fd_list[fd].path = NULL;
return 0;
}
return real_close(fd);
}
ssize_t (*real_read)(int fd, void *buf, size_t count);
ssize_t read(int fd, void *buf, size_t count)
{
if (nfs_fd_list[fd].is_nfs == 1) {
int ret;
LD_NFS_DPRINTF(9, "read(fd:%d count:%d)", fd, (int)count);
if ((ret = nfs_read(nfs_fd_list[fd].nfs, nfs_fd_list[fd].fh,
count, buf)) < 0) {
errno = -ret;
return -1;
}
return ret;
}
return real_read(fd, buf, count);
}
ssize_t (*real_pread)(int fd, void *buf, size_t count, off_t offset);
ssize_t pread(int fd, void *buf, size_t count, off_t offset) {
if (nfs_fd_list[fd].is_nfs == 1) {
int ret;
LD_NFS_DPRINTF(9, "pread(fd:%d offset:%d count:%d)", fd,
(int)offset, (int)count);
if ((ret = nfs_pread(nfs_fd_list[fd].nfs, nfs_fd_list[fd].fh,
offset, count, buf)) < 0) {
errno = -ret;
return -1;
}
return ret;
}
return real_pread(fd, buf, count, offset);
}
ssize_t (*real_write)(int fd, const void *buf, size_t count);
ssize_t write(int fd, const void *buf, size_t count)
{
if (nfs_fd_list[fd].is_nfs == 1) {
int ret;
LD_NFS_DPRINTF(9, "write(fd:%d count:%d)", fd, (int)count);
if ((ret = nfs_write(nfs_fd_list[fd].nfs, nfs_fd_list[fd].fh,
count,
(char *)discard_const(buf))) < 0) {
errno = -ret;
return -1;
}
return ret;
}
return real_write(fd, buf, count);
}
ssize_t (*real_pwrite)(int fd, const void *buf, size_t count, off_t offset);
ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset) {
if (nfs_fd_list[fd].is_nfs == 1) {
int ret;
LD_NFS_DPRINTF(9, "pwrite(fd:%d offset:%d count:%d)", fd,
(int)offset, (int)count);
if ((ret = nfs_pwrite(nfs_fd_list[fd].nfs, nfs_fd_list[fd].fh,
offset, count,
(char *)discard_const(buf))) < 0) {
errno = -ret;
return -1;
}
return ret;
}
return real_pwrite(fd, buf, count, offset);
}
int (*real_dup2)(int oldfd, int newfd);
int dup2(int oldfd, int newfd)
{
close(newfd);
if (nfs_fd_list[oldfd].is_nfs == 1) {
struct nfs_context *nfs;
struct nfs_url *url;
struct nfsfh *fh = NULL;
int ret, fd;
LD_NFS_DPRINTF(9, "dup2(%s:%d, %d)", nfs_fd_list[oldfd].path,
oldfd, newfd);
nfs = nfs_init_context();
if (nfs == NULL) {
LD_NFS_DPRINTF(1, "Failed to create context");
errno = ENOMEM;
return -1;
}
url = nfs_parse_url_full(nfs, nfs_fd_list[oldfd].path);
if (url == NULL) {
LD_NFS_DPRINTF(1, "Failed to parse URL: %s\n",
nfs_get_error(nfs));
nfs_destroy_context(nfs);
errno = EINVAL;
return -1;
}
if (nfs_mount(nfs, url->server, url->path) != 0) {
LD_NFS_DPRINTF(1, "Failed to mount nfs share : %s\n",
nfs_get_error(nfs));
nfs_destroy_url(url);
nfs_destroy_context(nfs);
errno = EINVAL;
return -1;
}
if ((ret = nfs_open(nfs, url->file, nfs_fd_list[oldfd].mode,
&fh)) != 0) {
LD_NFS_DPRINTF(1, "Failed to open nfs file : %s\n",
nfs_get_error(nfs));
nfs_destroy_url(url);
nfs_destroy_context(nfs);
errno = -ret;
return -1;
}
/* We could actually end on the right descriptor by chance */
if (nfs_get_fd(nfs) != newfd) {
if (real_dup2(nfs_get_fd(nfs), newfd) < 0) {
LD_NFS_DPRINTF(1, "Failed to dup2 file : %d",
errno);
return -1;
}
close(rpc_get_fd(nfs_get_rpc_context(nfs)));
rpc_set_fd(nfs_get_rpc_context(nfs), newfd);
}
fd = nfs_get_fd(nfs);
if (fd >= NFS_MAX_FD) {
LD_NFS_DPRINTF(1, "Too many files open");
nfs_destroy_url(url);
nfs_destroy_context(nfs);
errno = ENFILE;
return -1;
}
nfs_fd_list[fd].is_nfs = 1;
nfs_fd_list[fd].nfs = nfs;
nfs_fd_list[fd].fh = fh;
nfs_fd_list[fd].path = strdup(nfs_fd_list[oldfd].path);
nfs_fd_list[fd].flags = nfs_fd_list[oldfd].flags;
nfs_fd_list[fd].mode = nfs_fd_list[oldfd].mode;
nfs_destroy_url(url);
LD_NFS_DPRINTF(9, "dup2(%s) successful",
nfs_fd_list[oldfd].path);
return fd;
}
return real_dup2(oldfd, newfd);
}
int (*real_xstat)(int ver, __const char *path, struct stat *buf);
int __xstat(int ver, const char *path, struct stat *buf)
{
if (!strncmp(path, "nfs:", 4)) {
int fd, ret;
LD_NFS_DPRINTF(9, "__xstat(%s)", path);
fd = open(path, 0, 0);
if (fd == -1) {
return fd;
}
ret = __fxstat(ver, fd, buf);
close(fd);
return ret;
}
return real_xstat(ver, path, buf);
}
int (*real_xstat64)(int ver, __const char *path, struct stat64 *buf);
int __xstat64(int ver, const char *path, struct stat64 *buf)
{
if (!strncmp(path, "nfs:", 4)) {
int fd, ret;
LD_NFS_DPRINTF(9, "__xstat64(%s)", path);
fd = open(path, 0, 0);
if (fd == -1) {
return fd;
}
ret = __fxstat64(ver, fd, buf);
close(fd);
return ret;
}
return real_xstat64(ver, path, buf);
}
int (*real_lxstat)(int ver, __const char *path, struct stat *buf);
int __lxstat(int ver, const char *path, struct stat *buf)
{
if (!strncmp(path, "nfs:", 4)) {
int fd, ret;
LD_NFS_DPRINTF(9, "__lxstat(%s)", path);
fd = open(path, 0, 0);
if (fd == -1) {
return fd;
}
ret = __fxstat(ver, fd, buf);
close(fd);
return ret;
}
return real_lxstat(ver, path, buf);
}
int (*real_lxstat64)(int ver, __const char *path, struct stat64 *buf);
int __lxstat64(int ver, const char *path, struct stat64 *buf)
{
if (!strncmp(path, "nfs:", 4)) {
int fd, ret;
LD_NFS_DPRINTF(9, "__lxstat64(%s)", path);
fd = open(path, 0, 0);
if (fd == -1) {
return fd;
}
ret = __fxstat64(ver, fd, buf);
close(fd);
return ret;
}
return real_lxstat64(ver, path, buf);
}
int (*real_fxstat)(int ver, int fd, struct stat *buf);
int __fxstat(int ver, int fd, struct stat *buf)
{
if (nfs_fd_list[fd].is_nfs == 1) {
int ret;
struct nfs_stat_64 st64;
LD_NFS_DPRINTF(9, "__fxstat(%d)", fd);
if ((ret = nfs_fstat64(nfs_fd_list[fd].nfs, nfs_fd_list[fd].fh,
(void *)&st64)) < 0) {
errno = -ret;
return -1;
}
buf->st_dev = st64.nfs_dev;
buf->st_ino = st64.nfs_ino;
buf->st_mode = st64.nfs_mode;
buf->st_nlink = st64.nfs_nlink;
buf->st_uid = st64.nfs_uid;
buf->st_gid = st64.nfs_gid;
buf->st_rdev = st64.nfs_rdev;
buf->st_size = st64.nfs_size;
buf->st_blksize = st64.nfs_blksize;
buf->st_blocks = st64.nfs_blocks;
buf->st_atim.tv_sec = st64.nfs_atime;
buf->st_atim.tv_usec = st64.nfs_atime_nsec / 1000;
buf->st_mtim.tv_sec = st64.nfs_mtime;
buf->st_mtim.tv_usec = st64.nfs_mtime_nsec / 1000;
buf->st_ctim.tv_sec = st64.nfs_ctime;
buf->st_ctim.tv_usec = st64.nfs_ctime_nsec / 1000;
LD_NFS_DPRINTF(9, "__fxstat(%d) success", fd);
return ret;
}
return real_fxstat(ver, fd, buf);
}
int (*real_fxstat64)(int ver, int fd, struct stat64 *buf);
int __fxstat64(int ver, int fd, struct stat64 *buf)
{
if (nfs_fd_list[fd].is_nfs == 1) {
int ret;
struct nfs_stat_64 st64;
LD_NFS_DPRINTF(9, "__fxstat64(%d)", fd);
if ((ret = nfs_fstat64(nfs_fd_list[fd].nfs, nfs_fd_list[fd].fh,
(void *)&st64)) < 0) {
errno = -ret;
return -1;
}
buf->st_dev = st64.nfs_dev;
buf->st_ino = st64.nfs_ino;
buf->st_mode = st64.nfs_mode;
buf->st_nlink = st64.nfs_nlink;
buf->st_uid = st64.nfs_uid;
buf->st_gid = st64.nfs_gid;
buf->st_rdev = st64.nfs_rdev;
buf->st_size = st64.nfs_size;
buf->st_blksize = st64.nfs_blksize;
buf->st_blocks = st64.nfs_blocks;
buf->st_atim.tv_sec = st64.nfs_atime;
buf->st_atim.tv_usec = st64.nfs_atime_nsec / 1000;
buf->st_mtim.tv_sec = st64.nfs_mtime;
buf->st_mtim.tv_usec = st64.nfs_mtime_nsec / 1000;
buf->st_ctim.tv_sec = st64.nfs_ctime;
buf->st_ctim.tv_usec = st64.nfs_ctime_nsec / 1000;
LD_NFS_DPRINTF(9, "__fxstat64(%d) success", fd);
return ret;
}
return real_fxstat64(ver, fd, buf);
}
int (*real_fallocate)(int fd, int mode, off_t offset, off_t len);
int fallocate(int fd, int mode, off_t offset, off_t len)
{
if (nfs_fd_list[fd].is_nfs == 1) {
LD_NFS_DPRINTF(9, "fallocate(%d)", fd);
errno = EOPNOTSUPP;
return -1;
}
return real_fallocate(fd, mode, offset, len);
}
int (*real_ftruncate)(int fd, off_t len);
int ftruncate(int fd, off_t len)
{
if (nfs_fd_list[fd].is_nfs == 1) {
int ret;
LD_NFS_DPRINTF(9, "ftruncate(%d, %d)", fd, (int)len);
if ((ret = nfs_ftruncate(nfs_fd_list[fd].nfs,
nfs_fd_list[fd].fh,
len)) < 0) {
errno = -ret;
return -1;
}
return 0;
}
return real_ftruncate(fd, len);
}
int (*real_truncate)(const char *path, off_t len);
int truncate(const char *path, off_t len)
{
if (!strncmp(path, "nfs:", 4)) {
int fd, ret;
LD_NFS_DPRINTF(9, "truncate(%s, %d)", path, (int)len);
fd = open(path, 0, 0);
if (fd == -1) {
return fd;
}
ret = ftruncate(fd, len);
close(fd);
return ret;
}
return real_truncate(path, len);
}
int (*real_fchmod)(int fd, mode_t mode);
int fchmod(int fd, mode_t mode)
{
if (nfs_fd_list[fd].is_nfs == 1) {
int ret;
LD_NFS_DPRINTF(9, "fchmod(%d, %o)", fd, (int)mode);
if ((ret = nfs_fchmod(nfs_fd_list[fd].nfs,
nfs_fd_list[fd].fh,
mode)) < 0) {
errno = -ret;
return -1;
}
return 0;
}
return real_fchmod(fd, mode);
}
int (*real_chmod)(const char *path, mode_t mode);
int chmod(const char *path, mode_t mode)
{
if (!strncmp(path, "nfs:", 4)) {
int fd, ret;
LD_NFS_DPRINTF(9, "chmod(%s, %o)", path, (int)mode);
fd = open(path, 0, 0);
if (fd == -1) {
return fd;
}
ret = fchmod(fd, mode);
close(fd);
return ret;
}
return real_chmod(path, mode);
}
static void __attribute__((constructor)) _init(void)
{
int i;
if (getenv("LD_NFS_DEBUG") != NULL) {
debug = atoi(getenv("LD_NFS_DEBUG"));
}
real_open = dlsym(RTLD_NEXT, "open");
if (real_open == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(open)");
exit(10);
}
real_close = dlsym(RTLD_NEXT, "close");
if (real_close == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(close)");
exit(10);
}
real_read = dlsym(RTLD_NEXT, "read");
if (real_read == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(read)");
exit(10);
}
real_pread = dlsym(RTLD_NEXT, "pread");
if (real_pread == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(pread)");
exit(10);
}
real_write = dlsym(RTLD_NEXT, "write");
if (real_write == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(write)");
exit(10);
}
real_pwrite = dlsym(RTLD_NEXT, "pwrite");
if (real_pwrite == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(pwrite)");
exit(10);
}
real_xstat = dlsym(RTLD_NEXT, "__xstat");
if (real_xstat == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(__xstat)");
exit(10);
}
real_xstat64 = dlsym(RTLD_NEXT, "__xstat64");
if (real_xstat64 == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(__xstat64)");
}
real_lxstat = dlsym(RTLD_NEXT, "__lxstat");
if (real_lxstat == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(__lxstat)");
exit(10);
}
real_lxstat64 = dlsym(RTLD_NEXT, "__lxstat64");
if (real_lxstat64 == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(_lxstat64)");
exit(10);
}
real_fxstat = dlsym(RTLD_NEXT, "__fxstat");
if (real_fxstat == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(__fxstat)");
exit(10);
}
real_fxstat64 = dlsym(RTLD_NEXT, "__fxstat64");
if (real_fxstat64 == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(__fxstat64)");
exit(10);
}
real_fallocate = dlsym(RTLD_NEXT, "fallocate");
if (real_fallocate == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(fallocate)");
exit(10);
}
real_dup2 = dlsym(RTLD_NEXT, "dup2");
if (real_dup2 == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(dup2)");
exit(10);
}
real_truncate = dlsym(RTLD_NEXT, "truncate");
if (real_truncate == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(truncate)");
exit(10);
}
real_ftruncate = dlsym(RTLD_NEXT, "ftruncate");
if (real_ftruncate == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(ftruncate)");
exit(10);
}
real_chmod = dlsym(RTLD_NEXT, "chmod");
if (real_chmod == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(chmod)");
exit(10);
}
real_fchmod = dlsym(RTLD_NEXT, "fchmod");
if (real_fchmod == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(fchmod)");
exit(10);
}
}
libnfs-libnfs-1.9.8/examples/nfs-io.c 0000664 0000000 0000000 00000007522 12557450341 0017452 0 ustar 00root root 0000000 0000000 /*
Copyright (C) by Peter Lieven 2013
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 3 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.
You should have received a copy of the GNU General Public License
along with this program; if not, see .
*/
#define _FILE_OFFSET_BITS 64
#define _GNU_SOURCE
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef AROS
#include "aros_compat.h"
#endif
#ifdef WIN32
#include "win32_compat.h"
#pragma comment(lib, "ws2_32.lib")
WSADATA wsaData;
#define PRId64 "ll"
#else
#include
#include
#include
#include
#ifndef AROS
#include
#endif
#endif
#ifdef HAVE_UNISTD_H
#include
#endif
#include
#include
#include
#include
#include
#include
#include "libnfs.h"
#include "libnfs-raw.h"
#include "libnfs-raw-mount.h"
void print_usage(void)
{
fprintf(stderr, "Usage: nfs-io [-?|--help|--usage] [stat|creat|unlink|mkdir|rmdir] \n");
}
int main(int argc, char *argv[])
{
int ret = 1;
struct nfs_context *nfs = NULL;
struct nfsfh *nfsfh = NULL;
struct nfs_url *url = NULL;
#ifdef WIN32
if (WSAStartup(MAKEWORD(2,2), &wsaData) != 0) {
printf("Failed to start Winsock2\n");
exit(10);
}
#endif
#ifdef AROS
aros_init_socket();
#endif
if (argc < 3) {
fprintf(stderr, "No URL specified.\n");
goto finished;
}
nfs = nfs_init_context();
if (nfs == NULL) {
printf("failed to init context\n");
goto finished;
}
url = nfs_parse_url_full(nfs, argv[argc - 1]);
if (url == NULL) {
fprintf(stderr, "%s\n", nfs_get_error(nfs));
goto finished;
}
if (nfs_mount(nfs, url->server, url->path) != 0) {
fprintf(stderr, "Failed to mount nfs share : %s\n", nfs_get_error(nfs));
goto finished;
}
if (!strncmp(argv[1], "creat", 5)) {
ret = nfs_creat(nfs, url->file, 0600, &nfsfh);
} else if (!strncmp(argv[1], "unlink", 6)) {
ret = nfs_unlink(nfs, url->file);
} else if (!strncmp(argv[1], "mkdir", 5)) {
ret = nfs_mkdir(nfs, url->file);
} else if (!strncmp(argv[1], "rmdir", 5)) {
ret = nfs_rmdir(nfs, url->file);
} else if (!strncmp(argv[1], "stat", 4)) {
struct nfs_stat_64 st;
ret = nfs_stat64(nfs, url->file, &st);
if (!ret) {
switch (st.nfs_mode & S_IFMT) {
#ifndef WIN32
case S_IFLNK:
printf("l");
break;
#endif
case S_IFREG:
printf("-");
break;
case S_IFDIR:
printf("d");
break;
case S_IFCHR:
printf("c");
break;
case S_IFBLK:
printf("b");
break;
}
printf("%c%c%c",
"-r"[!!(st.nfs_mode & S_IRUSR)],
"-w"[!!(st.nfs_mode & S_IWUSR)],
"-x"[!!(st.nfs_mode & S_IXUSR)]
);
printf("%c%c%c",
"-r"[!!(st.nfs_mode & S_IRGRP)],
"-w"[!!(st.nfs_mode & S_IWGRP)],
"-x"[!!(st.nfs_mode & S_IXGRP)]
);
printf("%c%c%c",
"-r"[!!(st.nfs_mode & S_IROTH)],
"-w"[!!(st.nfs_mode & S_IWOTH)],
"-x"[!!(st.nfs_mode & S_IXOTH)]
);
printf(" %2d", (int)st.nfs_nlink);
printf(" %5d", (int)st.nfs_uid);
printf(" %5d", (int)st.nfs_gid);
printf(" %12" PRId64, st.nfs_size);
printf("\n");
}
} else {
goto finished;
}
if (ret) {
fprintf(stderr, "ERROR: %s\n", nfs_get_error(nfs));
}
finished:
if (ret > 0) {
print_usage();
}
nfs_destroy_url(url);
if (nfs != NULL) {
if (nfsfh) {
nfs_close(nfs, nfsfh);
}
nfs_destroy_context(nfs);
}
return !!ret;
}
libnfs-libnfs-1.9.8/examples/nfsclient-async.c 0000664 0000000 0000000 00000016164 12557450341 0021361 0 ustar 00root root 0000000 0000000 /*
Copyright (C) by Ronnie Sahlberg 2010
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 3 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.
You should have received a copy of the GNU General Public License
along with this program; if not, see .
*/
/* Example program using the highlevel async interface.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef WIN32
#include "win32_compat.h"
#else
#include
#endif
#ifdef HAVE_POLL_H
#include
#endif
#ifdef HAVE_UNISTD_H
#include
#endif
#define SERVER "10.1.1.27"
#define EXPORT "/VIRTUAL"
#define NFSFILE "/BOOKS/Classics/Dracula.djvu"
#define NFSDIR "/BOOKS/Classics/"
#include
#include
#include
#include
#include
#include "libnfs.h"
#include "libnfs-raw.h"
#include "libnfs-raw-mount.h"
struct rpc_context *mount_context;
struct client {
char *server;
char *export;
uint32_t mount_port;
struct nfsfh *nfsfh;
int is_finished;
};
void mount_export_cb(struct rpc_context *mount_context, int status, void *data, void *private_data)
{
struct client *client = private_data;
exports export = *(exports *)data;
if (status < 0) {
printf("MOUNT/EXPORT failed with \"%s\"\n", rpc_get_error(mount_context));
exit(10);
}
printf("Got exports list from server %s\n", client->server);
while (export != NULL) {
printf("Export: %s\n", export->ex_dir);
export = export->ex_next;
}
mount_context = NULL;
client->is_finished = 1;
}
void nfs_opendir_cb(int status, struct nfs_context *nfs, void *data, void *private_data)
{
struct client *client = private_data;
struct nfsdir *nfsdir = data;
struct nfsdirent *nfsdirent;
if (status < 0) {
printf("opendir failed with \"%s\"\n", (char *)data);
exit(10);
}
printf("opendir successful\n");
while((nfsdirent = nfs_readdir(nfs, nfsdir)) != NULL) {
printf("Inode:%d Name:%s\n", (int)nfsdirent->inode, nfsdirent->name);
}
nfs_closedir(nfs, nfsdir);
mount_context = rpc_init_context();
if (mount_getexports_async(mount_context, client->server, mount_export_cb, client) != 0) {
printf("Failed to start MOUNT/EXPORT\n");
exit(10);
}
}
void nfs_close_cb(int status, struct nfs_context *nfs, void *data, void *private_data)
{
struct client *client = private_data;
if (status < 0) {
printf("close failed with \"%s\"\n", (char *)data);
exit(10);
}
printf("close successful\n");
printf("call opendir(%s)\n", NFSDIR);
if (nfs_opendir_async(nfs, NFSDIR, nfs_opendir_cb, client) != 0) {
printf("Failed to start async nfs close\n");
exit(10);
}
}
void nfs_fstat64_cb(int status, struct nfs_context *nfs, void *data, void *private_data)
{
struct client *client = private_data;
struct nfs_stat_64 *st;
if (status < 0) {
printf("fstat call failed with \"%s\"\n", (char *)data);
exit(10);
}
printf("Got reply from server for fstat(%s).\n", NFSFILE);
st = (struct nfs_stat_64 *)data;
printf("Mode %04o\n", (int)st->nfs_mode);
printf("Size %d\n", (int)st->nfs_size);
printf("Inode %04o\n", (int)st->nfs_ino);
printf("Close file\n");
if (nfs_close_async(nfs, client->nfsfh, nfs_close_cb, client) != 0) {
printf("Failed to start async nfs close\n");
exit(10);
}
}
void nfs_read_cb(int status, struct nfs_context *nfs, void *data, void *private_data)
{
struct client *client = private_data;
char *read_data;
int i;
if (status < 0) {
printf("read failed with \"%s\"\n", (char *)data);
exit(10);
}
printf("read successful with %d bytes of data\n", status);
read_data = data;
for (i=0;i<16;i++) {
printf("%02x ", read_data[i]&0xff);
}
printf("\n");
printf("Fstat file :%s\n", NFSFILE);
if (nfs_fstat64_async(nfs, client->nfsfh, nfs_fstat64_cb, client) != 0) {
printf("Failed to start async nfs fstat\n");
exit(10);
}
}
void nfs_open_cb(int status, struct nfs_context *nfs, void *data, void *private_data)
{
struct client *client = private_data;
struct nfsfh *nfsfh;
if (status < 0) {
printf("open call failed with \"%s\"\n", (char *)data);
exit(10);
}
nfsfh = data;
client->nfsfh = nfsfh;
printf("Got reply from server for open(%s). Handle:%p\n", NFSFILE, data);
printf("Read first 64 bytes\n");
if (nfs_pread_async(nfs, nfsfh, 0, 64, nfs_read_cb, client) != 0) {
printf("Failed to start async nfs open\n");
exit(10);
}
}
void nfs_stat64_cb(int status, struct nfs_context *nfs, void *data, void *private_data)
{
struct client *client = private_data;
struct nfs_stat_64 *st;
if (status < 0) {
printf("stat call failed with \"%s\"\n", (char *)data);
exit(10);
}
printf("Got reply from server for stat(%s).\n", NFSFILE);
st = (struct nfs_stat_64 *)data;
printf("Mode %04o\n", (unsigned int) st->nfs_mode);
printf("Size %d\n", (int)st->nfs_size);
printf("Inode %04o\n", (int)st->nfs_ino);
printf("Open file for reading :%s\n", NFSFILE);
if (nfs_open_async(nfs, NFSFILE, O_RDONLY, nfs_open_cb, client) != 0) {
printf("Failed to start async nfs open\n");
exit(10);
}
}
void nfs_mount_cb(int status, struct nfs_context *nfs, void *data, void *private_data)
{
struct client *client = private_data;
if (status < 0) {
printf("mount/mnt call failed with \"%s\"\n", (char *)data);
exit(10);
}
printf("Got reply from server for MOUNT/MNT procedure.\n");
printf("Stat file :%s\n", NFSFILE);
if (nfs_stat64_async(nfs, NFSFILE, nfs_stat64_cb, client) != 0) {
printf("Failed to start async nfs stat\n");
exit(10);
}
}
int main(int argc _U_, char *argv[] _U_)
{
struct nfs_context *nfs;
int ret;
struct client client;
struct pollfd pfds[2]; /* nfs:0 mount:1 */
client.server = SERVER;
client.export = EXPORT;
client.is_finished = 0;
nfs = nfs_init_context();
if (nfs == NULL) {
printf("failed to init context\n");
exit(10);
}
ret = nfs_mount_async(nfs, client.server, client.export, nfs_mount_cb, &client);
if (ret != 0) {
printf("Failed to start async nfs mount\n");
exit(10);
}
for (;;) {
int num_fds;
pfds[0].fd = nfs_get_fd(nfs);
pfds[0].events = nfs_which_events(nfs);
num_fds = 1;
if (mount_context != 0 && rpc_get_fd(mount_context) != -1) {
pfds[1].fd = rpc_get_fd(mount_context);
pfds[1].events = rpc_which_events(mount_context);
num_fds = 2;
}
if (poll(&pfds[0], 2, -1) < 0) {
printf("Poll failed");
exit(10);
}
if (mount_context != NULL) {
if (rpc_service(mount_context, pfds[1].revents) < 0) {
printf("rpc_service failed\n");
break;
}
}
if (nfs_service(nfs, pfds[0].revents) < 0) {
printf("nfs_service failed\n");
break;
}
if (client.is_finished) {
break;
}
}
nfs_destroy_context(nfs);
if (mount_context != NULL) {
rpc_destroy_context(mount_context);
mount_context = NULL;
}
printf("nfsclient finished\n");
return 0;
}
libnfs-libnfs-1.9.8/examples/nfsclient-bcast.c 0000664 0000000 0000000 00000013105 12557450341 0021330 0 ustar 00root root 0000000 0000000 /*
Copyright (C) by Ronnie Sahlberg 2011
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 3 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.
You should have received a copy of the GNU General Public License
along with this program; if not, see .
*/
/* Example program using the lowlevel raw broadcast interface.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef WIN32
#include "win32_compat.h"
#endif
#ifdef HAVE_POLL_H
#include
#endif
#ifdef HAVE_UNISTD_H
#include
#endif
#include
#include
#include
#include
#ifdef HAVE_SYS_TIME_H
#include
#endif
#ifdef HAVE_NET_IF_H
#include
#endif
#ifdef HAVE_NETDB_H
#include
#endif
#ifdef HAVE_SYS_IOCTL_H
#include
#endif
#ifdef HAVE_SYS_SOCKET_H
#include
#endif
#include "libnfs.h"
#include "libnfs-raw.h"
#include "libnfs-private.h"
#include "libnfs-raw-mount.h"
#include "libnfs-raw-portmap.h"
struct nfs_list_data {
int status;
struct nfs_server_list *srvrs;
};
void free_nfs_srvr_list(struct nfs_server_list *srv)
{
while (srv != NULL) {
struct nfs_server_list *next = srv->next;
free(srv->addr);
free(srv);
srv = next;
}
}
void pm_cb(struct rpc_context *rpc, int status, void *data _U_, void *private_data)
{
struct nfs_list_data *srv_data = private_data;
struct sockaddr *sin;
char hostdd[16];
struct nfs_server_list *srvr;
if (status == RPC_STATUS_CANCEL) {
return;
}
if (status != 0) {
srv_data->status = -1;
return;
}
sin = rpc_get_recv_sockaddr(rpc);
if (sin == NULL) {
rpc_set_error(rpc, "failed to get sockaddr in CALLIT callback");
srv_data->status = -1;
return;
}
if (getnameinfo(sin, sizeof(struct sockaddr_in), &hostdd[0], sizeof(hostdd), NULL, 0, NI_NUMERICHOST) < 0) {
rpc_set_error(rpc, "getnameinfo failed in CALLIT callback");
srv_data->status = -1;
return;
}
srvr = malloc(sizeof(struct nfs_server_list));
if (srvr == NULL) {
rpc_set_error(rpc, "Malloc failed when allocating server structure");
srv_data->status = -1;
return;
}
srvr->addr = strdup(hostdd);
if (srvr->addr == NULL) {
rpc_set_error(rpc, "Strdup failed when allocating server structure");
free(srvr);
srv_data->status = -1;
return;
}
srvr->next = srv_data->srvrs;
srv_data->srvrs = srvr;
}
int main(int argc _U_, char *argv[] _U_)
{
struct rpc_context *rpc;
struct pollfd pfd;
struct ifconf ifc;
int size;
struct timeval tv_start, tv_current;
struct nfs_list_data data = {0, NULL};
struct nfs_server_list *srvr;
char *ptr;
rpc = rpc_init_udp_context();
if (rpc == NULL) {
printf("failed to init context\n");
exit(10);
}
if (rpc_bind_udp(rpc, "0.0.0.0", 0) < 0) {
printf("failed to bind to udp %s\n", rpc_get_error(rpc));
exit(10);
}
/* get list of all interfaces */
size = sizeof(struct ifreq);
ifc.ifc_buf = NULL;
ifc.ifc_len = size;
while(ifc.ifc_len > (size - sizeof(struct ifreq))) {
size *= 2;
free(ifc.ifc_buf);
ifc.ifc_len = size;
ifc.ifc_buf = malloc(size);
memset(ifc.ifc_buf, 0, size);
if (ioctl(rpc_get_fd(rpc), SIOCGIFCONF, (caddr_t)&ifc) < 0) {
printf("ioctl SIOCGIFCONF failed\n");
exit(10);
}
}
for (ptr =(char *)ifc.ifc_buf; ptr < ((char *)ifc.ifc_buf) + ifc.ifc_len; ) {
struct ifreq *ifr;
char bcdd[16];
ifr = (struct ifreq *)ptr;
#ifdef HAVE_SOCKADDR_LEN
if (ifr->ifr_addr.sa_len > sizeof(struct sockaddr)) {
ptr += sizeof(ifr->ifr_name) + ifr->ifr_addr.sa_len;
} else {
ptr += sizeof(ifr->ifr_name) + sizeof(struct sockaddr);
}
#else
ptr += sizeof(struct ifreq);
#endif
if (ifr->ifr_addr.sa_family != AF_INET) {
continue;
}
if (ioctl(rpc_get_fd(rpc), SIOCGIFFLAGS, ifr) < 0) {
printf("ioctl DRBADDR failed\n");
exit(10);
}
if (!(ifr->ifr_flags & IFF_UP)) {
continue;
}
if (ifr->ifr_flags & IFF_LOOPBACK) {
continue;
}
if (!(ifr->ifr_flags & IFF_BROADCAST)) {
continue;
}
if (ioctl(rpc_get_fd(rpc), SIOCGIFBRDADDR, ifr) < 0) {
continue;
}
if (getnameinfo(&ifr->ifr_broadaddr, sizeof(struct sockaddr_in), &bcdd[0], sizeof(bcdd), NULL, 0, NI_NUMERICHOST) < 0) {
continue;
}
if (rpc_set_udp_destination(rpc, bcdd, 111, 1) < 0) {
printf("failed to set udp destination %s\n", rpc_get_error(rpc));
exit(10);
}
if (rpc_pmap2_callit_async(rpc, MOUNT_PROGRAM, 2, 0, NULL, 0, pm_cb, &data) < 0) {
printf("Failed to set up callit function\n");
exit(10);
}
}
free(ifc.ifc_buf);
gettimeofday(&tv_start, NULL);
for(;;) {
int mpt;
pfd.fd = rpc_get_fd(rpc);
pfd.events = rpc_which_events(rpc);
gettimeofday(&tv_current, NULL);
mpt = 1000
- (tv_current.tv_sec *1000 + tv_current.tv_usec / 1000)
+ (tv_start.tv_sec *1000 + tv_start.tv_usec / 1000);
if (poll(&pfd, 1, mpt) < 0) {
printf("Poll failed");
exit(10);
}
if (pfd.revents == 0) {
break;
}
if (rpc_service(rpc, pfd.revents) < 0) {
printf("rpc_service failed with %s\n", rpc_get_error(rpc));
break;
}
}
for (srvr=data.srvrs; srvr; srvr = srvr->next) {
printf("NFS SERVER @ %s\n", srvr->addr);
}
free_nfs_srvr_list(data.srvrs);
rpc_destroy_context(rpc);
rpc=NULL;
return 0;
}
libnfs-libnfs-1.9.8/examples/nfsclient-listservers.c 0000664 0000000 0000000 00000002362 12557450341 0022624 0 ustar 00root root 0000000 0000000 /*
Copyright (C) by Ronnie Sahlberg 2011
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 3 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.
You should have received a copy of the GNU General Public License
along with this program; if not, see .
*/
/* Example program showing sync interface to probe for all local servers
*/
#ifdef AROS
#include "aros_compat.h"
#endif
#ifdef WIN32
#include "win32_compat.h"
#endif
#include
#include
#include "libnfs.h"
int main(int argc _U_, char *argv[] _U_)
{
struct nfs_server_list *srvrs;
struct nfs_server_list *srv;
#ifdef AROS
aros_init_socket();
#endif
srvrs = nfs_find_local_servers();
for (srv=srvrs; srv; srv = srv->next) {
printf("NFS SERVER @ %s\n", srv->addr);
}
free_nfs_srvr_list(srvrs);
return 0;
}
libnfs-libnfs-1.9.8/examples/nfsclient-raw.c 0000664 0000000 0000000 00000032270 12557450341 0021031 0 ustar 00root root 0000000 0000000 /*
Copyright (C) by Ronnie Sahlberg 2010
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 3 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.
You should have received a copy of the GNU General Public License
along with this program; if not, see .
*/
/* Example program using the lowlevel raw interface.
* This allow accurate control of the exact commands that are being used.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef WIN32
#include "win32_compat.h"
#endif
#define SERVER "10.1.1.27"
#define EXPORT "/shared"
#ifdef HAVE_POLL_H
#include
#endif
#ifdef HAVE_NETINET_IN_H
#include
#endif
#include
#include
#include
#include "libnfs.h"
#include "libnfs-raw.h"
#include "libnfs-raw-mount.h"
#include "libnfs-raw-nfs.h"
#include "libnfs-raw-portmap.h"
#include "libnfs-raw-rquota.h"
struct client {
char *server;
char *export;
uint32_t mount_port;
uint32_t rquota_port;
int is_finished;
struct nfs_fh3 rootfh;
};
void rquota_getquota_cb(struct rpc_context *rpc _U_, int status, void *data, void *private_data)
{
struct client *client = private_data;
// GETQUOTA1res *res = data;
if (status == RPC_STATUS_ERROR) {
printf("rquota/getquota call failed with \"%s\"\n", (char *)data);
exit(10);
}
if (status != RPC_STATUS_SUCCESS) {
printf("rquota/getquota call to server %s failed, status:%d\n", client->server, status);
exit(10);
}
printf("rquota responded ok\n");
client->is_finished = 1;
}
void rquota_connect_cb(struct rpc_context *rpc, int status, void *data _U_, void *private_data)
{
struct client *client = private_data;
if (status != RPC_STATUS_SUCCESS) {
printf("connection to RPC.RQUOTAD on server %s failed\n", client->server);
exit(10);
}
printf("Connected to RPC.RQUOTAD on %s:%d\n", client->server, client->rquota_port);
printf("Send GETQUOTA request for uid 100\n");
if (rpc_rquota1_getquota_async(rpc, rquota_getquota_cb, EXPORT, 100, client) != 0) {
printf("Failed to send getquota request\n");
exit(10);
}
}
void acl_getacl_cb(struct rpc_context *rpc _U_, int status, void *data, void *private_data)
{
struct client *client = private_data;
GETACL3res *res = data;
printf("Got NFSACL/GETACL reply\n");
if (status == RPC_STATUS_SUCCESS) {
printf("Got an ACL : ACL status:%d\n", res->status);
if (res->status == NFS3_OK) {
int i;
printf("ACL MASK 0x%08x\n", res->GETACL3res_u.resok.mask);
printf("NUM ACE %d\n", res->GETACL3res_u.resok.ace_count);
for (i=0; iGETACL3res_u.resok.ace.ace_len; i++) {
printf("Type:0x%08x\n", res->GETACL3res_u.resok.ace.ace_val[i].type);
printf("ID:%d\n", res->GETACL3res_u.resok.ace.ace_val[i].id);
printf("Perm:0x%08x\n", res->GETACL3res_u.resok.ace.ace_val[i].perm);
}
}
}
printf("Disconnect socket from nfs server\n");
if (rpc_disconnect(rpc, "normal disconnect") != 0) {
printf("Failed to disconnect socket to nfs\n");
exit(10);
}
printf("Connect to RPC.RQUOTAD on %s:%d\n", client->server, client->rquota_port);
if (rpc_connect_async(rpc, client->server, client->rquota_port, rquota_connect_cb, client) != 0) {
printf("Failed to start connection\n");
exit(10);
}
}
void acl_null_cb(struct rpc_context *rpc _U_, int status, void *data, void *private_data)
{
struct client *client = private_data;
GETACL3args args;
printf("Got NFSACL/NULL reply\n");
printf("Get ACL for root handle\n");
args.dir = client->rootfh;
args.mask = NFSACL_MASK_ACL_ENTRY|NFSACL_MASK_ACL_COUNT|NFSACL_MASK_ACL_DEFAULT_ENTRY|NFSACL_MASK_ACL_DEFAULT_COUNT;
if (rpc_nfsacl_getacl_async(rpc, acl_getacl_cb, &args, client) != 0) {
printf("Failed to send getacl request\n");
exit(10);
}
}
void nfs_fsinfo_cb(struct rpc_context *rpc _U_, int status, void *data, void *private_data)
{
struct client *client = private_data;
FSINFO3res *res = data;
if (status == RPC_STATUS_ERROR) {
printf("nfs/fsinfo call failed with \"%s\"\n", (char *)data);
exit(10);
}
if (status != RPC_STATUS_SUCCESS) {
printf("nfs/fsinfo call to server %s failed, status:%d\n", client->server, status);
exit(10);
}
printf("Got reply from server for NFS/FSINFO procedure.\n");
printf("Read Max:%d\n", (int)res->FSINFO3res_u.resok.rtmax);
printf("Write Max:%d\n", (int)res->FSINFO3res_u.resok.wtmax);
printf("Send NFSACL/NULL request\n");
if (rpc_nfsacl_null_async(rpc, acl_null_cb, client) != 0) {
printf("Failed to send acl/null request\n");
exit(10);
}
}
void nfs_connect_cb(struct rpc_context *rpc, int status, void *data _U_, void *private_data)
{
struct client *client = private_data;
struct FSINFO3args args;
if (status != RPC_STATUS_SUCCESS) {
printf("connection to RPC.MOUNTD on server %s failed\n", client->server);
exit(10);
}
printf("Connected to RPC.NFSD on %s:%d\n", client->server, client->mount_port);
printf("Send FSINFO request\n");
args.fsroot = client->rootfh;
if (rpc_nfs3_fsinfo_async(rpc, nfs_fsinfo_cb, &args, client) != 0) {
printf("Failed to send fsinfo request\n");
exit(10);
}
}
void mount_mnt_cb(struct rpc_context *rpc, int status, void *data, void *private_data)
{
struct client *client = private_data;
mountres3 *mnt = data;
if (status == RPC_STATUS_ERROR) {
printf("mount/mnt call failed with \"%s\"\n", (char *)data);
exit(10);
}
if (status != RPC_STATUS_SUCCESS) {
printf("mount/mnt call to server %s failed, status:%d\n", client->server, status);
exit(10);
}
printf("Got reply from server for MOUNT/MNT procedure.\n");
client->rootfh.data.data_len = mnt->mountres3_u.mountinfo.fhandle.fhandle3_len;
client->rootfh.data.data_val = malloc(client->rootfh.data.data_len);
memcpy(client->rootfh.data.data_val, mnt->mountres3_u.mountinfo.fhandle.fhandle3_val, client->rootfh.data.data_len);
printf("Disconnect socket from mountd server\n");
if (rpc_disconnect(rpc, "normal disconnect") != 0) {
printf("Failed to disconnect socket to mountd\n");
exit(10);
}
printf("Connect to RPC.NFSD on %s:%d\n", client->server, 2049);
if (rpc_connect_async(rpc, client->server, 2049, nfs_connect_cb, client) != 0) {
printf("Failed to start connection\n");
exit(10);
}
}
void mount_export_cb(struct rpc_context *rpc, int status, void *data, void *private_data)
{
struct client *client = private_data;
exports export = *(exports *)data;
if (status == RPC_STATUS_ERROR) {
printf("mount null call failed with \"%s\"\n", (char *)data);
exit(10);
}
if (status != RPC_STATUS_SUCCESS) {
printf("mount null call to server %s failed, status:%d\n", client->server, status);
exit(10);
}
printf("Got reply from server for MOUNT/EXPORT procedure.\n");
while (export != NULL) {
printf("Export: %s\n", export->ex_dir);
export = export->ex_next;
}
printf("Send MOUNT/MNT command for %s\n", client->export);
if (rpc_mount_mnt_async(rpc, mount_mnt_cb, client->export, client) != 0) {
printf("Failed to send mnt request\n");
exit(10);
}
}
void mount_null_cb(struct rpc_context *rpc, int status, void *data, void *private_data)
{
struct client *client = private_data;
if (status == RPC_STATUS_ERROR) {
printf("mount null call failed with \"%s\"\n", (char *)data);
exit(10);
}
if (status != RPC_STATUS_SUCCESS) {
printf("mount null call to server %s failed, status:%d\n", client->server, status);
exit(10);
}
printf("Got reply from server for MOUNT/NULL procedure.\n");
printf("Send MOUNT/EXPORT command\n");
if (rpc_mount_export_async(rpc, mount_export_cb, client) != 0) {
printf("Failed to send export request\n");
exit(10);
}
}
void mount_connect_cb(struct rpc_context *rpc, int status, void *data _U_, void *private_data)
{
struct client *client = private_data;
if (status != RPC_STATUS_SUCCESS) {
printf("connection to RPC.MOUNTD on server %s failed\n", client->server);
exit(10);
}
printf("Connected to RPC.MOUNTD on %s:%d\n", client->server, client->mount_port);
printf("Send NULL request to check if RPC.MOUNTD is actually running\n");
if (rpc_mount_null_async(rpc, mount_null_cb, client) != 0) {
printf("Failed to send null request\n");
exit(10);
}
}
void pmap_getport2_cb(struct rpc_context *rpc, int status, void *data, void *private_data)
{
struct client *client = private_data;
if (status == RPC_STATUS_ERROR) {
printf("portmapper getport call failed with \"%s\"\n", (char *)data);
exit(10);
}
if (status != RPC_STATUS_SUCCESS) {
printf("portmapper getport call to server %s failed, status:%d\n", client->server, status);
exit(10);
}
client->mount_port = *(uint32_t *)data;
printf("GETPORT returned RPC.MOUNTD is on port:%d\n", client->mount_port);
if (client->mount_port == 0) {
printf("RPC.MOUNTD is not available on server : %s:%d\n", client->server, client->mount_port);
exit(10);
}
printf("Disconnect socket from portmap server\n");
if (rpc_disconnect(rpc, "normal disconnect") != 0) {
printf("Failed to disconnect socket to portmapper\n");
exit(10);
}
printf("Connect to RPC.MOUNTD on %s:%d\n", client->server, client->mount_port);
if (rpc_connect_async(rpc, client->server, client->mount_port, mount_connect_cb, client) != 0) {
printf("Failed to start connection\n");
exit(10);
}
}
void pmap_getport1_cb(struct rpc_context *rpc, int status, void *data, void *private_data)
{
struct client *client = private_data;
if (status == RPC_STATUS_ERROR) {
printf("portmapper getport call failed with \"%s\"\n", (char *)data);
exit(10);
}
if (status != RPC_STATUS_SUCCESS) {
printf("portmapper getport call to server %s failed, status:%d\n", client->server, status);
exit(10);
}
client->rquota_port = *(uint32_t *)data;
printf("GETPORT returned RPC.RQUOTAD on port:%d\n", client->rquota_port);
if (client->rquota_port == 0) {
printf("RPC.RQUOTAD is not available on server : %s:%d\n", client->server, client->rquota_port);
// exit(10);
}
printf("Send getport request asking for MOUNT port\n");
if (rpc_pmap2_getport_async(rpc, MOUNT_PROGRAM, MOUNT_V3, IPPROTO_TCP, pmap_getport2_cb, client) != 0) {
printf("Failed to send getport request\n");
exit(10);
}
}
void pmap_dump_cb(struct rpc_context *rpc, int status, void *data, void *private_data)
{
struct client *client = private_data;
struct pmap2_dump_result *dr = data;
struct pmap2_mapping_list *list = dr->list;
if (status == RPC_STATUS_ERROR) {
printf("portmapper null call failed with \"%s\"\n", (char *)data);
exit(10);
}
if (status != RPC_STATUS_SUCCESS) {
printf("portmapper null call to server %s failed, status:%d\n", client->server, status);
exit(10);
}
printf("Got reply from server for PORTMAP/DUMP procedure.\n");
while (list) {
printf("Prog:%d Vers:%d Protocol:%d Port:%d\n",
list->map.prog,
list->map.vers,
list->map.prot,
list->map.port);
list = list->next;
}
printf("Send getport request asking for MOUNT port\n");
if (rpc_pmap2_getport_async(rpc, RQUOTA_PROGRAM, RQUOTA_V1, IPPROTO_TCP, pmap_getport1_cb, client) != 0) {
printf("Failed to send getport request\n");
exit(10);
}
}
void pmap_null_cb(struct rpc_context *rpc, int status, void *data, void *private_data)
{
struct client *client = private_data;
if (status == RPC_STATUS_ERROR) {
printf("portmapper null call failed with \"%s\"\n", (char *)data);
exit(10);
}
if (status != RPC_STATUS_SUCCESS) {
printf("portmapper null call to server %s failed, status:%d\n", client->server, status);
exit(10);
}
printf("Got reply from server for PORTMAP/NULL procedure.\n");
printf("Send PMAP/DUMP command\n");
if (rpc_pmap2_dump_async(rpc, pmap_dump_cb, client) != 0) {
printf("Failed to send getport request\n");
exit(10);
}
}
void pmap_connect_cb(struct rpc_context *rpc, int status, void *data _U_, void *private_data)
{
struct client *client = private_data;
printf("pmap_connect_cb status:%d.\n", status);
if (status != RPC_STATUS_SUCCESS) {
printf("connection to portmapper on server %s failed\n", client->server);
exit(10);
}
printf("Send NULL request to check if portmapper is actually running\n");
if (rpc_pmap2_null_async(rpc, pmap_null_cb, client) != 0) {
printf("Failed to send null request\n");
exit(10);
}
}
int main(int argc _U_, char *argv[] _U_)
{
struct rpc_context *rpc;
struct pollfd pfd;
struct client client;
rpc = rpc_init_context();
if (rpc == NULL) {
printf("failed to init context\n");
exit(10);
}
client.server = SERVER;
client.export = EXPORT;
client.is_finished = 0;
if (rpc_connect_async(rpc, client.server, 111, pmap_connect_cb, &client) != 0) {
printf("Failed to start connection\n");
exit(10);
}
for (;;) {
pfd.fd = rpc_get_fd(rpc);
pfd.events = rpc_which_events(rpc);
if (poll(&pfd, 1, -1) < 0) {
printf("Poll failed");
exit(10);
}
if (rpc_service(rpc, pfd.revents) < 0) {
printf("rpc_service failed\n");
break;
}
if (client.is_finished) {
break;
}
}
rpc_destroy_context(rpc);
rpc=NULL;
printf("nfsclient finished\n");
return 0;
}
libnfs-libnfs-1.9.8/examples/nfsclient-sync.c 0000664 0000000 0000000 00000011404 12557450341 0021210 0 ustar 00root root 0000000 0000000 /*
Copyright (C) by Ronnie Sahlberg 2010
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 3 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.
You should have received a copy of the GNU General Public License
along with this program; if not, see .
*/
#define _FILE_OFFSET_BITS 64
#define _GNU_SOURCE
/* Example program using the highlevel sync interface
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef AROS
#include "aros_compat.h"
#endif
#ifdef WIN32
#include "win32_compat.h"
#pragma comment(lib, "ws2_32.lib")
WSADATA wsaData;
#define PRId64 "ll"
#else
#include
#include
#include
#ifndef AROS
#include
#endif
#endif
#ifdef HAVE_UNISTD_H
#include
#endif
#include
#include
#include
#include
#include
#include
#include "libnfs.h"
#include "libnfs-raw.h"
#include "libnfs-raw-mount.h"
struct client {
char *server;
char *export;
uint32_t mount_port;
int is_finished;
};
char buf[3*1024*1024+337];
void print_usage(void)
{
fprintf(stderr, "Usage: nfsclient-sync [-?|--help] [--usage] \n");
}
int main(int argc, char *argv[])
{
struct nfs_context *nfs = NULL;
int i, ret, res;
uint64_t offset;
struct client client;
struct nfs_stat_64 st;
struct nfsfh *nfsfh;
struct nfsdir *nfsdir;
struct nfsdirent *nfsdirent;
struct statvfs svfs;
exports export, tmp;
const char *url = NULL;
char *server = NULL, *path = NULL, *strp;
#ifdef WIN32
if (WSAStartup(MAKEWORD(2,2), &wsaData) != 0) {
printf("Failed to start Winsock2\n");
exit(10);
}
#endif
#ifdef AROS
aros_init_socket();
#endif
url = argv[1];
if (url == NULL) {
fprintf(stderr, "No URL specified.\n");
print_usage();
exit(0);
}
if (strncmp(url, "nfs://", 6)) {
fprintf(stderr, "Invalid URL specified.\n");
print_usage();
exit(0);
}
server = strdup(url + 6);
if (server == NULL) {
fprintf(stderr, "Failed to strdup server string\n");
exit(10);
}
if (server[0] == '/' || server[0] == '\0') {
fprintf(stderr, "Invalid server string.\n");
free(server);
exit(10);
}
strp = strchr(server, '/');
if (strp == NULL) {
fprintf(stderr, "Invalid URL specified.\n");
print_usage();
free(server);
exit(0);
}
path = strdup(strp);
if (path == NULL) {
fprintf(stderr, "Failed to strdup server string\n");
free(server);
exit(10);
}
if (path[0] != '/') {
fprintf(stderr, "Invalid path.\n");
free(server);
free(path);
exit(10);
}
*strp = 0;
client.server = server;
client.export = path;
client.is_finished = 0;
nfs = nfs_init_context();
if (nfs == NULL) {
printf("failed to init context\n");
goto finished;
}
ret = nfs_mount(nfs, client.server, client.export);
if (ret != 0) {
printf("Failed to mount nfs share : %s\n", nfs_get_error(nfs));
goto finished;
}
ret = nfs_opendir(nfs, "/", &nfsdir);
if (ret != 0) {
printf("Failed to opendir(\"/\") %s\n", nfs_get_error(nfs));
exit(10);
}
while((nfsdirent = nfs_readdir(nfs, nfsdir)) != NULL) {
char path[1024];
if (!strcmp(nfsdirent->name, ".") || !strcmp(nfsdirent->name, "..")) {
continue;
}
sprintf(path, "%s/%s", "/", nfsdirent->name);
ret = nfs_stat64(nfs, path, &st);
if (ret != 0) {
fprintf(stderr, "Failed to stat(%s) %s\n", path, nfs_get_error(nfs));
continue;
}
switch (st.nfs_mode & S_IFMT) {
#ifndef WIN32
case S_IFLNK:
#endif
case S_IFREG:
printf("-");
break;
case S_IFDIR:
printf("d");
break;
case S_IFCHR:
printf("c");
break;
case S_IFBLK:
printf("b");
break;
}
printf("%c%c%c",
"-r"[!!(st.nfs_mode & S_IRUSR)],
"-w"[!!(st.nfs_mode & S_IWUSR)],
"-x"[!!(st.nfs_mode & S_IXUSR)]
);
printf("%c%c%c",
"-r"[!!(st.nfs_mode & S_IRGRP)],
"-w"[!!(st.nfs_mode & S_IWGRP)],
"-x"[!!(st.nfs_mode & S_IXGRP)]
);
printf("%c%c%c",
"-r"[!!(st.nfs_mode & S_IROTH)],
"-w"[!!(st.nfs_mode & S_IWOTH)],
"-x"[!!(st.nfs_mode & S_IXOTH)]
);
printf(" %2d", (int)st.nfs_nlink);
printf(" %5d", (int)st.nfs_uid);
printf(" %5d", (int)st.nfs_gid);
printf(" %12" PRId64, st.nfs_size);
printf(" %s\n", nfsdirent->name);
}
nfs_closedir(nfs, nfsdir);
finished:
free(server);
free(path);
if (nfs != NULL) {
nfs_destroy_context(nfs);
}
return 0;
}
libnfs-libnfs-1.9.8/examples/portmap-client.c 0000664 0000000 0000000 00000027542 12557450341 0021221 0 ustar 00root root 0000000 0000000 /*
Copyright (C) by Ronnie Sahlberg 2014
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 3 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.
You should have received a copy of the GNU General Public License
along with this program; if not, see .
*/
/* Example program using the lowlevel raw interface.
* This allow accurate control of the exact commands that are being used.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef WIN32
#include "win32_compat.h"
#endif
#ifdef HAVE_POLL_H
#include
#endif
#ifdef HAVE_NETINET_IN_H
#include
#endif
#include
#include
#include
#include
#include
#include
#include "libnfs.h"
#include "libnfs-raw.h"
#include "libnfs-raw-mount.h"
#include "libnfs-raw-nfs.h"
#include "libnfs-raw-portmap.h"
#include "libnfs-raw-rquota.h"
struct client {
int is_finished;
};
void pmap2_dump_cb(struct rpc_context *rpc, int status, void *data, void *private_data)
{
struct client *client = private_data;
struct pmap2_dump_result *dr = data;
struct pmap2_mapping_list *list = dr->list;
if (status == RPC_STATUS_ERROR) {
printf("PORTMAP2/DUMP call failed with \"%s\"\n", (char *)data);
exit(10);
}
if (status != RPC_STATUS_SUCCESS) {
printf("PORTMAP2/DUMP call failed, status:%d\n", status);
exit(10);
}
printf("PORTMAP2/DUMP:\n");
while (list) {
printf(" Prog:%d Vers:%d Protocol:%d Port:%d\n",
list->map.prog,
list->map.vers,
list->map.prot,
list->map.port);
list = list->next;
}
client->is_finished = 1;
}
void pmap3_dump_cb(struct rpc_context *rpc, int status, void *data, void *private_data)
{
struct client *client = private_data;
struct pmap3_dump_result *dr = data;
struct pmap3_mapping_list *list = dr->list;
if (status == RPC_STATUS_ERROR) {
printf("PORTMAP3/DUMP call failed with \"%s\"\n", (char *)data);
exit(10);
}
if (status != RPC_STATUS_SUCCESS) {
printf("PORTMAP3/DUMP call failed, status:%d\n", status);
exit(10);
}
printf("PORTMAP3/DUMP:\n");
while (list) {
printf(" Prog:%d Vers:%d Netid:%s Addr:%s Owner:%s\n",
list->map.prog,
list->map.vers,
list->map.netid,
list->map.addr,
list->map.owner);
list = list->next;
}
client->is_finished = 1;
}
void pmap3_getaddr_cb(struct rpc_context *rpc, int status, void *data, void *private_data)
{
struct client *client = private_data;
struct pmap3_string_result *gar = data;
if (status == RPC_STATUS_ERROR) {
printf("PORTMAP3/GETADDR call failed with \"%s\"\n", (char *)data);
exit(10);
}
if (status != RPC_STATUS_SUCCESS) {
printf("PORTMAP3/GETADDR call failed, status:%d\n", status);
exit(10);
}
printf("PORTMAP3/GETADDR:\n");
printf(" Addr:%s\n", gar->addr);
client->is_finished = 1;
}
void pmap3_set_cb(struct rpc_context *rpc, int status, void *data, void *private_data)
{
struct client *client = private_data;
uint32_t res = *(uint32_t *)data;
if (status == RPC_STATUS_ERROR) {
printf("PORTMAP3/SET call failed with \"%s\"\n", (char *)data);
exit(10);
}
if (status != RPC_STATUS_SUCCESS) {
printf("PORTMAP3/SET call failed, status:%d\n", status);
exit(10);
}
printf("PORTMAP3/SET:\n");
printf(" Res:%d\n", res);
client->is_finished = 1;
}
void pmap3_unset_cb(struct rpc_context *rpc, int status, void *data, void *private_data)
{
struct client *client = private_data;
uint32_t res = *(uint32_t *)data;
if (status == RPC_STATUS_ERROR) {
printf("PORTMAP3/UNSET call failed with \"%s\"\n", (char *)data);
exit(10);
}
if (status != RPC_STATUS_SUCCESS) {
printf("PORTMAP3/UNSET call failed, status:%d\n", status);
exit(10);
}
printf("PORTMAP3/UNSET:\n");
printf(" Res:%d\n", res);
client->is_finished = 1;
}
void pmap3_gettime_cb(struct rpc_context *rpc, int status, void *data, void *private_data)
{
struct client *client = private_data;
time_t t = *(uint32_t *)data;
if (status == RPC_STATUS_ERROR) {
printf("PORTMAP3/GETTIME call failed with \"%s\"\n", (char *)data);
exit(10);
}
if (status != RPC_STATUS_SUCCESS) {
printf("PORTMAP3/GETTIME call failed, status:%d\n", status);
exit(10);
}
printf("PORTMAP3/GETTIME:\n");
printf(" Time:%d %s\n", (int)t, ctime(&t));
client->is_finished = 1;
}
void pmap3_uaddr2taddr_cb(struct rpc_context *rpc, int status, void *data, void *private_data)
{
struct client *client = private_data;
struct pmap3_netbuf *nb = data;
struct sockaddr_storage *ss;
char host[256], port[6];
int i;
if (status == RPC_STATUS_ERROR) {
printf("PORTMAP3/UADDR2TADDR call failed with \"%s\"\n", (char *)data);
exit(10);
}
if (status != RPC_STATUS_SUCCESS) {
printf("PORTMAP3/UADDR2TADDR call failed, status:%d\n", status);
exit(10);
}
printf("PORTMAP3/UADDR2TADDR:\n");
printf(" MaxLen:%d\n", nb->maxlen);
printf(" ");
for (i = 0; i < nb->maxlen; i++) {
printf("%02x ", nb->buf.buf_val[i]);
if (i %16 == 15) {
printf("\n ");
}
}
printf("\n");
printf(" ---\n");
ss = (struct sockaddr_storage *)&nb->buf.buf_val[0];
getnameinfo((struct sockaddr *)ss, sizeof(struct sockaddr_storage),
&host[0], sizeof(host), &port[0], sizeof(port),
NI_NUMERICHOST|NI_NUMERICSERV);
switch (ss->ss_family) {
case AF_INET:
printf(" IPv4: %s:%s\n", &host[0], &port[0]);
break;
case AF_INET6:
printf(" IPv6: %s:%s\n", &host[0], &port[0]);
break;
}
client->is_finished = 1;
}
void pmap2_null_cb(struct rpc_context *rpc, int status, void *data, void *private_data)
{
struct client *client = private_data;
if (status == RPC_STATUS_ERROR) {
printf("PORTMAP2/NULL call failed with \"%s\"\n", (char *)data);
exit(10);
}
if (status != RPC_STATUS_SUCCESS) {
printf("PORTMAP2/NULL call failed, status:%d\n", status);
exit(10);
}
printf("PORTMAP2/NULL responded and server is alive\n");
client->is_finished = 1;
}
void pmap3_null_cb(struct rpc_context *rpc, int status, void *data, void *private_data)
{
struct client *client = private_data;
if (status == RPC_STATUS_ERROR) {
printf("PORTMAP3/NULL call failed with \"%s\"\n", (char *)data);
exit(10);
}
if (status != RPC_STATUS_SUCCESS) {
printf("PORTMAP3/NULL call failed, status:%d\n", status);
exit(10);
}
printf("PORTMAP3/NULL responded and server is alive\n");
client->is_finished = 1;
}
void pmap_null_cb(struct rpc_context *rpc, int status, void *data, void *private_data)
{
struct client *client = private_data;
if (status == RPC_STATUS_ERROR) {
printf("PORTMAP/NULL call failed with \"%s\"\n", (char *)data);
exit(10);
}
if (status != RPC_STATUS_SUCCESS) {
printf("PORTMAP/NULL call failed, status:%d\n", status);
exit(10);
}
client->is_finished = 1;
}
void pmap_connect_cb(struct rpc_context *rpc, int status, void *data _U_, void *private_data)
{
struct client *client = private_data;
if (status != RPC_STATUS_SUCCESS) {
printf("connection to portmapper failed\n");
exit(10);
}
if (rpc_pmap2_null_async(rpc, pmap_null_cb, client) != 0) {
printf("Failed to send null request\n");
exit(10);
}
}
static void wait_until_finished(struct rpc_context *rpc, struct client *client)
{
struct pollfd pfd;
client->is_finished = 0;
for (;;) {
pfd.fd = rpc_get_fd(rpc);
pfd.events = rpc_which_events(rpc);
if (poll(&pfd, 1, -1) < 0) {
printf("Poll failed");
exit(10);
}
if (rpc_service(rpc, pfd.revents) < 0) {
printf("rpc_service failed\n");
break;
}
if (client->is_finished) {
break;
}
}
}
int main(int argc _U_, char *argv[] _U_)
{
struct rpc_context *rpc;
struct client client;
char *server = NULL;
int i;
int null2 = 0;
int dump2 = 0;
int null3 = 0;
int set3 = 0;
int unset3 = 0;
int getaddr3 = 0;
int dump3 = 0;
int gettime3 = 0;
int u2t3 = 0;
int command_found = 0;
int set3prog, set3vers;
char *set3netid, *set3addr, *set3owner;
int unset3prog, unset3vers;
char *unset3netid, *unset3addr, *unset3owner;
int getaddr3prog, getaddr3vers;
char *getaddr3netid, *getaddr3addr, *getaddr3owner;
char *u2t3string;
rpc = rpc_init_context();
if (rpc == NULL) {
printf("failed to init context\n");
exit(10);
}
for (i = 1; i < argc; i++) {
if (!strcmp(argv[i], "dump2")) {
dump2 = 1;
command_found++;
} else if (!strcmp(argv[i], "null2")) {
null2 = 1;
command_found++;
} else if (!strcmp(argv[i], "dump3")) {
dump3 = 1;
command_found++;
} else if (!strcmp(argv[i], "gettime3")) {
gettime3 = 1;
command_found++;
} else if (!strcmp(argv[i], "u2t3")) {
u2t3 = 1;
u2t3string = argv[++i];
command_found++;
} else if (!strcmp(argv[i], "getaddr3")) {
getaddr3 = 1;
getaddr3prog = atoi(argv[++i]);
getaddr3vers = atoi(argv[++i]);
getaddr3netid = argv[++i];
getaddr3addr = argv[++i];
getaddr3owner = argv[++i];
command_found++;
} else if (!strcmp(argv[i], "set3")) {
set3 = 1;
set3prog = atoi(argv[++i]);
set3vers = atoi(argv[++i]);
set3netid = argv[++i];
set3addr = argv[++i];
set3owner = argv[++i];
command_found++;
} else if (!strcmp(argv[i], "null3")) {
null3 = 1;
command_found++;
} else {
server = argv[i];
}
}
if (command_found == 0 || server == NULL) {
fprintf(stderr, "Usage: portmap-client \n");
exit(10);
}
if (rpc_connect_async(rpc, server, 111, pmap_connect_cb, &client) != 0) {
printf("Failed to start connection\n");
exit(10);
}
wait_until_finished(rpc, &client);
if (null2) {
if (rpc_pmap2_null_async(rpc, pmap2_null_cb, &client) != 0) {
printf("Failed to send NULL2 request\n");
exit(10);
}
wait_until_finished(rpc, &client);
}
if (dump2) {
if (rpc_pmap2_dump_async(rpc, pmap2_dump_cb, &client) != 0) {
printf("Failed to send DUMP2 request\n");
exit(10);
}
wait_until_finished(rpc, &client);
}
if (null3) {
if (rpc_pmap3_null_async(rpc, pmap3_null_cb, &client) != 0) {
printf("Failed to send NULL3 request\n");
exit(10);
}
wait_until_finished(rpc, &client);
}
if (dump3) {
if (rpc_pmap3_dump_async(rpc, pmap3_dump_cb, &client) != 0) {
printf("Failed to send DUMP3 request\n");
exit(10);
}
wait_until_finished(rpc, &client);
}
if (gettime3) {
if (rpc_pmap3_gettime_async(rpc, pmap3_gettime_cb, &client) != 0) {
printf("Failed to send GETTIME3 request\n");
exit(10);
}
wait_until_finished(rpc, &client);
}
if (u2t3) {
if (rpc_pmap3_uaddr2taddr_async(rpc, u2t3string, pmap3_uaddr2taddr_cb, &client) != 0) {
printf("Failed to send UADDR2TADDR3 request\n");
exit(10);
}
wait_until_finished(rpc, &client);
}
if (getaddr3) {
struct pmap3_mapping map;
map.prog = getaddr3prog;
map.vers = getaddr3vers;
map.netid = getaddr3netid;
map.addr = getaddr3addr;
map.owner = getaddr3owner;
if (rpc_pmap3_getaddr_async(rpc, &map, pmap3_getaddr_cb, &client) != 0) {
printf("Failed to send GETADDR3 request\n");
exit(10);
}
wait_until_finished(rpc, &client);
}
if (set3) {
struct pmap3_mapping map;
map.prog = set3prog;
map.vers = set3vers;
map.netid = set3netid;
map.addr = set3addr;
map.owner = set3owner;
if (rpc_pmap3_set_async(rpc, &map, pmap3_set_cb, &client) != 0) {
printf("Failed to send SET3 request\n");
exit(10);
}
wait_until_finished(rpc, &client);
}
if (unset3) {
struct pmap3_mapping map;
map.prog = unset3prog;
map.vers = unset3vers;
map.netid = unset3netid;
map.addr = unset3addr;
map.owner = unset3owner;
if (rpc_pmap3_unset_async(rpc, &map, pmap3_unset_cb, &client) != 0) {
printf("Failed to send UNSET3 request\n");
exit(10);
}
wait_until_finished(rpc, &client);
}
rpc_destroy_context(rpc);
rpc=NULL;
return 0;
}
libnfs-libnfs-1.9.8/include/ 0000775 0000000 0000000 00000000000 12557450341 0015712 5 ustar 00root root 0000000 0000000 libnfs-libnfs-1.9.8/include/Makefile.am 0000664 0000000 0000000 00000000544 12557450341 0017751 0 ustar 00root root 0000000 0000000 nfscdir = $(includedir)/nfsc
dist_nfsc_HEADERS = \
nfsc/libnfs.h \
nfsc/libnfs-raw.h \
nfsc/libnfs-zdr.h \
../mount/libnfs-raw-mount.h \
../portmap/libnfs-raw-portmap.h \
../nfs/libnfs-raw-nfs.h \
../nlm/libnfs-raw-nlm.h \
../nsm/libnfs-raw-nsm.h \
../rquota/libnfs-raw-rquota.h
dist_noinst_HEADERS = \
libnfs-private.h \
slist.h
libnfs-libnfs-1.9.8/include/libnfs-private.h 0000664 0000000 0000000 00000012525 12557450341 0021015 0 ustar 00root root 0000000 0000000 /*
Copyright (C) 2010 by Ronnie Sahlberg
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, see .
*/
#ifndef _LIBNFS_PRIVATE_H_
#define _LIBNFS_PRIVATE_H_
#ifdef HAVE_CONFIG_H
#include "config.h" /* HAVE_SOCKADDR_STORAGE ? */
#endif
#ifndef WIN32
#include /* struct sockaddr_storage */
#endif
#include "libnfs-zdr.h"
#ifdef __cplusplus
extern "C" {
#endif
#if !defined(HAVE_SOCKADDR_STORAGE) && !defined(WIN32)
/*
* RFC 2553: protocol-independent placeholder for socket addresses
*/
#define _SS_MAXSIZE 128
#define _SS_ALIGNSIZE (sizeof(double))
#define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(unsigned char) * 2)
#define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(unsigned char) * 2 - \
_SS_PAD1SIZE - _SS_ALIGNSIZE)
struct sockaddr_storage {
#ifdef HAVE_SOCKADDR_LEN
unsigned char ss_len; /* address length */
unsigned char ss_family; /* address family */
#else
unsigned short ss_family;
#endif
char __ss_pad1[_SS_PAD1SIZE];
double __ss_align; /* force desired structure storage alignment */
char __ss_pad2[_SS_PAD2SIZE];
};
#endif
struct rpc_fragment {
struct rpc_fragment *next;
uint64_t size;
char *data;
};
#define RPC_CONTEXT_MAGIC 0xc6e46435
#define RPC_PARAM_UNDEFINED -1
/*
* Queue is singly-linked but we hold on to the tail
*/
struct rpc_queue {
struct rpc_pdu *head, *tail;
};
#define HASHES 1024
#define NFS_RA_TIMEOUT 5
#define NFS_MAX_XFER_SIZE (1024 * 1024)
struct rpc_context {
uint32_t magic;
int fd;
int is_connected;
char *error_string;
rpc_cb connect_cb;
void *connect_data;
struct AUTH *auth;
uint32_t xid;
/* buffer used for encoding RPC PDU */
char *encodebuf;
int encodebuflen;
struct rpc_queue outqueue;
struct sockaddr_storage udp_src;
struct rpc_queue waitpdu[HASHES];
uint32_t inpos;
char *inbuf;
uint32_t inbuflen;
/* special fields for UDP, which can sometimes be BROADCASTed */
int is_udp;
struct sockaddr *udp_dest;
int is_broadcast;
/* track the address we connect to so we can auto-reconnect on session failure */
struct sockaddr_storage s;
int auto_reconnect;
/* fragment reassembly */
struct rpc_fragment *fragments;
/* parameters passable via URL */
int tcp_syncnt;
int uid;
int gid;
uint32_t readahead;
int debug;
};
struct rpc_pdu {
struct rpc_pdu *next;
uint32_t xid;
ZDR zdr;
uint32_t written;
struct rpc_data outdata;
rpc_cb cb;
void *private_data;
/* function to decode the zdr reply data and buffer to decode into */
zdrproc_t zdr_decode_fn;
caddr_t zdr_decode_buf;
uint32_t zdr_decode_bufsize;
};
void rpc_reset_queue(struct rpc_queue *q);
void rpc_enqueue(struct rpc_queue *q, struct rpc_pdu *pdu);
void rpc_return_to_queue(struct rpc_queue *q, struct rpc_pdu *pdu);
unsigned int rpc_hash_xid(uint32_t xid);
struct rpc_pdu *rpc_allocate_pdu(struct rpc_context *rpc, int program, int version, int procedure, rpc_cb cb, void *private_data, zdrproc_t zdr_decode_fn, int zdr_bufsize);
void rpc_free_pdu(struct rpc_context *rpc, struct rpc_pdu *pdu);
int rpc_queue_pdu(struct rpc_context *rpc, struct rpc_pdu *pdu);
int rpc_get_pdu_size(char *buf);
int rpc_process_pdu(struct rpc_context *rpc, char *buf, int size);
void rpc_error_all_pdus(struct rpc_context *rpc, const char *error);
void rpc_set_error(struct rpc_context *rpc, const char *error_string, ...)
#ifdef __GNUC__
__attribute__((format(printf, 2, 3)))
#endif
;
void nfs_set_error(struct nfs_context *nfs, char *error_string, ...)
#ifdef __GNUC__
__attribute__((format(printf, 2, 3)))
#endif
;
#define RPC_LOG(rpc, level, format, ...) \
do { \
if (level <= rpc->debug) { \
fprintf(stderr, "libnfs:%d " format "\n", level, ## __VA_ARGS__); \
} \
} while (0)
const char *nfs_get_server(struct nfs_context *nfs);
const char *nfs_get_export(struct nfs_context *nfs);
/* we dont want to expose UDP to normal applications/users this is private to libnfs to use exclusively for broadcast RPC */
int rpc_bind_udp(struct rpc_context *rpc, char *addr, int port);
int rpc_set_udp_destination(struct rpc_context *rpc, char *addr, int port, int is_broadcast);
struct rpc_context *rpc_init_udp_context(void);
struct sockaddr *rpc_get_recv_sockaddr(struct rpc_context *rpc);
void rpc_set_autoreconnect(struct rpc_context *rpc);
void rpc_unset_autoreconnect(struct rpc_context *rpc);
void rpc_set_tcp_syncnt(struct rpc_context *rpc, int v);
void rpc_set_uid(struct rpc_context *rpc, int uid);
void rpc_set_gid(struct rpc_context *rpc, int gid);
void rpc_set_readahead(struct rpc_context *rpc, uint32_t v);
void rpc_set_debug(struct rpc_context *rpc, int level);
int rpc_add_fragment(struct rpc_context *rpc, char *data, uint64_t size);
void rpc_free_all_fragments(struct rpc_context *rpc);
const struct nfs_fh3 *nfs_get_rootfh(struct nfs_context *nfs);
#ifdef __cplusplus
}
#endif
#endif /* !_LIBNFS_PRIVATE_H_ */
libnfs-libnfs-1.9.8/include/nfsc/ 0000775 0000000 0000000 00000000000 12557450341 0016643 5 ustar 00root root 0000000 0000000 libnfs-libnfs-1.9.8/include/nfsc/libnfs-raw.h 0000664 0000000 0000000 00000230203 12557450341 0021060 0 ustar 00root root 0000000 0000000 /*
Copyright (C) 2010 by Ronnie Sahlberg
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, see .
*/
/*
* This is the lowlevel interface to access NFS resources.
* Through this interface you have access to the full gamut of nfs and nfs related
* protocol as well as the XDR encoded/decoded structures.
*/
#ifndef _LIBNFS_RAW_H_
#define _LIBNFS_RAW_H_
#include
#include
#ifdef __cplusplus
extern "C" {
#endif
struct rpc_data {
int size;
unsigned char *data;
};
struct rpc_context;
struct rpc_context *rpc_init_context(void);
void rpc_destroy_context(struct rpc_context *rpc);
void rpc_set_auth(struct rpc_context *rpc, struct AUTH *auth);
int rpc_get_fd(struct rpc_context *rpc);
int rpc_which_events(struct rpc_context *rpc);
int rpc_service(struct rpc_context *rpc, int revents);
char *rpc_get_error(struct rpc_context *rpc);
int rpc_queue_length(struct rpc_context *rpc);
/* Utility function to get an RPC context from a NFS context. Useful for doing low level NFSACL
* calls on a NFS context.
*/
struct rpc_context *nfs_get_rpc_context(struct nfs_context *nfs);
/* This function returns the nfs_fh3 structure from a nfsfh structure.
This allows to use a file onened with nfs_open() together with low-level
rpc functions that thake a nfs filehandle
*/
struct nfs_fh3 *nfs_get_fh(struct nfsfh *nfsfh);
/* Control what the next XID value to be used on the context will be.
This can be used when multiple contexts are used to the same server
to avoid that the two contexts have xid collissions.
*/
void rpc_set_next_xid(struct rpc_context *rpc, uint32_t xid);
/* This function can be used to set the file descriptor used for
* the RPC context. It is primarily useful when emulating dup2()
* and similar or where you want full control of the filedescriptor numbers
* used by the rpc socket.
*
* ...
* oldfd = rpc_get_fd(rpc);
* dup2(oldfd, newfd);
* rpc_set_fd(rpc, newfd);
* close(oldfd);
* ...
*/
void rpc_set_fd(struct rpc_context *rpc, int fd);
#define RPC_STATUS_SUCCESS 0
#define RPC_STATUS_ERROR 1
#define RPC_STATUS_CANCEL 2
/*
* Async connection to the tcp port at server:port.
* Function returns
* 0 : The connection was initiated. Once the connection establish finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the connection. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : The tcp connection was successfully established.
* data is NULL.
* RPC_STATUS_ERROR : The connection failed to establish.
* data is the erro string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* : data is NULL.
*/
int rpc_connect_async(struct rpc_context *rpc, const char *server, int port, rpc_cb cb, void *private_data);
/*
* Async function to connect to a specific RPC program/version
* Function returns
* 0 : The connection was initiated. Once the connection establish finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the connection. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : The tcp connection was successfully established.
* data is NULL.
* RPC_STATUS_ERROR : The connection failed to establish.
* data is the erro string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* : data is NULL.
*/
int rpc_connect_program_async(struct rpc_context *rpc, const char *server, int program, int version, rpc_cb cb, void *private_data);
/*
* When disconnecting a connection in flight. All commands in flight will be called with the callback
* and status RPC_STATUS_ERROR. Data will be the error string for the disconnection.
*/
int rpc_disconnect(struct rpc_context *rpc, const char *error);
/*
* PORTMAP v2 FUNCTIONS
*/
/*
* Call PORTMAPPER2/NULL
* Function returns
* 0 : The connection was initiated. Once the connection establish finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the connection. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the portmapper daemon.
* data is NULL.
* RPC_STATUS_ERROR : An error occured when trying to contact the portmapper.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
EXTERN int rpc_pmap2_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
/*
* Call PORTMAPPER2/GETPORT.
* Function returns
* 0 : The connection was initiated. Once the connection establish finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the connection. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the portmapper daemon.
* data is a (uint32_t *), containing the port returned.
* RPC_STATUS_ERROR : An error occured when trying to contact the portmapper.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
EXTERN int rpc_pmap2_getport_async(struct rpc_context *rpc, int program, int version, int protocol, rpc_cb cb, void *private_data);
/*
* Call PORTMAPPER2/SET
* Function returns
* 0 : The connection was initiated. Once the connection establish finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the connection. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the portmapper daemon.
* data is a (uint32_t *), containing status
* RPC_STATUS_ERROR : An error occured when trying to contact the portmapper.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
EXTERN int rpc_pmap2_set_async(struct rpc_context *rpc, int program, int version, int protocol, int port, rpc_cb cb, void *private_data);
/*
* Call PORTMAPPER2/UNSET
* Function returns
* 0 : The connection was initiated. Once the connection establish finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the connection. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the portmapper daemon.
* data is a (uint32_t *), containing status
* RPC_STATUS_ERROR : An error occured when trying to contact the portmapper.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
EXTERN int rpc_pmap2_unset_async(struct rpc_context *rpc, int program, int version, int protocol, int port, rpc_cb cb, void *private_data);
/*
* Call PORTMAPPER2/DUMP.
* Function returns
* 0 : The connection was initiated. Once the connection establish finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the connection. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the portmapper daemon.
* data is struct pmap2_dump_result.
* RPC_STATUS_ERROR : An error occured when trying to contact the portmapper.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
EXTERN int rpc_pmap2_dump_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
/*
* Call PORTMAPPER2/CALLIT.
* Function returns
* 0 : The connection was initiated. Once the connection establish finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the connection. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the portmapper daemon
* data is a 'pmap2_call_result' pointer.
* RPC_STATUS_ERROR : An error occured when trying to contact the portmapper.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
EXTERN int rpc_pmap2_callit_async(struct rpc_context *rpc, int program, int version, int procedure, char *data, int datalen, rpc_cb cb, void *private_data);
/*
* PORTMAP v3 FUNCTIONS
*/
/*
* Call PORTMAPPER3/NULL
* Function returns
* 0 : The connection was initiated. Once the connection establish finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the connection. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the portmapper daemon.
* data is NULL.
* RPC_STATUS_ERROR : An error occured when trying to contact the portmapper.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
EXTERN int rpc_pmap3_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
/*
* Call PORTMAPPER3/SET.
* Function returns
* 0 : The connection was initiated. Once the connection establish finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the connection. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the portmapper daemon.
* data is uint32_t *
* RPC_STATUS_ERROR : An error occured when trying to contact the portmapper.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct pmap3_mapping;
EXTERN int rpc_pmap3_set_async(struct rpc_context *rpc, struct pmap3_mapping *map, rpc_cb cb, void *private_data);
/*
* Call PORTMAPPER3/UNSET.
* Function returns
* 0 : The connection was initiated. Once the connection establish finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the connection. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the portmapper daemon.
* data is uint32_t *
* RPC_STATUS_ERROR : An error occured when trying to contact the portmapper.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
EXTERN int rpc_pmap3_unset_async(struct rpc_context *rpc, struct pmap3_mapping *map, rpc_cb cb, void *private_data);
/*
* Call PORTMAPPER3/GETADDR.
* Function returns
* 0 : The connection was initiated. Once the connection establish finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the connection. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the portmapper daemon.
* data is struct pmap3_string_result.
* RPC_STATUS_ERROR : An error occured when trying to contact the portmapper.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
EXTERN int rpc_pmap3_getaddr_async(struct rpc_context *rpc, struct pmap3_mapping *map, rpc_cb cb, void *private_data);
/*
* Call PORTMAPPER3/DUMP.
* Function returns
* 0 : The connection was initiated. Once the connection establish finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the connection. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the portmapper daemon.
* data is struct pmap3_dump_result.
* RPC_STATUS_ERROR : An error occured when trying to contact the portmapper.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
EXTERN int rpc_pmap3_dump_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
/*
* Call PORTMAPPER3/CALLIT.
* Function returns
* 0 : The connection was initiated. Once the connection establish finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the connection. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the portmapper daemon
* data is a 'pmap3_call_result' pointer.
* RPC_STATUS_ERROR : An error occured when trying to contact the portmapper.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
EXTERN int rpc_pmap3_callit_async(struct rpc_context *rpc, int program, int version, int procedure, char *data, int datalen, rpc_cb cb, void *private_data);
/*
* Call PORTMAPPER3/GETTIME.
* Function returns
* 0 : The connection was initiated. Once the connection establish finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the connection. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the portmapper daemon.
* data is a uint32_t *.
* RPC_STATUS_ERROR : An error occured when trying to contact the portmapper.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
EXTERN int rpc_pmap3_gettime_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
/*
* Call PORTMAPPER3/UADDR2TADDR.
* Function returns
* 0 : The connection was initiated. Once the connection establish finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the connection. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the portmapper daemon.
* data is a struct pmap3_netbuf *.
* RPC_STATUS_ERROR : An error occured when trying to contact the portmapper.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
EXTERN int rpc_pmap3_uaddr2taddr_async(struct rpc_context *rpc, char *uaddr, rpc_cb cb, void *private_data);
/*
* Call PORTMAPPER3/TADDR2UADDR.
* Function returns
* 0 : The connection was initiated. Once the connection establish finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the connection. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the portmapper daemon.
* data is a struct pmap3_string_result *.
* RPC_STATUS_ERROR : An error occured when trying to contact the portmapper.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct pmap3_netbuf;
EXTERN int rpc_pmap3_taddr2uaddr_async(struct rpc_context *rpc, struct pmap3_netbuf *netbuf, rpc_cb cb, void *private_data);
/*
* MOUNT v3 FUNCTIONS
*/
char *mountstat3_to_str(int stat);
int mountstat3_to_errno(int error);
/*
* Call MOUNT3/NULL
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the mount daemon.
* data is NULL.
* RPC_STATUS_ERROR : An error occured when trying to contact the mount daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
EXTERN int rpc_mount3_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
EXTERN int rpc_mount_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
/*
* Call MOUNT3/MNT
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the mount daemon.
* data is union mountres3.
* RPC_STATUS_ERROR : An error occured when trying to contact the mount daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
EXTERN int rpc_mount3_mnt_async(struct rpc_context *rpc, rpc_cb cb, char *exportname, void *private_data);
EXTERN int rpc_mount_mnt_async(struct rpc_context *rpc, rpc_cb cb, char *exportname, void *private_data);
/*
* Call MOUNT3/DUMP
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the mount daemon.
* data is a mountlist.
* RPC_STATUS_ERROR : An error occured when trying to contact the mount daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
EXTERN int rpc_mount3_dump_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
EXTERN int rpc_mount_dump_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
/*
* Call MOUNT3/UMNT
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the mount daemon.
* data NULL.
* RPC_STATUS_ERROR : An error occured when trying to contact the mount daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
EXTERN int rpc_mount3_umnt_async(struct rpc_context *rpc, rpc_cb cb, char *exportname, void *private_data);
EXTERN int rpc_mount_umnt_async(struct rpc_context *rpc, rpc_cb cb, char *exportname, void *private_data);
/*
* Call MOUNT3/UMNTALL
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the mount daemon.
* data NULL.
* RPC_STATUS_ERROR : An error occured when trying to contact the mount daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
EXTERN int rpc_mount3_umntall_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
EXTERN int rpc_mount_umntall_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
/*
* Call MOUNT3/EXPORT
* NOTE: You must include 'libnfs-raw-mount.h' to get the definitions of the
* returned structures.
*
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the mount daemon.
* data is a pointer to an exports pointer:
* exports export = *(exports *)data;
* RPC_STATUS_ERROR : An error occured when trying to contact the mount daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
EXTERN int rpc_mount3_export_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
EXTERN int rpc_mount_export_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
/*
* MOUNT v1 FUNCTIONS (Used with NFSv2)
*/
/*
* Call MOUNT1/NULL
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the mount daemon.
* data is NULL.
* RPC_STATUS_ERROR : An error occured when trying to contact the mount daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
EXTERN int rpc_mount1_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
/*
* Call MOUNT1/MNT
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the mount daemon.
* data is union mountres1.
* RPC_STATUS_ERROR : An error occured when trying to contact the mount daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
EXTERN int rpc_mount1_mnt_async(struct rpc_context *rpc, rpc_cb cb, char *exportname, void *private_data);
/*
* Call MOUNT1/DUMP
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the mount daemon.
* data is a mountlist.
* RPC_STATUS_ERROR : An error occured when trying to contact the mount daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
EXTERN int rpc_mount1_dump_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
/*
* Call MOUNT1/UMNT
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the mount daemon.
* data NULL.
* RPC_STATUS_ERROR : An error occured when trying to contact the mount daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
EXTERN int rpc_mount1_umnt_async(struct rpc_context *rpc, rpc_cb cb, char *exportname, void *private_data);
/*
* Call MOUNT1/UMNTALL
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the mount daemon.
* data NULL.
* RPC_STATUS_ERROR : An error occured when trying to contact the mount daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
EXTERN int rpc_mount1_umntall_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
/*
* Call MOUNT1/EXPORT
* NOTE: You must include 'libnfs-raw-mount.h' to get the definitions of the
* returned structures.
*
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the mount daemon.
* data is a pointer to an exports pointer:
* exports export = *(exports *)data;
* RPC_STATUS_ERROR : An error occured when trying to contact the mount daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
EXTERN int rpc_mount1_export_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
/*
* NFS v3 FUNCTIONS
*/
struct nfs_fh3;
char *nfsstat3_to_str(int error);
int nfsstat3_to_errno(int error);
/*
* Call NFS3/NULL
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is NULL.
* RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
EXTERN int rpc_nfs3_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
EXTERN int rpc_nfs_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
/*
* Call NFS3/GETATTR
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is GETATTR3res
* RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct GETATTR3args;
EXTERN int rpc_nfs3_getattr_async(struct rpc_context *rpc, rpc_cb cb, struct GETATTR3args *args, void *private_data);
EXTERN int rpc_nfs_getattr_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, void *private_data);
/*
* Call NFS3/PATHCONF
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is PATHCONF3res
* RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct PATHCONF3args;
EXTERN int rpc_nfs3_pathconf_async(struct rpc_context *rpc, rpc_cb cb, struct PATHCONF3args *args, void *private_data);
EXTERN int rpc_nfs_pathconf_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, void *private_data);
/*
* Call NFS3/LOOKUP
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is LOOKUP3res
* RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct LOOKUP3args;
EXTERN int rpc_nfs3_lookup_async(struct rpc_context *rpc, rpc_cb cb, struct LOOKUP3args *args, void *private_data);
EXTERN int rpc_nfs_lookup_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *name, void *private_data);
/*
* Call NFS3/ACCESS
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is ACCESS3res
* RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct ACCESS3args;
EXTERN int rpc_nfs3_access_async(struct rpc_context *rpc, rpc_cb cb, struct ACCESS3args *args, void *private_data);
EXTERN int rpc_nfs_access_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, int access, void *private_data);
/*
* Call NFS3/READ
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is READ3res
* RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct READ3args;
EXTERN int rpc_nfs3_read_async(struct rpc_context *rpc, rpc_cb cb, struct READ3args *args, void *private_data);
EXTERN int rpc_nfs_read_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, uint64_t offset, uint64_t count, void *private_data);
/*
* Call NFS3/WRITE
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is WRITE3res *
* RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct WRITE3args;
EXTERN int rpc_nfs3_write_async(struct rpc_context *rpc, rpc_cb cb, struct WRITE3args *args, void *private_data);
EXTERN int rpc_nfs_write_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *buf, uint64_t offset, uint64_t count, int stable_how, void *private_data);
/*
* Call NFS3/COMMIT
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is COMMIT3res *
* RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct COMMIT3args;
EXTERN int rpc_nfs3_commit_async(struct rpc_context *rpc, rpc_cb cb, struct COMMIT3args *args, void *private_data);
EXTERN int rpc_nfs_commit_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, void *private_data);
/*
* Call NFS3/SETATTR
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is SETATTR3res *
* RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct SETATTR3args;
EXTERN int rpc_nfs3_setattr_async(struct rpc_context *rpc, rpc_cb cb, struct SETATTR3args *args, void *private_data);
EXTERN int rpc_nfs_setattr_async(struct rpc_context *rpc, rpc_cb cb, struct SETATTR3args *args, void *private_data);
/*
* Call NFS3/MKDIR
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is MKDIR3res *
* RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct MKDIR3args;
EXTERN int rpc_nfs3_mkdir_async(struct rpc_context *rpc, rpc_cb cb, struct MKDIR3args *args, void *private_data);
EXTERN int rpc_nfs_mkdir_async(struct rpc_context *rpc, rpc_cb cb, struct MKDIR3args *args, void *private_data);
/*
* Call NFS3/RMDIR
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is RMDIR3res *
* RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct RMDIR3args;
EXTERN int rpc_nfs3_rmdir_async(struct rpc_context *rpc, rpc_cb cb, struct RMDIR3args *args, void *private_data);
EXTERN int rpc_nfs_rmdir_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *dir, void *private_data);
/*
* Call NFS3/CREATE
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is CREATE3res *
* RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct CREATE3args;
EXTERN int rpc_nfs3_create_async(struct rpc_context *rpc, rpc_cb cb, struct CREATE3args *args, void *private_data);
EXTERN int rpc_nfs_create_async(struct rpc_context *rpc, rpc_cb cb, struct CREATE3args *args, void *private_data);
/*
* Call NFS3/MKNOD
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is MKNOD3res *
* RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct MKNOD3args;
EXTERN int rpc_nfs3_mknod_async(struct rpc_context *rpc, rpc_cb cb, struct MKNOD3args *args, void *private_data);
EXTERN int rpc_nfs_mknod_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *file, int mode, int major, int minor, void *private_data);
/*
* Call NFS3/REMOVE
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is REMOVE3res *
* RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct REMOVE3args;
EXTERN int rpc_nfs3_remove_async(struct rpc_context *rpc, rpc_cb cb, struct REMOVE3args *args, void *private_data);
EXTERN int rpc_nfs_remove_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *name, void *private_data);
/*
* Call NFS3/READDIR
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is READDIR3res *
* RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct READDIR3args;
EXTERN int rpc_nfs3_readdir_async(struct rpc_context *rpc, rpc_cb cb, struct READDIR3args *args, void *private_data);
EXTERN int rpc_nfs_readdir_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, uint64_t cookie, char *cookieverf, int count, void *private_data);
/*
* Call NFS3/READDIRPLUS
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is READDIRPLUS3res *
* RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct READDIRPLUS3args;
EXTERN int rpc_nfs3_readdirplus_async(struct rpc_context *rpc, rpc_cb cb, struct READDIRPLUS3args *args, void *private_data);
EXTERN int rpc_nfs_readdirplus_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, uint64_t cookie, char *cookieverf, int count, void *private_data);
/*
* Call NFS3/FSSTAT
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is FSSTAT3res
* RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct FSSTAT3args;
EXTERN int rpc_nfs3_fsstat_async(struct rpc_context *rpc, rpc_cb cb, struct FSSTAT3args *args, void *private_data);
EXTERN int rpc_nfs_fsstat_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, void *private_data);
/*
* Call NFS3/FSINFO
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is FSINFO3res
* RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct FSINFO3args;
EXTERN int rpc_nfs3_fsinfo_async(struct rpc_context *rpc, rpc_cb cb, struct FSINFO3args *args, void *private_data);
EXTERN int rpc_nfs_fsinfo_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, void *private_data);
/*
* Call NFS3/READLINK
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is READLINK3res *
* RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct READLINK3args;
EXTERN int rpc_nfs3_readlink_async(struct rpc_context *rpc, rpc_cb cb, struct READLINK3args *args, void *private_data);
EXTERN int rpc_nfs_readlink_async(struct rpc_context *rpc, rpc_cb cb, struct READLINK3args *args, void *private_data);
/*
* Call NFS3/SYMLINK
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is SYMLINK3res *
* RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct SYMLINK3args;
EXTERN int rpc_nfs3_symlink_async(struct rpc_context *rpc, rpc_cb cb, struct SYMLINK3args *args, void *private_data);
EXTERN int rpc_nfs_symlink_async(struct rpc_context *rpc, rpc_cb cb, struct SYMLINK3args *args, void *private_data);
/*
* Call NFS3/RENAME
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is RENAME3res *
* RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct RENAME3args;
EXTERN int rpc_nfs3_rename_async(struct rpc_context *rpc, rpc_cb cb, struct RENAME3args *args, void *private_data);
EXTERN int rpc_nfs_rename_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *olddir, char *oldname, struct nfs_fh3 *newdir, char *newname, void *private_data);
/*
* Call NFS3/LINK
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is LINK3res *
* RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct LINK3args;
EXTERN int rpc_nfs3_link_async(struct rpc_context *rpc, rpc_cb cb, struct LINK3args *args, void *private_data);
EXTERN int rpc_nfs_link_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *file, struct nfs_fh3 *newdir, char *newname, void *private_data);
/*
* NFS v2 FUNCTIONS
*/
/*
* Call NFS2/NULL
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is NULL.
* RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
EXTERN int rpc_nfs2_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
/*
* Call NFS2/GETATTR
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is GETATTR2res
* RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct GETATTR2args;
EXTERN int rpc_nfs2_getattr_async(struct rpc_context *rpc, rpc_cb cb, struct GETATTR2args *args, void *private_data);
/*
* Call NFS2/SETATTR
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is SETATTR2res *
* RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct SETATTR2args;
EXTERN int rpc_nfs2_setattr_async(struct rpc_context *rpc, rpc_cb cb, struct SETATTR2args *args, void *private_data);
/*
* Call NFS2/LOOKUP
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is LOOKUP2res
* RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct LOOKUP2args;
EXTERN int rpc_nfs2_lookup_async(struct rpc_context *rpc, rpc_cb cb, struct LOOKUP2args *args, void *private_data);
/*
* Call NFS2/READLINK
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is READLINK2res *
* RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct READLINK2args;
EXTERN int rpc_nfs32_readlink_async(struct rpc_context *rpc, rpc_cb cb, struct READLINK2args *args, void *private_data);
/*
* Call NFS2/READ
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is READ2res
* RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct READ2args;
EXTERN int rpc_nfs2_read_async(struct rpc_context *rpc, rpc_cb cb, struct READ2args *args, void *private_data);
/*
* Call NFS2/WRITE
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is WRITE2res *
* RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct WRITE2args;
EXTERN int rpc_nfs2_write_async(struct rpc_context *rpc, rpc_cb cb, struct WRITE2args *args, void *private_data);
/*
* Call NFS2/CREATE
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is CREATE2res *
* RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct CREATE2args;
EXTERN int rpc_nfs2_create_async(struct rpc_context *rpc, rpc_cb cb, struct CREATE2args *args, void *private_data);
/*
* Call NFS2/REMOVE
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is REMOVE2res *
* RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct REMOVE2args;
EXTERN int rpc_nfs2_remove_async(struct rpc_context *rpc, rpc_cb cb, struct REMOVE2args *args, void *private_data);
/*
* Call NFS2/RENAME
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is RENAME2res *
* RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct RENAME2args;
EXTERN int rpc_nfs2_rename_async(struct rpc_context *rpc, rpc_cb cb, struct RENAME2args *args, void *private_data);
/*
* Call NFS2/LINK
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is LINK2res *
* RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct LINK2args;
EXTERN int rpc_nfs2_link_async(struct rpc_context *rpc, rpc_cb cb, struct LINK2args *args, void *private_data);
/*
* Call NFS2/SYMLINK
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is SYMLINK2res *
* RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct SYMLINK2args;
EXTERN int rpc_nfs2_symlink_async(struct rpc_context *rpc, rpc_cb cb, struct SYMLINK2args *args, void *private_data);
/*
* Call NFS2/MKDIR
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is MKDIR2res *
* RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct MKDIR2args;
EXTERN int rpc_nfs2_mkdir_async(struct rpc_context *rpc, rpc_cb cb, struct MKDIR2args *args, void *private_data);
/*
* Call NFS2/RMDIR
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is RMDIR2res *
* RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct RMDIR2args;
EXTERN int rpc_nfs2_rmdir_async(struct rpc_context *rpc, rpc_cb cb, struct RMDIR2args *args, void *private_data);
/*
* Call NFS2/READDIR
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is READDIR2res *
* RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct READDIR2args;
EXTERN int rpc_nfs2_readdir_async(struct rpc_context *rpc, rpc_cb cb, struct READDIR2args *args, void *private_data);
/*
* Call NFS2/STATFS
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is STATFS2res *
* RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct STATFS2args;
EXTERN int rpc_nfs2_statfs_async(struct rpc_context *rpc, rpc_cb cb, struct STATFS2args *args, void *private_data);
/*
* RQUOTA FUNCTIONS
*/
char *rquotastat_to_str(int error);
int rquotastat_to_errno(int error);
/*
* Call RQUOTA1/NULL
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the rquota daemon.
* data is NULL.
* RPC_STATUS_ERROR : An error occured when trying to contact the rquota daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
EXTERN int rpc_rquota1_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
/*
* Call RQUOTA1/GETQUOTA
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the rquota daemon.
* data is a RQUOTA1res structure.
* RPC_STATUS_ERROR : An error occured when trying to contact the rquota daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
EXTERN int rpc_rquota1_getquota_async(struct rpc_context *rpc, rpc_cb cb, char *exportname, int uid, void *private_data);
/*
* Call RQUOTA1/GETACTIVEQUOTA
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the rquota daemon.
* data is a RQUOTA1res structure.
* RPC_STATUS_ERROR : An error occured when trying to contact the rquota daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
EXTERN int rpc_rquota1_getactivequota_async(struct rpc_context *rpc, rpc_cb cb, char *exportname, int uid, void *private_data);
/*
* Call RQUOTA2/NULL
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the rquota daemon.
* data is NULL.
* RPC_STATUS_ERROR : An error occured when trying to contact the rquota daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
int rpc_rquota2_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
/*
* Call RQUOTA2/GETQUOTA
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the rquota daemon.
* data is a RQUOTA1res structure.
* RPC_STATUS_ERROR : An error occured when trying to contact the rquota daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
int rpc_rquota2_getquota_async(struct rpc_context *rpc, rpc_cb cb, char *exportname, int type, int uid, void *private_data);
/*
* Call RQUOTA2/GETACTIVEQUOTA
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the rquota daemon.
* data is a RQUOTA1res structure.
* RPC_STATUS_ERROR : An error occured when trying to contact the rquota daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
int rpc_rquota2_getactivequota_async(struct rpc_context *rpc, rpc_cb cb, char *exportname, int type, int uid, void *private_data);
/*
* NFSACL functions
*/
/*
* Call NFSACL/NULL
* Call the NULL procedure for the NFSACL
*
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the rquota daemon.
* data is NULL
* RPC_STATUS_ERROR : An error occured when trying to contact the rquota daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
EXTERN int rpc_nfsacl_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
/*
* Call NFSACL/GETACL
*
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is a GETACL3res pointer
* RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct GETACL3args;
EXTERN int rpc_nfsacl_getacl_async(struct rpc_context *rpc, rpc_cb cb, struct GETACL3args *args, void *private_data);
/*
* Call NFSACL/SETACL
*
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is a SETACL3res pointer
* RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct SETACL3args;
EXTERN int rpc_nfsacl_setacl_async(struct rpc_context *rpc, rpc_cb cb, struct SETACL3args *args, void *private_data);
/*
* NLM functions
*/
char *nlmstat4_to_str(int stat);
/*
* Call NLM/NULL
* Call the NULL procedure for the NLM protocol
*
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nlm daemon.
* data is NULL
* RPC_STATUS_ERROR : An error occured when trying to contact the nlm daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
EXTERN int rpc_nlm4_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
/*
* Call NLM/TEST
* Call the TEST procedure for the NLM protocol
*
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nlm daemon.
* data is NLM4_TESTres
* RPC_STATUS_ERROR : An error occured when trying to contact the nlm daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct NLM4_TESTargs;
EXTERN int rpc_nlm4_test_async(struct rpc_context *rpc, rpc_cb cb, struct NLM4_TESTargs *args, void *private_data);
/*
* Call NLM/LOCK
* Call the LOCK procedure for the NLM protocol
*
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nlm daemon.
* data is NLM4_LOCKres
* RPC_STATUS_ERROR : An error occured when trying to contact the nlm daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct NLM4_LOCKargs;
EXTERN int rpc_nlm4_lock_async(struct rpc_context *rpc, rpc_cb cb, struct NLM4_LOCKargs *args, void *private_data);
/*
* Call NLM/CANCEL
* Call the CANCEL procedure for the NLM protocol
*
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nlm daemon.
* data is NLM4_CANCres
* RPC_STATUS_ERROR : An error occured when trying to contact the nlm daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct NLM4_CANCargs;
EXTERN int rpc_nlm4_cancel_async(struct rpc_context *rpc, rpc_cb cb, struct NLM4_CANCargs *args, void *private_data);
/*
* Call NLM/UNLOCK
* Call the UNLOCK procedure for the NLM protocol
*
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nlm daemon.
* data is NLM4_UNLOCKres
* RPC_STATUS_ERROR : An error occured when trying to contact the nlm daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct NLM4_UNLOCKargs;
EXTERN int rpc_nlm4_unlock_async(struct rpc_context *rpc, rpc_cb cb, struct NLM4_UNLOCKargs *args, void *private_data);
/*
* NSM functions
*/
char *nsmstat1_to_str(int stat);
/*
* Call NSM/NULL
* Call the NULL procedure for the NSM protocol
*
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nsm daemon.
* data is NULL
* RPC_STATUS_ERROR : An error occured when trying to contact the nsm daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
EXTERN int rpc_nsm1_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
/*
* Call NSM/STAT
* Call the STAT procedure for the NSM protocol
*
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nsm daemon.
* data is NSM1_STATres
* RPC_STATUS_ERROR : An error occured when trying to contact the nsm daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct NSM1_STATargs;
EXTERN int rpc_nsm1_stat_async(struct rpc_context *rpc, rpc_cb cb, struct NSM1_STATargs *args, void *private_data);
/*
* Call NSM/MON
* Call the MON procedure for the NSM protocol
*
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nsm daemon.
* data is NSM1_MONres
* RPC_STATUS_ERROR : An error occured when trying to contact the nsm daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct NSM1_MONargs;
EXTERN int rpc_nsm1_mon_async(struct rpc_context *rpc, rpc_cb cb, struct NSM1_MONargs *args, void *private_data);
/*
* Call NSM/UNMON
* Call the UNMON procedure for the NSM protocol
*
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nsm daemon.
* data is NSM1_UNMONres
* RPC_STATUS_ERROR : An error occured when trying to contact the nsm daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct NSM1_UNMONargs;
EXTERN int rpc_nsm1_unmon_async(struct rpc_context *rpc, rpc_cb cb, struct NSM1_UNMONargs *args, void *private_data);
/*
* Call NSM/UNMONALL
* Call the UNMONALL procedure for the NSM protocol
*
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nsm daemon.
* data is NSM1_UNMONALLres
* RPC_STATUS_ERROR : An error occured when trying to contact the nsm daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct NSM1_UNMONALLargs;
EXTERN int rpc_nsm1_unmonall_async(struct rpc_context *rpc, rpc_cb cb, struct NSM1_UNMONALLargs *args, void *private_data);
/*
* Call NSM/SIMUCRASH
* Call the SIMUCRASH procedure for the NSM protocol
*
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nsm daemon.
* data is NULL
* RPC_STATUS_ERROR : An error occured when trying to contact the nsm daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
EXTERN int rpc_nsm1_simucrash_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
/*
* Call NSM/NOTIFY
* Call the NOTIFY procedure for the NSM protocol
*
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nsm daemon.
* data is NULL
* RPC_STATUS_ERROR : An error occured when trying to contact the nsm daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct NSM1_NOTIFYargs;
EXTERN int rpc_nsm1_notify_async(struct rpc_context *rpc, rpc_cb cb, struct NSM1_NOTIFYargs *args, void *private_data);
#ifdef __cplusplus
}
#endif
#endif
libnfs-libnfs-1.9.8/include/nfsc/libnfs-zdr.h 0000664 0000000 0000000 00000015016 12557450341 0021071 0 ustar 00root root 0000000 0000000 /*
Copyright (C) 2012 by Ronnie Sahlberg
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, see .
*/
/*
* This file contains definitions for the built in ZDR implementation.
* This is a very limited ZDR subset that can only marshal to/from a momory buffer,
* i.e. zdrmem_create() buffers.
* It aims to be compatible with normal rpcgen generated functions.
*/
/************************************************************
* Definitions copied from RFC 5531
* and slightly modified.
************************************************************/
#ifndef _LIBNFS_ZDR_H_
#define _LIBNFS_ZDR_H_
#ifdef WIN32
#ifndef CADDR_T_DEFINED
#define CADDR_T_DEFINED
typedef char *caddr_t;
#endif
#endif
#include
#include
#include
#include
#ifdef __cplusplus
extern "C" {
#endif
#define _RPC_RPC_H 1
#define _RPC_ZDR_H 1
#define _RPC_AUTH_H 1
/* we dont need these */
typedef void CLIENT;
struct svc_req {
int _dummy_;
};
typedef void SVCXPRT;
#define ZDR_INLINE(...) NULL
#define IZDR_PUT_U_LONG(...) assert(0)
#define IZDR_GET_U_LONG(...) (assert(0), 0)
#define IZDR_PUT_LONG(...) assert(0)
#define IZDR_GET_LONG(...) (assert(0), 0)
#define IZDR_PUT_BOOL(...) assert(0)
#define IZDR_GET_BOOL(...) (assert(0), 0)
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
enum zdr_op {
ZDR_ENCODE = 0,
ZDR_DECODE = 1
};
struct zdr_mem {
struct zdr_mem *next;
caddr_t buf;
uint32_t size;
};
struct ZDR {
enum zdr_op x_op;
caddr_t buf;
int size;
int pos;
struct zdr_mem *mem;
};
typedef struct ZDR ZDR;
typedef uint32_t u_int;
typedef uint32_t enum_t;
typedef uint32_t bool_t;
typedef int (*zdrproc_t) (ZDR *, void *,...);
#define AUTH_NONE 0
#define AUTH_NULL 0
#define AUTH_UNIX 1
struct opaque_auth {
uint32_t oa_flavor;
caddr_t oa_base;
uint32_t oa_length;
};
extern struct opaque_auth _null_auth;
struct AUTH {
struct opaque_auth ah_cred;
struct opaque_auth ah_verf;
caddr_t ah_private;
};
#define RPC_MSG_VERSION 2
enum msg_type {
CALL = 0,
REPLY = 1
};
enum reply_stat {
MSG_ACCEPTED=0,
MSG_DENIED=1
};
enum accept_stat {
SUCCESS = 0,
PROG_UNAVAIL = 1,
PROG_MISMATCH = 2,
PROC_UNAVAIL = 3,
GARBAGE_ARGS = 4,
SYSTEM_ERR = 5
};
enum reject_stat {
RPC_MISMATCH = 0,
AUTH_ERROR = 1
};
enum auth_stat {
AUTH_OK=0,
/*
* failed at remote end
*/
AUTH_BADCRED = 1, /* bogus credentials (seal broken) */
AUTH_REJECTEDCRED = 2, /* client should begin new session */
AUTH_BADVERF = 3, /* bogus verifier (seal broken) */
AUTH_REJECTEDVERF = 4, /* verifier expired or was replayed */
AUTH_TOOWEAK = 5, /* rejected due to security reasons */
/*
* failed locally
*/
AUTH_INVALIDRESP = 6, /* bogus response verifier */
AUTH_FAILED = 7 /* some unknown reason */
};
struct call_body {
uint32_t rpcvers;
uint32_t prog;
uint32_t vers;
uint32_t proc;
struct opaque_auth cred;
struct opaque_auth verf;
};
struct accepted_reply {
struct opaque_auth verf;
uint32_t stat;
union {
struct {
caddr_t where;
zdrproc_t proc;
} results;
struct {
uint32_t low;
uint32_t high;
} mismatch_info;
} reply_data;
};
struct rejected_reply {
enum reject_stat stat;
union {
struct {
uint32_t low;
uint32_t high;
} mismatch_info;
enum auth_stat stat;
} reject_data;
};
struct reply_body {
uint32_t stat;
union {
struct accepted_reply areply;
struct rejected_reply rreply;
} reply;
};
struct rpc_msg {
uint32_t xid;
uint32_t direction;
union {
struct call_body cbody;
struct reply_body rbody;
} body;
};
#define zdrmem_create libnfs_zdrmem_create
void libnfs_zdrmem_create(ZDR *zdrs, const caddr_t addr, uint32_t size, enum zdr_op xop);
#define zdr_destroy libnfs_zdr_destroy
void libnfs_zdr_destroy(ZDR *zdrs);
#define zdr_bytes libnfs_zdr_bytes
bool_t libnfs_zdr_bytes(ZDR *zdrs, char **bufp, uint32_t *size, uint32_t maxsize);
#define zdr_u_int libnfs_zdr_u_int
bool_t libnfs_zdr_u_int(ZDR *zdrs, uint32_t *u);
#define zdr_int libnfs_zdr_int
bool_t libnfs_zdr_int(ZDR *zdrs, int32_t *i);
#define zdr_uint64_t libnfs_zdr_uint64_t
bool_t libnfs_zdr_uint64_t(ZDR *zdrs, uint64_t *u);
#define zdr_int64_t libnfs_zdr_int64_t
bool_t libnfs_zdr_int64_t(ZDR *zdrs, int64_t *i);
#define zdr_enum libnfs_zdr_enum
bool_t libnfs_zdr_enum(ZDR *zdrs, enum_t *e);
#define zdr_bool libnfs_zdr_bool
bool_t libnfs_zdr_bool(ZDR *zdrs, bool_t *b);
#define zdr_void libnfs_zdr_void
bool_t libnfs_zdr_void(void);
#define zdr_pointer libnfs_zdr_pointer
bool_t libnfs_zdr_pointer(ZDR *zdrs, char **objp, uint32_t size, zdrproc_t proc);
#define zdr_opaque libnfs_zdr_opaque
bool_t libnfs_zdr_opaque(ZDR *zdrs, char *objp, uint32_t size);
#define zdr_string libnfs_zdr_string
bool_t libnfs_zdr_string(ZDR *zdrs, char **strp, uint32_t maxsize);
#define zdr_array libnfs_zdr_array
bool_t libnfs_zdr_array(ZDR *zdrs, char **arrp, uint32_t *size, uint32_t maxsize, uint32_t elsize, zdrproc_t proc);
#define zdr_setpos libnfs_zdr_setpos
bool_t libnfs_zdr_setpos(ZDR *zdrs, uint32_t pos);
#define zdr_getpos libnfs_zdr_getpos
uint32_t libnfs_zdr_getpos(ZDR *zdrs);
#define zdr_free libnfs_zdr_free
void libnfs_zdr_free(zdrproc_t proc, char *objp);
struct rpc_context;
#define zdr_callmsg libnfs_zdr_callmsg
bool_t libnfs_zdr_callmsg(struct rpc_context *rpc, ZDR *zdrs, struct rpc_msg *msg);
#define zdr_replymsg libnfs_zdr_replymsg
bool_t libnfs_zdr_replymsg(struct rpc_context *rpc, ZDR *zdrs, struct rpc_msg *msg);
#define authnone_create libnfs_authnone_create
struct AUTH *libnfs_authnone_create(void);
#define authunix_create libnfs_authunix_create
struct AUTH *libnfs_authunix_create(const char *host, uint32_t uid, uint32_t gid, uint32_t len, uint32_t *groups);
#define authunix_create_default libnfs_authunix_create_default
struct AUTH *libnfs_authunix_create_default(void);
#define auth_destroy libnfs_auth_destroy
void libnfs_auth_destroy(struct AUTH *auth);
#ifdef __cplusplus
}
#endif
#endif
libnfs-libnfs-1.9.8/include/nfsc/libnfs.h 0000664 0000000 0000000 00000122302 12557450341 0020271 0 ustar 00root root 0000000 0000000 /*
Copyright (C) 2010 by Ronnie Sahlberg
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, see .
*/
/*
* This is the highlevel interface to access NFS resources using a posix-like interface
*/
#ifndef _LIBNFS_H_
#define _LIBNFS_H_
#include
#if defined(ANDROID)
#include
#endif
#if defined(AROS)
#include
#endif
#if defined(__APPLE__) && defined(__MACH__)
#include
#endif
#ifdef __cplusplus
extern "C" {
#endif
#define LIBNFS_FEATURE_READAHEAD
#define LIBNFS_FEATURE_DEBUG
#define NFS_BLKSIZE 4096
struct nfs_context;
struct rpc_context;
struct nfs_url {
char *server;
char *path;
char *file;
};
#if defined(WIN32)
#define EXTERN __declspec( dllexport )
#else
#define EXTERN
#endif
#if defined(WIN32)
struct statvfs {
uint32_t f_bsize;
uint32_t f_frsize;
uint64_t f_blocks;
uint64_t f_bfree;
uint64_t f_bavail;
uint32_t f_files;
uint32_t f_ffree;
uint32_t f_favail;
uint32_t f_fsid;
uint32_t f_flag;
uint32_t f_namemax;
};
struct utimbuf {
time_t actime;
time_t modtime;
};
#define R_OK 4
#define W_OK 2
#define X_OK 1
#endif
/*
* Used for interfacing the async version of the api into an external eventsystem
*/
EXTERN int nfs_get_fd(struct nfs_context *nfs);
EXTERN int nfs_which_events(struct nfs_context *nfs);
EXTERN int nfs_service(struct nfs_context *nfs, int revents);
EXTERN int nfs_queue_length(struct nfs_context *nfs);
/*
* Used if you need different credentials than the default for the current user.
*/
struct AUTH;
EXTERN void nfs_set_auth(struct nfs_context *nfs, struct AUTH *auth);
/*
* When an operation failed, this function can extract a detailed error string.
*/
EXTERN char *nfs_get_error(struct nfs_context *nfs);
/*
* Callback for all ASYNC nfs functions
*/
typedef void (*nfs_cb)(int err, struct nfs_context *nfs, void *data, void *private_data);
/*
* Callback for all ASYNC rpc functions
*/
typedef void (*rpc_cb)(struct rpc_context *rpc, int status, void *data, void *private_data);
/*
* NFS CONTEXT.
*/
/*
* Create an NFS c, the context.
* Function returns
* NULL : Failed to create a context.
* *nfs : A pointer to an nfs context.
*/
EXTERN struct nfs_context *nfs_init_context(void);
/*
* Destroy an nfs context.
*/
EXTERN void nfs_destroy_context(struct nfs_context *nfs);
/*
* URL parsing functions.
* These functions all parse a URL of the form
* nfs://server/path/file?argv=val[&arg=val]*
* and returns a nfs_url.
*
* Apart from parsing the URL the functions will also update
* the nfs context to reflect settings controlled via url arguments.
*
* Current URL arguments are :
* tcp-syncnt= : Number of SYNs to send during the seccion establish
* before failing settin up the tcp connection to the
* server.
* uid= : UID value to use when talking to the server.
* default it 65534 on Windows and getuid() on unixen.
* gid= : GID value to use when talking to the server.
* default it 65534 on Windows and getgid() on unixen.
* readahead= : Enable readahead for files and set the maximum amount
* of readahead to .
*/
/*
* Parse a complete NFS URL including, server, path and
* filename. Fail if any component is missing.
*/
EXTERN struct nfs_url *nfs_parse_url_full(struct nfs_context *nfs, const char *url);
/*
* Parse an NFS URL, but do not split path and file. File
* in the resulting struct remains NULL.
*/
EXTERN struct nfs_url *nfs_parse_url_dir(struct nfs_context *nfs, const char *url);
/*
* Parse an NFS URL, but do not fail if file, path or even server is missing.
* Check elements of the resulting struct for NULL.
*/
EXTERN struct nfs_url *nfs_parse_url_incomplete(struct nfs_context *nfs, const char *url);
/*
* Free the URL struct returned by the nfs_parse_url_* functions.
*/
EXTERN void nfs_destroy_url(struct nfs_url *url);
struct nfsfh;
/*
* Get the maximum supported READ3 size by the server
*/
EXTERN uint64_t nfs_get_readmax(struct nfs_context *nfs);
/*
* Get the maximum supported WRITE3 size by the server
*/
EXTERN uint64_t nfs_get_writemax(struct nfs_context *nfs);
/*
* MODIFY CONNECT PARAMTERS
*/
EXTERN void nfs_set_tcp_syncnt(struct nfs_context *nfs, int v);
EXTERN void nfs_set_uid(struct nfs_context *nfs, int uid);
EXTERN void nfs_set_gid(struct nfs_context *nfs, int gid);
EXTERN void nfs_set_readahead(struct nfs_context *nfs, uint32_t v);
EXTERN void nfs_set_debug(struct nfs_context *nfs, int level);
/*
* MOUNT THE EXPORT
*/
/*
* Async nfs mount.
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* 0 : Success.
* data is NULL
* -errno : An error occured.
* data is the error string.
*/
EXTERN int nfs_mount_async(struct nfs_context *nfs, const char *server, const char *exportname, nfs_cb cb, void *private_data);
/*
* Sync nfs mount.
* Function returns
* 0 : The operation was successfull.
* -errno : The command failed.
*/
EXTERN int nfs_mount(struct nfs_context *nfs, const char *server, const char *exportname);
/*
* STAT()
*/
/*
* Async stat()
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* 0 : Success.
* data is struct stat *
* -errno : An error occured.
* data is the error string.
*/
/* This function is deprecated. Use nfs_stat64_async() instead */
struct stat;
EXTERN int nfs_stat_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
/*
* Sync stat()
* Function returns
* 0 : The operation was successfull.
* -errno : The command failed.
*/
/* This function is deprecated. Use nfs_stat64() instead */
#ifdef WIN32
EXTERN int nfs_stat(struct nfs_context *nfs, const char *path, struct __stat64 *st);
#else
EXTERN int nfs_stat(struct nfs_context *nfs, const char *path, struct stat *st);
#endif
/* nfs_stat64
* 64 bit version if stat. All fields are always 64bit.
* Use these functions instead of nfs_stat[_async](), especially if you
* have weird stat structures.
*/
/*
* STAT()
*/
struct nfs_stat_64 {
uint64_t nfs_dev;
uint64_t nfs_ino;
uint64_t nfs_mode;
uint64_t nfs_nlink;
uint64_t nfs_uid;
uint64_t nfs_gid;
uint64_t nfs_rdev;
uint64_t nfs_size;
uint64_t nfs_blksize;
uint64_t nfs_blocks;
uint64_t nfs_atime;
uint64_t nfs_mtime;
uint64_t nfs_ctime;
uint64_t nfs_atime_nsec;
uint64_t nfs_mtime_nsec;
uint64_t nfs_ctime_nsec;
uint64_t nfs_used;
};
/*
* Async stat()
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* 0 : Success.
* data is struct nfs_stat_64 *
* -errno : An error occured.
* data is the error string.
*/
EXTERN int nfs_stat64_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
/*
* Sync stat()
* Function returns
* 0 : The operation was successfull.
* -errno : The command failed.
*/
EXTERN int nfs_stat64(struct nfs_context *nfs, const char *path, struct nfs_stat_64 *st);
/*
* Async stat()
*
* Like stat except if the destination is a symbolic link, it acts on the
* symbolic link itself.
*
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* 0 : Success.
* data is struct nfs_stat_64 *
* -errno : An error occured.
* data is the error string.
*/
EXTERN int nfs_lstat64_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
/*
* Sync stat()
*
* Like stat except if the destination is a symbolic link, it acts on the
* symbolic link itself.
*
* Function returns
* 0 : The operation was successfull.
* -errno : The command failed.
*/
EXTERN int nfs_lstat64(struct nfs_context *nfs, const char *path, struct nfs_stat_64 *st);
/*
* FSTAT()
*/
/*
* Async fstat(nfsfh *)
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* 0 : Success.
* data is struct stat *
* -errno : An error occured.
* data is the error string.
*/
/* This function is deprecated. Use nfs_fstat64_async() instead */
EXTERN int nfs_fstat_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb, void *private_data);
/*
* Sync fstat(nfsfh *)
* Function returns
* 0 : The operation was successfull.
* -errno : The command failed.
*/
#ifdef WIN32
EXTERN int nfs_fstat(struct nfs_context *nfs, struct nfsfh *nfsfh, struct __stat64 *st);
#else
EXTERN int nfs_fstat(struct nfs_context *nfs, struct nfsfh *nfsfh, struct stat *st);
#endif
/* nfs_fstat64
* 64 bit version of fstat. All fields are always 64bit.
* Use these functions instead of nfs_fstat[_async](), especially if you
* have weird stat structures.
*/
/*
* FSTAT()
*/
/*
* Async fstat(nfsfh *)
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* 0 : Success.
* data is struct stat *
* -errno : An error occured.
* data is the error string.
*/
EXTERN int nfs_fstat64_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb, void *private_data);
/*
* Sync fstat(nfsfh *)
* Function returns
* 0 : The operation was successfull.
* -errno : The command failed.
*/
EXTERN int nfs_fstat64(struct nfs_context *nfs, struct nfsfh *nfsfh, struct nfs_stat_64 *st);
/*
* UMASK() never blocks, so no special aync/async versions are available
*/
/*
* Sync umask()
* Function returns the old mask.
*/
EXTERN uint16_t nfs_umask(struct nfs_context *nfs, uint16_t mask);
/*
* OPEN()
*/
/*
* Async open()
*
* mode is a combination of the flags :
* O_RDOLNY, O_WRONLY, O_RDWR , O_SYNC, O_APPEND, O_TRUNC
*
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* Supported flags are
* O_APPEND
* O_RDONLY
* O_WRONLY
* O_RDWR
* O_SYNC
* O_TRUNC (Only valid with O_RDWR or O_WRONLY. Ignored otherwise.)
*
* When the callback is invoked, status indicates the result:
* 0 : Success.
* data is a struct *nfsfh;
* The nfsfh is close using nfs_close().
* -errno : An error occured.
* data is the error string.
*/
EXTERN int nfs_open_async(struct nfs_context *nfs, const char *path, int flags, nfs_cb cb, void *private_data);
/*
* Sync open()
* Function returns
* 0 : The operation was successfull. *nfsfh is filled in.
* -errno : The command failed.
*/
EXTERN int nfs_open(struct nfs_context *nfs, const char *path, int flags, struct nfsfh **nfsfh);
/*
* CLOSE
*/
/*
* Async close(nfsfh)
*
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* 0 : Success.
* data is NULL.
* -errno : An error occured.
* data is the error string.
*/
EXTERN int nfs_close_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb, void *private_data);
/*
* Sync close(nfsfh)
* Function returns
* 0 : The operation was successfull.
* -errno : The command failed.
*/
EXTERN int nfs_close(struct nfs_context *nfs, struct nfsfh *nfsfh);
/*
* PREAD()
*/
/*
* Async pread()
*
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* >=0 : Success.
* status is numer of bytes read.
* data is a pointer to the returned data.
* -errno : An error occured.
* data is the error string.
*/
EXTERN int nfs_pread_async(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t offset, uint64_t count, nfs_cb cb, void *private_data);
/*
* Sync pread()
* Function returns
* >=0 : numer of bytes read.
* -errno : An error occured.
*/
EXTERN int nfs_pread(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t offset, uint64_t count, char *buf);
/*
* READ()
*/
/*
* Async read()
*
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* >=0 : Success.
* status is numer of bytes read.
* data is a pointer to the returned data.
* -errno : An error occured.
* data is the error string.
*/
EXTERN int nfs_read_async(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t count, nfs_cb cb, void *private_data);
/*
* Sync read()
* Function returns
* >=0 : numer of bytes read.
* -errno : An error occured.
*/
EXTERN int nfs_read(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t count, char *buf);
/*
* PWRITE()
*/
/*
* Async pwrite()
*
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* >=0 : Success.
* status is numer of bytes written.
* -errno : An error occured.
* data is the error string.
*/
EXTERN int nfs_pwrite_async(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t offset, uint64_t count, char *buf, nfs_cb cb, void *private_data);
/*
* Sync pwrite()
* Function returns
* >=0 : numer of bytes written.
* -errno : An error occured.
*/
EXTERN int nfs_pwrite(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t offset, uint64_t count, char *buf);
/*
* WRITE()
*/
/*
* Async write()
*
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* >=0 : Success.
* status is numer of bytes written.
* -errno : An error occured.
* data is the error string.
*/
EXTERN int nfs_write_async(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t count, char *buf, nfs_cb cb, void *private_data);
/*
* Sync write()
* Function returns
* >=0 : numer of bytes written.
* -errno : An error occured.
*/
EXTERN int nfs_write(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t count, char *buf);
/*
* LSEEK()
*/
/*
* Async lseek()
*
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* >=0 : Success.
* data is uint64_t * for the current position.
* -errno : An error occured.
* data is the error string.
*/
EXTERN int nfs_lseek_async(struct nfs_context *nfs, struct nfsfh *nfsfh, int64_t offset, int whence, nfs_cb cb, void *private_data);
/*
* Sync lseek()
* Function returns
* >=0 : numer of bytes read.
* -errno : An error occured.
*/
EXTERN int nfs_lseek(struct nfs_context *nfs, struct nfsfh *nfsfh, int64_t offset, int whence, uint64_t *current_offset);
/*
* FSYNC()
*/
/*
* Async fsync()
*
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* 0 : Success.
* -errno : An error occured.
* data is the error string.
*/
EXTERN int nfs_fsync_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb, void *private_data);
/*
* Sync fsync()
* Function returns
* 0 : Success
* -errno : An error occured.
*/
EXTERN int nfs_fsync(struct nfs_context *nfs, struct nfsfh *nfsfh);
/*
* TRUNCATE()
*/
/*
* Async truncate()
*
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* 0 : Success.
* -errno : An error occured.
* data is the error string.
*/
EXTERN int nfs_truncate_async(struct nfs_context *nfs, const char *path, uint64_t length, nfs_cb cb, void *private_data);
/*
* Sync truncate()
* Function returns
* 0 : Success
* -errno : An error occured.
*/
EXTERN int nfs_truncate(struct nfs_context *nfs, const char *path, uint64_t length);
/*
* FTRUNCATE()
*/
/*
* Async ftruncate()
*
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* 0 : Success.
* -errno : An error occured.
* data is the error string.
*/
EXTERN int nfs_ftruncate_async(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t length, nfs_cb cb, void *private_data);
/*
* Sync ftruncate()
* Function returns
* 0 : Success
* -errno : An error occured.
*/
EXTERN int nfs_ftruncate(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t length);
/*
* MKDIR()
*/
/*
* Async mkdir()
*
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* 0 : Success.
* -errno : An error occured.
* data is the error string.
*/
EXTERN int nfs_mkdir_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
/*
* Sync mkdir()
* Function returns
* 0 : Success
* -errno : An error occured.
*/
EXTERN int nfs_mkdir(struct nfs_context *nfs, const char *path);
/*
* RMDIR()
*/
/*
* Async rmdir()
*
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* 0 : Success.
* -errno : An error occured.
* data is the error string.
*/
EXTERN int nfs_rmdir_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
/*
* Sync rmdir()
* Function returns
* 0 : Success
* -errno : An error occured.
*/
EXTERN int nfs_rmdir(struct nfs_context *nfs, const char *path);
/*
* CREAT()
*/
/*
* Async creat()
*
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* 0 : Success.
* data is a struct *nfsfh;
* -errno : An error occured.
* data is the error string.
*/
EXTERN int nfs_creat_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb cb, void *private_data);
/*
* Sync creat()
* Function returns
* 0 : Success
* -errno : An error occured.
*/
EXTERN int nfs_creat(struct nfs_context *nfs, const char *path, int mode, struct nfsfh **nfsfh);
/*
* Async create()
*
* Same as nfs_creat_async but allows passing flags:
* O_APPEND
* O_SYNC
* O_EXCL
* O_TRUNC
*
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* 0 : Success.
* data is a struct *nfsfh;
* -errno : An error occured.
* data is the error string.
*/
EXTERN int nfs_create_async(struct nfs_context *nfs, const char *path, int flags, int mode, nfs_cb cb, void *private_data);
/*
* Sync create()
* Function returns
* 0 : Success
* -errno : An error occured.
*/
EXTERN int nfs_create(struct nfs_context *nfs, const char *path, int flags, int mode, struct nfsfh **nfsfh);
/*
* MKNOD()
*/
/*
* Async mknod()
*
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* 0 : Success.
* -errno : An error occured.
* data is the error string.
*/
EXTERN int nfs_mknod_async(struct nfs_context *nfs, const char *path, int mode, int dev, nfs_cb cb, void *private_data);
/*
* Sync mknod()
* Function returns
* 0 : Success
* -errno : An error occured.
*/
EXTERN int nfs_mknod(struct nfs_context *nfs, const char *path, int mode, int dev);
/*
* UNLINK()
*/
/*
* Async unlink()
*
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* 0 : Success.
* data is NULL
* -errno : An error occured.
* data is the error string.
*/
EXTERN int nfs_unlink_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
/*
* Sync unlink()
* Function returns
* 0 : Success
* -errno : An error occured.
*/
EXTERN int nfs_unlink(struct nfs_context *nfs, const char *path);
/*
* OPENDIR()
*/
struct nfsdir;
/*
* Async opendir()
*
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* When struct nfsdir * is returned, this resource is closed/freed by calling nfs_closedir()
*
* When the callback is invoked, status indicates the result:
* 0 : Success.
* data is struct nfsdir *
* -errno : An error occured.
* data is the error string.
*/
EXTERN int nfs_opendir_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
/*
* Sync opendir()
* Function returns
* 0 : Success
* -errno : An error occured.
*/
EXTERN int nfs_opendir(struct nfs_context *nfs, const char *path, struct nfsdir **nfsdir);
/*
* READDIR()
*/
struct nfsdirent {
struct nfsdirent *next;
char *name;
uint64_t inode;
/* Some extra fields we get for free through the READDIRPLUS3 call.
You need libnfs-raw-nfs.h for type/mode constants */
uint32_t type; /* NF3REG, NF3DIR, NF3BLK, ... */
uint32_t mode;
uint64_t size;
struct timeval atime;
struct timeval mtime;
struct timeval ctime;
uint32_t uid;
uint32_t gid;
uint32_t nlink;
uint64_t dev;
uint64_t rdev;
uint64_t blksize;
uint64_t blocks;
uint64_t used;
uint32_t atime_nsec;
uint32_t mtime_nsec;
uint32_t ctime_nsec;
};
/*
* nfs_readdir() never blocks, so no special sync/async versions are available
*/
EXTERN struct nfsdirent *nfs_readdir(struct nfs_context *nfs, struct nfsdir *nfsdir);
/*
* CLOSEDIR()
*/
/*
* nfs_closedir() never blocks, so no special sync/async versions are available
*/
EXTERN void nfs_closedir(struct nfs_context *nfs, struct nfsdir *nfsdir);
/*
* CHDIR()
*/
/*
* Async chdir()
*
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* 0 : Success.
* data is NULL;
* -errno : An error occured.
* data is the error string.
*/
EXTERN int nfs_chdir_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
/*
* Sync chdir()
* Function returns
* 0 : The operation was successfull.
* -errno : The command failed.
*/
EXTERN int nfs_chdir(struct nfs_context *nfs, const char *path);
/*
* GETCWD()
*/
/*
* nfs_getcwd() never blocks, so no special sync/async versions are available
*/
/*
* Sync getcwd()
* This function returns a pointer to the current working directory.
* This pointer is only stable until the next [f]chdir or when the
* context is destroyed.
*
* Function returns
* 0 : The operation was successfull and *cwd is filled in.
* -errno : The command failed.
*/
EXTERN void nfs_getcwd(struct nfs_context *nfs, const char **cwd);
/*
* STATVFS()
*/
/*
* Async statvfs()
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* 0 : Success.
* data is struct statvfs *
* -errno : An error occured.
* data is the error string.
*/
struct statvfs;
EXTERN int nfs_statvfs_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
/*
* Sync statvfs()
* Function returns
* 0 : The operation was successfull.
* -errno : The command failed.
*/
EXTERN int nfs_statvfs(struct nfs_context *nfs, const char *path, struct statvfs *svfs);
/*
* READLINK()
*/
/*
* Async readlink()
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* 0 : Success.
* data is a char *
* data is only valid during the callback and is automatically freed when the callback returns.
* -errno : An error occured.
* data is the error string.
*/
struct statvfs;
EXTERN int nfs_readlink_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
/*
* Sync readlink()
* Function returns
* 0 : The operation was successfull.
* -errno : The command failed.
*/
EXTERN int nfs_readlink(struct nfs_context *nfs, const char *path, char *buf, int bufsize);
/*
* CHMOD()
*/
/*
* Async chmod()
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* 0 : Success.
* data is NULL
* -errno : An error occured.
* data is the error string.
*/
EXTERN int nfs_chmod_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb cb, void *private_data);
/*
* Sync chmod()
* Function returns
* 0 : The operation was successfull.
* -errno : The command failed.
*/
EXTERN int nfs_chmod(struct nfs_context *nfs, const char *path, int mode);
/*
* Async chmod()
*
* Like chmod except if the destination is a symbolic link, it acts on the
* symbolic link itself.
*
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* 0 : Success.
* data is NULL
* -errno : An error occured.
* data is the error string.
*/
EXTERN int nfs_lchmod_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb cb, void *private_data);
/*
* Sync chmod()
*
* Like chmod except if the destination is a symbolic link, it acts on the
* symbolic link itself.
*
* Function returns
* 0 : The operation was successfull.
* -errno : The command failed.
*/
EXTERN int nfs_lchmod(struct nfs_context *nfs, const char *path, int mode);
/*
* FCHMOD()
*/
/*
* Async fchmod()
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* 0 : Success.
* data is NULL
* -errno : An error occured.
* data is the error string.
*/
EXTERN int nfs_fchmod_async(struct nfs_context *nfs, struct nfsfh *nfsfh, int mode, nfs_cb cb, void *private_data);
/*
* Sync fchmod()
* Function returns
* 0 : The operation was successfull.
* -errno : The command failed.
*/
EXTERN int nfs_fchmod(struct nfs_context *nfs, struct nfsfh *nfsfh, int mode);
/*
* CHOWN()
*/
/*
* Async chown()
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* 0 : Success.
* data is NULL
* -errno : An error occured.
* data is the error string.
*/
EXTERN int nfs_chown_async(struct nfs_context *nfs, const char *path, int uid, int gid, nfs_cb cb, void *private_data);
/*
* Sync chown()
* Function returns
* 0 : The operation was successfull.
* -errno : The command failed.
*/
EXTERN int nfs_chown(struct nfs_context *nfs, const char *path, int uid, int gid);
/*
* Async chown()
*
* Like chown except if the destination is a symbolic link, it acts on the
* symbolic link itself.
*
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* 0 : Success.
* data is NULL
* -errno : An error occured.
* data is the error string.
*/
EXTERN int nfs_lchown_async(struct nfs_context *nfs, const char *path, int uid, int gid, nfs_cb cb, void *private_data);
/*
* Sync chown()
*
* Like chown except if the destination is a symbolic link, it acts on the
* symbolic link itself.
*
* Function returns
* 0 : The operation was successfull.
* -errno : The command failed.
*/
EXTERN int nfs_lchown(struct nfs_context *nfs, const char *path, int uid, int gid);
/*
* FCHOWN()
*/
/*
* Async fchown()
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* 0 : Success.
* data is NULL
* -errno : An error occured.
* data is the error string.
*/
EXTERN int nfs_fchown_async(struct nfs_context *nfs, struct nfsfh *nfsfh, int uid, int gid, nfs_cb cb, void *private_data);
/*
* Sync fchown()
* Function returns
* 0 : The operation was successfull.
* -errno : The command failed.
*/
EXTERN int nfs_fchown(struct nfs_context *nfs, struct nfsfh *nfsfh, int uid, int gid);
/*
* UTIMES()
*/
/*
* Async utimes()
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* 0 : Success.
* data is NULL
* -errno : An error occured.
* data is the error string.
*/
EXTERN int nfs_utimes_async(struct nfs_context *nfs, const char *path, struct timeval *times, nfs_cb cb, void *private_data);
/*
* Sync utimes()
* Function returns
* 0 : The operation was successfull.
* -errno : The command failed.
*/
EXTERN int nfs_utimes(struct nfs_context *nfs, const char *path, struct timeval *times);
/*
* Async utimes()
*
* Like utimes except if the destination is a symbolic link, it acts on the
* symbolic link itself.
*
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* 0 : Success.
* data is NULL
* -errno : An error occured.
* data is the error string.
*/
EXTERN int nfs_lutimes_async(struct nfs_context *nfs, const char *path, struct timeval *times, nfs_cb cb, void *private_data);
/*
* Sync utimes()
*
* Like utimes except if the destination is a symbolic link, it acts on the
* symbolic link itself.
*
* Function returns
* 0 : The operation was successfull.
* -errno : The command failed.
*/
EXTERN int nfs_lutimes(struct nfs_context *nfs, const char *path, struct timeval *times);
/*
* UTIME()
*/
/*
* Async utime()
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* 0 : Success.
* data is NULL
* -errno : An error occured.
* data is the error string.
*/
struct utimbuf;
EXTERN int nfs_utime_async(struct nfs_context *nfs, const char *path, struct utimbuf *times, nfs_cb cb, void *private_data);
/*
* Sync utime()
* Function returns
* 0 : The operation was successfull.
* -errno : The command failed.
*/
EXTERN int nfs_utime(struct nfs_context *nfs, const char *path, struct utimbuf *times);
/*
* ACCESS()
*/
/*
* Async access()
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* 0 : Success.
* data is NULL
* -errno : An error occured.
* data is the error string.
*/
EXTERN int nfs_access_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb cb, void *private_data);
/*
* Sync access()
* Function returns
* 0 : The operation was successfull.
* -errno : The command failed.
*/
EXTERN int nfs_access(struct nfs_context *nfs, const char *path, int mode);
/*
* ACCESS2()
*/
/*
* Async access2()
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* >= 0 : A mask of R_OK, W_OK and X_OK indicating which permissions are
* available.
* data is NULL
* -errno : An error occured.
* data is the error string.
*/
EXTERN int nfs_access2_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
/*
* Sync access()
* Function returns
* >= 0 : A mask of R_OK, W_OK and X_OK indicating which permissions are
* available.
* -errno : The command failed.
*/
EXTERN int nfs_access2(struct nfs_context *nfs, const char *path);
/*
* SYMLINK()
*/
/*
* Async symlink()
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* 0 : Success.
* data is NULL
* -errno : An error occured.
* data is the error string.
*/
EXTERN int nfs_symlink_async(struct nfs_context *nfs, const char *oldpath, const char *newpath, nfs_cb cb, void *private_data);
/*
* Sync symlink()
* Function returns
* 0 : The operation was successfull.
* -errno : The command failed.
*/
EXTERN int nfs_symlink(struct nfs_context *nfs, const char *oldpath, const char *newpath);
/*
* RENAME()
*/
/*
* Async rename(, )
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* 0 : Success.
* data is NULL
* -errno : An error occured.
* data is the error string.
*/
EXTERN int nfs_rename_async(struct nfs_context *nfs, const char *oldpath, const char *newpath, nfs_cb cb, void *private_data);
/*
* Sync rename(, )
* Function returns
* 0 : The operation was successfull.
* -errno : The command failed.
*/
EXTERN int nfs_rename(struct nfs_context *nfs, const char *oldpath, const char *newpath);
/*
* LINK()
*/
/*
* Async link(, )
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* 0 : Success.
* data is NULL
* -errno : An error occured.
* data is the error string.
*/
EXTERN int nfs_link_async(struct nfs_context *nfs, const char *oldpath, const char *newpath, nfs_cb cb, void *private_data);
/*
* Sync link(, )
* Function returns
* 0 : The operation was successfull.
* -errno : The command failed.
*/
EXTERN int nfs_link(struct nfs_context *nfs, const char *oldpath, const char *newpath);
/*
* GETEXPORTS()
*/
/*
* Async getexports()
* NOTE: You must include 'libnfs-raw-mount.h' to get the definitions of the
* returned structures.
*
* This function will return the list of exports from an NFS server.
*
* Function returns
* 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the operation. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* 0 : Success.
* data is a pointer to an exports pointer:
* exports export = *(exports *)data;
* -errno : An error occured.
* data is the error string.
*/
EXTERN int mount_getexports_async(struct rpc_context *rpc, const char *server, rpc_cb cb, void *private_data);
/*
* Sync getexports()
* Function returns
* NULL : something failed
* exports export : a linked list of exported directories
*
* returned data must be freed by calling mount_free_export_list(exportnode);
*/
EXTERN struct exportnode *mount_getexports(const char *server);
EXTERN void mount_free_export_list(struct exportnode *exports);
struct nfs_server_list {
struct nfs_server_list *next;
char *addr;
};
/*
* Sync find_local_servers()
* This function will probe all local networks for NFS server. This function will
* block for one second while awaiting for all nfs servers to respond.
*
* Function returns
* NULL : something failed
*
* struct nfs_server_list : a linked list of all discovered servers
*
* returned data must be freed by nfs_free_srvr_list(srv);
*/
struct nfs_server_list *nfs_find_local_servers(void);
void free_nfs_srvr_list(struct nfs_server_list *srv);
#ifdef __cplusplus
}
#endif
#endif /* !_LIBNFS_H_ */
libnfs-libnfs-1.9.8/include/slist.h 0000664 0000000 0000000 00000003202 12557450341 0017216 0 ustar 00root root 0000000 0000000 /*
Copyright (C) 2010 by Ronnie Sahlberg
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, see .
*/
#ifndef _LIBNFS_SLIST_H_
#define _LIBNFS_SLIST_H_
#define LIBNFS_LIST_ADD(list, item) \
do { \
(item)->next = (*list); \
(*list) = (item); \
} while (0);
#define LIBNFS_LIST_ADD_END(list, item) \
if ((*list) == NULL) { \
LIBNFS_LIST_ADD((list), (item)); \
} else { \
void *head = (*list); \
while ((*list)->next) \
(*list) = (*list)->next; \
(*list)->next = (item); \
(item)->next = NULL; \
(*list) = head; \
}
#define LIBNFS_LIST_REMOVE(list, item) \
if ((*list) == (item)) { \
(*list) = (item)->next; \
} else { \
void *head = (*list); \
while ((*list)->next && (*list)->next != (item)) \
(*list) = (*list)->next; \
if ((*list)->next != NULL) { \
(*list)->next = (*list)->next->next; \
} \
(*list) = head; \
}
#endif /* !_LIBNFS_SLIST_H_ */
libnfs-libnfs-1.9.8/lib/ 0000775 0000000 0000000 00000000000 12557450341 0015035 5 ustar 00root root 0000000 0000000 libnfs-libnfs-1.9.8/lib/Makefile.am 0000664 0000000 0000000 00000001362 12557450341 0017073 0 ustar 00root root 0000000 0000000 AM_CFLAGS=$(WARN_CFLAGS)
lib_LTLIBRARIES = libnfs.la
libnfs_la_CPPFLAGS = -I$(abs_top_srcdir)/include \
-I$(abs_top_srcdir)/include/nfsc \
-I$(abs_top_srcdir)/mount \
-I$(abs_top_srcdir)/nfs \
-I$(abs_top_srcdir)/nlm \
-I$(abs_top_srcdir)/nsm \
-I$(abs_top_srcdir)/portmap \
-I$(abs_top_srcdir)/rquota \
"-D_U_=__attribute__((unused))"
libnfs_la_SOURCES = \
init.c \
libnfs.c \
libnfs-sync.c \
libnfs-zdr.c \
pdu.c \
socket.c
SOCURRENT=9
SOREVISION=0
SOAGE=1
libnfs_la_LDFLAGS = -version-info $(SOCURRENT):$(SOREVISION):$(SOAGE)
libnfs_la_LIBADD = \
../mount/libmount.la \
../nfs/libnfs.la \
../nlm/libnlm.la \
../nsm/libnsm.la \
../portmap/libportmap.la \
../rquota/librquota.la
libnfs-libnfs-1.9.8/lib/init.c 0000664 0000000 0000000 00000014373 12557450341 0016154 0 ustar 00root root 0000000 0000000 /*
Copyright (C) 2010 by Ronnie Sahlberg
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, see .
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef AROS
#include "aros_compat.h"
#endif
#ifdef WIN32
#include "win32_compat.h"
#endif
#define _GNU_SOURCE
#ifdef HAVE_UNISTD_H
#include
#endif
#ifdef HAVE_STRINGS_H
#include
#endif
#include
#include
#include
#include
#include
#include
#include "slist.h"
#include "libnfs-zdr.h"
#include "libnfs.h"
#include "libnfs-raw.h"
#include "libnfs-private.h"
struct rpc_context *rpc_init_context(void)
{
struct rpc_context *rpc;
static uint32_t salt = 0;
unsigned int i;
rpc = malloc(sizeof(struct rpc_context));
if (rpc == NULL) {
return NULL;
}
memset(rpc, 0, sizeof(struct rpc_context));
rpc->magic = RPC_CONTEXT_MAGIC;
/* Allow NFS_MAX_XFER_SIZE of data (for writes) and some */
rpc->encodebuflen = NFS_MAX_XFER_SIZE + 4096;
rpc->encodebuf = malloc(rpc->encodebuflen);
if (rpc->encodebuf == NULL) {
free(rpc);
return NULL;
}
rpc->inbuflen = 2 * (NFS_MAX_XFER_SIZE + 4096);
rpc->inbuf = malloc(rpc->inbuflen);
if (rpc->inbuf == NULL) {
free(rpc);
return NULL;
}
rpc->auth = authunix_create_default();
if (rpc->auth == NULL) {
free(rpc->encodebuf);
free(rpc);
return NULL;
}
rpc->xid = salt + time(NULL) + (getpid() << 16);
salt += 0x01000000;
rpc->fd = -1;
rpc->tcp_syncnt = RPC_PARAM_UNDEFINED;
#if defined(WIN32) || defined(ANDROID)
rpc->uid = 65534;
rpc->gid = 65534;
#else
rpc->uid = getuid();
rpc->gid = getgid();
#endif
rpc_reset_queue(&rpc->outqueue);
for (i = 0; i < HASHES; i++)
rpc_reset_queue(&rpc->waitpdu[i]);
return rpc;
}
void rpc_set_readahead(struct rpc_context *rpc, uint32_t v)
{
assert(rpc->magic == RPC_CONTEXT_MAGIC);
rpc->readahead = v;
}
void rpc_set_debug(struct rpc_context *rpc, int level)
{
assert(rpc->magic == RPC_CONTEXT_MAGIC);
rpc->debug = level;
}
struct rpc_context *rpc_init_udp_context(void)
{
struct rpc_context *rpc;
rpc = rpc_init_context();
if (rpc != NULL) {
rpc->is_udp = 1;
}
return rpc;
}
void rpc_set_auth(struct rpc_context *rpc, struct AUTH *auth)
{
assert(rpc->magic == RPC_CONTEXT_MAGIC);
if (rpc->auth != NULL) {
auth_destroy(rpc->auth);
}
rpc->auth = auth;
}
static void rpc_set_uid_gid(struct rpc_context *rpc, int uid, int gid) {
if (uid != rpc->uid || gid != rpc->gid) {
struct AUTH *auth = libnfs_authunix_create("libnfs", uid, gid, 0, NULL);
if (auth != NULL) {
rpc_set_auth(rpc, auth);
rpc->uid = uid;
rpc->gid = gid;
}
}
}
void rpc_set_uid(struct rpc_context *rpc, int uid) {
rpc_set_uid_gid(rpc, uid, rpc->gid);
}
void rpc_set_gid(struct rpc_context *rpc, int gid) {
rpc_set_uid_gid(rpc, rpc->uid, gid);
}
void rpc_set_error(struct rpc_context *rpc, const char *error_string, ...)
{
va_list ap;
char *old_error_string = rpc->error_string;
assert(rpc->magic == RPC_CONTEXT_MAGIC);
va_start(ap, error_string);
rpc->error_string = malloc(1024);
vsnprintf(rpc->error_string, 1024, error_string, ap);
va_end(ap);
fprintf(stderr, "libnfs error: %s\n", rpc->error_string);
if (old_error_string != NULL) {
free(old_error_string);
}
}
char *rpc_get_error(struct rpc_context *rpc)
{
assert(rpc->magic == RPC_CONTEXT_MAGIC);
return rpc->error_string;
}
void rpc_error_all_pdus(struct rpc_context *rpc, const char *error)
{
struct rpc_pdu *pdu;
unsigned int i;
assert(rpc->magic == RPC_CONTEXT_MAGIC);
while ((pdu = rpc->outqueue.head) != NULL) {
pdu->cb(rpc, RPC_STATUS_ERROR, (void *)error, pdu->private_data);
rpc->outqueue.head = pdu->next;
rpc_free_pdu(rpc, pdu);
}
rpc->outqueue.tail = NULL;
for (i = 0; i < HASHES; i++) {
struct rpc_queue *q = &rpc->waitpdu[i];
while((pdu = q->head) != NULL) {
pdu->cb(rpc, RPC_STATUS_ERROR, (void *)error,
pdu->private_data);
q->head = pdu->next;
rpc_free_pdu(rpc, pdu);
}
q->tail = NULL;
}
}
static void rpc_free_fragment(struct rpc_fragment *fragment)
{
if (fragment->data != NULL) {
free(fragment->data);
}
free(fragment);
}
void rpc_free_all_fragments(struct rpc_context *rpc)
{
assert(rpc->magic == RPC_CONTEXT_MAGIC);
while (rpc->fragments != NULL) {
struct rpc_fragment *fragment = rpc->fragments;
rpc->fragments = fragment->next;
rpc_free_fragment(fragment);
}
}
int rpc_add_fragment(struct rpc_context *rpc, char *data, uint64_t size)
{
struct rpc_fragment *fragment;
assert(rpc->magic == RPC_CONTEXT_MAGIC);
fragment = malloc(sizeof(struct rpc_fragment));
if (fragment == NULL) {
return -1;
}
fragment->size = size;
fragment->data = malloc(fragment->size);
if(fragment->data == NULL) {
free(fragment);
return -1;
}
memcpy(fragment->data, data, fragment->size);
LIBNFS_LIST_ADD_END(&rpc->fragments, fragment);
return 0;
}
void rpc_destroy_context(struct rpc_context *rpc)
{
struct rpc_pdu *pdu;
unsigned int i;
assert(rpc->magic == RPC_CONTEXT_MAGIC);
while((pdu = rpc->outqueue.head) != NULL) {
pdu->cb(rpc, RPC_STATUS_CANCEL, NULL, pdu->private_data);
LIBNFS_LIST_REMOVE(&rpc->outqueue.head, pdu);
rpc_free_pdu(rpc, pdu);
}
for (i = 0; i < HASHES; i++) {
struct rpc_queue *q = &rpc->waitpdu[i];
while((pdu = q->head) != NULL) {
pdu->cb(rpc, RPC_STATUS_CANCEL, NULL, pdu->private_data);
LIBNFS_LIST_REMOVE(&q->head, pdu);
rpc_free_pdu(rpc, pdu);
}
}
rpc_free_all_fragments(rpc);
auth_destroy(rpc->auth);
rpc->auth =NULL;
if (rpc->fd != -1) {
close(rpc->fd);
}
free(rpc->encodebuf);
free(rpc->inbuf);
free(rpc->error_string);
free(rpc->udp_dest);
rpc->magic = 0;
free(rpc);
}
libnfs-libnfs-1.9.8/lib/libnfs-sync.c 0000664 0000000 0000000 00000107424 12557450341 0017440 0 ustar 00root root 0000000 0000000 /*
Copyright (C) 2010 by Ronnie Sahlberg
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, see .
*/
/*
* High level api to nfs filesystems
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef AROS
#include "aros_compat.h"
#endif
#ifdef WIN32
#include "win32_compat.h"
#endif
#ifdef HAVE_SYS_SOCKET_H
#include
#endif
#ifdef HAVE_NET_IF_H
#include
#endif
#ifdef ANDROID
#define statvfs statfs
#endif
#ifdef HAVE_SYS_VFS_H
#include
#endif
#ifdef HAVE_SYS_STATVFS_H
#include
#endif
#ifdef HAVE_SYS_IOCTL_H
#include
#endif
#ifdef HAVE_POLL_H
#include
#endif
#ifdef HAVE_NETDB_H
#include
#endif
#ifdef HAVE_UNISTD_H
#include
#endif
#ifdef HAVE_NETINET_IN_H
#include
#endif
#ifdef HAVE_STRINGS_H
#include
#endif
#include
#include
#include
#include
#include
#include
#include
#include
#ifdef HAVE_SYS_SOCKIO_H
#include
#endif
#ifdef HAVE_SYS_TIME_H
#include
#endif
#include "libnfs-zdr.h"
#include "libnfs.h"
#include "libnfs-raw.h"
#include "libnfs-raw-mount.h"
#include "libnfs-raw-nfs.h"
#include "libnfs-private.h"
struct sync_cb_data {
int is_finished;
int status;
uint64_t offset;
void *return_data;
int return_int;
const char *call;
};
static void wait_for_reply(struct rpc_context *rpc, struct sync_cb_data *cb_data)
{
struct pollfd pfd;
assert(rpc->magic == RPC_CONTEXT_MAGIC);
while (!cb_data->is_finished) {
pfd.fd = rpc_get_fd(rpc);
pfd.events = rpc_which_events(rpc);
if (poll(&pfd, 1, -1) < 0) {
rpc_set_error(rpc, "Poll failed");
cb_data->status = -EIO;
break;
}
if (rpc_service(rpc, pfd.revents) < 0) {
rpc_set_error(rpc, "rpc_service failed");
cb_data->status = -EIO;
break;
}
if (rpc_get_fd(rpc) == -1) {
rpc_set_error(rpc, "Socket closed\n");
break;
}
}
}
static void wait_for_nfs_reply(struct nfs_context *nfs, struct sync_cb_data *cb_data)
{
struct pollfd pfd;
while (!cb_data->is_finished) {
pfd.fd = nfs_get_fd(nfs);
pfd.events = nfs_which_events(nfs);
if (poll(&pfd, 1, -1) < 0) {
nfs_set_error(nfs, "Poll failed");
cb_data->status = -EIO;
break;
}
if (nfs_service(nfs, pfd.revents) < 0) {
nfs_set_error(nfs, "nfs_service failed");
cb_data->status = -EIO;
break;
}
}
}
/*
* connect to the server and mount the export
*/
static void mount_cb(int status, struct nfs_context *nfs, void *data, void *private_data)
{
struct sync_cb_data *cb_data = private_data;
cb_data->is_finished = 1;
cb_data->status = status;
if (status < 0) {
nfs_set_error(nfs, "mount/mnt call failed with \"%s\"", (char *)data);
return;
}
}
int nfs_mount(struct nfs_context *nfs, const char *server, const char *export)
{
struct sync_cb_data cb_data;
struct rpc_context *rpc = nfs_get_rpc_context(nfs);
assert(rpc->magic == RPC_CONTEXT_MAGIC);
cb_data.is_finished = 0;
if (nfs_mount_async(nfs, server, export, mount_cb, &cb_data) != 0) {
nfs_set_error(nfs, "nfs_mount_async failed");
return -1;
}
wait_for_nfs_reply(nfs, &cb_data);
/* Dont want any more callbacks even if the socket is closed */
rpc->connect_cb = NULL;
return cb_data.status;
}
/*
* stat()
*/
static void stat_cb(int status, struct nfs_context *nfs, void *data, void *private_data)
{
struct sync_cb_data *cb_data = private_data;
cb_data->is_finished = 1;
cb_data->status = status;
if (status < 0) {
nfs_set_error(nfs, "stat call failed with \"%s\"", (char *)data);
return;
}
#ifdef WIN32
memcpy(cb_data->return_data, data, sizeof(struct __stat64));
#else
memcpy(cb_data->return_data, data, sizeof(struct stat));
#endif
}
#ifdef WIN32
int nfs_stat(struct nfs_context *nfs, const char *path, struct __stat64 *st)
#else
int nfs_stat(struct nfs_context *nfs, const char *path, struct stat *st)
#endif
{
struct sync_cb_data cb_data;
cb_data.is_finished = 0;
cb_data.return_data = st;
if (nfs_stat_async(nfs, path, stat_cb, &cb_data) != 0) {
nfs_set_error(nfs, "nfs_stat_async failed");
return -1;
}
wait_for_nfs_reply(nfs, &cb_data);
return cb_data.status;
}
static void stat64_cb(int status, struct nfs_context *nfs, void *data, void *private_data)
{
struct sync_cb_data *cb_data = private_data;
cb_data->is_finished = 1;
cb_data->status = status;
if (status < 0) {
nfs_set_error(nfs, "stat call failed with \"%s\"", (char *)data);
return;
}
memcpy(cb_data->return_data, data, sizeof(struct nfs_stat_64));
}
int nfs_stat64(struct nfs_context *nfs, const char *path, struct nfs_stat_64 *st)
{
struct sync_cb_data cb_data;
cb_data.is_finished = 0;
cb_data.return_data = st;
if (nfs_stat64_async(nfs, path, stat64_cb, &cb_data) != 0) {
nfs_set_error(nfs, "nfs_stat64_async failed");
return -1;
}
wait_for_nfs_reply(nfs, &cb_data);
return cb_data.status;
}
int nfs_lstat64(struct nfs_context *nfs, const char *path, struct nfs_stat_64 *st)
{
struct sync_cb_data cb_data;
cb_data.is_finished = 0;
cb_data.return_data = st;
if (nfs_lstat64_async(nfs, path, stat64_cb, &cb_data) != 0) {
nfs_set_error(nfs, "nfs_lstat64_async failed");
return -1;
}
wait_for_nfs_reply(nfs, &cb_data);
return cb_data.status;
}
/*
* open()
*/
static void open_cb(int status, struct nfs_context *nfs, void *data, void *private_data)
{
struct sync_cb_data *cb_data = private_data;
struct nfsfh *fh, **nfsfh;
cb_data->is_finished = 1;
cb_data->status = status;
if (status < 0) {
nfs_set_error(nfs, "open call failed with \"%s\"", (char *)data);
return;
}
fh = data;
nfsfh = cb_data->return_data;
*nfsfh = fh;
}
int nfs_open(struct nfs_context *nfs, const char *path, int flags, struct nfsfh **nfsfh)
{
struct sync_cb_data cb_data;
cb_data.is_finished = 0;
cb_data.return_data = nfsfh;
if (nfs_open_async(nfs, path, flags, open_cb, &cb_data) != 0) {
nfs_set_error(nfs, "nfs_open_async failed");
return -1;
}
wait_for_nfs_reply(nfs, &cb_data);
return cb_data.status;
}
/*
* chdir()
*/
static void chdir_cb(int status, struct nfs_context *nfs, void *data, void *private_data)
{
struct sync_cb_data *cb_data = private_data;
cb_data->is_finished = 1;
cb_data->status = status;
if (status < 0) {
nfs_set_error(nfs, "chdir call failed with \"%s\"", (char *)data);
return;
}
}
int nfs_chdir(struct nfs_context *nfs, const char *path)
{
struct sync_cb_data cb_data;
cb_data.is_finished = 0;
if (nfs_chdir_async(nfs, path, chdir_cb, &cb_data) != 0) {
nfs_set_error(nfs, "nfs_chdir_async failed with %s",
nfs_get_error(nfs));
return -1;
}
wait_for_nfs_reply(nfs, &cb_data);
return cb_data.status;
}
/*
* pread()
*/
static void pread_cb(int status, struct nfs_context *nfs, void *data, void *private_data)
{
struct sync_cb_data *cb_data = private_data;
char *buffer;
cb_data->is_finished = 1;
cb_data->status = status;
if (status < 0) {
nfs_set_error(nfs, "%s call failed with \"%s\"", cb_data->call, (char *)data);
return;
}
buffer = cb_data->return_data;
memcpy(buffer, (char *)data, status);
}
int nfs_pread(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t offset, uint64_t count, char *buffer)
{
struct sync_cb_data cb_data;
cb_data.is_finished = 0;
cb_data.return_data = buffer;
cb_data.call = "pread";
if (nfs_pread_async(nfs, nfsfh, offset, count, pread_cb, &cb_data) != 0) {
nfs_set_error(nfs, "nfs_pread_async failed");
return -1;
}
wait_for_nfs_reply(nfs, &cb_data);
return cb_data.status;
}
/*
* read()
*/
int nfs_read(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t count, char *buffer)
{
struct sync_cb_data cb_data;
cb_data.is_finished = 0;
cb_data.return_data = buffer;
cb_data.call = "read";
if (nfs_read_async(nfs, nfsfh, count, pread_cb, &cb_data) != 0) {
nfs_set_error(nfs, "nfs_read_async failed");
return -1;
}
wait_for_nfs_reply(nfs, &cb_data);
return cb_data.status;
}
/*
* close()
*/
static void close_cb(int status, struct nfs_context *nfs, void *data, void *private_data)
{
struct sync_cb_data *cb_data = private_data;
cb_data->is_finished = 1;
cb_data->status = status;
if (status < 0) {
nfs_set_error(nfs, "close call failed with \"%s\"", (char *)data);
return;
}
}
int nfs_close(struct nfs_context *nfs, struct nfsfh *nfsfh)
{
struct sync_cb_data cb_data;
cb_data.is_finished = 0;
if (nfs_close_async(nfs, nfsfh, close_cb, &cb_data) != 0) {
nfs_set_error(nfs, "nfs_close_async failed");
return -1;
}
wait_for_nfs_reply(nfs, &cb_data);
return cb_data.status;
}
/*
* fstat()
*/
int nfs_fstat(struct nfs_context *nfs, struct nfsfh *nfsfh, struct stat *st)
{
struct sync_cb_data cb_data;
cb_data.is_finished = 0;
cb_data.return_data = st;
if (nfs_fstat_async(nfs, nfsfh, stat_cb, &cb_data) != 0) {
nfs_set_error(nfs, "nfs_fstat_async failed");
return -1;
}
wait_for_nfs_reply(nfs, &cb_data);
return cb_data.status;
}
/*
* fstat64()
*/
int nfs_fstat64(struct nfs_context *nfs, struct nfsfh *nfsfh, struct nfs_stat_64 *st)
{
struct sync_cb_data cb_data;
cb_data.is_finished = 0;
cb_data.return_data = st;
if (nfs_fstat64_async(nfs, nfsfh, stat64_cb, &cb_data) != 0) {
nfs_set_error(nfs, "nfs_fstat64_async failed");
return -1;
}
wait_for_nfs_reply(nfs, &cb_data);
return cb_data.status;
}
/*
* pwrite()
*/
static void pwrite_cb(int status, struct nfs_context *nfs, void *data, void *private_data)
{
struct sync_cb_data *cb_data = private_data;
cb_data->is_finished = 1;
cb_data->status = status;
if (status < 0)
nfs_set_error(nfs, "%s call failed with \"%s\"", cb_data->call, (char *)data);
}
int nfs_pwrite(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t offset, uint64_t count, char *buf)
{
struct sync_cb_data cb_data;
cb_data.is_finished = 0;
cb_data.call = "pwrite";
if (nfs_pwrite_async(nfs, nfsfh, offset, count, buf, pwrite_cb, &cb_data) != 0) {
nfs_set_error(nfs, "nfs_pwrite_async failed");
return -1;
}
wait_for_nfs_reply(nfs, &cb_data);
return cb_data.status;
}
/*
* write()
*/
int nfs_write(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t count, char *buf)
{
struct sync_cb_data cb_data;
cb_data.is_finished = 0;
cb_data.call = "write";
if (nfs_write_async(nfs, nfsfh, count, buf, pwrite_cb, &cb_data) != 0) {
nfs_set_error(nfs, "nfs_write_async failed");
return -1;
}
wait_for_nfs_reply(nfs, &cb_data);
return cb_data.status;
}
/*
* fsync()
*/
static void fsync_cb(int status, struct nfs_context *nfs, void *data, void *private_data)
{
struct sync_cb_data *cb_data = private_data;
cb_data->is_finished = 1;
cb_data->status = status;
if (status < 0) {
nfs_set_error(nfs, "fsync call failed with \"%s\"", (char *)data);
return;
}
}
int nfs_fsync(struct nfs_context *nfs, struct nfsfh *nfsfh)
{
struct sync_cb_data cb_data;
cb_data.is_finished = 0;
if (nfs_fsync_async(nfs, nfsfh, fsync_cb, &cb_data) != 0) {
nfs_set_error(nfs, "nfs_fsync_async failed");
return -1;
}
wait_for_nfs_reply(nfs, &cb_data);
return cb_data.status;
}
/*
* ftruncate()
*/
static void ftruncate_cb(int status, struct nfs_context *nfs, void *data, void *private_data)
{
struct sync_cb_data *cb_data = private_data;
cb_data->is_finished = 1;
cb_data->status = status;
if (status < 0) {
nfs_set_error(nfs, "ftruncate call failed with \"%s\"", (char *)data);
return;
}
}
int nfs_ftruncate(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t length)
{
struct sync_cb_data cb_data;
cb_data.is_finished = 0;
if (nfs_ftruncate_async(nfs, nfsfh, length, ftruncate_cb, &cb_data) != 0) {
nfs_set_error(nfs, "nfs_ftruncate_async failed");
return -1;
}
wait_for_nfs_reply(nfs, &cb_data);
return cb_data.status;
}
/*
* truncate()
*/
static void truncate_cb(int status, struct nfs_context *nfs, void *data, void *private_data)
{
struct sync_cb_data *cb_data = private_data;
cb_data->is_finished = 1;
cb_data->status = status;
if (status < 0) {
nfs_set_error(nfs, "truncate call failed with \"%s\"", (char *)data);
return;
}
}
int nfs_truncate(struct nfs_context *nfs, const char *path, uint64_t length)
{
struct sync_cb_data cb_data;
cb_data.is_finished = 0;
if (nfs_truncate_async(nfs, path, length, truncate_cb, &cb_data) != 0) {
nfs_set_error(nfs, "nfs_ftruncate_async failed");
return -1;
}
wait_for_nfs_reply(nfs, &cb_data);
return cb_data.status;
}
/*
* mkdir()
*/
static void mkdir_cb(int status, struct nfs_context *nfs, void *data, void *private_data)
{
struct sync_cb_data *cb_data = private_data;
cb_data->is_finished = 1;
cb_data->status = status;
if (status < 0) {
nfs_set_error(nfs, "mkdir call failed with \"%s\"", (char *)data);
return;
}
}
int nfs_mkdir(struct nfs_context *nfs, const char *path)
{
struct sync_cb_data cb_data;
cb_data.is_finished = 0;
if (nfs_mkdir_async(nfs, path, mkdir_cb, &cb_data) != 0) {
nfs_set_error(nfs, "nfs_mkdir_async failed");
return -1;
}
wait_for_nfs_reply(nfs, &cb_data);
return cb_data.status;
}
/*
* rmdir()
*/
static void rmdir_cb(int status, struct nfs_context *nfs, void *data, void *private_data)
{
struct sync_cb_data *cb_data = private_data;
cb_data->is_finished = 1;
cb_data->status = status;
if (status < 0) {
nfs_set_error(nfs, "rmdir call failed with \"%s\"", (char *)data);
return;
}
}
int nfs_rmdir(struct nfs_context *nfs, const char *path)
{
struct sync_cb_data cb_data;
cb_data.is_finished = 0;
if (nfs_rmdir_async(nfs, path, rmdir_cb, &cb_data) != 0) {
nfs_set_error(nfs, "nfs_rmdir_async failed");
return -1;
}
wait_for_nfs_reply(nfs, &cb_data);
return cb_data.status;
}
/*
* creat()
*/
static void creat_cb(int status, struct nfs_context *nfs, void *data, void *private_data)
{
struct sync_cb_data *cb_data = private_data;
struct nfsfh *fh, **nfsfh;
cb_data->is_finished = 1;
cb_data->status = status;
if (status < 0) {
nfs_set_error(nfs, "creat call failed with \"%s\"", (char *)data);
return;
}
fh = data;
nfsfh = cb_data->return_data;
*nfsfh = fh;
}
int nfs_create(struct nfs_context *nfs, const char *path, int flags, int mode, struct nfsfh **nfsfh)
{
struct sync_cb_data cb_data;
cb_data.is_finished = 0;
cb_data.return_data = nfsfh;
if (nfs_create_async(nfs, path, flags, mode, creat_cb, &cb_data) != 0) {
nfs_set_error(nfs, "nfs_create_async failed");
return -1;
}
wait_for_nfs_reply(nfs, &cb_data);
return cb_data.status;
}
int nfs_creat(struct nfs_context *nfs, const char *path, int mode, struct nfsfh **nfsfh)
{
return nfs_create(nfs, path, 0, mode, nfsfh);
}
/*
* mknod()
*/
static void mknod_cb(int status, struct nfs_context *nfs, void *data, void *private_data)
{
struct sync_cb_data *cb_data = private_data;
cb_data->is_finished = 1;
cb_data->status = status;
if (status < 0) {
nfs_set_error(nfs, "mknod call failed with \"%s\"", (char *)data);
return;
}
}
int nfs_mknod(struct nfs_context *nfs, const char *path, int mode, int dev)
{
struct sync_cb_data cb_data;
cb_data.is_finished = 0;
if (nfs_mknod_async(nfs, path, mode, dev, mknod_cb, &cb_data) != 0) {
nfs_set_error(nfs, "nfs_creat_async failed");
return -1;
}
wait_for_nfs_reply(nfs, &cb_data);
return cb_data.status;
}
/*
* unlink()
*/
static void unlink_cb(int status, struct nfs_context *nfs, void *data, void *private_data)
{
struct sync_cb_data *cb_data = private_data;
cb_data->is_finished = 1;
cb_data->status = status;
if (status < 0) {
nfs_set_error(nfs, "unlink call failed with \"%s\"", (char *)data);
return;
}
}
int nfs_unlink(struct nfs_context *nfs, const char *path)
{
struct sync_cb_data cb_data;
cb_data.is_finished = 0;
if (nfs_unlink_async(nfs, path, unlink_cb, &cb_data) != 0) {
nfs_set_error(nfs, "nfs_unlink_async failed");
return -1;
}
wait_for_nfs_reply(nfs, &cb_data);
return cb_data.status;
}
/*
* opendir()
*/
static void opendir_cb(int status, struct nfs_context *nfs, void *data, void *private_data)
{
struct sync_cb_data *cb_data = private_data;
struct nfsdir *dir, **nfsdir;
cb_data->is_finished = 1;
cb_data->status = status;
if (status < 0) {
nfs_set_error(nfs, "opendir call failed with \"%s\"", (char *)data);
return;
}
dir = data;
nfsdir = cb_data->return_data;
*nfsdir = dir;
}
int nfs_opendir(struct nfs_context *nfs, const char *path, struct nfsdir **nfsdir)
{
struct sync_cb_data cb_data;
cb_data.is_finished = 0;
cb_data.return_data = nfsdir;
if (nfs_opendir_async(nfs, path, opendir_cb, &cb_data) != 0) {
nfs_set_error(nfs, "nfs_opendir_async failed");
return -1;
}
wait_for_nfs_reply(nfs, &cb_data);
return cb_data.status;
}
/*
* lseek()
*/
static void lseek_cb(int status, struct nfs_context *nfs, void *data, void *private_data)
{
struct sync_cb_data *cb_data = private_data;
cb_data->is_finished = 1;
cb_data->status = status;
if (status < 0) {
nfs_set_error(nfs, "lseek call failed with \"%s\"", (char *)data);
return;
}
if (cb_data->return_data != NULL) {
memcpy(cb_data->return_data, data, sizeof(uint64_t));
}
}
int nfs_lseek(struct nfs_context *nfs, struct nfsfh *nfsfh, int64_t offset, int whence, uint64_t *current_offset)
{
struct sync_cb_data cb_data;
cb_data.is_finished = 0;
cb_data.return_data = current_offset;
if (nfs_lseek_async(nfs, nfsfh, offset, whence, lseek_cb, &cb_data) != 0) {
nfs_set_error(nfs, "nfs_lseek_async failed");
return -1;
}
wait_for_nfs_reply(nfs, &cb_data);
return cb_data.status;
}
/*
* statvfs()
*/
static void statvfs_cb(int status, struct nfs_context *nfs, void *data, void *private_data)
{
struct sync_cb_data *cb_data = private_data;
cb_data->is_finished = 1;
cb_data->status = status;
if (status < 0) {
nfs_set_error(nfs, "statvfs call failed with \"%s\"", (char *)data);
return;
}
memcpy(cb_data->return_data, data, sizeof(struct statvfs));
}
int nfs_statvfs(struct nfs_context *nfs, const char *path, struct statvfs *svfs)
{
struct sync_cb_data cb_data;
cb_data.is_finished = 0;
cb_data.return_data = svfs;
if (nfs_statvfs_async(nfs, path, statvfs_cb, &cb_data) != 0) {
nfs_set_error(nfs, "nfs_statvfs_async failed");
return -1;
}
wait_for_nfs_reply(nfs, &cb_data);
return cb_data.status;
}
/*
* readlink()
*/
static void readlink_cb(int status, struct nfs_context *nfs, void *data, void *private_data)
{
struct sync_cb_data *cb_data = private_data;
cb_data->is_finished = 1;
cb_data->status = status;
if (status < 0) {
nfs_set_error(nfs, "readlink call failed with \"%s\"", (char *)data);
return;
}
if (strlen(data) > (size_t)cb_data->return_int) {
nfs_set_error(nfs, "Too small buffer for readlink");
cb_data->status = -ENAMETOOLONG;
return;
}
memcpy(cb_data->return_data, data, strlen(data)+1);
}
int nfs_readlink(struct nfs_context *nfs, const char *path, char *buf, int bufsize)
{
struct sync_cb_data cb_data;
cb_data.is_finished = 0;
cb_data.return_data = buf;
cb_data.return_int = bufsize;
if (nfs_readlink_async(nfs, path, readlink_cb, &cb_data) != 0) {
nfs_set_error(nfs, "nfs_readlink_async failed");
return -1;
}
wait_for_nfs_reply(nfs, &cb_data);
return cb_data.status;
}
/*
* chmod()
*/
static void chmod_cb(int status, struct nfs_context *nfs, void *data, void *private_data)
{
struct sync_cb_data *cb_data = private_data;
cb_data->is_finished = 1;
cb_data->status = status;
if (status < 0) {
nfs_set_error(nfs, "chmod call failed with \"%s\"", (char *)data);
return;
}
}
int nfs_chmod(struct nfs_context *nfs, const char *path, int mode)
{
struct sync_cb_data cb_data;
cb_data.is_finished = 0;
if (nfs_chmod_async(nfs, path, mode, chmod_cb, &cb_data) != 0) {
nfs_set_error(nfs, "nfs_chmod_async failed");
return -1;
}
wait_for_nfs_reply(nfs, &cb_data);
return cb_data.status;
}
int nfs_lchmod(struct nfs_context *nfs, const char *path, int mode)
{
struct sync_cb_data cb_data;
cb_data.is_finished = 0;
if (nfs_lchmod_async(nfs, path, mode, chmod_cb, &cb_data) != 0) {
nfs_set_error(nfs, "nfs_lchmod_async failed");
return -1;
}
wait_for_nfs_reply(nfs, &cb_data);
return cb_data.status;
}
/*
* fchmod()
*/
static void fchmod_cb(int status, struct nfs_context *nfs, void *data, void *private_data)
{
struct sync_cb_data *cb_data = private_data;
cb_data->is_finished = 1;
cb_data->status = status;
if (status < 0) {
nfs_set_error(nfs, "fchmod call failed with \"%s\"", (char *)data);
return;
}
}
int nfs_fchmod(struct nfs_context *nfs, struct nfsfh *nfsfh, int mode)
{
struct sync_cb_data cb_data;
cb_data.is_finished = 0;
if (nfs_fchmod_async(nfs, nfsfh, mode, fchmod_cb, &cb_data) != 0) {
nfs_set_error(nfs, "nfs_fchmod_async failed");
return -1;
}
wait_for_nfs_reply(nfs, &cb_data);
return cb_data.status;
}
/*
* chown()
*/
static void chown_cb(int status, struct nfs_context *nfs, void *data, void *private_data)
{
struct sync_cb_data *cb_data = private_data;
cb_data->is_finished = 1;
cb_data->status = status;
if (status < 0) {
nfs_set_error(nfs, "chown call failed with \"%s\"", (char *)data);
return;
}
}
int nfs_chown(struct nfs_context *nfs, const char *path, int uid, int gid)
{
struct sync_cb_data cb_data;
cb_data.is_finished = 0;
if (nfs_chown_async(nfs, path, uid, gid, chown_cb, &cb_data) != 0) {
nfs_set_error(nfs, "nfs_chown_async failed");
return -1;
}
wait_for_nfs_reply(nfs, &cb_data);
return cb_data.status;
}
/*
* lchown()
*/
int nfs_lchown(struct nfs_context *nfs, const char *path, int uid, int gid)
{
struct sync_cb_data cb_data;
cb_data.is_finished = 0;
if (nfs_lchown_async(nfs, path, uid, gid, chown_cb, &cb_data) != 0) {
nfs_set_error(nfs, "nfs_lchown_async failed");
return -1;
}
wait_for_nfs_reply(nfs, &cb_data);
return cb_data.status;
}
/*
* fchown()
*/
static void fchown_cb(int status, struct nfs_context *nfs, void *data, void *private_data)
{
struct sync_cb_data *cb_data = private_data;
cb_data->is_finished = 1;
cb_data->status = status;
if (status < 0) {
nfs_set_error(nfs, "fchown call failed with \"%s\"", (char *)data);
return;
}
}
int nfs_fchown(struct nfs_context *nfs, struct nfsfh *nfsfh, int uid, int gid)
{
struct sync_cb_data cb_data;
cb_data.is_finished = 0;
if (nfs_fchown_async(nfs, nfsfh, uid, gid, fchown_cb, &cb_data) != 0) {
nfs_set_error(nfs, "nfs_fchown_async failed");
return -1;
}
wait_for_nfs_reply(nfs, &cb_data);
return cb_data.status;
}
/*
* utimes()
*/
static void utimes_cb(int status, struct nfs_context *nfs, void *data, void *private_data)
{
struct sync_cb_data *cb_data = private_data;
cb_data->is_finished = 1;
cb_data->status = status;
if (status < 0) {
nfs_set_error(nfs, "utimes call failed with \"%s\"", (char *)data);
return;
}
}
int nfs_utimes(struct nfs_context *nfs, const char *path, struct timeval *times)
{
struct sync_cb_data cb_data;
cb_data.is_finished = 0;
if (nfs_utimes_async(nfs, path, times, utimes_cb, &cb_data) != 0) {
nfs_set_error(nfs, "nfs_utimes_async failed");
return -1;
}
wait_for_nfs_reply(nfs, &cb_data);
return cb_data.status;
}
int nfs_lutimes(struct nfs_context *nfs, const char *path, struct timeval *times)
{
struct sync_cb_data cb_data;
cb_data.is_finished = 0;
if (nfs_lutimes_async(nfs, path, times, utimes_cb, &cb_data) != 0) {
nfs_set_error(nfs, "nfs_lutimes_async failed");
return -1;
}
wait_for_nfs_reply(nfs, &cb_data);
return cb_data.status;
}
/*
* utime()
*/
static void utime_cb(int status, struct nfs_context *nfs, void *data, void *private_data)
{
struct sync_cb_data *cb_data = private_data;
cb_data->is_finished = 1;
cb_data->status = status;
if (status < 0) {
nfs_set_error(nfs, "utime call failed with \"%s\"", (char *)data);
return;
}
}
int nfs_utime(struct nfs_context *nfs, const char *path, struct utimbuf *times)
{
struct sync_cb_data cb_data;
cb_data.is_finished = 0;
if (nfs_utime_async(nfs, path, times, utime_cb, &cb_data) != 0) {
nfs_set_error(nfs, "nfs_utimes_async failed");
return -1;
}
wait_for_nfs_reply(nfs, &cb_data);
return cb_data.status;
}
/*
* access()
*/
static void access_cb(int status, struct nfs_context *nfs, void *data, void *private_data)
{
struct sync_cb_data *cb_data = private_data;
cb_data->is_finished = 1;
cb_data->status = status;
if (status < 0) {
nfs_set_error(nfs, "access call failed with \"%s\"", (char *)data);
return;
}
}
int nfs_access(struct nfs_context *nfs, const char *path, int mode)
{
struct sync_cb_data cb_data;
cb_data.is_finished = 0;
if (nfs_access_async(nfs, path, mode, access_cb, &cb_data) != 0) {
nfs_set_error(nfs, "nfs_access_async failed");
return -1;
}
wait_for_nfs_reply(nfs, &cb_data);
return cb_data.status;
}
/*
* access2()
*/
static void access2_cb(int status, struct nfs_context *nfs, void *data, void *private_data)
{
struct sync_cb_data *cb_data = private_data;
cb_data->is_finished = 1;
cb_data->status = status;
if (status < 0) {
nfs_set_error(nfs, "access2 call failed with \"%s\"", (char *)data);
return;
}
}
int nfs_access2(struct nfs_context *nfs, const char *path)
{
struct sync_cb_data cb_data;
cb_data.is_finished = 0;
if (nfs_access2_async(nfs, path, access2_cb, &cb_data) != 0) {
nfs_set_error(nfs, "nfs_access2_async failed");
return -1;
}
wait_for_nfs_reply(nfs, &cb_data);
return cb_data.status;
}
/*
* symlink()
*/
static void symlink_cb(int status, struct nfs_context *nfs, void *data, void *private_data)
{
struct sync_cb_data *cb_data = private_data;
cb_data->is_finished = 1;
cb_data->status = status;
if (status < 0) {
nfs_set_error(nfs, "symlink call failed with \"%s\"", (char *)data);
return;
}
}
int nfs_symlink(struct nfs_context *nfs, const char *oldpath, const char *newpath)
{
struct sync_cb_data cb_data;
cb_data.is_finished = 0;
if (nfs_symlink_async(nfs, oldpath, newpath, symlink_cb, &cb_data) != 0) {
nfs_set_error(nfs, "nfs_symlink_async failed");
return -1;
}
wait_for_nfs_reply(nfs, &cb_data);
return cb_data.status;
}
/*
* rename()
*/
static void rename_cb(int status, struct nfs_context *nfs, void *data, void *private_data)
{
struct sync_cb_data *cb_data = private_data;
cb_data->is_finished = 1;
cb_data->status = status;
if (status < 0) {
nfs_set_error(nfs, "rename call failed with \"%s\"", (char *)data);
return;
}
}
int nfs_rename(struct nfs_context *nfs, const char *oldpath, const char *newpath)
{
struct sync_cb_data cb_data;
cb_data.is_finished = 0;
if (nfs_rename_async(nfs, oldpath, newpath, rename_cb, &cb_data) != 0) {
nfs_set_error(nfs, "nfs_rename_async failed");
return -1;
}
wait_for_nfs_reply(nfs, &cb_data);
return cb_data.status;
}
/*
* link()
*/
static void link_cb(int status, struct nfs_context *nfs, void *data, void *private_data)
{
struct sync_cb_data *cb_data = private_data;
cb_data->is_finished = 1;
cb_data->status = status;
if (status < 0) {
nfs_set_error(nfs, "link call failed with \"%s\"", (char *)data);
return;
}
}
int nfs_link(struct nfs_context *nfs, const char *oldpath, const char *newpath)
{
struct sync_cb_data cb_data;
cb_data.is_finished = 0;
if (nfs_link_async(nfs, oldpath, newpath, link_cb, &cb_data) != 0) {
nfs_set_error(nfs, "nfs_link_async failed");
return -1;
}
wait_for_nfs_reply(nfs, &cb_data);
return cb_data.status;
}
void mount_getexports_cb(struct rpc_context *mount_context, int status, void *data, void *private_data)
{
struct sync_cb_data *cb_data = private_data;
exports export;
assert(mount_context->magic == RPC_CONTEXT_MAGIC);
cb_data->is_finished = 1;
cb_data->status = status;
cb_data->return_data = NULL;
if (status != 0) {
rpc_set_error(mount_context, "mount/export call failed with \"%s\"", (char *)data);
return;
}
export = *(exports *)data;
while (export != NULL) {
exports new_export;
new_export = malloc(sizeof(*new_export));
memset(new_export, 0, sizeof(*new_export));
new_export->ex_dir = strdup(export->ex_dir);
new_export->ex_next = cb_data->return_data;
cb_data->return_data = new_export;
export = export->ex_next;
}
}
struct exportnode *mount_getexports(const char *server)
{
struct sync_cb_data cb_data;
struct rpc_context *rpc;
cb_data.is_finished = 0;
cb_data.return_data = NULL;
rpc = rpc_init_context();
if (mount_getexports_async(rpc, server, mount_getexports_cb, &cb_data) != 0) {
rpc_destroy_context(rpc);
return NULL;
}
wait_for_reply(rpc, &cb_data);
rpc_destroy_context(rpc);
return cb_data.return_data;
}
void mount_free_export_list(struct exportnode *exp)
{
struct exportnode *tmp;
while ((tmp = exp)) {
exp = exp->ex_next;
free(tmp->ex_dir);
free(tmp);
}
}
void free_nfs_srvr_list(struct nfs_server_list *srv)
{
while (srv != NULL) {
struct nfs_server_list *next = srv->next;
free(srv->addr);
free(srv);
srv = next;
}
}
struct nfs_list_data {
int status;
struct nfs_server_list *srvrs;
};
void callit_cb(struct rpc_context *rpc, int status, void *data _U_, void *private_data)
{
struct nfs_list_data *srv_data = private_data;
struct sockaddr *sin;
char hostdd[16];
struct nfs_server_list *srvr;
assert(rpc->magic == RPC_CONTEXT_MAGIC);
if (status == RPC_STATUS_CANCEL) {
return;
}
if (status != 0) {
srv_data->status = -1;
return;
}
sin = rpc_get_recv_sockaddr(rpc);
if (sin == NULL) {
rpc_set_error(rpc, "failed to get sockaddr in CALLIT callback");
srv_data->status = -1;
return;
}
if (getnameinfo(sin, sizeof(struct sockaddr_in), &hostdd[0], sizeof(hostdd), NULL, 0, NI_NUMERICHOST) < 0) {
rpc_set_error(rpc, "getnameinfo failed in CALLIT callback");
srv_data->status = -1;
return;
}
/* check for dupes */
for (srvr = srv_data->srvrs; srvr; srvr = srvr->next) {
if (!strcmp(hostdd, srvr->addr)) {
return;
}
}
srvr = malloc(sizeof(struct nfs_server_list));
if (srvr == NULL) {
rpc_set_error(rpc, "Malloc failed when allocating server structure");
srv_data->status = -1;
return;
}
srvr->addr = strdup(hostdd);
if (srvr->addr == NULL) {
rpc_set_error(rpc, "Strdup failed when allocating server structure");
free(srvr);
srv_data->status = -1;
return;
}
srvr->next = srv_data->srvrs;
srv_data->srvrs = srvr;
}
#ifdef WIN32
static int send_nfsd_probes(struct rpc_context *rpc, INTERFACE_INFO *InterfaceList, int numIfs, struct nfs_list_data *data)
{
int i=0;
assert(rpc->magic == RPC_CONTEXT_MAGIC);
for(i = 0; i < numIfs; i++)
{
SOCKADDR *pAddress;
char bcdd[16];
unsigned long nFlags = 0;
pAddress = (SOCKADDR *) & (InterfaceList[i].iiBroadcastAddress);
if(pAddress->sa_family != AF_INET)
continue;
nFlags = InterfaceList[i].iiFlags;
if (!(nFlags & IFF_UP))
{
continue;
}
if (nFlags & IFF_LOOPBACK)
{
continue;
}
if (!(nFlags & IFF_BROADCAST))
{
continue;
}
if (getnameinfo(pAddress, sizeof(struct sockaddr_in), &bcdd[0], sizeof(bcdd), NULL, 0, NI_NUMERICHOST) < 0)
{
continue;
}
if (rpc_set_udp_destination(rpc, bcdd, 111, 1) < 0)
{
return -1;
}
if (rpc_pmap2_callit_async(rpc, MOUNT_PROGRAM, 2, 0, NULL, 0, callit_cb, data) < 0)
{
return -1;
}
}
return 0;
}
struct nfs_server_list *nfs_find_local_servers(void)
{
struct rpc_context *rpc;
struct nfs_list_data data = {0, NULL};
struct timeval tv_start, tv_current;
int loop;
struct pollfd pfd;
INTERFACE_INFO InterfaceList[20];
unsigned long nBytesReturned;
int nNumInterfaces = 0;
rpc = rpc_init_udp_context();
if (rpc == NULL)
{
return NULL;
}
if (rpc_bind_udp(rpc, "0.0.0.0", 0) < 0)
{
rpc_destroy_context(rpc);
return NULL;
}
if (WSAIoctl(rpc_get_fd(rpc), SIO_GET_INTERFACE_LIST, 0, 0, &InterfaceList, sizeof(InterfaceList), &nBytesReturned, 0, 0) == SOCKET_ERROR)
{
return NULL;
}
nNumInterfaces = nBytesReturned / sizeof(INTERFACE_INFO);
for (loop=0; loop<3; loop++)
{
if (send_nfsd_probes(rpc, InterfaceList, nNumInterfaces, &data) != 0)
{
rpc_destroy_context(rpc);
return NULL;
}
win32_gettimeofday(&tv_start, NULL);
for(;;)
{
int mpt;
pfd.fd = rpc_get_fd(rpc);
pfd.events = rpc_which_events(rpc);
win32_gettimeofday(&tv_current, NULL);
mpt = 1000
- (tv_current.tv_sec *1000 + tv_current.tv_usec / 1000)
+ (tv_start.tv_sec *1000 + tv_start.tv_usec / 1000);
if (poll(&pfd, 1, mpt) < 0)
{
free_nfs_srvr_list(data.srvrs);
rpc_destroy_context(rpc);
return NULL;
}
if (pfd.revents == 0)
{
break;
}
if (rpc_service(rpc, pfd.revents) < 0)
{
break;
}
}
}
rpc_destroy_context(rpc);
if (data.status != 0)
{
free_nfs_srvr_list(data.srvrs);
return NULL;
}
return data.srvrs;
}
#else
static int send_nfsd_probes(struct rpc_context *rpc, struct ifconf *ifc, struct nfs_list_data *data)
{
char *ptr;
assert(rpc->magic == RPC_CONTEXT_MAGIC);
for (ptr =(char *)(ifc->ifc_buf); ptr < (char *)(ifc->ifc_buf) + ifc->ifc_len; ) {
struct ifreq *ifr;
char bcdd[16];
ifr = (struct ifreq *)ptr;
#ifdef HAVE_SOCKADDR_LEN
if (ifr->ifr_addr.sa_len > sizeof(struct sockaddr)) {
ptr += sizeof(ifr->ifr_name) + ifr->ifr_addr.sa_len;
} else {
ptr += sizeof(ifr->ifr_name) + sizeof(struct sockaddr);
}
#else
ptr += sizeof(struct ifreq);
#endif
if (ifr->ifr_addr.sa_family != AF_INET) {
continue;
}
if (ioctl(rpc_get_fd(rpc), SIOCGIFFLAGS, ifr) < 0) {
return -1;
}
if (!(ifr->ifr_flags & IFF_UP)) {
continue;
}
if (ifr->ifr_flags & IFF_LOOPBACK) {
continue;
}
if (!(ifr->ifr_flags & IFF_BROADCAST)) {
continue;
}
if (ioctl(rpc_get_fd(rpc), SIOCGIFBRDADDR, ifr) < 0) {
continue;
}
if (getnameinfo(&ifr->ifr_broadaddr, sizeof(struct sockaddr_in), &bcdd[0], sizeof(bcdd), NULL, 0, NI_NUMERICHOST) < 0) {
continue;
}
if (rpc_set_udp_destination(rpc, bcdd, 111, 1) < 0) {
return -1;
}
if (rpc_pmap2_callit_async(rpc, MOUNT_PROGRAM, 2, 0, NULL, 0, callit_cb, data) < 0) {
return -1;
}
}
return 0;
}
struct nfs_server_list *nfs_find_local_servers(void)
{
struct rpc_context *rpc;
struct nfs_list_data data = {0, NULL};
struct timeval tv_start, tv_current;
struct ifconf ifc;
int size, loop;
struct pollfd pfd;
rpc = rpc_init_udp_context();
if (rpc == NULL) {
return NULL;
}
if (rpc_bind_udp(rpc, "0.0.0.0", 0) < 0) {
rpc_destroy_context(rpc);
return NULL;
}
/* get list of all interfaces */
size = sizeof(struct ifreq);
ifc.ifc_buf = NULL;
ifc.ifc_len = size;
while(ifc.ifc_len > (size - sizeof(struct ifreq))) {
size *= 2;
free(ifc.ifc_buf);
ifc.ifc_len = size;
ifc.ifc_buf = malloc(size);
memset(ifc.ifc_buf, 0, size);
if (ioctl(rpc_get_fd(rpc), SIOCGIFCONF, (caddr_t)&ifc) < 0) {
rpc_destroy_context(rpc);
free(ifc.ifc_buf);
return NULL;
}
}
for (loop=0; loop<3; loop++) {
if (send_nfsd_probes(rpc, &ifc, &data) != 0) {
rpc_destroy_context(rpc);
free(ifc.ifc_buf);
return NULL;
}
gettimeofday(&tv_start, NULL);
for(;;) {
int mpt;
pfd.fd = rpc_get_fd(rpc);
pfd.events = rpc_which_events(rpc);
gettimeofday(&tv_current, NULL);
mpt = 1000
- (tv_current.tv_sec *1000 + tv_current.tv_usec / 1000)
+ (tv_start.tv_sec *1000 + tv_start.tv_usec / 1000);
if (poll(&pfd, 1, mpt) < 0) {
free_nfs_srvr_list(data.srvrs);
rpc_destroy_context(rpc);
return NULL;
}
if (pfd.revents == 0) {
break;
}
if (rpc_service(rpc, pfd.revents) < 0) {
break;
}
}
}
free(ifc.ifc_buf);
rpc_destroy_context(rpc);
if (data.status != 0) {
free_nfs_srvr_list(data.srvrs);
return NULL;
}
return data.srvrs;
}
#endif//WIN32
libnfs-libnfs-1.9.8/lib/libnfs-win32.def 0000664 0000000 0000000 00000007537 12557450341 0017746 0 ustar 00root root 0000000 0000000 LIBRARY libnfs
EXPORTS
mount_free_export_list
mount_getexports
mount_getexports_async
nfs_find_local_servers
free_nfs_srvr_list
nfs_access
nfs_access_async
nfs_chdir
nfs_chmod
nfs_chmod_async
nfs_chown
nfs_chown_async
nfs_close
nfs_close_async
nfs_closedir
nfs_creat
nfs_creat_async
nfs_destroy_context
nfs_fchmod
nfs_fchmod_async
nfs_fchown
nfs_fchown_async
nfs_fstat
nfs_fstat_async
nfs_fsync
nfs_fsync_async
nfs_ftruncate
nfs_ftruncate_async
nfs_get_error
nfs_get_fd
nfs_get_readmax
nfs_get_writemax
nfs_getcwd
nfs_init_context
nfs_link
nfs_link_async
nfs_lseek
nfs_lseek_async
nfs_mkdir
nfs_mkdir_async
nfs_mknod
nfs_mknod_async
nfs_mount
nfs_mount_async
nfs_open
nfs_open_async
nfs_opendir
nfs_opendir_async
nfs_parse_url_full
nfs_parse_url_dir
nfs_parse_url_incomplete
nfs_destroy_url
nfs_pread
nfs_pread_async
nfs_pwrite
nfs_pwrite_async
nfs_read
nfs_read_async
nfs_readdir
nfs_readlink
nfs_readlink_async
nfs_rename
nfs_rename_async
nfs_rmdir
nfs_rmdir_async
nfs_service
nfs_set_auth
nfs_set_gid
nfs_set_tcp_syncnt
nfs_set_uid
nfs_set_readahead
nfs_set_debug
nfs_stat
nfs_stat_async
nfs_stat64
nfs_stat64_async
nfs_statvfs
nfs_statvfs_async
nfs_symlink
nfs_symlink_async
nfs_truncate
nfs_truncate_async
nfs_unlink
nfs_unlink_async
nfs_utime
nfs_utime_async
nfs_utimes
nfs_utimes_async
nfs_which_events
nfs_write
nfs_write_async
win32_poll
rpc_connect_async
rpc_destroy_context
rpc_disconnect
rpc_get_error
rpc_get_fd
rpc_init_context
rpc_pmap2_null_async
rpc_pmap2_getport_async
rpc_pmap2_set_async
rpc_pmap2_unset_async
rpc_pmap2_dump_async
rpc_pmap2_callit_async
rpc_pmap3_null_async
rpc_pmap3_set_async
rpc_pmap3_unset_async
rpc_pmap3_getaddr_async
rpc_pmap3_dump_async
rpc_pmap3_callit_async
rpc_pmap3_gettime_async
rpc_pmap3_uaddr2taddr_async
rpc_pmap3_taddr2uaddr_async
rpc_mount_null_async
rpc_mount_mnt_async
rpc_mount_dump_async
rpc_mount_umnt_async
rpc_mount_umntall_async
rpc_mount_export_async
rpc_mount1_null_async
rpc_mount1_mnt_async
rpc_mount1_dump_async
rpc_mount1_umnt_async
rpc_mount1_umntall_async
rpc_mount1_export_async
rpc_mount3_null_async
rpc_mount3_mnt_async
rpc_mount3_dump_async
rpc_mount3_umnt_async
rpc_mount3_umntall_async
rpc_mount3_export_async
rpc_nfsacl_null_async
rpc_nfsacl_getacl_async
rpc_nfsacl_setacl_async
rpc_nfs_null_async
rpc_nfs_getattr_async
rpc_nfs_pathconf_async
rpc_nfs_lookup_async
rpc_nfs_access_async
rpc_nfs_read_async
rpc_nfs_write_async
rpc_nfs_commit_async
rpc_nfs_setattr_async
rpc_nfs_mkdir_async
rpc_nfs_rmdir_async
rpc_nfs_create_async
rpc_nfs_mknod_async
rpc_nfs_remove_async
rpc_nfs_readdir_async
rpc_nfs_readdirplus_async
rpc_nfs_fsstat_async
rpc_nfs_fsinfo_async
rpc_nfs_readlink_async
rpc_nfs_symlink_async
rpc_nfs_rename_async
rpc_nfs_link_async
rpc_nfs2_null_async
rpc_nfs2_getattr_async
rpc_nfs2_setattr_async
rpc_nfs2_lookup_async
rpc_nfs2_readlink_async
rpc_nfs2_read_async
rpc_nfs2_write_async
rpc_nfs2_create_async
rpc_nfs2_remove_async
rpc_nfs2_rename_async
rpc_nfs2_link_async
rpc_nfs2_symlink_async
rpc_nfs2_mkdir_async
rpc_nfs2_rmdir_async
rpc_nfs2_readdir_async
rpc_nfs2_statfs_async
rpc_nfs3_null_async
rpc_nfs3_getattr_async
rpc_nfs3_pathconf_async
rpc_nfs3_lookup_async
rpc_nfs3_access_async
rpc_nfs3_read_async
rpc_nfs3_write_async
rpc_nfs3_commit_async
rpc_nfs3_setattr_async
rpc_nfs3_mkdir_async
rpc_nfs3_rmdir_async
rpc_nfs3_create_async
rpc_nfs3_mknod_async
rpc_nfs3_remove_async
rpc_nfs3_readdir_async
rpc_nfs3_readdirplus_async
rpc_nfs3_fsstat_async
rpc_nfs3_fsinfo_async
rpc_nfs3_readlink_async
rpc_nfs3_symlink_async
rpc_nfs3_rename_async
rpc_nfs3_link_async
rpc_nlm4_null_async
rpc_nlm4_test_async
rpc_nlm4_lock_async
rpc_nlm4_cancel_async
rpc_nlm4_unlock_async
rpc_nsm1_null_async
rpc_nsm1_stat_async
rpc_nsm1_mon_async
rpc_nsm1_unmon_async
rpc_nsm1_unmonall_async
rpc_nsm1_simucrash_async
rpc_nsm1_notify_async
rpc_rquota1_null_async
rpc_rquota1_getquota_async
rpc_rquota1_getactivequota_async
rpc_service
rpc_set_fd
rpc_which_events
libnfs-libnfs-1.9.8/lib/libnfs-zdr.c 0000664 0000000 0000000 00000027620 12557450341 0017262 0 ustar 00root root 0000000 0000000 /*
Copyright (C) 2012 by Ronnie Sahlberg
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, see .
*/
/*
* This file contains definitions for the built in ZDR implementation.
* This is a very limited ZDR subset that can only marshal to/from a momory buffer,
* i.e. zdrmem_create() buffers.
* It aims to be compatible with normal rpcgen generated functions.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef WIN32
#include "win32_compat.h"
#endif
#ifdef AROS
#include "aros_compat.h"
#endif
#ifdef HAVE_ARPA_INET_H
#include
#endif
#include
#include
#include
#include
#include "libnfs-zdr.h"
#include "libnfs.h"
#include "libnfs-raw.h"
#include "libnfs-private.h"
struct opaque_auth _null_auth;
bool_t libnfs_zdr_setpos(ZDR *zdrs, uint32_t pos)
{
zdrs->pos = pos;
return TRUE;
}
uint32_t libnfs_zdr_getpos(ZDR *zdrs)
{
return zdrs->pos;
}
void libnfs_zdrmem_create(ZDR *zdrs, const caddr_t addr, uint32_t size, enum zdr_op xop)
{
zdrs->x_op = xop;
zdrs->buf = addr;
zdrs->size = size;
zdrs->pos = 0;
zdrs->mem = NULL;
}
static void *zdr_malloc(ZDR *zdrs, uint32_t size)
{
struct zdr_mem *mem;
mem = malloc(sizeof(struct zdr_mem));
mem->next = zdrs->mem;
mem->size = size;
mem->buf = malloc(mem->size);
zdrs->mem = mem;
return mem->buf;
}
void libnfs_zdr_destroy(ZDR *zdrs)
{
while (zdrs->mem != NULL) {
struct zdr_mem *mem = zdrs->mem->next;
free(zdrs->mem->buf);
free(zdrs->mem);
zdrs->mem = mem;
}
}
bool_t libnfs_zdr_u_int(ZDR *zdrs, uint32_t *u)
{
if (zdrs->pos + 4 > zdrs->size) {
return FALSE;
}
switch (zdrs->x_op) {
case ZDR_ENCODE:
*(uint32_t *)&zdrs->buf[zdrs->pos] = htonl(*u);
zdrs->pos += 4;
return TRUE;
break;
case ZDR_DECODE:
*u = ntohl(*(uint32_t *)&zdrs->buf[zdrs->pos]);
zdrs->pos += 4;
return TRUE;
break;
}
return FALSE;
}
bool_t libnfs_zdr_int(ZDR *zdrs, int32_t *i)
{
return libnfs_zdr_u_int(zdrs, (uint32_t *)i);
}
bool_t libnfs_zdr_uint64_t(ZDR *zdrs, uint64_t *u)
{
if (zdrs->pos + 8 > zdrs->size) {
return FALSE;
}
switch (zdrs->x_op) {
case ZDR_ENCODE:
*(uint32_t *)&zdrs->buf[zdrs->pos] = htonl((*u >> 32));
zdrs->pos += 4;
*(uint32_t *)&zdrs->buf[zdrs->pos] = htonl((*u & 0xffffffff));
zdrs->pos += 4;
return TRUE;
break;
case ZDR_DECODE:
*u = ntohl(*(uint32_t *)&zdrs->buf[zdrs->pos]);
zdrs->pos += 4;
*u <<= 32;
*u |= (uint32_t)ntohl(*(uint32_t *)&zdrs->buf[zdrs->pos]);
zdrs->pos += 4;
return TRUE;
break;
}
return FALSE;
}
bool_t libnfs_zdr_int64_t(ZDR *zdrs, int64_t *i)
{
return libnfs_zdr_uint64_t(zdrs, (uint64_t *)i);
}
bool_t libnfs_zdr_bytes(ZDR *zdrs, char **bufp, uint32_t *size, uint32_t maxsize)
{
if (!libnfs_zdr_u_int(zdrs, size)) {
return FALSE;
}
if (zdrs->pos + *size > zdrs->size) {
return FALSE;
}
switch (zdrs->x_op) {
case ZDR_ENCODE:
memcpy(&zdrs->buf[zdrs->pos], *bufp, *size);
zdrs->pos += *size;
zdrs->pos = (zdrs->pos + 3) & ~3;
return TRUE;
case ZDR_DECODE:
if (*bufp == NULL) {
*bufp = zdr_malloc(zdrs, *size);
}
memcpy(*bufp, &zdrs->buf[zdrs->pos], *size);
zdrs->pos += *size;
zdrs->pos = (zdrs->pos + 3) & ~3;
return TRUE;
}
return FALSE;
}
bool_t libnfs_zdr_enum(ZDR *zdrs, enum_t *e)
{
bool_t ret;
int32_t i = *e;
ret = libnfs_zdr_u_int(zdrs, (uint32_t *)&i);
*e = i;
return ret;
}
bool_t libnfs_zdr_bool(ZDR *zdrs, bool_t *b)
{
return libnfs_zdr_u_int(zdrs, (uint32_t *)b);
}
bool_t libnfs_zdr_void(void)
{
return TRUE;
}
bool_t libnfs_zdr_pointer(ZDR *zdrs, char **objp, uint32_t size, zdrproc_t proc)
{
bool_t more_data;
more_data = (*objp != NULL);
if (!libnfs_zdr_bool(zdrs, &more_data)) {
return FALSE;
}
if (more_data == 0) {
*objp = NULL;
return TRUE;
}
if (zdrs->x_op == ZDR_DECODE) {
*objp = zdr_malloc(zdrs, size);
if (*objp == NULL) {
return FALSE;
}
memset(*objp, 0, size);
}
return proc(zdrs, *objp);
}
bool_t libnfs_zdr_opaque(ZDR *zdrs, char *objp, uint32_t size)
{
switch (zdrs->x_op) {
case ZDR_ENCODE:
memcpy(&zdrs->buf[zdrs->pos], objp, size);
zdrs->pos += size;
if (zdrs->pos & 3) {
memset(&zdrs->buf[zdrs->pos], 0x00, 4 - (zdrs->pos & 3));
}
zdrs->pos = (zdrs->pos + 3) & ~3;
return TRUE;
case ZDR_DECODE:
memcpy(objp, &zdrs->buf[zdrs->pos], size);
zdrs->pos += size;
zdrs->pos = (zdrs->pos + 3) & ~3;
return TRUE;
}
return FALSE;
}
bool_t libnfs_zdr_string(ZDR *zdrs, char **strp, uint32_t maxsize)
{
uint32_t size;
if (zdrs->x_op == ZDR_ENCODE) {
size = strlen(*strp);
}
if (!libnfs_zdr_u_int(zdrs, &size)) {
return FALSE;
}
if (zdrs->pos + size > zdrs->size) {
return FALSE;
}
switch (zdrs->x_op) {
case ZDR_ENCODE:
return libnfs_zdr_opaque(zdrs, *strp, size);
case ZDR_DECODE:
*strp = zdr_malloc(zdrs, size + 1);
if (*strp == NULL) {
return FALSE;
}
(*strp)[size] = 0;
return libnfs_zdr_opaque(zdrs, *strp, size);
}
return FALSE;
}
bool_t libnfs_zdr_array(ZDR *zdrs, char **arrp, uint32_t *size, uint32_t maxsize, uint32_t elsize, zdrproc_t proc)
{
int i;
if (!libnfs_zdr_u_int(zdrs, size)) {
return FALSE;
}
if (zdrs->pos + *size * elsize > zdrs->size) {
return FALSE;
}
if (zdrs->x_op == ZDR_DECODE) {
*arrp = zdr_malloc(zdrs, *size * elsize);
if (*arrp == NULL) {
return FALSE;
}
memset(*arrp, 0, *size * elsize);
}
for (i = 0; i < *size; i++) {
if (!proc(zdrs, *arrp + i * elsize)) {
return FALSE;
}
}
return TRUE;
}
void libnfs_zdr_free(zdrproc_t proc, char *objp)
{
}
static bool_t libnfs_opaque_auth(ZDR *zdrs, struct opaque_auth *auth)
{
if (!libnfs_zdr_u_int(zdrs, &auth->oa_flavor)) {
return FALSE;
}
if (!libnfs_zdr_bytes(zdrs, &auth->oa_base, &auth->oa_length, auth->oa_length)) {
return FALSE;
}
return TRUE;
}
static bool_t libnfs_rpc_call_body(struct rpc_context *rpc, ZDR *zdrs, struct call_body *cmb)
{
if (!libnfs_zdr_u_int(zdrs, &cmb->rpcvers)) {
rpc_set_error(rpc, "libnfs_rpc_call_body failed to encode "
"RPCVERS");
return FALSE;
}
if (!libnfs_zdr_u_int(zdrs, &cmb->prog)) {
rpc_set_error(rpc, "libnfs_rpc_call_body failed to encode "
"PROG");
return FALSE;
}
if (!libnfs_zdr_u_int(zdrs, &cmb->vers)) {
rpc_set_error(rpc, "libnfs_rpc_call_body failed to encode "
"VERS");
return FALSE;
}
if (!libnfs_zdr_u_int(zdrs, &cmb->proc)) {
rpc_set_error(rpc, "libnfs_rpc_call_body failed to encode "
"PROC");
return FALSE;
}
if (!libnfs_opaque_auth(zdrs, &cmb->cred)) {
rpc_set_error(rpc, "libnfs_rpc_call_body failed to encode "
"CRED");
return FALSE;
}
if (!libnfs_opaque_auth(zdrs, &cmb->verf)) {
rpc_set_error(rpc, "libnfs_rpc_call_body failed to encode "
"VERF");
return FALSE;
}
return TRUE;
}
static bool_t libnfs_accepted_reply(ZDR *zdrs, struct accepted_reply *ar)
{
if (!libnfs_opaque_auth(zdrs, &ar->verf)) {
return FALSE;
}
if (!libnfs_zdr_u_int(zdrs, &ar->stat)) {
return FALSE;
}
switch (ar->stat) {
case SUCCESS:
if (!ar->reply_data.results.proc(zdrs, ar->reply_data.results.where)) {
return FALSE;
}
return TRUE;
case PROG_MISMATCH:
if (!libnfs_zdr_u_int(zdrs, &ar->reply_data.mismatch_info.low)) {
return FALSE;
}
if (!libnfs_zdr_u_int(zdrs, &ar->reply_data.mismatch_info.high)) {
return FALSE;
}
return TRUE;
default:
return TRUE;
}
return FALSE;
}
static bool_t libnfs_rejected_reply(ZDR *zdrs, struct rejected_reply *rr)
{
if (!libnfs_zdr_u_int(zdrs, &rr->stat)) {
return FALSE;
}
switch (rr->stat) {
case RPC_MISMATCH:
if (!libnfs_zdr_u_int(zdrs, &rr->reject_data.mismatch_info.low)) {
return FALSE;
}
if (!libnfs_zdr_u_int(zdrs, &rr->reject_data.mismatch_info.high)) {
return FALSE;
}
return TRUE;
case AUTH_ERROR:
if (!libnfs_zdr_u_int(zdrs, &rr->reject_data.stat)) {
return FALSE;
}
return TRUE;
default:
return TRUE;
}
return FALSE;
}
static bool_t libnfs_rpc_reply_body(struct rpc_context *rpc, ZDR *zdrs, struct reply_body *rmb)
{
if (!libnfs_zdr_u_int(zdrs, &rmb->stat)) {
rpc_set_error(rpc, "libnfs_rpc_reply_body failed to decode "
"STAT");
return FALSE;
}
switch (rmb->stat) {
case MSG_ACCEPTED:
if (!libnfs_accepted_reply(zdrs, &rmb->reply.areply)) {
rpc_set_error(rpc, "libnfs_rpc_reply_body failed to "
"decode ACCEPTED");
return FALSE;
}
return TRUE;
case MSG_DENIED:
if (!libnfs_rejected_reply(zdrs, &rmb->reply.rreply)) {
rpc_set_error(rpc, "libnfs_rpc_reply_body failed to "
"decode DENIED");
return FALSE;
}
return TRUE;
}
rpc_set_error(rpc, "libnfs_rpc_reply_body failed to "
"decode. Neither ACCEPTED nor DENIED");
return FALSE;
}
static bool_t libnfs_rpc_msg(struct rpc_context *rpc, ZDR *zdrs, struct rpc_msg *msg)
{
int ret;
if (!libnfs_zdr_u_int(zdrs, &msg->xid)) {
rpc_set_error(rpc, "libnfs_rpc_msg failed to decode XID");
return FALSE;
}
if (!libnfs_zdr_u_int(zdrs, &msg->direction)) {
rpc_set_error(rpc, "libnfs_rpc_msg failed to decode DIRECTION");
return FALSE;
}
switch (msg->direction) {
case CALL:
ret = libnfs_rpc_call_body(rpc, zdrs, &msg->body.cbody);
if (!ret) {
rpc_set_error(rpc, "libnfs_rpc_msg failed to encode "
"CALL, ret=%d: %s", ret, rpc_get_error(rpc));
}
return ret;
case REPLY:
ret = libnfs_rpc_reply_body(rpc, zdrs, &msg->body.rbody);
if (!ret) {
rpc_set_error(rpc, "libnfs_rpc_msg failed to decode "
"REPLY, ret=%d: %s", ret, rpc_get_error(rpc));
}
return ret;
default:
rpc_set_error(rpc, "libnfs_rpc_msg failed to decode. "
"Neither CALL not REPLY");
return FALSE;
}
}
bool_t libnfs_zdr_callmsg(struct rpc_context *rpc, ZDR *zdrs, struct rpc_msg *msg)
{
return libnfs_rpc_msg(rpc, zdrs, msg);
}
bool_t libnfs_zdr_replymsg(struct rpc_context *rpc, ZDR *zdrs, struct rpc_msg *msg)
{
return libnfs_rpc_msg(rpc, zdrs, msg);
}
struct AUTH *authnone_create(void)
{
struct AUTH *auth;
auth = malloc(sizeof(struct AUTH));
auth->ah_cred.oa_flavor = AUTH_NONE;
auth->ah_cred.oa_length = 0;
auth->ah_cred.oa_base = NULL;
auth->ah_verf.oa_flavor = AUTH_NONE;
auth->ah_verf.oa_length = 0;
auth->ah_verf.oa_base = NULL;
auth->ah_private = NULL;
return auth;
}
struct AUTH *libnfs_authunix_create(const char *host, uint32_t uid, uint32_t gid, uint32_t len, uint32_t *groups)
{
struct AUTH *auth;
int size;
uint32_t *buf;
int idx;
size = 4 + 4 + ((strlen(host) + 3) & ~3) + 4 + 4 + 4 + len * 4;
auth = malloc(sizeof(struct AUTH));
memset(auth, 0x00, sizeof(struct AUTH));
auth->ah_cred.oa_flavor = AUTH_UNIX;
auth->ah_cred.oa_length = size;
auth->ah_cred.oa_base = malloc(size);
memset(auth->ah_cred.oa_base, 0x00, size);
buf = (uint32_t *)auth->ah_cred.oa_base;
idx = 0;
buf[idx++] = htonl(time(NULL));
buf[idx++] = htonl(strlen(host));
memcpy(&buf[2], host, strlen(host));
idx += (strlen(host) + 3) >> 2;
buf[idx++] = htonl(uid);
buf[idx++] = htonl(gid);
buf[idx++] = htonl(len);
while (len-- > 0) {
buf[idx++] = htonl(*groups++);
}
auth->ah_verf.oa_flavor = AUTH_NONE;
auth->ah_verf.oa_length = 0;
auth->ah_verf.oa_base = NULL;
auth->ah_private = NULL;
return auth;
}
struct AUTH *libnfs_authunix_create_default(void)
{
#ifdef WIN32
return libnfs_authunix_create("libnfs", 65534, 65534, 0, NULL);
#else
return libnfs_authunix_create("libnfs", getuid(), getgid(), 0, NULL);
#endif
}
void libnfs_auth_destroy(struct AUTH *auth)
{
if (auth->ah_cred.oa_base) {
free(auth->ah_cred.oa_base);
}
if (auth->ah_verf.oa_base) {
free(auth->ah_verf.oa_base);
}
free(auth);
}
libnfs-libnfs-1.9.8/lib/libnfs.c 0000664 0000000 0000000 00000450155 12557450341 0016470 0 ustar 00root root 0000000 0000000 /*
Copyright (C) 2010 by Ronnie Sahlberg
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, see .
*/
/*
* High level api to nfs filesystems
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef AROS
#include "aros_compat.h"
#endif
#ifdef WIN32
#include "win32_compat.h"
#endif
#ifdef HAVE_UTIME_H
#include
#endif
#ifdef ANDROID
#define statvfs statfs
#endif
#define _GNU_SOURCE
#ifdef HAVE_UNISTD_H
#include
#endif
#ifdef HAVE_SYS_VFS_H
#include