From cdfbc722f4d63d3ed3740cbb549062f712010d90 Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Mon, 9 Jun 2014 13:13:16 -0500 Subject: [PATCH] LU-2675 build: remove liblustre and libsysio Remove the lustre/liblustre and libsysio subdirectories. Signed-off-by: John L. Hammond Change-Id: I53c06b8c76955519a33a7b1292b0d87495105607 Reviewed-on: http://review.whamcloud.com/10657 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Bob Glossman Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin --- build/Rules.in | 4 - libsysio/.gitignore | 5 - libsysio/AUTHORS | 6 - libsysio/COPYING | 502 ------ libsysio/ChangeLog | 31 - libsysio/INSTALL | 229 --- libsysio/Makefile.am | 89 -- libsysio/NEWS | 0 libsysio/README | 66 - libsysio/Rules.make | 18 - libsysio/autogen.sh | 5 - libsysio/compile | 99 -- libsysio/config.guess | 1535 ------------------ libsysio/config.sub | 1773 --------------------- libsysio/configure.ac | 583 ------- libsysio/depcomp | 688 --------- libsysio/dev/stdfd/.gitignore | 1 - libsysio/dev/stdfd/module.mk | 2 - libsysio/dev/stdfd/stdfd.c | 258 ---- libsysio/dev/stdfd/stdfd.h | 50 - libsysio/drivers/incore/.gitignore | 1 - libsysio/drivers/incore/README | 27 - libsysio/drivers/incore/fs_incore.c | 1727 --------------------- libsysio/drivers/incore/fs_incore.h | 48 - libsysio/drivers/incore/module.mk | 2 - libsysio/drivers/native/.gitignore | 1 - libsysio/drivers/native/fs_native.c | 1813 ---------------------- libsysio/drivers/native/fs_native.h | 48 - libsysio/drivers/native/module.mk | 2 - libsysio/drivers/sockets/.gitignore | 1 - libsysio/drivers/sockets/module.mk | 2 - libsysio/drivers/sockets/sockets.c | 633 -------- libsysio/drivers/yod/.gitignore | 1 - libsysio/drivers/yod/fs_yod.c | 1252 --------------- libsysio/drivers/yod/fs_yod.h | 48 - libsysio/drivers/yod/module.mk | 10 - libsysio/include/cplant-yod.h | 69 - libsysio/include/creds.h | 72 - libsysio/include/dev.h | 153 -- libsysio/include/file.h | 146 -- libsysio/include/fs.h | 179 --- libsysio/include/inode.h | 486 ------ libsysio/include/module.mk | 5 - libsysio/include/mount.h | 98 -- libsysio/include/native.h | 255 --- libsysio/include/stddir.h | 67 - libsysio/include/sysio-cmn.h | 226 --- libsysio/include/sysio-symbols.h | 26 - libsysio/include/sysio.h | 301 ---- libsysio/include/xtio.h | 345 ----- libsysio/install-sh | 527 ------- libsysio/misc/gdb-libsysio | 127 -- libsysio/misc/init-env.sh | 40 - libsysio/missing | 376 ----- libsysio/mkinstalldirs | 111 -- libsysio/src/.gitignore | 1 - libsysio/src/access.c | 282 ---- libsysio/src/chdir.c | 278 ---- libsysio/src/chmod.c | 118 -- libsysio/src/chown.c | 127 -- libsysio/src/dev.c | 172 --- libsysio/src/dup.c | 87 -- libsysio/src/fcntl.c | 301 ---- libsysio/src/file.c | 317 ---- libsysio/src/file_hack.c | 421 ----- libsysio/src/fs.c | 162 -- libsysio/src/fsync.c | 82 - libsysio/src/getdirentries.c | 252 --- libsysio/src/init.c | 1103 ------------- libsysio/src/inode.c | 981 ------------ libsysio/src/ioctl.c | 91 -- libsysio/src/ioctx.c | 271 ---- libsysio/src/iowait.c | 95 -- libsysio/src/link.c | 114 -- libsysio/src/lseek.c | 226 --- libsysio/src/mkdir.c | 100 -- libsysio/src/mknod.c | 138 -- libsysio/src/module.mk | 32 - libsysio/src/mount.c | 740 --------- libsysio/src/namei.c | 509 ------ libsysio/src/open.c | 308 ---- libsysio/src/readdir.c | 161 -- libsysio/src/readdir64.c | 10 - libsysio/src/readlink.c | 89 -- libsysio/src/reconcile.c | 356 ----- libsysio/src/rename.c | 190 --- libsysio/src/rmdir.c | 106 -- libsysio/src/rw.c | 1337 ---------------- libsysio/src/stat.c | 286 ---- libsysio/src/stat64.c | 194 --- libsysio/src/statvfs.c | 155 -- libsysio/src/statvfs64.c | 107 -- libsysio/src/stddir.c | 119 -- libsysio/src/stdlib.c | 121 -- libsysio/src/symlink.c | 100 -- libsysio/src/truncate.c | 164 -- libsysio/src/unlink.c | 110 -- libsysio/src/utime.c | 98 -- libsysio/tests/.gitignore | 1 - libsysio/tests/Makefile.am | 114 -- libsysio/tests/README | 185 --- libsysio/tests/drv_init_all.c | 23 - libsysio/tests/gendrvdata.sh | 61 - libsysio/tests/module.mk | 7 - libsysio/tests/startup.c | 65 - libsysio/tests/sysio-run-start.c | 26 - libsysio/tests/test.h | 48 - libsysio/tests/test_chown.c | 143 -- libsysio/tests/test_copy.c | 217 --- libsysio/tests/test_fcntl_lock.c | 145 -- libsysio/tests/test_getcwd.c | 174 --- libsysio/tests/test_link.c | 140 -- libsysio/tests/test_list.c | 212 --- libsysio/tests/test_mkdir.c | 163 -- libsysio/tests/test_mknod.c | 162 -- libsysio/tests/test_path.c | 225 --- libsysio/tests/test_regions.c | 281 ---- libsysio/tests/test_rename.c | 132 -- libsysio/tests/test_stats.c | 189 --- libsysio/tests/test_stddir.c | 171 -- libsysio/tests/test_symlink.c | 140 -- libsysio/tests/test_unlink.c | 165 -- lustre/liblustre/.gitignore | 2 - lustre/liblustre/Makefile.am | 69 - lustre/liblustre/dir.c | 300 ---- lustre/liblustre/file.c | 533 ------- lustre/liblustre/genlib.sh | 114 -- lustre/liblustre/llite_cl.c | 769 --------- lustre/liblustre/llite_lib.c | 413 ----- lustre/liblustre/llite_lib.h | 393 ----- lustre/liblustre/lutil.c | 250 --- lustre/liblustre/lutil.h | 43 - lustre/liblustre/namei.c | 581 ------- lustre/liblustre/rw.c | 320 ---- lustre/liblustre/super.c | 2059 ------------------------- lustre/liblustre/tests/.gitignore | 6 - lustre/liblustre/tests/Makefile.am | 50 - lustre/liblustre/tests/echo_test.c | 299 ---- lustre/liblustre/tests/mpi/.gitignore | 2 - lustre/liblustre/tests/mpi/Makefile.am | 17 - lustre/liblustre/tests/mpi/test_lock_cancel.c | 209 --- lustre/liblustre/tests/recovery_small.c | 407 ----- lustre/liblustre/tests/replay_ost_single.c | 353 ----- lustre/liblustre/tests/replay_single.c | 439 ------ lustre/liblustre/tests/sanity.c | 1578 ------------------- lustre/liblustre/tests/test_common.c | 470 ------ lustre/liblustre/tests/test_common.h | 74 - lustre/tests/Makefile.am | 2 +- lustre/tests/liblustre.sh | 46 - 149 files changed, 1 insertion(+), 39166 deletions(-) delete mode 100644 libsysio/.gitignore delete mode 100644 libsysio/AUTHORS delete mode 100644 libsysio/COPYING delete mode 100644 libsysio/ChangeLog delete mode 100644 libsysio/INSTALL delete mode 100644 libsysio/Makefile.am delete mode 100644 libsysio/NEWS delete mode 100644 libsysio/README delete mode 100644 libsysio/Rules.make delete mode 100755 libsysio/autogen.sh delete mode 100755 libsysio/compile delete mode 100755 libsysio/config.guess delete mode 100755 libsysio/config.sub delete mode 100644 libsysio/configure.ac delete mode 100755 libsysio/depcomp delete mode 100644 libsysio/dev/stdfd/.gitignore delete mode 100644 libsysio/dev/stdfd/module.mk delete mode 100644 libsysio/dev/stdfd/stdfd.c delete mode 100644 libsysio/dev/stdfd/stdfd.h delete mode 100644 libsysio/drivers/incore/.gitignore delete mode 100644 libsysio/drivers/incore/README delete mode 100644 libsysio/drivers/incore/fs_incore.c delete mode 100644 libsysio/drivers/incore/fs_incore.h delete mode 100644 libsysio/drivers/incore/module.mk delete mode 100644 libsysio/drivers/native/.gitignore delete mode 100644 libsysio/drivers/native/fs_native.c delete mode 100644 libsysio/drivers/native/fs_native.h delete mode 100644 libsysio/drivers/native/module.mk delete mode 100644 libsysio/drivers/sockets/.gitignore delete mode 100644 libsysio/drivers/sockets/module.mk delete mode 100644 libsysio/drivers/sockets/sockets.c delete mode 100644 libsysio/drivers/yod/.gitignore delete mode 100644 libsysio/drivers/yod/fs_yod.c delete mode 100644 libsysio/drivers/yod/fs_yod.h delete mode 100644 libsysio/drivers/yod/module.mk delete mode 100644 libsysio/include/cplant-yod.h delete mode 100644 libsysio/include/creds.h delete mode 100644 libsysio/include/dev.h delete mode 100644 libsysio/include/file.h delete mode 100644 libsysio/include/fs.h delete mode 100644 libsysio/include/inode.h delete mode 100644 libsysio/include/module.mk delete mode 100644 libsysio/include/mount.h delete mode 100644 libsysio/include/native.h delete mode 100644 libsysio/include/stddir.h delete mode 100644 libsysio/include/sysio-cmn.h delete mode 100644 libsysio/include/sysio-symbols.h delete mode 100644 libsysio/include/sysio.h delete mode 100644 libsysio/include/xtio.h delete mode 100755 libsysio/install-sh delete mode 100644 libsysio/misc/gdb-libsysio delete mode 100644 libsysio/misc/init-env.sh delete mode 100755 libsysio/missing delete mode 100755 libsysio/mkinstalldirs delete mode 100644 libsysio/src/.gitignore delete mode 100644 libsysio/src/access.c delete mode 100644 libsysio/src/chdir.c delete mode 100644 libsysio/src/chmod.c delete mode 100644 libsysio/src/chown.c delete mode 100644 libsysio/src/dev.c delete mode 100644 libsysio/src/dup.c delete mode 100644 libsysio/src/fcntl.c delete mode 100644 libsysio/src/file.c delete mode 100644 libsysio/src/file_hack.c delete mode 100644 libsysio/src/fs.c delete mode 100644 libsysio/src/fsync.c delete mode 100644 libsysio/src/getdirentries.c delete mode 100644 libsysio/src/init.c delete mode 100644 libsysio/src/inode.c delete mode 100644 libsysio/src/ioctl.c delete mode 100644 libsysio/src/ioctx.c delete mode 100644 libsysio/src/iowait.c delete mode 100644 libsysio/src/link.c delete mode 100644 libsysio/src/lseek.c delete mode 100644 libsysio/src/mkdir.c delete mode 100644 libsysio/src/mknod.c delete mode 100644 libsysio/src/module.mk delete mode 100644 libsysio/src/mount.c delete mode 100644 libsysio/src/namei.c delete mode 100644 libsysio/src/open.c delete mode 100644 libsysio/src/readdir.c delete mode 100644 libsysio/src/readdir64.c delete mode 100644 libsysio/src/readlink.c delete mode 100644 libsysio/src/reconcile.c delete mode 100644 libsysio/src/rename.c delete mode 100644 libsysio/src/rmdir.c delete mode 100644 libsysio/src/rw.c delete mode 100644 libsysio/src/stat.c delete mode 100644 libsysio/src/stat64.c delete mode 100644 libsysio/src/statvfs.c delete mode 100644 libsysio/src/statvfs64.c delete mode 100644 libsysio/src/stddir.c delete mode 100644 libsysio/src/stdlib.c delete mode 100644 libsysio/src/symlink.c delete mode 100644 libsysio/src/truncate.c delete mode 100644 libsysio/src/unlink.c delete mode 100644 libsysio/src/utime.c delete mode 100644 libsysio/tests/.gitignore delete mode 100644 libsysio/tests/Makefile.am delete mode 100644 libsysio/tests/README delete mode 100644 libsysio/tests/drv_init_all.c delete mode 100644 libsysio/tests/gendrvdata.sh delete mode 100644 libsysio/tests/module.mk delete mode 100644 libsysio/tests/startup.c delete mode 100644 libsysio/tests/sysio-run-start.c delete mode 100644 libsysio/tests/test.h delete mode 100644 libsysio/tests/test_chown.c delete mode 100644 libsysio/tests/test_copy.c delete mode 100644 libsysio/tests/test_fcntl_lock.c delete mode 100644 libsysio/tests/test_getcwd.c delete mode 100644 libsysio/tests/test_link.c delete mode 100644 libsysio/tests/test_list.c delete mode 100644 libsysio/tests/test_mkdir.c delete mode 100644 libsysio/tests/test_mknod.c delete mode 100644 libsysio/tests/test_path.c delete mode 100644 libsysio/tests/test_regions.c delete mode 100644 libsysio/tests/test_rename.c delete mode 100644 libsysio/tests/test_stats.c delete mode 100644 libsysio/tests/test_stddir.c delete mode 100644 libsysio/tests/test_symlink.c delete mode 100644 libsysio/tests/test_unlink.c delete mode 100644 lustre/liblustre/.gitignore delete mode 100644 lustre/liblustre/Makefile.am delete mode 100644 lustre/liblustre/dir.c delete mode 100644 lustre/liblustre/file.c delete mode 100755 lustre/liblustre/genlib.sh delete mode 100644 lustre/liblustre/llite_cl.c delete mode 100644 lustre/liblustre/llite_lib.c delete mode 100644 lustre/liblustre/llite_lib.h delete mode 100644 lustre/liblustre/lutil.c delete mode 100644 lustre/liblustre/lutil.h delete mode 100644 lustre/liblustre/namei.c delete mode 100644 lustre/liblustre/rw.c delete mode 100644 lustre/liblustre/super.c delete mode 100644 lustre/liblustre/tests/.gitignore delete mode 100644 lustre/liblustre/tests/Makefile.am delete mode 100644 lustre/liblustre/tests/echo_test.c delete mode 100644 lustre/liblustre/tests/mpi/.gitignore delete mode 100644 lustre/liblustre/tests/mpi/Makefile.am delete mode 100644 lustre/liblustre/tests/mpi/test_lock_cancel.c delete mode 100644 lustre/liblustre/tests/recovery_small.c delete mode 100644 lustre/liblustre/tests/replay_ost_single.c delete mode 100644 lustre/liblustre/tests/replay_single.c delete mode 100644 lustre/liblustre/tests/sanity.c delete mode 100644 lustre/liblustre/tests/test_common.c delete mode 100644 lustre/liblustre/tests/test_common.h delete mode 100644 lustre/tests/liblustre.sh diff --git a/build/Rules.in b/build/Rules.in index 1ac462e..0259bc6 100644 --- a/build/Rules.in +++ b/build/Rules.in @@ -8,10 +8,6 @@ # # and autoMakefile.am: # -# if LIBLUSTRE -# -# endif -# # if MODULES # modulefs_DATA = $(KMODEXT) # endif diff --git a/libsysio/.gitignore b/libsysio/.gitignore deleted file mode 100644 index 5a0f1ce..0000000 --- a/libsysio/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -/aclocal.m4 -/autom4te.cache -/lib -/Makefile.in -/INSTALL diff --git a/libsysio/AUTHORS b/libsysio/AUTHORS deleted file mode 100644 index 0dcc9cd..0000000 --- a/libsysio/AUTHORS +++ /dev/null @@ -1,6 +0,0 @@ -Lee Ward - -Various folks at: - -Cluster File Systems Incorporated. (www.clusterfs.com) -Cray Incorporated (www.cray.com) diff --git a/libsysio/COPYING b/libsysio/COPYING deleted file mode 100644 index 2bb5b6e..0000000 --- a/libsysio/COPYING +++ /dev/null @@ -1,502 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! diff --git a/libsysio/ChangeLog b/libsysio/ChangeLog deleted file mode 100644 index 126c27f..0000000 --- a/libsysio/ChangeLog +++ /dev/null @@ -1,31 +0,0 @@ -Sat Feb 22 10:32:10 EST 2003 - Created ---- - -*Added mount() api call to support sub-mounts. - -*Added rudimentary automounts per the namespace chapter in the "Lustre -Architecture Reference". Note, full URI support is not implemented. See -the README for details. - -Think I have it going for simultaneous 32/64 bit support. Together with -the nagging build for test_stat. - -*Miscellaneous bugs fixed. - ---- -Lee -- Sat Mar 22 15:01:45 EST 2003 - -*Added "incore" file system. An in-memory file system solving boot-strap -and other annoying little chicken-and-the-egg problems. - -*Added support for devices - -*Added support for accessing the pre-opened standard file descriptors 0, 1, -and 2 via the stdfd device driver (major number 0, minor 0, 1, and 2). - ---- -Lee -- Mon Jan 26 11:26:14 EST 2004 - -*Altered the internal interface to pass the xtvec (see .../include/xtio.h) in -order to support strided-io. diff --git a/libsysio/INSTALL b/libsysio/INSTALL deleted file mode 100644 index 54caf7c..0000000 --- a/libsysio/INSTALL +++ /dev/null @@ -1,229 +0,0 @@ -Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software -Foundation, Inc. - - This file is free documentation; the Free Software Foundation gives -unlimited permission to copy, distribute and modify it. - -Basic Installation -================== - - These are generic installation instructions. - - The `configure' shell script attempts to guess correct values for -various system-dependent variables used during compilation. It uses -those values to create a `Makefile' in each directory of the package. -It may also create one or more `.h' files containing system-dependent -definitions. Finally, it creates a shell script `config.status' that -you can run in the future to recreate the current configuration, and a -file `config.log' containing compiler output (useful mainly for -debugging `configure'). - - It can also use an optional file (typically called `config.cache' -and enabled with `--cache-file=config.cache' or simply `-C') that saves -the results of its tests to speed up reconfiguring. (Caching is -disabled by default to prevent problems with accidental use of stale -cache files.) - - If you need to do unusual things to compile the package, please try -to figure out how `configure' could check whether to do them, and mail -diffs or instructions to the address given in the `README' so they can -be considered for the next release. If you are using the cache, and at -some point `config.cache' contains results you don't want to keep, you -may remove or edit it. - - The file `configure.ac' (or `configure.in') is used to create -`configure' by a program called `autoconf'. You only need -`configure.ac' if you want to change it or regenerate `configure' using -a newer version of `autoconf'. - -The simplest way to compile this package is: - - 1. `cd' to the directory containing the package's source code and type - `./configure' to configure the package for your system. If you're - using `csh' on an old version of System V, you might need to type - `sh ./configure' instead to prevent `csh' from trying to execute - `configure' itself. - - Running `configure' takes awhile. While running, it prints some - messages telling which features it is checking for. - - 2. Type `make' to compile the package. - - 3. Optionally, type `make check' to run any self-tests that come with - the package. - - 4. Type `make install' to install the programs and any data files and - documentation. - - 5. You can remove the program binaries and object files from the - source code directory by typing `make clean'. To also remove the - files that `configure' created (so you can compile the package for - a different kind of computer), type `make distclean'. There is - also a `make maintainer-clean' target, but that is intended mainly - for the package's developers. If you use it, you may have to get - all sorts of other programs in order to regenerate files that came - with the distribution. - -Compilers and Options -===================== - - Some systems require unusual options for compilation or linking that -the `configure' script does not know about. Run `./configure --help' -for details on some of the pertinent environment variables. - - You can give `configure' initial values for configuration parameters -by setting variables in the command line or in the environment. Here -is an example: - - ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix - - *Note Defining Variables::, for more details. - -Compiling For Multiple Architectures -==================================== - - You can compile the package for more than one kind of computer at the -same time, by placing the object files for each architecture in their -own directory. To do this, you must use a version of `make' that -supports the `VPATH' variable, such as GNU `make'. `cd' to the -directory where you want the object files and executables to go and run -the `configure' script. `configure' automatically checks for the -source code in the directory that `configure' is in and in `..'. - - If you have to use a `make' that does not support the `VPATH' -variable, you have to compile the package for one architecture at a -time in the source code directory. After you have installed the -package for one architecture, use `make distclean' before reconfiguring -for another architecture. - -Installation Names -================== - - By default, `make install' will install the package's files in -`/usr/local/bin', `/usr/local/man', etc. You can specify an -installation prefix other than `/usr/local' by giving `configure' the -option `--prefix=PATH'. - - You can specify separate installation prefixes for -architecture-specific files and architecture-independent files. If you -give `configure' the option `--exec-prefix=PATH', the package will use -PATH as the prefix for installing programs and libraries. -Documentation and other data files will still use the regular prefix. - - In addition, if you use an unusual directory layout you can give -options like `--bindir=PATH' to specify different values for particular -kinds of files. Run `configure --help' for a list of the directories -you can set and what kinds of files go in them. - - If the package supports it, you can cause programs to be installed -with an extra prefix or suffix on their names by giving `configure' the -option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. - -Optional Features -================= - - Some packages pay attention to `--enable-FEATURE' options to -`configure', where FEATURE indicates an optional part of the package. -They may also pay attention to `--with-PACKAGE' options, where PACKAGE -is something like `gnu-as' or `x' (for the X Window System). The -`README' should mention any `--enable-' and `--with-' options that the -package recognizes. - - For packages that use the X Window System, `configure' can usually -find the X include and library files automatically, but if it doesn't, -you can use the `configure' options `--x-includes=DIR' and -`--x-libraries=DIR' to specify their locations. - -Specifying the System Type -========================== - - There may be some features `configure' cannot figure out -automatically, but needs to determine by the type of machine the package -will run on. Usually, assuming the package is built to be run on the -_same_ architectures, `configure' can figure that out, but if it prints -a message saying it cannot guess the machine type, give it the -`--build=TYPE' option. TYPE can either be a short name for the system -type, such as `sun4', or a canonical name which has the form: - - CPU-COMPANY-SYSTEM - -where SYSTEM can have one of these forms: - - OS KERNEL-OS - - See the file `config.sub' for the possible values of each field. If -`config.sub' isn't included in this package, then this package doesn't -need to know the machine type. - - If you are _building_ compiler tools for cross-compiling, you should -use the `--target=TYPE' option to select the type of system they will -produce code for. - - If you want to _use_ a cross compiler, that generates code for a -platform different from the build platform, you should specify the -"host" platform (i.e., that on which the generated programs will -eventually be run) with `--host=TYPE'. - -Sharing Defaults -================ - - If you want to set default values for `configure' scripts to share, -you can create a site shell script called `config.site' that gives -default values for variables like `CC', `cache_file', and `prefix'. -`configure' looks for `PREFIX/share/config.site' if it exists, then -`PREFIX/etc/config.site' if it exists. Or, you can set the -`CONFIG_SITE' environment variable to the location of the site script. -A warning: not all `configure' scripts look for a site script. - -Defining Variables -================== - - Variables not defined in a site shell script can be set in the -environment passed to `configure'. However, some packages may run -configure again during the build, and the customized values of these -variables may be lost. In order to avoid this problem, you should set -them in the `configure' command line, using `VAR=value'. For example: - - ./configure CC=/usr/local2/bin/gcc - -will cause the specified gcc to be used as the C compiler (unless it is -overridden in the site shell script). - -`configure' Invocation -====================== - - `configure' recognizes the following options to control how it -operates. - -`--help' -`-h' - Print a summary of the options to `configure', and exit. - -`--version' -`-V' - Print the version of Autoconf used to generate the `configure' - script, and exit. - -`--cache-file=FILE' - Enable the cache: use and save the results of the tests in FILE, - traditionally `config.cache'. FILE defaults to `/dev/null' to - disable caching. - -`--config-cache' -`-C' - Alias for `--cache-file=config.cache'. - -`--quiet' -`--silent' -`-q' - Do not print messages saying which checks are being made. To - suppress all normal output, redirect it to `/dev/null' (any error - messages will still be shown). - -`--srcdir=DIR' - Look for the package's source code in directory DIR. Usually - `configure' can determine that directory automatically. - -`configure' also accepts some other, not widely useful, options. Run -`configure --help' for more details. - diff --git a/libsysio/Makefile.am b/libsysio/Makefile.am deleted file mode 100644 index 1262105..0000000 --- a/libsysio/Makefile.am +++ /dev/null @@ -1,89 +0,0 @@ -AUTOMAKE_OPTIONS=1.6 - -if WITH_TESTS -TESTDIR = tests -else -TESTDIR = -endif - -include $(top_srcdir)/src/module.mk -include $(top_srcdir)/include/module.mk -include $(top_srcdir)/tests/module.mk -include $(top_srcdir)/dev/stdfd/module.mk -include $(top_srcdir)/drivers/incore/module.mk -include $(top_srcdir)/drivers/native/module.mk -include $(top_srcdir)/drivers/yod/module.mk -include $(top_srcdir)/drivers/sockets/module.mk - -lib_LIBRARIES = ${LIBBUILD_DIR}/libsysio.a - -if WITH_STDFD_DEV -OPTIONAL_STDFD_SRCS = $(STDFD_SRCS) -else -OPTIONAL_STDFD_SRCS = -endif - -if WITH_INCORE_DRIVER -OPTIONAL_INCORE_SRCS = $(INCORE_SRCS) -else -OPTIONAL_INCORE_SRCS = -endif - -if WITH_NATIVE_DRIVER -OPTIONAL_NATIVE_SRCS = $(NATIVE_SRCS) -else -OPTIONAL_NATIVE_SRCS = -endif - -if WITH_SOCKETS_DRIVER -OPTIONAL_SOCKETS_SRCS = $(SOCKETS_SRCS) -else -OPTIONAL_SOCKETS_SRCS = -endif - -if WITH_CPLANT_YOD -OPTIONAL_YOD_SRCS = $(YOD_SRCS) -else -OPTIONAL_YOD_SRCS = -endif - -if WITH_LUSTRE_HACK -# it would be better that let configure script check this -OPTIONAL_LUSTRE_CFLAGS = -fPIC -endif - -AM_CFLAGS = $(OPTIONAL_LUSTRE_CFLAGS) - -__LIBBUILD_DIR__libsysio_a_SOURCES = \ - $(SRCDIR_SRCS) \ - $(OPTIONAL_STDFD_SRCS) \ - $(OPTIONAL_INCORE_SRCS) \ - $(OPTIONAL_SOCKETS_SRCS) \ - $(OPTIONAL_NATIVE_SRCS) \ - $(OPTIONAL_YOD_SRCS) - -include $(top_srcdir)/Rules.make - -EXTRA_DIST = Rules.make misc/init-env.sh $(TESTS_EXTRA) $(SRCDIR_EXTRA) \ - $(INCLUDE_EXTRA) $(STDFD_EXTRA) $(INCORE_EXTRA) \ - $(SOCKETS_EXTRA) $(NATIVE_EXTRA) $(YOD_EXTRA) - -AM_CPPFLAGS += ${YOD_DRIVER_FLAGS} - -really-clean: testsclean maintainer-clean - -rm -rf autom4te-2.53.cache - -rm -rf .deps - -rm -f Makefile.in - -rm -f compile depcomp INSTALL install-sh missing mkinstalldirs \ - configure aclocal.m4 - -rm -f config.guess config.sub - -rm -rf $(LIBBUILD_DIR) - -rm -f libsysio*.tar.gz - cd $(TESTDIR); rm -rf Makefile Makefile.in .deps - -tests: $(lib_LIBRARIES) FORCE - cd $(TESTDIR); ${MAKE} -testsclean: FORCE - cd $(TESTDIR); ${MAKE} clean -clean: testsclean clean-am -FORCE: diff --git a/libsysio/NEWS b/libsysio/NEWS deleted file mode 100644 index e69de29..0000000 diff --git a/libsysio/README b/libsysio/README deleted file mode 100644 index 76b9b97..0000000 --- a/libsysio/README +++ /dev/null @@ -1,66 +0,0 @@ -Build ------ - -To bootstrap configuration: - -sh autogen.sh -./configure [options] - -Without the supported "--with" options only the core sysio library is -built. - -Option --with-native-driver=yes will cause the "native" host name space test -driver to be enabled and made available in drivers/native/libsysio_native.a -when built. This is set by default; Use "no" to disable. - -Option --with-tests=yes will cause the test programs in the tests directory -to be enabled. This is set by default; Use "no" to disable. - -Option --with-automount= will cause automount support -to be included. If is not supplied, a default value -of ".mount" will be used, matching the Lustre documentation. - -To build: - -Just `make' it. - -Automounts ----------- - -For a full description of this see the "Lustre Book" at: - - -In short, though, whenever a component is being looked up in a directory and -that directory has the "set-UID" bit set, then the directory is -searched for a special file. By default, that file is called ".mount" but -you may set it to any name using the --with-automount option described -earlier. - -If the content of that file has something formatted, exactly: - -: - -Then the description is mounted on the directory containing the -special automount file and being used as the parent in the lookup. If the -mount is successful, the parent is replaced with the newly mounted directory -and processing continues. If the mount fails, or the automount file -does not exist or cannot be read, everything continues as though the operation -had never been attempted. - -File systems, or volumes, or file-sets, or whatever they are called, that -have been automounted may also be automatically unmounted when resource -is required. They are not on a timer, unless the file system driver implements -one for them. They just disappear as resource is needed elsewhere. As they -were automatically mounted to begin with, they should re-establish as needed, -transparently. - -REDSTORM --------- - -The following works for me: - -#!/bin/sh - -export CFLAGS="-DREDSTORM -nostdinc -isystem /home/lee/REDSTORM/catamount/computeincs/i386 -isystem /home/lee/REDSTORM/catamount/include -g -W -Wall -ansi" - -sh configure --with-autmount=".mount" --with-native=yes --with-incore-yes --with-stdfd=yes --with-tests=yes diff --git a/libsysio/Rules.make b/libsysio/Rules.make deleted file mode 100644 index e69c6a2..0000000 --- a/libsysio/Rules.make +++ /dev/null @@ -1,18 +0,0 @@ -if WITH_STDFD_DEV -STDFD_DEV_CPPFLAGS =-DSTDFD_DEV=1 -I$(top_srcdir)/dev/stdfd -else -STFD_DEV_CPPFLAGS = -endif - -if WITH_SOCKETS_DRIVER -SOCKETS_CPPFLAGS=-DWITH_SOCKETS=1 -else -SOCKETS_CPPFLAGS= -endif - -DEV_CPPFLAGS = $(STDFD_DEV_CPPFLAGS) - -AM_CPPFLAGS = \ - $(TRACING) \ - $(AUTOMOUNT) $(ZERO_SUM_MEMORY) $(DEV_CPPFLAGS) $(SOCKETS_CPPFLAGS) \ - $(DEFER_INIT_CWD) $(SYSIO_LABEL_NAMES) -I$(top_srcdir)/include diff --git a/libsysio/autogen.sh b/libsysio/autogen.sh deleted file mode 100755 index fb2b383..0000000 --- a/libsysio/autogen.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -${ACLOCAL:-aclocal} && -${AUTOMAKE:-automake} --add-missing --copy && -${AUTOCONF:-autoconf} diff --git a/libsysio/compile b/libsysio/compile deleted file mode 100755 index 9bb997a..0000000 --- a/libsysio/compile +++ /dev/null @@ -1,99 +0,0 @@ -#! /bin/sh - -# Wrapper for compilers which do not understand `-c -o'. - -# Copyright 1999, 2000 Free Software Foundation, Inc. -# Written by Tom Tromey . -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, 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, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Usage: -# compile PROGRAM [ARGS]... -# `-o FOO.o' is removed from the args passed to the actual compile. - -prog=$1 -shift - -ofile= -cfile= -args= -while test $# -gt 0; do - case "$1" in - -o) - # configure might choose to run compile as `compile cc -o foo foo.c'. - # So we do something ugly here. - ofile=$2 - shift - case "$ofile" in - *.o | *.obj) - ;; - *) - args="$args -o $ofile" - ofile= - ;; - esac - ;; - *.c) - cfile=$1 - args="$args $1" - ;; - *) - args="$args $1" - ;; - esac - shift -done - -if test -z "$ofile" || test -z "$cfile"; then - # If no `-o' option was seen then we might have been invoked from a - # pattern rule where we don't need one. That is ok -- this is a - # normal compilation that the losing compiler can handle. If no - # `.c' file was seen then we are probably linking. That is also - # ok. - exec "$prog" $args -fi - -# Name of file we expect compiler to create. -cofile=`echo $cfile | sed -e 's|^.*/||' -e 's/\.c$/.o/'` - -# Create the lock directory. -# Note: use `[/.-]' here to ensure that we don't use the same name -# that we are using for the .o file. Also, base the name on the expected -# object file name, since that is what matters with a parallel build. -lockdir=`echo $cofile | sed -e 's|[/.-]|_|g'`.d -while true; do - if mkdir $lockdir > /dev/null 2>&1; then - break - fi - sleep 1 -done -# FIXME: race condition here if user kills between mkdir and trap. -trap "rmdir $lockdir; exit 1" 1 2 15 - -# Run the compile. -"$prog" $args -status=$? - -if test -f "$cofile"; then - mv "$cofile" "$ofile" -fi - -rmdir $lockdir -exit $status diff --git a/libsysio/config.guess b/libsysio/config.guess deleted file mode 100755 index 0e71611..0000000 --- a/libsysio/config.guess +++ /dev/null @@ -1,1535 +0,0 @@ -#! /bin/sh -# Attempt to guess a canonical system name. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, -# 2011 Free Software Foundation, Inc. - -timestamp='2011-11-11' - -# This file is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is 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, write to the Free Software -# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA -# 02110-1301, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - - -# Originally written by Per Bothner. Please send patches (context -# diff format) to and include a ChangeLog -# entry. -# -# This script attempts to guess a canonical system name similar to -# config.sub. If it succeeds, it prints the system name on stdout, and -# exits with 0. Otherwise, it exits with 1. -# -# You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] - -Output the configuration name of the system \`$me' is run on. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.guess ($timestamp) - -Originally written by Per Bothner. -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, -2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free -Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit ;; - --version | -v ) - echo "$version" ; exit ;; - --help | --h* | -h ) - echo "$usage"; exit ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" >&2 - exit 1 ;; - * ) - break ;; - esac -done - -if test $# != 0; then - echo "$me: too many arguments$help" >&2 - exit 1 -fi - -trap 'exit 1' 1 2 15 - -# CC_FOR_BUILD -- compiler used by this script. Note that the use of a -# compiler to aid in system detection is discouraged as it requires -# temporary files to be created and, as you can see below, it is a -# headache to deal with in a portable fashion. - -# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still -# use `HOST_CC' if defined, but it is deprecated. - -# Portable tmp directory creation inspired by the Autoconf team. - -set_cc_for_build=' -trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; -trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; -: ${TMPDIR=/tmp} ; - { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || - { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || - { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || - { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; -dummy=$tmp/dummy ; -tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; -case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int x;" > $dummy.c ; - for c in cc gcc c89 c99 ; do - if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then - CC_FOR_BUILD="$c"; break ; - fi ; - done ; - if test x"$CC_FOR_BUILD" = x ; then - CC_FOR_BUILD=no_compiler_found ; - fi - ;; - ,,*) CC_FOR_BUILD=$CC ;; - ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac ; set_cc_for_build= ;' - -# This is needed to find uname on a Pyramid OSx when run in the BSD universe. -# (ghazi@noc.rutgers.edu 1994-08-24) -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then - PATH=$PATH:/.attbin ; export PATH -fi - -UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown -UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown -UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown -UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown - -# Detect uclibc systems. - -LIBC="gnu" -if [ -f /usr/include/bits/uClibc_config.h ] -then - LIBC=uclibc - if [ -n `grep "#define __UCLIBC_CONFIG_VERSION__" /usr/include/bits/uClibc_config.h` ] - then - UCLIBC_SUBVER=`sed -n "/#define __UCLIBC_CONFIG_VERSION__ /s///p" /usr/include/bits/uClibc_config.h` - LIBC=$LIBC$UCLIBC_SUBVER - fi -fi - -# Note: order is significant - the case branches are not exclusive. - -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in - *:NetBSD:*:*) - # NetBSD (nbsd) targets should (where applicable) match one or - # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, - # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently - # switched to ELF, *-*-netbsd* would select the old - # object file format. This provides both forward - # compatibility and a consistent mechanism for selecting the - # object file format. - # - # Note: NetBSD doesn't particularly care about the vendor - # portion of the name. We always set it to "unknown". - sysctl="sysctl -n hw.machine_arch" - UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ - /usr/sbin/$sysctl 2>/dev/null || echo unknown)` - case "${UNAME_MACHINE_ARCH}" in - armeb) machine=armeb-unknown ;; - arm*) machine=arm-unknown ;; - sh3el) machine=shl-unknown ;; - sh3eb) machine=sh-unknown ;; - sh5el) machine=sh5le-unknown ;; - *) machine=${UNAME_MACHINE_ARCH}-unknown ;; - esac - # The Operating System including object format, if it has switched - # to ELF recently, or will in the future. - case "${UNAME_MACHINE_ARCH}" in - arm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval $set_cc_for_build - if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep -q __ELF__ - then - # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). - # Return netbsd for either. FIX? - os=netbsd - else - os=netbsdelf - fi - ;; - *) - os=netbsd - ;; - esac - # The OS release - # Debian GNU/NetBSD machines have a different userland, and - # thus, need a distinct triplet. However, they do not need - # kernel version information, so it can be replaced with a - # suitable tag, in the style of linux-gnu. - case "${UNAME_VERSION}" in - Debian*) - release='-gnu' - ;; - *) - release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` - ;; - esac - # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: - # contains redundant information, the shorter form: - # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}" - exit ;; - *:OpenBSD:*:*) - UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} - exit ;; - *:ekkoBSD:*:*) - echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} - exit ;; - *:SolidBSD:*:*) - echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} - exit ;; - macppc:MirBSD:*:*) - echo powerpc-unknown-mirbsd${UNAME_RELEASE} - exit ;; - *:MirBSD:*:*) - echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} - exit ;; - alpha:OSF1:*:*) - case $UNAME_RELEASE in - *4.0) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` - ;; - *5.*) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` - ;; - esac - # According to Compaq, /usr/sbin/psrinfo has been available on - # OSF/1 and Tru64 systems produced since 1995. I hope that - # covers most systems running today. This code pipes the CPU - # types through head -n 1, so we only detect the type of CPU 0. - ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` - case "$ALPHA_CPU_TYPE" in - "EV4 (21064)") - UNAME_MACHINE="alpha" ;; - "EV4.5 (21064)") - UNAME_MACHINE="alpha" ;; - "LCA4 (21066/21068)") - UNAME_MACHINE="alpha" ;; - "EV5 (21164)") - UNAME_MACHINE="alphaev5" ;; - "EV5.6 (21164A)") - UNAME_MACHINE="alphaev56" ;; - "EV5.6 (21164PC)") - UNAME_MACHINE="alphapca56" ;; - "EV5.7 (21164PC)") - UNAME_MACHINE="alphapca57" ;; - "EV6 (21264)") - UNAME_MACHINE="alphaev6" ;; - "EV6.7 (21264A)") - UNAME_MACHINE="alphaev67" ;; - "EV6.8CB (21264C)") - UNAME_MACHINE="alphaev68" ;; - "EV6.8AL (21264B)") - UNAME_MACHINE="alphaev68" ;; - "EV6.8CX (21264D)") - UNAME_MACHINE="alphaev68" ;; - "EV6.9A (21264/EV69A)") - UNAME_MACHINE="alphaev69" ;; - "EV7 (21364)") - UNAME_MACHINE="alphaev7" ;; - "EV7.9 (21364A)") - UNAME_MACHINE="alphaev79" ;; - esac - # A Pn.n version is a patched version. - # A Vn.n version is a released version. - # A Tn.n version is a released field test version. - # A Xn.n version is an unreleased experimental baselevel. - # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - # Reset EXIT trap before exiting to avoid spurious non-zero exit code. - exitcode=$? - trap '' 0 - exit $exitcode ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit ;; - Amiga*:UNIX_System_V:4.0:*) - echo m68k-unknown-sysv4 - exit ;; - *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos - exit ;; - *:[Mm]orph[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-morphos - exit ;; - *:OS/390:*:*) - echo i370-ibm-openedition - exit ;; - *:z/VM:*:*) - echo s390-ibm-zvmoe - exit ;; - *:OS400:*:*) - echo powerpc-ibm-os400 - exit ;; - arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} - exit ;; - arm:riscos:*:*|arm:RISCOS:*:*) - echo arm-unknown-riscos - exit ;; - SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) - echo hppa1.1-hitachi-hiuxmpp - exit ;; - Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) - # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. - if test "`(/bin/universe) 2>/dev/null`" = att ; then - echo pyramid-pyramid-sysv3 - else - echo pyramid-pyramid-bsd - fi - exit ;; - NILE*:*:*:dcosx) - echo pyramid-pyramid-svr4 - exit ;; - DRS?6000:unix:4.0:6*) - echo sparc-icl-nx6 - exit ;; - DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) - case `/usr/bin/uname -p` in - sparc) echo sparc-icl-nx7; exit ;; - esac ;; - s390x:SunOS:*:*) - echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) - echo i386-pc-auroraux${UNAME_RELEASE} - exit ;; - i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) - eval $set_cc_for_build - SUN_ARCH="i386" - # If there is a compiler, see if it is configured for 64-bit objects. - # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. - # This test works for both compilers. - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then - if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null - then - SUN_ARCH="x86_64" - fi - fi - echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:6*:*) - # According to config.sub, this is the proper way to canonicalize - # SunOS6. Hard to guess exactly what SunOS6 will be like, but - # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:*:*) - case "`/usr/bin/arch -k`" in - Series*|S4*) - UNAME_RELEASE=`uname -v` - ;; - esac - # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` - exit ;; - sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} - exit ;; - sun*:*:4.2BSD:*) - UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 - case "`/bin/arch`" in - sun3) - echo m68k-sun-sunos${UNAME_RELEASE} - ;; - sun4) - echo sparc-sun-sunos${UNAME_RELEASE} - ;; - esac - exit ;; - aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} - exit ;; - # The situation for MiNT is a little confusing. The machine name - # can be virtually everything (everything which is not - # "atarist" or "atariste" at least should have a processor - # > m68000). The system name ranges from "MiNT" over "FreeMiNT" - # to the lowercase version "mint" (or "freemint"). Finally - # the system name "TOS" denotes a system which is actually not - # MiNT. But MiNT is downward compatible to TOS, so this should - # be no problem. - atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit ;; - hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit ;; - *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} - exit ;; - m68k:machten:*:*) - echo m68k-apple-machten${UNAME_RELEASE} - exit ;; - powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} - exit ;; - RISC*:Mach:*:*) - echo mips-dec-mach_bsd4.3 - exit ;; - RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} - exit ;; - VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} - exit ;; - 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} - exit ;; - mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c -#ifdef __cplusplus -#include /* for printf() prototype */ - int main (int argc, char *argv[]) { -#else - int main (argc, argv) int argc; char *argv[]; { -#endif - #if defined (host_mips) && defined (MIPSEB) - #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); - #endif - #endif - exit (-1); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c && - dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && - SYSTEM_NAME=`$dummy $dummyarg` && - { echo "$SYSTEM_NAME"; exit; } - echo mips-mips-riscos${UNAME_RELEASE} - exit ;; - Motorola:PowerMAX_OS:*:*) - echo powerpc-motorola-powermax - exit ;; - Motorola:*:4.3:PL8-*) - echo powerpc-harris-powermax - exit ;; - Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) - echo powerpc-harris-powermax - exit ;; - Night_Hawk:Power_UNIX:*:*) - echo powerpc-harris-powerunix - exit ;; - m88k:CX/UX:7*:*) - echo m88k-harris-cxux7 - exit ;; - m88k:*:4*:R4*) - echo m88k-motorola-sysv4 - exit ;; - m88k:*:3*:R3*) - echo m88k-motorola-sysv3 - exit ;; - AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] - then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] - then - echo m88k-dg-dgux${UNAME_RELEASE} - else - echo m88k-dg-dguxbcs${UNAME_RELEASE} - fi - else - echo i586-dg-dgux${UNAME_RELEASE} - fi - exit ;; - M88*:DolphinOS:*:*) # DolphinOS (SVR3) - echo m88k-dolphin-sysv3 - exit ;; - M88*:*:R3*:*) - # Delta 88k system running SVR3 - echo m88k-motorola-sysv3 - exit ;; - XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) - echo m88k-tektronix-sysv3 - exit ;; - Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) - echo m68k-tektronix-bsd - exit ;; - *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` - exit ;; - ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id - exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' - i*86:AIX:*:*) - echo i386-ibm-aix - exit ;; - ia64:AIX:*:*) - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} - exit ;; - *:AIX:2:3) - if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - - main() - { - if (!__power_pc()) - exit(1); - puts("powerpc-ibm-aix3.2.5"); - exit(0); - } -EOF - if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` - then - echo "$SYSTEM_NAME" - else - echo rs6000-ibm-aix3.2.5 - fi - elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then - echo rs6000-ibm-aix3.2.4 - else - echo rs6000-ibm-aix3.2 - fi - exit ;; - *:AIX:*:[4567]) - IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` - if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then - IBM_ARCH=rs6000 - else - IBM_ARCH=powerpc - fi - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} - exit ;; - *:AIX:*:*) - echo rs6000-ibm-aix - exit ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) - echo romp-ibm-bsd4.4 - exit ;; - ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to - exit ;; # report: romp-ibm BSD 4.3 - *:BOSX:*:*) - echo rs6000-bull-bosx - exit ;; - DPX/2?00:B.O.S.:*:*) - echo m68k-bull-sysv3 - exit ;; - 9000/[34]??:4.3bsd:1.*:*) - echo m68k-hp-bsd - exit ;; - hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) - echo m68k-hp-bsd4.4 - exit ;; - 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; - 9000/[678][0-9][0-9]) - if [ -x /usr/bin/getconf ]; then - sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` - sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 - 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; - '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 - esac ;; - esac - fi - if [ "${HP_ARCH}" = "" ]; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - - #define _HPUX_SOURCE - #include - #include - - int main () - { - #if defined(_SC_KERNEL_BITS) - long bits = sysconf(_SC_KERNEL_BITS); - #endif - long cpu = sysconf (_SC_CPU_VERSION); - - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1"); break; - case CPU_PA_RISC2_0: - #if defined(_SC_KERNEL_BITS) - switch (bits) - { - case 64: puts ("hppa2.0w"); break; - case 32: puts ("hppa2.0n"); break; - default: puts ("hppa2.0"); break; - } break; - #else /* !defined(_SC_KERNEL_BITS) */ - puts ("hppa2.0"); break; - #endif - default: puts ("hppa1.0"); break; - } - exit (0); - } -EOF - (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` - test -z "$HP_ARCH" && HP_ARCH=hppa - fi ;; - esac - if [ ${HP_ARCH} = "hppa2.0w" ] - then - eval $set_cc_for_build - - # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating - # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler - # generating 64-bit code. GNU and HP use different nomenclature: - # - # $ CC_FOR_BUILD=cc ./config.guess - # => hppa2.0w-hp-hpux11.23 - # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess - # => hppa64-hp-hpux11.23 - - if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | - grep -q __LP64__ - then - HP_ARCH="hppa2.0w" - else - HP_ARCH="hppa64" - fi - fi - echo ${HP_ARCH}-hp-hpux${HPUX_REV} - exit ;; - ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} - exit ;; - 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - int - main () - { - long cpu = sysconf (_SC_CPU_VERSION); - /* The order matters, because CPU_IS_HP_MC68K erroneously returns - true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct - results, however. */ - if (CPU_IS_PA_RISC (cpu)) - { - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; - case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; - default: puts ("hppa-hitachi-hiuxwe2"); break; - } - } - else if (CPU_IS_HP_MC68K (cpu)) - puts ("m68k-hitachi-hiuxwe2"); - else puts ("unknown-hitachi-hiuxwe2"); - exit (0); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && - { echo "$SYSTEM_NAME"; exit; } - echo unknown-hitachi-hiuxwe2 - exit ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) - echo hppa1.1-hp-bsd - exit ;; - 9000/8??:4.3bsd:*:*) - echo hppa1.0-hp-bsd - exit ;; - *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) - echo hppa1.0-hp-mpeix - exit ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) - echo hppa1.1-hp-osf - exit ;; - hp8??:OSF1:*:*) - echo hppa1.0-hp-osf - exit ;; - i*86:OSF1:*:*) - if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk - else - echo ${UNAME_MACHINE}-unknown-osf1 - fi - exit ;; - parisc*:Lites*:*:*) - echo hppa1.1-hp-lites - exit ;; - C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) - echo c1-convex-bsd - exit ;; - C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit ;; - C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) - echo c34-convex-bsd - exit ;; - C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) - echo c38-convex-bsd - exit ;; - C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) - echo c4-convex-bsd - exit ;; - CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ - | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ - -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ - -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - *:UNICOS/mp:*:*) - echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) - FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; - 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` - echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; - i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} - exit ;; - sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} - exit ;; - *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} - exit ;; - *:FreeBSD:*:*) - UNAME_PROCESSOR=`/usr/bin/uname -p` - case ${UNAME_PROCESSOR} in - amd64) - echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; - *) - echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; - esac - exit ;; - i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin - exit ;; - *:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 - exit ;; - i*:MSYS*:*) - echo ${UNAME_MACHINE}-pc-msys - exit ;; - i*:windows32*:*) - # uname -m includes "-pc" on this system. - echo ${UNAME_MACHINE}-mingw32 - exit ;; - i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 - exit ;; - *:Interix*:*) - case ${UNAME_MACHINE} in - x86) - echo i586-pc-interix${UNAME_RELEASE} - exit ;; - authenticamd | genuineintel | EM64T) - echo x86_64-unknown-interix${UNAME_RELEASE} - exit ;; - IA64) - echo ia64-unknown-interix${UNAME_RELEASE} - exit ;; - esac ;; - [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) - echo i${UNAME_MACHINE}-pc-mks - exit ;; - 8664:Windows_NT:*) - echo x86_64-pc-mks - exit ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i586-pc-interix - exit ;; - i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin - exit ;; - amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) - echo x86_64-unknown-cygwin - exit ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin - exit ;; - prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - *:GNU:*:*) - # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` - exit ;; - *:GNU/*:*:*) - # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu - exit ;; - i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix - exit ;; - alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in - EV5) UNAME_MACHINE=alphaev5 ;; - EV56) UNAME_MACHINE=alphaev56 ;; - PCA56) UNAME_MACHINE=alphapca56 ;; - PCA57) UNAME_MACHINE=alphapca56 ;; - EV6) UNAME_MACHINE=alphaev6 ;; - EV67) UNAME_MACHINE=alphaev67 ;; - EV68*) UNAME_MACHINE=alphaev68 ;; - esac - objdump --private-headers /bin/sh | grep -q ld.so.1 - if test "$?" = 0 ; then LIBC="gnulibc1" ; else LIBC="" ; fi - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - arm*:Linux:*:*) - eval $set_cc_for_build - if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep -q __ARM_EABI__ - then - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - else - if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep -q __ARM_PCS_VFP - then - echo ${UNAME_MACHINE}-unknown-linux-gnueabi - else - echo ${UNAME_MACHINE}-unknown-linux-gnueabihf - fi - fi - exit ;; - avr32*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - cris:Linux:*:*) - echo cris-axis-linux-${LIBC} - exit ;; - crisv32:Linux:*:*) - echo crisv32-axis-linux-${LIBC} - exit ;; - frv:Linux:*:*) - echo frv-unknown-linux-${LIBC} - exit ;; - hexagon:Linux:*:*) - echo hexagon-unknown-linux-${LIBC} - exit ;; - i*86:Linux:*:*) - LIBC=gnu - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #ifdef __dietlibc__ - LIBC=dietlibc - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` - echo "${UNAME_MACHINE}-pc-linux-${LIBC}" - exit ;; - ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - m32r*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - mips:Linux:*:* | mips64:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #undef CPU - #undef ${UNAME_MACHINE} - #undef ${UNAME_MACHINE}el - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=${UNAME_MACHINE}el - #else - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=${UNAME_MACHINE} - #else - CPU= - #endif - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } - ;; - or32:Linux:*:*) - echo or32-unknown-linux-${LIBC} - exit ;; - padre:Linux:*:*) - echo sparc-unknown-linux-${LIBC} - exit ;; - parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-${LIBC} - exit ;; - parisc:Linux:*:* | hppa:Linux:*:*) - # Look for CPU level - case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; - PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; - *) echo hppa-unknown-linux-${LIBC} ;; - esac - exit ;; - ppc64:Linux:*:*) - echo powerpc64-unknown-linux-${LIBC} - exit ;; - ppc:Linux:*:*) - echo powerpc-unknown-linux-${LIBC} - exit ;; - s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux - exit ;; - sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - tile*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - vax:Linux:*:*) - echo ${UNAME_MACHINE}-dec-linux-${LIBC} - exit ;; - x86_64:Linux:*:* | [lk]1om:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - xtensa*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - i*86:DYNIX/ptx:4*:*) - # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. - # earlier versions are messed up and put the nodename in both - # sysname and nodename. - echo i386-sequent-sysv4 - exit ;; - i*86:UNIX_SV:4.2MP:2.*) - # Unixware is an offshoot of SVR4, but it has its own version - # number series starting with 2... - # I am not positive that other SVR4 systems won't match this, - # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} - exit ;; - i*86:OS/2:*:*) - # If we were able to find `uname', then EMX Unix compatibility - # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx - exit ;; - i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop - exit ;; - i*86:atheos:*:*) - echo ${UNAME_MACHINE}-unknown-atheos - exit ;; - i*86:syllable:*:*) - echo ${UNAME_MACHINE}-pc-syllable - exit ;; - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} - exit ;; - i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp - exit ;; - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` - if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} - else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} - fi - exit ;; - i*86:*:5:[678]*) - # UnixWare 7.x, OpenUNIX and OpenServer 6. - case `/bin/uname -X | grep "^Machine"` in - *486*) UNAME_MACHINE=i486 ;; - *Pentium) UNAME_MACHINE=i586 ;; - *Pent*|*Celeron) UNAME_MACHINE=i686 ;; - esac - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} - exit ;; - i*86:*:3.2:*) - if test -f /usr/options/cb.name; then - UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then - UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` - (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 - (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ - && UNAME_MACHINE=i586 - (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ - && UNAME_MACHINE=i686 - (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ - && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL - else - echo ${UNAME_MACHINE}-pc-sysv32 - fi - exit ;; - pc:*:*:*) - # Left here for compatibility: - # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i586. - # Note: whatever this is, it MUST be the same as what config.sub - # prints for the "djgpp" host, or else GDB configury will decide that - # this is a cross-build. - echo i586-pc-msdosdjgpp - exit ;; - Intel:Mach:3*:*) - echo i386-pc-mach3 - exit ;; - paragon:*:*:*) - echo i860-intel-osf1 - exit ;; - i860:*:4.*:*) # i860-SVR4 - if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 - else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 - fi - exit ;; - mini*:CTIX:SYS*5:*) - # "miniframe" - echo m68010-convergent-sysv - exit ;; - mc68k:UNIX:SYSTEM5:3.51m) - echo m68k-convergent-sysv - exit ;; - M680?0:D-NIX:5.3:*) - echo m68k-diab-dnix - exit ;; - M68*:*:R3V[5678]*:*) - test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; - 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) - OS_REL='' - test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; - 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4; exit; } ;; - NCR*:*:4.2:* | MPRAS*:*:4.2:*) - OS_REL='.3' - test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } - /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; - m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} - exit ;; - mc68030:UNIX_System_V:4.*:*) - echo m68k-atari-sysv4 - exit ;; - TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} - exit ;; - rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} - exit ;; - PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) - echo powerpc-unknown-lynxos${UNAME_RELEASE} - exit ;; - SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} - exit ;; - RM*:ReliantUNIX-*:*:*) - echo mips-sni-sysv4 - exit ;; - RM*:SINIX-*:*:*) - echo mips-sni-sysv4 - exit ;; - *:SINIX-*:*:*) - if uname -p 2>/dev/null >/dev/null ; then - UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 - else - echo ns32k-sni-sysv - fi - exit ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says - echo i586-unisys-sysv4 - exit ;; - *:UNIX_System_V:4*:FTX*) - # From Gerald Hewes . - # How about differentiating between stratus architectures? -djm - echo hppa1.1-stratus-sysv4 - exit ;; - *:*:*:FTX*) - # From seanf@swdc.stratus.com. - echo i860-stratus-sysv4 - exit ;; - i*86:VOS:*:*) - # From Paul.Green@stratus.com. - echo ${UNAME_MACHINE}-stratus-vos - exit ;; - *:VOS:*:*) - # From Paul.Green@stratus.com. - echo hppa1.1-stratus-vos - exit ;; - mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} - exit ;; - news*:NEWS-OS:6*:*) - echo mips-sony-newsos6 - exit ;; - R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) - if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} - else - echo mips-unknown-sysv${UNAME_RELEASE} - fi - exit ;; - BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. - echo powerpc-be-beos - exit ;; - BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. - echo powerpc-apple-beos - exit ;; - BePC:BeOS:*:*) # BeOS running on Intel PC compatible. - echo i586-pc-beos - exit ;; - BePC:Haiku:*:*) # Haiku running on Intel PC compatible. - echo i586-pc-haiku - exit ;; - SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} - exit ;; - SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} - exit ;; - SX-6:SUPER-UX:*:*) - echo sx6-nec-superux${UNAME_RELEASE} - exit ;; - SX-7:SUPER-UX:*:*) - echo sx7-nec-superux${UNAME_RELEASE} - exit ;; - SX-8:SUPER-UX:*:*) - echo sx8-nec-superux${UNAME_RELEASE} - exit ;; - SX-8R:SUPER-UX:*:*) - echo sx8r-nec-superux${UNAME_RELEASE} - exit ;; - Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} - exit ;; - *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} - exit ;; - *:Darwin:*:*) - UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - case $UNAME_PROCESSOR in - i386) - eval $set_cc_for_build - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then - if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null - then - UNAME_PROCESSOR="x86_64" - fi - fi ;; - unknown) UNAME_PROCESSOR=powerpc ;; - esac - echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} - exit ;; - *:procnto*:*:* | *:QNX:[0123456789]*:*) - UNAME_PROCESSOR=`uname -p` - if test "$UNAME_PROCESSOR" = "x86"; then - UNAME_PROCESSOR=i386 - UNAME_MACHINE=pc - fi - echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} - exit ;; - *:QNX:*:4*) - echo i386-pc-qnx - exit ;; - NEO-?:NONSTOP_KERNEL:*:*) - echo neo-tandem-nsk${UNAME_RELEASE} - exit ;; - NSE-?:NONSTOP_KERNEL:*:*) - echo nse-tandem-nsk${UNAME_RELEASE} - exit ;; - NSR-?:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} - exit ;; - *:NonStop-UX:*:*) - echo mips-compaq-nonstopux - exit ;; - BS2000:POSIX*:*:*) - echo bs2000-siemens-sysv - exit ;; - DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} - exit ;; - *:Plan9:*:*) - # "uname -m" is not consistent, so use $cputype instead. 386 - # is converted to i386 for consistency with other x86 - # operating systems. - if test "$cputype" = "386"; then - UNAME_MACHINE=i386 - else - UNAME_MACHINE="$cputype" - fi - echo ${UNAME_MACHINE}-unknown-plan9 - exit ;; - *:TOPS-10:*:*) - echo pdp10-unknown-tops10 - exit ;; - *:TENEX:*:*) - echo pdp10-unknown-tenex - exit ;; - KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) - echo pdp10-dec-tops20 - exit ;; - XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) - echo pdp10-xkl-tops20 - exit ;; - *:TOPS-20:*:*) - echo pdp10-unknown-tops20 - exit ;; - *:ITS:*:*) - echo pdp10-unknown-its - exit ;; - SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} - exit ;; - *:DragonFly:*:*) - echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit ;; - *:*VMS:*:*) - UNAME_MACHINE=`(uname -p) 2>/dev/null` - case "${UNAME_MACHINE}" in - A*) echo alpha-dec-vms ; exit ;; - I*) echo ia64-dec-vms ; exit ;; - V*) echo vax-dec-vms ; exit ;; - esac ;; - *:XENIX:*:SysV) - echo i386-pc-xenix - exit ;; - i*86:skyos:*:*) - echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' - exit ;; - i*86:rdos:*:*) - echo ${UNAME_MACHINE}-pc-rdos - exit ;; - i*86:AROS:*:*) - echo ${UNAME_MACHINE}-pc-aros - exit ;; -esac - -#echo '(No uname command or uname output not recognized.)' 1>&2 -#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 - -eval $set_cc_for_build -cat >$dummy.c < -# include -#endif -main () -{ -#if defined (sony) -#if defined (MIPSEB) - /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, - I don't know.... */ - printf ("mips-sony-bsd\n"); exit (0); -#else -#include - printf ("m68k-sony-newsos%s\n", -#ifdef NEWSOS4 - "4" -#else - "" -#endif - ); exit (0); -#endif -#endif - -#if defined (__arm) && defined (__acorn) && defined (__unix) - printf ("arm-acorn-riscix\n"); exit (0); -#endif - -#if defined (hp300) && !defined (hpux) - printf ("m68k-hp-bsd\n"); exit (0); -#endif - -#if defined (NeXT) -#if !defined (__ARCHITECTURE__) -#define __ARCHITECTURE__ "m68k" -#endif - int version; - version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; - if (version < 4) - printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); - else - printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); - exit (0); -#endif - -#if defined (MULTIMAX) || defined (n16) -#if defined (UMAXV) - printf ("ns32k-encore-sysv\n"); exit (0); -#else -#if defined (CMU) - printf ("ns32k-encore-mach\n"); exit (0); -#else - printf ("ns32k-encore-bsd\n"); exit (0); -#endif -#endif -#endif - -#if defined (__386BSD__) - printf ("i386-pc-bsd\n"); exit (0); -#endif - -#if defined (sequent) -#if defined (i386) - printf ("i386-sequent-dynix\n"); exit (0); -#endif -#if defined (ns32000) - printf ("ns32k-sequent-dynix\n"); exit (0); -#endif -#endif - -#if defined (_SEQUENT_) - struct utsname un; - - uname(&un); - - if (strncmp(un.version, "V2", 2) == 0) { - printf ("i386-sequent-ptx2\n"); exit (0); - } - if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ - printf ("i386-sequent-ptx1\n"); exit (0); - } - printf ("i386-sequent-ptx\n"); exit (0); - -#endif - -#if defined (vax) -# if !defined (ultrix) -# include -# if defined (BSD) -# if BSD == 43 - printf ("vax-dec-bsd4.3\n"); exit (0); -# else -# if BSD == 199006 - printf ("vax-dec-bsd4.3reno\n"); exit (0); -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# endif -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# else - printf ("vax-dec-ultrix\n"); exit (0); -# endif -#endif - -#if defined (alliant) && defined (i860) - printf ("i860-alliant-bsd\n"); exit (0); -#endif - - exit (1); -} -EOF - -$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && - { echo "$SYSTEM_NAME"; exit; } - -# Apollos put the system type in the environment. - -test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } - -# Convex versions that predate uname can use getsysinfo(1) - -if [ -x /usr/convex/getsysinfo ] -then - case `getsysinfo -f cpu_type` in - c1*) - echo c1-convex-bsd - exit ;; - c2*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit ;; - c34*) - echo c34-convex-bsd - exit ;; - c38*) - echo c38-convex-bsd - exit ;; - c4*) - echo c4-convex-bsd - exit ;; - esac -fi - -cat >&2 < in order to provide the needed -information to handle your system. - -config.guess timestamp = $timestamp - -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null` - -hostinfo = `(hostinfo) 2>/dev/null` -/bin/universe = `(/bin/universe) 2>/dev/null` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` -/bin/arch = `(/bin/arch) 2>/dev/null` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` - -UNAME_MACHINE = ${UNAME_MACHINE} -UNAME_RELEASE = ${UNAME_RELEASE} -UNAME_SYSTEM = ${UNAME_SYSTEM} -UNAME_VERSION = ${UNAME_VERSION} -EOF - -exit 1 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/libsysio/config.sub b/libsysio/config.sub deleted file mode 100755 index 5958d83..0000000 --- a/libsysio/config.sub +++ /dev/null @@ -1,1773 +0,0 @@ -#! /bin/sh -# Configuration validation subroutine script. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, -# 2011 Free Software Foundation, Inc. - -timestamp='2011-11-11' - -# This file is (in principle) common to ALL GNU software. -# The presence of a machine in this file suggests that SOME GNU software -# can handle that machine. It does not imply ALL GNU software can. -# -# This file is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is 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, write to the Free Software -# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA -# 02110-1301, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - - -# Please send patches to . Submit a context -# diff and a properly formatted GNU ChangeLog entry. -# -# Configuration subroutine to validate and canonicalize a configuration type. -# Supply the specified configuration type as an argument. -# If it is invalid, we print an error message on stderr and exit with code 1. -# Otherwise, we print the canonical config type on stdout and succeed. - -# You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD - -# This file is supposed to be the same for all GNU packages -# and recognize all the CPU types, system types and aliases -# that are meaningful with *any* GNU software. -# Each package is responsible for reporting which valid configurations -# it does not support. The user should be able to distinguish -# a failure to support a valid configuration from a meaningless -# configuration. - -# The goal of this file is to map all the various variations of a given -# machine specification into a single specification in the form: -# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM -# or in some cases, the newer four-part form: -# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM -# It is wrong to echo any other type of specification. - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] CPU-MFR-OPSYS - $0 [OPTION] ALIAS - -Canonicalize a configuration name. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.sub ($timestamp) - -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, -2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free -Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit ;; - --version | -v ) - echo "$version" ; exit ;; - --help | --h* | -h ) - echo "$usage"; exit ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" - exit 1 ;; - - *local*) - # First pass through any local machine types. - echo $1 - exit ;; - - * ) - break ;; - esac -done - -case $# in - 0) echo "$me: missing argument$help" >&2 - exit 1;; - 1) ;; - *) echo "$me: too many arguments$help" >&2 - exit 1;; -esac - -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ - linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ - knetbsd*-gnu* | netbsd*-gnu* | \ - kopensolaris*-gnu* | \ - storm-chaos* | os2-emx* | rtmk-nova*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac - -### Let's recognize common machines as not being operating systems so -### that things like config.sub decstation-3100 work. We also -### recognize some manufacturers as not being operating systems, so we -### can provide default operating systems below. -case $os in - -sun*os*) - # Prevent following clause from handling this invalid input. - ;; - -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ - -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ - -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ - -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ - -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ - -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis | -knuth | -cray | -microblaze) - os= - basic_machine=$1 - ;; - -bluegene*) - os=-cnk - ;; - -sim | -cisco | -oki | -wec | -winbond) - os= - basic_machine=$1 - ;; - -scout) - ;; - -wrs) - os=-vxworks - basic_machine=$1 - ;; - -chorusos*) - os=-chorusos - basic_machine=$1 - ;; - -chorusrdb) - os=-chorusrdb - basic_machine=$1 - ;; - -hiux*) - os=-hiuxwe2 - ;; - -sco6) - os=-sco5v6 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5) - os=-sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco4) - os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2.[4-9]*) - os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2v[4-9]*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5v6*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco*) - os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -udk*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -isc) - os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -clix*) - basic_machine=clipper-intergraph - ;; - -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -lynx*) - os=-lynxos - ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` - ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` - ;; - -psos*) - os=-psos - ;; - -mint | -mint[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; -esac - -# Decode aliases for certain CPU-COMPANY combinations. -case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - 1750a | 580 \ - | a29k \ - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ - | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ - | am33_2.0 \ - | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ - | be32 | be64 \ - | bfin \ - | c4x | clipper \ - | d10v | d30v | dlx | dsp16xx \ - | epiphany \ - | fido | fr30 | frv \ - | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | hexagon \ - | i370 | i860 | i960 | ia64 \ - | ip2k | iq2000 \ - | [lk]1om \ - | le32 | le64 \ - | lm32 \ - | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | mcore | mep | metag \ - | mips | mipsbe | mipseb | mipsel | mipsle \ - | mips16 \ - | mips64 | mips64el \ - | mips64octeon | mips64octeonel \ - | mips64orion | mips64orionel \ - | mips64r5900 | mips64r5900el \ - | mips64vr | mips64vrel \ - | mips64vr4100 | mips64vr4100el \ - | mips64vr4300 | mips64vr4300el \ - | mips64vr5000 | mips64vr5000el \ - | mips64vr5900 | mips64vr5900el \ - | mipsisa32 | mipsisa32el \ - | mipsisa32r2 | mipsisa32r2el \ - | mipsisa64 | mipsisa64el \ - | mipsisa64r2 | mipsisa64r2el \ - | mipsisa64sb1 | mipsisa64sb1el \ - | mipsisa64sr71k | mipsisa64sr71kel \ - | mipstx39 | mipstx39el \ - | mn10200 | mn10300 \ - | moxie \ - | mt \ - | msp430 \ - | nds32 | nds32le | nds32be \ - | nios | nios2 \ - | ns16k | ns32k \ - | open8 \ - | or32 \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle \ - | pyramid \ - | rl78 | rx \ - | score \ - | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ - | sh64 | sh64le \ - | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ - | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ - | spu \ - | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ - | ubicom32 \ - | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ - | we32k \ - | x86 | xc16x | xstormy16 | xtensa \ - | z8k | z80) - basic_machine=$basic_machine-unknown - ;; - c54x) - basic_machine=tic54x-unknown - ;; - c55x) - basic_machine=tic55x-unknown - ;; - c6x) - basic_machine=tic6x-unknown - ;; - m6811 | m68hc11 | m6812 | m68hc12 | picochip) - # Motorola 68HC11/12. - basic_machine=$basic_machine-unknown - os=-none - ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) - ;; - ms1) - basic_machine=mt-unknown - ;; - - strongarm | thumb | xscale) - basic_machine=arm-unknown - ;; - - xscaleeb) - basic_machine=armeb-unknown - ;; - - xscaleel) - basic_machine=armel-unknown - ;; - - # We use `pc' rather than `unknown' - # because (1) that's what they normally are, and - # (2) the word "unknown" tends to confuse beginning users. - i*86 | x86_64) - basic_machine=$basic_machine-pc - ;; - # Object if more than one company name word. - *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; - # Recognize the basic CPU types with company name. - 580-* \ - | a29k-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ - | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ - | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ - | avr-* | avr32-* \ - | be32-* | be64-* \ - | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* \ - | clipper-* | craynv-* | cydra-* \ - | d10v-* | d30v-* | dlx-* \ - | elxsi-* \ - | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ - | h8300-* | h8500-* \ - | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | hexagon-* \ - | i*86-* | i860-* | i960-* | ia64-* \ - | ip2k-* | iq2000-* \ - | [lk]1om-* \ - | le32-* | le64-* \ - | lm32-* \ - | m32c-* | m32r-* | m32rle-* \ - | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ - | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ - | mips16-* \ - | mips64-* | mips64el-* \ - | mips64octeon-* | mips64octeonel-* \ - | mips64orion-* | mips64orionel-* \ - | mips64r5900-* | mips64r5900el-* \ - | mips64vr-* | mips64vrel-* \ - | mips64vr4100-* | mips64vr4100el-* \ - | mips64vr4300-* | mips64vr4300el-* \ - | mips64vr5000-* | mips64vr5000el-* \ - | mips64vr5900-* | mips64vr5900el-* \ - | mipsisa32-* | mipsisa32el-* \ - | mipsisa32r2-* | mipsisa32r2el-* \ - | mipsisa64-* | mipsisa64el-* \ - | mipsisa64r2-* | mipsisa64r2el-* \ - | mipsisa64sb1-* | mipsisa64sb1el-* \ - | mipsisa64sr71k-* | mipsisa64sr71kel-* \ - | mipstx39-* | mipstx39el-* \ - | mmix-* \ - | mt-* \ - | msp430-* \ - | nds32-* | nds32le-* | nds32be-* \ - | nios-* | nios2-* \ - | none-* | np1-* | ns16k-* | ns32k-* \ - | open8-* \ - | orion-* \ - | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ - | pyramid-* \ - | rl78-* | romp-* | rs6000-* | rx-* \ - | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ - | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ - | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ - | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ - | tahoe-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ - | tile*-* \ - | tron-* \ - | ubicom32-* \ - | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ - | vax-* \ - | we32k-* \ - | x86-* | x86_64-* | xc16x-* | xps100-* \ - | xstormy16-* | xtensa*-* \ - | ymp-* \ - | z8k-* | z80-*) - ;; - # Recognize the basic CPU types without company name, with glob match. - xtensa*) - basic_machine=$basic_machine-unknown - ;; - # Recognize the various machine names and aliases which stand - # for a CPU type and a company and sometimes even an OS. - 386bsd) - basic_machine=i386-unknown - os=-bsd - ;; - 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att - ;; - 3b*) - basic_machine=we32k-att - ;; - a29khif) - basic_machine=a29k-amd - os=-udi - ;; - abacus) - basic_machine=abacus-unknown - ;; - adobe68k) - basic_machine=m68010-adobe - os=-scout - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; - amd64) - basic_machine=x86_64-pc - ;; - amd64-*) - basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv - ;; - amiga | amiga-*) - basic_machine=m68k-unknown - ;; - amigaos | amigados) - basic_machine=m68k-unknown - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-unknown - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - apollo68bsd) - basic_machine=m68k-apollo - os=-bsd - ;; - aros) - basic_machine=i386-pc - os=-aros - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - blackfin) - basic_machine=bfin-unknown - os=-linux - ;; - blackfin-*) - basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - bluegene*) - basic_machine=powerpc-ibm - os=-cnk - ;; - c54x-*) - basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c55x-*) - basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c6x-*) - basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c90) - basic_machine=c90-cray - os=-unicos - ;; - cegcc) - basic_machine=arm-unknown - os=-cegcc - ;; - convex-c1) - basic_machine=c1-convex - os=-bsd - ;; - convex-c2) - basic_machine=c2-convex - os=-bsd - ;; - convex-c32) - basic_machine=c32-convex - os=-bsd - ;; - convex-c34) - basic_machine=c34-convex - os=-bsd - ;; - convex-c38) - basic_machine=c38-convex - os=-bsd - ;; - cray | j90) - basic_machine=j90-cray - os=-unicos - ;; - craynv) - basic_machine=craynv-cray - os=-unicosmp - ;; - cr16 | cr16-*) - basic_machine=cr16-unknown - os=-elf - ;; - crds | unos) - basic_machine=m68k-crds - ;; - crisv32 | crisv32-* | etraxfs*) - basic_machine=crisv32-axis - ;; - cris | cris-* | etrax*) - basic_machine=cris-axis - ;; - crx) - basic_machine=crx-unknown - os=-elf - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec - ;; - decsystem10* | dec10*) - basic_machine=pdp10-dec - os=-tops10 - ;; - decsystem20* | dec20*) - basic_machine=pdp10-dec - os=-tops20 - ;; - delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola - ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - dicos) - basic_machine=i686-pc - os=-dicos - ;; - djgpp) - basic_machine=i586-pc - os=-msdosdjgpp - ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=-bosx - ;; - dpx2* | dpx2*-bull) - basic_machine=m68k-bull - os=-sysv3 - ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon - ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd - ;; - encore | umax | mmax) - basic_machine=ns32k-encore - ;; - es1800 | OSE68k | ose68k | ose | OSE) - basic_machine=m68k-ericsson - os=-ose - ;; - fx2800) - basic_machine=i860-alliant - ;; - genix) - basic_machine=ns32k-ns - ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - go32) - basic_machine=i386-pc - os=-go32 - ;; - h3050r* | hiux*) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - h8300xray) - basic_machine=h8300-hitachi - os=-xray - ;; - h8500hms) - basic_machine=h8500-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 - ;; - hp300-*) - basic_machine=m68k-hp - ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux - ;; - hp3k9[0-9][0-9] | hp9[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp - ;; - hp9k3[2-9][0-9]) - basic_machine=m68k-hp - ;; - hp9k6[0-9][0-9] | hp6[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k7[0-79][0-9] | hp7[0-79][0-9]) - basic_machine=hppa1.1-hp - ;; - hp9k78[0-9] | hp78[0-9]) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][13679] | hp8[0-9][13679]) - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][0-9] | hp8[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hppa-next) - os=-nextstep3 - ;; - hppaosf) - basic_machine=hppa1.1-hp - os=-osf - ;; - hppro) - basic_machine=hppa1.1-hp - os=-proelf - ;; - i370-ibm* | ibm*) - basic_machine=i370-ibm - ;; -# I'm not sure what "Sysv32" means. Should this be sysv3.2? - i*86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv32 - ;; - i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 - ;; - i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv - ;; - i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 - ;; - i386mach) - basic_machine=i386-mach - os=-mach - ;; - i386-vsta | vsta) - basic_machine=i386-unknown - os=-vsta - ;; - iris | iris4d) - basic_machine=mips-sgi - case $os in - -irix*) - ;; - *) - os=-irix4 - ;; - esac - ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; - m68knommu) - basic_machine=m68k-unknown - os=-linux - ;; - m68knommu-*) - basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; - microblaze) - basic_machine=microblaze-xilinx - ;; - mingw32) - basic_machine=i386-pc - os=-mingw32 - ;; - mingw32ce) - basic_machine=arm-unknown - os=-mingw32ce - ;; - miniframe) - basic_machine=m68000-convergent - ;; - *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; - mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` - ;; - mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown - ;; - monitor) - basic_machine=m68k-rom68k - os=-coff - ;; - morphos) - basic_machine=powerpc-unknown - os=-morphos - ;; - msdos) - basic_machine=i386-pc - os=-msdos - ;; - ms1-*) - basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` - ;; - msys) - basic_machine=i386-pc - os=-msys - ;; - mvs) - basic_machine=i370-ibm - os=-mvs - ;; - nacl) - basic_machine=le32-unknown - os=-nacl - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - netbsd386) - basic_machine=i386-unknown - os=-netbsd - ;; - netwinder) - basic_machine=armv4l-rebel - os=-linux - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos - ;; - news-3600 | risc-news) - basic_machine=mips-sony - os=-newsos - ;; - necv70) - basic_machine=v70-nec - os=-sysv - ;; - next | m*-next ) - basic_machine=m68k-next - case $os in - -nextstep* ) - ;; - -ns2*) - os=-nextstep2 - ;; - *) - os=-nextstep3 - ;; - esac - ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - mon960) - basic_machine=i960-intel - os=-mon960 - ;; - nonstopux) - basic_machine=mips-compaq - os=-nonstopux - ;; - np1) - basic_machine=np1-gould - ;; - neo-tandem) - basic_machine=neo-tandem - ;; - nse-tandem) - basic_machine=nse-tandem - ;; - nsr-tandem) - basic_machine=nsr-tandem - ;; - op50n-* | op60c-*) - basic_machine=hppa1.1-oki - os=-proelf - ;; - openrisc | openrisc-*) - basic_machine=or32-unknown - ;; - os400) - basic_machine=powerpc-ibm - os=-os400 - ;; - OSE68000 | ose68000) - basic_machine=m68000-ericsson - os=-ose - ;; - os68k) - basic_machine=m68k-none - os=-os68k - ;; - pa-hitachi) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - parisc) - basic_machine=hppa-unknown - os=-linux - ;; - parisc-*) - basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - pbd) - basic_machine=sparc-tti - ;; - pbb) - basic_machine=m68k-tti - ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 - ;; - pc98) - basic_machine=i386-pc - ;; - pc98-*) - basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium | p5 | k5 | k6 | nexgen | viac3) - basic_machine=i586-pc - ;; - pentiumpro | p6 | 6x86 | athlon | athlon_*) - basic_machine=i686-pc - ;; - pentiumii | pentium2 | pentiumiii | pentium3) - basic_machine=i686-pc - ;; - pentium4) - basic_machine=i786-pc - ;; - pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium4-*) - basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pn) - basic_machine=pn-gould - ;; - power) basic_machine=power-ibm - ;; - ppc | ppcbe) basic_machine=powerpc-unknown - ;; - ppc-* | ppcbe-*) - basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppcle | powerpclittle | ppc-le | powerpc-little) - basic_machine=powerpcle-unknown - ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64) basic_machine=powerpc64-unknown - ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64le | powerpc64little | ppc64-le | powerpc64-little) - basic_machine=powerpc64le-unknown - ;; - ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ps2) - basic_machine=i386-ibm - ;; - pw32) - basic_machine=i586-unknown - os=-pw32 - ;; - rdos) - basic_machine=i386-pc - os=-rdos - ;; - rom68k) - basic_machine=m68k-rom68k - os=-coff - ;; - rm[46]00) - basic_machine=mips-siemens - ;; - rtpc | rtpc-*) - basic_machine=romp-ibm - ;; - s390 | s390-*) - basic_machine=s390-ibm - ;; - s390x | s390x-*) - basic_machine=s390x-ibm - ;; - sa29200) - basic_machine=a29k-amd - os=-udi - ;; - sb1) - basic_machine=mipsisa64sb1-unknown - ;; - sb1el) - basic_machine=mipsisa64sb1el-unknown - ;; - sde) - basic_machine=mipsisa32-sde - os=-elf - ;; - sei) - basic_machine=mips-sei - os=-seiux - ;; - sequent) - basic_machine=i386-sequent - ;; - sh) - basic_machine=sh-hitachi - os=-hms - ;; - sh5el) - basic_machine=sh5le-unknown - ;; - sh64) - basic_machine=sh64-unknown - ;; - sparclite-wrs | simso-wrs) - basic_machine=sparclite-wrs - os=-vxworks - ;; - sps7) - basic_machine=m68k-bull - os=-sysv2 - ;; - spur) - basic_machine=spur-unknown - ;; - st2000) - basic_machine=m68k-tandem - ;; - stratus) - basic_machine=i860-stratus - os=-sysv4 - ;; - strongarm-* | thumb-*) - basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - sun2) - basic_machine=m68000-sun - ;; - sun2os3) - basic_machine=m68000-sun - os=-sunos3 - ;; - sun2os4) - basic_machine=m68000-sun - os=-sunos4 - ;; - sun3os3) - basic_machine=m68k-sun - os=-sunos3 - ;; - sun3os4) - basic_machine=m68k-sun - os=-sunos4 - ;; - sun4os3) - basic_machine=sparc-sun - os=-sunos3 - ;; - sun4os4) - basic_machine=sparc-sun - os=-sunos4 - ;; - sun4sol2) - basic_machine=sparc-sun - os=-solaris2 - ;; - sun3 | sun3-*) - basic_machine=m68k-sun - ;; - sun4) - basic_machine=sparc-sun - ;; - sun386 | sun386i | roadrunner) - basic_machine=i386-sun - ;; - sv1) - basic_machine=sv1-cray - os=-unicos - ;; - symmetry) - basic_machine=i386-sequent - os=-dynix - ;; - t3e) - basic_machine=alphaev5-cray - os=-unicos - ;; - t90) - basic_machine=t90-cray - os=-unicos - ;; - tile*) - basic_machine=$basic_machine-unknown - os=-linux-gnu - ;; - tx39) - basic_machine=mipstx39-unknown - ;; - tx39el) - basic_machine=mipstx39el-unknown - ;; - toad1) - basic_machine=pdp10-xkl - os=-tops20 - ;; - tower | tower-32) - basic_machine=m68k-ncr - ;; - tpf) - basic_machine=s390x-ibm - os=-tpf - ;; - udi29k) - basic_machine=a29k-amd - os=-udi - ;; - ultra3) - basic_machine=a29k-nyu - os=-sym1 - ;; - v810 | necv810) - basic_machine=v810-nec - os=-none - ;; - vaxv) - basic_machine=vax-dec - os=-sysv - ;; - vms) - basic_machine=vax-dec - os=-vms - ;; - vpp*|vx|vx-*) - basic_machine=f301-fujitsu - ;; - vxworks960) - basic_machine=i960-wrs - os=-vxworks - ;; - vxworks68) - basic_machine=m68k-wrs - os=-vxworks - ;; - vxworks29k) - basic_machine=a29k-wrs - os=-vxworks - ;; - w65*) - basic_machine=w65-wdc - os=-none - ;; - w89k-*) - basic_machine=hppa1.1-winbond - os=-proelf - ;; - xbox) - basic_machine=i686-pc - os=-mingw32 - ;; - xps | xps100) - basic_machine=xps100-honeywell - ;; - xscale-* | xscalee[bl]-*) - basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` - ;; - ymp) - basic_machine=ymp-cray - os=-unicos - ;; - z8k-*-coff) - basic_machine=z8k-unknown - os=-sim - ;; - z80-*-coff) - basic_machine=z80-unknown - os=-sim - ;; - none) - basic_machine=none-none - os=-none - ;; - -# Here we handle the default manufacturer of certain CPU types. It is in -# some cases the only manufacturer, in others, it is the most popular. - w89k) - basic_machine=hppa1.1-winbond - ;; - op50n) - basic_machine=hppa1.1-oki - ;; - op60c) - basic_machine=hppa1.1-oki - ;; - romp) - basic_machine=romp-ibm - ;; - mmix) - basic_machine=mmix-knuth - ;; - rs6000) - basic_machine=rs6000-ibm - ;; - vax) - basic_machine=vax-dec - ;; - pdp10) - # there are many clones, so DEC is not a safe bet - basic_machine=pdp10-unknown - ;; - pdp11) - basic_machine=pdp11-dec - ;; - we32k) - basic_machine=we32k-att - ;; - sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) - basic_machine=sh-unknown - ;; - sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) - basic_machine=sparc-sun - ;; - cydra) - basic_machine=cydra-cydrome - ;; - orion) - basic_machine=orion-highlevel - ;; - orion105) - basic_machine=clipper-highlevel - ;; - mac | mpw | mac-mpw) - basic_machine=m68k-apple - ;; - pmac | pmac-mpw) - basic_machine=powerpc-apple - ;; - *-unknown) - # Make sure to match an already-canonicalized machine name. - ;; - *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; -esac - -# Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` - ;; - *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` - ;; - *) - ;; -esac - -# Decode manufacturer-specific aliases for certain operating systems. - -if [ x"$os" != x"" ] -then -case $os in - # First match some system type aliases - # that might get confused with valid system types. - # -solaris* is a basic system type, with this one exception. - -auroraux) - os=-auroraux - ;; - -solaris1 | -solaris1.*) - os=`echo $os | sed -e 's|solaris1|sunos4|'` - ;; - -solaris) - os=-solaris2 - ;; - -svr4*) - os=-sysv4 - ;; - -unixware*) - os=-sysv4.2uw - ;; - -gnu/linux*) - os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` - ;; - # First accept the basic system types. - # The portable systems comes first. - # Each alternative MUST END IN A *, to match a version number. - # -sysv* is not here because it comes later, after sysvr4. - -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ - | -sym* | -kopensolaris* \ - | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* | -aros* \ - | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ - | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ - | -openbsd* | -solidbsd* \ - | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ - | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ - | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ - | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* | -cegcc* \ - | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -linux-android* \ - | -linux-newlib* | -linux-uclibc* \ - | -uxpv* | -beos* | -mpeix* | -udk* \ - | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ - | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ - | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ - | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ - | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ - | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; - -qnx*) - case $basic_machine in - x86-* | i*86-*) - ;; - *) - os=-nto$os - ;; - esac - ;; - -nto-qnx*) - ;; - -nto*) - os=`echo $os | sed -e 's|nto|nto-qnx|'` - ;; - -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ - | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) - ;; - -mac*) - os=`echo $os | sed -e 's|mac|macos|'` - ;; - -linux-dietlibc) - os=-linux-dietlibc - ;; - -linux*) - os=`echo $os | sed -e 's|linux|linux-gnu|'` - ;; - -sunos5*) - os=`echo $os | sed -e 's|sunos5|solaris2|'` - ;; - -sunos6*) - os=`echo $os | sed -e 's|sunos6|solaris3|'` - ;; - -opened*) - os=-openedition - ;; - -os400*) - os=-os400 - ;; - -wince*) - os=-wince - ;; - -osfrose*) - os=-osfrose - ;; - -osf*) - os=-osf - ;; - -utek*) - os=-bsd - ;; - -dynix*) - os=-bsd - ;; - -acis*) - os=-aos - ;; - -atheos*) - os=-atheos - ;; - -syllable*) - os=-syllable - ;; - -386bsd) - os=-bsd - ;; - -ctix* | -uts*) - os=-sysv - ;; - -nova*) - os=-rtmk-nova - ;; - -ns2 ) - os=-nextstep2 - ;; - -nsk*) - os=-nsk - ;; - # Preserve the version number of sinix5. - -sinix5.*) - os=`echo $os | sed -e 's|sinix|sysv|'` - ;; - -sinix*) - os=-sysv4 - ;; - -tpf*) - os=-tpf - ;; - -triton*) - os=-sysv3 - ;; - -oss*) - os=-sysv3 - ;; - -svr4) - os=-sysv4 - ;; - -svr3) - os=-sysv3 - ;; - -sysvr4) - os=-sysv4 - ;; - # This must come after -sysvr4. - -sysv*) - ;; - -ose*) - os=-ose - ;; - -es1800*) - os=-ose - ;; - -xenix) - os=-xenix - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - os=-mint - ;; - -aros*) - os=-aros - ;; - -kaos*) - os=-kaos - ;; - -zvmoe) - os=-zvmoe - ;; - -dicos*) - os=-dicos - ;; - -nacl*) - ;; - -none) - ;; - *) - # Get rid of the `-' at the beginning of $os. - os=`echo $os | sed 's/[^-]*-//'` - echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 - exit 1 - ;; -esac -else - -# Here we handle the default operating systems that come with various machines. -# The value should be what the vendor currently ships out the door with their -# machine or put another way, the most popular os provided with the machine. - -# Note that if you're going to try to match "-MANUFACTURER" here (say, -# "-sun"), then you have to tell the case statement up towards the top -# that MANUFACTURER isn't an operating system. Otherwise, code above -# will signal an error saying that MANUFACTURER isn't an operating -# system, and we'll never get to this point. - -case $basic_machine in - score-*) - os=-elf - ;; - spu-*) - os=-elf - ;; - *-acorn) - os=-riscix1.2 - ;; - arm*-rebel) - os=-linux - ;; - arm*-semi) - os=-aout - ;; - c4x-* | tic4x-*) - os=-coff - ;; - tic54x-*) - os=-coff - ;; - tic55x-*) - os=-coff - ;; - tic6x-*) - os=-coff - ;; - # This must come before the *-dec entry. - pdp10-*) - os=-tops20 - ;; - pdp11-*) - os=-none - ;; - *-dec | vax-*) - os=-ultrix4.2 - ;; - m68*-apollo) - os=-domain - ;; - i386-sun) - os=-sunos4.0.2 - ;; - m68000-sun) - os=-sunos3 - # This also exists in the configure program, but was not the - # default. - # os=-sunos4 - ;; - m68*-cisco) - os=-aout - ;; - mep-*) - os=-elf - ;; - mips*-cisco) - os=-elf - ;; - mips*-*) - os=-elf - ;; - or32-*) - os=-coff - ;; - *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 - ;; - sparc-* | *-sun) - os=-sunos4.1.1 - ;; - *-be) - os=-beos - ;; - *-haiku) - os=-haiku - ;; - *-ibm) - os=-aix - ;; - *-knuth) - os=-mmixware - ;; - *-wec) - os=-proelf - ;; - *-winbond) - os=-proelf - ;; - *-oki) - os=-proelf - ;; - *-hp) - os=-hpux - ;; - *-hitachi) - os=-hiux - ;; - i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv - ;; - *-cbm) - os=-amigaos - ;; - *-dg) - os=-dgux - ;; - *-dolphin) - os=-sysv3 - ;; - m68k-ccur) - os=-rtu - ;; - m88k-omron*) - os=-luna - ;; - *-next ) - os=-nextstep - ;; - *-sequent) - os=-ptx - ;; - *-crds) - os=-unos - ;; - *-ns) - os=-genix - ;; - i370-*) - os=-mvs - ;; - *-next) - os=-nextstep3 - ;; - *-gould) - os=-sysv - ;; - *-highlevel) - os=-bsd - ;; - *-encore) - os=-bsd - ;; - *-sgi) - os=-irix - ;; - *-siemens) - os=-sysv4 - ;; - *-masscomp) - os=-rtu - ;; - f30[01]-fujitsu | f700-fujitsu) - os=-uxpv - ;; - *-rom68k) - os=-coff - ;; - *-*bug) - os=-coff - ;; - *-apple) - os=-macos - ;; - *-atari*) - os=-mint - ;; - *) - os=-none - ;; -esac -fi - -# Here we handle the case where we know the os, and the CPU type, but not the -# manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) - case $os in - -riscix*) - vendor=acorn - ;; - -sunos*) - vendor=sun - ;; - -cnk*|-aix*) - vendor=ibm - ;; - -beos*) - vendor=be - ;; - -hpux*) - vendor=hp - ;; - -mpeix*) - vendor=hp - ;; - -hiux*) - vendor=hitachi - ;; - -unos*) - vendor=crds - ;; - -dgux*) - vendor=dg - ;; - -luna*) - vendor=omron - ;; - -genix*) - vendor=ns - ;; - -mvs* | -opened*) - vendor=ibm - ;; - -os400*) - vendor=ibm - ;; - -ptx*) - vendor=sequent - ;; - -tpf*) - vendor=ibm - ;; - -vxsim* | -vxworks* | -windiss*) - vendor=wrs - ;; - -aux*) - vendor=apple - ;; - -hms*) - vendor=hitachi - ;; - -mpw* | -macos*) - vendor=apple - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - vendor=atari - ;; - -vos*) - vendor=stratus - ;; - esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` - ;; -esac - -echo $basic_machine$os -exit - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/libsysio/configure.ac b/libsysio/configure.ac deleted file mode 100644 index 324fe17..0000000 --- a/libsysio/configure.ac +++ /dev/null @@ -1,583 +0,0 @@ -AC_INIT(libsysio, 1.2) - -AC_CANONICAL_SYSTEM - -case "$host_os" in - aix*) - ;; - linux*) - ;; - *) - AC_MSG_WARN('***' ${host_os}: Unsupported OS target) - ;; -esac - -AM_INIT_AUTOMAKE([subdir-objects 1.9 tar-ustar]) -AM_MAINTAINER_MODE([enable]) -AC_PROG_CC -AM_PROG_CC_C_O -AC_PROG_RANLIB -AC_CHECK_TOOL(CC, gcc, [no]) -AC_CHECK_TOOL(LD, ld, [no]) -AC_CHECK_TOOL(AR, ar, [no]) -AC_CHECK_TOOL(OBJDUMP, objdump, [no]) -AC_CHECK_TOOL(STRIP, strip, [no]) -AC_PROG_MAKE_SET -AC_HEADER_STDC -AC_HEADER_STAT -AC_HEADER_TIME - -AS_IF([test "x$cross_compiling" = xyes], - [case $host_vendor in - # The K1OM architecture is an extension of the x86 architecture - # and in MPSS 2.1 it's defined in $host_vendor. But in MPSS 3.x - # it's defined in $host_arch. So, try to support both case. - k1om | mpss) - AC_MSG_RESULT([Intel(R) Xeon Phi(TM)]) - CC_TARGET_ARCH=`$CC -v 2>&1 | grep Target: | sed -e 's/Target: //'` - if test \( $CC_TARGET_ARCH != x86_64-k1om-linux \ - -a $CC_TARGET_ARCH != k1om-mpss-linux \) - then - AC_MSG_ERROR([Cross compiler not found in PATH.]) - fi - CCAS=$CC - ;; - *) - ;; - esac] -) - -if test ${target_cpu} == "powerpc64"; then - AC_MSG_WARN([set compiler with -m64]) - CC="$CC -m64" -fi - -have_lib_dir=yes; -AC_ARG_WITH(lib-dir, - AC_HELP_STRING([--with-lib-dir=], - [directory for sysio library]), - [ case "${withval}" in - "yes"|"no"|"") have_lib_dir=no ;; - *) LIBBUILD_DIR=${withval}; - test -d ${LIBBUILD_DIR} || mkdir ${LIBBUILD_DIR} || - have_lib_dir=no;; - esac;], - [ LIBBUILD_DIR=`pwd`/lib; - test -d ${LIBBUILD_DIR} || mkdir ${LIBBUILD_DIR} || have_lib_dir=no;]) -if test x${have_lib_dir} = xyes; then - echo "Using sysio library directory ${LIBBUILD_DIR}" -else - AC_MSG_ERROR(Need writeable path to sysio library directory ${LIBBUILD_DIR}) -fi -AC_SUBST(LIBBUILD_DIR) - -AC_ARG_WITH(native_driver, - AC_HELP_STRING([--with-native-driver],[build native test driver]), - [ case "${withval}" in - yes) ;; - no) ;; - *) AC_MSG_ERROR(bad value ${withval} for --with-native-driver) ;; - esac;], - [with_native_driver=yes;]) -AM_CONDITIONAL(WITH_NATIVE_DRIVER, test x$with_native_driver = xyes) - -AC_ARG_WITH(incore-driver, - AC_HELP_STRING([--with-incore-driver],[build incore test driver]), - [ case "${withval}" in - yes) ;; - no) ;; - *) AC_MSG_ERROR(bad value ${withval} for --with-incore-driver) ;; - esac], - [with_incore_driver=yes]) -AM_CONDITIONAL(WITH_INCORE_DRIVER, test x$with_incore_driver = xyes) - -AC_ARG_WITH(tests, - AC_HELP_STRING([--with-tests],[build tests]), - [ case "${withval}" in - yes) ;; - no) ;; - *) AC_MSG_ERROR(bad value ${withval} for --with-tests) ;; - esac], - [with_tests=yes]) -AM_CONDITIONAL(WITH_TESTS, test x$with_tests = xyes) - -AC_ARG_WITH(automount, - AC_HELP_STRING([--with-automount@<:@=@:>@], - [with automounts @<:@=.mount@:>@]), - [ if test x${withval} = xyes; then - AUTOMOUNT=-DAUTOMOUNT_FILE_NAME="\\\".mount\\\"" - elif test x${withval} != x; then - AUTOMOUNT=-DAUTOMOUNT_FILE_NAME="\\\"${withval}\\\"" - fi]) -AC_SUBST(AUTOMOUNT) - -AC_ARG_WITH(stdfd-dev, - AC_HELP_STRING([--with-stdfd-dev], - [build standard file descriptors pseudo-driver]), - [ case "${withval}" in - yes) ;; - no) ;; - *) AC_MSG_ERROR(bad value ${withval} for --with-stdfd-dev) ;; - esac], - [with_stdfd_dev=yes]) -AM_CONDITIONAL(WITH_STDFD_DEV, test x$with_stdfd_dev = xyes) - -AC_ARG_WITH(zero-sum-memory, - AC_HELP_STRING([--with-zero-sum-memory], - [free all dynamically allocated memory at the end -- useful for debugging]), - [ case "${withval}" in - yes) ZERO_SUM_MEMORY=-DZERO_SUM_MEMORY=1 ;; - no) ;; - *) AC_MSG_ERROR(bad value ${withval} for --with-zero-sum-memory) ;; - esac], - [with_zero_sum_memory=no]) -AC_SUBST(ZERO_SUM_MEMORY) - -AC_ARG_WITH(defer-init-cwd, - AC_HELP_STRING([--with-defer-init-cwd], - [defer initialization of current working directory]), - [ case "${withval}" in - yes) DEFER_INIT_CWD=-DDEFER_INIT_CWD=1 ;; - no) ;; - *) AC_MSG_ERROR(bad value ${withval} for --with-defer-init-cwd) ;; - esac], - [with_defer_init_cwd=no]) -AC_SUBST(DEFER_INIT_CWD) - -AC_ARG_WITH(tracing, - AC_HELP_STRING([--with-tracing], - [enable tracing support]), - [ case "${withval}" in - yes) TRACING=-DSYSIO_TRACING=1 ;; - no) ;; - *) AC_MSG_ERROR(bad value ${withval} for --with-tracing) ;; - esac], - [TRACING=-DSYSIO_TRACING=1]) -AC_SUBST(TRACING) - -AC_ARG_WITH(cplant_yod, - AC_HELP_STRING([--with-cplant-yod],[build cplant yod I/O driver]), - [ case "${withval}" in - yes) if test x${with_stdfd_dev} != xyes; then - with_stdfd_dev=yes - AM_CONDITIONAL(WITH_STDFD_DEV, test x$with_stdfd_dev = xyes) - fi ;; - no) ;; - *) AC_MSG_ERROR(bad value ${withval} for --with-cplant-yod);; - esac], - [with_cplant_yod=no]) -AM_CONDITIONAL(WITH_CPLANT_YOD, test x$with_cplant_yod = xyes) - -AC_ARG_WITH(cplant_tests, - AC_HELP_STRING([--with-cplant-tests=], - [build libsysio tests for cplant platform]), - [ case "${withval}" in - yes) AC_MSG_ERROR(need path to compiler for --with-cplant-tests);; - no) with_cplant_tests=no;; - *) CC=${withval} - CCDEPMODE=${CC} - CPP="${CC} -E" - AC_CHECK_FILE(${CC}, - [ if test x${with_cplant_yod} != xyes; then - with_cplant_yod=yes - AM_CONDITIONAL(WITH_CPLANT_YOD, test x$with_cplant_yod = xyes) - fi], - [ AC_MSG_ERROR(path not found ${CC} for --with-cplant-tests) ]);; - esac], - [with_cplant_tests=no]) -AM_CONDITIONAL(WITH_CPLANT_TESTS, test x$with_cplant_tests != xno) - -AC_ARG_WITH(sockets, - AC_HELP_STRING([--with-sockets], - [build sockets interface driver (EXPERIMENTAL)]), - [ case "${withval}" in - yes) ;; - no) ;; - *) AC_MSG_ERROR(bad value ${withval} for --with-sockets) ;; - esac], - [with_sockets=no]) -AM_CONDITIONAL(WITH_SOCKETS_DRIVER, test x$with_sockets = xyes) - -AC_ARG_WITH(lustre-hack, - AC_HELP_STRING([--with-lustre-hack], - [have hacking code which needed to support liblustre driver (EXPERIMENTAL)]), - [ case "${withval}" in - yes) ;; - no) ;; - *) AC_MSG_ERROR(bad value ${withval} for --with-lustre-hack) ;; - esac], - [with_lustre_hack=no]) -AM_CONDITIONAL(WITH_LUSTRE_HACK, test x$with_lustre_hack = xyes) -if test x$with_lustre_hack = xyes; then - AC_DEFINE(HAVE_LUSTRE_HACK) -fi - -AC_ARG_WITH(alternate-symbols, - AC_HELP_STRING([--with-alternate-symbols@<:@=@:>@], - [Prepend standard, public, symbols with a unique qualifer]), - [ case "${withval}" in - yes) SYSIO_LABEL_NAMES=-DSYSIO_LABEL_NAMES=sysio_ ;; - no) ;; - *) SYSIO_LABEL_NAMES=-DSYSIO_LABEL_NAMES="${withval}" ;; - esac]) -AC_SUBST(SYSIO_LABEL_NAMES) - -# We keep the original values in `$config_*' and never modify them, so we -# can write them unchanged into config.make. Everything else uses -# $machine, $vendor, and $os, and changes them whenever convenient. -config_machine=$host_cpu config_vendor=$host_vendor config_os=$host_os - -# Don't allow vendor == "unknown" -test "$config_vendor" = unknown && config_vendor= -config_os="`echo $config_os | sed 's/^unknown-//'`" - -# Some configurations imply other options. -case "$host_os" in - gnu* | linux* | bsd4.4* | netbsd* | freebsd*) - # These systems always use GNU tools. - gnu_ld=yes gnu_as=yes ;; -esac -case "$host_os" in - # i586-linuxaout is mangled into i586-pc-linux-gnuaout - linux*ecoff* | linux*aout* | gnu*aout* | gnu*ecoff*) - ;; - gnu* | linux* | freebsd* | netbsd* | sysv4* | solaris2* | irix6*) - # These systems (almost) always use the ELF format. - elf=yes - ;; - aix*) - # These systems are always xcoff - xcoff=yes - elf=no - ;; -esac - -machine=$config_machine -vendor=$config_vendor -os=$config_os - -# config.guess on some IBM machines says `rs6000' instead of `powerpc'. -# Unify this here. -if test "$machine" = rs6000; then - machine="powerpc" -fi - -case "$host_os" in - gnu* | linux*) - AC_DEFINE(_XOPEN_SOURCE, 600) - ;; - aix*) - # ... and always needed... - AC_DEFINE(__USE_LARGEFILE64) - AC_DEFINE(_LARGE_FILES) - AC_DEFINE(_LARGE_FILE_API) - AC_DEFINE(_ALL_SOURCE) - AC_DEFINE(_XOPEN_SOURCE_EXTENDED) - ;; -esac - -AC_MSG_CHECKING(for symlink support) -AC_TRY_COMPILE([ -#include -#include -],[ -#ifndef S_ISLNK -#error -#endif -], - symlink_support="yes", - symlink_support="no" -) -AC_MSG_RESULT($symlink_support) - -if test x$symlink_support = xyes; then - AC_MSG_CHECKING(if readlink returns int) - AC_TRY_COMPILE([ -#include - ],[ - extern int readlink(const char *, char *, size_t); - ], - readlink_returns_int="yes", - readlink_returns_int="no" - ) - AC_MSG_RESULT($readlink_returns_int) - if test x$readlink_returns_int = no; then - AC_DEFINE(HAVE_POSIX_1003_READLINK, - 1, - [readlink returns ssize_t]) - fi -fi - -AC_MSG_CHECKING(if readlink returns ssize_t) -AC_TRY_COMPILE([ - #include -],[ - ssize_t readlink(const char *, char *, size_t); -],[ - AC_MSG_RESULT([yes]) - AC_DEFINE(HAVE_POSIX_1003_READLINK, 1, [readlink returns ssize_t]) -],[ - AC_MSG_RESULT([no]) -]) - -# If we can't provoke the declaration of stat64 then we assume the -# environment supports 64-bit file support naturally. Beware! -AC_MSG_CHECKING(whether _LARGEFILE64_SOURCE definition is required) -AC_TRY_COMPILE([ -#include -#include -#include ], [ -struct stat64 st64;], -sysio_largefile64_source_required=no, -sysio_largefile64_source_required=maybe) -if test x$sysio_largefile64_source_required = xmaybe; then - AC_TRY_COMPILE([ -#define _LARGEFILE64_SOURCE -#include -#include -#include ], [ -struct stat64 st64;], - sysio_largefile64_source_required=yes, - sysio_largefile64_source_required=no) -fi -AC_MSG_RESULT($sysio_largefile64_source_required) -if test x$sysio_largefile64_source_required = xyes; then - AC_DEFINE(_LARGEFILE64_SOURCE) -fi - -# Alpha linux defines -# -AC_MSG_CHECKING(for alpha linux) -alpha_linux_env=no -if test `expr ${machine} : "alpha"` = 5 && \ - test `expr ${os} : "linux"` = 5; then - alpha_linux_env=yes - AC_DEFINE(ALPHA_LINUX) -fi -AC_MSG_RESULT($alpha_linux_env) -AM_CONDITIONAL(TEST_ALPHA_ARG, test x$alpha_linux_env = xyes) - -# Check for __st_ino -# -AC_MSG_CHECKING(for __st_ino) -AC_TRY_COMPILE([ -#include ], -[struct stat st; -st.__st_ino = 0;], - have__st_ino=yes, - have__st_ino=no) -AC_MSG_RESULT($have__st_ino) -if test x$have__st_ino = xyes; then - AC_DEFINE(HAVE__ST_INO) -fi - -# Check for st_gen -# -AC_MSG_CHECKING(for st_gen) -AC_TRY_COMPILE([ -#include ], -[struct stat st; -st.st_gen = 0;], - have_st_gen=yes, - have_st_gen=no) -AC_MSG_RESULT($have_st_gen) -if test x$have_st_gen = xyes; then - AC_DEFINE(HAVE_GENERATION) -fi - -AC_MSG_CHECKING(for POSIX 2008 preadv) -tmp_flags="$CFLAGS" -CFLAGS="$CFLAGS -Wall -Werror" -AC_TRY_COMPILE([ -#include -ssize_t preadv (int __fd, const struct iovec *__iovec, - int __count, off_t off) -{ - return 0; -} -],[ -],[ -AC_DEFINE(HAVE_POSIX2008_PREADV, 1, [POSIX 2008 preadv]) -AC_MSG_RESULT(yes) -],[ -AC_MSG_RESULT(no) -]) -CFLAGS="$tmp_flags" - -AC_MSG_CHECKING(for POSIX 2008 scandir) -tmp_flags="$CFLAGS" -CFLAGS="$CFLAGS -Wall -Werror" -AC_TRY_COMPILE([ -#define _BSD_SOURCE - -#include -#include - -int scandir(const char *dir, - struct dirent ***namelist, - int(*filter)(const struct dirent *), - int(*compar)(const struct dirent **, - const struct dirent **) - ); - -],[ -], [ -AC_DEFINE(HAVE_POSIX2008_SCANDIR, 1, [POSIX 2008 scandir]) -AC_MSG_RESULT(yes) -],[ -AC_MSG_RESULT(no) -]) -CFLAGS="$tmp_flags" - - -AC_MSG_CHECKING(for POSIX 2008 preadv) -tmp_flags="$CFLAGS" -CFLAGS="$CFLAGS -Wall -Werror" -AC_TRY_COMPILE([ -#include -ssize_t preadv (int __fd, const struct iovec *__iovec, - int __count, off_t off) -{ - return 0; -} -],[ -],[ -AC_DEFINE(HAVE_POSIX2008_PREADV, 1, [POSIX 2008 preadv]) -AC_MSG_RESULT(yes) -],[ -AC_MSG_RESULT(no) -]) -CFLAGS="$tmp_flags" - -AC_MSG_CHECKING(for POSIX 2008 scandir) -tmp_flags="$CFLAGS" -CFLAGS="$CFLAGS -Wall -Werror" -AC_TRY_COMPILE([ -#define _BSD_SOURCE - -#include -#include - -int scandir(const char *dir, - struct dirent ***namelist, - int(*filter)(const struct dirent *), - int(*compar)(const struct dirent **, - const struct dirent **) - ); - -],[ -], [ -AC_DEFINE(HAVE_POSIX2008_SCANDIR, 1, [POSIX 2008 scandir]) -AC_MSG_RESULT(yes) -],[ -AC_MSG_RESULT(no) -]) -CFLAGS="$tmp_flags" - - -AC_MSG_CHECKING(whether .text pseudo-op must be used) -AC_CACHE_VAL(am_cv_sysio_asm_dot_text, [dnl -cat > conftest.s </dev/null; then - am_cv_sysio_asm_dot_text=.text - fi - rm -f conftest*]) -if test -z "$am_cv_sysio_asm_dot_text"; then - AC_MSG_RESULT(no) -else - AC_MSG_RESULT(yes) -fi - -AC_CACHE_CHECK(for assembler global-symbol directive, - am_cv_sysio_asm_global_directive, [dnl -am_cv_sysio_asm_global_directive=UNKNOWN -for ac_globl in .globl .global .EXPORT; do - cat > conftest.s </dev/null; then - am_cv_sysio_asm_global_directive=${ac_globl} - fi - rm -f conftest* - test $am_cv_sysio_asm_global_directive != UNKNOWN && break -done]) -if test $am_cv_sysio_asm_global_directive = UNKNOWN; then - AC_MSG_ERROR(cannot determine asm global directive) -#else -# AC_DEFINE_UNQUOTED(ASM_GLOBAL_DIRECTIVE, ${am_cv_sysio_asm_global_directive}) -fi - -AC_CACHE_CHECK(for .set assembler directive, - am_cv_sysio_asm_set_directive, [dnl -cat > conftest.s< conftest1.c <&AC_FD_CC 2>&AC_FD_CC; then - am_cv_sysio_asm_set_directive=yes - else - am_cv_sysio_asm_set_directive=no - fi - rm -f conftest*]) -#if test $am_cv_sysio_asm_set_directive = yes; then -# AC_DEFINE(HAVE_ASM_SET_DIRECTIVE) -#fi - -AC_CACHE_CHECK(for assembler .weak directive, am_cv_sysio_asm_weak_directive, - [dnl -cat > conftest.s </dev/null; then - am_cv_sysio_asm_weak_directive=yes - else - am_cv_sysio_asm_weak_directive=no - fi - rm -f conftest*]) - -if test $am_cv_sysio_asm_weak_directive = no; then - AC_CACHE_CHECK(for assembler .weakext directive, - am_cv_sysio_asm_weakext_directive, [dnl -cat > conftest.s </dev/null; then - am_cv_sysio_asm_weakext_directive=yes - else - am_cv_sysio_asm_weakext_directive=no - fi - rm -f conftest*]) -fi # no .weak - -if test x$am_cv_sysio_asm_weak_directive = xyes; then - AC_DEFINE(HAVE_ASM_WEAK_DIRECTIVE) -fi -if test x$am_cv_sysio_asm_weakext_directive = xyes; then - AC_DEFINE(HAVE_ASM_WEAKEXT_DIRECTIVE) -fi - -AC_OUTPUT( - Makefile - tests/Makefile) diff --git a/libsysio/depcomp b/libsysio/depcomp deleted file mode 100755 index bd0ac08..0000000 --- a/libsysio/depcomp +++ /dev/null @@ -1,688 +0,0 @@ -#! /bin/sh -# depcomp - compile a program generating dependencies as side-effects - -scriptversion=2011-12-04.11; # UTC - -# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010, -# 2011 Free Software Foundation, Inc. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, 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 . - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Originally written by Alexandre Oliva . - -case $1 in - '') - echo "$0: No command. Try \`$0 --help' for more information." 1>&2 - exit 1; - ;; - -h | --h*) - cat <<\EOF -Usage: depcomp [--help] [--version] PROGRAM [ARGS] - -Run PROGRAMS ARGS to compile a file, generating dependencies -as side-effects. - -Environment variables: - depmode Dependency tracking mode. - source Source file read by `PROGRAMS ARGS'. - object Object file output by `PROGRAMS ARGS'. - DEPDIR directory where to store dependencies. - depfile Dependency file to output. - tmpdepfile Temporary file to use when outputting dependencies. - libtool Whether libtool is used (yes/no). - -Report bugs to . -EOF - exit $? - ;; - -v | --v*) - echo "depcomp $scriptversion" - exit $? - ;; -esac - -if test -z "$depmode" || test -z "$source" || test -z "$object"; then - echo "depcomp: Variables source, object and depmode must be set" 1>&2 - exit 1 -fi - -# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. -depfile=${depfile-`echo "$object" | - sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} -tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} - -rm -f "$tmpdepfile" - -# Some modes work just like other modes, but use different flags. We -# parameterize here, but still list the modes in the big case below, -# to make depend.m4 easier to write. Note that we *cannot* use a case -# here, because this file can only contain one case statement. -if test "$depmode" = hp; then - # HP compiler uses -M and no extra arg. - gccflag=-M - depmode=gcc -fi - -if test "$depmode" = dashXmstdout; then - # This is just like dashmstdout with a different argument. - dashmflag=-xM - depmode=dashmstdout -fi - -cygpath_u="cygpath -u -f -" -if test "$depmode" = msvcmsys; then - # This is just like msvisualcpp but w/o cygpath translation. - # Just convert the backslash-escaped backslashes to single forward - # slashes to satisfy depend.m4 - cygpath_u='sed s,\\\\,/,g' - depmode=msvisualcpp -fi - -if test "$depmode" = msvc7msys; then - # This is just like msvc7 but w/o cygpath translation. - # Just convert the backslash-escaped backslashes to single forward - # slashes to satisfy depend.m4 - cygpath_u='sed s,\\\\,/,g' - depmode=msvc7 -fi - -case "$depmode" in -gcc3) -## gcc 3 implements dependency tracking that does exactly what -## we want. Yay! Note: for some reason libtool 1.4 doesn't like -## it if -MD -MP comes after the -MF stuff. Hmm. -## Unfortunately, FreeBSD c89 acceptance of flags depends upon -## the command line argument order; so add the flags where they -## appear in depend2.am. Note that the slowdown incurred here -## affects only configure: in makefiles, %FASTDEP% shortcuts this. - for arg - do - case $arg in - -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; - *) set fnord "$@" "$arg" ;; - esac - shift # fnord - shift # $arg - done - "$@" - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - mv "$tmpdepfile" "$depfile" - ;; - -gcc) -## There are various ways to get dependency output from gcc. Here's -## why we pick this rather obscure method: -## - Don't want to use -MD because we'd like the dependencies to end -## up in a subdir. Having to rename by hand is ugly. -## (We might end up doing this anyway to support other compilers.) -## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like -## -MM, not -M (despite what the docs say). -## - Using -M directly means running the compiler twice (even worse -## than renaming). - if test -z "$gccflag"; then - gccflag=-MD, - fi - "$@" -Wp,"$gccflag$tmpdepfile" - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - echo "$object : \\" > "$depfile" - alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz -## The second -e expression handles DOS-style file names with drive letters. - sed -e 's/^[^:]*: / /' \ - -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" -## This next piece of magic avoids the `deleted header file' problem. -## The problem is that when a header file which appears in a .P file -## is deleted, the dependency causes make to die (because there is -## typically no way to rebuild the header). We avoid this by adding -## dummy dependencies for each header file. Too bad gcc doesn't do -## this for us directly. - tr ' ' ' -' < "$tmpdepfile" | -## Some versions of gcc put a space before the `:'. On the theory -## that the space means something, we add a space to the output as -## well. hp depmode also adds that space, but also prefixes the VPATH -## to the object. Take care to not repeat it in the output. -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ - | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -hp) - # This case exists only to let depend.m4 do its work. It works by - # looking at the text of this script. This case will never be run, - # since it is checked for above. - exit 1 - ;; - -sgi) - if test "$libtool" = yes; then - "$@" "-Wp,-MDupdate,$tmpdepfile" - else - "$@" -MDupdate "$tmpdepfile" - fi - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - - if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files - echo "$object : \\" > "$depfile" - - # Clip off the initial element (the dependent). Don't try to be - # clever and replace this with sed code, as IRIX sed won't handle - # lines with more than a fixed number of characters (4096 in - # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; - # the IRIX cc adds comments like `#:fec' to the end of the - # dependency line. - tr ' ' ' -' < "$tmpdepfile" \ - | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ - tr ' -' ' ' >> "$depfile" - echo >> "$depfile" - - # The second pass generates a dummy entry for each header file. - tr ' ' ' -' < "$tmpdepfile" \ - | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ - >> "$depfile" - else - # The sourcefile does not contain any dependencies, so just - # store a dummy comment line, to avoid errors with the Makefile - # "include basename.Plo" scheme. - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" - ;; - -aix) - # The C for AIX Compiler uses -M and outputs the dependencies - # in a .u file. In older versions, this file always lives in the - # current directory. Also, the AIX compiler puts `$object:' at the - # start of each line; $object doesn't have directory information. - # Version 6 uses the directory in both cases. - dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` - test "x$dir" = "x$object" && dir= - base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` - if test "$libtool" = yes; then - tmpdepfile1=$dir$base.u - tmpdepfile2=$base.u - tmpdepfile3=$dir.libs/$base.u - "$@" -Wc,-M - else - tmpdepfile1=$dir$base.u - tmpdepfile2=$dir$base.u - tmpdepfile3=$dir$base.u - "$@" -M - fi - stat=$? - - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" - exit $stat - fi - - for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" - do - test -f "$tmpdepfile" && break - done - if test -f "$tmpdepfile"; then - # Each line is of the form `foo.o: dependent.h'. - # Do two passes, one to just change these to - # `$object: dependent.h' and one to simply `dependent.h:'. - sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" - # That's a tab and a space in the []. - sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" - else - # The sourcefile does not contain any dependencies, so just - # store a dummy comment line, to avoid errors with the Makefile - # "include basename.Plo" scheme. - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" - ;; - -icc) - # Intel's C compiler understands `-MD -MF file'. However on - # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c - # ICC 7.0 will fill foo.d with something like - # foo.o: sub/foo.c - # foo.o: sub/foo.h - # which is wrong. We want: - # sub/foo.o: sub/foo.c - # sub/foo.o: sub/foo.h - # sub/foo.c: - # sub/foo.h: - # ICC 7.1 will output - # foo.o: sub/foo.c sub/foo.h - # and will wrap long lines using \ : - # foo.o: sub/foo.c ... \ - # sub/foo.h ... \ - # ... - - "$@" -MD -MF "$tmpdepfile" - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - # Each line is of the form `foo.o: dependent.h', - # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. - # Do two passes, one to just change these to - # `$object: dependent.h' and one to simply `dependent.h:'. - sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" - # Some versions of the HPUX 10.20 sed can't process this invocation - # correctly. Breaking it into two sed invocations is a workaround. - sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | - sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -hp2) - # The "hp" stanza above does not work with aCC (C++) and HP's ia64 - # compilers, which have integrated preprocessors. The correct option - # to use with these is +Maked; it writes dependencies to a file named - # 'foo.d', which lands next to the object file, wherever that - # happens to be. - # Much of this is similar to the tru64 case; see comments there. - dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` - test "x$dir" = "x$object" && dir= - base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` - if test "$libtool" = yes; then - tmpdepfile1=$dir$base.d - tmpdepfile2=$dir.libs/$base.d - "$@" -Wc,+Maked - else - tmpdepfile1=$dir$base.d - tmpdepfile2=$dir$base.d - "$@" +Maked - fi - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile1" "$tmpdepfile2" - exit $stat - fi - - for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" - do - test -f "$tmpdepfile" && break - done - if test -f "$tmpdepfile"; then - sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" - # Add `dependent.h:' lines. - sed -ne '2,${ - s/^ *// - s/ \\*$// - s/$/:/ - p - }' "$tmpdepfile" >> "$depfile" - else - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" "$tmpdepfile2" - ;; - -tru64) - # The Tru64 compiler uses -MD to generate dependencies as a side - # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. - # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put - # dependencies in `foo.d' instead, so we check for that too. - # Subdirectories are respected. - dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` - test "x$dir" = "x$object" && dir= - base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` - - if test "$libtool" = yes; then - # With Tru64 cc, shared objects can also be used to make a - # static library. This mechanism is used in libtool 1.4 series to - # handle both shared and static libraries in a single compilation. - # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. - # - # With libtool 1.5 this exception was removed, and libtool now - # generates 2 separate objects for the 2 libraries. These two - # compilations output dependencies in $dir.libs/$base.o.d and - # in $dir$base.o.d. We have to check for both files, because - # one of the two compilations can be disabled. We should prefer - # $dir$base.o.d over $dir.libs/$base.o.d because the latter is - # automatically cleaned when .libs/ is deleted, while ignoring - # the former would cause a distcleancheck panic. - tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 - tmpdepfile2=$dir$base.o.d # libtool 1.5 - tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 - tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 - "$@" -Wc,-MD - else - tmpdepfile1=$dir$base.o.d - tmpdepfile2=$dir$base.d - tmpdepfile3=$dir$base.d - tmpdepfile4=$dir$base.d - "$@" -MD - fi - - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" - exit $stat - fi - - for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" - do - test -f "$tmpdepfile" && break - done - if test -f "$tmpdepfile"; then - sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" - # That's a tab and a space in the []. - sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" - else - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" - ;; - -msvc7) - if test "$libtool" = yes; then - showIncludes=-Wc,-showIncludes - else - showIncludes=-showIncludes - fi - "$@" $showIncludes > "$tmpdepfile" - stat=$? - grep -v '^Note: including file: ' "$tmpdepfile" - if test "$stat" = 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - echo "$object : \\" > "$depfile" - # The first sed program below extracts the file names and escapes - # backslashes for cygpath. The second sed program outputs the file - # name when reading, but also accumulates all include files in the - # hold buffer in order to output them again at the end. This only - # works with sed implementations that can handle large buffers. - sed < "$tmpdepfile" -n ' -/^Note: including file: *\(.*\)/ { - s//\1/ - s/\\/\\\\/g - p -}' | $cygpath_u | sort -u | sed -n ' -s/ /\\ /g -s/\(.*\)/ \1 \\/p -s/.\(.*\) \\/\1:/ -H -$ { - s/.*/ / - G - p -}' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -msvc7msys) - # This case exists only to let depend.m4 do its work. It works by - # looking at the text of this script. This case will never be run, - # since it is checked for above. - exit 1 - ;; - -#nosideeffect) - # This comment above is used by automake to tell side-effect - # dependency tracking mechanisms from slower ones. - -dashmstdout) - # Important note: in order to support this mode, a compiler *must* - # always write the preprocessed file to stdout, regardless of -o. - "$@" || exit $? - - # Remove the call to Libtool. - if test "$libtool" = yes; then - while test "X$1" != 'X--mode=compile'; do - shift - done - shift - fi - - # Remove `-o $object'. - IFS=" " - for arg - do - case $arg in - -o) - shift - ;; - $object) - shift - ;; - *) - set fnord "$@" "$arg" - shift # fnord - shift # $arg - ;; - esac - done - - test -z "$dashmflag" && dashmflag=-M - # Require at least two characters before searching for `:' - # in the target name. This is to cope with DOS-style filenames: - # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. - "$@" $dashmflag | - sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" - rm -f "$depfile" - cat < "$tmpdepfile" > "$depfile" - tr ' ' ' -' < "$tmpdepfile" | \ -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -dashXmstdout) - # This case only exists to satisfy depend.m4. It is never actually - # run, as this mode is specially recognized in the preamble. - exit 1 - ;; - -makedepend) - "$@" || exit $? - # Remove any Libtool call - if test "$libtool" = yes; then - while test "X$1" != 'X--mode=compile'; do - shift - done - shift - fi - # X makedepend - shift - cleared=no eat=no - for arg - do - case $cleared in - no) - set ""; shift - cleared=yes ;; - esac - if test $eat = yes; then - eat=no - continue - fi - case "$arg" in - -D*|-I*) - set fnord "$@" "$arg"; shift ;; - # Strip any option that makedepend may not understand. Remove - # the object too, otherwise makedepend will parse it as a source file. - -arch) - eat=yes ;; - -*|$object) - ;; - *) - set fnord "$@" "$arg"; shift ;; - esac - done - obj_suffix=`echo "$object" | sed 's/^.*\././'` - touch "$tmpdepfile" - ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" - rm -f "$depfile" - # makedepend may prepend the VPATH from the source file name to the object. - # No need to regex-escape $object, excess matching of '.' is harmless. - sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" - sed '1,2d' "$tmpdepfile" | tr ' ' ' -' | \ -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" "$tmpdepfile".bak - ;; - -cpp) - # Important note: in order to support this mode, a compiler *must* - # always write the preprocessed file to stdout. - "$@" || exit $? - - # Remove the call to Libtool. - if test "$libtool" = yes; then - while test "X$1" != 'X--mode=compile'; do - shift - done - shift - fi - - # Remove `-o $object'. - IFS=" " - for arg - do - case $arg in - -o) - shift - ;; - $object) - shift - ;; - *) - set fnord "$@" "$arg" - shift # fnord - shift # $arg - ;; - esac - done - - "$@" -E | - sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ - -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | - sed '$ s: \\$::' > "$tmpdepfile" - rm -f "$depfile" - echo "$object : \\" > "$depfile" - cat < "$tmpdepfile" >> "$depfile" - sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -msvisualcpp) - # Important note: in order to support this mode, a compiler *must* - # always write the preprocessed file to stdout. - "$@" || exit $? - - # Remove the call to Libtool. - if test "$libtool" = yes; then - while test "X$1" != 'X--mode=compile'; do - shift - done - shift - fi - - IFS=" " - for arg - do - case "$arg" in - -o) - shift - ;; - $object) - shift - ;; - "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") - set fnord "$@" - shift - shift - ;; - *) - set fnord "$@" "$arg" - shift - shift - ;; - esac - done - "$@" -E 2>/dev/null | - sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" - rm -f "$depfile" - echo "$object : \\" > "$depfile" - sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" - echo " " >> "$depfile" - sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -msvcmsys) - # This case exists only to let depend.m4 do its work. It works by - # looking at the text of this script. This case will never be run, - # since it is checked for above. - exit 1 - ;; - -none) - exec "$@" - ;; - -*) - echo "Unknown depmode $depmode" 1>&2 - exit 1 - ;; -esac - -exit 0 - -# Local Variables: -# mode: shell-script -# sh-indentation: 2 -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" -# time-stamp-end: "; # UTC" -# End: diff --git a/libsysio/dev/stdfd/.gitignore b/libsysio/dev/stdfd/.gitignore deleted file mode 100644 index c83c013..0000000 --- a/libsysio/dev/stdfd/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/.dirstamp diff --git a/libsysio/dev/stdfd/module.mk b/libsysio/dev/stdfd/module.mk deleted file mode 100644 index ad034fb..0000000 --- a/libsysio/dev/stdfd/module.mk +++ /dev/null @@ -1,2 +0,0 @@ -STDFD_SRCS = dev/stdfd/stdfd.c -STDFD_EXTRA = dev/stdfd/stdfd.h dev/stdfd/module.mk diff --git a/libsysio/dev/stdfd/stdfd.c b/libsysio/dev/stdfd/stdfd.c deleted file mode 100644 index 6ea426c..0000000 --- a/libsysio/dev/stdfd/stdfd.c +++ /dev/null @@ -1,258 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#ifdef __linux__ -#define _BSD_SOURCE -#endif - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "xtio.h" -#include "native.h" -#include "inode.h" -#include "dev.h" - -#include "stdfd.h" - -#ifdef CPLANT_YOD -#include -#include "cplant-yod.h" -#define dowrite(f, b, n) write_yod(f, b, n) -#define doread(f, b, n) read_yod(f, b, n) -#else -#define dowrite(f, b, n) syscall(SYSIO_SYS_write, f, b, n) -#define doread(f, b, n) syscall(SYSIO_SYS_read, f, b, n) -#endif - -/* - * Pre-opened standard file descriptors driver. - */ - -static int stdfd_open(struct pnode *pno, int flags, mode_t mode); -static int stdfd_close(struct inode *ino); -static int stdfd_read(struct inode *ino, struct ioctx *ioctx); -static int stdfd_write(struct inode *ino, struct ioctx *ioctx); -static int stdfd_iodone(struct ioctx *ioctx); -static int stdfd_datasync(struct inode *ino); -static int stdfd_fcntl(struct inode *ino, int cmd, va_list ap, int *rtn); -static int stdfd_ioctl(struct inode *ino, - unsigned long int request, - va_list ap); - -int -_sysio_stdfd_init() -{ - struct inode_ops stdfd_operations; - - stdfd_operations = _sysio_nodev_ops; - stdfd_operations.inop_open = stdfd_open; - stdfd_operations.inop_close = stdfd_close; - stdfd_operations.inop_read = stdfd_read; - stdfd_operations.inop_write = stdfd_write; - stdfd_operations.inop_iodone = stdfd_iodone; - stdfd_operations.inop_fcntl = stdfd_fcntl; - stdfd_operations.inop_datasync = stdfd_datasync; - stdfd_operations.inop_ioctl = stdfd_ioctl; - - return _sysio_char_dev_register(SYSIO_C_STDFD_MAJOR, - "stdfd", - &stdfd_operations); -} - -static int -stdfd_open(struct pnode *pno __IS_UNUSED, - int flags __IS_UNUSED, - mode_t mode __IS_UNUSED) -{ - - return 0; -} - -static int -stdfd_close(struct inode *ino __IS_UNUSED) -{ - - return 0; -} - -static int -doio(ssize_t (*f)(void *, size_t, _SYSIO_OFF_T, struct inode *), - struct inode *ino, - struct ioctx *ioctx) -{ - - if (ioctx->ioctx_xtvlen != 1) { - /* - * No scatter/gather to "file" address space (we're not - * seekable) and "nowhere" makes no sense. - */ - return -EINVAL; - } - ioctx->ioctx_cc = - _sysio_doio(ioctx->ioctx_xtv, ioctx->ioctx_xtvlen, - ioctx->ioctx_iov, ioctx->ioctx_iovlen, - (ssize_t (*)(void *, size_t, _SYSIO_OFF_T, void *))f, - ino); - if (ioctx->ioctx_cc < 0) { - ioctx->ioctx_errno = -ioctx->ioctx_cc; - ioctx->ioctx_cc = -1; - } - return 0; -} - -static ssize_t -stdfd_read_simple(void *buf, - size_t nbytes, - _SYSIO_OFF_T off __IS_UNUSED, - struct inode *ino) -{ - int fd = SYSIO_MINOR_DEV(ino->i_stbuf.st_rdev); - int cc; - - cc = doread(fd, buf, nbytes); - if (cc < 0) - cc = -errno; - return cc; -} - -static int -stdfd_read(struct inode *ino, struct ioctx *ioctx) -{ - - return doio(stdfd_read_simple, ino, ioctx); -} - -static ssize_t -stdfd_write_simple(const void *buf, - size_t nbytes, - _SYSIO_OFF_T off __IS_UNUSED, - struct inode *ino) -{ - int fd = SYSIO_MINOR_DEV(ino->i_stbuf.st_rdev); - int cc; - - cc = dowrite(fd, buf, nbytes); - if (cc < 0) - cc = -errno; - return cc; -} - -static int -stdfd_write(struct inode *ino, struct ioctx *ioctx) -{ - - return doio((ssize_t (*)(void *, - size_t, - _SYSIO_OFF_T, - struct inode *))stdfd_write_simple, - ino, - ioctx); -} - -static int -stdfd_iodone(struct ioctx *iocp __IS_UNUSED) -{ - - /* - * It's always done in this driver. It completed when posted. - */ - return 1; -} - -static int -stdfd_fcntl(struct inode *ino, - int cmd, - va_list ap, - int *rtn) -{ - int err; - int fd = SYSIO_MINOR_DEV(ino->i_stbuf.st_rdev); - long arg; - - err = 0; - switch (cmd) { - case F_GETFL: - *rtn = syscall(SYS_fcntl, fd, cmd); - if (*rtn == -1) - err = -errno; - break; - case F_SETFL: - arg = va_arg(ap, long); - *rtn = syscall(SYS_fcntl, fd, cmd, arg); - if (*rtn == -1) - err = -errno; - va_end(ap); - break; - default: - *rtn = -1; - err = -EINVAL; - } - return err; -} - -static int -stdfd_datasync(struct inode *ino __IS_UNUSED) -{ - - /* - * We don't buffer, so nothing to do. - */ - return 0; -} - -static int -stdfd_ioctl(struct inode *ino __IS_UNUSED, - unsigned long int request __IS_UNUSED, - va_list ap __IS_UNUSED) -{ - - return -ENOTTY; -} diff --git a/libsysio/dev/stdfd/stdfd.h b/libsysio/dev/stdfd/stdfd.h deleted file mode 100644 index 3bac7c1..0000000 --- a/libsysio/dev/stdfd/stdfd.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -/* - * Std{in,out,err} pseudo-device-driver support. - */ - -#define SYSIO_C_STDFD_MAJOR 0 - -extern int _sysio_stdfd_init(void); diff --git a/libsysio/drivers/incore/.gitignore b/libsysio/drivers/incore/.gitignore deleted file mode 100644 index c83c013..0000000 --- a/libsysio/drivers/incore/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/.dirstamp diff --git a/libsysio/drivers/incore/README b/libsysio/drivers/incore/README deleted file mode 100644 index 2f8c4b8..0000000 --- a/libsysio/drivers/incore/README +++ /dev/null @@ -1,27 +0,0 @@ -This "incore" file system driver is a self-contained file system. It does -not use any resource external to the node. - -It is primarily intended for enabling an efficient compute-node bootstrap. It -might also be useful for a very small scratch file system, holding device -files, and the like. - -The root directory i-node is manufactured on the fly. The source specification -for the mount() call should be something like: - - ++ - -Where: - are the directory permissions masked by 0777 - Note -- no umask is applied. - should be the owner's uid - should be the owner's gid - -Most operations are supported, with the notable exception of symbolic -links. - -In the implementation, the driver is really set up to export most -useful symbols without polluting the name space or contending with -other public symbols. However, the symbols are not yet exported. If -we ever require a proc-fs style file system, this could be very useful -provided a little extra work is done to allow other drivers to overload -some operations. Particularly the file ops, I would think. diff --git a/libsysio/drivers/incore/fs_incore.c b/libsysio/drivers/incore/fs_incore.c deleted file mode 100644 index ec94abc..0000000 --- a/libsysio/drivers/incore/fs_incore.c +++ /dev/null @@ -1,1727 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#ifdef __linux__ -#define _BSD_SOURCE -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef _HAVE_STATVFS -#include -#endif -#include - -#include "sysio.h" -#include "xtio.h" -#include "fs.h" -#include "mount.h" -#include "inode.h" -#include "dev.h" - -#include "fs_incore.h" - - -/* - * In-core file system pseudo-driver. - */ - -/* - * Pseudo-blocksize. - */ -#define INCORE_BLKSIZE (8192) - -/* - * Format of an incore inode. - */ -struct incore_inode { - LIST_ENTRY(incore_inode) ici_link; /* i-nodes list link */ - struct intnl_stat ici_st; /* attrs */ - struct file_identifier ici_fileid; /* file ID */ - void *ici_data; /* file data */ -}; - -/* - * Given pointer to inode, return pointer to incore-inode. - */ -#define I2IC(ino) ((struct incore_inode *)(ino)->i_private) - -struct incore_filesys { - LIST_HEAD(, incore_inode) icfs_icinodes; /* all i-nodes list */ -}; - -/* - * Given pointer to filesys, return pointer to incore-filesys. - */ -#define FS2ICFS(fs) ((struct incore_filesys *)(fs)->fs_private) - -static int _sysio_incore_fsswop_mount(const char *source, - unsigned flags, - const void *data, - struct pnode *tocover, - struct mount **mntp); - -static struct fssw_ops incore_fssw_ops = { - _sysio_incore_fsswop_mount -}; - -static void _sysio_incore_fsop_gone(struct filesys *fs); - -static struct filesys_ops incore_fs_ops = { - _sysio_incore_fsop_gone, -}; - -static int _sysio_incore_dirop_lookup(struct pnode *pno, - struct inode **inop, - struct intent *intnt, - const char *path); -static int _sysio_incore_inop_getattr(struct pnode *pno, - struct inode *ino, - struct intnl_stat *stbuf); -static int _sysio_incore_inop_setattr(struct pnode *pno, - struct inode *ino, - unsigned mask, - struct intnl_stat *stbuf); -static ssize_t _sysio_incore_dirop_filldirentries(struct inode *ino, - _SYSIO_OFF_T *posp, - char *buf, - size_t nbytes); -static int _sysio_incore_dirop_mkdir(struct pnode *pno, mode_t mode); -static int _sysio_incore_dirop_rmdir(struct pnode *pno); -static int _sysio_incore_inop_open(struct pnode *pno, int flags, mode_t mode); -static int _sysio_incore_inop_close(struct inode *ino); -static int _sysio_incore_dirop_link(struct pnode *old, struct pnode *new); -static int _sysio_incore_dirop_unlink(struct pnode *pno); -static int _sysio_incore_dirop_rename(struct pnode *old, struct pnode *new); -static int _sysio_incore_filop_read(struct inode *ino, struct ioctx *ioctx); -static int _sysio_incore_filop_write(struct inode *ino, struct ioctx *ioctx); -static _SYSIO_OFF_T _sysio_incore_filop_pos(struct inode *ino, - _SYSIO_OFF_T off); -static int _sysio_incore_filop_iodone(struct ioctx *ioctx); -static int _sysio_incore_filop_fcntl(struct inode *ino, - int cmd, va_list ap, int *rtn); -static int _sysio_incore_inop_sync(struct inode *ino); -static int _sysio_incore_filop_ioctl(struct inode *ino, - unsigned long int request, - va_list ap); -static int _sysio_incore_dirop_mknod(struct pnode *pno, mode_t mode, dev_t dev); -#ifdef _HAVE_STATVFS -static int _sysio_incore_inop_statvfs(struct pnode *pno, - struct inode *ino, - struct intnl_statvfs *buf); -#endif -static void _sysio_incore_inop_gone(struct inode *ino); - -#define _sysio_incore_dirop_symlink \ - (int (*)(struct pnode *, const char *))_sysio_do_enosys -#define _sysio_incore_dirop_readlink \ - (int (*)(struct pnode *, char *, size_t))_sysio_do_enosys -#define _sysio_incore_dirop_read \ - (int (*)(struct inode *, \ - struct ioctx *))_sysio_do_eisdir -#define _sysio_incore_dirop_write \ - (int (*)(struct inode *, \ - struct ioctx *))_sysio_do_eisdir -#define _sysio_incore_dirop_pos \ - (_SYSIO_OFF_T (*)(struct inode *, \ - _SYSIO_OFF_T))_sysio_do_eisdir -#define _sysio_incore_dirop_iodone \ - (int (*)(struct ioctx *))_sysio_do_illop -#define _sysio_incore_dirop_fcntl \ - (int (*)(struct inode *, int, va_list, int *))_sysio_do_eisdir -#define _sysio_incore_dirop_ioctl \ - (int (*)(struct inode *, \ - unsigned long int, \ - va_list))_sysio_do_eisdir - -static struct inode_ops _sysio_incore_dir_ops = { - _sysio_incore_dirop_lookup, - _sysio_incore_inop_getattr, - _sysio_incore_inop_setattr, - _sysio_incore_dirop_filldirentries, - _sysio_incore_dirop_mkdir, - _sysio_incore_dirop_rmdir, - _sysio_incore_dirop_symlink, - _sysio_incore_dirop_readlink, - _sysio_incore_inop_open, - _sysio_incore_inop_close, - _sysio_incore_dirop_link, - _sysio_incore_dirop_unlink, - _sysio_incore_dirop_rename, - _sysio_incore_dirop_read, - _sysio_incore_dirop_write, - _sysio_incore_dirop_pos, - _sysio_incore_dirop_iodone, - _sysio_incore_dirop_fcntl, - _sysio_incore_inop_sync, - _sysio_incore_inop_sync, - _sysio_incore_dirop_ioctl, - _sysio_incore_dirop_mknod, -#ifdef _HAVE_STATVFS - _sysio_incore_inop_statvfs, -#endif - _sysio_incore_inop_gone -}; - -#define _sysio_incore_filop_lookup \ - (int (*)(struct pnode *, \ - struct inode **, \ - struct intent *, \ - const char *))_sysio_do_illop -#define _sysio_incore_filop_filldirentries \ - (ssize_t (*)(struct inode *, \ - _SYSIO_OFF_T *, \ - char *, \ - size_t))_sysio_do_illop -#define _sysio_incore_filop_mkdir \ - (int (*)(struct pnode *, mode_t))_sysio_do_illop -#define _sysio_incore_filop_rmdir \ - (int (*)(struct pnode *))_sysio_do_illop -#define _sysio_incore_filop_symlink \ - (int (*)(struct pnode *, const char *))_sysio_do_illop -#define _sysio_incore_symlinkop_readlink \ - (int (*)(struct pnode *, char *, size_t))_sysio_do_illop -#define _sysio_incore_filop_link \ - (int (*)(struct pnode *old, struct pnode *new))_sysio_do_illop -#define _sysio_incore_filop_unlink \ - (int (*)(struct pnode *pno))_sysio_do_illop -#define _sysio_incore_filop_rename \ - (int (*)(struct pnode *old, struct pnode *new))_sysio_do_illop -#define _sysio_incore_filop_mknod \ - (int (*)(struct pnode *pno, mode_t, dev_t))_sysio_do_illop - -static struct inode_ops _sysio_incore_file_ops = { - _sysio_incore_filop_lookup, - _sysio_incore_inop_getattr, - _sysio_incore_inop_setattr, - _sysio_incore_filop_filldirentries, - _sysio_incore_filop_mkdir, - _sysio_incore_filop_rmdir, - _sysio_incore_filop_symlink, - _sysio_incore_symlinkop_readlink, - _sysio_incore_inop_open, - _sysio_incore_inop_close, - _sysio_incore_filop_link, - _sysio_incore_filop_unlink, - _sysio_incore_filop_rename, - _sysio_incore_filop_read, - _sysio_incore_filop_write, - _sysio_incore_filop_pos, - _sysio_incore_filop_iodone, - _sysio_incore_filop_fcntl, - _sysio_incore_inop_sync, - _sysio_incore_inop_sync, - _sysio_incore_filop_ioctl, - _sysio_incore_filop_mknod, -#ifdef _HAVE_STATVFS - _sysio_incore_inop_statvfs, -#endif - _sysio_incore_inop_gone -}; - -static struct inode_ops _sysio_incore_dev_ops = { - _sysio_incore_filop_lookup, - _sysio_incore_inop_getattr, - _sysio_incore_inop_setattr, - _sysio_incore_filop_filldirentries, - _sysio_incore_filop_mkdir, - _sysio_incore_filop_rmdir, - _sysio_incore_filop_symlink, - _sysio_incore_symlinkop_readlink, - _sysio_nodev_inop_open, - _sysio_nodev_inop_close, - _sysio_incore_filop_link, - _sysio_incore_filop_unlink, - _sysio_incore_filop_rename, - _sysio_nodev_inop_read, - _sysio_nodev_inop_write, - _sysio_nodev_inop_pos, - _sysio_nodev_inop_iodone, - _sysio_incore_filop_fcntl, - _sysio_incore_inop_sync, - _sysio_nodev_inop_sync, - _sysio_nodev_inop_ioctl, - _sysio_incore_filop_mknod, -#ifdef _HAVE_STATVFS - _sysio_incore_inop_statvfs, -#endif - _sysio_incore_inop_gone -}; - -typedef void *(*probe_ty)(void *data, size_t len, void *arg); - -/* - * Lookup data argument bundle record. - */ -struct lookup_data { - struct qstr *name; /* desired entry name */ - struct intnl_dirent *de; /* last dirent */ - size_t minsiz; /* min hole needed */ - struct { - void *p; /* best hole */ - size_t len; /* best hole len */ - } hole; -}; - -/* - * Initialize lookup data argument bundle. - */ -#define INCORE_LD_INIT(ld, minsz, qs) \ - do { \ - (ld)->name = (qs); \ - (ld)->de = NULL; \ - (ld)->minsiz = (minsz); \ - (ld)->hole.p = NULL; \ - (ld)->hole.len = 0; \ - } while (0) - -/* - * Calculate size of a directory entry given length of the entry name. - */ -#define INCORE_D_RECLEN(namlen) \ - (((size_t )&((struct intnl_dirent *)0)->d_name + \ - (namlen) + 1 + sizeof(void *)) & \ - ~(sizeof(void *) - 1)) - -/* - * Given mode bits, return directory entry type code. - */ -#define INCORE_D_TYPEOF(m) (((m) & S_IFMT) >> 12) -#define INCORE_D_TEMPLATE_LEN (INCORE_D_RECLEN(1) + INCORE_D_RECLEN(2)) - -char *incore_dir_template; -#if 0 -static struct intnl_dirent incore_dir_template[] = { - { - 0, - INCORE_D_RECLEN(1), - INCORE_D_RECLEN(1), - INCORE_D_TYPEOF(S_IFDIR), - { '.', '\0' } - }, - { - 0, - INCORE_D_RECLEN(1) + INCORE_D_RECLEN(2), - INCORE_D_RECLEN(2), - INCORE_D_TYPEOF(S_IFDIR), - { '.', '.', '\0' } - } -}; -#endif - -/* - * Initialize this driver. - */ -int -_sysio_incore_init() -{ - struct intnl_dirent *de; - off_t off; - - /* - * Fill in the directory template. - */ - incore_dir_template = calloc(1, INCORE_D_TEMPLATE_LEN); - if (incore_dir_template == NULL) - return -ENOMEM; - de = (struct intnl_dirent *)incore_dir_template; -#ifdef _DIRENT_HAVE_D_OFF - de->d_off = -#endif - off = de->d_reclen = INCORE_D_RECLEN(1); - de->d_type = INCORE_D_TYPEOF(S_IFDIR); - de->d_name[0] = '.'; -#ifdef _DIRENT_HAVE_D_NAMLEN - de->d_namlen = 1; -#endif - /* - * Move to entry for `..' - */ - de = (struct intnl_dirent *)((char *)de + off); - de->d_reclen = INCORE_D_RECLEN(2); -#ifdef _DIRENT_HAVE_D_NAMLEN - de->d_namlen = 2; -#endif -#ifdef _DIRENT_HAVE_D_OFF - de->d_off = -#endif - off += de->d_reclen; - de->d_type = INCORE_D_TYPEOF(S_IFDIR); - de->d_name[0] = de->d_name[1] = '.'; - de->d_name[2] = ' '; - - return _sysio_fssw_register("incore", &incore_fssw_ops); -} - -static ino_t -incore_inum_alloc() -{ - static ino_t nxtnum = 1; - - assert(nxtnum); - return nxtnum++; -} - -static struct incore_inode * -incore_i_alloc(struct incore_filesys *icfs, struct intnl_stat *st) -{ - struct incore_inode *icino; - - assert(st->st_ino); - assert(!st->st_size); - - icino = malloc(sizeof(struct incore_inode)); - if (!icino) - return NULL; - icino->ici_st = *st; - icino->ici_fileid.fid_data = &icino->ici_st.st_ino; - icino->ici_fileid.fid_len = sizeof(icino->ici_st.st_ino); - icino->ici_data = NULL; - - LIST_INSERT_HEAD(&icfs->icfs_icinodes, icino, ici_link); - - return icino; -} - -static int -incore_trunc(struct incore_inode *icino, _SYSIO_OFF_T size, int clear) -{ - _SYSIO_OFF_T n; - void *p; - - if (size < 0) - return -EINVAL; - n = size; - if (!size) { - if (icino->ici_data) { - free(icino->ici_data); - icino->ici_data = NULL; - } - n = 0; - goto out; - } - p = realloc(icino->ici_data, (size_t )n); - if (!p) - return -ENOSPC; - icino->ici_data = p; - if (clear && n > icino->ici_st.st_size) - (void )memset((char *)icino->ici_data + icino->ici_st.st_size, - 0, - (size_t )(n - icino->ici_st.st_size)); -out: - icino->ici_st.st_size = n; - icino->ici_st.st_blocks = - (n + icino->ici_st.st_blksize - 1) / icino->ici_st.st_blksize; - icino->ici_st.st_mtime = time(NULL); - return 0; -} - -static void -incore_i_destroy(struct incore_inode *icino) -{ - - LIST_REMOVE(icino, ici_link); - (void )incore_trunc(icino, 0, 0); - free(icino); -} - -static struct incore_inode * -incore_directory_new(struct incore_filesys *icfs, - struct incore_inode *parent, - struct intnl_stat *st) -{ - struct incore_inode *icino; - int err; - struct intnl_dirent *de; - - icino = incore_i_alloc(icfs, st); - if (!icino) - return NULL; - - if (!parent) - parent = icino; /* root */ - - /* - * Allocate and init directory data. - */ - err = incore_trunc(icino, INCORE_D_TEMPLATE_LEN, 1); - if (err) { - incore_i_destroy(icino); - return NULL; - } - (void )memcpy(icino->ici_data, - &incore_dir_template, - INCORE_D_TEMPLATE_LEN); - de = icino->ici_data; - de->d_ino = st->st_ino; - de = - (struct intnl_dirent *)((char *)de + -#ifdef _DIRENT_HAVE_D_OFF - de->d_off -#else - de->d_reclen -#endif - ); - de->d_ino = parent->ici_st.st_ino; - - /* - * Set creation time to modify time set by truncate. - */ - st->st_ctime = st->st_mtime; - - return icino; -} - -static int -_sysio_incore_fsswop_mount(const char *source, - unsigned flags, - const void *data __IS_UNUSED, - struct pnode *tocover, - struct mount **mntp) -{ - char *cp; - unsigned long ul; - long l; - mode_t mode; - uid_t uid; - gid_t gid; - int err; - dev_t dev; - struct intnl_stat stat; - struct incore_filesys *icfs; - ino_t inum; - struct incore_inode *icino; - struct filesys *fs; - struct inode *rooti; - struct pnode_base *rootpb; - struct mount *mnt; - static struct qstr noname = { NULL, 0, 0 }; - - /* - * Source is a specification for the root attributes of this - * new file system in the format: - * - * [+][-] - */ - ul = strtoul(source, &cp, 0); - mode = (mode_t )ul & 07777; - uid = getuid(); /* default */ - gid = getgid(); /* default */ - if (*cp != '\0') { - /* - * Get user and/or group. - */ - if (*cp != '+' || - (ul == ULONG_MAX && errno == ERANGE) || - (unsigned long)mode != ul || - mode > 07777) - return -EINVAL; - source = cp; - l = strtol(source, &cp, 0); - uid = (uid_t )l; - if (((l == LONG_MIN || l == LONG_MAX) && - errno == ERANGE) || - (long )uid != l) - return -EINVAL; - if (*cp != '+') - return -EINVAL; - source = cp; - l = strtol(source, &cp, 0); - gid = (gid_t )l; - if (((l == LONG_MIN || l == LONG_MAX) && - errno == ERANGE) || - (long )gid != l) - return -EINVAL; - if (*cp != '\0') - return -EINVAL; - } - - err = 0; - - dev = _sysio_dev_alloc(); - - mnt = NULL; - rootpb = NULL; - rooti = NULL; - fs = NULL; - icino = NULL; - icfs = NULL; - - /* - * Create new FS. - */ - icfs = malloc(sizeof(struct incore_filesys)); - if (!icfs) { - err = -ENOMEM; - goto error; - } - (void )memset(icfs, 0, sizeof(struct incore_filesys)); - LIST_INIT(&icfs->icfs_icinodes); - - /* - * Create root i-node. - */ - (void )memset(&stat, 0, sizeof(stat)); - stat.st_dev = dev; - inum = incore_inum_alloc(); -#ifdef HAVE__ST_INO - stat.__st_ino = inum; -#endif - stat.st_mode = S_IFDIR | (mode & 07777); - stat.st_nlink = 2; - stat.st_uid = uid; - stat.st_gid = gid; - stat.st_size = 0; - stat.st_blksize = INCORE_BLKSIZE; - stat.st_blocks = 0; - stat.st_ctime = stat.st_mtime = stat.st_atime = 0; - stat.st_ino = inum; - icino = incore_directory_new(icfs, NULL, &stat); - if (!icino) - return -ENOSPC; - icino->ici_st.st_atime = icino->ici_st.st_mtime; - - fs = - _sysio_fs_new(&incore_fs_ops, - (flags & MOUNT_F_RO) ? FS_F_RO : 0, - icfs); - if (!fs) { - err = -ENOMEM; - goto error; - } - - /* - * Create root for system. - * - * Persistent across remounts because we ask for immunity. - */ - rooti = - _sysio_i_new(fs, - &icino->ici_fileid, - &icino->ici_st, - 1, - &_sysio_incore_dir_ops, - icino); - if (!rooti) { - err = -ENOMEM; - goto error; - } - rootpb = _sysio_pb_new(&noname, NULL, rooti); - if (!rootpb) { - err = -ENOMEM; - goto error; - } - - /* - * Have path-node specified by the given source argument. Let the - * system finish the job, now. - */ - mnt = NULL; - err = - _sysio_do_mount(fs, - rootpb, - flags, - tocover, - &mnt); - if (err) - goto error; - - *mntp = mnt; - - goto out; - -error: - if (mnt && _sysio_do_unmount(mnt) != 0) - abort(); - if (rootpb) { - _sysio_pb_gone(rootpb); - rooti = NULL; - } - if (rooti) - I_RELE(rooti); - if (fs) { - FS_RELE(fs); - goto out; - } - if (icino) { - incore_i_destroy(icino); - goto out; - } - if (icfs) { - free(icfs); - goto out; - } - -out: - return err; -} - -static void -_sysio_incore_fsop_gone(struct filesys *fs) -{ - struct incore_filesys *icfs; - struct incore_inode *icino, *oicino; - - icfs = FS2ICFS(fs); - - /* - * Free up i-node resource associated with this file system. - */ - icino = icfs->icfs_icinodes.lh_first; - while (icino) { - oicino = icino; - icino = icino->ici_link.le_next; - incore_i_destroy(oicino); - } - - /* - * Free the FS record. - */ - free(icfs); -} - -/* - * A directory search engine. Various functions are carried out by - * supplying appropriate callback functions. - * - * The two arguments, entry and hole, are called, if not null, for each - * directory entry and hole, respectively. - */ -static void * -incore_directory_probe(void *data, - size_t siz, - _SYSIO_OFF_T origin -#ifndef _DIRENT_HAVE_D_OFF - __IS_UNUSED -#endif - , - probe_ty entry, - probe_ty hole, - void *arg) -{ - struct intnl_dirent *de; - void *p; - size_t n; - - de = data; - for (;;) { -#ifdef _DIRENT_HAVE_D_OFF - assert(de->d_off); -#else - assert(de->d_reclen); -#endif - if (entry && (p = (*entry)(de, de->d_reclen, arg))) - return p; - n = -#ifdef _DIRENT_HAVE_D_OFF - de->d_off - origin; -#else - ((void *)de - data) + de->d_reclen; -#endif - if (hole) { - p = (*hole)((void *)de, de->d_reclen, arg); - if (p) - return p; - } - if (n >= siz) - break; - de = (struct intnl_dirent *)((char *)data + n); - } - - return NULL; -} - -static struct intnl_dirent * -incore_directory_match(struct intnl_dirent *de, - size_t reclen, - struct lookup_data *ld) -{ - size_t len; - -#if defined(BSD) || defined(REDSTORM) - if (IFTODT(de->d_type) == DT_WHT) - return NULL; -#endif -#ifdef _DIRENT_HAVE_D_NAMLEN - len = de->d_namlen; -#else - { - const char *cp, *end; - - cp = de->d_name; - end = (const char *)de + reclen; - while (cp < end && *cp != '\0') - cp++; - len = cp - de->d_name; - } -#endif - if (ld->name->len == len && - strncmp(de->d_name, ld->name->name, ld->name->len) == 0) - return de; - ld->de = de; - return NULL; -} - -static int -_sysio_incore_dirop_lookup(struct pnode *pno, - struct inode **inop, - struct intent *intnt __IS_UNUSED, - const char *path __IS_UNUSED) -{ - struct inode *ino; - struct intnl_dirent *de; - struct incore_inode *icino; - struct lookup_data lookup_data; - struct file_identifier fileid; -#ifdef notdef - struct inode_ops *ops; -#endif - - /* - * Revalidate? - */ - if (*inop) { - icino = I2IC(*inop); - assert(icino); - (*inop)->i_stbuf = icino->ici_st; - return 0; - } - - ino = pno->p_parent->p_base->pb_ino; - icino = I2IC(ino); - INCORE_LD_INIT(&lookup_data, - ULONG_MAX, - &pno->p_base->pb_name); - de = - incore_directory_probe(icino->ici_data, - icino->ici_st.st_size, - 0, - (probe_ty )incore_directory_match, - NULL, - &lookup_data); - if (!de) - return -ENOENT; - - fileid.fid_data = &de->d_ino; - fileid.fid_len = sizeof(de->d_ino); - ino = - _sysio_i_find(ino->i_fs, &fileid); -#ifdef notdef - if (ino) - goto out; - icino->ici_fileid.fid_data = &icino->ici_st.st_ino; - icino->ici_fileid.fid_len = sizeof(icino->ici_st.st_ino); - ops = NULL; - switch (icino->ici_st.st_mode & S_IFMT) { - case S_IFDIR: - ops = &_sysio_incore_dir_ops; - break; - case S_IFREG: - ops = &_sysio_incore_file_ops; - break; - default: - break; - } - if (!ops) - abort(); - ino = - _sysio_i_new(ino->i_fs, - &icino->ici_fileid, - &icino->ici_st - 1, - ops, - icino); -#endif - if (!ino) - return -ENOMEM; - -#ifdef notdef -out: -#endif - *inop = ino; - return 0; -} - -static int -_sysio_incore_inop_getattr(struct pnode *pno, - struct inode *ino, - struct intnl_stat *stbuf) -{ - struct incore_inode *icino; - - if (!ino) - ino = pno->p_base->pb_ino; - icino = I2IC(ino); - *stbuf = icino->ici_st; - return 0; -} - -static int -_sysio_incore_inop_setattr(struct pnode *pno, - struct inode *ino, - unsigned mask, - struct intnl_stat *stbuf) -{ - struct incore_inode *icino; - int err; - - if (!ino) - ino = pno->p_base->pb_ino; - if (!ino) - return -EBADF; - icino = I2IC(ino); - - err = 0; - if (mask & SETATTR_LEN) { - err = incore_trunc(icino, stbuf->st_size, 1); - if (err) - goto out; - mask &= ~SETATTR_LEN; - } - if (mask & SETATTR_MODE) { - icino->ici_st.st_mode = - (icino->ici_st.st_mode & S_IFMT) | (stbuf->st_mode & 07777); - } - if (mask & SETATTR_MTIME) - icino->ici_st.st_mtime = stbuf->st_mtime; - if (mask & SETATTR_ATIME) - icino->ici_st.st_atime = stbuf->st_atime; - if (mask & SETATTR_UID) - icino->ici_st.st_uid = stbuf->st_uid; - if (mask & SETATTR_GID) - icino->ici_st.st_gid = stbuf->st_gid; - icino->ici_st.st_ctime = time(NULL); - - ino->i_stbuf = icino->ici_st; -out: - return err; -} - -static void * -incore_directory_position(struct intnl_dirent *de, - size_t reclen __IS_UNUSED, - void *p) -{ - - return (void *)de >= p ? de : NULL; -} - -struct copy_info { - void *data; - size_t nbytes; - unsigned count; -}; - -/* - * Eumeration callback. - * - * Note: - * Whiteout entries are never returned. - */ -static void * -incore_directory_enumerate(struct intnl_dirent *de, - size_t reclen, - struct copy_info *cinfo) { - -#ifdef DT_WHT - if (de->d_type == DT_WHT) { - /* - * Keep going but skip the copy. - */ - return NULL; - } -#endif - cinfo->count++; - if (reclen > cinfo->nbytes) - return de; - (void *)memcpy(cinfo->data, de, reclen); - cinfo->data = (char *)cinfo->data + reclen; - cinfo->nbytes -= reclen; - return NULL; -} - -static ssize_t -_sysio_incore_dirop_filldirentries(struct inode *ino, - _SYSIO_OFF_T *posp, - char *buf, - size_t nbytes) -{ - struct incore_inode *icino = I2IC(ino); - off_t off; - struct intnl_dirent *de; - struct copy_info copy_info; - - if (*posp >= icino->ici_st.st_size) - return 0; - - de = - incore_directory_probe(icino->ici_data, - icino->ici_st.st_size, - *posp, - (probe_ty )incore_directory_position, - NULL, - (char *)icino->ici_data + *posp); - if (!de) { - /* - * Past EOF. - */ - return 0; - } - - copy_info.data = buf; - copy_info.nbytes = nbytes; - copy_info.count = 0; - off = (char *)de - (char *)icino->ici_data; - de = - incore_directory_probe(de, - icino->ici_st.st_size - off, - off, - (probe_ty )incore_directory_enumerate, - NULL, - ©_info); - icino->ici_st.st_atime = time(NULL); - if (nbytes == copy_info.nbytes && copy_info.count) - return -EINVAL; - nbytes -= copy_info.nbytes; -#if 0 - if (!nbytes) - return -EOVERFLOW; -#endif - *posp += nbytes; - return (ssize_t )nbytes; -} - -static struct intnl_dirent * -incore_directory_best_fit(void *data, size_t len, struct lookup_data *ld) -{ - - if (!ld->hole.len || len < ld->hole.len) { - ld->hole.p = data; - ld->hole.len = len; - } - - return NULL; -} - -static int -incore_directory_insert(struct incore_inode *parent, - struct qstr *name, - ino_t inum, - unsigned char type) -{ - size_t reclen; - struct lookup_data lookup_data; - struct intnl_dirent *de; - size_t xt; - size_t n; - size_t r; - - reclen = INCORE_D_RECLEN(name->len); - INCORE_LD_INIT(&lookup_data, reclen, name); - de = - incore_directory_probe(parent->ici_data, - parent->ici_st.st_size, - 0, - (probe_ty )incore_directory_match, - (probe_ty )incore_directory_best_fit, - &lookup_data); - if (de) - return -EEXIST; - de = lookup_data.de; - xt = (char *)lookup_data.de - (char *)parent->ici_data; - n = -#ifdef _DIRENT_HAVE_D_OFF - de->d_off; -#else - xt + de->d_reclen; -#endif - r = -#ifdef _DIRENT_HAVE_D_OFF - de->d_reclen; -#else - INCORE_D_RECLEN(de->d_namlen); -#endif - if (!parent->ici_st.st_size || - xt + r + reclen > (size_t )parent->ici_st.st_size) { - int err; - - err = incore_trunc(parent, xt + r + reclen, 1); - if (err) - return err; - de = (struct intnl_dirent *)((char *)parent->ici_data + xt); - n = parent->ici_st.st_size; - } - -#ifdef _DIRENT_HAVE_D_OFF - de->d_off = xt + r; /* trim */ -#else - de->d_reclen = r; -#endif - de = (struct intnl_dirent *)((char *)de + r); /* reposition */ - xt += r; - -#ifndef _DIRENT_HAVE_D_OFF - /* - * Will we split this hole or use all of it? - */ - if (lookup_data.hole.len - reclen && - lookup_data.hole.len - reclen <= INCORE_D_RECLEN(1)) - reclen = lookup_data.hole.len; -#endif - - /* - * Insert new. - */ - de->d_ino = inum; -#ifdef _DIRENT_HAVE_D_OFF - de->d_off = n; -#endif - de->d_reclen = reclen; - de->d_type = type; - (void )memcpy(de->d_name, name->name, name->len); -#ifdef _DIRENT_HAVE_D_NAMLEN - de->d_namlen = name->len; -#endif - -#ifndef _DIRENT_HAVE_D_OFF - xt += reclen; - if (n - xt) { - /* - * White-out remaining part of the hole. - */ - (void *)de += reclen; - de->d_ino = 0; - de->d_reclen = n - xt; - de->d_type = DT_WHT; - de->d_namlen = 0; - } -#endif - - /* - * Update attributes to reflect the new entry. - */ - parent->ici_st.st_nlink++; - assert(parent->ici_st.st_nlink); - parent->ici_st.st_atime = parent->ici_st.st_mtime = time(NULL); - - return 0; -} - -static int -_sysio_incore_dirop_mkdir(struct pnode *pno, mode_t mode) -{ - struct intnl_stat stat; - struct incore_inode *icino, *parent; - ino_t inum; - int err; - struct intnl_dirent *de = NULL; - struct inode *ino; - - ino = pno->p_parent->p_base->pb_ino; - parent = I2IC(ino); - - if (!S_ISDIR(parent->ici_st.st_mode)) - return -ENOTDIR; - - (void )memset(&stat, 0, sizeof(stat)); - stat.st_dev = pno->p_parent->p_base->pb_ino->i_fs->fs_dev; - inum = incore_inum_alloc(); -#ifdef HAVE__ST_INO - stat.__st_ino = inum; -#endif - stat.st_mode = S_IFDIR | (mode & 07777); - stat.st_nlink = 2; - stat.st_uid = getuid(); - stat.st_gid = getgid(); - stat.st_size = 0; - stat.st_blksize = 4096; - stat.st_blocks = 0; - stat.st_ctime = stat.st_mtime = stat.st_atime = 0; - stat.st_ino = inum; - icino = incore_directory_new(FS2ICFS(ino->i_fs), parent, &stat); - if (!icino) - return -ENOSPC; - - /* - * Tell the system about the new inode. - * - * Persistent across remounts because we ask for immunity. - */ - ino = - _sysio_i_new(pno->p_parent->p_base->pb_ino->i_fs, - &icino->ici_fileid, - &stat, - 1, - &_sysio_incore_dir_ops, - icino); - if (!ino) { - incore_i_destroy(icino); - return -ENOMEM; - } - - /* - * Insert into parent. - */ - err = - incore_directory_insert(parent, - &pno->p_base->pb_name, - stat.st_ino, - INCORE_D_TYPEOF(S_IFDIR)); - - if (err) { - de->d_ino = 0; /* bad parent */ - I_RELE(ino); - _sysio_i_gone(ino); - return err; - } - - pno->p_base->pb_ino = ino; - return 0; -} - -static int -incore_unlink_entry(struct incore_inode *icino, - struct qstr *name) -{ - struct lookup_data lookup_data; - struct intnl_dirent *de; - size_t reclen; -#ifdef _DIRENT_HAVE_D_OFF - size_t off; -#endif - - if (!S_ISDIR(icino->ici_st.st_mode)) - return -ENOTDIR; - - INCORE_LD_INIT(&lookup_data, 0, name); - de = - incore_directory_probe(icino->ici_data, - icino->ici_st.st_size, - 0, - (probe_ty )incore_directory_match, - NULL, - &lookup_data); - if (!de) - return -ENOENT; - assert((size_t )((char *)de - (char *)icino->ici_data) >= - INCORE_D_TEMPLATE_LEN); -#ifndef _DIRENT_HAVE_D_OFF - reclen = de->d_reclen; -#else - off = de->d_off; - reclen = off - ((char *)de - (char *)icino->ici_data); -#endif - (void )memset(de, 0, reclen); -#ifndef _DIRENT_HAVE_D_OFF - de->d_type = (__uint8_t )DTTOIF(DT_WHT); - de->d_reclen = reclen; -#else - lookup_data.de->d_off = off; -#endif - - /* - * Adjust link count. - */ - assert(icino->ici_st.st_nlink > 2); - icino->ici_st.st_nlink--; - - return 0; -} - -static int -_sysio_incore_dirop_rmdir(struct pnode *pno) -{ - struct inode *ino = pno->p_base->pb_ino; - struct incore_inode *icino = I2IC(ino); - int err; - - if (!pno->p_base->pb_name.len || - (pno->p_base->pb_name.name[0] == '.' && - (pno->p_base->pb_name.len == 1 || - (pno->p_base->pb_name.len == 2 && - pno->p_base->pb_name.name[1] == '.')))) - return -EINVAL; - - if (!S_ISDIR(icino->ici_st.st_mode)) - return -ENOTDIR; - - if (icino->ici_st.st_nlink > 2) - return -ENOTEMPTY; - - pno->p_base->pb_ino = NULL; - err = - incore_unlink_entry(I2IC(pno->p_parent->p_base->pb_ino), - &pno->p_base->pb_name); - return err; -} - -static int -incore_create(struct pnode *pno, struct intnl_stat *stat) -{ - struct inode *dino, *ino; - struct incore_inode *icino; - int err; - - dino = pno->p_parent->p_base->pb_ino; - assert(dino); - - icino = incore_i_alloc(FS2ICFS(dino->i_fs), stat); - if (!icino) - return -ENOSPC; - - /* - * Tell the system about the new inode. - */ - ino = - _sysio_i_new(dino->i_fs, - &icino->ici_fileid, - stat, - 1, - S_ISREG(stat->st_mode) - ? &_sysio_incore_file_ops - : &_sysio_incore_dev_ops, - icino); - if (!ino) { - incore_i_destroy(icino); - return -ENOMEM; - } - - /* - * Insert into parent. - */ - err = - incore_directory_insert(I2IC(dino), - &pno->p_base->pb_name, - stat->st_ino, - INCORE_D_TYPEOF(icino->ici_st.st_mode)); - if (err) { - I_RELE(ino); - _sysio_i_gone(ino); - return err; - } - - pno->p_base->pb_ino = ino; - return 0; -} - -static int -_sysio_incore_inop_open(struct pnode *pno, int flags __IS_UNUSED, mode_t mode) -{ - struct intnl_stat stat; - ino_t inum; - - /* - * File exists. Nothing to do. - */ - if (pno->p_base->pb_ino) - return 0; - - /* - * Must create a new, regular, file. - */ - (void )memset(&stat, 0, sizeof(stat)); - stat.st_dev = pno->p_parent->p_base->pb_ino->i_fs->fs_dev; - inum = incore_inum_alloc(); -#ifdef HAVE__ST_INO - stat.__st_ino = inum; -#endif - stat.st_mode = S_IFREG | (mode & 07777); - stat.st_nlink = 1; - stat.st_uid = getuid(); - stat.st_gid = getgid(); - stat.st_rdev = 0; - stat.st_size = 0; - stat.st_blksize = 4096; - stat.st_blocks = 0; - stat.st_ctime = stat.st_mtime = stat.st_atime = 0; - stat.st_ino = inum; - - return incore_create(pno, &stat); -} - -static int -_sysio_incore_inop_close(struct inode *ino __IS_UNUSED) -{ - - return 0; -} - -static int -_sysio_incore_dirop_link(struct pnode *old, struct pnode *new) -{ - struct incore_inode *icino = I2IC(old->p_base->pb_ino); - int err; - - assert(!new->p_base->pb_ino); - assert(!S_ISDIR(old->p_base->pb_ino->i_stbuf.st_mode)); - - /* - * Can bump the link count? - */ - if (!(icino->ici_st.st_nlink + 1)) - return -EMLINK; - /* - * Insert into parent. - */ - err = - incore_directory_insert(I2IC(new->p_parent->p_base->pb_ino), - &new->p_base->pb_name, - icino->ici_st.st_ino, - INCORE_D_TYPEOF(icino->ici_st.st_mode)); - if (err) - return err; - /* - * Bump the link count. - */ - icino->ici_st.st_nlink++; - - return 0; -} - -static int -_sysio_incore_dirop_rename(struct pnode *old, struct pnode *new) -{ - int err; - struct incore_inode *icino = I2IC(old->p_base->pb_ino); - - if (new->p_base->pb_ino) { - /* - * Have to kill off the target first. - */ - if (S_ISDIR(I2IC(new->p_base->pb_ino)->ici_st.st_mode) && - I2IC(new->p_base->pb_ino)->ici_st.st_nlink > 2) - return -ENOTEMPTY; - err = - incore_unlink_entry(I2IC(new->p_parent->p_base->pb_ino), - &new->p_base->pb_name); - if (err) - return err; - } - - /* - * Insert into new parent. - */ - err = - incore_directory_insert(I2IC(new->p_parent->p_base->pb_ino), - &new->p_base->pb_name, - icino->ici_st.st_ino, - INCORE_D_TYPEOF(icino->ici_st.st_mode)); - if (err) - abort(); - /* - * Remove from the old parent. - */ - err = - incore_unlink_entry(I2IC(old->p_parent->p_base->pb_ino), - &old->p_base->pb_name); - if (err) - abort(); - - if (S_ISDIR(icino->ici_st.st_mode)) { - struct intnl_dirent *de; - - /* - * We moved a directory. The entry for `..' must be corrected. - */ - de = icino->ici_data; - de++; - assert(strcmp(de->d_name, "..") == 0); - de->d_ino = I2IC(new->p_parent->p_base->pb_ino)->ici_st.st_ino; - } - return 0; -} - -static int -_sysio_incore_dirop_unlink(struct pnode *pno) -{ - struct inode *ino = pno->p_base->pb_ino; - struct incore_inode *icino = I2IC(ino); - int err; - - if (S_ISDIR(icino->ici_st.st_mode)) - return -EISDIR; - - err = - incore_unlink_entry(I2IC(pno->p_parent->p_base->pb_ino), - &pno->p_base->pb_name); - return err; -} - -static int -doio(ssize_t (*f)(void *, size_t, _SYSIO_OFF_T, struct incore_inode *), - struct inode *ino, - struct ioctx *ioctx) -{ - - ioctx->ioctx_cc = - _sysio_doio(ioctx->ioctx_xtv, ioctx->ioctx_xtvlen, - ioctx->ioctx_iov, ioctx->ioctx_iovlen, - (ssize_t (*)(void *, size_t, _SYSIO_OFF_T, void *))f, - I2IC(ino)); - if (ioctx->ioctx_cc < 0) { - ioctx->ioctx_errno = -ioctx->ioctx_cc; - ioctx->ioctx_cc = -1; - } - ioctx->ioctx_done = 1; - - return 0; -} - -static ssize_t -incore_read(void *buf, size_t nbytes, - _SYSIO_OFF_T off, - struct incore_inode *icino) -{ - size_t n; - - if (off < 0) - return -EINVAL; - if (!nbytes || off > icino->ici_st.st_size) - return 0; - n = icino->ici_st.st_size - (size_t )off; - if (n > nbytes) - n = nbytes; - (void )memcpy(buf, (char *)icino->ici_data + off, (size_t )n); - - return (ssize_t )n; -} - -static int -_sysio_incore_filop_read(struct inode *ino, struct ioctx *ioctx) -{ - - - return doio(incore_read, ino, ioctx); -} - -static ssize_t -incore_write(const void *buf, size_t nbytes, - _SYSIO_OFF_T off, - struct incore_inode *icino) -{ - _SYSIO_OFF_T pos; - - if (off < 0) - return -EINVAL; - if (!nbytes || off > icino->ici_st.st_size) - return 0; - pos = off + nbytes; - if (off && pos <= off) { - /* - * It's all or nothing. We won't write just part of - * the buffer. - */ - return -EFBIG; - } - if (pos > icino->ici_st.st_size) { - int err; - - err = incore_trunc(icino, (size_t )pos, 0); - if (err) - return err; - } - (void )memcpy((char *)icino->ici_data + off, buf, nbytes); - - return (ssize_t )nbytes; -} - -static int -_sysio_incore_filop_write(struct inode *ino, struct ioctx *ioctx) -{ - - return doio((ssize_t (*)(void *, size_t, - _SYSIO_OFF_T, - struct incore_inode *))incore_write, - ino, - ioctx); -} - -static _SYSIO_OFF_T -_sysio_incore_filop_pos(struct inode *ino __IS_UNUSED, _SYSIO_OFF_T off) -{ - - return off; -} - -static int -_sysio_incore_filop_iodone(struct ioctx *iocp __IS_UNUSED) -{ - - /* - * It's always done in this driver. It completed when posted. - */ - return 1; -} - -static int -_sysio_incore_filop_fcntl(struct inode *ino __IS_UNUSED, - int cmd __IS_UNUSED, - va_list ap __IS_UNUSED, - int *rtn) -{ - - /* - * No fcntl's supported. - */ - *rtn = -1; - return -ENOTTY; -} - -static int -_sysio_incore_inop_sync(struct inode *ino __IS_UNUSED) -{ - - /* - * With what? - */ - return 0; -} - -static int -_sysio_incore_filop_ioctl(struct inode *ino __IS_UNUSED, - unsigned long int request __IS_UNUSED, - va_list ap __IS_UNUSED) -{ - - /* - * No ioctl's supported. - */ - return -ENOTTY; -} - -static int -_sysio_incore_dirop_mknod(struct pnode *pno, mode_t mode, dev_t dev) -{ - mode_t m; - struct intnl_stat stat; - ino_t inum; - - assert(!pno->p_base->pb_ino); - - m = mode & S_IFMT; - if (S_ISCHR(m)) - m &= ~S_IFCHR; - else if (S_ISFIFO(m)) - m &= ~S_IFIFO; - else if (S_ISBLK(m)) - m &= ~S_IFCHR; - else - return -EINVAL; - if (m) - return -EINVAL; - - /* - * Initialize attributes. - */ - (void )memset(&stat, 0, sizeof(stat)); - stat.st_dev = pno->p_parent->p_base->pb_ino->i_fs->fs_dev; - inum = incore_inum_alloc(); -#ifdef HAVE__ST_INO - stat.__st_ino = inum; -#endif - stat.st_mode = mode; - stat.st_nlink = 1; - stat.st_uid = getuid(); - stat.st_gid = getgid(); - stat.st_rdev = dev; - stat.st_size = 0; - stat.st_blksize = 4096; - stat.st_blocks = 0; - stat.st_ctime = stat.st_mtime = stat.st_atime = 0; - stat.st_ino = inum; - - return incore_create(pno, &stat); -} - -#ifdef _HAVE_STATVFS -static int -_sysio_incore_inop_statvfs(struct pnode *pno, - struct inode *ino, - struct intnl_statvfs *buf) -{ - struct filesys *fs; - - if (!ino) - ino = pno->p_base->pb_ino; - assert(ino); - - fs = pno->p_base->pb_ino->i_fs; - - (void )memset(buf, 0, sizeof(struct intnl_statvfs)); - - /* - * Mostly, we lie. - */ - buf->f_bsize = fs->fs_bsize; - buf->f_frsize = buf->f_bsize; - buf->f_blocks = ~0; - buf->f_blocks /= buf->f_bsize; - buf->f_bfree = buf->f_blocks - 1; - buf->f_bavail = buf->f_bfree; - buf->f_files = buf->f_blocks; - buf->f_ffree = buf->f_files - 1; - buf->f_favail = buf->f_ffree; - buf->f_fsid = fs->fs_id; - buf->f_flag = 0; - buf->f_namemax = ULONG_MAX; - - return 0; -} -#endif - -void -_sysio_incore_inop_gone(struct inode *ino) -{ - struct incore_inode *icino = I2IC(ino); - - incore_i_destroy(icino); -} diff --git a/libsysio/drivers/incore/fs_incore.h b/libsysio/drivers/incore/fs_incore.h deleted file mode 100644 index 84fa631..0000000 --- a/libsysio/drivers/incore/fs_incore.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -/* - * Native file system driver support. - */ - -extern int _sysio_incore_init(void); diff --git a/libsysio/drivers/incore/module.mk b/libsysio/drivers/incore/module.mk deleted file mode 100644 index 140d69b..0000000 --- a/libsysio/drivers/incore/module.mk +++ /dev/null @@ -1,2 +0,0 @@ -INCORE_SRCS = drivers/incore/fs_incore.c -INCORE_EXTRA = drivers/incore/fs_incore.h drivers/incore/module.mk diff --git a/libsysio/drivers/native/.gitignore b/libsysio/drivers/native/.gitignore deleted file mode 100644 index c83c013..0000000 --- a/libsysio/drivers/native/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/.dirstamp diff --git a/libsysio/drivers/native/fs_native.c b/libsysio/drivers/native/fs_native.c deleted file mode 100644 index 7980f68..0000000 --- a/libsysio/drivers/native/fs_native.c +++ /dev/null @@ -1,1813 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2004 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#ifdef __linux__ -#define _BSD_SOURCE -#endif - -#include /* for NULL */ -#include -#ifdef __linux__ -#include -#endif -#include -#if !(defined(REDSTORM) || defined(MAX_IOVEC)) -#include -#endif -#include -#include -#include -#include -#include -#include -#include -#if 0 -#include -#endif -#ifdef _HAVE_STATVFS -#include -#include -#endif -#include -#include -#include - -#include "sysio.h" -#include "xtio.h" -#include "native.h" -#include "fs.h" -#include "mount.h" -#include "inode.h" - -#include "fs_native.h" - -#ifdef REDSTORM -#include -#endif - -#if defined(SYSIO_SYS_getdirentries) -#define DIR_CVT_64 0 -#elif defined(SYSIO_SYS_getdents64) -#define DIR_CVT_64 0 -#elif defined(SYSIO_SYS_getdents) -#if defined(_LARGEFILE64_SOURCE) -#define DIR_CVT_64 1 -/* - * Kernel version of directory entry. - */ -struct linux_dirent { - unsigned long ld_ino; - unsigned long ld_off; - unsigned short ld_reclen; - char ld_name[1]; -}; -#include -#else /* !defined(_LARGEFILE64_SOURCE) */ -#define DIR_CVT_64 0 -#endif /* defined(_LARGEFILE64_SOURCE) */ -#else /* catch-none */ -#error No usable directory fill entries interface available -#endif - -/* - * Native file system information we keep per FS. - */ -struct native_filesystem { - time_t nfs_atimo; /* attr timeout (sec) */ -}; - -/* - * Given fs, return driver private part. - */ -#define FS2NFS(fs) \ - ((struct native_filesystem *)(fs)->fs_private) - -/* - * Native file identifiers format. - */ -struct native_inode_identifier { - dev_t dev; /* device number */ - ino_t ino; /* i-number */ -#ifdef HAVE_GENERATION - unsigned int gen; /* generation number */ -#endif -}; - -/* - * Driver-private i-node information we keep about local host file - * system objects. - */ -struct native_inode { - unsigned - ni_seekok : 1, /* can seek? */ - ni_attrvalid : 1, /* cached attrs ok? */ - ni_resetfpos : 1; /* reset fpos? */ - struct native_inode_identifier ni_ident; /* unique identifier */ - struct file_identifier ni_fileid; /* ditto */ - int ni_fd; /* host fildes */ - int ni_oflags; /* flags, from open */ - unsigned ni_nopens; /* soft ref count */ - _SYSIO_OFF_T ni_fpos; /* current pos */ - time_t ni_attrtim; /* attrs expire time */ -}; - -/* - * Cached attributes usable? - */ -#define NATIVE_ATTRS_VALID(nino, t) \ - ((nino)->ni_attrtim && (t) < (nino)->ni_attrtim) - -/* - * Native IO path arguments. - */ -struct native_io { - char nio_op; /* 'r' or 'w' */ - struct native_inode *nio_nino; /* native ino */ -}; - -static int native_inop_lookup(struct pnode *pno, - struct inode **inop, - struct intent *intnt, - const char *path); -static int native_inop_getattr(struct pnode *pno, - struct inode *ino, - struct intnl_stat *stbuf); -static int native_inop_setattr(struct pnode *pno, - struct inode *ino, - unsigned mask, - struct intnl_stat *stbuf); -static ssize_t native_filldirentries(struct inode *ino, - _SYSIO_OFF_T *posp, - char *buf, - size_t nbytes); -static int native_inop_mkdir(struct pnode *pno, mode_t mode); -static int native_inop_rmdir(struct pnode *pno); -static int native_inop_symlink(struct pnode *pno, const char *data); -static int native_inop_readlink(struct pnode *pno, char *buf, size_t bufsiz); -static int native_inop_open(struct pnode *pno, int flags, mode_t mode); -static int native_inop_close(struct inode *ino); -static int native_inop_link(struct pnode *old, struct pnode *new); -static int native_inop_unlink(struct pnode *pno); -static int native_inop_rename(struct pnode *old, struct pnode *new); -static int native_inop_read(struct inode *ino, struct ioctx *ioctx); -static int native_inop_write(struct inode *ino, struct ioctx *ioctx); -static _SYSIO_OFF_T native_inop_pos(struct inode *ino, _SYSIO_OFF_T off); -static int native_inop_iodone(struct ioctx *ioctx); -static int native_inop_fcntl(struct inode *ino, int cmd, va_list ap, int *rtn); -static int native_inop_sync(struct inode *ino); -static int native_inop_datasync(struct inode *ino); -static int native_inop_ioctl(struct inode *ino, - unsigned long int request, - va_list ap); -static int native_inop_mknod(struct pnode *pno, mode_t mode, dev_t dev); -#ifdef _HAVE_STATVFS -static int native_inop_statvfs(struct pnode *pno, - struct inode *ino, - struct intnl_statvfs *buf); -#endif -static void native_inop_gone(struct inode *ino); - -static struct inode_ops native_i_ops = { - native_inop_lookup, - native_inop_getattr, - native_inop_setattr, - native_filldirentries, - native_inop_mkdir, - native_inop_rmdir, - native_inop_symlink, - native_inop_readlink, - native_inop_open, - native_inop_close, - native_inop_link, - native_inop_unlink, - native_inop_rename, - native_inop_read, - native_inop_write, - native_inop_pos, - native_inop_iodone, - native_inop_fcntl, - native_inop_sync, - native_inop_datasync, - native_inop_ioctl, - native_inop_mknod, -#ifdef _HAVE_STATVFS - native_inop_statvfs, -#endif - native_inop_gone -}; - -static int native_fsswop_mount(const char *source, - unsigned flags, - const void *data, - struct pnode *tocover, - struct mount **mntp); - -static struct fssw_ops native_fssw_ops = { - native_fsswop_mount -}; - -static void native_fsop_gone(struct filesys *fs); - -static struct filesys_ops native_inodesys_ops = { - native_fsop_gone, -}; - -/* - * This example driver plays a strange game. It maintains a private, - * internal mount -- It's own separate, rooted, name space. The local - * file system's entire name space is available via this tree. - * - * This simplifies the implementation. At mount time, we need to generate - * a path-node to be used as a root. This allows us to look up the needed - * node in the host name space and leverage a whole lot of support from - * the system. - */ -static struct mount *native_internal_mount = NULL; - -/* - * Given i-node, return driver private part. - */ -#define I2NI(ino) ((struct native_inode *)((ino)->i_private)) - -/* - * stat -- by path. - */ -static int -native_stat(const char *path, - struct inode *ino, - time_t t, - struct intnl_stat *buf) -{ - struct native_inode *nino; - int err; - struct _sysio_native_stat stbuf; - - nino = ino ? I2NI(ino) : NULL; - - if (path) - err = syscall(SYSIO_SYS_stat, path, &stbuf); - else if (nino && nino->ni_fd >= 0) - err = syscall(SYSIO_SYS_fstat, nino->ni_fd, &stbuf); - else - abort(); - if (err) { - if (nino) - nino->ni_attrtim = 0; - return -errno; - } - if (nino) { - nino->ni_attrtim = t; - SYSIO_COPY_STAT(&stbuf, &ino->i_stbuf); - if (buf) - *buf = ino->i_stbuf; - return 0; - } - if (!buf) - return 0; - SYSIO_COPY_STAT(&stbuf, buf); - return 0; -} - -/* - * Introduce an i-node to the system. - */ -static struct inode * -native_i_new(struct filesys *fs, time_t expiration, struct intnl_stat *buf) -{ - struct native_inode *nino; - struct inode *ino; - - nino = malloc(sizeof(struct native_inode)); - if (!nino) - return NULL; - bzero(&nino->ni_ident, sizeof(nino->ni_ident)); - nino->ni_seekok = 0; - nino->ni_attrvalid = 0; - nino->ni_resetfpos = 0; - nino->ni_ident.dev = buf->st_dev; - nino->ni_ident.ino = buf->st_ino; -#ifdef HAVE_GENERATION - nino->ni_ident.gen = buf->st_gen; -#endif - nino->ni_fileid.fid_data = &nino->ni_ident; - nino->ni_fileid.fid_len = sizeof(nino->ni_ident); - nino->ni_fd = -1; - nino->ni_oflags = 0; - nino->ni_nopens = 0; - nino->ni_fpos = 0; - nino->ni_attrtim = expiration; - ino = - _sysio_i_new(fs, - &nino->ni_fileid, - buf, - 0, - &native_i_ops, - nino); - if (!ino) - free(nino); - return ino; -} - -/* - * Initialize this driver. - */ -int -_sysio_native_init() -{ - - /* - * Capture current process umask and reset our process umask to - * zero. All permission bits to open/creat/setattr are absolute -- - * They've already had a umask applied, when appropriate. - */ -#ifndef REDSTORM - _sysio_umask = syscall(SYSIO_SYS_umask, 0); - /* - * For Red Storm, this functionality is handled in cstart. - * The mask to be "captured" has been sent already. - * This eliminates a system call from every node! - */ -#endif /* REDSTORM */ - - return _sysio_fssw_register("native", &native_fssw_ops); -} - -/* - * Create private, internal, view of the hosts name space. - */ -static int -create_internal_namespace(const void *data) -{ - char *opts; - ssize_t len; - char *cp; - struct native_filesystem *nfs; - int err; - struct mount *mnt; - struct inode *rootino; - struct pnode_base *rootpb; - static struct qstr noname = { NULL, 0, 0 }; - struct filesys *fs; - time_t t; - struct intnl_stat stbuf; - unsigned long ul; - static struct option_value_info v[] = { - { "atimo", "30" }, - { NULL, NULL } - }; - - if (native_internal_mount) { - /* - * Reentered! - */ - abort(); - } - - /* - * Get mount options. - */ - opts = NULL; - if (data && (len = strlen((char *)data))) { - opts = malloc(len + 1); - if (!opts) - return -ENOMEM; - (void )strcpy(opts, data); - if (_sysio_get_args(opts, v) - opts != (ssize_t )len) - return -EINVAL; - } - ul = strtoul(v[0].ovi_value, &cp, 0); - if (*cp != '\0' || ul >= UINT_MAX) - return -EINVAL; - if (opts) { - free(opts); - opts = NULL; - } - - /* - * We maintain an artificial, internal, name space in order to - * have access to fully qualified path names in the various routines. - * Initialize that name space now. - */ - fs = NULL; - mnt = NULL; - rootino = NULL; - rootpb = NULL; - /* - * This really should be per-mount. Hmm, but that's best done - * as proper sub-mounts in the core and not this driver. We reconcile - * now, here, by putting the mount options on the file system. That - * means they are global and only can be passed at the initial mount. - * - * Maybe do it right some day? - */ - nfs = malloc(sizeof(struct native_filesystem)); - if (!nfs) { - err = -ENOMEM; - goto error; - } - nfs->nfs_atimo = ul; - if ((unsigned long)nfs->nfs_atimo != ul) { - err = -EINVAL; - goto error; - } - fs = _sysio_fs_new(&native_inodesys_ops, 0, nfs); - if (!fs) { - err = -ENOMEM; - goto error; - } - - /* - * Get root i-node. - */ - t = _SYSIO_LOCAL_TIME(); - err = native_stat("/", NULL, 0, &stbuf); - if (err) - goto error; - rootino = native_i_new(fs, t + FS2NFS(fs)->nfs_atimo, &stbuf); - if (!rootino) { - err = -ENOMEM; - goto error; - } - - /* - * Generate base path-node for root. - */ - rootpb = _sysio_pb_new(&noname, NULL, rootino); - if (!rootpb) { - err = -ENOMEM; - goto error; - } - - /* - * Mount it. This name space is disconnected from the - * rest of the system -- Only available within this driver. - */ - err = _sysio_do_mount(fs, rootpb, 0, NULL, &mnt); - if (err) - goto error; - - native_internal_mount = mnt; - return 0; -error: - if (mnt) { - if (_sysio_do_unmount(mnt) != 0) - abort(); - nfs = NULL; - fs = NULL; - rootpb = NULL; - rootino = NULL; - } - if (rootpb) - _sysio_pb_gone(rootpb); - if (fs) { - FS_RELE(fs); - nfs = NULL; - } - if (nfs) - free(nfs); - if (opts) - free(opts); - - return err; -} - -static int -native_fsswop_mount(const char *source, - unsigned flags, - const void *data, - struct pnode *tocover, - struct mount **mntp) -{ - int err; - struct nameidata nameidata; - struct mount *mnt; - - /* - * Caller must use fully qualified path names when specifying - * the source. - */ - if (*source != '/') - return -ENOENT; - - if (!native_internal_mount) { - err = create_internal_namespace(data); - if (err) - return err; - } else if (data && *(char *)data) - return -EINVAL; - - /* - * Lookup the source in the internally maintained name space. - */ - ND_INIT(&nameidata, 0, source, native_internal_mount->mnt_root, NULL); - err = _sysio_path_walk(native_internal_mount->mnt_root, &nameidata); - if (err) - return err; - - /* - * Have path-node specified by the given source argument. Let the - * system finish the job, now. - */ - err = - _sysio_do_mount(native_internal_mount->mnt_fs, - nameidata.nd_pno->p_base, - flags, - tocover, - &mnt); - /* - * Release the internal name space pnode and clean up any - * aliases we might have generated. We really don't need to cache them - * as they are only used at mount time.. - */ - P_RELE(nameidata.nd_pno); - (void )_sysio_p_prune(native_internal_mount->mnt_root); - - if (!err) { - FS_REF(native_internal_mount->mnt_fs); - *mntp = mnt; - } - return err; -} - -static int -native_i_invalid(struct inode *inop, struct intnl_stat *stat) -{ - struct native_inode *nino; - - /* - * Validate passed in inode against stat struct info - */ - nino = I2NI(inop); - - if (!nino->ni_attrtim || - (nino->ni_ident.dev != stat->st_dev || - nino->ni_ident.ino != stat->st_ino || -#ifdef HAVE_GENERATION - nino->ni_ident.gen != stat->st_gen || -#endif - ((inop)->i_stbuf.st_mode & S_IFMT) != (stat->st_mode & S_IFMT)) || - (((inop)->i_stbuf.st_rdev != stat->st_rdev) && - (S_ISCHR((inop)->i_stbuf.st_mode) || - S_ISBLK((inop)->i_stbuf.st_mode)))) { - nino->ni_attrtim = 0; /* invalidate attrs */ - return 1; - } - return 0; -} - -static struct inode * -native_iget(struct filesys *fs, time_t expire, struct intnl_stat *stbp) -{ - struct inode *ino; - struct native_inode_identifier ident; - struct file_identifier fileid; - - bzero(&ident, sizeof(ident)); - ident.dev = stbp->st_dev; - ident.ino = stbp->st_ino; -#ifdef HAVE_GENERATION - ident.gen = stbp->st_gen; -#endif - fileid.fid_data = &ident; - fileid.fid_len = sizeof(ident); - ino = _sysio_i_find(fs, &fileid); - if (ino) { - ino->i_stbuf = *stbp; - I2NI(ino)->ni_attrtim = expire; - return ino; - } - return native_i_new(fs, expire, stbp); -} - -/* - * Find, and validate, or create i-node by host-relative path. Returned i-node - * is referenced. - */ -static int -native_ibind(struct filesys *fs, - char *path, - time_t t, - struct inode **inop) -{ - struct intnl_stat ostbuf, stbuf; - int err; - struct inode *ino; - - if (*inop) - ostbuf = (*inop)->i_stbuf; - - err = native_stat(path, *inop, t, &stbuf); - if (err) - return err; - - /* - * Validate? - */ - if (*inop) { - if (!native_i_invalid(*inop, &ostbuf)) - return 0; - /* - * Invalidate. - */ - _sysio_i_undead(*inop); - *inop = NULL; - } - - if (!(ino = native_iget(fs, t + FS2NFS(fs)->nfs_atimo, &stbuf))) - return -ENOMEM; - - *inop = ino; - return 0; -} - -static int -native_inop_lookup(struct pnode *pno, - struct inode **inop, - struct intent *intnt __IS_UNUSED, - const char *path __IS_UNUSED) -{ - time_t t; - char *fqpath; - struct filesys *fs; - int err; - - *inop = pno->p_base->pb_ino; - - /* - * Try to use the cached attributes unless the intent - * indicates we are looking up the last component and - * caller wants attributes. In that case, force a refresh. - */ - t = _SYSIO_LOCAL_TIME(); - if (*inop && - (path || !intnt || (intnt->int_opmask & INT_GETATTR) == 0) && - NATIVE_ATTRS_VALID(I2NI(*inop), t)) - return 0; - - /* - * Don't have an inode yet. Because we translate everything back to - * a single name space for the host, we will assume the object the - * caller is looking for has no existing alias in our internal - * name space. We don't see the same file on different mounts in the - * underlying host FS as the same file. - * - * The file identifier *will* be unique. It's got to have a different - * dev. - */ - fqpath = _sysio_pb_path(pno->p_base, '/'); - if (!fqpath) - return -ENOMEM; - fs = pno->p_mount->mnt_fs; - err = native_ibind(fs, fqpath, t + FS2NFS(fs)->nfs_atimo, inop); - free(fqpath); - if (err) - *inop = NULL; - return err; -} - -static int -native_inop_getattr(struct pnode *pno, - struct inode *ino, - struct intnl_stat *stat) -{ - struct native_inode *nino; - int err; - - /* - * We just cannot use the cached attributes when getattr is - * called. Had the caller felt those were sufficient then - * they could have (would have?) simply used what was cached - * after revalidating. In this case, there's a good chance the - * caller is looking for the current time stamps and/or size. Something - * pretty volatile anyway. - */ - err = 0; /* compiler cookie */ - if (pno) { - char *path; - struct filesys *fs; - time_t t; - - path = _sysio_pb_path(pno->p_base, '/'); - if (!path) - return -ENOMEM; - fs = pno->p_mount->mnt_fs; - t = _SYSIO_LOCAL_TIME(); - err = native_stat(path, ino, t + FS2NFS(fs)->nfs_atimo, stat); - free(path); - } else if ((nino = I2NI(ino))->ni_fd >= 0) - /* - * Don't have access to the fs record anymore. Just - * refresh but keep the current timeout. - */ - err = native_stat(NULL, ino, nino->ni_attrtim, stat); - else { - /* - * Dev inodes don't open in this driver. We won't have - * a file descriptor with which to do the deed then. Satisfy - * the request from the cached copy of the attributes. - */ - (void )memcpy(stat, - &ino->i_stbuf, - sizeof(struct intnl_stat)); - err = 0; - } - - return err; -} - -#ifdef SYSIO_SYS_utime -static int -_ut(const char *path, time_t actime, time_t modtime) -{ - struct utimbuf ut; - - ut.actime = actime; - ut.modtime = modtime; - return syscall(SYSIO_SYS_utime, path, &ut); -} -#else -static int -_ut(const char *path, time_t actime, time_t modtime) -{ - struct timeval tv[2]; - - tv[0].tv_sec = actime; - tv[0].tv_usec = 0; - tv[1].tv_sec = modtime; - tv[1].tv_usec = 0; - return syscall(SYSIO_SYS_utimes, path, &tv); -} -#endif - -static int -native_inop_setattr(struct pnode *pno, - struct inode *ino, - unsigned mask, - struct intnl_stat *stat) -{ - char *path; - struct native_inode *nino; - int fd; - int err; - - path = NULL; - nino = ino ? I2NI(ino) : NULL; - fd = -1; - if (nino) - fd = nino->ni_fd; - if (fd < 0 || mask & (SETATTR_MTIME|SETATTR_ATIME)) { - if (!pno) - return -EEXIST; - path = _sysio_pb_path(pno->p_base, '/'); - if (!path) - return -ENOMEM; - } - - /* - * Get current status for undo. - */ - err = native_stat(path, ino, 0, NULL); - if (err) - goto out; - - if (mask & SETATTR_MODE) { - mode_t mode; - - /* - * Alter permissions attribute. - */ - mode = stat->st_mode & 07777; - err = - fd < 0 - ? syscall(SYSIO_SYS_chmod, path, mode) - : syscall(SYSIO_SYS_fchmod, fd, mode); - if (err) - err = -errno; - } - if (err) - mask &= ~SETATTR_MODE; - else if (mask & (SETATTR_MTIME|SETATTR_ATIME)) { - time_t actime, modtime; - - /* - * Alter access and/or modify time attributes. - */ - actime = ino->i_stbuf.st_atime; - modtime = ino->i_stbuf.st_mtime; - if (mask & SETATTR_ATIME) - actime = stat->st_atime; - if (mask & SETATTR_MTIME) - modtime = stat->st_mtime; - if (_ut(path, actime, modtime) != 0) - return -errno; - } - if (err) - mask &= ~(SETATTR_MTIME|SETATTR_ATIME); - else if (mask & (SETATTR_UID|SETATTR_GID)) { - - /* - * Alter owner and/or group identifiers. - */ - err = - fd < 0 - ? syscall(SYSIO_SYS_chown, - path, - mask & SETATTR_UID - ? stat->st_uid - : (uid_t )-1, - mask & SETATTR_GID - ? stat->st_gid - : (gid_t )-1) - : syscall(SYSIO_SYS_fchown, - fd, - mask & SETATTR_UID - ? stat->st_uid - : (uid_t )-1, - mask & SETATTR_GID - ? stat->st_gid - : (gid_t )-1); - if (err) - err = -errno; - } - if (err) - mask &= ~(SETATTR_UID|SETATTR_GID); - else if (mask & SETATTR_LEN) { - /* - * Do the truncate last. It can't be undone. - */ - err = fd < 0 - ? syscall(SYSIO_SYS_truncate, path, stat->st_size) - : syscall(SYSIO_SYS_ftruncate, fd, stat->st_size); - if (err) - err = -errno; - } - if (!err) - goto out; - /* - * Undo after error. Some or all of this might not work... We - * can but try. - */ - if (mask & (SETATTR_UID|SETATTR_GID)) { - (void )(fd < 0 - ? syscall(SYSIO_SYS_chown, - path, - mask & SETATTR_UID - ? ino->i_stbuf.st_uid - : (uid_t )-1, - mask & SETATTR_GID - ? ino->i_stbuf.st_gid - : (gid_t )-1) - : syscall(SYSIO_SYS_fchown, - fd, - mask & SETATTR_UID - ? ino->i_stbuf.st_uid - : (uid_t )-1, - mask & SETATTR_GID - ? ino->i_stbuf.st_gid - : (gid_t )-1)); - } - if (mask & (SETATTR_MTIME|SETATTR_ATIME)) - (void )_ut(path, ino->i_stbuf.st_atime, ino->i_stbuf.st_mtime); - if (mask & SETATTR_MODE) { - fd < 0 - ? syscall(SYSIO_SYS_chmod, path, ino->i_stbuf.st_mode & 07777) - : syscall(SYSIO_SYS_fchmod, ino->i_stbuf.st_mode & 07777); - } -out: - /* - * We must refresh the cached attributes. - */ - if (!err && native_stat(path, ino, _SYSIO_LOCAL_TIME(), NULL) != 0) - abort(); - if (path) - free(path); - return err; -} - -static int -native_pos(int fd, _SYSIO_OFF_T *offset, int whence) -{ - _SYSIO_OFF_T off; - - assert(fd >= 0); - assert(*offset >= 0); - - off = *offset; -#if defined(_LARGEFILE64_SOURCE) && defined(SYSIO_SYS__llseek) - { - int err; - err = - syscall(SYSIO_SYS__llseek, - (unsigned int)fd, - (unsigned int)(off >> 32), - (unsigned int)off, - &off, - whence); - if (err == -1) - return -errno; - } -#else - off = - syscall(SYSIO_SYS_lseek, - fd, - off, - whence); - if (off == -1) - return -errno; -#endif - *offset = off; - - return 0; -} - -static ssize_t -native_ifilldirentries(struct native_inode *nino, - _SYSIO_OFF_T *posp, - char *buf, - size_t nbytes) -{ - int err; - ssize_t cc; -#if defined(SYSIO_SYS_getdirentries) - _SYSIO_OFF_T waste=*posp; -#endif - - if (*posp < 0) - return -EINVAL; - - /* - * Stream-oriented access requires that we reposition prior to the - * fill call. - */ - assert(nino->ni_seekok); - if (*posp != nino->ni_fpos || nino->ni_resetfpos) { - nino->ni_fpos = *posp; - err = native_pos(nino->ni_fd, &nino->ni_fpos, SEEK_SET); - if (err) { - nino->ni_resetfpos = 1; - return err; - } - nino->ni_resetfpos = 0; - } - - cc = -#if defined(SYSIO_SYS_getdirentries) - syscall(SYSIO_SYS_getdirentries, - nino->ni_fd, - buf, - nbytes, - &waste); -#elif defined(SYSIO_SYS_getdents64) - syscall(SYSIO_SYS_getdents64, nino->ni_fd, buf, nbytes); -#elif defined(SYSIO_SYS_getdents) - syscall(SYSIO_SYS_getdents, nino->ni_fd, buf, nbytes); -#endif - - if (cc < 0) - return -errno; - /* - * Stream-oriented access requires that we discover where we are - * after the call. - */ - if ((err = native_pos(nino->ni_fd, &nino->ni_fpos, SEEK_CUR)) != 0) { - /* - * Leave the position at the old I suppose. - */ - nino->ni_resetfpos = 1; - return err; - } - *posp = nino->ni_fpos; - return cc; -} - -static ssize_t -native_filldirentries(struct inode *ino, - _SYSIO_OFF_T *posp, - char *buf, - size_t nbytes) -{ - struct native_inode *nino = I2NI(ino); -#if DIR_CVT_64 - char *bp; - size_t count; - struct linux_dirent *ldp; - struct dirent64 *d64p; - size_t namlen; - size_t reclen; -#else -#define bp buf -#define count nbytes -#endif - ssize_t cc; - - assert(nino->ni_fd >= 0); - -#if DIR_CVT_64 - count = nbytes; - while (!(bp = malloc(count))) { - count /= 2; - if (count < sizeof(struct dirent)) - return -ENOMEM; - } -#endif - cc = native_ifilldirentries(nino, posp, bp, count); - if (cc < 0) { -#if DIR_CVT_64 - free(bp); -#endif - return cc; - } -#if DIR_CVT_64 - ldp = (struct linux_dirent *)bp; - d64p = (struct dirent64 *)buf; - while (cc) { - namlen = strlen(ldp->ld_name); - reclen = sizeof(*d64p) - sizeof(d64p->d_name) + namlen; - if (nbytes <= reclen) - break; - d64p->d_ino = ldp->ld_ino; - d64p->d_off = nino->ni_fpos = ldp->ld_off; - d64p->d_reclen = - (((reclen + sizeof(long))) / sizeof(long)) * sizeof(long); - if (nbytes < d64p->d_reclen) - d64p->d_reclen = reclen + 1; - d64p->d_type = DT_UNKNOWN; /* you lose -- sorry. */ - (void )memcpy(d64p->d_name, ldp->ld_name, namlen); - /* - * Zero pad the rest. - */ - for (cp = d64p->d_name + namlen, n = d64p->d_reclen - reclen; - n; - n--) - *cp++ = 0; - cc -= ldp->ld_reclen; - ldp = (struct linux_dirent *)((char *)ldp + ldp->ld_reclen); - nbytes -= d64p->d_reclen; - d64p = (struct dirent64 *)((char *)d64p + d64p->d_reclen); - } - free(bp); - cc = - (d64p == (struct dirent64 *)buf && cc) - ? -EINVAL - : (char *)d64p - buf; -#else -#undef bp -#undef count -#endif - return cc; -} - -static int -native_inop_mkdir(struct pnode *pno, mode_t mode) -{ - char *path; - int err; - - path = _sysio_pb_path(pno->p_base, '/'); - if (!path) - return -ENOMEM; - - err = syscall(SYSIO_SYS_mkdir, path, mode); - if (err != 0) - err = -errno; - free(path); - return err; -} - -static int -native_inop_rmdir(struct pnode *pno) -{ - char *path; - int err; - - path = _sysio_pb_path(pno->p_base, '/'); - if (!path) - return -ENOMEM; - - err = syscall(SYSIO_SYS_rmdir, path); - if (err != 0) - err = -errno; - free(path); - return err; -} - -static int -native_inop_symlink(struct pnode *pno, const char *data) -{ - char *path; - int err; - - path = _sysio_pb_path(pno->p_base, '/'); - if (!path) - return -ENOMEM; - - err = syscall(SYSIO_SYS_symlink, data, path); - if (err != 0) - err = -errno; - free(path); - return err; -} - -static int -native_inop_readlink(struct pnode *pno, char *buf, size_t bufsiz) -{ - char *path; - int i; - - path = _sysio_pb_path(pno->p_base, '/'); - if (!path) - return -ENOMEM; - i = syscall(SYSIO_SYS_readlink, path, buf, bufsiz); - if (i < 0) - i = -errno; - free(path); - return i; -} - -static int -native_inop_open(struct pnode *pno, int flags, mode_t mode) -{ - struct native_inode *nino; - char *path; - int fd; - - path = _sysio_pb_path(pno->p_base, '/'); - if (!path) - return -ENOMEM; - - /* - * Whether the file is already open, or not, makes no difference. - * Want to always give the host OS a chance to authorize in case - * something has changed underneath us. - */ - if (flags & O_WRONLY) { - /* - * Promote write-only attempt to RW. - */ - flags &= ~O_WRONLY; - flags |= O_RDWR; - } -#ifdef O_LARGEFILE - flags |= O_LARGEFILE; -#endif - fd = syscall(SYSIO_SYS_open, path, flags, mode); - if (!pno->p_base->pb_ino && fd >= 0) { - struct filesys *fs; - int err; - - /* - * Success but we need to return an i-node. - */ - fs = pno->p_mount->mnt_fs; - err = - native_ibind(fs, - path, - _SYSIO_LOCAL_TIME() + FS2NFS(fs)->nfs_atimo, - &pno->p_base->pb_ino); - if (err) { - (void )syscall(SYSIO_SYS_close, fd); - if (err == -EEXIST) - abort(); - fd = err; - } - } - free(path); - if (fd < 0) - return -errno; - - /* - * Remember this new open. - */ - nino = I2NI(pno->p_base->pb_ino); - nino->ni_nopens++; - assert(nino->ni_nopens); - - if (nino->ni_fd >= 0) { - if ((nino->ni_oflags & O_RDWR) || - (flags & (O_RDONLY|O_WRONLY|O_RDWR)) == O_RDONLY) { - /* - * Keep existing. - */ - (void )syscall(SYSIO_SYS_close, fd); - return 0; - } - (void )syscall(SYSIO_SYS_close, nino->ni_fd); - } - /* - * Invariant; First open. Must init. - */ - nino->ni_resetfpos = 0; - nino->ni_fpos = 0; - nino->ni_fd = fd; - /* - * Need to know whether we can seek on this - * descriptor. - */ - nino->ni_seekok = - native_pos(nino->ni_fd, &nino->ni_fpos, SEEK_CUR) != 0 ? 0 : 1; - - return 0; -} - -static int -native_inop_close(struct inode *ino) -{ - struct native_inode *nino = I2NI(ino); - int err; - - if (nino->ni_fd < 0) - abort(); - - assert(nino->ni_nopens); - if (--nino->ni_nopens) { - /* - * Hmmm. We really don't need anything else. However, some - * filesystems try to implement a sync-on-close semantic. - * As this appears now, that is lost. Might want to change - * it somehow in the future? - */ - return 0; - } - - err = syscall(SYSIO_SYS_close, nino->ni_fd); - if (err) - return -errno; - - nino->ni_fd = -1; - nino->ni_resetfpos = 0; - nino->ni_fpos = 0; - return 0; -} - -static int -native_inop_link(struct pnode *old, struct pnode *new) -{ - int err; - char *opath, *npath; - - err = 0; - - opath = _sysio_pb_path(old->p_base, '/'); - npath = _sysio_pb_path(new->p_base, '/'); - if (!(opath && npath)) { - err = -ENOMEM; - goto out; - } - - err = syscall(SYSIO_SYS_link, opath, npath); - if (err != 0) - err = -errno; - -out: - if (opath) - free(opath); - if (npath) - free(npath); - return err; -} - -static int -native_inop_unlink(struct pnode *pno) -{ - char *path; - int err = 0; - - path = _sysio_pb_path(pno->p_base, '/'); - if (!path) - return -ENOMEM; - - /* - * For this driver, unlink is easy with open files. Since the - * file remains open to the system, too, the descriptors are still - * valid. - * - * Other drivers will have some difficulty here as the entry in the - * file system name space must be removed without sacrificing access - * to the file itself. In NFS this is done with a mechanism referred - * to as a `silly delete'. The file is moved to a temporary name - * (usually .NFSXXXXXX, where the X's are replaced by the PID and some - * unique characters) in order to simulate the proper semantic. - */ - if (syscall(SYSIO_SYS_unlink, path) != 0) - err = -errno; - free(path); - return err; -} - -static int -native_inop_rename(struct pnode *old, struct pnode *new) -{ - int err; - char *opath, *npath; - - opath = _sysio_pb_path(old->p_base, '/'); - npath = _sysio_pb_path(new->p_base, '/'); - if (!(opath && npath)) { - err = -ENOMEM; - goto out; - } - - err = syscall(SYSIO_SYS_rename, opath, npath); - if (err != 0) - err = -errno; - -out: - if (opath) - free(opath); - if (npath) - free(npath); - return err; -} - -static ssize_t -dopio(void *buf, size_t count, _SYSIO_OFF_T off, struct native_io *nio) -{ - ssize_t cc; - - if (!nio->nio_nino->ni_seekok) { - if (off != nio->nio_nino->ni_fpos) { - /* - * They're trying to reposition. Can't - * seek on this descriptor so we err out now. - */ - errno = ESPIPE; - return -1; - } - cc = - syscall(nio->nio_op == 'r' - ? SYSIO_SYS_read - : SYSIO_SYS_write, - nio->nio_nino->ni_fd, - buf, - count); - if (cc > 0) - nio->nio_nino->ni_fpos += cc; - } else - cc = - syscall((nio->nio_op == 'r' - ? SYSIO_SYS_pread - : SYSIO_SYS_pwrite), - nio->nio_nino->ni_fd, - buf, - count, - off); - - return cc; -} - -static ssize_t -doiov(const struct iovec *iov, - int count, - _SYSIO_OFF_T off, - ssize_t limit, - struct native_io *nio) -{ - ssize_t cc; - -#if !(defined(REDSTORM) || defined(MAX_IOVEC)) -#define MAX_IOVEC INT_MAX -#endif - - - if (count <= 0) - return -EINVAL; - - /* - * Avoid the reposition call if we're already at the right place. - * Allows us to access pipes and fifos. - */ - if (off != nio->nio_nino->ni_fpos) { - int err; - - err = native_pos(nio->nio_nino->ni_fd, &off, SEEK_SET); - if (err) { - nio->nio_nino->ni_resetfpos = 1; - return err; - } - nio->nio_nino->ni_resetfpos = 0; - nio->nio_nino->ni_fpos = off; - } - - /* - * The {read,write}v is safe as this routine is only ever called - * by _sysio_enumerate_extents() and that routine is exact. It never - * passes iovectors including tails. - */ - cc = -#ifndef REDSTORM - count <= MAX_IOVEC - ? syscall(nio->nio_op == 'r' ? SYSIO_SYS_readv : SYSIO_SYS_writev, - nio->nio_nino->ni_fd, - iov, - count) - : -#endif - _sysio_enumerate_iovec(iov, - count, - off, - limit, - (ssize_t (*)(void *, - size_t, - _SYSIO_OFF_T, - void *))dopio, - nio); - if (cc < 0) - cc = -errno; - else - nio->nio_nino->ni_fpos += cc; - return cc; - -#if !(defined(REDSTORM) || defined(MAX_IOVEC)) -#undef MAX_IOVEC -#endif -} - -#if 0 -static int -lockop_all(struct native_inode *nino, - struct intnl_xtvec *xtv, - size_t count, - short op) -{ - struct flock flock; - int err; - - if (!count) - return -EINVAL; - flock.l_type = op; - flock.l_whence = SEEK_SET; - while (count--) { - flock.l_start = xtv->xtv_off; - flock.l_len = xtv->xtv_len; - xtv++; - err = - syscall(SYSIO_SYS_fcntl, - nino->ni_fd, - F_SETLK, - &flock); - if (err != 0) - return -errno; - } - return 0; -} - -static int -order_xtv(const struct intnl_xtvec *xtv1, const struct intnl_xtvec *xtv2) -{ - - if (xtv1->xtv_off < xtv2->xtv_off) - return -1; - if (xtv1->xtv_off > xtv2->xtv_off) - return 1; - return 0; -} -#endif - -static int -doio(char op, struct ioctx *ioctx) -{ - struct native_inode *nino; -#if 0 - int dolocks; - struct intnl_xtvec *oxtv; - int err; -#endif - struct native_io arguments; - ssize_t cc; -#if 0 - struct intnl_xtvec *front, *rear, tmp; -#endif - - nino = I2NI(ioctx->ioctx_ino); -#if 0 - dolocks = ioctx->ioctx_xtvlen > 1 && nino->ni_seekok; - if (dolocks) { - /* - * Must lock the regions (in order!) since we can't do - * strided-IO as a single atomic operation. - */ - oxtv = malloc(ioctx->ioctx_xtvlen * sizeof(struct intnl_xtvec)); - if (!oxtv) - return -ENOMEM; - (void )memcpy(oxtv, - ioctx->ioctx_xtv, - ioctx->ioctx_xtvlen * sizeof(struct intnl_xtvec)); - qsort(oxtv, - ioctx->ioctx_xtvlen, - sizeof(struct intnl_xtvec), - (int (*)(const void *, const void *))order_xtv); - err = - lockop_all(nino, - oxtv, ioctx->ioctx_xtvlen, - op == 'r' ? F_RDLCK : F_WRLCK); - if (err) { - free(oxtv); - return err; - } - } -#endif - arguments.nio_op = op; - arguments.nio_nino = nino; - cc = - _sysio_enumerate_extents(ioctx->ioctx_xtv, ioctx->ioctx_xtvlen, - ioctx->ioctx_iov, ioctx->ioctx_iovlen, - (ssize_t (*)(const struct iovec *, - int, - _SYSIO_OFF_T, - ssize_t, - void *))doiov, - &arguments); -#if 0 - if (dolocks) { - /* - * Must unlock in reverse order. - */ - front = oxtv; - rear = front + ioctx->ioctx_xtvlen - 1; - while (front < rear) { - tmp = *front; - *front++ = *rear; - *rear-- = tmp; - } - if (lockop_all(nino, oxtv, ioctx->ioctx_xtvlen, F_UNLCK) != 0) - abort(); - free(oxtv); - } -#endif - if ((ioctx->ioctx_cc = cc) < 0) { - ioctx->ioctx_errno = -ioctx->ioctx_cc; - ioctx->ioctx_cc = -1; - } - return 0; -} - -static int -native_inop_read(struct inode *ino __IS_UNUSED, struct ioctx *ioctx) -{ - - return doio('r', ioctx); -} - -static int -native_inop_write(struct inode *ino __IS_UNUSED, struct ioctx *ioctx) -{ - - return doio('w', ioctx); -} - -static _SYSIO_OFF_T -native_inop_pos(struct inode *ino, _SYSIO_OFF_T off) -{ - struct native_inode *nino = I2NI(ino); - int err; - - err = native_pos(nino->ni_fd, &off, SEEK_SET); - return err < 0 ? err : off; -} - -static int -native_inop_iodone(struct ioctx *ioctxp __IS_UNUSED) -{ - - /* - * It's always done in this driver. It completed when posted. - */ - return 1; -} - -static int -native_inop_fcntl(struct inode *ino, - int cmd, - va_list ap, - int *rtn) -{ - struct native_inode *nino = I2NI(ino); - long arg; - int err; - - if (nino->ni_fd < 0) - abort(); - - err = 0; - switch (cmd) { - case F_GETFD: - case F_GETFL: -#ifdef F_GETOWN - case F_GETOWN: -#endif - *rtn = syscall(SYSIO_SYS_fcntl, nino->ni_fd, cmd); - if (*rtn == -1) - err = -errno; - break; - case F_DUPFD: - case F_SETFD: - case F_SETFL: - case F_GETLK: - case F_SETLK: - case F_SETLKW: -#ifdef F_SETOWN - case F_SETOWN: -#endif - arg = va_arg(ap, long); - *rtn = syscall(SYSIO_SYS_fcntl, nino->ni_fd, cmd, arg); - if (*rtn == -1) - err = -errno; - break; - default: - *rtn = -1; - err = -EINVAL; - } - return err; -} - -static int -native_inop_mknod(struct pnode *pno __IS_UNUSED, - mode_t mode __IS_UNUSED, - dev_t dev __IS_UNUSED) -{ - - return -ENOSYS; -} - -#ifdef _HAVE_STATVFS -static int -native_inop_statvfs(struct pnode *pno, - struct inode *ino, - struct intnl_statvfs *buf) -{ - char *path; - int rc; - struct statfs fs; - - path = NULL; - if (!ino || I2NI(ino)->ni_fd < 0) { - path = _sysio_pb_path(pno->p_base, '/'); - if (!path) - return -ENOMEM; - } - - /* - * The syscall interface does not support SYSIO_SYS_fstatvfs. - * Should possibly return ENOSYS, but thought it - * better to use SYSIO_SYS_fstatfs and fill in as much of - * the statvfs structure as possible. This allows - * for more of a test of the sysio user interface. - */ - rc = - path - ? syscall(SYSIO_SYS_statfs, path, &fs) - : syscall(SYSIO_SYS_fstatfs, I2NI(ino)->ni_fd, &fs); - if (path) - free(path); - if (rc < 0) - return -errno; - - buf->f_bsize = fs.f_bsize; /* file system block size */ - buf->f_frsize = fs.f_bsize; /* file system fundamental block size */ - buf->f_blocks = fs.f_blocks; - buf->f_bfree = fs.f_bfree; - buf->f_bavail = fs.f_bavail; - buf->f_files = fs.f_files; /* Total number serial numbers */ - buf->f_ffree = fs.f_ffree; /* Number free serial numbers */ - buf->f_favail = fs.f_ffree; /* Number free ser num for non-privileged*/ - buf->f_fsid = fs.f_fsid.__val[1]; - buf->f_flag = 0; /* No equiv in statfs; maybe use type? */ - buf->f_namemax = fs.f_namelen; - return 0; -} -#endif - -static int -native_inop_sync(struct inode *ino) -{ - int err; - - assert(I2NI(ino)->ni_fd >= 0); - - err = syscall(SYSIO_SYS_fsync, I2NI(ino)->ni_fd); - if (err) - err = -errno; - return err; -} - -static int -native_inop_datasync(struct inode *ino) -{ - struct native_inode *nino; - int err; - - nino = I2NI(ino); - assert(nino->ni_fd >= 0); - -#ifdef SYSIO_SYS_fdatasync - err = syscall(SYSIO_SYS_fdatasync, I2NI(ino)->ni_fd); -#else -#if 0 -#warning No fdatasync system call -- Using fsync instead! -#endif - err = syscall(SYSIO_SYS_fsync, I2NI(ino)->ni_fd); -#endif - if (err) - err = -errno; - return err; -} - -#ifdef HAVE_LUSTRE_HACK -static int -native_inop_ioctl(struct inode *ino, - unsigned long int request, - va_list ap) -{ - struct native_inode *nino; - long arg1, arg2, arg3, arg4; - int rtn; - - nino = I2NI(ino); - assert(nino->ni_fd >= 0); - arg1 = va_arg(ap, long); - arg2 = va_arg(ap, long); - arg3 = va_arg(ap, long); - arg4 = va_arg(ap, long); - - rtn = - syscall(SYSIO_SYS_ioctl, I2NI(ino)->ni_fd, request, - arg1, arg2, arg3, arg4); - if (rtn < 0) - rtn = -errno; - return rtn; -} -#else -static int -native_inop_ioctl(struct inode *ino __IS_UNUSED, - unsigned long int request __IS_UNUSED, - va_list ap __IS_UNUSED) -{ - - /* - * I'm lazy. Maybe implemented later. - */ - return -ENOTTY; -} -#endif - -static void -native_inop_gone(struct inode *ino) -{ - struct native_inode *nino = I2NI(ino); - - if (nino->ni_fd >= 0) - (void )syscall(SYSIO_SYS_close, nino->ni_fd); - - free(ino->i_private); -} - -static void -native_fsop_gone(struct filesys *fs __IS_UNUSED) -{ - - free(fs->fs_private); - /* - * Do nothing. There is no private part maintained for the - * native file interface. - */ -} diff --git a/libsysio/drivers/native/fs_native.h b/libsysio/drivers/native/fs_native.h deleted file mode 100644 index 1590379..0000000 --- a/libsysio/drivers/native/fs_native.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -/* - * Native file system driver support. - */ - -extern int _sysio_native_init(void); diff --git a/libsysio/drivers/native/module.mk b/libsysio/drivers/native/module.mk deleted file mode 100644 index 8cada8a..0000000 --- a/libsysio/drivers/native/module.mk +++ /dev/null @@ -1,2 +0,0 @@ -NATIVE_SRCS = drivers/native/fs_native.c -NATIVE_EXTRA = drivers/native/fs_native.h drivers/native/module.mk diff --git a/libsysio/drivers/sockets/.gitignore b/libsysio/drivers/sockets/.gitignore deleted file mode 100644 index c83c013..0000000 --- a/libsysio/drivers/sockets/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/.dirstamp diff --git a/libsysio/drivers/sockets/module.mk b/libsysio/drivers/sockets/module.mk deleted file mode 100644 index 261fcfa..0000000 --- a/libsysio/drivers/sockets/module.mk +++ /dev/null @@ -1,2 +0,0 @@ -SOCKETS_SRCS = drivers/sockets/sockets.c -SOCKETS_EXTRA = drivers/sockets/module.mk diff --git a/libsysio/drivers/sockets/sockets.c b/libsysio/drivers/sockets/sockets.c deleted file mode 100644 index 8dec0a7..0000000 --- a/libsysio/drivers/sockets/sockets.c +++ /dev/null @@ -1,633 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#ifdef __linux__ -#define _BSD_SOURCE -#endif - -#include /* for NULL */ -#include -#ifdef __linux__ -#include -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef __linux__ -#include -#endif -#include -#include - -#include "sysio.h" -#include "xtio.h" -#include "native.h" -#include "fs.h" -#include "inode.h" -#include "file.h" -#include "dev.h" /* _sysio_nodev_ops */ - -/* - * Sockets interface driver - */ - -/* - * Sockets file identifiers format. - */ -struct sockets_ino_identifier { - ino_t inum; /* i-number */ -}; - -/* - * Driver-private i-node information we keep about in-use sockets. - */ -struct socket_info { - struct sockets_ino_identifier ski_ident; /* unique identifier */ - struct file_identifier ski_fileid; /* ditto */ - int ski_fd; /* host fildes */ -}; - -static int sockets_inop_close(struct inode *ino); -static int sockets_inop_read(struct inode *ino, - struct ioctx *ioctx); -static int sockets_inop_write(struct inode *ino, - struct ioctx *ioctxp); -static _SYSIO_OFF_T sockets_inop_pos(struct inode *ino, - _SYSIO_OFF_T off); -static int sockets_inop_iodone(struct ioctx *ioctx); -static int sockets_inop_sync(struct inode *ino); -static int sockets_inop_datasync(struct inode *ino); -static int sockets_inop_fcntl(struct inode *ino, int cmd, va_list ap, int *rtn); -static int sockets_inop_ioctl(struct inode *ino, - unsigned long int request, - va_list ap); -static void sockets_inop_gone(struct inode *ino); -static void sockets_illop(void); - -/* - * Given i-node, return driver private part. - */ -#define I2SKI(ino) ((struct socket_info *)((ino)->i_private)) - -struct filesys_ops sockets_filesys_ops = { - (void (*)(struct filesys *))sockets_illop -}; - -static struct filesys *sockets_fs = NULL; - -static struct inode_ops sockets_i_ops; - -/* - * Initialize this driver. - */ -int -_sysio_sockets_init() -{ - - assert(!sockets_fs); - - sockets_i_ops = _sysio_nodev_ops; - sockets_i_ops.inop_close = sockets_inop_close; - sockets_i_ops.inop_read = sockets_inop_read; - sockets_i_ops.inop_write = sockets_inop_write; - sockets_i_ops.inop_pos = sockets_inop_pos; - sockets_i_ops.inop_iodone = sockets_inop_iodone; - sockets_i_ops.inop_fcntl = sockets_inop_fcntl; - sockets_i_ops.inop_sync = sockets_inop_sync; - sockets_i_ops.inop_datasync = sockets_inop_datasync; - sockets_i_ops.inop_ioctl = sockets_inop_ioctl; - sockets_i_ops.inop_gone = sockets_inop_gone; - - sockets_fs = _sysio_fs_new(&sockets_filesys_ops, 0, NULL); - if (!sockets_fs) - return -ENOMEM; - - return 0; -} - -static int -sockets_inop_close(struct inode *ino) -{ - struct socket_info *ski = I2SKI(ino); - int err; - - if (ski->ski_fd < 0) - return -EBADF; - - err = syscall(SYSIO_SYS_close, ski->ski_fd); - if (err) - return -errno; - ski->ski_fd = -1; - return 0; -} - -/* - * A helper function performing the real IO operation work. - * - * We don't really have async IO. We'll just perform the function - * now. - */ -static int -doio(ssize_t (*f)(int, const struct iovec *, int), - struct inode *ino, - struct ioctx *ioctx) -{ - struct socket_info *ski = I2SKI(ino); - - assert(ski->ski_fd >= 0); - - /* XXX there's no way to check the position - * here we only could ingore the extends - */ - if (ioctx->ioctx_xtvlen != 1) - return -EINVAL; - - if (ioctx->ioctx_iovlen && (int) ioctx->ioctx_iovlen < 0) - return -EINVAL; - - /* - * Call the appropriate (read/write) IO function to - * transfer the data now. - */ - ioctx->ioctx_cc = - (*f)(ski->ski_fd, ioctx->ioctx_iov, ioctx->ioctx_iovlen); - if (ioctx->ioctx_cc < 0) - ioctx->ioctx_errno = errno; - - ioctx->ioctx_done = 1; - return 0; -} - -/* - * Helper function passed to doio(), above, to accomplish a real readv. - */ -static ssize_t -_readv(int fd, const struct iovec *vector, int count) -{ - - return syscall(SYSIO_SYS_readv, fd, vector, count); -} - -static int -sockets_inop_read(struct inode *ino, - struct ioctx *ioctx) -{ - - return doio(_readv, ino, ioctx); -} - -/* - * Helper function passed to doio(), above, to accomplish a real writev. - */ -static ssize_t -_writev(int fd, const struct iovec *vector, int count) -{ - - return syscall(SYSIO_SYS_writev, fd, vector, count); -} - -static int -sockets_inop_write(struct inode *ino, - struct ioctx *ioctx) -{ - - return doio(_writev, ino, ioctx); -} - -static _SYSIO_OFF_T -sockets_inop_pos(struct inode *ino __IS_UNUSED, _SYSIO_OFF_T off __IS_UNUSED) -{ - return -EINVAL; -} - -static int -sockets_inop_iodone(struct ioctx *ioctxp __IS_UNUSED) -{ - - /* - * It's always done in this driver. It completed when posted. - */ - return 1; -} - -static int -sockets_inop_fcntl(struct inode *ino __IS_UNUSED, - int cmd __IS_UNUSED, - va_list ap __IS_UNUSED, - int *rtn) -{ - long arg; - - assert(I2SKI(ino)->ski_fd >= 0); - - switch (cmd) { - case F_GETFD: - case F_GETFL: - case F_GETOWN: - *rtn = syscall(SYSIO_SYS_fcntl, I2SKI(ino)->ski_fd, cmd); - break; - case F_DUPFD: - case F_SETFD: - case F_SETFL: - case F_GETLK: - case F_SETLK: - case F_SETLKW: - case F_SETOWN: - arg = va_arg(ap, long); - *rtn = syscall(SYSIO_SYS_fcntl, I2SKI(ino)->ski_fd, cmd, arg); - break; - default: - *rtn = -1; - errno = EINVAL; - } - return *rtn == -1 ? -errno : 0; -} - -static int -sockets_inop_sync(struct inode *ino) -{ - - assert(I2SKI(ino)->ski_fd >= 0); - - return syscall(SYSIO_SYS_fsync, I2SKI(ino)->ski_fd); -} - -static int -sockets_inop_datasync(struct inode *ino) -{ - - assert(I2SKI(ino)->ski_fd >= 0); - - return syscall(SYSIO_SYS_fdatasync, I2SKI(ino)->ski_fd); -} - -#ifdef HAVE_LUSTRE_HACK -/* - * we blindly extract 4 params and pass to host kernel, the stack - * should be ok. hope no ioctl will consume more then 4 params... - */ -static int -sockets_inop_ioctl(struct inode *ino, - unsigned long int request, - va_list ap) -{ - long arg1, arg2, arg3, arg4; - - assert(I2SKI(ino)->ski_fd >= 0); - - arg1 = va_arg(ap, long); - arg2 = va_arg(ap, long); - arg3 = va_arg(ap, long); - arg4 = va_arg(ap, long); - - return syscall(SYSIO_SYS_ioctl, I2SKI(ino)->ski_fd, request, - arg1, arg2, arg3, arg4); -} -#else -static int -sockets_inop_ioctl(struct inode *ino __IS_UNUSED, - unsigned long int request __IS_UNUSED, - va_list ap __IS_UNUSED) -{ - /* - * I'm lazy. Maybe implemented later. - */ - return -ENOTTY; -} -#endif - -static void -sockets_inop_gone(struct inode *ino) -{ - - (void )sockets_inop_close(ino); - free(ino->i_private); -} - -static void -sockets_illop(void) -{ - - abort(); -} - -static struct inode * -_sysio_sockets_inew() -{ - static ino_t inum = 1; - struct socket_info *ski; - struct inode *ino; - static struct intnl_stat zero_stat; - - ski = malloc(sizeof(struct socket_info)); - if (!ski) - return NULL; - ski->ski_ident.inum = inum++; - ski->ski_fileid.fid_data = &ski->ski_ident; - ski->ski_fileid.fid_len = sizeof(ski->ski_ident); - ski->ski_fd = -1; - - ino = - _sysio_i_new(sockets_fs, - &ski->ski_fileid, - &zero_stat, - 0, - &sockets_i_ops, - ski); - if (!ino) - free(ski); - - return ino; -} - -int -SYSIO_INTERFACE_NAME(socket)(int domain, int type, int protocol) -{ - int err; - struct inode *ino; - struct socket_info *ski; - struct file *fil; - - err = 0; - fil = NULL; - - ino = _sysio_sockets_inew(); - if (!ino) { - err = -ENOMEM; - goto error; - } - - ski = I2SKI(ino); -#ifndef SYSIO_SYS_socketcall - ski->ski_fd = syscall(SYSIO_SYS_socket, domain, type, protocol); -#else - { - unsigned long avec[3] = {domain, type, protocol}; - ski->ski_fd = - syscall(SYSIO_SYS_socketcall, SYS_SOCKET, avec); - } -#endif - if (ski->ski_fd < 0) { - err = -errno; - goto error; - } - - fil = _sysio_fnew(ino, O_RDWR); - if (!fil) { - err = -ENOMEM; - goto error; - } - -#ifdef HAVE_LUSTRE_HACK - err = _sysio_fd_set(fil, ski->ski_fd, 1); -#else - err = _sysio_fd_set(fil, -1, 0); -#endif - if (err < 0) - goto error; - - return err; - -error: - if (fil) - F_RELE(fil); - if (ino) - I_RELE(ino); - - errno = -err; - return -1; -} - -int -SYSIO_INTERFACE_NAME(accept)(int s, struct sockaddr *addr, socklen_t *addrlen) -{ - int err; - struct inode *ino; - struct socket_info *ski; - struct file *ofil, *nfil; - - err = 0; - nfil = NULL; - ino = NULL; - - ofil = _sysio_fd_find(s); - if (!ofil) { - err = -EBADF; - goto error; - } - - ino = _sysio_sockets_inew(); - if (!ino) { - err = -ENOMEM; - goto error; - } - - nfil = _sysio_fnew(ino, O_RDWR); - if (!nfil) { - err = -ENOMEM; - goto error; - } - - ski = I2SKI(ino); -#ifndef SYSIO_SYS_socketcall - ski->ski_fd = - syscall(SYSIO_SYS_accept, - I2SKI(ofil->f_ino)->ski_fd, - addr, - addrlen); -#else - { - unsigned long avec[3] = { - (unsigned long) I2SKI(ofil->f_ino)->ski_fd, - (unsigned long) addr, - (unsigned long) addrlen}; - ski->ski_fd = - syscall(SYSIO_SYS_socketcall, SYS_ACCEPT, avec); - } -#endif - if (ski->ski_fd < 0) { - err = -errno; - goto error; - } - -#ifdef HAVE_LUSTRE_HACK - err = _sysio_fd_set(nfil, ski->ski_fd, 1); -#else - err = _sysio_fd_set(nfil, -1, 0); -#endif - if (err < 0) - goto error; - - return err; - -error: - if (nfil) - F_RELE(nfil); - if (ino) - I_RELE(ino); - - errno = -err; - return -1; -} - -int -SYSIO_INTERFACE_NAME(bind)(int sockfd, - const struct sockaddr *my_addr, - socklen_t addrlen) -{ - int err; - struct file *fil; -#ifdef SYSIO_SYS_socketcall - unsigned long avec[3]; -#endif - - err = 0; - - fil = _sysio_fd_find(sockfd); - if (!fil) { - err = -EBADF; - goto out; - } - -#ifndef SYSIO_SYS_socketcall - if (syscall(SYSIO_SYS_bind, - I2SKI(fil->f_ino)->ski_fd, - my_addr, - addrlen)) { -#else - avec[0] = I2SKI(fil->f_ino)->ski_fd; - avec[1] = (unsigned long )my_addr; - avec[2] = addrlen; - if (syscall(SYSIO_SYS_socketcall, SYS_BIND, avec) != 0) { -#endif - err = -errno; - goto out; - } - - return 0; -out: - errno = -err; - return -1; -} - -int -SYSIO_INTERFACE_NAME(listen)(int s, int backlog) -{ - int err; - struct file *fil; -#ifdef SYSIO_SYS_socketcall - unsigned long avec[2]; -#endif - - err = 0; - - fil = _sysio_fd_find(s); - if (!fil) { - err = -EBADF; - goto out; - } - -#ifndef SYSIO_SYS_socketcall - if (syscall(SYSIO_SYS_listen, - I2SKI(fil->f_ino)->ski_fd, - backlog) != 0) { -#else - avec[0] = I2SKI(fil->f_ino)->ski_fd; - avec[1] = backlog; - if (syscall(SYSIO_SYS_socketcall, SYS_LISTEN, avec) != 0) { -#endif - err = -errno; - goto out; - } - - return 0; -out: - errno = -err; - return -1; -} - -int -SYSIO_INTERFACE_NAME(connect)(int sockfd, - const struct sockaddr *serv_addr, - socklen_t addrlen) -{ - int err; - struct file *fil; -#ifdef SYSIO_SYS_socketcall - unsigned long avec[3]; -#endif - - err = 0; - - fil = _sysio_fd_find(sockfd); - if (!fil) { - err = -EBADF; - goto out; - } - -#ifndef SYSIO_SYS_socketcall - if (syscall(SYSIO_SYS_connect, - I2SKI(fil->f_ino)->ski_fd, - serv_addr, - addrlen) != 0) { -#else - avec[0] = I2SKI(fil->f_ino)->ski_fd; - avec[1] = (unsigned long )serv_addr; - avec[2] = addrlen; - if (syscall(SYSIO_SYS_socketcall, SYS_CONNECT, avec) != 0) { -#endif - err = -errno; - goto out; - } - - return 0; -out: - errno = -err; - return -1; -} diff --git a/libsysio/drivers/yod/.gitignore b/libsysio/drivers/yod/.gitignore deleted file mode 100644 index c83c013..0000000 --- a/libsysio/drivers/yod/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/.dirstamp diff --git a/libsysio/drivers/yod/fs_yod.c b/libsysio/drivers/yod/fs_yod.c deleted file mode 100644 index ea0ce35..0000000 --- a/libsysio/drivers/yod/fs_yod.c +++ /dev/null @@ -1,1252 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#ifdef __linux__ -#define _BSD_SOURCE -#endif - -#include /* for NULL */ -#include -#ifdef __linux__ -#include -#endif -#include -#include -#include -#include -#include -#include -#include -#if 0 -#include -#endif -#ifdef _HAVE_STATVFS -#include -#endif -#include -#include - -#include "xtio.h" -#include "sysio.h" -#include "fs.h" -#include "mount.h" -#include "inode.h" - -#include "fs_yod.h" - -/* - * Remote file system driver - * calls are re-directed to the initiating yod - */ -#include "cplant-yod.h" - -/* stat struct used by yod, which - * is not compiled with __USE_FILE_OFFSET64 - */ -#define __yod_stat stat -#ifdef ALPHA_LINUX -#define COPY_STAT(src, dest) \ -do { \ - memset((dest), 0, sizeof((*dest))); \ - (dest)->st_dev = (src)->st_dev; \ - (dest)->st_ino = (src)->st_ino; \ - (dest)->st_mode = (src)->st_mode; \ - (dest)->st_nlink = (src)->st_nlink; \ - (dest)->st_uid = (src)->st_uid; \ - (dest)->st_gid = (src)->st_gid; \ - (dest)->st_rdev = (src)->st_rdev; \ - (dest)->st_size = (src)->st_size; \ - (dest)->st_atime = (src)->st_atime; \ - (dest)->st_mtime = (src)->st_mtime; \ - (dest)->st_ctime = (src)->st_ctime; \ - (dest)->st_blksize = (src)->st_blksize; \ - (dest)->st_blocks = (src)->st_blocks; \ - (dest)->st_flags = (src)->st_flags; \ - (dest)->st_gen = (src)->st_gen; \ -} while (0) -#else -#define COPY_STAT(src, dest) \ -do { \ - memset((dest), 0, sizeof((*dest))); \ - (dest)->st_dev = (src)->st_dev; \ - (dest)->st_ino = (src)->st_ino; \ - (dest)->st_mode = (src)->st_mode; \ - (dest)->st_nlink = (src)->st_nlink; \ - (dest)->st_uid = (src)->st_uid; \ - (dest)->st_gid = (src)->st_gid; \ - (dest)->st_rdev = (src)->st_rdev; \ - (dest)->st_size = (src)->st_size; \ - (dest)->st_atime = (src)->st_atime; \ - (dest)->st_mtime = (src)->st_mtime; \ - (dest)->st_ctime = (src)->st_ctime; \ - (dest)->st_blksize = (src)->st_blksize; \ - (dest)->st_blocks = (src)->st_blocks; \ -} while (0) -#endif - -/* - * Yod file identifiers format. - */ -struct yod_inode_identifier { - dev_t dev; /* device number */ - ino_t ino; /* i-number */ -#ifdef HAVE_GENERATION - unsigned int gen; /* generation number */ -#endif -}; - -/* - * Driver-private i-node information we keep about local host file - * system objects. - */ -struct yod_inode { - unsigned ni_seekok : 1; /* can seek? */ - struct yod_inode_identifier ni_ident; /* unique identifier */ - struct file_identifier ni_fileid; /* ditto */ - int ni_fd; /* host fildes */ - int ni_oflags; /* flags, from open */ - unsigned ni_nopens; /* soft ref count */ - _SYSIO_OFF_T ni_fpos; /* current pos */ -}; - -static int yod_inop_lookup(struct pnode *pno, - struct inode **inop, - struct intent *intnt, - const char *path); -static int yod_inop_getattr(struct pnode *pno, - struct inode *ino, - struct intnl_stat *stbuf); -static int yod_inop_setattr(struct pnode *pno, - struct inode *ino, - unsigned mask, - struct intnl_stat *stbuf); -static ssize_t yod_filldirentries(struct inode *ino, - off64_t *posp, - char *buf, - size_t nbytes); -static int yod_inop_mkdir(struct pnode *pno, mode_t mode); -static int yod_inop_rmdir(struct pnode *pno); -static int yod_inop_symlink(struct pnode *pno, const char *data); -static int yod_inop_readlink(struct pnode *pno, char *buf, size_t bufsiz); -static int yod_inop_open(struct pnode *pno, int flags, mode_t mode); -static int yod_inop_close(struct inode *ino); -static int yod_inop_link(struct pnode *old, struct pnode *new); -static int yod_inop_unlink(struct pnode *pno); -static int yod_inop_rename(struct pnode *old, struct pnode *new); -static _SYSIO_OFF_T yod_inop_pos (struct inode *ino, _SYSIO_OFF_T off); -static int yod_inop_read(struct inode *ino, struct ioctx *ioctx); -static int yod_inop_write(struct inode *ino, struct ioctx *ioctx); -static int yod_inop_iodone(struct ioctx *ioctx); -static int yod_inop_fcntl(struct inode *ino, int cmd, va_list ap, int *rtn); -static int yod_inop_sync(struct inode *ino); -static int yod_inop_datasync(struct inode *ino); -static int yod_inop_ioctl(struct inode *ino, - unsigned long int request, - va_list ap); -static int yod_inop_mknod(struct pnode *pno, mode_t mode, dev_t dev); -#ifdef _HAVE_STATVFS -static int yod_inop_statvfs(struct pnode *pno, - struct inode *ino, - struct intnl_statvfs *buf); -#endif -static void yod_inop_gone(struct inode *ino); - -static struct inode_ops yod_i_ops = { - yod_inop_lookup, - yod_inop_getattr, - yod_inop_setattr, - yod_filldirentries, - yod_inop_mkdir, - yod_inop_rmdir, - yod_inop_symlink, - yod_inop_readlink, - yod_inop_open, - yod_inop_close, - yod_inop_link, - yod_inop_unlink, - yod_inop_rename, - yod_inop_read, - yod_inop_write, - yod_inop_pos, - yod_inop_iodone, - yod_inop_fcntl, - yod_inop_sync, - yod_inop_datasync, - yod_inop_ioctl, - yod_inop_mknod, -#ifdef _HAVE_STATVFS - yod_inop_statvfs, -#endif - yod_inop_gone -}; - -static int yod_fsswop_mount(const char *source, - unsigned flags, - const void *data, - struct pnode *tocover, - struct mount **mntp); - -static struct fssw_ops yod_fssw_ops = { - yod_fsswop_mount -}; - -static void yod_fsop_gone(struct filesys *fs); - -static struct filesys_ops yod_inodesys_ops = { - yod_fsop_gone -}; - -/* - * Placeholder internal mount as in native driver - */ -static struct mount *yod_internal_mount = NULL; - -/* - * Given i-node, return driver private part. - */ -#define I2NI(ino) ((struct yod_inode *)((ino)->i_private)) - -/* - * stat -- by path. - */ -static int -yod_stat(const char *path, struct intnl_stat *buf) -{ - int err; - struct __yod_stat stbuf; - - err = stat_yod(path, &stbuf); - if (err) - err = -errno; - COPY_STAT(&stbuf, buf); - - return err; -} - -/* - * stat -- by fildes - */ -static int -yod_fstat(int fd, struct intnl_stat *buf) -{ - int err; - struct __yod_stat stbuf; - - err = fstat_yod(fd, &stbuf); - if (err) - err = -errno; - COPY_STAT(&stbuf, buf); - - return err; -} - -/* - * Introduce an i-node to the system. - */ -static struct inode * -yod_i_new(struct filesys *fs, struct intnl_stat *buf) -{ - struct yod_inode *nino; - struct inode *ino; - - nino = malloc(sizeof(struct yod_inode)); - if (!nino) - return NULL; - bzero(&nino->ni_ident, sizeof(nino->ni_ident)); - nino->ni_seekok = 0; - nino->ni_ident.dev = buf->st_dev; - nino->ni_ident.ino = buf->st_ino; -#ifdef HAVE_GENERATION - nino->ni_ident.gen = buf->st_gen; -#endif - nino->ni_fileid.fid_data = &nino->ni_ident; - nino->ni_fileid.fid_len = sizeof(nino->ni_ident); - nino->ni_fd = -1; - nino->ni_oflags = 0; - nino->ni_nopens = 0; - nino->ni_fpos = 0; - ino = - _sysio_i_new(fs, - &nino->ni_fileid, - buf, - 0, - &yod_i_ops, - nino); - if (!ino) - free(nino); - return ino; -} - -/* - * Initialize this driver. - */ -int -_sysio_yod_init() -{ - - /* - * Capture current process umask and reset our process umask to - * zero. All permission bits to open/creat/setattr are absolute -- - * They've already had a umask applied, when appropriate. - */ - _sysio_umask = syscall(SYS_umask, 0); - - return _sysio_fssw_register("yod", &yod_fssw_ops); -} - -/* - * Create private, internal, view of the hosts name space. - */ -static int -create_internal_namespace() -{ - int err; - struct mount *mnt; - struct inode *rootino; - struct pnode_base *rootpb; - static struct qstr noname = { NULL, 0, 0 }; - struct filesys *fs; - struct intnl_stat stbuf; - - if (yod_internal_mount) { - /* - * Reentered! - */ - abort(); - } - - /* - * We maintain an artificial, internal, name space in order to - * have access to fully qualified path names in the various routines. - * Initialize that name space now. - */ - mnt = NULL; - rootino = NULL; - rootpb = NULL; - fs = _sysio_fs_new(&yod_inodesys_ops, 0, NULL); - if (!fs) { - err = -ENOMEM; - goto error; - } - - /* - * Get root i-node. - */ - err = yod_stat("/", &stbuf); - if (err) - goto error; - rootino = yod_i_new(fs, &stbuf); - if (!rootino) { - err = -ENOMEM; - goto error; - } - - /* - * Generate base path-node for root. - */ - rootpb = _sysio_pb_new(&noname, NULL, rootino); - if (!rootpb) { - err = -ENOMEM; - goto error; - } - - /* - * Mount it. This name space is disconnected from the - * rest of the system -- Only available within this driver. - */ - err = _sysio_do_mount(fs, rootpb, 0, NULL, &mnt); - if (err) - goto error; - - yod_internal_mount = mnt; - return 0; -error: - if (mnt) { - if (_sysio_do_unmount(mnt) != 0) - abort(); - fs = NULL; - rootpb = NULL; - rootino = NULL; - } - if (rootpb) - _sysio_pb_gone(rootpb); - if (fs) { - FS_RELE(fs); - } - - return err; -} - -static int -yod_fsswop_mount(const char *source, - unsigned flags, - const void *data __IS_UNUSED, - struct pnode *tocover, - struct mount **mntp) -{ - int err; - struct nameidata nameidata; - struct mount *mnt; - - /* - * Caller must use fully qualified path names when specifying - * the source. - */ - if (*source != '/') - return -ENOENT; - - if (!yod_internal_mount) { - err = create_internal_namespace(); - if (err) - return err; - } - - /* - * Lookup the source in the internally maintained name space. - */ - ND_INIT(&nameidata, 0, source, yod_internal_mount->mnt_root, NULL); - err = _sysio_path_walk(yod_internal_mount->mnt_root, &nameidata); - if (err) - return err; - - /* - * Have path-node specified by the given source argument. Let the - * system finish the job, now. - */ - err = - _sysio_do_mount(yod_internal_mount->mnt_fs, - nameidata.nd_pno->p_base, - flags, - tocover, - &mnt); - /* - * Release the internal name space pnode and clean up any - * aliases we might have generated. We really don't need to cache them - * as they are only used at mount time.. - */ - P_RELE(nameidata.nd_pno); - (void )_sysio_p_prune(yod_internal_mount->mnt_root); - - if (!err) { - FS_REF(yod_internal_mount->mnt_fs); - *mntp = mnt; - } - return err; -} - -static int -yod_i_invalid(struct inode *inop, struct intnl_stat *stat) -{ - /* - * Validate passed in inode against stat struct info - */ - struct yod_inode *nino = I2NI(inop); - - if ((nino->ni_ident.dev != stat->st_dev || - nino->ni_ident.ino != stat->st_ino || -#ifdef HAVE_GENERATION - nino->ni_ident.gen != stat->st_gen || -#endif - ((inop)->i_stbuf.st_mode & S_IFMT) != (stat->st_mode & S_IFMT)) || - (((inop)->i_stbuf.st_rdev != stat->st_rdev) && - (S_ISCHR((inop)->i_stbuf.st_mode) || - S_ISBLK((inop)->i_stbuf.st_mode)))) - return 1; - - return 0; -} - -/* - * Find, and validate, or create i-node by host-relative path. Returned i-node - * is referenced. - */ -static int -yod_iget(struct filesys *fs, - const char *path, - struct inode **inop, - int forced) -{ - int err; - struct inode *ino; - struct intnl_stat stbuf; - struct yod_inode_identifier ident; - struct file_identifier fileid; - - /* - * Get file status. - */ - err = yod_stat(path, &stbuf); - if (err) { - *inop = NULL; - return err; - } - - /* - * Validate? - */ - if (*inop) { - if (!yod_i_invalid(*inop, &stbuf)) - return 0; - /* - * Invalidate. - */ - *inop = NULL; - } - - /* - * I-node is not already known. Find or create it. - */ - bzero(&ident, sizeof(ident)); - ident.dev = stbuf.st_dev; - ident.ino = stbuf.st_ino; -#ifdef HAVE_GENERATION - ident.gen = stbuf.st_gen; -#endif - fileid.fid_data = &ident; - fileid.fid_len = sizeof(ident); - ino = _sysio_i_find(fs, &fileid); - if (ino && forced) { - /* - * Insertion was forced but it's already present! - */ - if (yod_i_invalid(ino, &stbuf)) { - /* - * Cached inode has stale attrs - * make way for the new one - */ - I_RELE(ino); - _sysio_i_undead(ino); - ino = NULL; - } else - /* - * OK to reuse cached inode - */ - goto out; - } - - if (!ino) { - ino = yod_i_new(fs, &stbuf); - if (!ino) - err = -ENOMEM; - } -out: - if (!err) - *inop = ino; - return err; -} - -/* - * Look up named object in host's name space by path. - */ -static int -yod_path_lookup(struct filesys *fs, const char *path, struct inode **inop) -{ - - return yod_iget(fs, path, inop, 0); -} - -/* - * Look up object by it's path node. - */ -static int -yod_i_lookup(struct filesys *fs, struct pnode_base *pb, struct inode **inop) -{ - int err; - char *path; - - path = _sysio_pb_path(pb, '/'); - if (!path) - return -ENOMEM; - err = yod_path_lookup(fs, path, inop); - free(path); - return err; -} - -static int -yod_inop_lookup(struct pnode *pno, - struct inode **inop, - struct intent *intnt __IS_UNUSED, - const char *path __IS_UNUSED) -{ - int err; - - *inop = pno->p_base->pb_ino; - - /* - * Don't have an inode yet. Because we translate everything back to - * a single name space for the host, we will assume the object the - * caller is looking for has no existing alias in our internal - * name space. We don't see the same file on different mounts in the - * underlying host FS as the same file. - * - * The file identifier *will* be unique. It's got to have a different - * dev. - */ - err = yod_i_lookup(pno->p_mount->mnt_fs, pno->p_base, inop); - if (err) - *inop = NULL; - return err; -} - -static int -yod_inop_getattr(struct pnode *pno, struct inode *ino, struct intnl_stat *stbuf) -{ - char *path; - int err; - - path = NULL; - if (!ino || I2NI(ino)->ni_fd < 0) { - path = _sysio_pb_path(pno->p_base, '/'); - if (!path) - return -ENOMEM; - } - err = - path - ? yod_stat(path, stbuf) - : yod_fstat(I2NI(ino)->ni_fd, stbuf); - if (path) - free(path); - return err; -} - -static int -yod_inop_setattr(struct pnode *pno, - struct inode *ino, - unsigned mask, - struct intnl_stat *stbuf) -{ - char *path; - int fd; - struct intnl_stat st; - int err; - - path = NULL; - fd = ino ? I2NI(ino)->ni_fd : -1; - if (fd < 0 || mask & (SETATTR_MTIME|SETATTR_ATIME)) { - if (!pno) - return -EEXIST; - path = _sysio_pb_path(pno->p_base, '/'); - if (!path) - return -ENOMEM; - } - - /* - * Get current status for undo. - */ - err = - fd < 0 - ? yod_stat(path, &st) - : yod_fstat(fd, &st); - if (err) - goto out; - - if (mask & SETATTR_MODE) { - mode_t mode; - - /* - * Alter permissions attribute. - */ - mode = stbuf->st_mode & 07777; - err = chmod_yod(path, mode); - } - if (err) - mask &= ~SETATTR_MODE; - - if (mask & (SETATTR_UID|SETATTR_GID)) { - - /* - * Alter owner and/or group identifiers. - */ - err = chown_yod(path, - mask & SETATTR_UID - ? stbuf->st_uid - : (uid_t )-1, - mask & SETATTR_GID - ? stbuf->st_gid - : (gid_t )-1); - } - if (err) - mask &= ~(SETATTR_UID|SETATTR_GID); - else if (mask & SETATTR_LEN) { - /* - * Do the truncate last. It can't be undone. - */ - (void )(fd < 0 - ? truncate_yod(path, stbuf->st_size) - : ftruncate_yod(fd, stbuf->st_size)); - } - if (!err) - goto out; - /* - * Undo after error. Some or all of this might not work... We - * can but try. - */ - if (mask & (SETATTR_UID|SETATTR_GID)) { - (void )chown_yod(path, - mask & SETATTR_UID - ? st.st_uid - : (uid_t )-1, - mask & SETATTR_GID - ? st.st_gid - : (gid_t )-1); - } - if (mask & SETATTR_MODE) { - chmod_yod(path, st.st_mode & 07777); - } -out: - if (path) - free(path); - return err; -} - -static ssize_t -yod_filldirentries(struct inode *ino, - char *buf, - _SYSIO_OFF_T *posp, - size_t nbytes) -{ - struct yod_inode *nino = I2NI(ino); - _SYSIO_OFF_T result; - ssize_t cc; - - assert(nino->ni_fd >= 0); - - result = *basep; - if (*basep != nino->ni_fpos && - (result = lseek_yod(nino->ni_fd, - *posp, - SEEK_SET) == -1)) - return -errno; - nino->ni_fpos = result; - memset(buf, 0, nbytes); - /* - * This is almost certainly broken. The resulting position parameter - * points to the block just filled, not the next. - */ - cc = getdirentries_yod(nino->ni_fd, buf, nbytes, &result); - if (cc < 0) - return -errno; - nino->ni_fpos = *posp = result; - return cc; -} - -static int -yod_inop_mkdir(struct pnode *pno, mode_t mode) -{ - char *path; - int err; - - path = _sysio_pb_path(pno->p_base, '/'); - if (!path) - return -ENOMEM; - - err = mkdir_yod(path, mode); - free(path); - return err; -} - -static int -yod_inop_rmdir(struct pnode *pno) -{ - char *path; - int err; - - path = _sysio_pb_path(pno->p_base, '/'); - if (!path) - return -ENOMEM; - - err = rmdir_yod(path); - free(path); - return err; -} - -static int -yod_inop_symlink(struct pnode *pno, const char *data) -{ - char *path; - int err; - - path = _sysio_pb_path(pno->p_base, '/'); - if (!path) - return -ENOMEM; - - err = symlink_yod(data, path); - free(path); - return err; -} - -static int -yod_inop_readlink(struct pnode *pno __IS_UNUSED, - char *buf __IS_UNUSED, - size_t bufsiz __IS_UNUSED) -{ - - return -ENOSYS; -} - -static int -yod_inop_open(struct pnode *pno, int flags, mode_t mode) -{ - struct yod_inode *nino; - char *path; - int fd; - - path = _sysio_pb_path(pno->p_base, '/'); - if (!path) - return -ENOMEM; - - /* - * Whether the file is already open, or not, makes no difference. - * Want to always give the host OS a chance to authorize in case - * something has changed underneath us. - */ - if (flags & O_WRONLY) { - /* - * Promote write-only attempt to RW. - */ - flags &= ~O_WRONLY; - flags |= O_RDWR; - } - fd = open_yod(path, flags, mode); - if (!pno->p_base->pb_ino && fd >= 0) { - int err; - - /* - * Success but we need to return an i-node. - */ - err = - yod_iget(pno->p_mount->mnt_fs, - path, - &pno->p_base->pb_ino, - 1); - if (err) { - (void )close_yod(fd); - if (err == -EEXIST) - abort(); - fd = err; - } - } - free(path); - if (fd < 0) - return -errno; - - /* - * Remember this new open. - */ - nino = I2NI(pno->p_base->pb_ino); - nino->ni_nopens++; - assert(nino->ni_nopens); - - if (nino->ni_fd >= 0) { - if ((nino->ni_oflags & O_RDWR) || - (flags & (O_RDONLY|O_WRONLY|O_RDWR)) == O_RDONLY) { - /* - * Keep existing. - */ - (void )close_yod(fd); - return 0; - } - (void )close_yod(nino->ni_fd); - } - /* - * Invariant; First open. Must init. - */ - nino->ni_fpos = 0; - nino->ni_fd = fd; - - /* - * Need to know whether we can seek on this - * descriptor. - */ - nino->ni_seekok = - lseek_yod(nino->ni_fd, 0, SEEK_CUR) != 0 ? 0 : 1; - - return 0; -} - -static int -yod_inop_close(struct inode *ino) -{ - struct yod_inode *nino = I2NI(ino); - int err; - - if (nino->ni_fd < 0) - abort(); - - assert(nino->ni_nopens); - if (--nino->ni_nopens) - return 0; - - err = close_yod(nino->ni_fd); - if (err) - return -errno; - - nino->ni_fd = -1; - nino->ni_fpos = 0; - return 0; -} - -static int -yod_inop_link(struct pnode *old, struct pnode *new) -{ - int err; - char *opath, *npath; - - err = 0; - - opath = _sysio_pb_path(old->p_base, '/'); - npath = _sysio_pb_path(new->p_base, '/'); - if (!(opath && npath)) { - err = -ENOMEM; - goto out; - } - - err = link_yod(opath, npath); - -out: - if (opath) - free(opath); - if (npath) - free(npath); - - return err; -} - -static int -yod_inop_unlink(struct pnode *pno) -{ - char *path; - int err = 0; - - path = _sysio_pb_path(pno->p_base, '/'); - if (!path) - return -ENOMEM; - - /* - * For this driver, unlink is easy with open files. Since the - * file remains open to the system, too, the descriptors are still - * valid. - * - * Other drivers will have some difficulty here as the entry in the - * file system name space must be removed without sacrificing access - * to the file itself. In NFS this is done with a mechanism referred - * to as a `silly delete'. The file is moved to a temporary name - * (usually .NFSXXXXXX, where the X's are replaced by the PID and some - * unique characters) in order to simulate the proper semantic. - */ - if (unlink_yod(path) != 0) - err = -errno; - free(path); - return err; -} - -/* - * A helper function performing the real IO operation work. - * - * We don't really have async IO. We'll just perform the function - * now. - */ -static int -doio(ssize_t (*f)(void *, size_t, _SYSIO_OFF_T, struct yod_inode *), - struct ioctx *ioctx) -{ - struct yod_inode *nino = I2NI(ioctx->ioctx_ino); - - ioctx->ioctx_cc = - _sysio_doio(ioctx->ioctx_xtv, ioctx->ioctx_xtvlen, - ioctx->ioctx_iov, ioctx->ioctx_iovlen, - (ssize_t (*)(void *, size_t, - _SYSIO_OFF_T, void *))f, - nino); - if (ioctx->ioctx_cc < 0) { - ioctx->ioctx_errno = -ioctx->ioctx_cc; - ioctx->ioctx_cc = -1; - return -1; - } - nino->ni_fpos += ioctx->ioctx_cc; - ioctx->ioctx_done = 1; - return 0; -} - -static ssize_t -yod_read_simple(void *buf, - size_t nbytes, - _SYSIO_OFF_T off, - struct yod_inode *nino) -{ - if (off != nino->ni_fpos) { - _SYSIO_OFF_T rtn; - - rtn = lseek_yod(nino->ni_fd, off, SEEK_SET); - if (rtn < 0) - return -1; - nino->ni_fpos = rtn; - } - return read_yod(nino->ni_fd, buf, nbytes); -} - -static int -yod_inop_read(struct inode *ino __IS_UNUSED, struct ioctx *ioctx) -{ - - return doio(yod_read_simple, ioctx); -} - -static int -yod_inop_rename(struct pnode *old, struct pnode *new) -{ - int err; - char *opath, *npath; - - opath = _sysio_pb_path(old->p_base, '/'); - npath = _sysio_pb_path(new->p_base, '/'); - if (!(opath && npath)) { - err = -ENOMEM; - goto out; - } - - err = rename_yod(opath, npath); - -out: - if (opath) - free(opath); - if (npath) - free(npath); - - return err; -} - -static ssize_t -yod_write_simple(void *buf, - size_t nbytes, - _SYSIO_OFF_T off, - struct yod_inode *nino) -{ - - if (off != nino->ni_fpos) { - _SYSIO_OFF_T rtn; - - rtn = lseek_yod(nino->ni_fd, off, SEEK_SET); - if (rtn < 0) - return -1; - nino->ni_fpos = rtn; - } - return write_yod(nino->ni_fd, buf, nbytes); -} - -static int -yod_inop_write(struct inode *ino __IS_UNUSED, struct ioctx *ioctx) -{ - - return doio(yod_write_simple, ioctx); -} - -static _SYSIO_OFF_T -yod_inop_pos(struct inode *ino, _SYSIO_OFF_T off) -{ - struct yod_inode *nino = I2NI(ino); - int err; - - err = lseek_yod(nino->ni_fd, off, SEEK_SET); - return err < 0 ? err : off; -} - -static int -yod_inop_iodone(struct ioctx *ioctxp __IS_UNUSED) -{ - - /* - * It's always done in this driver. It completed when posted. - */ - return 1; -} - -static int -yod_inop_fcntl(struct inode *ino, int cmd, va_list ap, int *rtn) -{ - struct yod_inode *nino = I2NI(ino); - long arg; - int err; - - if (nino->ni_fd < 0) - abort(); - - err = 0; - switch (cmd) { - case F_GETFD: - case F_GETFL: -#ifdef F_GETOWN - case F_GETOWN: -#endif - *rtn = syscall(SYS_fcntl, nino->ni_fd, cmd); - if (*rtn == -1) - err = -errno; - break; - case F_DUPFD: - case F_SETFD: - case F_SETFL: - case F_GETLK: - case F_SETLK: - case F_SETLKW: -#ifdef F_SETOWN - case F_SETOWN: -#endif - arg = va_arg(ap, long); - *rtn = syscall(SYS_fcntl, nino->ni_fd, cmd, arg); - if (*rtn == -1) - err = -errno; - break; - default: - *rtn = -1; - err = -EINVAL; - } - return err; -} - -static int -yod_inop_mknod(struct pnode *pno __IS_UNUSED, - mode_t mode __IS_UNUSED, - dev_t dev __IS_UNUSED) -{ - - return -ENOSYS; -} - -#ifdef _HAVE_STATVFS -static int -yod_inop_statvfs(struct pnode *pno, - struct inode *ino, - struct intnl_statvfs *buf) -{ - char *path; - int rc; - struct statfs fs; - - path = NULL; - if (!ino || I2NI(ino)->ni_fd < 0) { - path = _sysio_pb_path(pno->p_base, '/'); - if (!path) - return -ENOMEM; - } - - /* - * The syscall interface does not support SYS_fstatvfs. - * Should possibly return ENOSYS, but thought it - * better to use SYS_fstatfs and fill in as much of - * the statvfs structure as possible. This allows - * for more of a test of the sysio user interface. - */ - rc = - path - ? statfs_yod(path, &fs) - : fstatfs_yod(I2NI(ino)->ni_fd, &fs); - if (path) - free(path); - if (rc < 0) - return -errno; - - buf->f_bsize = fs.f_bsize; /* file system block size */ - buf->f_frsize = fs.f_bsize; /* file system fundamental block size */ - buf->f_blocks = fs.f_blocks; - buf->f_bfree = fs.f_bfree; - buf->f_bavail = fs.f_bavail; - buf->f_files = fs.f_files; /* Total number serial numbers */ - buf->f_ffree = fs.f_ffree; /* Number free serial numbers */ - buf->f_favail = fs.f_ffree; /* Number free ser num for non-privileged*/ - buf->f_fsid = fs.f_fsid.__val[1]; - buf->f_flag = 0; /* No equiv in statfs; maybe use type? */ - buf->f_namemax = fs.f_namelen; - return 0; -} -#endif - -static int -yod_inop_sync(struct inode *ino) -{ - - assert(I2NI(ino)->ni_fd >= 0); - - return fsync_yod(I2NI(ino)->ni_fd); -} - -static int -yod_inop_datasync(struct inode *ino) -{ - - assert(I2NI(ino)->ni_fd >= 0); - - return fsync_yod(I2NI(ino)->ni_fd); -} - -static int -yod_inop_ioctl(struct inode *ino __IS_UNUSED, - unsigned long int request __IS_UNUSED, - va_list ap __IS_UNUSED) -{ - - /* - * I'm lazy. Maybe implemented later. - */ - errno = ENOTTY; - return -1; -} - -static void -yod_inop_gone(struct inode *ino) -{ - struct yod_inode *nino = I2NI(ino); - - if (nino->ni_fd) - (void )close(nino->ni_fd); - free(ino->i_private); -} - -static void -yod_fsop_gone(struct filesys *fs __IS_UNUSED) -{ - - /* - * Do nothing. There is no private part maintained for the - * yod file interface. - */ -} diff --git a/libsysio/drivers/yod/fs_yod.h b/libsysio/drivers/yod/fs_yod.h deleted file mode 100644 index 174b82d..0000000 --- a/libsysio/drivers/yod/fs_yod.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -/* - * Remote file system driver support. - */ - -extern int _sysio_yod_init(); diff --git a/libsysio/drivers/yod/module.mk b/libsysio/drivers/yod/module.mk deleted file mode 100644 index 1c2cc91..0000000 --- a/libsysio/drivers/yod/module.mk +++ /dev/null @@ -1,10 +0,0 @@ -if WITH_CPLANT_YOD -YOD_SRCS = drivers/yod/fs_yod.c -YOD_DRIVER_FLAGS = -DCPLANT_YOD -else -YOD_SRCS = -YOD_DRIVER_FLAGS = -endif - -# Bring yod files along in the distribution regardless -YOD_EXTRA = include/cplant-yod.h drivers/yod/fs_yod.h drivers/yod/module.mk diff --git a/libsysio/include/cplant-yod.h b/libsysio/include/cplant-yod.h deleted file mode 100644 index 8aa4b50..0000000 --- a/libsysio/include/cplant-yod.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -/* - * cplant yod I/O functions - */ -extern int chmod_yod(const char* path, mode_t); -extern int chown_yod(const char* path, uid_t, gid_t); -extern int stat_yod(const char *path, struct stat *sbuf); -extern int fstat_yod(int fd, struct stat *buf); -#ifdef _HAVE_STATVFS -extern int statfs_yod(const char *path, struct statfs *sbuf); -extern int fstatfs_yod(int fd, struct statfs *buf); -#endif -extern int mkdir_yod(const char *path, mode_t mode); -extern int rmdir_yod(const char *path); -extern int getdirentries_yod(int fd, char *buf, size_t nbytes, loff_t *basep); -extern int link_yod(const char *path1, const char *path2); -extern int unlink_yod(const char *path); -extern int symlink_yod(const char *path1, const char *path2 ); -extern int rename_yod( const char *path1, const char *path2 ); -extern int open_yod(const char *fname, int flags, mode_t mode); -extern int close_yod(int); -extern ssize_t write_yod(int fd, const void *buff, size_t nbytes); -extern ssize_t read_yod(int fd, void *buff, size_t nbytes); -extern int fsync_yod(int fd); -extern int truncate_yod(const char *path, off_t length); -extern int ftruncate_yod(int fd, long length); -extern off_t lseek_yod(int fd, off_t offset, int whence); diff --git a/libsysio/include/creds.h b/libsysio/include/creds.h deleted file mode 100644 index 672dfcf..0000000 --- a/libsysio/include/creds.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include - -#ifndef _CREDS_H_ -#define _CREDS_H_ - -/* - * Superuser's UID. - */ -#define _SYSIO_ROOT_UID 0 - -/* - * Data structure for user credentials - */ - -struct creds { - uid_t creds_uid; - gid_t *creds_gids; - int creds_ngids; -}; - - -#ifdef _SYSIO_ROOT_UID -/* - * Is caller the superuser? - */ -#define _sysio_is_root(_crp) \ - ((_crp)->creds_uid == _SYSIO_ROOT_UID) -#endif -#endif diff --git a/libsysio/include/dev.h b/libsysio/include/dev.h deleted file mode 100644 index 2620d49..0000000 --- a/libsysio/include/dev.h +++ /dev/null @@ -1,153 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -/* - * Device support. - */ - -/* - * Make a device number, composed of major and minor parts. We *assume* that - * the system version of a dev_t is 16 bits or more. - */ -#define SYSIO_MKDEV(major, minor) \ - ((((major) & 0xff) << 8) | ((minor) & 0xff)) - -/* - * Return major unit given dev number. - */ -#define SYSIO_MAJOR_DEV(dev) \ - (((dev) >> 8) & 0xff) - -/* - * Return minor unit given dev number. - */ -#define SYSIO_MINOR_DEV(dev) \ - ((dev) & 0xff) - -extern const struct inode_ops _sysio_nodev_ops; - -#define _sysio_nodev_inop_lookup \ - (int (*)(struct pnode *, \ - struct inode **, \ - struct intent *, \ - const char *))_sysio_do_illop -#define _sysio_nodev_inop_getattr \ - (int (*)(struct pnode *, \ - struct inode *, \ - struct intnl_stat *))_sysio_do_ebadf -#define _sysio_nodev_inop_setattr \ - (int (*)(struct pnode *, \ - struct inode *, \ - unsigned , \ - struct intnl_stat *))_sysio_do_ebadf -#define _sysio_nodev_filldirentries \ - (ssize_t (*)(struct inode *, \ - _SYSIO_OFF_T *, \ - char *, \ - size_t))_sysio_do_illop -#define _sysio_nodev_inop_mkdir \ - (int (*)(struct pnode *, \ - mode_t))_sysio_do_illop -#define _sysio_nodev_inop_rmdir \ - (int (*)(struct pnode *))_sysio_do_illop -#define _sysio_nodev_inop_symlink \ - (int (*)(struct pnode *, \ - const char *))_sysio_do_illop -#define _sysio_nodev_inop_readlink \ - (int (*)(struct pnode *, \ - char *, \ - size_t))_sysio_do_illop -#define _sysio_nodev_inop_open \ - (int (*)(struct pnode *, \ - int, \ - mode_t))_sysio_do_enodev -#define _sysio_nodev_inop_close \ - (int (*)(struct inode *))_sysio_do_ebadf -#define _sysio_nodev_inop_link \ - (int (*)(struct pnode *, struct pnode *))_sysio_do_illop -#define _sysio_nodev_inop_unlink \ - (int (*)(struct pnode *))_sysio_do_illop -#define _sysio_nodev_inop_rename \ - (int (*)(struct pnode *, struct pnode *))_sysio_do_illop -#define _sysio_nodev_inop_read \ - (int (*)(struct inode *, \ - struct ioctx *))_sysio_do_ebadf -#define _sysio_nodev_inop_write \ - (int (*)(struct inode *, \ - struct ioctx *))_sysio_do_ebadf -#define _sysio_nodev_inop_pos \ - (_SYSIO_OFF_T (*)(struct inode *, _SYSIO_OFF_T))_sysio_do_ebadf -#define _sysio_nodev_inop_iodone \ - (int (*)(struct ioctx *))_sysio_do_einval -#define _sysio_nodev_inop_fcntl \ - (int (*)(struct inode *, \ - int, \ - va_list, \ - int *))_sysio_do_ebadf -#define _sysio_nodev_inop_sync \ - (int (*)(struct inode *))_sysio_do_ebadf -#define _sysio_nodev_inop_datasync \ - (int (*)(struct inode *))_sysio_do_ebadf -#define _sysio_nodev_inop_ioctl \ - (int (*)(struct inode *, \ - unsigned long int, \ - va_list))_sysio_do_ebadf -#define _sysio_nodev_inop_mknod \ - (int (*)(struct pnode *, \ - mode_t, \ - dev_t))_sysio_do_illop -#ifdef _HAVE_STATVFS -#define _sysio_nodev_inop_statvfs \ - (int (*)(struct pnode *, \ - struct inode *, \ - struct intnl_statvfs *))_sysio_do_illop -#endif -#define _sysio_nodev_inop_gone \ - (void (*)(struct inode *ino))_sysio_do_noop - -extern int _sysio_dev_init(void); -extern dev_t _sysio_dev_alloc(void); -extern struct inode_ops *_sysio_dev_lookup(mode_t mode, dev_t dev); -extern int _sysio_char_dev_register(int major, - const char *name, - struct inode_ops *ops); diff --git a/libsysio/include/file.h b/libsysio/include/file.h deleted file mode 100644 index d30e84e..0000000 --- a/libsysio/include/file.h +++ /dev/null @@ -1,146 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2006 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -/* - * Open file support. - */ - -/* - * Test whether large file support on this file. - */ -#ifdef O_LARGEFILE -#define _F_LARGEFILE(fil) \ - ((fil)->f_flags & O_LARGEFILE) -#else -#define _F_LARGEFILE(fil) \ - (1) -#endif -/* - * Return max seek value for this file. - */ -#define _SEEK_MAX(fil) \ - (_F_LARGEFILE(fil) ? _SYSIO_OFF_T_MAX : LONG_MAX) - -#ifdef _LARGEFILE64_SOURCE -#define _SYSIO_FLOCK flock64 -#else -#define _SYSIO_FLOCK flock -#endif - -/* - * A file record is maintained for each open file in the system. It holds - * all the info necessary to track the context and parameters for the - * operations that may be performed. - */ -struct file { - struct inode *f_ino; /* path node */ - _SYSIO_OFF_T f_pos; /* current stream pos */ - unsigned f_ref; /* ref count */ - int f_flags; /* open/fcntl flags */ -}; - -/* - * Reference a file record. - */ -#define F_REF(fil) \ - do { \ - (fil)->f_ref++; \ - assert((fil)->f_ref); \ - } while (0) - -/* - * Release reference to a file record. - */ -#define F_RELE(fil) \ - do { \ - assert((fil)->f_ref); \ - (fil)->f_ref--; \ - if (!(fil)->f_ref) \ - _sysio_fgone(fil); \ - } while (0) - -/* - * Init file record. - * - * NB: Don't forget to take a reference to the inode too! - */ -#define _SYSIO_FINIT(fil, ino, flags) \ - do { \ - (fil)->f_ino = (ino); \ - (fil)->f_pos = 0; \ - (fil)->f_ref = 0; \ - (fil)->f_flags = (flags); \ - } while (0) - -/* - * Determine if a file may be read/written. - * - * Given a ptr to an open file table entry and a flag indicating desired - * access return non-zero if the file record indicates that the access is - * permitted or zero, if not. - * - * 'r' for read access check - * 'w' for write access check - */ - -#define F_CHKRW(_fil, _c) \ - (((_c) == 'r' && !((_fil)->f_flags & O_WRONLY)) || \ - ((_c) == 'w' && ((_fil)->f_flags & (O_WRONLY | O_RDWR)))) - -struct ioctx; - -extern struct file *_sysio_fnew(struct inode *ino, int flags); -extern void _sysio_fgone(struct file *fil); -extern void _sysio_fcompletio(struct ioctx *ioctx, struct file *fil); -extern int _sysio_fd_close(int fd); -extern struct file *_sysio_fd_find(int fd); -extern int _sysio_fd_set(struct file *fil, int fd, int force); -extern int _sysio_fd_dup(int oldfd, int newfd, int force); -extern int _sysio_fd_close_all(void); -#ifdef ZERO_SUM_MEMORY -extern void _sysio_fd_shutdown(void); -#endif -extern _SYSIO_OFF_T _sysio_lseek_prepare(struct file *fil, - _SYSIO_OFF_T offset, - int whence, - _SYSIO_OFF_T max); diff --git a/libsysio/include/fs.h b/libsysio/include/fs.h deleted file mode 100644 index e324006..0000000 --- a/libsysio/include/fs.h +++ /dev/null @@ -1,179 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -/* - * File system or volume support. - */ -#ifndef SYSIO_FS_H_ -#define SYSIO_FS_H_ - -#include - -struct filesys; - -struct pnode; -struct mount; - -/* - * File system switch operations. - */ -struct fssw_ops { - int (*fsswop_mount)(const char *source, - unsigned flags, - const void *data, - struct pnode *tocover, - struct mount **mntp); -}; - -/* - * File system switch entry record. - * - * Each available file system or volume access driver is represented by - * one of these switch entries in the switch. - */ -struct fsswent { - const char *fssw_name; /* entry name */ - LIST_ENTRY(fsswent) fssw_link; /* link to next */ - struct fssw_ops fssw_ops; /* operations */ -}; - -/* - * Init file system switch entry record. - */ -#define FSSWENT_INIT(fsswent, name, ops) \ - do { \ - (fsswent)->fssw_name = (name); \ - (fsswent)->fssw_ops = (ops); \ - } while (0) - -struct inode; - -/* - * File system operations. - */ -struct filesys_ops { - void (*fsop_gone)(struct filesys *); -}; - -/* - * Define the desired size of the file system record's inode table. This should - * probably be something fancy that tries to use up a system page, or the - * like. I'm not feeling adventurous right now though. It is prime though. - * That should help out the hash. - */ -#ifndef FS_ITBLSIZ -#define FS_ITBLSIZ 503 -#endif - -/* - * Inode list head record. - */ -LIST_HEAD(itable_entry, inode); - -/* - * A filesys record is maintained for each active file system or volume. - */ -struct filesys { - dev_t fs_dev; /* device ID */ - unsigned fs_ref; /* soft ref count */ - unsigned fs_flags; /* flags (see below) */ - struct filesys_ops fs_ops; /* operations */ - void *fs_private; /* driver data */ - struct itable_entry fs_itbl[FS_ITBLSIZ]; /* inodes hash */ - unsigned long fs_id; /* ID */ - size_t fs_bsize; /* block size */ -}; - -#define FS_F_RO 0x01 /* read-only */ - -/* - * Init file system record. - */ -#define FS_INIT(fs, flags, ops, private) \ - do { \ - size_t __i; \ - struct itable_entry *__head; \ - \ - (fs)->fs_ref = 1; \ - (fs)->fs_flags = (flags); \ - (fs)->fs_ops = *(ops); \ - (fs)->fs_private = (private); \ - __i = FS_ITBLSIZ; \ - __head = (fs)->fs_itbl; \ - do { \ - LIST_INIT(__head); \ - __head++; \ - } while (--__i); \ - } while (0) - -/* - * Reference file system record. - */ -#define FS_REF(fs) \ - do { \ - ++(fs)->fs_ref; \ - assert((fs)->fs_ref); \ - } while (0) - -/* - * Release reference to file system record. - */ -#define FS_RELE(fs) \ - do { \ - assert((fs)->fs_ref); \ - if (!--(fs)->fs_ref) \ - _sysio_fs_gone(fs); \ - } while (0) - -extern struct fsswent *_sysio_fssw_lookup(const char *name); -extern int _sysio_fssw_register(const char *name, struct fssw_ops *ops); -extern char *incore_dir_template; -extern struct filesys * _sysio_fs_new(struct filesys_ops *ops, - unsigned mask, - void *private); -extern void _sysio_fs_gone(struct filesys *fs); -#ifdef ZERO_SUM_MEMORY -extern void _sysio_fssw_shutdown(void); -#endif - -#endif /* SYSIO_FS_H_ */ diff --git a/libsysio/include/inode.h b/libsysio/include/inode.h deleted file mode 100644 index baedc50..0000000 --- a/libsysio/include/inode.h +++ /dev/null @@ -1,486 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2006 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#if defined(AUTOMOUNT_FILE_NAME) && !defined(MAX_MOUNT_DEPTH) -/* - * Maximum number of automounts to attempt in path traversal. - */ -#define MAX_MOUNT_DEPTH 64 -#endif - -/* - * Each i-node is uniquely identified by a file identifier, supplied by - * the relevant file system driver. The i-node number returned in the getattrs - * call is not always enough. - */ -struct file_identifier { - void *fid_data; - size_t fid_len; -}; - -struct pnode; -struct inode; -struct intent; -struct intnl_dirent; -struct intnl_stat; -#ifdef _HAVE_STATVFS -struct intnl_statvfs; -#endif -struct io_arguments; -struct ioctx; - -/* - * Operations on i-nodes. - * - * Should this be split up into file and name space operations? - */ -struct inode_ops { - int (*inop_lookup)(struct pnode *pno, - struct inode **inop, - struct intent *intnt, - const char *path); - int (*inop_getattr)(struct pnode *pno, - struct inode *ino, - struct intnl_stat *stbuf); - int (*inop_setattr)(struct pnode *pno, - struct inode *ino, - unsigned mask, - struct intnl_stat *stbuf); - ssize_t (*inop_filldirentries)(struct inode *ino, - _SYSIO_OFF_T *posp, - char *buf, - size_t nbytes); - int (*inop_mkdir)(struct pnode *pno, mode_t mode); - int (*inop_rmdir)(struct pnode *pno); - int (*inop_symlink)(struct pnode *pno, const char *data); - int (*inop_readlink)(struct pnode *pno, char *buf, size_t bufsiz); - int (*inop_open)(struct pnode *pno, int flags, mode_t mode); - int (*inop_close)(struct inode *ino); - int (*inop_link)(struct pnode *old, struct pnode *new); - int (*inop_unlink)(struct pnode *pno); - int (*inop_rename)(struct pnode *old, struct pnode *new); - int (*inop_read)(struct inode *ino, struct ioctx *ioctx); - int (*inop_write)(struct inode *ino, struct ioctx *ioctx); - _SYSIO_OFF_T (*inop_pos)(struct inode *ino, _SYSIO_OFF_T off); - int (*inop_iodone)(struct ioctx *iocp); - int (*inop_fcntl)(struct inode *ino, int cmd, va_list ap, int *rtn); - int (*inop_sync)(struct inode *ino); - int (*inop_datasync)(struct inode *ino); - int (*inop_ioctl)(struct inode *ino, unsigned long int request, va_list ap); - int (*inop_mknod)(struct pnode *pno, mode_t mode, dev_t dev); -#ifdef _HAVE_STATVFS - int (*inop_statvfs)(struct pnode *pno, - struct inode *ino, - struct intnl_statvfs *buf); -#endif - void (*inop_gone)(struct inode *ino); -}; - -/* - * Values for the mask to inop_setattr. - */ -#define SETATTR_MODE 0x01 -#define SETATTR_MTIME 0x02 -#define SETATTR_ATIME 0x04 -#define SETATTR_UID 0x08 -#define SETATTR_GID 0x10 -#define SETATTR_LEN 0x20 - -/* - * An i-node record is maintained for each file object in the system. - */ -struct inode { - LIST_ENTRY(inode) i_link; /* FS i-nodes link */ - unsigned - i_immune : 1, /* immune from GC */ - i_zombie : 1; /* stale inode */ - unsigned i_ref; /* soft ref counter */ - struct inode_ops i_ops; /* operations */ - struct intnl_stat i_stbuf; /* attrs */ - struct filesys *i_fs; /* file system ptr */ - struct file_identifier *i_fid; /* file ident */ - void *i_private; /* driver data */ - TAILQ_ENTRY(inode) i_nodes; /* all i-nodes link */ -}; - -/* - * Init an i-node record. - */ -#define I_INIT(ino, fs, stat, ops, fid, immunity, private) \ - do { \ - (ino)->i_immune = (immunity) ? 1 : 0; \ - (ino)->i_zombie = 0; \ - (ino)->i_ref = 0; \ - (ino)->i_ops = *(ops); \ - (ino)->i_stbuf = *(stat); \ - (ino)->i_fs = (fs); \ - (ino)->i_fid = (fid); \ - (ino)->i_private = (private); \ - } while (0) - -/* - * Take soft reference to i-node. - */ -#define I_REF(ino) \ - do { \ - TAILQ_REMOVE(&_sysio_inodes, (ino), i_nodes); \ - TAILQ_INSERT_TAIL(&_sysio_inodes, (ino), i_nodes); \ - (ino)->i_ref++; \ - assert((ino)->i_ref); \ - } while (0) - -/* - * Release soft reference to i-node. - */ -#define I_RELE(ino) \ - do { \ - assert((ino)->i_ref); \ - if (!--(ino)->i_ref && (ino)->i_zombie) \ - _sysio_i_gone(ino); \ - } while (0) - -/* - * Attempt to kill an inode. - */ -#define I_GONE(ino) \ - do { \ - _sysio_i_undead(ino); \ - I_RELE(ino); \ - } while (0) - -/* - * The "quick string" record (inspired by the structure of the same name - * from Linux) is used to pass a string without delimiters as well as useful - * information about the string. - */ -struct qstr { - const char *name; - size_t len; - unsigned hashval; -}; - -/* - * A path node is an entry in a directory. It may have many aliases, one - * for each name space in which it occurs. This record holds the - * common information. - */ -struct pnode_base { - struct qstr pb_name; /* entry name */ - struct inode *pb_ino; /* inode */ - LIST_HEAD(, pnode_base) pb_children; /* children if a dir */ - LIST_ENTRY(pnode_base) pb_sibs; /* links to siblings */ - LIST_ENTRY(pnode_base) pb_names; /* near names links */ - LIST_HEAD(, pnode) pb_aliases; /* aliases */ - struct pnode_base *pb_parent; /* parent */ -}; - -/* - * Since a file system may be multiply mounted, in different parts of the local - * tree, a file system object may appear in different places. We handle that - * with aliases. There is one pnode for every alias the system is tracking. - * - * Name space traversal depends heavily on the interpretation of many - * of the fields in this structure. For that reason a detailed discussion - * of the various fields is given. - * - * The reference field records soft references to the record. For instance, - * it tracks file and directory opens. It does not track sibling references, - * though, as those are hard references and can be found by examining the - * aliases list in the base part of the node. - * - * The parent value points to the parent directory for this entry, in the - * *system* name space -- Not the mounted volumes. If you want to examine - * the moutned volume name space, use the base record. - * - * The base value points to the base path node information. It is info common - * to all of the aliases. - * - * The mount value points to the mount record for the rooted name space in - * which the alias is found. Notably, if a node is the root of a sub-tree then - * the mount record, among other things, indicates another node - * (in another sub-tree) that is covered by this one. - * - * Another sub-tree, mounted on this node, is indicated by a non-null cover. - * The pnode pointed to, then, is the root of the mounted sub-tree. - * - * The links list entry holds pointers to other aliases for the base path - * node entry. - * - * The nodes link is bookkeeping. - */ -struct pnode { - unsigned p_ref; /* soft ref count */ - struct pnode *p_parent; /* parent */ - struct pnode_base *p_base; /* base part */ - struct mount *p_mount; /* mount info */ - struct pnode *p_cover; /* covering pnode */ - LIST_ENTRY(pnode) p_links; /* other aliases */ - TAILQ_ENTRY(pnode) p_nodes; /* all nodes links */ -}; - -/* - * Reference path-tree node. - */ -#define P_REF(pno) \ - do { \ - TAILQ_REMOVE(&_sysio_pnodes, (pno), p_nodes); \ - TAILQ_INSERT_TAIL(&_sysio_pnodes, (pno), p_nodes); \ - (pno)->p_ref++; \ - assert((pno)->p_ref); \ - } while (0) - -/* - * Release reference to path-tree node. - */ -#define P_RELE(pno) \ - do { \ - assert((pno)->p_ref); \ - --(pno)->p_ref; \ - } while (0) - -/* - * An intent record allows callers of namei and lookup to pass some information - * about what they want to accomplish in the end. - */ -struct intent { - unsigned int_opmask; - void *int_arg1; - void *int_arg2; -}; - -/* - * Intent operations. - */ -#define INT_GETATTR 0x01 /* get attrs */ -#define INT_SETATTR 0x02 /* set attrs */ -#define INT_UPDPARENT 0x04 /* insert/delete */ -#define INT_OPEN 0x08 /* open */ -#define INT_CREAT (INT_UPDPARENT|0x10) /* insert */ -#define INT_READLINK 0x12 /* readlink */ - -#define INTENT_INIT(intnt, mask, arg1, arg2) \ - do { \ - (intnt)->int_opmask = (mask); \ - (intnt)->int_arg1 = (arg1); \ - (intnt)->int_arg2 = (arg2); \ - } while (0) - -/* - * Bundled up arguments to _sysio_path_walk. - */ -struct nameidata { - unsigned nd_flags; /* flags (see below) */ - const char *nd_path; /* path arg */ - struct pnode *nd_pno; /* returned pnode */ - struct pnode *nd_root; /* system/user root */ - struct intent *nd_intent; /* intent (NULL ok) */ - unsigned nd_slicnt; /* symlink indirects */ -#ifdef AUTOMOUNT_FILE_NAME - unsigned nd_amcnt; /* automounts */ -#endif -}; - -/* - * Values for nameidata flags field. - */ -#define ND_NOFOLLOW 0x01 /* no follow symlinks */ -#define ND_NEGOK 0x02 /* last missing is ok */ -#define ND_NOPERMCHECK 0x04 /* don't check perms */ - -#ifdef AUTOMOUNT_FILE_NAME -#define _ND_INIT_AUTOMOUNT(nd) ((nd)->nd_amcnt = 0) -#else -#define _ND_INIT_AUTOMOUNT(nd) -#endif - -#define _ND_INIT_OTHERS(nd) \ - _ND_INIT_AUTOMOUNT(nd) - -/* - * Init nameidata record. - */ -#define ND_INIT(nd, flags, path, root, intnt) \ - do { \ - (nd)->nd_flags = (flags); \ - (nd)->nd_path = (path); \ - (nd)->nd_pno = NULL; \ - (nd)->nd_root = (root); \ - (nd)->nd_intent = (intnt); \ - (nd)->nd_slicnt = 0; \ - _ND_INIT_OTHERS(nd); \ - } while (0) - -/* - * IO completion callback record. - */ -struct ioctx_callback { - TAILQ_ENTRY(ioctx_callback) iocb_next; /* list link */ - void (*iocb_f)(struct ioctx *, void *); /* cb func */ - void *iocb_data; /* cb data */ -}; - -/* - * All IO internally is done with an asynchronous mechanism. This record - * holds the completion information. It's too big :-( - */ -struct ioctx { - LIST_ENTRY(ioctx) ioctx_link; /* AIO list link */ - unsigned - ioctx_fast : 1, /* from stack space */ - ioctx_done : 1, /* transfer complete */ - ioctx_write : 1; /* op is a write */ - struct inode *ioctx_ino; /* i-node */ - const struct iovec *ioctx_iov; /* scatter/gather vec */ - size_t ioctx_iovlen; /* iovec length */ - const struct intnl_xtvec *ioctx_xtv; /* extents */ - size_t ioctx_xtvlen; /* xtv length */ - ssize_t ioctx_cc; /* rtn char count */ - int ioctx_errno; /* error number */ - TAILQ_HEAD(, ioctx_callback) ioctx_cbq; /* callback queue */ - void *ioctx_private; /* driver data */ -}; - -/* - * Init IO context record. - */ -#define IOCTX_INIT(ioctx, fast, wr, ino, iov, iovlen, xtv, xtvlen) \ - do { \ - (ioctx)->ioctx_fast = (fast); \ - (ioctx)->ioctx_done = 0; \ - (ioctx)->ioctx_write = (wr) ? 1 : 0; \ - (ioctx)->ioctx_ino = (ino); \ - (ioctx)->ioctx_iov = (iov); \ - (ioctx)->ioctx_iovlen = (iovlen); \ - (ioctx)->ioctx_xtv = (xtv); \ - (ioctx)->ioctx_xtvlen = (xtvlen); \ - (ioctx)->ioctx_cc = 0; \ - (ioctx)->ioctx_errno = 0; \ - TAILQ_INIT(&(ioctx)->ioctx_cbq); \ - (ioctx)->ioctx_private = NULL; \ - } while (0) - -/* - * Return whether access to a pnode is read-only. - */ -#define IS_RDONLY(pno) \ - ((pno)->p_mount->mnt_flags & MOUNT_F_RO) - -extern struct pnode *_sysio_root; - -extern TAILQ_HEAD(inodes_head, inode) _sysio_inodes; -extern TAILQ_HEAD(pnodes_head, pnode) _sysio_pnodes; - -extern int _sysio_i_init(void); -#ifdef ZERO_SUM_MEMORY -extern void _sysio_i_shutdown(void); -#endif -extern struct inode *_sysio_i_new(struct filesys *fs, - struct file_identifier *fid, - struct intnl_stat *stat, - unsigned immunity, - struct inode_ops *ops, - void *private); -extern struct inode *_sysio_i_find(struct filesys *fs, - struct file_identifier *fid); -extern void _sysio_i_gone(struct inode *ino); -extern void _sysio_i_undead(struct inode *ino); -extern int _sysio_p_find_alias(struct pnode *parent, - struct qstr *name, - struct pnode **pnop); -extern int _sysio_p_validate(struct pnode *pno, - struct intent *intnt, - const char *path); -extern struct pnode_base *_sysio_pb_new(struct qstr *name, - struct pnode_base *parent, - struct inode *ino); -extern void _sysio_pb_gone(struct pnode_base *pb); -extern struct pnode *_sysio_p_new_alias(struct pnode *parent, - struct pnode_base *pb, - struct mount *mnt); -extern void _sysio_p_gone(struct pnode *pno); -extern size_t _sysio_p_prune(struct pnode *root); -extern int _sysio_p_kill_all(struct pnode *root); -extern char *_sysio_pb_path(struct pnode_base *pb, char separator); -extern int _sysio_setattr(struct pnode *pno, - struct inode *ino, - unsigned mask, - struct intnl_stat *stbuf); -extern void _sysio_do_noop(void); -extern void _sysio_do_illop(void); -extern int _sysio_do_ebadf(void); -extern int _sysio_do_einval(void); -extern int _sysio_do_enoent(void); -extern int _sysio_do_enodev(void); -extern int _sysio_do_espipe(void); -extern int _sysio_do_eisdir(void); -extern int _sysio_do_enosys(void); -extern int _sysio_path_walk(struct pnode *parent, struct nameidata *nd); -#ifdef AUTOMOUNT_FILE_NAME -extern void _sysio_next_component(const char *path, struct qstr *name); -#endif -extern int _sysio_permitted(struct pnode *pno, int amode); -extern int _sysio_namei(struct pnode *pno, - const char *path, - unsigned flags, - struct intent *intnt, - struct pnode **pnop); -extern int _sysio_p_chdir(struct pnode *pno); -extern int _sysio_ioctx_init(void); -extern void _sysio_ioctx_enter(struct ioctx *ioctx); -extern struct ioctx *_sysio_ioctx_new(struct inode *ino, - int wr, - const struct iovec *iov, - size_t iovlen, - const struct intnl_xtvec *xtv, - size_t xtvlen); -extern int _sysio_ioctx_cb(struct ioctx *ioctx, - void (*f)(struct ioctx *, void *), - void *data); -extern void _sysio_ioctx_cb_free(struct ioctx_callback *cb); -extern struct ioctx *_sysio_ioctx_find(void *id); -extern int _sysio_ioctx_done(struct ioctx *ioctx); -extern ssize_t _sysio_ioctx_wait(struct ioctx *ioctx); -extern void _sysio_ioctx_complete(struct ioctx *ioctx); -extern int _sysio_open(struct pnode *pno, int flags, mode_t mode); -extern int _sysio_mkdir(struct pnode *where, mode_t mode); -extern int _sysio_mknod(struct pnode *where, mode_t mode, dev_t dev); diff --git a/libsysio/include/module.mk b/libsysio/include/module.mk deleted file mode 100644 index dc6bfd4..0000000 --- a/libsysio/include/module.mk +++ /dev/null @@ -1,5 +0,0 @@ -INCLUDE_EXTRA = include/dev.h include/file.h include/fs.h \ - include/inode.h include/mount.h include/sysio.h include/sysio-cmn.h \ - include/sysio-symbols.h include/cplant-yod.h \ - include/module.mk include/xtio.h include/stddir.h \ - include/native.h include/creds.h diff --git a/libsysio/include/mount.h b/libsysio/include/mount.h deleted file mode 100644 index 24f631d..0000000 --- a/libsysio/include/mount.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -/* - * Mount support. - */ - -struct filesys; -struct pnode; - -/* - * Each file system may be mounted multiple times and in various places - * in the name space. The mount record maintains the binding information - * between the system name space and the file system's. - */ -struct mount { - struct filesys *mnt_fs; /* file system */ - unsigned mnt_flags; /* flags (see below) */ - struct pnode *mnt_root; /* fs sub-tree root */ - struct pnode *mnt_covers; /* covered pnode */ - LIST_ENTRY(mount) mnt_link; /* link to next */ -}; - -/* - * Mount flags definitions. - */ -#define MOUNT_F_RO 0x01 /* read-only */ -#ifdef AUTOMOUNT_FILE_NAME -#define MOUNT_F_AUTO 0x02 /* automount enabled */ -#endif - -#ifdef AUTOMOUNT_FILE_NAME -extern struct qstr _sysio_mount_file_name; -#endif - -struct pnode_base; - -extern int _sysio_mount_init(void); -extern int _sysio_do_mount(struct filesys *fs, - struct pnode_base *rootpb, - unsigned flags, - struct pnode *tocover, - struct mount **mntp); -extern int _sysio_do_unmount(struct mount *fs); -extern int _sysio_mount_root(const char *source, - const char *type, - unsigned flags, - const void *data); -extern int _sysio_mount(struct pnode *cwd, - const char *source, - const char *target, - const char *filesystemtype, - unsigned long mountflags, - const void *data); -extern int _sysio_unmount_all(void); -#ifdef AUTOMOUNT_FILE_NAME -extern int _sysio_automount(struct pnode *mntpno); -#endif diff --git a/libsysio/include/native.h b/libsysio/include/native.h deleted file mode 100644 index 0aeab3c..0000000 --- a/libsysio/include/native.h +++ /dev/null @@ -1,255 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2004 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -/* - * Native file system support. - */ - -#if ALPHA_LINUX - -/* - * stat struct from asm/stat.h, as returned - * by alpha linux kernel - */ -struct _sysio_native_stat { - unsigned int st_dev; - unsigned int st_ino; - unsigned int st_mode; - unsigned int st_nlink; - unsigned int st_uid; - unsigned int st_gid; - unsigned int st_rdev; - long st_size; - unsigned long st_atime; - unsigned long st_mtime; - unsigned long st_ctime; - unsigned int st_blksize; - int st_blocks; - unsigned int st_flags; - unsigned int st_gen; -}; - -#define SYSIO_COPY_STAT(src, dest) \ -do { \ - memset((dest), 0, sizeof((*dest))); \ - (dest)->st_dev = (src)->st_dev; \ - (dest)->st_ino = (src)->st_ino; \ - (dest)->st_mode = (src)->st_mode; \ - (dest)->st_nlink = (src)->st_nlink; \ - (dest)->st_uid = (src)->st_uid; \ - (dest)->st_gid = (src)->st_gid; \ - (dest)->st_rdev = (src)->st_rdev; \ - (dest)->st_size = (src)->st_size; \ - (dest)->st_atime = (src)->st_atime; \ - (dest)->st_mtime = (src)->st_mtime; \ - (dest)->st_ctime = (src)->st_ctime; \ - (dest)->st_blksize = (src)->st_blksize; \ - (dest)->st_blocks = (src)->st_blocks; \ - (dest)->st_flags = (src)->st_flags; \ - (dest)->st_gen = (src)->st_gen; \ -} while (0) - -#else -#define _sysio_native_stat intnl_stat -#define SYSIO_COPY_STAT(src, dest) *(dest) = *(src) -#endif - -/* - * System calls. - */ -#if defined(_LARGEFILE64_SOURCE) && defined(SYS_lstat64) -#define SYSIO_SYS_stat SYS_lstat64 -#elif defined(SYS_lstat) -#define SYSIO_SYS_stat SYS_lstat -#endif -#if defined(_LARGEFILE64_SOURCE) && defined(SYS_fstat64) -#define SYSIO_SYS_fstat SYS_fstat64 -#elif defined(SYS_fstat) -#define SYSIO_SYS_fstat SYS_fstat -#endif -#if defined(_LARGEFILE64_SOURCE) && defined(SYS_truncate64) -#define SYSIO_SYS_truncate SYS_truncate64 -#elif defined(SYS_truncate) -#define SYSIO_SYS_truncate SYS_truncate -#endif -#if defined(_LARGEFILE64_SOURCE) && defined(SYS_ftruncate64) -#define SYSIO_SYS_ftruncate SYS_ftruncate64 -#elif defined(SYS_ftruncate) -#define SYSIO_SYS_ftruncate SYS_ftruncate -#endif -#if defined(SYS_open) -#define SYSIO_SYS_open SYS_open -#endif -#if defined(SYS_close) -#define SYSIO_SYS_close SYS_close -#endif -#if defined(_LARGEFILE64_SOURCE) && defined(SYS_lseek64) -#define SYSIO_SYS_lseek SYS_lseek64 -#elif defined(SYS_lseek) -#define SYSIO_SYS_lseek SYS_lseek -#endif -#if defined(SYS__llseek) -# if defined (__mips64__) -# define SYSIO_SYS__llseek SYS_O32__llseek -# else -# define SYSIO_SYS__llseek SYS__llseek -# endif -#endif -#if defined(SYS_read) -#define SYSIO_SYS_read SYS_read -#endif -#if defined(SYS_write) -#define SYSIO_SYS_write SYS_write -#endif -#if defined(SYS_readv) -#define SYSIO_SYS_readv SYS_readv -#endif -#if defined(SYS_writev) -#define SYSIO_SYS_writev SYS_writev -#endif -#if defined(_LARGEFILE64_SOURCE) && defined(SYS_pread64) -#define SYSIO_SYS_pread SYS_pread64 -#elif defined(SYS_pread) -#define SYSIO_SYS_pread SYS_pread -#endif -#if defined(_LARGEFILE64_SOURCE) && defined(SYS_pwrite64) -#define SYSIO_SYS_pwrite SYS_pwrite64 -#elif defined(SYS_pwrite) -#define SYSIO_SYS_pwrite SYS_pwrite -#endif -#if defined(_LARGEFILE64_SOURCE) && defined(SYS_fcntl64) -#define SYSIO_SYS_fcntl SYS_fcntl64 -#elif defined(SYS_fcntl) -#define SYSIO_SYS_fcntl SYS_fcntl -#endif -#if defined(SYS_fsync) -#define SYSIO_SYS_fsync SYS_fsync -#endif -#if defined(ALPHA_LINUX) && defined(SYS_osf_fdatasync) -#define SYSIO_SYS_fdatasync SYS_osf_fdatasync -#elif defined(SYS_fdatasync) -#define SYSIO_SYS_fdatasync SYS_fdatasync -#endif -#if defined(SYS_chmod) -#define SYSIO_SYS_chmod SYS_chmod -#endif -#if defined(SYS_fchmod) -#define SYSIO_SYS_fchmod SYS_fchmod -#endif -#if defined(SYS_chown) -#define SYSIO_SYS_chown SYS_chown -#endif -#if defined(SYS_fchown) -#define SYSIO_SYS_fchown SYS_fchown -#endif -#if defined(SYS_umask) -#define SYSIO_SYS_umask SYS_umask -#endif -#if defined(SYS_mkdir) -#define SYSIO_SYS_mkdir SYS_mkdir -#endif -#if defined(SYS_rmdir) -#define SYSIO_SYS_rmdir SYS_rmdir -#endif -#if defined(SYS_getdirentries) -#if defined(_LARGEFILE64_SOURCE) && defined(SYS_getdirentries64) -#define SYSIO_SYS_getdirentries SYS_getdirentries64 -#elif defined(SYS_getdirentries) -#define SYSIO_SYS_getdirentries SYS_getdirentries -#endif -#endif -#if defined(_LARGEFILE64_SOURCE) && defined(SYS_getdents64) -# define SYSIO_SYS_getdents64 SYS_getdents64 -#elif defined(SYS_getdents) -# if defined (__mips64__) -# define SYSIO_SYS_getdents64 SYS_getdents -# else -# define SYSIO_SYS_getdents SYS_getdents -# endif -#endif -#if defined(SYS_link) -#define SYSIO_SYS_link SYS_link -#endif -#if defined(SYS_unlink) -#define SYSIO_SYS_unlink SYS_unlink -#endif -#if defined(SYS_symlink) -#define SYSIO_SYS_symlink SYS_symlink -#endif -#if defined(SYS_rename) -#define SYSIO_SYS_rename SYS_rename -#endif -#if defined(SYS_readlink) -#define SYSIO_SYS_readlink SYS_readlink -#endif -#if defined(SYS_utimes) -#define SYSIO_SYS_utimes SYS_utimes -#endif -#if defined(SYS_utime) -#define SYSIO_SYS_utime SYS_utime -#endif -#if defined(SYS_socketcall) -# if defined (__mips64__) -# define SYSIO_SYS_socketcall SYS_O32_socketcall -# else -# define SYSIO_SYS_socketcall SYS_socketcall -# endif -#endif -#if defined(SYS_socket) -#define SYSIO_SYS_socket SYS_socket -#endif -#if defined(SYS_accept) -#define SYSIO_SYS_accept SYS_accept -#endif -#if defined(SYS_bind) -#define SYSIO_SYS_bind SYS_bind -#endif -#if defined(SYS_listen) -#define SYSIO_SYS_listen SYS_listen -#endif -#if defined(SYS_connect) -#define SYSIO_SYS_connect SYS_connect -#endif -#if defined(SYS_ioctl) -#define SYSIO_SYS_ioctl SYS_ioctl -#endif diff --git a/libsysio/include/stddir.h b/libsysio/include/stddir.h deleted file mode 100644 index ff830c7..0000000 --- a/libsysio/include/stddir.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2004 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -/* - * Support for directory functions - */ - -#ifndef _STDDIR_H_ -#define _STDDIR_H_ - -#undef BUFSIZE -#define BUFSIZE 4096 - -struct __dirstream { - int fd; - _SYSIO_OFF_T base; /* start pos for next system call */ - _SYSIO_OFF_T filepos; /* current pos in dir file stream */ - size_t cur; /* current byte pos in data buffer */ - size_t effective; /* effective data size in buffer */ - char buf[BUFSIZE]; -}; - -#ifndef MAX -#define MAX(a,b) (a) > (b) ? (a) : (b) -#endif - -#endif /* ! _STDDIR_H_ */ diff --git a/libsysio/include/sysio-cmn.h b/libsysio/include/sysio-cmn.h deleted file mode 100644 index abb6ddd..0000000 --- a/libsysio/include/sysio-cmn.h +++ /dev/null @@ -1,226 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2006 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -/* - * System IO common information. - */ - -#if !defined(__IS_UNUSED) && defined(__GNUC__) -#define __IS_UNUSED __attribute__ ((unused)) -#else -#define __IS_UNUSED -#endif - -/* - * Define internal file-offset type and it's maximum value. - */ -#ifdef _LARGEFILE64_SOURCE -#define _SYSIO_OFF_T off64_t -#ifdef LLONG_MAX -#define _SYSIO_OFF_T_MAX (LLONG_MAX) -#else -/* - * Don't have LLONG_MAX before C99. We'll need to define it ourselves. - */ -#define _SYSIO_OFF_T_MAX (9223372036854775807LL) -#endif -#else -#define _SYSIO_OFF_T off_t -#define _SYSIO_OFF_T_MAX LONG_MAX -#endif - -/* - * Internally, all file status is carried in the 64-bit capable - * structure. - */ -#ifdef _LARGEFILE64_SOURCE -#define intnl_xtvec xtvec64 -#else -#define intnl_xtvec xtvec -#endif -struct intnl_xtvec; - -struct iovec; - -/* - * Symbol composition. - */ -#define _PREPEND_HELPER(p, x) \ - p ## x -#define PREPEND(p, x) \ - _PREPEND_HELPER(p, x) - -/* - * SYSIO name label macros - */ -#ifndef SYSIO_INTERFACE_NAME -#ifdef SYSIO_LABEL_NAMES -#define SYSIO_INTERFACE_NAME(x) \ - PREPEND(SYSIO_LABEL_NAMES, x) -#else -#define SYSIO_INTERFACE_NAME(x) x -#endif /* SYSIO_LABEL_NAMES */ -#endif /* !SYSIO_INTERFACE_NAME */ - -/* for debugging */ -#if 0 -#define ASSERT(cond) \ - if (!(cond)) { \ - printf("ASSERTION(" #cond ") failed: " __FILE__ ":" \ - __FUNCTION__ ":%d\n", __LINE__); \ - abort(); \ - } - -#define ERROR(fmt, a...) \ - do { \ - printf("ERROR(" __FILE__ ":%d):" fmt, __LINE__, ##a); \ - while(0) - -#else -#define ERROR(fmt) do{}while(0) -#define ASSERT do{}while(0) -#endif - -/* - * SYSIO interface frame macros - * - * + DISPLAY_BLOCK; Allocates storage on the stack for use by the set of - * macros. - * + ENTER; Performs entry point work - * + RETURN; Returns a value and performs exit point work - * - * NB: For RETURN, the arguments are the return value and value for errno. - * If the value for errno is non-zero then that value, *negated*, is set - * into errno. - */ -#define SYSIO_INTERFACE_DISPLAY_BLOCK \ - int _saved_errno; -#define SYSIO_INTERFACE_ENTER \ - do { \ - _saved_errno = errno; \ - SYSIO_ENTER; \ - } while (0) -#define SYSIO_INTERFACE_RETURN(rtn, err) \ - do { \ - SYSIO_LEAVE; \ - errno = (err) ? -(err) : _saved_errno; \ - return (rtn); \ - } while(0) - -/* Interface enter/leave hook functions */ -#ifdef SYSIO_TRACING -extern void *_sysio_entry_trace_q; -extern void *_sysio_exit_trace_q; - -extern void *_sysio_register_trace(void *q, - void (*)(const char *file, - const char *func, - int line, - void *data), - void *data, - void (*destructor)(void *data)); -extern void _sysio_remove_trace(void *q, void *p); -extern void _sysio_run_trace_q(void *q, - const char *file, - const char *func, - int line); -#define SYSIO_ENTER \ - do { \ - _sysio_run_trace_q(_sysio_entry_trace_q, \ - __FILE__, __func__, __LINE__); \ - } while (0) - - -#define SYSIO_LEAVE \ - do { \ - _sysio_run_trace_q(_sysio_exit_trace_q, \ - __FILE__, __func__, __LINE__); \ - } while (0) -#else -#define SYSIO_ENTER \ - do { } while (0) -#define SYSIO_LEAVE \ - do { } while (0) -#endif - -/* Accounting for IO stats; Read and write character count. */ -#if defined(REDSTORM) -#define _SYSIO_UPDACCT(w, cc) \ - do { \ - if ((cc) < 0) \ - break; \ - if (w) \ - _add_iostats(0, (size_t )(cc)); \ - else \ - _add_iostats((size_t )(cc), 0); \ - } while(0) -#else -#define _SYSIO_UPDACCT(w, cc) -#endif - -extern ssize_t _sysio_validx(const struct intnl_xtvec *xtv, size_t xtvlen, - const struct iovec *iov, size_t iovlen, - _SYSIO_OFF_T limit); -extern ssize_t _sysio_enumerate_extents(const struct intnl_xtvec *xtv, - size_t xtvlen, - const struct iovec *iov, - size_t iovlen, - ssize_t (*f)(const struct iovec *, - int, - _SYSIO_OFF_T, - ssize_t, - void *), - void *arg); -extern ssize_t _sysio_enumerate_iovec(const struct iovec *iov, - size_t count, - _SYSIO_OFF_T off, - ssize_t limit, - ssize_t (*f)(void *, - size_t, - _SYSIO_OFF_T, - void *), - void *arg); -extern ssize_t _sysio_doio(const struct intnl_xtvec *xtv, size_t xtvlen, - const struct iovec *iov, size_t iovlen, - ssize_t (*f)(void *, size_t, _SYSIO_OFF_T, void *), - void *arg); diff --git a/libsysio/include/sysio-symbols.h b/libsysio/include/sysio-symbols.h deleted file mode 100644 index 4b7cf56..0000000 --- a/libsysio/include/sysio-symbols.h +++ /dev/null @@ -1,26 +0,0 @@ -#if defined(HAVE_ASM_WEAK_DIRECTIVE) || defined(HAVE_ASM_WEAKEXT_DIRECTIVE) -#define HAVE_WEAK_SYMBOLS -#endif - -#define STRINGOF(x) #x - -/* - * Define alias, asym, as a strong alias for symbol, sym. - */ -#define sysio_sym_strong_alias(sym, asym) \ - extern __typeof(sym) asym __attribute__((alias(STRINGOF(sym)))); - -#ifdef HAVE_WEAK_SYMBOLS - -/* - * Define alias, asym, as a strong alias for symbol, sym. - */ -#define sysio_sym_weak_alias(sym, asym) \ - extern __typeof(sym) asym __attribute__((weak, alias(STRINGOF(sym)))); -#else /* !defined(HAVE_ASM_WEAK_DIRECTIVE) */ - -/* - * Weak symbols not supported. Make it a strong alias then. - */ -#define sysio_sym_weak_alias(sym, asym) sysio_sym_strong_alias(sym, asym) -#endif diff --git a/libsysio/include/sysio.h b/libsysio/include/sysio.h deleted file mode 100644 index c9eab42..0000000 --- a/libsysio/include/sysio.h +++ /dev/null @@ -1,301 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2004 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -/* - * System IO common information. - */ - -#include -#include - -#include "sysio-cmn.h" -#include "creds.h" - -#if defined(_DIRENT_H) && _DIRENT_H -/* - * Need directory access routines too. - */ -#define _DECLARE_DIR_ACCESS 1 -#else -#define _DECLARE_DIR_ACCESS 0 -#endif - -#ifndef PATH_SEPARATOR -/* - * Path separator. - */ -#define PATH_SEPARATOR '/' -#endif - -#ifndef MAX_SYMLINK -/* - * Max recursion depth allowed when resoving symbolic links. - */ -#define MAX_SYMLINK 250 -#endif - -/* - * Internally, all directory entries are carried in the 64-bit capable - * structure. - */ -#ifdef _LARGEFILE64_SOURCE -#define intnl_dirent dirent64 -#else -#define intnl_dirent dirent -#endif -struct dirent; - -/* - * Internally, all file status is carried in the 64-bit capable - * structure. - */ -#ifdef _LARGEFILE64_SOURCE -#define intnl_stat stat64 -#else -#define intnl_stat stat -#endif -struct stat; - -#ifdef _HAVE_STATVFS -#ifdef _LARGEFILE64_SOURCE -#define intnl_statvfs statvfs64 -#else -#define intnl_statvfs statvfs -#define INTNL_STATVFS_IS_NATURAL 1 -#endif -struct statvfs; -struct intnl_statvfs; -#endif - -struct utimbuf; - -struct intnl_stat; - -struct pnode; - -#ifdef DEFER_INIT_CWD -extern const char *_sysio_init_cwd; -#endif - -extern struct pnode *_sysio_cwd; - -extern mode_t _sysio_umask; - -extern int _sysio_init(void); -extern void _sysio_shutdown(void); -#ifdef ZERO_SUM_MEMORY -extern void _sysio_access_shutdown(void); -#endif - -#if 0 -struct _sysio_boot_ctl { - const char *onam; - const char *oarg; -}; -#endif - -extern int _sysio_boot(const char *opt, const char *arg); - -/* - * Option-value pair information. - */ -struct option_value_info { - const char *ovi_name; /* name */ - char *ovi_value; /* value */ -}; - -extern const char * _sysio_get_token(const char *buf, - int accepts, - const char *delim, - const char *ignore, - char *tbuf); -extern char * _sysio_get_args(char *buf, struct option_value_info *vec); - -#define _SYSIO_LOCAL_TIME() _sysio_local_time() - -extern time_t _sysio_local_time(void); - -#ifdef SYSIO_TRACING -extern void _sysio_cprintf(const char *fmt, ...); -#endif - -/* - * The following should be defined by the system includes, and probably are, - * but it's not illegal to have multiple externs, so long as they are the - * same. It helps when building the library in a standalone fashion. - */ -extern int SYSIO_INTERFACE_NAME(access)(const char *path, int amode); -extern int SYSIO_INTERFACE_NAME(chdir)(const char *path); -extern int SYSIO_INTERFACE_NAME(chmod)(const char *path, mode_t mode); -extern int SYSIO_INTERFACE_NAME(fchmod)(int fd, mode_t mode); -extern int SYSIO_INTERFACE_NAME(chown)(const char *path, uid_t owner, - gid_t group); -extern int SYSIO_INTERFACE_NAME(fchown)(int fd, uid_t owner, gid_t group); -extern int SYSIO_INTERFACE_NAME(close)(int d); -extern int SYSIO_INTERFACE_NAME(dup)(int oldfd); -extern int SYSIO_INTERFACE_NAME(dup2)(int oldfd, int newfd); -extern int SYSIO_INTERFACE_NAME(fcntl)(int fd, int cmd, ...); -extern int SYSIO_INTERFACE_NAME(fcntl64)(int fd, int cmd, ...); -extern int SYSIO_INTERFACE_NAME(fstat)(int fd, struct stat *buf); -#ifdef _LARGEFILE64_SOURCE -extern int SYSIO_INTERFACE_NAME(fstat64)(int fd, struct stat64 *buf); -extern int SYSIO_INTERFACE_NAME(lstat64)(const char *path, struct stat64 *buf); -#endif -extern int SYSIO_INTERFACE_NAME(fsync)(int fd); -extern char *SYSIO_INTERFACE_NAME(getcwd)(char *buf, size_t size); -extern off_t SYSIO_INTERFACE_NAME(lseek)(int fd, off_t offset, int whence); -#ifdef _LARGEFILE64_SOURCE -extern off64_t SYSIO_INTERFACE_NAME(lseek64)(int fd, off64_t offset, - int whence); -#endif -extern int SYSIO_INTERFACE_NAME(lstat)(const char *path, struct stat *buf); -#ifdef BSD -extern int SYSIO_INTERFACE_NAME(getdirentries)(int fd, char *buf, int nbytes , - long *basep); -#else -extern ssize_t SYSIO_INTERFACE_NAME(getdirentries)(int fd, char *buf, - size_t nbytes, off_t *basep); -#ifdef _LARGEFILE64_SOURCE -extern ssize_t SYSIO_INTERFACE_NAME(getdirentries64)(int fd, - char *buf, - size_t nbytes, - off64_t *basep); -#endif -#endif -extern int SYSIO_INTERFACE_NAME(mkdir)(const char *path, mode_t mode); -extern int SYSIO_INTERFACE_NAME(open)(const char *path, int flag, ...); -#ifdef _LARGEFILE64_SOURCE -extern int SYSIO_INTERFACE_NAME(open64)(const char *path, int flag, ...); -#endif -extern int SYSIO_INTERFACE_NAME(creat)(const char *path, mode_t mode); -#ifdef _LARGEFILE64_SOURCE -extern int SYSIO_INTERFACE_NAME(creat64)(const char *path, mode_t mode); -#endif -extern int SYSIO_INTERFACE_NAME(stat)(const char *path, struct stat *buf); -#ifdef _LARGEFILE64_SOURCE -extern int SYSIO_INTERFACE_NAME(stat64)(const char *path, struct stat64 *buf); -#endif -extern ssize_t SYSIO_INTERFACE_NAME(read)(int fd, void *buf, size_t count); -extern ssize_t SYSIO_INTERFACE_NAME(pread)(int fd, void *buf, size_t count, - off_t offset); -extern ssize_t SYSIO_INTERFACE_NAME(readv)(int fd, - const struct iovec *iov, - int count); -extern ssize_t SYSIO_INTERFACE_NAME(write)(int fd, - const void *buf, - size_t count); -extern ssize_t SYSIO_INTERFACE_NAME(pwrite)(int fd, - const void *buf, - size_t count, - off_t offset); -extern ssize_t SYSIO_INTERFACE_NAME(writev)(int fd, - const struct iovec *iov, - int count); -#ifdef _HAVE_STATVFS -extern int SYSIO_INTERFACE_NAME(statvfs)(const char *path, struct statvfs *buf); -#ifdef _LARGEFILE64_SOURCE -extern int SYSIO_INTERFACE_NAME(statvfs64)(const char *path, - struct statvfs64 *buf); -#endif -extern int SYSIO_INTERFACE_NAME(fstatvfs)(int fd, struct statvfs *buf); -#ifdef _LARGEFILE64_SOURCE -extern int SYSIO_INTERFACE_NAME(fstatvfs64)(int fd, struct statvfs64 *buf); -#endif -#endif -extern int SYSIO_INTERFACE_NAME(truncate)(const char *path, off_t length); -#ifdef _LARGEFILE64_SOURCE -extern int SYSIO_INTERFACE_NAME(truncate64)(const char *path, off64_t length); -#endif -extern int SYSIO_INTERFACE_NAME(ftruncate)(int fd, off_t length); -#ifdef _LARGEFILE64_SOURCE -extern int SYSIO_INTERFACE_NAME(ftruncate64)(int fd, off64_t length); -#endif -extern int SYSIO_INTERFACE_NAME(rmdir)(const char *path); -extern int SYSIO_INTERFACE_NAME(symlink)(const char *path1, const char *path2); -#ifdef HAVE_POSIX_1003_READLINK -extern ssize_t SYSIO_INTERFACE_NAME(readlink)(const char *path, -#else -extern int SYSIO_INTERFACE_NAME(readlink)(const char *path, -#endif - char *buf, - size_t bufsiz); -extern int SYSIO_INTERFACE_NAME(link)(const char *oldpath, const char *newpath); -extern int SYSIO_INTERFACE_NAME(unlink)(const char *path); -extern int SYSIO_INTERFACE_NAME(rename)(const char *oldpath, - const char *newpath); -extern int SYSIO_INTERFACE_NAME(fdatasync)(int fd); -extern int SYSIO_INTERFACE_NAME(ioctl)(int fd, unsigned long request, ...); -extern mode_t SYSIO_INTERFACE_NAME(umask)(mode_t mask); -extern int SYSIO_INTERFACE_NAME(mknod)(const char *path, - mode_t mode, dev_t dev); -extern int SYSIO_INTERFACE_NAME(utime)(const char *path, - const struct utimbuf *buf); -extern int SYSIO_INTERFACE_NAME(mount)(const char *source, const char *target, - const char *filesystemtype, - unsigned long mountflags, - const void *data); -extern int SYSIO_INTERFACE_NAME(umount)(const char *target); -#if _DECLARE_DIR_ACCESS -extern DIR *SYSIO_INTERFACE_NAME(opendir)(const char *name); -extern int SYSIO_INTERFACE_NAME(closedir)(DIR *dir); -extern struct dirent *SYSIO_INTERFACE_NAME(readdir)(DIR *dir); - -extern int SYSIO_INTERFACE_NAME(scandir)(const char *dir, - struct dirent ***namelist, - int(*filter)(const struct dirent *), -#ifdef HAVE_POSIX2008_SCANDIR - int(*compar)(const struct dirent **, - const struct dirent **) -#else - int(*compar)(const void *, const void *) -#endif - ); -#if defined(_BSD_SOURCE) || defined(_SVID_SOURCE) -extern ssize_t SYSIO_INTERFACE_NAME(getdirentries)(int fd, - char *buf, - size_t nbytes, - off_t *basep); -#endif -#endif /* _DECLARE_DIR_ACCESS */ - -#undef _DECLARE_DIR_ACCESS diff --git a/libsysio/include/xtio.h b/libsysio/include/xtio.h deleted file mode 100644 index 8e67d2e..0000000 --- a/libsysio/include/xtio.h +++ /dev/null @@ -1,345 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2004 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -/* - * Extended application programmers interface for IO as found on Cray RedStorm - * and the other current SUNMos/Puma/Cougar/Catamount systems. - */ - -#ifndef _XTIO_H_ -#define _XTIO_H_ - -/* - * When compiled for use with libsysio, this allows one to move all the - * externals to a distinct namespace. When not, we want it to do nothing. - * - * NB: The choice of macro name here is dangerous. It's in the global - * namespace! We should fix that one of these days. - */ -#if !defined(SYSIO_INTERFACE_NAME) -#define SYSIO_INTERFACE_NAME(_n) _n -#endif - -#ifndef _IOID_T_DEFINED -#define _IOID_T_DEFINED -typedef void *ioid_t; - -#define IOID_FAIL 0 -#endif - -/* - * Structure for strided I/O. - */ -struct xtvec { -#ifndef __USE_FILE_OFFSET64 - __off_t xtv_off; /* Stride/Extent offset. */ -#else - __off64_t xtv_off; /* Stride/Extent offset. */ -#endif - size_t xtv_len; /* Stride/Extent length. */ -}; - -#ifdef __USE_LARGEFILE64 -struct xtvec64 { - __off64_t xtv_off; /* Stride/Extent offset. */ - size_t xtv_len; /* Stride/Extent length. */ -}; -#endif - -#ifdef HAVE_POSIX2008_PREADV -#define _SYSIO_PREADV_T int -#else -#define _SYSIO_PREADV_T size_t -#endif - -struct iovec; - -/* - * Get status of previously posted async file IO operation. - */ -extern int SYSIO_INTERFACE_NAME(iodone)(ioid_t ioid); - -/* - * Wait for completion of a previously posted asynch file IO request. - */ -extern ssize_t SYSIO_INTERFACE_NAME(iowait)(ioid_t ioid); - -/* - * Post asynch read into buffers mapped by an iovec from file at given offset. - */ -extern ioid_t SYSIO_INTERFACE_NAME(ipreadv)(int fd, - const struct iovec *iov, - size_t count, - off_t offset); - -#ifdef _LARGEFILE64_SOURCE -/* - * Post asynch read into buffers mapped by an iovec from file at given offset. - */ -extern ioid_t SYSIO_INTERFACE_NAME(ipread64v)(int fd, - const struct iovec *iov, - size_t count, - off64_t offset); -#endif - -/* - * Post asynch read into buffer from file at given offset. - */ -extern ioid_t SYSIO_INTERFACE_NAME(ipread)(int fd, - void *buf, - size_t count, - off_t offset); - -#ifdef _LARGEFILE64_SOURCE -/* - * Post asynch read into buffer from file at given offset. - */ -extern ioid_t SYSIO_INTERFACE_NAME(ipread64)(int fd, - void *buf, - size_t count, - off64_t offset); -#endif - -/* - * Read into buffers mapped by an iovec from file at given offset. - */ -extern ssize_t SYSIO_INTERFACE_NAME(preadv)(int fd, - const struct iovec *iov, - _SYSIO_PREADV_T count, - off_t offset); - -#ifdef _LARGEFILE64_SOURCE -/* - * Read into buffers mapped by an iovec from file at given offset. - */ -extern ssize_t SYSIO_INTERFACE_NAME(pread64v)(int fd, - const struct iovec *iov, - _SYSIO_PREADV_T count, - off64_t offset); -#endif - -/* - * Post asynch read into buffers mapped by an iovec. - */ -extern ioid_t SYSIO_INTERFACE_NAME(ireadv)(int fd, - const struct iovec *iov, - int count); - -/* - * Read into buffer. - */ -extern ioid_t SYSIO_INTERFACE_NAME(iread)(int fd, - void *buf, - size_t count); - -/* - * Post async read into buffers mapped by iovec from regions mapped - * by xtvec. - * - * NB: An adaptation of "listio" from Argonne's PVFS. - */ -extern ioid_t SYSIO_INTERFACE_NAME(ireadx)(int fd, - const struct iovec *iov, - size_t iov_count, - const struct xtvec *xtv, - size_t xtv_count); - -#ifdef __USE_LARGEFILE64 -/* - * Post async read into buffers mapped by iovec from regions mapped - * by xtvec. - * - * NB: An adaptation of "listio" from Argonne's PVFS. - */ -extern ioid_t SYSIO_INTERFACE_NAME(iread64x)(int fd, - const struct iovec *iov, - size_t iov_count, - const struct xtvec64 *xtv, - size_t xtv_count); -#endif - -/* - * Read into buffers mapped by iovec from regions mapped - * by xtvec. - * - * NB: An adaptation of "listio" from Argonne's PVFS. - */ -extern ssize_t SYSIO_INTERFACE_NAME(readx)(int fd, - const struct iovec *iov, - size_t iov_count, - const struct xtvec *xtv, - size_t xtv_count); - -#ifdef __USE_LARGEFILE64 -/* - * Read into buffers mapped by iovec from regions mapped - * by xtvec. - * - * NB: An adaptation of "listio" from Argonne's PVFS. - */ -extern ssize_t SYSIO_INTERFACE_NAME(read64x)(int fd, - const struct iovec *iov, - size_t iov_count, - const struct xtvec64 *xtv, - size_t xtv_count); -#endif - -/* - * Post asynch write from buffers mapped by an iovec to file at given offset. - */ -extern ioid_t SYSIO_INTERFACE_NAME(ipwritev)(int fd, - const struct iovec *iov, - size_t count, - off_t offset); -#ifdef _LARGEFILE64_SOURCE -/* - * Post asynch write from buffers mapped by an iovec to file at given offset. - */ -extern ioid_t SYSIO_INTERFACE_NAME(ipwrite64v)(int fd, - const struct iovec *iov, - size_t count, - off64_t offset); -#endif - -/* - * Post asynch write from buffer to file at given offset. - */ -extern ioid_t SYSIO_INTERFACE_NAME(ipwrite)(int fd, - const void *buf, - size_t count, - off_t offset); - -#ifdef _LARGEFILE64_SOURCE -/* - * Post asynch write from buffer to file at given offset. - */ -extern ioid_t SYSIO_INTERFACE_NAME(ipwrite64)(int fd, - const void *buf, - size_t count, - off64_t offset); -#endif - -/* - * Write from buffers mapped by an iovec to file at given offset. - */ -extern ssize_t SYSIO_INTERFACE_NAME(pwritev)(int fd, - const struct iovec *iov, - _SYSIO_PREADV_T count, - off_t offset); - -#ifdef _LARGEFILE64_SOURCE -/* - * Write from buffers mapped by an iovec to file at given offset. - */ -extern ssize_t SYSIO_INTERFACE_NAME(pwrite64v)(int fd, - const struct iovec *iov, - _SYSIO_PREADV_T count, - off64_t offset); -#endif - -/* - * Post asynch write from buffer to file at given offset. - */ -extern ioid_t SYSIO_INTERFACE_NAME(iwritev)(int fd, - const struct iovec *iov, - int count); - -/* - * Write from buffer to file at given offset. - */ -extern ioid_t SYSIO_INTERFACE_NAME(iwrite)(int fd, - const void *buf, - size_t count); - -/* - * Post async write from buffers mapped by iovec to regions mapped - * by xtvec. - * - * NB: An adaptation of "listio" from Argonne's PVFS. - */ -extern ioid_t SYSIO_INTERFACE_NAME(iwritex)(int fd, - const struct iovec *iov, - size_t iov_count, - const struct xtvec *xtv, - size_t xtv_count); - -#ifdef __USE_LARGEFILE64 -/* - * Post async write from buffers mapped by iovec to regions mapped - * by xtvec. - * - * NB: An adaptation of "listio" from Argonne's PVFS. - */ -extern ioid_t SYSIO_INTERFACE_NAME(iwrite64x)(int fd, - const struct iovec *iov, - size_t iov_count, - const struct xtvec64 *xtv, - size_t xtv_count); -#endif - -/* - * Write from buffers mapped by iovec to regions mapped - * by xtvec. - * - * NB: An adaptation of "listio" from Argonne's PVFS. - */ -extern ssize_t SYSIO_INTERFACE_NAME(writex)(int fd, - const struct iovec *iov, - size_t iov_count, - const struct xtvec *xtv, - size_t xtv_count); - -#ifdef __USE_LARGEFILE64 -/* - * Write from buffers mapped by iovec to regions mapped - * by xtvec. - * - * NB: An adaptation of "listio" from Argonne's PVFS. - */ -extern ssize_t SYSIO_INTERFACE_NAME(write64x)(int fd, - const struct iovec *iov, - size_t iov_count, - const struct xtvec64 *xtv, - size_t xtv_count); -#endif -#endif /* ! _XTIO_H_ */ diff --git a/libsysio/install-sh b/libsysio/install-sh deleted file mode 100755 index a9244eb..0000000 --- a/libsysio/install-sh +++ /dev/null @@ -1,527 +0,0 @@ -#!/bin/sh -# install - install a program, script, or datafile - -scriptversion=2011-01-19.21; # UTC - -# This originates from X11R5 (mit/util/scripts/install.sh), which was -# later released in X11R6 (xc/config/util/install.sh) with the -# following copyright and license. -# -# Copyright (C) 1994 X Consortium -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- -# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -# Except as contained in this notice, the name of the X Consortium shall not -# be used in advertising or otherwise to promote the sale, use or other deal- -# ings in this Software without prior written authorization from the X Consor- -# tium. -# -# -# FSF changes to this file are in the public domain. -# -# Calling this script install-sh is preferred over install.sh, to prevent -# `make' implicit rules from creating a file called install from it -# when there is no Makefile. -# -# This script is compatible with the BSD install script, but was written -# from scratch. - -nl=' -' -IFS=" "" $nl" - -# set DOITPROG to echo to test this script - -# Don't use :- since 4.3BSD and earlier shells don't like it. -doit=${DOITPROG-} -if test -z "$doit"; then - doit_exec=exec -else - doit_exec=$doit -fi - -# Put in absolute file names if you don't have them in your path; -# or use environment vars. - -chgrpprog=${CHGRPPROG-chgrp} -chmodprog=${CHMODPROG-chmod} -chownprog=${CHOWNPROG-chown} -cmpprog=${CMPPROG-cmp} -cpprog=${CPPROG-cp} -mkdirprog=${MKDIRPROG-mkdir} -mvprog=${MVPROG-mv} -rmprog=${RMPROG-rm} -stripprog=${STRIPPROG-strip} - -posix_glob='?' -initialize_posix_glob=' - test "$posix_glob" != "?" || { - if (set -f) 2>/dev/null; then - posix_glob= - else - posix_glob=: - fi - } -' - -posix_mkdir= - -# Desired mode of installed file. -mode=0755 - -chgrpcmd= -chmodcmd=$chmodprog -chowncmd= -mvcmd=$mvprog -rmcmd="$rmprog -f" -stripcmd= - -src= -dst= -dir_arg= -dst_arg= - -copy_on_change=false -no_target_directory= - -usage="\ -Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE - or: $0 [OPTION]... SRCFILES... DIRECTORY - or: $0 [OPTION]... -t DIRECTORY SRCFILES... - or: $0 [OPTION]... -d DIRECTORIES... - -In the 1st form, copy SRCFILE to DSTFILE. -In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. -In the 4th, create DIRECTORIES. - -Options: - --help display this help and exit. - --version display version info and exit. - - -c (ignored) - -C install only if different (preserve the last data modification time) - -d create directories instead of installing files. - -g GROUP $chgrpprog installed files to GROUP. - -m MODE $chmodprog installed files to MODE. - -o USER $chownprog installed files to USER. - -s $stripprog installed files. - -t DIRECTORY install into DIRECTORY. - -T report an error if DSTFILE is a directory. - -Environment variables override the default commands: - CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG - RMPROG STRIPPROG -" - -while test $# -ne 0; do - case $1 in - -c) ;; - - -C) copy_on_change=true;; - - -d) dir_arg=true;; - - -g) chgrpcmd="$chgrpprog $2" - shift;; - - --help) echo "$usage"; exit $?;; - - -m) mode=$2 - case $mode in - *' '* | *' '* | *' -'* | *'*'* | *'?'* | *'['*) - echo "$0: invalid mode: $mode" >&2 - exit 1;; - esac - shift;; - - -o) chowncmd="$chownprog $2" - shift;; - - -s) stripcmd=$stripprog;; - - -t) dst_arg=$2 - # Protect names problematic for `test' and other utilities. - case $dst_arg in - -* | [=\(\)!]) dst_arg=./$dst_arg;; - esac - shift;; - - -T) no_target_directory=true;; - - --version) echo "$0 $scriptversion"; exit $?;; - - --) shift - break;; - - -*) echo "$0: invalid option: $1" >&2 - exit 1;; - - *) break;; - esac - shift -done - -if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then - # When -d is used, all remaining arguments are directories to create. - # When -t is used, the destination is already specified. - # Otherwise, the last argument is the destination. Remove it from $@. - for arg - do - if test -n "$dst_arg"; then - # $@ is not empty: it contains at least $arg. - set fnord "$@" "$dst_arg" - shift # fnord - fi - shift # arg - dst_arg=$arg - # Protect names problematic for `test' and other utilities. - case $dst_arg in - -* | [=\(\)!]) dst_arg=./$dst_arg;; - esac - done -fi - -if test $# -eq 0; then - if test -z "$dir_arg"; then - echo "$0: no input file specified." >&2 - exit 1 - fi - # It's OK to call `install-sh -d' without argument. - # This can happen when creating conditional directories. - exit 0 -fi - -if test -z "$dir_arg"; then - do_exit='(exit $ret); exit $ret' - trap "ret=129; $do_exit" 1 - trap "ret=130; $do_exit" 2 - trap "ret=141; $do_exit" 13 - trap "ret=143; $do_exit" 15 - - # Set umask so as not to create temps with too-generous modes. - # However, 'strip' requires both read and write access to temps. - case $mode in - # Optimize common cases. - *644) cp_umask=133;; - *755) cp_umask=22;; - - *[0-7]) - if test -z "$stripcmd"; then - u_plus_rw= - else - u_plus_rw='% 200' - fi - cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; - *) - if test -z "$stripcmd"; then - u_plus_rw= - else - u_plus_rw=,u+rw - fi - cp_umask=$mode$u_plus_rw;; - esac -fi - -for src -do - # Protect names problematic for `test' and other utilities. - case $src in - -* | [=\(\)!]) src=./$src;; - esac - - if test -n "$dir_arg"; then - dst=$src - dstdir=$dst - test -d "$dstdir" - dstdir_status=$? - else - - # Waiting for this to be detected by the "$cpprog $src $dsttmp" command - # might cause directories to be created, which would be especially bad - # if $src (and thus $dsttmp) contains '*'. - if test ! -f "$src" && test ! -d "$src"; then - echo "$0: $src does not exist." >&2 - exit 1 - fi - - if test -z "$dst_arg"; then - echo "$0: no destination specified." >&2 - exit 1 - fi - dst=$dst_arg - - # If destination is a directory, append the input filename; won't work - # if double slashes aren't ignored. - if test -d "$dst"; then - if test -n "$no_target_directory"; then - echo "$0: $dst_arg: Is a directory" >&2 - exit 1 - fi - dstdir=$dst - dst=$dstdir/`basename "$src"` - dstdir_status=0 - else - # Prefer dirname, but fall back on a substitute if dirname fails. - dstdir=` - (dirname "$dst") 2>/dev/null || - expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$dst" : 'X\(//\)[^/]' \| \ - X"$dst" : 'X\(//\)$' \| \ - X"$dst" : 'X\(/\)' \| . 2>/dev/null || - echo X"$dst" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q' - ` - - test -d "$dstdir" - dstdir_status=$? - fi - fi - - obsolete_mkdir_used=false - - if test $dstdir_status != 0; then - case $posix_mkdir in - '') - # Create intermediate dirs using mode 755 as modified by the umask. - # This is like FreeBSD 'install' as of 1997-10-28. - umask=`umask` - case $stripcmd.$umask in - # Optimize common cases. - *[2367][2367]) mkdir_umask=$umask;; - .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; - - *[0-7]) - mkdir_umask=`expr $umask + 22 \ - - $umask % 100 % 40 + $umask % 20 \ - - $umask % 10 % 4 + $umask % 2 - `;; - *) mkdir_umask=$umask,go-w;; - esac - - # With -d, create the new directory with the user-specified mode. - # Otherwise, rely on $mkdir_umask. - if test -n "$dir_arg"; then - mkdir_mode=-m$mode - else - mkdir_mode= - fi - - posix_mkdir=false - case $umask in - *[123567][0-7][0-7]) - # POSIX mkdir -p sets u+wx bits regardless of umask, which - # is incompatible with FreeBSD 'install' when (umask & 300) != 0. - ;; - *) - tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ - trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 - - if (umask $mkdir_umask && - exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 - then - if test -z "$dir_arg" || { - # Check for POSIX incompatibilities with -m. - # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or - # other-writeable bit of parent directory when it shouldn't. - # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. - ls_ld_tmpdir=`ls -ld "$tmpdir"` - case $ls_ld_tmpdir in - d????-?r-*) different_mode=700;; - d????-?--*) different_mode=755;; - *) false;; - esac && - $mkdirprog -m$different_mode -p -- "$tmpdir" && { - ls_ld_tmpdir_1=`ls -ld "$tmpdir"` - test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" - } - } - then posix_mkdir=: - fi - rmdir "$tmpdir/d" "$tmpdir" - else - # Remove any dirs left behind by ancient mkdir implementations. - rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null - fi - trap '' 0;; - esac;; - esac - - if - $posix_mkdir && ( - umask $mkdir_umask && - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" - ) - then : - else - - # The umask is ridiculous, or mkdir does not conform to POSIX, - # or it failed possibly due to a race condition. Create the - # directory the slow way, step by step, checking for races as we go. - - case $dstdir in - /*) prefix='/';; - [-=\(\)!]*) prefix='./';; - *) prefix='';; - esac - - eval "$initialize_posix_glob" - - oIFS=$IFS - IFS=/ - $posix_glob set -f - set fnord $dstdir - shift - $posix_glob set +f - IFS=$oIFS - - prefixes= - - for d - do - test X"$d" = X && continue - - prefix=$prefix$d - if test -d "$prefix"; then - prefixes= - else - if $posix_mkdir; then - (umask=$mkdir_umask && - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break - # Don't fail if two instances are running concurrently. - test -d "$prefix" || exit 1 - else - case $prefix in - *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; - *) qprefix=$prefix;; - esac - prefixes="$prefixes '$qprefix'" - fi - fi - prefix=$prefix/ - done - - if test -n "$prefixes"; then - # Don't fail if two instances are running concurrently. - (umask $mkdir_umask && - eval "\$doit_exec \$mkdirprog $prefixes") || - test -d "$dstdir" || exit 1 - obsolete_mkdir_used=true - fi - fi - fi - - if test -n "$dir_arg"; then - { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && - { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && - { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || - test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 - else - - # Make a couple of temp file names in the proper directory. - dsttmp=$dstdir/_inst.$$_ - rmtmp=$dstdir/_rm.$$_ - - # Trap to clean up those temp files at exit. - trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 - - # Copy the file name to the temp name. - (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && - - # and set any options; do chmod last to preserve setuid bits. - # - # If any of these fail, we abort the whole thing. If we want to - # ignore errors from any of these, just make sure not to ignore - # errors from the above "$doit $cpprog $src $dsttmp" command. - # - { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && - { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && - { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && - { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && - - # If -C, don't bother to copy if it wouldn't change the file. - if $copy_on_change && - old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && - new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && - - eval "$initialize_posix_glob" && - $posix_glob set -f && - set X $old && old=:$2:$4:$5:$6 && - set X $new && new=:$2:$4:$5:$6 && - $posix_glob set +f && - - test "$old" = "$new" && - $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 - then - rm -f "$dsttmp" - else - # Rename the file to the real destination. - $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || - - # The rename failed, perhaps because mv can't rename something else - # to itself, or perhaps because mv is so ancient that it does not - # support -f. - { - # Now remove or move aside any old file at destination location. - # We try this two ways since rm can't unlink itself on some - # systems and the destination file might be busy for other - # reasons. In this case, the final cleanup might fail but the new - # file should still install successfully. - { - test ! -f "$dst" || - $doit $rmcmd -f "$dst" 2>/dev/null || - { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && - { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } - } || - { echo "$0: cannot unlink or rename $dst" >&2 - (exit 1); exit 1 - } - } && - - # Now rename the file to the real destination. - $doit $mvcmd "$dsttmp" "$dst" - } - fi || exit 1 - - trap '' 0 - fi -done - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" -# time-stamp-end: "; # UTC" -# End: diff --git a/libsysio/misc/gdb-libsysio b/libsysio/misc/gdb-libsysio deleted file mode 100644 index dd3f613..0000000 --- a/libsysio/misc/gdb-libsysio +++ /dev/null @@ -1,127 +0,0 @@ -# This Cplant(TM) source code is the property of Sandia National -# Laboratories. -# -# This Cplant(TM) source code is copyrighted by Sandia National -# Laboratories. -# -# The redistribution of this Cplant(TM) source code is subject to the -# terms of the GNU Lesser General Public License -# (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) -# -# Cplant(TM) Copyright 1998-2003 Sandia Corporation. -# Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive -# license for use of this work by or on behalf of the US Government. -# Export of this program may require a license from the United States -# Government. - -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# Questions or comments about this library should be sent to: -# -# Lee Ward -# Sandia National Laboratories, New Mexico -# P.O. Box 5800 -# Albuquerque, NM 87185-1110 -# -# lee@sandia.gov - -# -# Useful commands for debugging libsysio in gdb -# - -define x_dump_pbnode - printf "%p: ", $arg0 - if $arg0->pb_name.name - printf " \"%s\"", \ - $arg0->pb_name.name - else - printf " " - end - printf " aliases:[" - set $x_p = $arg0->pb_aliases.lh_first - while $x_p - printf "<%p r:%d mnt:%p>", \ - $x_p, \ - $x_p->p_ref, \ - $x_p->p_mount - set $x_p = $x_p->p_links.le_next - end - printf "]\n" -end -document x_dump_pbnode -Dump path-base node and it's aliases - -Usage: x_dump_pbnode -end - -define __x_dump_pnode - printf "%spnode %p, mount %p, base: ", $arg0, $arg1, $arg1->p_mount - x_dump_pbnode $arg1->p_base -end - -define x_dump_pnode - __x_dump_pnode "" $arg0 -end -document x_dump_pnode -Dump path node information - -Usage: x_dump_pnode -end - -define x_dump_mount - printf "MOUNT %p: root pnode %p, covers %p\n", \ - $arg0, $arg0->mnt_root, $arg0->mnt_covers - set $_x_dump_mount_var_pno = _sysio_pnodes->tqh_first - while $_x_dump_mount_var_pno != 0 -printf "%p, %p\n", $_x_dump_mount_var_pno, $arg0 - if $_x_dump_mount_var_pno->p_mount == $arg0 - __x_dump_pnode " " $_x_dump_mount_var_pno - end - set $_x_dump_mount_var_pno = \ - $_x_dump_mount_var_pno->p_nodes.tqe_next - end -end -document x_dump_mount -Dump single mount record information - -Usage: x_dump_mount -end - -define x_dump_mounts - set $__x_dump_mounts_var_mnt = mounts.lh_first - while $__x_dump_mounts_var_mnt - x_dump_mount $__x_dump_mounts_var_mnt - set $__x_dump_mounts_var_mnt = \ - $__x_dump_mounts_var_mnt->mnt_link.le_next - end -end -document x_dump_mounts -Dump the contents of the libsysio mount table - -Usage: x_dump_mounts -end - -define x_dump_pnodes - set $_x_dump_pnodes_var_pno = _sysio_pnodes.tqh_first - while $_x_dump_pnodes_var_pno - x_dump_pnode $_x_dump_pnodes_var_pno - set $_x_dump_pnodes_var_pno = \ - $_x_dump_pnodes_var_pno->p_nodes.tqe_next - end -end - -br _sysio_unmount_all -run -r /tmp/lee foo bar -x_dump_pnodes diff --git a/libsysio/misc/init-env.sh b/libsysio/misc/init-env.sh deleted file mode 100644 index ae1f881..0000000 --- a/libsysio/misc/init-env.sh +++ /dev/null @@ -1,40 +0,0 @@ -# -# Source this file. It will craft a usable name space for your testing. -# -# Lee; Sun Feb 8 18:02:16 EST 2004 -# -# Note: We really should support symlinks someday. -# -unset _root_flags -unset _extras -if [ "x${SYSIO_AUTOMOUNT}" == "xyes" ]; then - _root_flags="2" - # - # Add a /auto directory for automounted file systems. We - # craft one automount that mounts /usr/home from the native - # file system. Further automounts in the sub-mounts are not enabled. - # - _extras=" \ - {mnt, dev=\"incore:0755\",dir=\"/mnt\",fl=2} \ - {creat, ft=dir,nm=\"/mnt/home\",pm=04755} \ - {creat, ft=file,nm=\"/mnt/home/.mount\",pm=0600, \ - str=\"native:/home\"} \ - " -fi -export SYSIO_NAMESPACE="\ - {mnt, dev=\"native:/\",dir=/,fl=${_root_flags:-0}} \ - {mnt, dev=\"incore:0755\",dir=\"/dev\"} \ - {creat, ft=chr,nm=\"/dev/stdin\",pm=0400,mm=0+0} \ - {creat, ft=chr,nm=\"/dev/stdout\",pm=0200,mm=0+1} \ - {creat, ft=chr,nm=\"/dev/stderr\",pm=0200,mm=0+2} \ - {creat, ft=dir,nm=\"/dev/fd\",pm=0755} \ - {creat, ft=chr,nm=\"/dev/fd/0\",pm=0400,mm=0+0} \ - {open, nm=\"/dev/fd/0\",fd=0,m=0} \ - {creat, ft=chr,nm=\"/dev/fd/1\",pm=0200,mm=0+1} \ - {open, nm=\"/dev/fd/1\",fd=1,m=1} \ - {creat, ft=chr,nm=\"/dev/fd/2\",pm=0200,mm=0+2} \ - {open, nm=\"/dev/fd/2\",fd=2,m=1} \ - ${_extras} \ -" -unset _root_flags -unset _extras diff --git a/libsysio/missing b/libsysio/missing deleted file mode 100755 index 28055d2..0000000 --- a/libsysio/missing +++ /dev/null @@ -1,376 +0,0 @@ -#! /bin/sh -# Common stub for a few missing GNU programs while installing. - -scriptversion=2009-04-28.21; # UTC - -# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006, -# 2008, 2009 Free Software Foundation, Inc. -# Originally by Fran,cois Pinard , 1996. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, 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 . - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -if test $# -eq 0; then - echo 1>&2 "Try \`$0 --help' for more information" - exit 1 -fi - -run=: -sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' -sed_minuso='s/.* -o \([^ ]*\).*/\1/p' - -# In the cases where this matters, `missing' is being run in the -# srcdir already. -if test -f configure.ac; then - configure_ac=configure.ac -else - configure_ac=configure.in -fi - -msg="missing on your system" - -case $1 in ---run) - # Try to run requested program, and just exit if it succeeds. - run= - shift - "$@" && exit 0 - # Exit code 63 means version mismatch. This often happens - # when the user try to use an ancient version of a tool on - # a file that requires a minimum version. In this case we - # we should proceed has if the program had been absent, or - # if --run hadn't been passed. - if test $? = 63; then - run=: - msg="probably too old" - fi - ;; - - -h|--h|--he|--hel|--help) - echo "\ -$0 [OPTION]... PROGRAM [ARGUMENT]... - -Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an -error status if there is no known handling for PROGRAM. - -Options: - -h, --help display this help and exit - -v, --version output version information and exit - --run try to run the given command, and emulate it if it fails - -Supported PROGRAM values: - aclocal touch file \`aclocal.m4' - autoconf touch file \`configure' - autoheader touch file \`config.h.in' - autom4te touch the output file, or create a stub one - automake touch all \`Makefile.in' files - bison create \`y.tab.[ch]', if possible, from existing .[ch] - flex create \`lex.yy.c', if possible, from existing .c - help2man touch the output file - lex create \`lex.yy.c', if possible, from existing .c - makeinfo touch the output file - tar try tar, gnutar, gtar, then tar without non-portable flags - yacc create \`y.tab.[ch]', if possible, from existing .[ch] - -Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and -\`g' are ignored when checking the name. - -Send bug reports to ." - exit $? - ;; - - -v|--v|--ve|--ver|--vers|--versi|--versio|--version) - echo "missing $scriptversion (GNU Automake)" - exit $? - ;; - - -*) - echo 1>&2 "$0: Unknown \`$1' option" - echo 1>&2 "Try \`$0 --help' for more information" - exit 1 - ;; - -esac - -# normalize program name to check for. -program=`echo "$1" | sed ' - s/^gnu-//; t - s/^gnu//; t - s/^g//; t'` - -# Now exit if we have it, but it failed. Also exit now if we -# don't have it and --version was passed (most likely to detect -# the program). This is about non-GNU programs, so use $1 not -# $program. -case $1 in - lex*|yacc*) - # Not GNU programs, they don't have --version. - ;; - - tar*) - if test -n "$run"; then - echo 1>&2 "ERROR: \`tar' requires --run" - exit 1 - elif test "x$2" = "x--version" || test "x$2" = "x--help"; then - exit 1 - fi - ;; - - *) - if test -z "$run" && ($1 --version) > /dev/null 2>&1; then - # We have it, but it failed. - exit 1 - elif test "x$2" = "x--version" || test "x$2" = "x--help"; then - # Could not run --version or --help. This is probably someone - # running `$TOOL --version' or `$TOOL --help' to check whether - # $TOOL exists and not knowing $TOOL uses missing. - exit 1 - fi - ;; -esac - -# If it does not exist, or fails to run (possibly an outdated version), -# try to emulate it. -case $program in - aclocal*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`acinclude.m4' or \`${configure_ac}'. You might want - to install the \`Automake' and \`Perl' packages. Grab them from - any GNU archive site." - touch aclocal.m4 - ;; - - autoconf*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`${configure_ac}'. You might want to install the - \`Autoconf' and \`GNU m4' packages. Grab them from any GNU - archive site." - touch configure - ;; - - autoheader*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`acconfig.h' or \`${configure_ac}'. You might want - to install the \`Autoconf' and \`GNU m4' packages. Grab them - from any GNU archive site." - files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` - test -z "$files" && files="config.h" - touch_files= - for f in $files; do - case $f in - *:*) touch_files="$touch_files "`echo "$f" | - sed -e 's/^[^:]*://' -e 's/:.*//'`;; - *) touch_files="$touch_files $f.in";; - esac - done - touch $touch_files - ;; - - automake*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. - You might want to install the \`Automake' and \`Perl' packages. - Grab them from any GNU archive site." - find . -type f -name Makefile.am -print | - sed 's/\.am$/.in/' | - while read f; do touch "$f"; done - ;; - - autom4te*) - echo 1>&2 "\ -WARNING: \`$1' is needed, but is $msg. - You might have modified some files without having the - proper tools for further handling them. - You can get \`$1' as part of \`Autoconf' from any GNU - archive site." - - file=`echo "$*" | sed -n "$sed_output"` - test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` - if test -f "$file"; then - touch $file - else - test -z "$file" || exec >$file - echo "#! /bin/sh" - echo "# Created by GNU Automake missing as a replacement of" - echo "# $ $@" - echo "exit 0" - chmod +x $file - exit 1 - fi - ;; - - bison*|yacc*) - echo 1>&2 "\ -WARNING: \`$1' $msg. You should only need it if - you modified a \`.y' file. You may need the \`Bison' package - in order for those modifications to take effect. You can get - \`Bison' from any GNU archive site." - rm -f y.tab.c y.tab.h - if test $# -ne 1; then - eval LASTARG="\${$#}" - case $LASTARG in - *.y) - SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` - if test -f "$SRCFILE"; then - cp "$SRCFILE" y.tab.c - fi - SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` - if test -f "$SRCFILE"; then - cp "$SRCFILE" y.tab.h - fi - ;; - esac - fi - if test ! -f y.tab.h; then - echo >y.tab.h - fi - if test ! -f y.tab.c; then - echo 'main() { return 0; }' >y.tab.c - fi - ;; - - lex*|flex*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified a \`.l' file. You may need the \`Flex' package - in order for those modifications to take effect. You can get - \`Flex' from any GNU archive site." - rm -f lex.yy.c - if test $# -ne 1; then - eval LASTARG="\${$#}" - case $LASTARG in - *.l) - SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` - if test -f "$SRCFILE"; then - cp "$SRCFILE" lex.yy.c - fi - ;; - esac - fi - if test ! -f lex.yy.c; then - echo 'main() { return 0; }' >lex.yy.c - fi - ;; - - help2man*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified a dependency of a manual page. You may need the - \`Help2man' package in order for those modifications to take - effect. You can get \`Help2man' from any GNU archive site." - - file=`echo "$*" | sed -n "$sed_output"` - test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` - if test -f "$file"; then - touch $file - else - test -z "$file" || exec >$file - echo ".ab help2man is required to generate this page" - exit $? - fi - ;; - - makeinfo*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified a \`.texi' or \`.texinfo' file, or any other file - indirectly affecting the aspect of the manual. The spurious - call might also be the consequence of using a buggy \`make' (AIX, - DU, IRIX). You might want to install the \`Texinfo' package or - the \`GNU make' package. Grab either from any GNU archive site." - # The file to touch is that specified with -o ... - file=`echo "$*" | sed -n "$sed_output"` - test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` - if test -z "$file"; then - # ... or it is the one specified with @setfilename ... - infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` - file=`sed -n ' - /^@setfilename/{ - s/.* \([^ ]*\) *$/\1/ - p - q - }' $infile` - # ... or it is derived from the source name (dir/f.texi becomes f.info) - test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info - fi - # If the file does not exist, the user really needs makeinfo; - # let's fail without touching anything. - test -f $file || exit 1 - touch $file - ;; - - tar*) - shift - - # We have already tried tar in the generic part. - # Look for gnutar/gtar before invocation to avoid ugly error - # messages. - if (gnutar --version > /dev/null 2>&1); then - gnutar "$@" && exit 0 - fi - if (gtar --version > /dev/null 2>&1); then - gtar "$@" && exit 0 - fi - firstarg="$1" - if shift; then - case $firstarg in - *o*) - firstarg=`echo "$firstarg" | sed s/o//` - tar "$firstarg" "$@" && exit 0 - ;; - esac - case $firstarg in - *h*) - firstarg=`echo "$firstarg" | sed s/h//` - tar "$firstarg" "$@" && exit 0 - ;; - esac - fi - - echo 1>&2 "\ -WARNING: I can't seem to be able to run \`tar' with the given arguments. - You may want to install GNU tar or Free paxutils, or check the - command line arguments." - exit 1 - ;; - - *) - echo 1>&2 "\ -WARNING: \`$1' is needed, and is $msg. - You might have modified some files without having the - proper tools for further handling them. Check the \`README' file, - it often tells you about the needed prerequisites for installing - this package. You may also peek at any GNU archive site, in case - some other package would contain this missing \`$1' program." - exit 1 - ;; -esac - -exit 0 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" -# time-stamp-end: "; # UTC" -# End: diff --git a/libsysio/mkinstalldirs b/libsysio/mkinstalldirs deleted file mode 100755 index d2d5f21..0000000 --- a/libsysio/mkinstalldirs +++ /dev/null @@ -1,111 +0,0 @@ -#! /bin/sh -# mkinstalldirs --- make directory hierarchy -# Author: Noah Friedman -# Created: 1993-05-16 -# Public domain - -errstatus=0 -dirmode="" - -usage="\ -Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..." - -# process command line arguments -while test $# -gt 0 ; do - case $1 in - -h | --help | --h*) # -h for help - echo "$usage" 1>&2 - exit 0 - ;; - -m) # -m PERM arg - shift - test $# -eq 0 && { echo "$usage" 1>&2; exit 1; } - dirmode=$1 - shift - ;; - --) # stop option processing - shift - break - ;; - -*) # unknown option - echo "$usage" 1>&2 - exit 1 - ;; - *) # first non-opt arg - break - ;; - esac -done - -for file -do - if test -d "$file"; then - shift - else - break - fi -done - -case $# in - 0) exit 0 ;; -esac - -case $dirmode in - '') - if mkdir -p -- . 2>/dev/null; then - echo "mkdir -p -- $*" - exec mkdir -p -- "$@" - fi - ;; - *) - if mkdir -m "$dirmode" -p -- . 2>/dev/null; then - echo "mkdir -m $dirmode -p -- $*" - exec mkdir -m "$dirmode" -p -- "$@" - fi - ;; -esac - -for file -do - set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` - shift - - pathcomp= - for d - do - pathcomp="$pathcomp$d" - case $pathcomp in - -*) pathcomp=./$pathcomp ;; - esac - - if test ! -d "$pathcomp"; then - echo "mkdir $pathcomp" - - mkdir "$pathcomp" || lasterr=$? - - if test ! -d "$pathcomp"; then - errstatus=$lasterr - else - if test ! -z "$dirmode"; then - echo "chmod $dirmode $pathcomp" - lasterr="" - chmod "$dirmode" "$pathcomp" || lasterr=$? - - if test ! -z "$lasterr"; then - errstatus=$lasterr - fi - fi - fi - fi - - pathcomp="$pathcomp/" - done -done - -exit $errstatus - -# Local Variables: -# mode: shell-script -# sh-indentation: 2 -# End: -# mkinstalldirs ends here diff --git a/libsysio/src/.gitignore b/libsysio/src/.gitignore deleted file mode 100644 index c83c013..0000000 --- a/libsysio/src/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/.dirstamp diff --git a/libsysio/src/access.c b/libsysio/src/access.c deleted file mode 100644 index 1281541..0000000 --- a/libsysio/src/access.c +++ /dev/null @@ -1,282 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2006 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "mount.h" -#include "fs.h" -#include "inode.h" -#include "sysio-symbols.h" - -/* - * Use a persistent buffer for gids. No, not a cache. We just want to - * avoid calling malloc over, and over, and... - */ -static gid_t *gids = NULL; -static int gidslen = 0; - -/* - * Check given access type on given inode. - */ -int -_sysio_check_permission(struct pnode *pno, struct creds *crp, int amode) -{ - mode_t mask; - struct inode *ino; - int err; - struct intnl_stat *stat; - gid_t *gids; - int ngids; - int group_matched; - - /* - * Check amode. - */ - if ((amode & (R_OK|W_OK|X_OK)) != amode) - return -EINVAL; - - if (!amode) - return 0; - - mask = 0; - if (amode & R_OK) - mask |= S_IRUSR; - if (amode & W_OK) - mask |= S_IWUSR; - if (amode & X_OK) - mask |= S_IXUSR; - - ino = pno->p_base->pb_ino; - assert(ino); - - err = -EACCES; /* assume error */ - stat = &ino->i_stbuf; - do { -#ifdef _SYSIO_ROOT_UID - /* - * Root? - */ - if (_sysio_is_root(crp)) { - err = 0; - break; - } -#endif - - /* - * Owner? - */ - if (stat->st_uid == crp->creds_uid) { - if ((stat->st_mode & mask) == mask) - err = 0; - break; - } - - /* - * Group? - */ - mask >>= 3; - group_matched = 0; - gids = crp->creds_gids; - ngids = crp->creds_ngids; - while (ngids) { - ngids--; - if (stat->st_gid == *gids++) { - group_matched = 1; - if ((stat->st_mode & mask) == mask) - err = 0; - } - } - if (group_matched) - break; - - /* - * Other? - */ - mask >>= 3; - if ((stat->st_mode & mask) == mask) - err = 0; - } while (0); - if (err) - return err; - - /* - * Check for RO access to the file due to mount - * options. - */ - if (amode & W_OK && IS_RDONLY(pno)) - return -EROFS; - - return 0; -} - -/* - * Cache groups. - */ -static int -_sysio_ldgroups(gid_t gid0, gid_t **gidsp, int *gidslenp) -{ - int n, i; - void *p; - - n = *gidslenp; - if (n < 8) { - *gidsp = NULL; - n = 8; - } - for (;;) { - /* - * This is far more expensive than I would like. Each time - * called it has to go to some length to acquire the - * current uid and groups membership. We can't just cache - * the result, either. The caller could have altered something - * asynchronously. Wish we had easy access to this info. - */ - if (n > *gidslenp) { - p = realloc(*gidsp, (size_t )n * sizeof(gid_t)); - if (!p) - return -errno; - *gidsp = p; - *gidslenp = n; - } - (*gidsp)[0] = gid0; - i = getgroups(n - 1, *gidsp + 1); - if (i < 0) { - if (errno != EINVAL) - return -errno; - if (INT_MAX / 2 < n) - return -EINVAL; - n *= 2; - continue; - } - break; - } - return i; -} - -/* - * Get current credentials. - */ -static int -_sysio_ldcreds(uid_t uid, gid_t gid, struct creds *crp) -{ - int n; - - n = _sysio_ldgroups(gid, &gids, &gidslen); - if (n < 0) - return n; - crp->creds_uid = uid; - crp->creds_gids = gids; - crp->creds_ngids = n; - - return 0; -} - -/* - * Determine if a given access is permitted to a given file. - */ -int -_sysio_permitted(struct pnode *pno, int amode) -{ - struct creds cr; - int err; - - err = _sysio_ldcreds(geteuid(), getegid(), &cr); - if (err < 0) - return err; - err = _sysio_check_permission(pno, &cr, amode); - return err; -} - -#ifdef ZERO_SUM_MEMORY -/* - * Clean up persistent resource on shutdown. - */ -void -_sysio_access_shutdown() -{ - - if (gids) - free(gids); - gids = NULL; - gidslen = 0; -} -#endif - -int -SYSIO_INTERFACE_NAME(access)(const char *path, int amode) -{ - struct intent intent; - int err; - struct pnode *pno; - struct creds cr; - - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - - INTENT_INIT(&intent, INT_GETATTR, NULL, NULL); - err = _sysio_namei(_sysio_cwd, path, 0, &intent, &pno); - if (err) - SYSIO_INTERFACE_RETURN(-1, err); - err = _sysio_ldcreds(geteuid(), getegid(), &cr); - if (err < 0) - goto out; - err = - _sysio_check_permission(pno, &cr, amode); -out: - P_RELE(pno); - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef REDSTORM -#undef __access -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(access), - PREPEND(__, SYSIO_INTERFACE_NAME(access))) -#endif diff --git a/libsysio/src/chdir.c b/libsysio/src/chdir.c deleted file mode 100644 index 3f5c900..0000000 --- a/libsysio/src/chdir.c +++ /dev/null @@ -1,278 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2006 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * ############################################################################# - * # - * # This Cplant(TM) source code is the property of Sandia National - * # Laboratories. - * # - * # This Cplant(TM) source code is copyrighted by Sandia National - * # Laboratories. - * # - * # The redistribution of this Cplant(TM) source code is subject to the - * # terms of the GNU Lesser General Public License - * # (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * # - * # Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * # Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * # license for use of this work by or on behalf of the US Government. - * # Export of this program may require a license from the United States - * # Government. - * # - * ############################################################################# - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "mount.h" -#include "file.h" -#include "sysio-symbols.h" - -#ifdef DEFER_INIT_CWD -const char *_sysio_init_cwd = NULL; -#endif - -struct pnode *_sysio_cwd = NULL; - -/* - * Change to directory specified by the given pnode. - */ -int -_sysio_p_chdir(struct pnode *pno) -{ - int err; - - /* - * Revalidate the pnode, and ensure it's an accessable directory - */ - err = _sysio_p_validate(pno, NULL, NULL); - if (err) - return err; - if (!(pno->p_base->pb_ino && - S_ISDIR(pno->p_base->pb_ino->i_stbuf.st_mode))) - return -ENOTDIR; - if ((err = _sysio_permitted(pno, X_OK)) != 0) - return err; - - /* - * Release old if set. - */ - if (_sysio_cwd) - P_RELE(_sysio_cwd); - - /* - * Finally, change to the new. - */ - _sysio_cwd = pno; - - return 0; -} - -int -SYSIO_INTERFACE_NAME(chdir)(const char *path) -{ - int err; - struct pnode *pno; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - err = _sysio_namei(_sysio_cwd, path, 0, NULL, &pno); - if (err) - SYSIO_INTERFACE_RETURN(-1, err); - - err = _sysio_p_chdir(pno); - if (err) - P_RELE(pno); - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef REDSTORM -#undef __chdir -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(chdir), - PREPEND(__, SYSIO_INTERFACE_NAME(chdir))) -#endif - -/* - * Return path tracked by the path ancestor chain. - * - * If the buf pointer is NULL, a buffer large enough to hold the path - * is allocated from the heap. - */ - -static int -_sysio_p_path(struct pnode *pno, char **buf, size_t size) -{ - struct pnode *cur; - size_t len; - size_t n; - char *cp; - - cur = pno; - - if (!size && buf && *buf) - return -EINVAL; - - /* - * Walk up the tree to the root, summing the component name - * lengths and counting the vertices. - */ - len = 0; - n = 0; - do { - /* - * If this is a covering path-node then the name should be - * the *covered* nodes name, not this one unless we are at - * the root of the name-space. - */ - while (pno == pno->p_mount->mnt_root && pno != pno->p_parent ) - pno = pno->p_mount->mnt_covers; - - /* - * Add length of this component to running sum and - * account for this vertex. - */ - assert((len >= pno->p_base->pb_name.len && - (size_t )~0 - pno->p_base->pb_name.len > len) || - (size_t )~0 - len > pno->p_base->pb_name.len); - len += pno->p_base->pb_name.len; - n++; - assert(n); - pno = pno->p_parent; - } while (pno != pno->p_parent); - - if (!*buf) - size = len + n + 1; - if (len >= size || n >= size - len) - return -ERANGE; - if (!*buf) { - /* - * Allocate path buffer from the heap. - */ - *buf = malloc(size * sizeof(char)); - if (!*buf) - return -ENOMEM; - } - - /* - * Fill in the path buffer. - */ - pno = cur; - cp = *buf + len + n; - *cp = '\0'; /* NUL terminate */ - do { - /* - * If this is a covering path-node then the name should be - * the *covered* nodes name, not this one unless we are at - * the root of the name-space. - */ - while (pno == pno->p_mount->mnt_root && pno != pno->p_parent ) - pno = pno->p_mount->mnt_covers; - - /* - * Add component and separator. - */ - cp -= pno->p_base->pb_name.len; - (void )memcpy(cp, pno->p_base->pb_name.name, - pno->p_base->pb_name.len); - - *--cp = PATH_SEPARATOR; - pno = pno->p_parent; - } while (pno != pno->p_parent); - - return 0; -} - -char * -SYSIO_INTERFACE_NAME(getcwd)(char *buf, size_t size) -{ - int err; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; -#ifdef DEFER_INIT_CWD - if (!_sysio_cwd) { - struct pnode *pno; - - /* - * Can no longer defer initialization of the current working - * directory. Force namei to make it happen now. - */ - if (_sysio_namei(NULL, ".", 0, NULL, &pno) != 0) - abort(); - P_RELE(pno); - } -#endif - err = _sysio_p_path(_sysio_cwd, &buf, buf ? size : 0); - SYSIO_INTERFACE_RETURN(err ? NULL : buf, err); -} - -#ifdef __GLIBC__ -#undef __getcwd -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(getcwd), - PREPEND(__, SYSIO_INTERFACE_NAME(getcwd))) -#endif - -#if defined(PATH_MAX) && !(defined(REDSTORM)) -char * -SYSIO_INTERFACE_NAME(getwd)(char *buf) -{ - - if (!buf) { - errno = EFAULT; - return NULL; - } - - return SYSIO_INTERFACE_NAME(getcwd)(buf, PATH_MAX); -} -#endif diff --git a/libsysio/src/chmod.c b/libsysio/src/chmod.c deleted file mode 100644 index 936dec4..0000000 --- a/libsysio/src/chmod.c +++ /dev/null @@ -1,118 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "file.h" -#include "sysio-symbols.h" - -static int -do_chmod(struct pnode *pno, struct inode *ino, mode_t mode) -{ - int err; - struct intnl_stat stbuf; - unsigned mask; - - (void )memset(&stbuf, 0, sizeof(struct intnl_stat)); - stbuf.st_mode = mode & 07777; - mask = SETATTR_MODE; - err = _sysio_setattr(pno, ino, mask, &stbuf); - return err; -} - -int -SYSIO_INTERFACE_NAME(chmod)(const char *path, mode_t mode) -{ - int err; - struct pnode *pno; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - err = _sysio_namei(_sysio_cwd, path, 0, NULL, &pno); - if (err) - goto out; - err = do_chmod(pno, pno->p_base->pb_ino, mode); - P_RELE(pno); -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef REDSTORM -#undef __chmod -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(chmod), - PREPEND(__, SYSIO_INTERFACE_NAME(chmod))) -#endif - -int -SYSIO_INTERFACE_NAME(fchmod)(int fd, mode_t mode) -{ - int err; - struct file *fil; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - err = 0; - fil = _sysio_fd_find(fd); - if (!fil) { - err = -EBADF; - goto out; - } - - err = do_chmod(NULL, fil->f_ino, mode); -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef REDSTORM -#undef __fchmod -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(fchmod), - PREPEND(__, SYSIO_INTERFACE_NAME(fchmod))) -#endif diff --git a/libsysio/src/chown.c b/libsysio/src/chown.c deleted file mode 100644 index 827a815..0000000 --- a/libsysio/src/chown.c +++ /dev/null @@ -1,127 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "file.h" -#include "sysio-symbols.h" - -static int -_do_chown(struct pnode *pno, struct inode *ino, uid_t owner, gid_t group) -{ - int err; - struct intnl_stat stbuf; - unsigned mask; - - (void )memset(&stbuf, 0, sizeof(struct intnl_stat)); - mask = 0; - if (owner != (uid_t )-1) { - stbuf.st_uid = owner; - mask |= SETATTR_UID; - } - if (group != (gid_t )-1) { - stbuf.st_gid = group; - mask |= SETATTR_GID; - } - err = _sysio_setattr(pno, ino, mask, &stbuf); - return err; -} - -int -SYSIO_INTERFACE_NAME(chown)(const char *path, uid_t owner, gid_t group) -{ - int err; - struct pnode *pno; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - err = _sysio_namei(_sysio_cwd, path, 0, NULL, &pno); - if (err) - goto out; - - err = _do_chown(pno, pno->p_base->pb_ino, owner, group); - P_RELE(pno); -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef REDSTORM -#undef __chown -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(chown), - PREPEND(__, SYSIO_INTERFACE_NAME(chown))) -#endif - -int -SYSIO_INTERFACE_NAME(fchown)(int fd, uid_t owner, gid_t group) -{ - int err; - struct file *fil; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - err = 0; - fil = _sysio_fd_find(fd); - if (!fil) { - err = -EBADF; - goto out; - } - - err = _do_chown(NULL, fil->f_ino, owner, group); -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef REDSTORM -#undef __fchown -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(fchown), - PREPEND(__, SYSIO_INTERFACE_NAME(fchown))) -#endif - diff --git a/libsysio/src/dev.c b/libsysio/src/dev.c deleted file mode 100644 index 7fca77a..0000000 --- a/libsysio/src/dev.c +++ /dev/null @@ -1,172 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "dev.h" - -const struct inode_ops _sysio_nodev_ops = { - _sysio_nodev_inop_lookup, - _sysio_nodev_inop_getattr, - _sysio_nodev_inop_setattr, - _sysio_nodev_filldirentries, - _sysio_nodev_inop_mkdir, - _sysio_nodev_inop_rmdir, - _sysio_nodev_inop_symlink, - _sysio_nodev_inop_readlink, - _sysio_nodev_inop_open, - _sysio_nodev_inop_close, - _sysio_nodev_inop_link, - _sysio_nodev_inop_unlink, - _sysio_nodev_inop_rename, - _sysio_nodev_inop_read, - _sysio_nodev_inop_write, - _sysio_nodev_inop_pos, - _sysio_nodev_inop_iodone, - _sysio_nodev_inop_fcntl, - _sysio_nodev_inop_sync, - _sysio_nodev_inop_datasync, - _sysio_nodev_inop_ioctl, - _sysio_nodev_inop_mknod, -#ifdef _HAVE_STATVFS - _sysio_nodev_inop_statvfs, -#endif - _sysio_nodev_inop_gone -}; - -/* - * Support for pseudo-devices. - */ - -struct device { - const char *dev_name; - struct inode_ops dev_ops; -}; - -static struct device cdev[128]; - -int -_sysio_dev_init() -{ - unsigned major; - - major = 0; - do { - cdev[major].dev_name = NULL; - cdev[major].dev_ops = _sysio_nodev_ops; - } while (++major < sizeof(cdev) / sizeof(struct device)); - - return 0; -} - -/* - * Allocate major dev number in the dynamic range [128-255]. - */ -dev_t -_sysio_dev_alloc() -{ - unsigned short major; - static unsigned char c_major = 128; - - assert(c_major); - major = c_major++; - return SYSIO_MKDEV(major, 0); -} - -static int -dev_register(struct device devtbl[], - int major, - const char *name, - struct inode_ops *ops) -{ - - assert(major < 128); - - if (major < 0) { - major = sizeof(cdev) / sizeof(struct device); - while (major--) { - if (!devtbl[major].dev_name) - break; - } - } - if (major < 0) - return -ENXIO; /* I dunno, what? */ - if (devtbl[major].dev_name) - return -EEXIST; - devtbl[major].dev_name = name; - devtbl[major].dev_ops = *ops; - - return major; -} - -int -_sysio_char_dev_register(int major, const char *name, struct inode_ops *ops) -{ - - return dev_register(cdev, major, name, ops); -} - -struct inode_ops * -_sysio_dev_lookup(mode_t mode, dev_t dev) -{ - struct device *devtbl; - dev_t major; - - if (S_ISCHR(mode) || S_ISFIFO(mode)) - devtbl = cdev; - else - return (struct inode_ops *)&_sysio_nodev_ops; - - major = SYSIO_MAJOR_DEV(dev); - if (!(major < 128) || !devtbl[major].dev_name) - return (struct inode_ops *)&_sysio_nodev_ops; - - return &devtbl[major].dev_ops; -} diff --git a/libsysio/src/dup.c b/libsysio/src/dup.c deleted file mode 100644 index ba3d24c..0000000 --- a/libsysio/src/dup.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include - -#include "sysio.h" -#include "file.h" -#include "sysio-symbols.h" - -int -SYSIO_INTERFACE_NAME(dup2)(int oldfd, int newfd) -{ - int fd; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - if (newfd < 0) - SYSIO_INTERFACE_RETURN(-1, -EBADF); - fd = _sysio_fd_dup(oldfd, newfd, 1); - SYSIO_INTERFACE_RETURN(fd < 0 ? -1 : fd, fd < 0 ? fd : 0); -} - -#ifdef REDSTORM -#undef __dup2 -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(dup2), - PREPEND(__, SYSIO_INTERFACE_NAME(dup2))) -#endif - -int -SYSIO_INTERFACE_NAME(dup)(int oldfd) -{ - int fd; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fd = _sysio_fd_dup(oldfd, -1, 0); - SYSIO_INTERFACE_RETURN(fd < 0 ? -1 : fd, fd < 0 ? fd : 0); -} - -#ifdef __GLIBC__ -#undef __dup -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(dup), - PREPEND(__, SYSIO_INTERFACE_NAME(dup))) -#endif diff --git a/libsysio/src/fcntl.c b/libsysio/src/fcntl.c deleted file mode 100644 index 64f6a2c..0000000 --- a/libsysio/src/fcntl.c +++ /dev/null @@ -1,301 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2005 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "file.h" - -#include "sysio-symbols.h" - -#ifdef HAVE_LUSTRE_HACK -#include -#include -#endif - -#ifdef HAVE_LUSTRE_HACK -static int -_sysio_lustre_fcntl(int fd, int cmd, va_list ap, int *rtn) -{ - long arg = va_arg(ap, long); - - *rtn = syscall(SYSIO_SYS_fcntl, fd, cmd, arg); - return *rtn == -1 ? -errno : 0; -} -#endif - -static int -_sysio_fcntl_raw_call(struct inode *ino, int *r, int cmd, ...) -{ - va_list ap; - int err; - - va_start(ap, cmd); - err = ino->i_ops.inop_fcntl(ino, cmd, ap, r); - va_end(ap); - return err; -} - -/* - * Convert offsets to absolute, when appropriate, and call appropriate driver - * to complete the fcntl lock function. If successful, convert - * returned values back to appropriate form. - */ -static int -_sysio_fcntl_lock(struct file *fil, int cmd, struct _SYSIO_FLOCK *fl) -{ - struct _SYSIO_FLOCK flock; - _SYSIO_OFF_T pos; - int err; - int rtn; - - /* - * The drivers will not have a clue as to the - * current position of the file pointer. We need to - * convert relative whence values to absolute - * file adresses for them, then. - */ - flock = *fl; - switch (flock.l_whence) { - case SEEK_SET: - /* - * At least parameter check this one, too. - */ - case SEEK_CUR: - case SEEK_END: - pos = - _sysio_lseek_prepare(fil, - flock.l_start, - flock.l_whence, - _SEEK_MAX(fil)); - if (pos < 0) - return (int )pos; - flock.l_start = pos; - flock.l_whence = SEEK_SET; - break; - default: - return -EINVAL; - } - err = - _sysio_fcntl_raw_call(fil->f_ino, &rtn, cmd, &flock); - if (err) - return err; - /* - * Ugh, convert back to relative form. - */ - switch (fl->l_whence) { - case SEEK_SET: - break; - case SEEK_CUR: - fl->l_start = flock.l_start; - fl->l_start -= fil->f_pos; - break; - case SEEK_END: - fl->l_start = flock.l_start; - fl->l_start -= - fil->f_ino->i_stbuf.st_size; - break; - default: - abort(); - } - /* - * Return success. - */ - return 0; -} - -static int -_sysio_vfcntl(int fd, int cmd, va_list ap) -{ - int err; - int rtn; - struct file *fil; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - err = 0; - fil = _sysio_fd_find(fd); - if (!fil) { -#ifdef HAVE_LUSTRE_HACK - err = _sysio_lustre_fcntl(fd, cmd, ap, &rtn); - goto out; -#else - rtn = -1; - err = -EBADF; - goto out; -#endif - } - - switch (cmd) { - - case F_DUPFD: - { - long newfd; - - newfd = va_arg(ap, long); - if (newfd != (int )newfd || newfd < 0) { - rtn = -1; - err = -EBADF; - goto out; - } - rtn = _sysio_fd_dup(fd, (int )newfd, 0); - if (rtn < 0) { - err = rtn; - rtn = -1; - } - } - break; -#if !(defined(_LARGEFILE64_SOURCE) || F_GETLK64 == F_GETLK) - case F_GETLK: - case F_SETLK: - case F_SETLKW: - { - struct intnl_stat buf; - struct flock *fl; -#ifdef _LARGEFILE64_SOURCE - struct _SYSIO_FLOCK flock64; -#endif - - /* - * Refresh the cached attributes. - */ - err = - fil->f_ino->i_ops.inop_getattr(NULL, - fil->f_ino, - &buf); - if (err) { - rtn = -1; - break; - } - /* - * Copy args to a temp and normalize. - */ - fl = va_arg(ap, struct flock *); -#ifdef _LARGEFILE64_SOURCE - flock64.l_type = fl->l_type; - flock64.l_whence = fl->l_whence; - flock64.l_start = fl->l_start; - flock64.l_len = fl->l_len; - flock64.l_pid = fl->l_pid; - err = _sysio_fcntl_lock(fil, cmd, &flock64); -#else - err = _sysio_fcntl_lock(fil, cmd, fl); -#endif - if (err < 0) { - rtn = -1; - break; - } -#ifdef _LARGEFILE64_SOURCE - /* - * Copy back. Note that the fcntl_lock call - * should have ensured that no overflow was possible. - */ - fl->l_type = flock64.l_type; - fl->l_whence = flock64.l_whence; - fl->l_start = flock64.l_start; - assert(fl->l_start == flock64.l_start); - fl->l_len = flock64.l_len; - assert(fl->l_len == flock64.l_len); - fl->l_pid = flock64.l_pid; -#endif - rtn = 0; - } - break; -#endif /* !(_LARGEFILE64_SOURCE || F_GETLK64 == F_GETLK) */ -#ifdef _LARGEFILE64_SOURCE - case F_GETLK64: - case F_SETLK64: - case F_SETLKW64: - { - struct flock64 *fl64; - - fl64 = va_arg(ap, struct flock64 *); - err = _sysio_fcntl_lock(fil, cmd, fl64); - rtn = err ? -1 : 0; - } - break; -#endif - default: - err = fil->f_ino->i_ops.inop_fcntl(fil->f_ino, cmd, ap, &rtn); - break; - } - -out: - SYSIO_INTERFACE_RETURN(rtn, err); -} - -int -SYSIO_INTERFACE_NAME(fcntl)(int fd, int cmd, ...) -{ - va_list ap; - int err; - - va_start(ap, cmd); - err = _sysio_vfcntl(fd, cmd, ap); - va_end(ap); - return err; -} - -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(fcntl), - SYSIO_INTERFACE_NAME(fcntl64)) - -#ifdef __GLIBC__ -#undef __fcntl -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(fcntl), - PREPEND(__, SYSIO_INTERFACE_NAME(fcntl))) -#endif - -#ifdef BSD -#undef _fcntl -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(fcntl), - PREPEND(_, SYSIO_INTERFACE_NAME(fcntl))) -#endif diff --git a/libsysio/src/file.c b/libsysio/src/file.c deleted file mode 100644 index 9ed054e..0000000 --- a/libsysio/src/file.c +++ /dev/null @@ -1,317 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "file.h" -#include "inode.h" - -/* - * Support for file IO. - */ - -/* - * The open files table and it's size. - */ -static struct file **_sysio_oftab = NULL; -static size_t _sysio_oftab_size = 0; - -/* - * Create and initialize open file record. - */ -struct file * -_sysio_fnew(struct inode *ino, int flags) -{ - struct file *fil; - - fil = malloc(sizeof(struct file)); - if (!fil) - return NULL; - - _SYSIO_FINIT(fil, ino, flags); - F_REF(fil); - I_REF(fil->f_ino); - - return fil; -} - -/* - * Destroy open file record. - */ -void -_sysio_fgone(struct file *fil) -{ - int err; - - assert(!fil->f_ref); - assert(fil->f_ino); - err = (*fil->f_ino->i_ops.inop_close)(fil->f_ino); - assert(!err); - I_RELE(fil->f_ino); - free(fil); -} - -/* - * IO operation completion handler. - */ -void -_sysio_fcompletio(struct ioctx *ioctx, struct file *fil) -{ - _SYSIO_OFF_T off; - - if (ioctx->ioctx_cc <= 0) - return; - - assert(ioctx->ioctx_ino == fil->f_ino); - off = fil->f_pos + ioctx->ioctx_cc; - if (fil->f_pos && off <= fil->f_pos) - abort(); - fil->f_pos = off; -} - -/* - * Grow (or truncate) the file descriptor table. - */ -static int -fd_grow(size_t n) -{ - size_t count; - struct file **noftab, **filp; - - /* - * Sanity check the new size. - */ - if ((int )n < 0) - return -EMFILE; - - /* - * We never shrink the table. - */ - if (n <= _sysio_oftab_size) - return 0; - - noftab = realloc(_sysio_oftab, n * sizeof(struct file *)); - if (!noftab) - return -ENOMEM; - _sysio_oftab = noftab; - count = _sysio_oftab_size; - _sysio_oftab_size = n; - filp = _sysio_oftab + count; - n -= count; - while (n--) - *filp++ = NULL; - return 0; -} - -#ifdef ZERO_SUM_MEMORY -void -_sysio_fd_shutdown() -{ - - free(_sysio_oftab); - _sysio_oftab_size = 0; -} -#endif - -/* - * Find a free slot in the open files table greater than or equal to the - * argument. - */ -static int -find_free_fildes(int low) -{ - int n; - int err; - struct file **filp; - - for (n = low, filp = _sysio_oftab + low; - n >= 0 && (unsigned )n < _sysio_oftab_size && *filp; - n++, filp++) - ; - if (n < 0) - return -ENFILE; - if ((unsigned )n >= _sysio_oftab_size) { - err = fd_grow((unsigned )n + 1); - if (err) - return err; - filp = &_sysio_oftab[n]; - assert(!*filp); - } - - return n; -} - -/* - * Find open file record from file descriptor. - */ -struct file * -_sysio_fd_find(int fd) -{ - if (fd < 0 || (unsigned )fd >= _sysio_oftab_size) - return NULL; - - return _sysio_oftab[fd]; -} - -/* - * Close an open descriptor. - */ -int -_sysio_fd_close(int fd) -{ - struct file *fil; - - fil = _sysio_fd_find(fd); - if (!fil) - return -EBADF; - - _sysio_oftab[fd] = NULL; - - F_RELE(fil); - - return 0; -} - -/* - * Associate open file record with given file descriptor (if forced), or any - * available file descriptor if less than zero, or any available descriptor - * greater than or equal to the given one if not forced. - */ -int -_sysio_fd_set(struct file *fil, int fd, int force) -{ - int err; - struct file *ofil; - - /* - * Search for a free descriptor if needed. - */ - if (fd < 0 || !force) { - if (fd < 0) - fd = 0; - fd = find_free_fildes(fd); - if (fd < 0) - return fd; - } - - if ((unsigned )fd >= _sysio_oftab_size) { - err = fd_grow((unsigned )fd + 1); - if (err) - return err; - } - - /* - * Remember old. - */ - ofil = _sysio_fd_find(fd); - /* - * Take the entry. - */ - _sysio_oftab[fd] = fil; - if (ofil) - F_RELE(ofil); - - return fd; -} - -/* - * Duplicate old file descriptor. - * - * If the new file descriptor is less than zero, the new file descriptor - * is chosen freely. Otherwise, choose an available descriptor greater - * than or equal to the new, if not forced. Otherwise, if forced, (re)use - * the new. - */ -int -_sysio_fd_dup(int oldfd, int newfd, int force) -{ - struct file *fil; - int fd; - - if (oldfd == newfd && oldfd >= 0) - return newfd; - - fil = _sysio_fd_find(oldfd); - if (!fil) - return -EBADF; - - fd = _sysio_fd_set(fil, newfd, force); - if (fd >= 0) - F_REF(fil); - return fd; -} - -int -_sysio_fd_close_all() -{ - int fd; - struct file **filp; - - /* - * Close all open descriptors. - */ - for (fd = 0, filp = _sysio_oftab; - (size_t )fd < _sysio_oftab_size; - fd++, filp++) { - if (!*filp) - continue; - F_RELE(*filp); - *filp = NULL; - } - - /* - * Release current working directory. - */ - if (_sysio_cwd) { - P_RELE(_sysio_cwd); - _sysio_cwd = NULL; - } - - return 0; -} diff --git a/libsysio/src/file_hack.c b/libsysio/src/file_hack.c deleted file mode 100644 index e2eb79d..0000000 --- a/libsysio/src/file_hack.c +++ /dev/null @@ -1,421 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "file.h" -#include "inode.h" - -/* - * Support for file IO. - */ - -/* - * The open files table - */ -typedef struct oftab { - struct file **table; /* table array */ - size_t size; /* current table size */ - int offset; /* base fd number */ - int max; /* max size */ -} oftab_t; - -#define OFTAB_NATIVE (0) -#define OFTAB_VIRTUAL (1) - -static oftab_t _sysio_oftab[2] = { - {NULL, 0, 0, 0}, - {NULL, 0, 0, 1024*1024}, -}; - -static int native_max_fds = 0; - -static inline void init_oftab() -{ - if (!native_max_fds) { - native_max_fds = sysconf(_SC_OPEN_MAX); - if (native_max_fds <= 0) - abort(); - _sysio_oftab[OFTAB_NATIVE].max = native_max_fds - 1; - _sysio_oftab[OFTAB_VIRTUAL].offset = native_max_fds; - } -} - -static inline oftab_t *select_oftab(int fd) -{ - return & _sysio_oftab[fd >= native_max_fds || fd < 0]; -} - -/* - * Create and initialize open file record. - */ -struct file * -_sysio_fnew(struct inode *ino, int flags) -{ - struct file *fil; - - fil = malloc(sizeof(struct file)); - if (!fil) - return NULL; - - _SYSIO_FINIT(fil, ino, flags); - F_REF(fil); - I_REF(ino); - - return fil; -} - -/* - * Destroy open file record. - */ -void -_sysio_fgone(struct file *fil) -{ - int err; - - assert(!fil->f_ref); - assert(fil->f_ino); - err = (*fil->f_ino->i_ops.inop_close)(fil->f_ino); - I_RELE(fil->f_ino); - assert(!err); - free(fil); -} - -/* - * IO operation completion handler. - */ -void -_sysio_fcompletio(struct ioctx *ioctx, struct file *fil) -{ - _SYSIO_OFF_T off; - - if (ioctx->ioctx_cc <= 0) - return; - - assert(ioctx->ioctx_ino == fil->f_ino); - off = fil->f_pos + ioctx->ioctx_cc; - if (fil->f_pos && off <= fil->f_pos) - abort(); - fil->f_pos = off; -} - -/* - * Grow (or truncate) the file descriptor table. - */ -static int -fd_grow(oftab_t *oftab, size_t n) -{ - int fd; - size_t count; - struct file **noftab, **filp; - - /* - * Sanity check the new size. - */ - fd = (int )n; - if ((size_t )fd != n) - return -EMFILE; - - n++; /* index -> size */ - assert(n > oftab->size); - - if (n > oftab->max) - return -ERANGE; - - if (n < 8) - n = 8; - if (n - oftab->size < oftab->size) - n = (n + 1) * 2; - noftab = realloc(oftab->table, n * sizeof(struct file *)); - if (!noftab) - return -ENOMEM; - oftab->table = noftab; - count = oftab->size; - oftab->size = n; - if (n < count) - return 0; - filp = oftab->table + count; - n -= count; - while (n--) - *filp++ = NULL; - return 0; -} - -#ifdef ZERO_SUM_MEMORY -static void free_oftab(oftab_t *ot) -{ - if (ot->table) { - free(ot->table); - ot->size = 0; - } -} - -void -_sysio_fd_shutdown() -{ - free_oftab(&_sysio_oftab[OFTAB_NATIVE]); - free_oftab(&_sysio_oftab[OFTAB_VIRTUAL]); -} -#endif - -/* - * Find a free slot in the open files table which >= @low - * low < 0 means any - */ -static int -find_free_fildes(oftab_t *oftab, int low) - { - int n; - int err; - struct file **filp; - - if (low < 0) - low = oftab->offset; - - n = low - oftab->offset; - if (n < 0) - return -ENFILE; - - for (filp = oftab->table + n; - n < oftab->size && *filp; - n++, filp++) - ; - - if (n >= oftab->size) { - err = fd_grow(oftab, n); - if (err) - return err; - filp = &oftab->table[n]; - assert(!*filp); - } - - return oftab->offset + n; -} - -/* - * Find open file record from file descriptor. - * clear this entry if 'clear' is non-zero - */ -static struct file * -__sysio_fd_get(int fd, int clear) -{ - oftab_t *oftab; - struct file *file; - - init_oftab(); - - if (fd < 0) - return NULL; - - oftab = select_oftab(fd); - if (!oftab->table || fd >= oftab->offset + oftab->size) - return NULL; - - file = oftab->table[fd - oftab->offset]; - if (clear) - oftab->table[fd - oftab->offset] = NULL; - - return file; -} - -/* - * Find open file record from file descriptor. - */ -struct file * -_sysio_fd_find(int fd) -{ - return __sysio_fd_get(fd, 0); -} - -/* - * Close an open descriptor. - */ -int -_sysio_fd_close(int fd) -{ - struct file *fil; - - fil = __sysio_fd_get(fd, 1); - if (!fil) - return -EBADF; - - F_RELE(fil); - - return 0; -} - -/* - * Associate open file record with given file descriptor (if forced), or any - * available file descriptor if less than zero, or any available descriptor - * greater than or equal to the given one if not forced. - */ -int -_sysio_fd_set(struct file *fil, int fd, int force) -{ - int err; - struct file *ofil; - oftab_t *oftab; - - if (force && fd < 0) - abort(); - - init_oftab(); - - oftab = select_oftab(fd); - - /* - * Search for a free descriptor if needed. - */ - if (!force) { - fd = find_free_fildes(oftab, fd); - if (fd < 0) - return fd; - } - - if (fd - oftab->offset >= oftab->size) { - err = fd_grow(oftab, fd - oftab->offset); - if (err) - return err; - } - - /* - * Remember old. - */ - ofil = __sysio_fd_get(fd, 1); - if (ofil) { - /* FIXME sometimes we could intercept open/socket to create - * a fd, but missing close()? currently we have this problem - * with resolv lib. as a workaround simply destroy the file - * struct here. And this hack will break the behavior of - * DUPFD. - */ - if (fd >= 0 && oftab == &_sysio_oftab[0]) - free(ofil); - else - F_RELE(ofil); - } - - oftab->table[fd - oftab->offset] = fil; - - return fd; -} - -/* - * Duplicate old file descriptor. - * - * If the new file descriptor is less than zero, the new file descriptor - * is chosen freely. Otherwise, choose an available descriptor greater - * than or equal to the new, if not forced. Otherwise, if forced, (re)use - * the new. - */ -int -_sysio_fd_dup(int oldfd, int newfd, int force) -{ - struct file *fil; - int fd; - - init_oftab(); - - if (oldfd == newfd && oldfd >= 0) - return newfd; - - fil = _sysio_fd_find(oldfd); - if (!fil) - return -EBADF; - - /* old & new must belong to the same oftab */ - if (select_oftab(oldfd) != select_oftab(newfd)) - return -EINVAL; - - fd = _sysio_fd_set(fil, newfd, force); - if (fd >= 0) - F_REF(fil); - return fd; -} - -void -_sysio_oftable_close_all(oftab_t *oftab) -{ - struct file **filp; - int fd; - - for (fd = 0, filp = oftab->table; - (size_t )fd < oftab->size; - fd++, filp++) { - if (!*filp) - continue; - F_RELE(*filp); - *filp = NULL; - } -} - -int -_sysio_fd_close_all() -{ - /* Close all open descriptors */ - _sysio_oftable_close_all(&_sysio_oftab[OFTAB_VIRTUAL]); - /* FIXME: libsysio does not currently perform enough cleanup of - * open files to allow __liblustre_cleanup_() to safely call - * unmount(). See the related FIXME comment in that function - * for details. The following disabled code is left in place to - * document the solution that was originally under consideration - * but never fully implemented. */ -#if 0 - _sysio_oftable_close_all(&_sysio_oftab[OFTAB_NATIVE]); -#endif - - /* Release current working directory */ - if (_sysio_cwd) { - P_RELE(_sysio_cwd); - _sysio_cwd = NULL; - } - - return 0; -} diff --git a/libsysio/src/fs.c b/libsysio/src/fs.c deleted file mode 100644 index 0c9bd52..0000000 --- a/libsysio/src/fs.c +++ /dev/null @@ -1,162 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "fs.h" -#include "inode.h" - -/* - * File system abstractipon support. - */ - -/* - * The "file system switch". - */ -static LIST_HEAD(, fsswent) fsswitch = { NULL }; - -/* - * Lookup named entry in the switch. - */ -struct fsswent * -_sysio_fssw_lookup(const char *name) -{ - struct fsswent *fssw; - - if (!fsswitch.lh_first) - return NULL; - - fssw = fsswitch.lh_first; - do { - if (strcmp(fssw->fssw_name, name) == 0) - return fssw; - fssw = fssw->fssw_link.le_next; - } while (fssw); - return NULL; -} - -/* - * Register driver. - */ -int -_sysio_fssw_register(const char *name, struct fssw_ops *ops) -{ - struct fsswent *fssw; - - fssw = _sysio_fssw_lookup(name); - if (fssw) - return -EEXIST; - - fssw = malloc(sizeof(struct fsswent) + strlen(name) + 1); - if (!fssw) - return -ENOMEM; - fssw->fssw_name = (char *)fssw + sizeof(struct fsswent); - (void )strcpy((char *)fssw->fssw_name, name); - fssw->fssw_ops = *ops; - - LIST_INSERT_HEAD(&fsswitch, fssw, fssw_link); - - return 0; -} - -#ifdef ZERO_SUM_MEMORY -/* - * Shutdown - */ -void -_sysio_fssw_shutdown() -{ - struct fsswent *fssw; - - while ((fssw = fsswitch.lh_first)) { - LIST_REMOVE(fssw, fssw_link); - free(fssw); - } -} -#endif - -/* - * Allocate and initialize a new file system record. - */ -struct filesys * -_sysio_fs_new(struct filesys_ops *ops, unsigned flags, void *private) -{ - struct filesys *fs; - - fs = malloc(sizeof(struct filesys)); - if (!fs) - return NULL; - FS_INIT(fs, flags, ops, private); - return fs; -} - -/* - * Dispose of given file system record. - */ -void -_sysio_fs_gone(struct filesys *fs) -{ - size_t n; - struct itable_entry *head; - - if (fs->fs_ref) - abort(); - n = FS_ITBLSIZ; - do { - head = &fs->fs_itbl[--n]; - while (head->lh_first) - _sysio_i_gone(head->lh_first); - } while (n); - if (n) - abort(); - - (*fs->fs_ops.fsop_gone)(fs); - free(fs); -} diff --git a/libsysio/src/fsync.c b/libsysio/src/fsync.c deleted file mode 100644 index dda9904..0000000 --- a/libsysio/src/fsync.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "file.h" -#include "inode.h" - -int -SYSIO_INTERFACE_NAME(fsync)(int fd) -{ - struct file *fil; - int err; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!(fil && fil->f_ino)) - SYSIO_INTERFACE_RETURN(-1, -EBADF); - err = (*fil->f_ino->i_ops.inop_sync)(fil->f_ino); - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -int -SYSIO_INTERFACE_NAME(fdatasync)(int fd) -{ - struct file *fil; - int err; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!(fil && fil->f_ino)) - SYSIO_INTERFACE_RETURN(-1, -EBADF); - err = (*fil->f_ino->i_ops.inop_datasync)(fil->f_ino); - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} diff --git a/libsysio/src/getdirentries.c b/libsysio/src/getdirentries.c deleted file mode 100644 index 151829d..0000000 --- a/libsysio/src/getdirentries.c +++ /dev/null @@ -1,252 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2004 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#ifdef __GLIBC__ -#include -#endif -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "file.h" -#include "sysio-symbols.h" - -#ifndef __GNUC__ -#define __restrict -#endif - -static ssize_t -filldirents(struct file *fil, - char *buf, size_t nbytes, - _SYSIO_OFF_T *__restrict basep) -{ - _SYSIO_OFF_T opos; - ssize_t cc; - - if (!S_ISDIR(fil->f_ino->i_stbuf.st_mode)) - return -ENOTDIR; - - opos = fil->f_pos; - cc = - (*fil->f_ino->i_ops.inop_filldirentries)(fil->f_ino, - &fil->f_pos, - buf, nbytes); - if (cc < 0) - return cc; - *basep = opos; - return cc; -} - -static ssize_t -PREPEND(_, SYSIO_INTERFACE_NAME(getdirentries64))(int fd, - char *buf, - size_t nbytes, - _SYSIO_OFF_T * __restrict - basep) -{ - struct file *fil; - ssize_t cc; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - - fil = _sysio_fd_find(fd); - if (!(fil && fil->f_ino)) { - SYSIO_INTERFACE_RETURN(-1, -EBADF); - } - - cc = filldirents(fil, buf, nbytes, basep); - SYSIO_INTERFACE_RETURN(cc < 0 ? -1 : cc, cc < 0 ? (int )cc : 0); -} - -#ifdef _LARGEFILE64_SOURCE -#undef getdirentries64 -sysio_sym_strong_alias(PREPEND(_, SYSIO_INTERFACE_NAME(getdirentries64)), - SYSIO_INTERFACE_NAME(getdirentries64)) -#endif - -#undef getdirentries - -#ifndef DIRENT64_IS_NATURAL - -#ifndef EOVERFLOW -#define EOVERFLOW ERANGE -#endif - -#ifdef _DIRENT_HAVE_D_NAMLEN -#define _namlen(dp) ((dp)->d_namlen) -#else -#define _namlen(dp) (strlen((dp)->d_name)) -#endif - -#ifndef _rndup -#define _rndup(n, boundary) \ - ((((n) + (boundary) - 1 ) / (boundary)) * (boundary)) -#endif - -#define _dbaselen ((size_t )&((struct dirent *)0)->d_name[0]) - -#ifdef __GLIBC__ -#define _dreclen(namlen) \ - ((_dbaselen + (namlen) + __alignof__ (struct dirent)) & \ - ~(__alignof__ (struct dirent) - 1)) -#else /* !defined(__GLIBC__) */ -#define _dreclen(namlen) \ - _rndup(_dbaselen + (namlen) + 1, sizeof(int)) -#endif - -#ifndef BSD -ssize_t -SYSIO_INTERFACE_NAME(getdirentries)(int fd, - char *buf, - size_t nbytes, - off_t * __restrict basep) -#else -int -SYSIO_INTERFACE_NAME(getdirentries)(int fd, - char *buf, - int nbytes, - long * __restrict basep) -#endif -{ - struct file *fil; - _SYSIO_OFF_T b; - ssize_t cc, count; - struct dirent64 *d64p, d64; - struct dirent *dp; - size_t n, reclen; - void *p; - char *cp; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - - fil = _sysio_fd_find(fd); - if (!(fil && fil->f_ino)) { - SYSIO_INTERFACE_RETURN(-1, -EBADF); - } - - count = cc = filldirents(fil, buf, nbytes, &b); - d64p = (void *)buf; - dp = (void *)buf; - reclen = 0; - while (cc > 0) { - n = _namlen(d64p); - reclen = _dreclen(n); - d64.d_ino = d64p->d_ino; - d64.d_off = d64p->d_off; - d64.d_type = d64p->d_type; - d64.d_reclen = d64p->d_reclen; - /* - * Copy name first. - */ - (void )memcpy(dp->d_name, d64p->d_name, n); - /* - * Then, the rest. - */ - dp->d_ino = d64.d_ino; - dp->d_off = d64.d_off; - if (dp->d_ino != d64.d_ino || - dp->d_off != d64.d_off) { - /* - * If conversion failure then we are done. - */ - if (cc == count) { - /* - * Couldn't process any entries. We return - * the error now. - */ - cc = - EOVERFLOW; - } - break; - } - fil->f_pos = dp->d_off; - dp->d_type = d64.d_type; - dp->d_reclen = reclen; - /* - * Fill the remainder with zeros. - */ - p = (char *)dp + dp->d_reclen; -#ifdef HAVE_D_NAMLEN - dp->d_namlen = n; -#endif - cp = dp->d_name + n; - do { - *cp++ = 0; - } while (cp < (char *)p); - /* - * Advance. - */ - dp = p; - cc -= d64.d_reclen; - d64p = (struct dirent64 *)((char *)d64p + d64.d_reclen); - } - - if (cc < 0) - SYSIO_INTERFACE_RETURN(-1, cc); - cc = (char *)dp - buf; - *basep = b; - SYSIO_INTERFACE_RETURN(cc, 0); -} -#else /* !defined(DIRENT64_IS_NATURAL) */ -sysio_sym_strong_alias(PREPEND(_, SYSIO_INTERFACE_NAME(getdirentries64), - SYSIO_INTERFACE_NAME(getdirentries))) -#endif - -#ifdef REDSTORM -#undef __getdirentries -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(getdirentries), - PREPEND(__, SYSIO_INTERFACE_NAME(getdirentries))) -#endif -#if defined(BSD) || defined(REDSTORM) -#undef _getdirentries -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(getdirentries), - PREPEND(_, SYSIO_INTERFACE_NAME(getdirentries))) -#endif diff --git a/libsysio/src/init.c b/libsysio/src/init.c deleted file mode 100644 index 6dc4f29..0000000 --- a/libsysio/src/init.c +++ /dev/null @@ -1,1103 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2006 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#ifdef __linux__ -#define _BSD_SOURCE -#endif - -#ifdef SYSIO_TRACING -#include -#endif -#include -#if defined(_BSD_SOURCE) || defined(SYSIO_TRACING) -#include -#endif -#include -#include -#include -#ifdef SYSIO_TRACING -#include -#endif -#include -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "xtio.h" -#ifdef SYSIO_TRACING -#include "native.h" -#endif -#include "inode.h" -#include "fs.h" -#include "mount.h" -#include "file.h" -#include "dev.h" - -#ifdef STDFD_DEV -#include "stdfd.h" -#endif - -#ifdef SYSIO_TRACING - -/* - * Tracing callback record. - */ -struct trace_callback { - TAILQ_ENTRY(trace_callback) links; /* trace list links */ - void (*f)(const char *file, /* callback function */ - const char *func, - int line, - void *data); - void *data; /* callback data */ - void (*destructor)(void *data); /* data destructor */ -}; - -/* - * Initialize a tracing callback record. - */ -#define TCB_INIT(__tcb, __f, __d, __destroy) \ - do { \ - (__tcb)->f = (__f); \ - (__tcb)->data = (__d); \ - (__tcb)->destructor = (__destroy); \ - } while (0) - -/* - * Trace queue head record. - */ -TAILQ_HEAD(trace_q, trace_callback); - -/* - * The entry and exit queue heads, and queue pointers. - */ -static struct trace_q _sysio_entry_trace_head; -void *_sysio_entry_trace_q = &_sysio_entry_trace_head; -static struct trace_q _sysio_exit_trace_head; -void *_sysio_exit_trace_q = &_sysio_exit_trace_head; -#endif - -/* - * White space characters. - */ -#define IGNORE_WHITE " \t\r\n" - -/* - * Check if long overflows integer range. - */ -#if LONG_MAX <= INT_MAX -#define _irecheck(_l, _e) \ - ((_l) == LONG_MAX && (_e) == ERANGE) -#else -#define _irecheck(_l, _e) \ - ((_l) > INT_MAX) -#endif - -/* - * In sysio_init we'll allow simple comments, strings outside {} - * delimited by COMMENT_INTRO, and '\n' or '\0' - */ -#define COMMENT_INTRO '#' - -/* - * In sysio_init we'll allow simple comments, strings outside {} - * delimited by COMMENT_INTRO, and '\n' or '\0' - */ -#define COMMENT_INTRO '#' - -/* - * Sysio library initialization. Must be called before anything else in the - * library. - */ -int -_sysio_init() -{ - int err; -#ifdef WITH_SOCKETS - extern int _sysio_sockets_init(void); -#endif - -#ifdef SYSIO_TRACING - /* - * Initialize tracing callback queues. - */ - TAILQ_INIT(&_sysio_entry_trace_head); - TAILQ_INIT(&_sysio_exit_trace_head); -#endif - - err = _sysio_ioctx_init(); - if (err) - goto error; - err = _sysio_i_init(); - if (err) - goto error; - err = _sysio_mount_init(); - if (err) - goto error; - - err = _sysio_dev_init(); - if (err) - goto error; -#ifdef STDFD_DEV - err = _sysio_stdfd_init(); - if (err) - goto error; -#endif -#ifdef WITH_SOCKETS - err = _sysio_sockets_init(); - if (err) - goto error; -#endif - - goto out; -error: - errno = -err; -out: - /* - * Unlike all other _sysio routines, this one returns with errno - * set. It also returns the error, as usual. - */ - return err; -} - -/* - * Sysio library shutdown. - */ -void -_sysio_shutdown() -{ - - if (!(_sysio_fd_close_all() == 0 && - _sysio_unmount_all() == 0)) - abort(); - -#ifdef ZERO_SUM_MEMORY - _sysio_fd_shutdown(); - _sysio_i_shutdown(); - _sysio_fssw_shutdown(); - _sysio_access_shutdown(); - free(incore_dir_template); -#ifdef SYSIO_TRACING - { - struct trace_callback *tcb; - - /* - * Empty the trace queues and free the entries. - */ - while ((tcb = _sysio_entry_trace_head.tqh_first) != NULL) - _sysio_remove_trace(&_sysio_entry_trace_head, tcb); - while ((tcb = _sysio_exit_trace_head.tqh_first) != NULL) - _sysio_remove_trace(&_sysio_exit_trace_head, tcb); - } -#endif -#endif -} - -#ifdef SYSIO_TRACING - -#if !(defined(_HAVE_ASPRINTF) && _HAVE_ASPRINTF) -/* - * Print a string to allocated memory. - */ -static int -vasprintf(char **strp, const char *fmt, va_list ap) -{ - size_t siz; - int oerrno; - char *s; - va_list aq; - int n; - - siz = 50; - oerrno = errno; - if (!(s = malloc(siz))) { - errno = oerrno; - return -1; - } - for (;;) { - va_copy(aq, ap); - n = vsnprintf (s, siz, fmt, aq); - va_end(aq); - if (n > -1 && (size_t )n < siz) - break; - if (n > -1) /* glibc 2.1 */ - siz = n+1; /* precise */ - else /* glibc 2.0 */ - siz *= 2; /* twice the old */ - if (!(s = realloc (s, siz))) - break; - } - *strp = s; - errno = oerrno; - return n; -} - -#if 0 -static int -asprintf(char **strp, const char *fmt, ...) -{ - va_list ap; - int n; - - va_start(ap, fmt); - n = vasprintf(strp, fmt, ap); - va_end(ap); - return n; -} -#endif -#endif /* !(defined(_HAVE_ASPRINTF) && _HAVE_ASPRINTF) */ - -static void -_sysio_cwrite(const char *buf, size_t len) -{ - int oerrno; - - oerrno = errno; - (void )syscall(SYSIO_SYS_write, STDERR_FILENO, buf, len); - errno = oerrno; -} - -/* - * Console printf. - */ -void -_sysio_cprintf(const char *fmt, ...) -{ - va_list ap; - int len; - char *buf; - - va_start(ap, fmt); - buf = NULL; - len = vasprintf(&buf, fmt, ap); - va_end(ap); - if (len < 0) - return; - _sysio_cwrite(buf, len); - free(buf); -} - -/* - * Register a trace callback. - * - * The pointer to the trace record is returned. - */ -void * -_sysio_register_trace(void *q, - void (*f)(const char *file, - const char *func, - int line, - void *data), - void *data, - void (*destructor)(void *data)) -{ - struct trace_callback *tcb; - - tcb = malloc(sizeof(struct trace_callback)); - if (!tcb) - return NULL; - TCB_INIT(tcb, f, data, destructor); - TAILQ_INSERT_TAIL((struct trace_q *)q, tcb, links); - return tcb; -} - -/* - * Remove a registered trace callback. - */ -void -_sysio_remove_trace(void *q, void *p) -{ - struct trace_callback *tcb; - - tcb = (struct trace_callback *)p; - - if (tcb->destructor) - (*tcb->destructor)(tcb->data); - TAILQ_REMOVE((struct trace_q *)q, tcb, links); - free(tcb); -} - -void -/* - * Run a trace queue, making all the callbacks. - */ -_sysio_run_trace_q(void *q, - const char *file, - const char *func, - int line) -{ - struct trace_callback *tcb; - - tcb = ((struct trace_q *)q)->tqh_first; - while (tcb) { - (*tcb->f)(file, func, line, tcb->data); - tcb = tcb->links.tqe_next; - } -} - -static void -_sysio_trace_entry(const char *file __IS_UNUSED, - const char *func, - int line __IS_UNUSED, - void *data __IS_UNUSED) -{ - - _sysio_cprintf("+ENTER+ %s\n", func); -} - -static void -_sysio_trace_exit(const char *file __IS_UNUSED, - const char *func, - int line __IS_UNUSED, - void *data __IS_UNUSED) -{ - - _sysio_cprintf("+EXIT+ %s\n", func); -} -#endif /* defined(SYSIO_TRACING) */ - -/* - * (kind of)Duplicates strtok function. - * - * Given a buffer, returns the longest string - * that does not contain any delim characters. Will - * remove ws and any characters in the ignore string. - * Returns the token. - * - * The parameter controlling acceptance controls whether a positive - * match for some delimiter be made or not. If set, then either a delimiter - * or NUL character is success. - * - */ -const char * -_sysio_get_token(const char *buf, - int accepts, - const char *delim, - const char *ignore, - char *tbuf) -{ - char c; - int escape, quote; - - /* - * Find the first occurance of delim, recording how many - * characters lead up to it. Ignore indicated characters. - */ - escape = quote = 0; - while ((c = *buf) != '\0') { - buf++; - if (!escape) { - if (c == '\\') { - escape = 1; - continue; - } - if (c == '\"') { - quote ^= 1; - continue; - } - if (!quote) { - if (strchr(delim, c) != NULL) { - accepts = 1; - break; - } - if (strchr(ignore, c) != NULL) - continue; - } - } else - escape = 0; - *tbuf++ = c; - } - if (!accepts) - return NULL; - *tbuf = '\0'; /* NUL term */ - return buf; -} - -/* - * Parse and record named arguments given as `name = value', comma-separated - * pairs. - * - * NB: Alters the passed buffer. - */ -char * -_sysio_get_args(char *buf, struct option_value_info *vec) -{ - char *nxt; - char *name, *value; - struct option_value_info *v; - - for (;;) { - nxt = - (char *)_sysio_get_token(buf, - 1, - "=,", - IGNORE_WHITE, - name = buf); - if (!nxt || - (nxt != buf && *name == '\0' && buf + strlen(buf) == nxt)) { - buf = NULL; - break; - } - if (*name == '\0') - break; - buf = - (char *)_sysio_get_token(nxt, - 1, - ",", - IGNORE_WHITE, - value = nxt); - if (*value == '\0') - value = NULL; - for (v = vec; v->ovi_name; v++) - if (strcmp(v->ovi_name, name) == 0) - break; - if (!v->ovi_name) - return NULL; - v->ovi_value = value; - } - - return buf; -} - -static int -parse_mm(const char *s, dev_t *devp) -{ - unsigned long ul; - char *cp; - dev_t dev; - - ul = strtoul(s, &cp, 0); - if (*cp != '+' || ul > USHRT_MAX) - return -EINVAL; - dev = ul << 16; - s = (const char *)++cp; - ul = strtoul(s, &cp, 0); - if (*cp != '\0' || ul > USHRT_MAX) - return -EINVAL; - dev |= ul & 0xffff; - *devp = dev; - return 0; -} - -/* - * Performs the creat command for the namespace assembly - * - * NB: Alters the passed buffer. - */ -static int -do_creat(char *args) -{ - size_t len; - struct option_value_info v[] = { - { "ft", NULL }, /* file type */ - { "nm", NULL }, /* name */ - { "pm", NULL }, /* permissions */ - { "ow", NULL }, /* owner */ - { "gr", NULL }, /* group */ - { "mm", NULL }, /* major + minor */ - { "str", NULL }, /* file data */ - { NULL, NULL } - }; - const char *cp; - long perms; - long owner, group; - struct pnode *dir, *pno; - mode_t mode; - struct intent intent; - dev_t dev; - int err; - enum { - CREATE_DIR = 1, - CREATE_CHR = 2, - CREATE_BLK = 3, - CREATE_FILE = 4 - } op; - int intent_mode; - struct inode *ino; - int i; - - len = strlen(args); - if (_sysio_get_args(args, v) - args != (ssize_t )len || - !(v[0].ovi_value && - v[1].ovi_value && - v[2].ovi_value)) - return -EINVAL; - perms = strtol(v[2].ovi_value, (char **)&cp, 0); - if (*cp || - perms < 0 || - (perms == LONG_MAX && errno == ERANGE) || - ((unsigned)perms & ~07777)) - return -EINVAL; - if (v[3].ovi_value) { - owner = strtol(v[3].ovi_value, (char **)&cp, 0); - if (*cp || - ((owner == LONG_MIN || owner == LONG_MAX) - && errno == ERANGE)) - return -EINVAL; - } else - owner = getuid(); - if (v[4].ovi_value) { - group = strtol(v[4].ovi_value, (char **)&cp, 0); - if (*cp || - ((group == LONG_MIN || group == LONG_MAX) && - errno == ERANGE)) - return -EINVAL; - } else - group = getegid(); - - if (!(dir = _sysio_cwd) && !(dir = _sysio_root)) - return -ENOENT; - - /* - * Init, get the operation, setup the intent. - */ - err = 0; - mode = perms; - op = 0; - if (strcmp(v[0].ovi_value, "dir") == 0) { - op = CREATE_DIR; - INTENT_INIT(&intent, INT_CREAT, &mode, NULL); - } else if (strcmp(v[0].ovi_value, "chr") == 0) { - op = CREATE_CHR; - mode |= S_IFCHR; - INTENT_INIT(&intent, INT_CREAT, &mode, NULL); - if (!(v[5].ovi_value && parse_mm(v[5].ovi_value, &dev) == 0)) - err = -EINVAL; - } else if (strcmp(v[0].ovi_value, "blk") == 0) { - op = CREATE_BLK; - mode |= S_IFBLK; - INTENT_INIT(&intent, INT_CREAT, &mode, NULL); - if (!(v[5].ovi_value && parse_mm(v[5].ovi_value, &dev) == 0)) - err = -EINVAL; - } else if (strcmp(v[0].ovi_value, "file") == 0) { - op = CREATE_FILE; - intent_mode = O_CREAT|O_EXCL; - INTENT_INIT(&intent, INT_CREAT, &mode, &intent_mode); - } else - err = -EINVAL; - if (err) - return err; - - /* - * Lookup the given path. - */ - err = - _sysio_namei(dir, - v[1].ovi_value, - ND_NEGOK|ND_NOPERMCHECK, - &intent, - &pno); - if (err) - return err; - - /* - * Perform. - */ - switch (op) { - case CREATE_DIR: - err = _sysio_mkdir(pno, mode); - break; - case CREATE_CHR: - case CREATE_BLK: - err = _sysio_mknod(pno, mode, dev); - break; - case CREATE_FILE: - err = _sysio_open(pno, O_CREAT|O_EXCL, mode); - if (err) - break; - ino = pno->p_base->pb_ino; - if (v[6].ovi_value) { - struct iovec iovec; - struct intnl_xtvec xtvec; - struct ioctx io_context; - - /* - * Deposit optional file content. - */ - iovec.iov_base = v[6].ovi_value; - iovec.iov_len = strlen(v[6].ovi_value); - xtvec.xtv_off = 0; - xtvec.xtv_len = iovec.iov_len; - IOCTX_INIT(&io_context, - 1, - 1, - ino, - &iovec, 1, - &xtvec, 1); - _sysio_ioctx_enter(&io_context); - err = - (*ino->i_ops.inop_write)(pno->p_base->pb_ino, - &io_context); - if (!err) { - ssize_t cc; - - cc = _sysio_ioctx_wait(&io_context); - if (cc < 0) - err = cc; - else if ((size_t )cc != iovec.iov_len) - err = -EIO; /* huh? */ - } else - _sysio_ioctx_complete(&io_context); - } - i = (*ino->i_ops.inop_close)(ino); - if (!err) - err = i; - break; - default: - abort(); - } - - P_RELE(pno); - return err; -} - -/* - * Do mount. - * - * NB: The passed buffer is altered. - */ -static int -do_mnt(char *args) -{ - size_t len; - struct option_value_info v[] = { - { "dev", NULL }, /* source (type:dev) */ - { "dir", NULL }, /* target dir */ - { "fl", NULL }, /* flags */ - { "da", NULL }, /* mount data */ - { NULL, NULL } - }; - char *ty, *name; - unsigned long flags; - struct pnode *dir; - - len = strlen(args); - if (_sysio_get_args(args, v) - args != (ssize_t )len || - !(v[0].ovi_value && v[1].ovi_value)) - return -EINVAL; - ty = - (char *)_sysio_get_token(v[0].ovi_value, - 1, - ":", - "", - name = v[0].ovi_value); - flags = 0; - if (v[2].ovi_value) { - char *cp; - - /* - * Optional flags. - */ - flags = strtoul(v[2].ovi_value, &cp, 0); - if (*cp || (flags == ULONG_MAX && errno == ERANGE)) - return -EINVAL; - } - - if (strlen(v[1].ovi_value) == 1 && v[1].ovi_value[0] == PATH_SEPARATOR) { - /* - * Aha! It's root they want. Have to do that special. - */ - return _sysio_mount_root(ty, name, flags, v[3].ovi_value); - } - - if (!(dir = _sysio_cwd) && !(dir = _sysio_root)) - return -ENOENT; - return _sysio_mount(dir, - ty, - v[1].ovi_value, - name, - flags, - v[3].ovi_value); -} - - -#if 0 -/* - * Chdir - * - * NB: Alters the passed buffer. - */ -static int -do_cd(char *args) -{ - size_t len; - struct option_value_info v[] = { - { "dir", NULL }, /* directory */ - { NULL, NULL } - }; - int err; - struct pnode *dir, *pno; - - len = strlen(args); - if (_sysio_get_args(args, v) - args != (ssize_t )len || !v[0].ovi_value) - return -EINVAL; - - if (!(dir = _sysio_cwd) && !(dir = _sysio_root)) { - /* - * We have no namespace yet. They really need to give us - * something to work with. - */ - return -ENOENT; - } - err = _sysio_namei(dir, v[0].ovi_value, 0, NULL, &pno); - if (err) - return err; - err = _sysio_p_chdir(pno); - if (err) - P_RELE(pno); - return err; -} -#endif - -/* - * Does a chmod - * - * NB: Alters passed buffer. - */ -static int -do_chmd(char *args) -{ - size_t len; - struct option_value_info v[] = { - { "src", NULL }, /* path */ - { "pm", NULL }, /* perms */ - { NULL, NULL } - }; - long perms; - char *cp; - struct intnl_stat stbuf; - int err; - struct pnode *dir, *pno; - - len = strlen(args); - if (_sysio_get_args(args, v) - args != (ssize_t )len || - !(v[0].ovi_value && v[1].ovi_value)) - return -EINVAL; - perms = strtol(v[1].ovi_value, &cp, 0); - if (*cp || - perms < 0 || - (perms == LONG_MAX && errno == ERANGE) || - ((unsigned)perms & ~07777)) - return -EINVAL; - (void )memset(&stbuf, 0, sizeof(stbuf)); - stbuf.st_mode = (mode_t)perms; - - if (!(dir = _sysio_cwd) && !(dir = _sysio_root)) - return -ENOENT; - err = _sysio_namei(dir, v[0].ovi_value, ND_NOPERMCHECK, NULL, &pno); - if (err) - return err; - err = _sysio_setattr(pno, pno->p_base->pb_ino, SETATTR_MODE, &stbuf); - P_RELE(pno); - - return err; -} - -static int -do_open(char *args) -{ - size_t len; - struct option_value_info v[] = { - { "nm", NULL }, /* path */ - { "fd", NULL }, /* fildes */ - { "m", NULL }, /* mode */ - { NULL, NULL } - }; - char *cp; - long l; - int fd; - unsigned long ul; - mode_t m; - struct pnode *dir, *pno; - struct intent intent; - int err; - struct file *fil; - - len = strlen(args); - if (_sysio_get_args(args, v) - args != (ssize_t )len || - !(v[0].ovi_value && v[1].ovi_value && v[2].ovi_value)) - return -EINVAL; - l = strtol(v[1].ovi_value, (char **)&cp, 0); - if (*cp || l < 0 || _irecheck(l, errno)) - return -EINVAL; - fd = (int )l; - ul = strtoul(v[1].ovi_value, (char **)&cp, 0); - if (*cp || - (ul == ULONG_MAX && errno == ERANGE)) - return -EINVAL; - m = (mode_t )ul & (O_RDONLY|O_WRONLY|O_RDWR); - - if (!(dir = _sysio_cwd) && !(dir = _sysio_root)) - return -ENOENT; - INTENT_INIT(&intent, INT_OPEN, &m, NULL); - pno = NULL; - err = _sysio_namei(dir, v[0].ovi_value, ND_NOPERMCHECK, &intent, &pno); - if (err) - return err; - fil = NULL; - do { - err = _sysio_open(pno, m, 0); - if (err) - break; - fil = _sysio_fnew(pno->p_base->pb_ino, m); - if (!fil) { - err = -ENOMEM; - break; - } - err = _sysio_fd_set(fil, fd, 1); - if (err < 0) - break; - P_RELE(pno); - return 0; - } while (0); - if (fil) - F_RELE(fil); - if (pno) - P_RELE(pno); - return err; -} - -/* - * Execute the given cmd. - * - * NB: Buf is altered. - */ -static int -do_command(char *buf) -{ - size_t len; - char *args, *cmd; - - len = strlen(buf); - args = (char *)_sysio_get_token(buf, 1, ",", IGNORE_WHITE, cmd = buf); - if (args) { - if (strcmp("creat", cmd) == 0) - return do_creat(args); - if (strcmp("mnt", cmd) == 0) - return do_mnt(args); -#if 0 - if (strcmp("cd", cmd) == 0) - return do_cd(args); -#endif - if (strcmp("chmd", cmd) == 0) - return do_chmd(args); - if (strcmp("open", cmd) == 0) - return do_open(args); - } - return -EINVAL; -} - -#ifdef SYSIO_TRACING -/* - * Set/Unset tracing. - */ -static int -_sysio_boot_tracing(const char *arg) -{ - long l; - char *cp; - static struct trace_callback - *entcb = NULL, - *exitcb = NULL; - - l = 0; - if (arg) { - l = strtol(arg, (char **)&cp, 0); - if (*cp || !(l == 0 || l == 1)) - return -EINVAL; - } - if (l) { - if (entcb == NULL) - entcb = - _sysio_register_trace(_sysio_entry_trace_q, - _sysio_trace_entry, - NULL, - NULL); - if (entcb == NULL) - return -errno; - if (exitcb == NULL) - exitcb = - _sysio_register_trace(_sysio_exit_trace_q, - _sysio_trace_exit, - NULL, - NULL); - if (exitcb == NULL) - return -errno; - } else { - if (entcb != NULL) - _sysio_remove_trace(_sysio_entry_trace_q, entcb); - entcb = NULL; - if (exitcb != NULL) - _sysio_remove_trace(_sysio_exit_trace_q, exitcb); - exitcb = NULL; - } - return 0; -} -#endif - -/* - * Initialize the namespace. - */ -static int -_sysio_boot_namespace(const char *arg) -{ - char c, *tok; - ssize_t len; - int err; - unsigned count; - /* - * Allocate token buffer. - */ - len = strlen(arg); - tok = malloc(len ? len : 1); - if (!tok) - return -ENOMEM; - err = 0; - count = 0; - while (1) { - /* - * Discard leading white space. - */ - while ((c = *arg) != '\0' && strchr(IGNORE_WHITE, c)) - arg++; - if (COMMENT_INTRO == c) { - /* - * Discard comment. - */ - while (*arg && (*arg != '\n')) { - ++arg; - } - continue; - } - - if (c == '\0') - break; - if (c != '{') { - err = -EINVAL; - break; - } - /* - * Get the command. - */ - *tok = '\0'; - arg = - (char *)_sysio_get_token(arg + 1, - 0, - "}", - IGNORE_WHITE, - tok); - if (!arg) { - err = -EINVAL; - break; - } - count++; - /* - * Perform. - */ - err = do_command(tok); - if (err) - break; - } -#ifdef SYSIO_TRACING - if (err) - _sysio_cprintf("+NS init+ failed at expr %u (last = %s): %s\n", - count, - tok && *tok ? tok : "NULL", - strerror(-err)); -#endif - free(tok); - return err; -} - -#ifdef DEFER_INIT_CWD -/* - * Set deferred initial working directory. - */ -static int -_sysio_boot_cwd(const char *arg) -{ - - _sysio_init_cwd = arg; - return 0; -} -#endif - -/* - * Given an identifier and it's arguments, perform optional initializations. - */ -int -_sysio_boot(const char *opt, const char *arg) -{ - struct option_value_info vec[] = { -#ifdef SYSIO_TRACING - { "trace", NULL }, /* tracing? */ -#endif - { "namespace", NULL }, /* init namespace? */ -#ifdef DEFER_INIT_CWD - { "cwd", NULL }, /* init working dir */ -#endif - { NULL, NULL } - }; - struct option_value_info *v; - unsigned u; - static int (*f[])(const char *) = { -#ifdef SYSIO_TRACING - _sysio_boot_tracing, -#endif - _sysio_boot_namespace, -#ifdef DEFER_INIT_CWD - _sysio_boot_cwd, -#endif - NULL /* can't happen */ - }; - - for (v = vec, u = 0; v->ovi_name; v++, u++) - if (strcmp(v->ovi_name, opt) == 0) - break; - if (!v->ovi_name) - return -EINVAL; - return (*f[u])(arg); -} diff --git a/libsysio/src/inode.c b/libsysio/src/inode.c deleted file mode 100644 index fbe027d..0000000 --- a/libsysio/src/inode.c +++ /dev/null @@ -1,981 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2006 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "fs.h" -#include "mount.h" -#include "inode.h" -#include "dev.h" - -/* - * Support for path and index nodes. - */ - -/* - * Size of all names bucket-hash table. - */ -#ifndef NAMES_TABLE_LEN -#define NAMES_TABLE_LEN 251 -#endif - -/* - * Desired i-nodes cache size is MAX_INODES_MULTIPLIER times the number - * of slots in the names hash table. - */ -#define MAX_INODES_MULTIPLIER 3 - -/* - * Active i-nodes in the system and the number of same. - */ -struct inodes_head _sysio_inodes; -static size_t n_inodes = 0; -/* - * Desired number of active i-nodes. - */ -static size_t max_inodes = (MAX_INODES_MULTIPLIER * NAMES_TABLE_LEN); - -/* - * System table for rapid access to component names. - */ -static LIST_HEAD(, pnode_base) names[NAMES_TABLE_LEN]; -/* - * Number of names tracked by the system. - */ -static size_t n_names = 0; -/* - * Desired number of base path nodes to maintain. - */ -static size_t max_names = (2 * NAMES_TABLE_LEN); - -/* - * Number of pnodes to grab per memory allocation when filling the - * free list. - */ -#define PNODES_PER_CHUNK ((8 * 1024) / sizeof(struct pnode) - 2) - -#ifdef ZERO_SUM_MEMORY -/* - * Allocation information for pnodes bulk allocation. - */ -struct pnodes_block { - LIST_ENTRY(pnodes_block) pnblk_links; - struct pnode pnblk_nodes[PNODES_PER_CHUNK]; -}; - -static LIST_HEAD( ,pnodes_block) pnblocks; -#endif - -/* - * List of all path-nodes (aliases) referenced by any tree. - */ -struct pnodes_head _sysio_pnodes; - -/* - * Free path-nodes -- Not referenced by any tree for fas reuse. - */ -static LIST_HEAD( ,pnode) free_pnodes; - -/* - * The system root -- Aka `/'. - */ -struct pnode *_sysio_root = NULL; - -/* - * Initialize path and i-node support. Must be called before any other - * routine in this module. - */ -int -_sysio_i_init() -{ - unsigned i; - - TAILQ_INIT(&_sysio_inodes); - - for (i = 0; i < NAMES_TABLE_LEN; i++) - LIST_INIT(&names[i]); - -#ifdef ZERO_SUM_MEMORY - LIST_INIT(&pnblocks); -#endif - TAILQ_INIT(&_sysio_pnodes); - LIST_INIT(&free_pnodes); - - return 0; -} - -/* - * Garbage-collect idle i-nodes. We try to keep resource use limited to - * MAX_INODES_MULTIPLIER * max_names. - */ -static void -i_reclaim() -{ - struct inode *next, *ino; - size_t t; - - /* - * I just can't figure out a good way to reclaim these well without - * getting really fancy and using complex algorithms. The - * base nodes hold references on them for a long time and then - * release them. Those will age to the front of the queue and - * we have to skip over them. Oh well... - */ - t = MAX_INODES_MULTIPLIER * max_names; - if (max_inodes < t) { - /* - * Oops. Nope. We want more inodes than names entries. - */ - max_inodes = t; - return; - } - next = _sysio_inodes.tqh_first; - if (!next) - return; - t = max_inodes / 2; - do { - ino = next; - next = ino->i_nodes.tqe_next; - if (ino->i_ref || ino->i_immune) - continue; - _sysio_i_gone(ino); - } while (next && n_inodes > t); - - if (n_inodes > t) - max_inodes += t; -} - -static unsigned -hash(struct file_identifier *fid) -{ - size_t n; - unsigned char *ucp; - unsigned hkey; - - n = fid->fid_len; - ucp = fid->fid_data; - hkey = 0; - do { - hkey <<= 1; - hkey += *ucp++; - } while (--n); - return hkey; -} - -/* - * Allocate and initialize a new i-node. Returned i-node is referenced. - * - * NB: The passed file identifier is not copied. It is, therefor, up to the - * caller to assure that the value is static until the inode is destroyed. - */ -struct inode * -_sysio_i_new(struct filesys *fs, - struct file_identifier *fid, - struct intnl_stat *stat, - unsigned immunity, - struct inode_ops *ops, - void *private) -{ - struct inode *ino; - struct itable_entry *head; - struct inode_ops operations; - - if (n_inodes > max_inodes) { - /* - * Try to limit growth. - */ - i_reclaim(); - } - - ino = malloc(sizeof(struct inode)); - if (!ino) - return NULL; - ino->i_ops = *ops; - operations = *ops; - if (S_ISBLK(stat->st_mode) || - S_ISCHR(stat->st_mode) || - S_ISFIFO(stat->st_mode)) { - struct inode_ops *o; - - /* - * Replace some operations sent with - * those from the device table. - */ - o = _sysio_dev_lookup(stat->st_mode, stat->st_rdev); - operations.inop_open = o->inop_open; - operations.inop_close = o->inop_close; - operations.inop_read = o->inop_read; - operations.inop_write = o->inop_write; - operations.inop_pos = o->inop_pos; - operations.inop_iodone = o->inop_iodone; - operations.inop_fcntl = o->inop_fcntl; - operations.inop_datasync = o->inop_datasync; - operations.inop_ioctl = o->inop_ioctl; - } - I_INIT(ino, fs, stat, &operations, fid, immunity, private); - ino->i_ref = 1; - TAILQ_INSERT_TAIL(&_sysio_inodes, ino, i_nodes); - head = &fs->fs_itbl[hash(fid) % FS_ITBLSIZ]; - LIST_INSERT_HEAD(head, ino, i_link); - - n_inodes++; - assert(n_inodes); - - return ino; -} - -/* - * Find existing i-node given i-number and pointers to FS record - * and identifier. - */ -struct inode * -_sysio_i_find(struct filesys *fs, struct file_identifier *fid) -{ - struct inode *ino; - struct itable_entry *head; - - head = &fs->fs_itbl[hash(fid) % FS_ITBLSIZ]; - /* - * Look for existing. - */ - for (ino = head->lh_first; ino; ino = ino->i_link.le_next) - if (ino->i_fid->fid_len == fid->fid_len && - memcmp(ino->i_fid->fid_data, - fid->fid_data, - fid->fid_len) == 0) { - I_REF(ino); - break; - } - - return ino; -} - -/* - * Force reclaim of idle i-node. - */ -void -_sysio_i_gone(struct inode *ino) -{ - - if (ino->i_ref) - abort(); - if (!ino->i_zombie) - LIST_REMOVE(ino, i_link); - TAILQ_REMOVE(&_sysio_inodes, ino, i_nodes); - (*ino->i_ops.inop_gone)(ino); - free(ino); - - assert(n_inodes); - n_inodes--; -} - -/* - * Stale inode, zombie it and move it out of the way - */ -void -_sysio_i_undead(struct inode *ino) -{ - - if (ino->i_zombie) - return; - LIST_REMOVE(ino, i_link); - ino->i_zombie = 1; -} - -/* - * Garbage collect idle path (and base path) nodes tracked by the system. - */ -static void -p_reclaim() -{ - struct pnode *next, *pno; - size_t t; - - next = _sysio_pnodes.tqh_first; - if (!next) - return; - t = max_names / 2; - do { - pno = next; - if (pno->p_ref) { - next = pno->p_nodes.tqe_next; - continue; - } - pno->p_ref++; - assert(pno->p_ref); - (void )_sysio_p_prune(pno); - next = pno->p_nodes.tqe_next; - assert(pno->p_ref); - pno->p_ref--; - if (pno->p_ref) - continue; - (void )_sysio_p_prune(pno); - } while (n_names > t && next); - - if (n_names > t) - max_names += t; -} - -/* - * Allocate and initialize a new base path node. - */ -struct pnode_base * -_sysio_pb_new(struct qstr *name, struct pnode_base *parent, struct inode *ino) -{ - struct pnode_base *pb; - - if (n_names > max_names) { - /* - * Try to limit growth. - */ - p_reclaim(); - } - - pb = malloc(sizeof(struct pnode_base) + name->len); - if (!pb) - return NULL; - - pb->pb_name.name = NULL; - pb->pb_name.len = name->len; - if (pb->pb_name.len) { - char *cp; - - /* - * Copy the passed name. - * - * We have put the space for the name immediately behind - * the record in order to maximize spatial locality. - */ - cp = (char *)pb + sizeof(struct pnode_base); - (void )strncpy(cp, name->name, name->len); - pb->pb_name.name = cp; - assert(name->hashval); - pb->pb_name.hashval = name->hashval; - LIST_INSERT_HEAD(&names[name->hashval % NAMES_TABLE_LEN], - pb, - pb_names); - } - pb->pb_ino = ino; - LIST_INIT(&pb->pb_children); - LIST_INIT(&pb->pb_aliases); - if (parent) - LIST_INSERT_HEAD(&parent->pb_children, pb, pb_sibs); - pb->pb_parent = parent; - - n_names++; - assert(n_names); - - return pb; -} - -/* - * Destroy base path node, releasing resources back to the system. - * - * NB: Caller must release the inode referenced by the record. - */ -static void -pb_destroy(struct pnode_base *pb) -{ - - assert(n_names); - n_names--; - - assert(!pb->pb_aliases.lh_first); - assert(!pb->pb_children.lh_first); - assert(!pb->pb_ino); - if (pb->pb_name.len) - LIST_REMOVE(pb, pb_names); - if (pb->pb_parent) - LIST_REMOVE(pb, pb_sibs); - -#ifndef NDEBUG - /* - * This can help us catch pb-nodes that are free'd redundantly. - */ - pb->pb_name.hashval = 0; -#endif - free(pb); -} - -/* - * Force reclaim of idle base path node. - */ -void -_sysio_pb_gone(struct pnode_base *pb) -{ - - if (pb->pb_ino) - I_RELE(pb->pb_ino); - pb->pb_ino = NULL; - - pb_destroy(pb); -} - -/* - * Generate more path (alias) nodes for the fast allocator. - */ -static void -more_pnodes() -{ - size_t n; -#ifdef ZERO_SUM_MEMORY - struct pnodes_block *pnblk; -#endif - struct pnode *pno; - -#ifdef ZERO_SUM_MEMORY - pnblk = malloc(sizeof(struct pnodes_block)); - pno = NULL; - if (pnblk) { - LIST_INSERT_HEAD(&pnblocks, pnblk, pnblk_links); - pno = pnblk->pnblk_nodes; - } -#else - pno = malloc(PNODES_PER_CHUNK * sizeof(struct pnode)); -#endif - if (!pno) - return; - n = PNODES_PER_CHUNK; - do { - LIST_INSERT_HEAD(&free_pnodes, pno, p_links); - pno++; - } while (--n); -} - -#ifdef ZERO_SUM_MEMORY -/* - * Shutdown - */ -void -_sysio_i_shutdown() -{ - struct pnodes_block *pnblk; - - while ((pnblk = pnblocks.lh_first)) { - LIST_REMOVE(pnblk, pnblk_links); - free(pnblk); - } -} -#endif - -/* - * Allocate, initialize and establish appropriate links for new path (alias) - * node. - */ -struct pnode * -_sysio_p_new_alias(struct pnode *parent, - struct pnode_base *pb, - struct mount *mnt) -{ - struct pnode *pno; - - assert(!pb->pb_name.name || pb->pb_name.hashval); - - pno = free_pnodes.lh_first; - if (!pno) { - more_pnodes(); - pno = free_pnodes.lh_first; - } - if (!pno) - return NULL; - LIST_REMOVE(pno, p_links); - - pno->p_ref = 1; - pno->p_parent = parent; - if (!pno->p_parent) - pno->p_parent = pno; - pno->p_base = pb; - pno->p_mount = mnt; - pno->p_cover = NULL; - LIST_INSERT_HEAD(&pb->pb_aliases, pno, p_links); - TAILQ_INSERT_TAIL(&_sysio_pnodes, pno, p_nodes); - - return pno; -} - -/* - * For reclamation of idle path (alias) node. - */ -void -_sysio_p_gone(struct pnode *pno) -{ - struct pnode_base *pb; - - assert(!pno->p_ref); - assert(!pno->p_cover); - - TAILQ_REMOVE(&_sysio_pnodes, pno, p_nodes); - LIST_REMOVE(pno, p_links); - - pb = pno->p_base; - if (!(pb->pb_aliases.lh_first || pb->pb_children.lh_first)) - _sysio_pb_gone(pb); - - LIST_INSERT_HEAD(&free_pnodes, pno, p_links); -} - -/* - * (Re)Validate passed path node. - */ -int -_sysio_p_validate(struct pnode *pno, struct intent *intnt, const char *path) -{ - struct inode *ino; - struct pnode_base *rootpb; - int err; - - ino = pno->p_base->pb_ino; - /* - * An invalid pnode will not have an associated inode. We'll use - * the FS root inode, then -- It *must* be valid. - */ - rootpb = pno->p_mount->mnt_root->p_base; - assert(rootpb->pb_ino); - err = - rootpb->pb_ino->i_ops.inop_lookup(pno, - &ino, - intnt, - path); - /* - * If the inode lookup returns a different inode, release the old if - * present and point to the new. - */ - if (err || pno->p_base->pb_ino != ino) { - if (pno->p_base->pb_ino) - I_RELE(pno->p_base->pb_ino); - pno->p_base->pb_ino = ino; - } - return err; -} - -/* - * Find (or create!) an alias for the given parent and name. A misnomer, - * really -- This is a "get". Returned path node is referenced. - */ -int -_sysio_p_find_alias(struct pnode *parent, - struct qstr *name, - struct pnode **pnop) -{ - struct pnode_base *pb; - int err; - struct pnode *pno; - - /* - * Find the named child. - */ - if (name->len) { - /* - * Try the names table. - */ - pb = names[name->hashval % NAMES_TABLE_LEN].lh_first; - while (pb) { - if (pb->pb_parent == parent->p_base && - pb->pb_name.len == name->len && - strncmp(pb->pb_name.name, - name->name, - name->len) == 0) - break; - pb = pb->pb_names.le_next; - } - } else { - /* - * Brute force through the parent's list of children. - */ - pb = parent->p_base->pb_children.lh_first; - while (pb) { - if (pb->pb_parent == parent->p_base && - pb->pb_name.len == name->len && - strncmp(pb->pb_name.name, - name->name, - name->len) == 0) - break; - pb = pb->pb_sibs.le_next; - } - } - if (!pb) { - /* - * None found, create new child. - */ - pb = _sysio_pb_new(name, parent->p_base, NULL); - if (!pb) - return -ENOMEM; - } - /* - * Now find the proper alias. It's the one with the passed - * parent. - */ - err = 0; - pno = pb->pb_aliases.lh_first; - while (pno) { - if (pno->p_parent == parent) { - P_REF(pno); - break; - } - pno = pno->p_links.le_next; - } - if (!pno) { - /* - * Hmm. No alias. Just create an invalid one, to be - * validated later. - */ - pno = _sysio_p_new_alias(parent, pb, parent->p_mount); - if (!pno) - err = -ENOMEM; - } - if (!err) - *pnop = pno; - return err; -} - -/* - * Prune idle path base nodes freom the passed sub-tree, including the root. - */ -static void -_sysio_prune(struct pnode_base *rpb) -{ - struct pnode_base *nxtpb, *pb; - - nxtpb = rpb->pb_children.lh_first; - while ((pb = nxtpb)) { - nxtpb = pb->pb_sibs.le_next; - if (pb->pb_aliases.lh_first) - continue; - if (pb->pb_children.lh_first) { - _sysio_prune(pb); - continue; - } - _sysio_pb_gone(pb); - } - if (rpb->pb_children.lh_first) - return; - _sysio_pb_gone(rpb); -} - -/* - * Prune idle nodes from the passed sub-tree, including the root. - * - * Returns the number of aliases on the same mount that could not be pruned. - * i.e. a zero return means the entire sub-tree is gone. - */ -size_t -_sysio_p_prune(struct pnode *root) -{ - size_t count; - struct pnode_base *nxtpb, *pb; - struct pnode *nxtpno, *pno; - - count = 0; - nxtpb = root->p_base->pb_children.lh_first; - while ((pb = nxtpb)) { - nxtpb = pb->pb_sibs.le_next; - nxtpno = pb->pb_aliases.lh_first; - if (!nxtpno) { - _sysio_prune(pb); - continue; - } - while ((pno = nxtpno)) { - nxtpno = pno->p_links.le_next; - if (pno->p_mount != root->p_mount) { - /* - * Not the alias we were looking for. - */ - continue; - } - if (pno->p_base->pb_children.lh_first) { - /* - * Node is interior. Recurse. - */ - count += _sysio_p_prune(pno); - continue; - } - if (pno->p_ref) { - /* - * Can't prune; It's active. - */ - count++; - continue; - } - assert(!pno->p_cover); /* covered => ref'd! */ - assert(!pno->p_base->pb_name.name || - pno->p_base->pb_name.hashval); - /* - * Ok to prune. - */ - if (pno->p_mount->mnt_root == pno) { -#ifndef AUTOMOUNT_FILE_NAME - count++; - continue; -#else - /* - * This is an automount-point. Must - * unmount before relcaim. - */ - P_REF(pno); - if (_sysio_do_unmount(pno->p_mount) != 0) { - P_RELE(pno); - count++; - } - continue; -#endif - } - _sysio_p_gone(pno); - } - } - - if (count) { - /* - * Can't get the root or we disconnect the sub-trees. - */ - return count + (root->p_ref ? 1 : 0); - } - - /* - * All that is left is the root. Try for it too. - */ - if (root->p_ref) { - count++; - } else if (root->p_mount->mnt_root == root) { -#ifndef AUTOMOUNT_FILE_NAME - count++; -#else - /* - * This is an automount-point. Must - * unmount before relcaim. - */ - P_REF(root); - if (_sysio_do_unmount(root->p_mount) != 0) { - P_RELE(root); - count++; - } -#endif - } else - _sysio_p_gone(root); - - return count; -} - -/* - * Return path tracked by the base path node ancestor chain. - * - * Remember, base path nodes track the path relative to the file system and - * path (alias) nodes track path relative to our name space -- They cross - * mount points. - */ -char * -_sysio_pb_path(struct pnode_base *pb, const char separator) -{ - char *buf; - size_t len, n; - struct pnode_base *tmp; - char *cp; - - /* - * First pass: Traverse to the root of the sub-tree, remembering - * lengths. - */ - len = 0; - tmp = pb; - do { - n = tmp->pb_name.len; - len += tmp->pb_name.len; - if (n) - len++; - tmp = tmp->pb_parent; - } while (tmp); - if (!len) - len++; - /* - * Alloc space. - */ - buf = malloc(len + 1); - if (!buf) - return NULL; - /* - * Fill in the path buffer -- Backwards, since we're starting - * from the end. - */ - cp = buf; - *cp = separator; - cp += len; - *cp = '\0'; /* NUL term */ - tmp = pb; - do { - cp -= tmp->pb_name.len; - n = tmp->pb_name.len; - if (n) { - (void )strncpy(cp, tmp->pb_name.name, n); - *--cp = separator; - } - tmp = tmp->pb_parent; - } while (tmp); - - return buf; -} - -/* - * Common set attributes routine. - */ -int -_sysio_setattr(struct pnode *pno, - struct inode *ino, - unsigned mask, - struct intnl_stat *stbuf) -{ - /* - * It is possible that pno is null (for ftruncate call). - */ - - if (pno) - assert(!ino || pno->p_base->pb_ino == ino); - if (!ino) - ino = pno->p_base->pb_ino; - assert(ino); - - if (pno && IS_RDONLY(pno)) - return -EROFS; - - /* - * Determining permission to change the attributes is - * difficult, at best. Just try it. - */ - return (*ino->i_ops.inop_setattr)(pno, ino, mask, stbuf); -} - -/* - * Do nothing. - */ -void -_sysio_do_noop() -{ - - return; -} - -/* - * Abort. - */ -void -_sysio_do_illop() -{ - - abort(); -} - -/* - * Return -EBADF - */ -int -_sysio_do_ebadf() -{ - - return -EBADF; -} - -/* - * Return -EINVAL - */ -int -_sysio_do_einval() -{ - - return -EINVAL; -} - -/* - * Return -ENOENT - */ -int -_sysio_do_enoent() -{ - - return -ENOENT; -} - -/* - * Return -ESPIPE - */ -int -_sysio_do_espipe() -{ - - return -ESPIPE; -} - -/* - * Return -EISDIR - */ -int -_sysio_do_eisdir() -{ - - return -EISDIR; -} - -/* - * Return -ENOSYS - */ -int -_sysio_do_enosys() -{ - - return -ENOSYS; -} - - -/* - * Return -ENODEV - */ -int -_sysio_do_enodev() -{ - - return -ENODEV; -} diff --git a/libsysio/src/ioctl.c b/libsysio/src/ioctl.c deleted file mode 100644 index b6934cb..0000000 --- a/libsysio/src/ioctl.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "file.h" - -#include "sysio-symbols.h" - -int -SYSIO_INTERFACE_NAME(ioctl)(int fd, unsigned long request, ...) -{ - int err; - struct file *fil; - va_list ap; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - err = 0; - fil = _sysio_fd_find(fd); - if (!fil) { - err = -EBADF; - goto out; - } - - va_start(ap, request); - err = fil->f_ino->i_ops.inop_ioctl(fil->f_ino, request, ap); - va_end(ap); - -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - - -#ifdef __GLIBC__ -#undef __ioctl -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(ioctl), - PREPEND(__, SYSIO_INTERFACE_NAME(ioctl))) -#endif - -#ifdef BSD -#undef _ioctl -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(ioctl), - PREPEND(_, SYSIO_INTERFACE_NAME(ioctl))) -#endif diff --git a/libsysio/src/ioctx.c b/libsysio/src/ioctx.c deleted file mode 100644 index 6c06654..0000000 --- a/libsysio/src/ioctx.c +++ /dev/null @@ -1,271 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2004 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "xtio.h" -#include "inode.h" - -#if defined(REDSTORM) -#include -#endif - - -/* - * Asynchronous IO context support. - */ - -/* - * List of all outstanding (in-flight) asynch IO requests tracked - * by the system. - */ -static LIST_HEAD( ,ioctx) aioq; - -/* - * Free callback entry. - */ -#define cb_free(cb) free(cb) - -/* - * Initialization. Must be called before using any other routine in this - * module. - */ -int -_sysio_ioctx_init() -{ - - LIST_INIT(&aioq); - return 0; -} - -/* - * Enter an IO context onto the async IO events queue. - */ -void -_sysio_ioctx_enter(struct ioctx *ioctx) -{ - - LIST_INSERT_HEAD(&aioq, ioctx, ioctx_link); -} - -/* - * Allocate and initialize a new IO context. - */ -struct ioctx * -_sysio_ioctx_new(struct inode *ino, - int wr, - const struct iovec *iov, - size_t iovlen, - const struct intnl_xtvec *xtv, - size_t xtvlen) -{ - struct ioctx *ioctx; - - ioctx = malloc(sizeof(struct ioctx)); - if (!ioctx) - return NULL; - - I_REF(ino); - - IOCTX_INIT(ioctx, - 0, - wr, - ino, - iov, iovlen, - xtv, xtvlen); - - /* - * Link request onto the outstanding requests queue. - */ - _sysio_ioctx_enter(ioctx); - - return ioctx; -} - -/* - * Add an IO completion call-back to the end of the context call-back queue. - * These are called in iowait() as the last thing, right before the context - * is destroyed. - * - * They are called in order. Beware. - */ -int -_sysio_ioctx_cb(struct ioctx *ioctx, - void (*f)(struct ioctx *, void *), - void *data) -{ - struct ioctx_callback *entry; - - entry = malloc(sizeof(struct ioctx_callback)); - if (!entry) - return -ENOMEM; - - entry->iocb_f = f; - entry->iocb_data = data; - - TAILQ_INSERT_TAIL(&ioctx->ioctx_cbq, entry, iocb_next); - - return 0; -} - -/* - * Find an IO context given it's identifier. - * - * NB: This is dog-slow. If there are alot of these, we will need to change - * this implementation. - */ -struct ioctx * -_sysio_ioctx_find(void *id) -{ - struct ioctx *ioctx; - - for (ioctx = aioq.lh_first; ioctx; ioctx = ioctx->ioctx_link.le_next) - if (ioctx == id) - return ioctx; - - return NULL; -} - -/* - * Check if asynchronous IO operation is complete. - */ -int -_sysio_ioctx_done(struct ioctx *ioctx) -{ - - if (ioctx->ioctx_done) - return 1; - if (!(*ioctx->ioctx_ino->i_ops.inop_iodone)(ioctx)) - return 0; - ioctx->ioctx_done = 1; - return 1; -} - -/* - * Wait for asynchronous IO operation to complete, return status - * and dispose of the context. - * - * Note: - * The context is no longer valid after return. - */ -ssize_t -_sysio_ioctx_wait(struct ioctx *ioctx) -{ - ssize_t cc; - - /* - * Wait for async operation to complete. - */ - while (!_sysio_ioctx_done(ioctx)) { -#ifdef POSIX_PRIORITY_SCHEDULING - (void )sched_yield(); -#endif - } - - /* - * Get status. - */ - cc = ioctx->ioctx_cc; - if (cc < 0) - cc = -ioctx->ioctx_errno; - - /* - * Dispose. - */ - _sysio_ioctx_complete(ioctx); - - return cc; -} - -/* - * Free callback entry. - */ -void -_sysio_ioctx_cb_free(struct ioctx_callback *cb) -{ - - cb_free(cb); -} - -/* - * Complete an asynchronous IO request. - */ -void -_sysio_ioctx_complete(struct ioctx *ioctx) -{ - struct ioctx_callback *entry; - - - /* update IO stats */ - _SYSIO_UPDACCT(ioctx->ioctx_write, ioctx->ioctx_cc); - - /* - * Run the call-back queue. - */ - while ((entry = ioctx->ioctx_cbq.tqh_first)) { - TAILQ_REMOVE(&ioctx->ioctx_cbq, entry, iocb_next); - (*entry->iocb_f)(ioctx, entry->iocb_data); - cb_free(entry); - } - - /* - * Unlink from the file record's outstanding request queue. - */ - LIST_REMOVE(ioctx, ioctx_link); - - if (ioctx->ioctx_fast) - return; - - I_RELE(ioctx->ioctx_ino); - - free(ioctx); -} diff --git a/libsysio/src/iowait.c b/libsysio/src/iowait.c deleted file mode 100644 index 939b921..0000000 --- a/libsysio/src/iowait.c +++ /dev/null @@ -1,95 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" - -/* - * Asynch IO support for the API. - */ - -/* - * Poll status of asynch IO request. - */ -int -SYSIO_INTERFACE_NAME(iodone)(void *ioid) -{ - struct ioctx *ioctx; - int rc; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - ioctx = _sysio_ioctx_find(ioid); - if (!ioctx) - SYSIO_INTERFACE_RETURN(-1, -EINVAL); - - rc = _sysio_ioctx_done(ioctx); - SYSIO_INTERFACE_RETURN(rc < 0 ? -1 : rc, rc < 0 ? rc : 0); -} - -/* - * Wait for completion of and return results from identified asynch IO - * request. - * - * The identifier is no longer valid after return. - */ -ssize_t -SYSIO_INTERFACE_NAME(iowait)(void *ioid) -{ - struct ioctx *ioctx; - ssize_t cc; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - ioctx = _sysio_ioctx_find(ioid); - if (!ioctx) - SYSIO_INTERFACE_RETURN(-1, -EINVAL); - - cc = _sysio_ioctx_wait(ioctx); - SYSIO_INTERFACE_RETURN(cc < 0 ? -1 : cc, cc < 0 ? (int )cc : 0); -} diff --git a/libsysio/src/link.c b/libsysio/src/link.c deleted file mode 100644 index 638bd7e..0000000 --- a/libsysio/src/link.c +++ /dev/null @@ -1,114 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "mount.h" -#include "inode.h" -#include "sysio-symbols.h" - -int -SYSIO_INTERFACE_NAME(link)(const char *oldpath, const char *newpath) -{ - struct intent intent; - int err; - struct pnode *old, *new; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - INTENT_INIT(&intent, 0, NULL, NULL); - err = _sysio_namei(_sysio_cwd, oldpath, 0, &intent, &old); - if (err) - goto out; - if (S_ISDIR(old->p_base->pb_ino->i_stbuf.st_mode)) { - err = -EPERM; - goto error1; - } - INTENT_INIT(&intent, INT_UPDPARENT, NULL, NULL); - new = NULL; - err = _sysio_namei(_sysio_cwd, newpath, ND_NEGOK, &intent, &new); - if (err) - goto error1; - if (new->p_base->pb_ino) { - err = -EEXIST; - goto error2; - } - if (old->p_mount->mnt_root != new->p_mount->mnt_root) { - err = -EXDEV; - goto error2; - } - /* - * Use the parent node operations to request the task in case the - * driver is implemented using differentiated inode operations based - * on file type, such as incore does. - */ - err = old->p_parent->p_base->pb_ino->i_ops.inop_link(old, new); - if (err) - goto error2; - /* - * The new p-node must be pointed at the inode referenced by the old. - */ - assert(!new->p_base->pb_ino && old->p_base->pb_ino); - new->p_base->pb_ino = old->p_base->pb_ino; - I_REF(new->p_base->pb_ino); - -error2: - P_RELE(new); -error1: - P_RELE(old); -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef REDSTORM -#undef __link -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(link), - PREPEND(__, SYSIO_INTERFACE_NAME(link))) -#endif diff --git a/libsysio/src/lseek.c b/libsysio/src/lseek.c deleted file mode 100644 index 91d865d..0000000 --- a/libsysio/src/lseek.c +++ /dev/null @@ -1,226 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2005 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "file.h" - -#include "sysio-symbols.h" - -_SYSIO_OFF_T -_sysio_lseek_prepare(struct file *fil, - _SYSIO_OFF_T offset, - int whence, - _SYSIO_OFF_T max) -{ - _SYSIO_OFF_T off, pos; - struct intnl_stat stbuf; - - off = -1; - switch (whence) { - - case SEEK_SET: - off = 0; - break; - case SEEK_CUR: - off = fil->f_pos; - break; - case SEEK_END: - { - int err; - - /* - * Don't blindly trust the attributes - * in the inode record for this. Give the - * driver a chance to refresh them. - */ - err = - (*fil->f_ino->i_ops.inop_getattr)(NULL, - fil->f_ino, - &stbuf); - if (err) - return err; - - } - off = stbuf.st_size; - break; - default: - return -EINVAL; - } - pos = off + offset; - if ((offset < 0 && -offset > off) || (offset > 0 && pos <= off)) - return -EINVAL; - if (pos >= max) - return -EOVERFLOW; - return pos; -} - -static _SYSIO_OFF_T -_sysio_lseek(struct file *fil, - _SYSIO_OFF_T offset, - int whence, - _SYSIO_OFF_T max) -{ - _SYSIO_OFF_T pos; - - pos = _sysio_lseek_prepare(fil, offset, whence, max); - if (pos < 0) - return pos; - pos = (fil->f_ino->i_ops.inop_pos)(fil->f_ino, pos); - if (pos < 0) - return pos; - fil->f_pos = pos; - return pos; -} - -#ifdef _LARGEFILE64_SOURCE -#undef lseek64 - -extern off64_t -SYSIO_INTERFACE_NAME(lseek64)(int fd, off64_t offset, int whence) -{ - struct file *fil; - off64_t off; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!fil) - SYSIO_INTERFACE_RETURN((off64_t )-1, -EBADF); - off = _sysio_lseek(fil, offset, whence, _SEEK_MAX(fil)); - SYSIO_INTERFACE_RETURN(off < 0 ? (off64_t )-1 : off, - off < 0 ? (int )off : 0); - -} -#ifdef __GLIBC__ -#undef __lseek64 -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(lseek64), - PREPEND(__, SYSIO_INTERFACE_NAME(lseek64))) -#endif -#ifdef REDSTORM -#undef __libc_lseek64 -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(lseek64), - PREPEND(__, SYSIO_INTERFACE_NAME(libc_lseek64))) -#endif -#endif - -#undef lseek - -extern off_t -SYSIO_INTERFACE_NAME(lseek)(int fd, off_t offset, int whence) -{ - struct file *fil; - _SYSIO_OFF_T off; - off_t rtn; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!fil) - SYSIO_INTERFACE_RETURN((off_t )-1, -EBADF); - off = _sysio_lseek(fil, offset, whence, LONG_MAX); - if (off < 0) - SYSIO_INTERFACE_RETURN((off_t )-1, (int )off); - rtn = (off_t )off; - assert(rtn == off); - SYSIO_INTERFACE_RETURN(rtn, 0); -} - -#ifdef __GLIBC__ -#undef __lseek -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(lseek), - PREPEND(__, SYSIO_INTERFACE_NAME(lseek))) -#endif - -#ifdef __linux__ -#undef llseek -int -SYSIO_INTERFACE_NAME(llseek)(unsigned int fd __IS_UNUSED, - unsigned long offset_high __IS_UNUSED, - unsigned long offset_low __IS_UNUSED, - loff_t *result __IS_UNUSED, - unsigned int whence __IS_UNUSED) -{ - struct file *fil; - loff_t off; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - /* - * This is just plain goofy. - */ - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!fil) - SYSIO_INTERFACE_RETURN(-1, -EBADF); -#ifndef _LARGEFILE64_SOURCE - if (offset_high) { - /* - * We are using 32-bit internals. This just isn't - * going to work. - */ - SYSIO_INTERFACE_RETURN(-1, -EOVERFLOW); - } -#else - off = offset_high; - off <<= 32; - off |= offset_low; -#endif - off = _sysio_lseek(fil, off, whence, _SEEK_MAX(fil)); - if (off < 0) - SYSIO_INTERFACE_RETURN((off_t )-1, (int )off); - *result = off; - SYSIO_INTERFACE_RETURN(0, 0); -} - -#undef __llseek -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(llseek), - PREPEND(__, SYSIO_INTERFACE_NAME(llseek))) -#endif diff --git a/libsysio/src/mkdir.c b/libsysio/src/mkdir.c deleted file mode 100644 index a23e014..0000000 --- a/libsysio/src/mkdir.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2006 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "fs.h" -#include "mount.h" -#include "sysio-symbols.h" - -int -_sysio_mkdir(struct pnode *pno, mode_t mode) -{ - int err; - struct inode *parenti; - - if (pno->p_base->pb_ino) - return -EEXIST; - - err = _sysio_permitted(pno->p_parent, W_OK); - if (err) - return err; - - parenti = pno->p_parent->p_base->pb_ino; - assert(parenti); - return (*parenti->i_ops.inop_mkdir)(pno, mode); -} - -int -SYSIO_INTERFACE_NAME(mkdir)(const char *path, mode_t mode) -{ - int err; - struct intent intent; - struct pnode *pno; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - INTENT_INIT(&intent, INT_CREAT, &mode, NULL); - err = _sysio_namei(_sysio_cwd, path, ND_NEGOK, &intent, &pno); - if (err) - goto out; - - mode &= ~(_sysio_umask & 0777); /* apply umask */ - err = _sysio_mkdir(pno, mode); - P_RELE(pno); -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef REDSTORM -#undef __mkdir -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(mkdir), - PREPEND(__, SYSIO_INTERFACE_NAME(mkdir))) -#endif diff --git a/libsysio/src/mknod.c b/libsysio/src/mknod.c deleted file mode 100644 index 51e5f7f..0000000 --- a/libsysio/src/mknod.c +++ /dev/null @@ -1,138 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "fs.h" -#include "mount.h" - -#include "sysio-symbols.h" - -#undef mknod -#undef __xmknod - -/* - * Internal routine to make a device node. - */ -int -_sysio_mknod(struct pnode *pno, mode_t mode, dev_t dev) -{ - - if (pno->p_base->pb_ino) - return -EEXIST; - - /* - * Support only regular, character-special and fifos right now. - * (mode & S_IFMT) == 0 is the same as S_IFREG. - */ - if (!(S_ISREG(mode) || S_ISCHR(mode) || S_ISFIFO(mode))) - return -EINVAL; - - if (IS_RDONLY(pno)) - return -EROFS; - return (*pno->p_parent->p_base->pb_ino->i_ops.inop_mknod)(pno, - mode, - dev); -} - -int -PREPEND(__, SYSIO_INTERFACE_NAME(xmknod))(int __ver, - const char *path, - mode_t mode, - dev_t *dev) -{ - int err; - struct intent intent; - struct pnode *pno; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - if (__ver != _MKNOD_VER) { - err = -ENOSYS; - goto out; - } - - mode &= ~(_sysio_umask & 0777); /* apply umask */ - - INTENT_INIT(&intent, INT_CREAT, &mode, NULL); - err = _sysio_namei(_sysio_cwd, path, ND_NEGOK, &intent, &pno); - if (err) - goto out; - - err = _sysio_permitted(pno->p_parent, W_OK); - if (err) - goto error; - err = _sysio_mknod(pno, mode, *dev); -error: - P_RELE(pno); -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef REDSTORM -#undef _xmknod -sysio_sym_weak_alias(PREPEND(__, SYSIO_INTERFACE_NAME(xmknod)), - PREPEND(_, SYSIO_INTERFACE_NAME(xmknod))) -#endif - -static int -PREPEND(__, SYSIO_INTERFACE_NAME(mknod))(const char *path, - mode_t mode, - dev_t dev) -{ - - return PREPEND(__, SYSIO_INTERFACE_NAME(xmknod))(_MKNOD_VER, - path, - mode, - &dev); -} - -sysio_sym_weak_alias(PREPEND(__, SYSIO_INTERFACE_NAME(mknod)), - SYSIO_INTERFACE_NAME(mknod)) diff --git a/libsysio/src/module.mk b/libsysio/src/module.mk deleted file mode 100644 index ffd0c54..0000000 --- a/libsysio/src/module.mk +++ /dev/null @@ -1,32 +0,0 @@ -# -# Note; Remove statvfs{,64}.c until we decide what to do with them. -# Lee; Tue Feb 24 09:37:32 EST 2004 -# - -if WITH_LUSTRE_HACK -FILE_SUPPORT = src/file_hack.c -else -FILE_SUPPORT = src/file.c -endif - -if WITH_LUSTRE_HACK -LUSTRE_SRCDIR_SRCS = src/stdlib.c -else -LUSTRE_SRCDIR_SRCS = -endif - -SRCDIR_SRCS = src/access.c src/chdir.c src/chmod.c \ - src/chown.c src/dev.c src/dup.c src/fcntl.c \ - src/fs.c src/fsync.c \ - src/getdirentries.c src/init.c src/inode.c \ - src/ioctl.c src/ioctx.c src/iowait.c \ - src/link.c src/lseek.c src/mkdir.c \ - src/mknod.c src/mount.c src/namei.c \ - src/open.c src/rw.c src/reconcile.c src/rename.c \ - src/rmdir.c src/stat64.c src/stat.c \ - src/stddir.c src/readdir.c src/readdir64.c \ - src/symlink.c src/readlink.c \ - src/truncate.c src/unlink.c src/utime.c \ - $(FILE_SUPPORT) $(LUSTRE_SRCDIR_SRCS) - -SRCDIR_EXTRA = src/module.mk diff --git a/libsysio/src/mount.c b/libsysio/src/mount.c deleted file mode 100644 index 6fed655..0000000 --- a/libsysio/src/mount.c +++ /dev/null @@ -1,740 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2004 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#ifdef AUTOMOUNT_FILE_NAME -#include -#include -#endif -#include - -#include "sysio.h" -#include "xtio.h" -#include "fs.h" -#include "mount.h" -#include "inode.h" - -/* - * File system and volume mount support. - */ - -#ifdef AUTOMOUNT_FILE_NAME -/* - * Name of autmount specification file in a directory with - * the sticky-bit set. - */ -struct qstr _sysio_mount_file_name = { "", 0, 0 }; -#endif - -/* - * Active mounts. - */ -static LIST_HEAD(, mount) mounts; - -static int _sysio_sub_fsswop_mount(const char *source, - unsigned flags, - const void *data, - struct pnode *tocover, - struct mount **mntp); - -static struct fssw_ops _sysio_sub_fssw_ops = { - _sysio_sub_fsswop_mount -}; - -/* - * Initialization. Must be called before any other routine in this module. - */ -int -_sysio_mount_init() -{ - int err; - - LIST_INIT(&mounts); -#ifdef AUTOMOUNT_FILE_NAME - _sysio_next_component(AUTOMOUNT_FILE_NAME, &_sysio_mount_file_name); -#endif - - /* - * Register the sub-trees "file system" driver. - */ - err = _sysio_fssw_register("sub", &_sysio_sub_fssw_ops); - if (err) - return err; - - return 0; -} - -/* - * Mount rooted sub-tree somewhere in the existing name space. - */ -int -_sysio_do_mount(struct filesys *fs, - struct pnode_base *rootpb, - unsigned flags, - struct pnode *tocover, - struct mount **mntp) -{ - struct mount *mnt; - int err; - - /* - * It's really poor form to allow the new root to be a - * descendant of the pnode being covered. - */ - if (tocover) { - struct pnode_base *pb; - - for (pb = rootpb; - pb && pb != tocover->p_base; - pb = pb->pb_parent) - ; - if (pb == tocover->p_base) - return -EBUSY; - } - - /* - * Alloc - */ - mnt = malloc(sizeof(struct mount)); - if (!mnt) - return -ENOMEM; - err = 0; - /* - * Init enough to make the mount record usable to the path node - * generation routines. - */ - mnt->mnt_fs = fs; - if (fs->fs_flags & FS_F_RO) { - /* - * Propagate the read-only flag -- Whether they set it or not. - */ - flags |= MOUNT_F_RO; - } - mnt->mnt_flags = flags; - /* - * Get alias for the new root. - */ - mnt->mnt_root = - _sysio_p_new_alias(tocover ? tocover->p_parent : NULL, rootpb, mnt); - if (!mnt->mnt_root) { - err = -ENOMEM; - goto error; - } - /* - * It may have been a while since the root inode was validated; - * better validate again. And it better be a directory! - */ - err = _sysio_p_validate(mnt->mnt_root, NULL, NULL); - if (err) - goto error; - - if (!S_ISDIR(mnt->mnt_root->p_base->pb_ino->i_stbuf.st_mode)) { - err = -ENOTDIR; - goto error; - } - /* - * Cover up the mount point. - */ - mnt->mnt_covers = tocover; - if (!mnt->mnt_covers) { - /* - * New graph; It covers itself. - */ - mnt->mnt_covers = tocover = mnt->mnt_root; - } - assert(!tocover->p_cover); - tocover->p_cover = mnt->mnt_root; - - LIST_INSERT_HEAD(&mounts, mnt, mnt_link); - - *mntp = mnt; - return 0; - -error: - if (mnt->mnt_root) { - P_RELE(mnt->mnt_root); - _sysio_p_prune(mnt->mnt_root); - } - free(mnt); - return err; -} - -/* - * Remove mounted sub-tree from the system. - */ -int -_sysio_do_unmount(struct mount *mnt) -{ - struct pnode *root; - struct filesys *fs; - - root = mnt->mnt_root; - if (root->p_cover && root->p_cover != root) { - /* - * Active mount. - */ - return -EBUSY; - } - assert(mnt->mnt_covers->p_cover == root); - if (_sysio_p_prune(root) != 1) { - /* - * Active aliases. - */ - return -EBUSY; - } - /* - * We're committed. - * - * Drop ref of covered pnode and break linkage in name space. - */ - if (root->p_cover != root) - P_RELE(mnt->mnt_covers); - mnt->mnt_covers->p_cover = NULL; - LIST_REMOVE(mnt, mnt_link); - /* - * Kill the root. - */ - P_RELE(root); - root->p_cover = NULL; - _sysio_p_gone(root); - /* - * Release mount record resource. - */ - fs = mnt->mnt_fs; - free(mnt); - FS_RELE(fs); - - return 0; -} - -/* - * Establish the system name space. - */ -int -_sysio_mount_root(const char *source, - const char *fstype, - unsigned flags, - const void *data) -{ - struct fsswent *fssw; - int err; - struct mount *mnt; - - if (_sysio_root) - return -EBUSY; - - fssw = _sysio_fssw_lookup(fstype); - if (!fssw) - return -ENODEV; - - err = (*fssw->fssw_ops.fsswop_mount)(source, flags, data, NULL, &mnt); - if (err) - return err; - - _sysio_root = mnt->mnt_root; -#ifndef DEFER_INIT_CWD - /* - * It is very annoying to have to set the current working directory. - * So... If it isn't set, make it the root now. - */ - if (!_sysio_cwd) { - _sysio_cwd = _sysio_root; - P_REF(_sysio_cwd); - } -#endif - - return 0; -} - -int -_sysio_mount(struct pnode *cwd, - const char *source, - const char *target, - const char *filesystemtype, - unsigned long mountflags, - const void *data) -{ - int err; - struct fsswent *fssw; - struct intent intent; - struct pnode *tgt; - struct mount *mnt; - - /* - * Find the file system switch entry specified. - */ - fssw = _sysio_fssw_lookup(filesystemtype); - if (!fssw) - return -ENODEV; - - /* - * Look up the target path node. - */ - INTENT_INIT(&intent, INT_GETATTR, NULL, NULL); - err = _sysio_namei(cwd, target, 0, &intent, &tgt); - if (err) - return err; - - if (tgt == _sysio_root) { - /* - * Attempting to mount over root. - */ - err = -EBUSY; - } else { - /* - * Do the deed. - */ - err = - (*fssw->fssw_ops.fsswop_mount)(source, - mountflags, - data, - tgt, - &mnt); - } - if (err) - P_RELE(tgt); - return err; -} - -int -SYSIO_INTERFACE_NAME(mount)(const char *source, - const char *target, - const char *filesystemtype, - unsigned long mountflags, - const void *data) -{ - int err; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - err = - _sysio_mount(_sysio_cwd, - source, - target, - filesystemtype, - mountflags, - data); - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -int -SYSIO_INTERFACE_NAME(umount)(const char *target) -{ - int err; - struct pnode *pno; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - /* - * Look up the target path node. - */ - err = _sysio_namei(_sysio_cwd, target, 0, NULL, &pno); - if (err) - goto out; - P_RELE(pno); /* was ref'd */ - - /* - * Do the deed. - */ -#if 0 - if (!pno->p_cover) { - err = -EINVAL; - goto error; - } -#endif - assert(pno->p_mount); - err = _sysio_do_unmount(pno->p_mount); - -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -/* - * Unmount all file systems -- Usually as part of shutting everything down. - */ -int -_sysio_unmount_all() -{ - int err; - struct mount *mnt, *nxt; - struct pnode *pno; - - err = 0; - nxt = mounts.lh_first; - while ((mnt = nxt)) { - nxt = mnt->mnt_link.le_next; - pno = mnt->mnt_root; - /* - * If this is an automount generated mount, the root - * has no reference. We can cause the dismount with a - * simple prune. - */ - if (!_sysio_p_prune(pno)) - continue; -#ifdef notdef - /* - * Need a ref but only if this is not the root of a - * disconnected graph. If it is, then it is covered by itself - * and, so, already referenced. - */ - if (pno->p_cover != pno) - P_REF(pno); -#endif - err = _sysio_do_unmount(mnt); - if (err) { -#ifdef notdef - if (pno->p_cover != pno) - P_RELE(pno); -#endif - break; - } - if (pno == _sysio_root) - _sysio_root = NULL; - } - - return err; -} - -static int -_sysio_sub_fsswop_mount(const char *source, - unsigned flags, - const void *data __IS_UNUSED, - struct pnode *tocover, - struct mount **mntp) -{ - int err; - struct nameidata nameidata; - struct mount *mnt; - - /* - * How can we make a sub-mount from nothing? - */ - if (!_sysio_root) - return -EBUSY; - - /* - * Lookup the source. - */ - ND_INIT(&nameidata, 0, source, _sysio_root, NULL); - err = _sysio_path_walk(_sysio_root, &nameidata); - if (err) - return err; - - /* - * Mount the rooted sub-tree at the given position. - */ - err = - _sysio_do_mount(nameidata.nd_pno->p_mount->mnt_fs, - nameidata.nd_pno->p_base, - nameidata.nd_pno->p_mount->mnt_flags & flags, - tocover, - &mnt); - - /* - * Clean up and return. - */ - if (!err) { - FS_REF(nameidata.nd_pno->p_mount->mnt_fs); - *mntp = mnt; - } - P_RELE(nameidata.nd_pno); - return err; -} - -#ifdef AUTOMOUNT_FILE_NAME -/* - * Parse automount specification formatted as: - * - * :[[ \t]+] - * - * NB: - * The buffer sent is (almost) always modified. - */ -static int -parse_automount_spec(char *s, char **fstyp, char **srcp, char **optsp) -{ - int err; - char *cp; - char *fsty, *src, *opts; - - err = 0; - - /* - * Eat leading white. - */ - while (*s && *s == ' ' && *s == '\t') - s++; - /* - * Get fstype. - */ - fsty = cp = s; - while (*cp && - *cp != ':' && - *cp != ' ' && - *cp != '\t' && - *cp != '\r' && - *cp != '\n') - cp++; - if (fsty == cp || *cp != ':') - goto error; - *cp++ = '\0'; - - s = cp; - /* - * Eat leading white. - */ - while (*s && *s == ' ' && *s == '\t') - s++; - /* - * Get source. - */ - src = cp = s; - while (*cp && - *cp != ' ' && - *cp != '\t' && - *cp != '\r' && - *cp != '\n') - cp++; - if (src == cp) - goto error; - if (*cp) - *cp++ = '\0'; - - s = cp; - /* - * Eat leading white. - */ - while (*s && *s == ' ' && *s == '\t') - s++; - /* - * Get opts. - */ - opts = cp = s; - while (*cp && - *cp != ' ' && - *cp != '\t' && - *cp != '\r' && - *cp != '\n') - cp++; - if (opts == cp) - opts = NULL; - if (*cp) - *cp++ = '\0'; - - if (*cp) - goto error; - - *fstyp = fsty; - *srcp = src; - *optsp = opts; - return 0; - -error: - return -EINVAL; -} - -/* - * Parse (and strip) system mount options. - */ -static char * -parse_opts(char *opts, unsigned *flagsp) -{ - unsigned flags; - char *src, *dst; - char *cp; - - flags = 0; - src = dst = opts; - for (;;) { - cp = src; - while (*cp && *cp != ',') - cp++; - if (src + 2 == cp && strncmp(src, "rw", 2) == 0) { - /* - * Do nothing. This is the default. - */ - src += 2; - } else if (src + 2 == cp && strncmp(src, "ro", 2) == 0) { - /* - * Read-only. - */ - flags |= MOUNT_F_RO; - src += 2; - } - else if (src + 4 == cp && strncmp(src, "auto", 4) == 0) { - /* - * Enable automounts. - */ - flags |= MOUNT_F_AUTO; - src += 4; - } - if (src < cp) { - /* - * Copy what we didn't consume. - */ - if (dst != opts) - *dst++ = ','; - do - *dst++ = *src++; - while (src != cp); - } - if (!*src) - break; - *dst = '\0'; - src++; /* skip comma */ - } - *dst = '\0'; - - *flagsp = flags; - return opts; -} - -/* - * Attempt automount over the given directory. - */ -int -_sysio_automount(struct pnode *mntpno) -{ - int err; - struct inode *ino; - struct iovec iovec; - struct ioctx iocontext; - struct intnl_xtvec xtvec; - ssize_t cc; - char *fstype, *source, *opts; - unsigned flags; - struct fsswent *fssw; - struct mount *mnt; - - /* - * Revalidate -- Paranoia. - */ - err = _sysio_p_validate(mntpno, NULL, NULL); - if (err) - return err; - - /* - * Read file content. - */ - ino = mntpno->p_base->pb_ino; - if (ino->i_stbuf.st_size > 64 * 1024) { - /* - * Let's be reasonable. - */ - return -EINVAL; - } - iovec.iov_base = malloc(ino->i_stbuf.st_size + 1); - if (!iovec.iov_base) - return -ENOMEM; - iovec.iov_len = ino->i_stbuf.st_size; - err = _sysio_open(mntpno, O_RDONLY, 0); - if (err) - goto out; - xtvec.xtv_off = 0; - xtvec.xtv_len = ino->i_stbuf.st_size; - IOCTX_INIT(&iocontext, - 1, - 0, - ino, - &iovec, 1, - &xtvec, 1); - _sysio_ioctx_enter(&iocontext); - err = (*ino->i_ops.inop_read)(ino, &iocontext); - if (err) { - _sysio_ioctx_complete(&iocontext); - (void )(*ino->i_ops.inop_close)(ino); - goto out; - } - cc = _sysio_ioctx_wait(&iocontext); - err = (*ino->i_ops.inop_close)(ino); - if (err) - goto out; - if (cc < 0) { - err = (int )cc; - goto out; - } - ((char *)iovec.iov_base)[cc] = '\0'; - - /* - * Parse. - */ - err = parse_automount_spec(iovec.iov_base, &fstype, &source, &opts); - if (err) - goto out; - flags = 0; - if (opts) - opts = parse_opts(opts, &flags); - - /* - * Find the file system switch entry specified. - */ - fssw = _sysio_fssw_lookup(fstype); - if (!fssw) { - err = -ENODEV; - goto out; - } - - /* - * Do the deed. - */ - P_REF(mntpno->p_parent); - err = - (*fssw->fssw_ops.fsswop_mount)(source, - flags, - opts, - mntpno->p_parent, - &mnt); - if (err) - P_RELE(mntpno->p_parent); - -out: - if (iovec.iov_base) - free(iovec.iov_base); - return err; -} -#endif diff --git a/libsysio/src/namei.c b/libsysio/src/namei.c deleted file mode 100644 index 63e610e..0000000 --- a/libsysio/src/namei.c +++ /dev/null @@ -1,509 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2006 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "mount.h" -#include "inode.h" - -/* - * Parse next component in path. - */ -#ifndef AUTOMOUNT_FILE_NAME -static -#endif -void -_sysio_next_component(const char *path, struct qstr *name) -{ - while (*path == PATH_SEPARATOR) - path++; - name->name = path; - name->len = 0; - name->hashval = 0; - while (*path && *path != PATH_SEPARATOR) { - name->hashval = - 37 * name->hashval + *path++; - name->len++; - } -} - -/* - * Given parent, look up component. - */ -static int -lookup(struct pnode *parent, - struct qstr *name, - struct pnode **pnop, - struct intent *intnt, - const char *path, - int check_permissions) -{ - int err; - struct pnode *pno; - - if (!parent->p_base->pb_ino) - return -ENOTDIR; - - /* - * Sometimes we don't want to check permissions. At initialization - * time, for instance. - */ - if (check_permissions) { - err = _sysio_permitted(parent, X_OK); - if (err) - return err; - } - - /* - * Short-circuit `.' and `..'; We don't cache those. - */ - pno = NULL; - if (name->len == 1 && name->name[0] == '.') - pno = parent; - else if (name->len == 2 && name->name[0] == '.' && name->name[1] == '.') - pno = parent->p_parent; - if (pno) - P_REF(pno); - else { - /* - * Get cache entry then. - */ - err = _sysio_p_find_alias(parent, name, &pno); - if (err) - return err; - } - - /* - * While covered, move to the covering node. - */ - while (pno->p_cover && pno->p_cover != pno) { - struct pnode *cover; - - cover = pno->p_cover; - P_REF(cover); - P_RELE(pno); - pno = cover; - } - - *pnop = pno; - - /* - * (Re)validate the pnode. - */ - err = _sysio_p_validate(pno, intnt, path); - if (err) - return err; - - return 0; -} - -/* - * The meat. Walk an absolute or relative path, looking up each - * component. Various flags in the nameidata argument govern actions - * and return values/state. They are: - * - * ND_NOFOLLOW symbolic links are not followed - * ND_NEGOK if terminal/leaf does not exist, return - * path node (alias) anyway. - * ND_NOPERMCHECK do not check permissions - */ -int -_sysio_path_walk(struct pnode *parent, struct nameidata *nd) -{ - int err; - const char *path; - struct qstr this, next; - struct inode *ino; - - /* - * NULL path? - */ - if (!nd->nd_path) - return -EFAULT; - - /* - * Empty path? - */ - if (!*nd->nd_path) - return -ENOENT; - - /* - * Leading slash? - */ - if (*nd->nd_path == PATH_SEPARATOR) { - /* - * Make parent the root of the name space. - */ - parent = nd->nd_root; - } - -#ifdef DEFER_INIT_CWD - if (!parent) { - const char *icwd; - - if (!_sysio_init_cwd && !nd->nd_root) - abort(); - - /* - * Finally have to set the current working directory. We can - * not tolerate errors here or else risk leaving the process - * in a very unexpected location. We abort then unless all goes - * well. - */ - icwd = _sysio_init_cwd; - _sysio_init_cwd = NULL; - parent = nd->nd_root; - if (!parent) - abort(); - (void )_sysio_namei(nd->nd_root, icwd, 0, NULL, &parent); - if (_sysio_p_chdir(parent) != 0) - abort(); - } -#endif - - /* - * (Re)Validate the parent. - */ - err = _sysio_p_validate(parent, NULL, NULL); - if (err) - return err; - - /* - * Prime everything for the loop. Will need another reference to the - * initial directory. It'll be dropped later. - */ - nd->nd_pno = parent; - P_REF(nd->nd_pno); - _sysio_next_component(nd->nd_path, &next); - path = next.name; - parent = NULL; - err = 0; - - /* - * Derecurse the path tree-walk. - */ - for (;;) { - ino = nd->nd_pno->p_base->pb_ino; - if (S_ISLNK(ino->i_stbuf.st_mode) && - (next.len || !(nd->nd_flags & ND_NOFOLLOW))) { - char *lpath; - ssize_t cc; - struct nameidata nameidata; - - if (nd->nd_slicnt >= MAX_SYMLINK) { - err = -ELOOP; - break; - } - - /* - * Follow symbolic link. - */ - lpath = malloc(MAXPATHLEN + 1); - if (!lpath) { - err = -ENOMEM; - break; - } - cc = - ino->i_ops.inop_readlink(nd->nd_pno, - lpath, - MAXPATHLEN); - if (cc < 0) { - free(lpath); - err = (int )cc; - break; - } - lpath[cc] = '\0'; /* NUL term */ - /* - * Handle symbolic links with recursion. Yuck! - * Pass the NULL intent for recursive symlink - * except the last component. - */ - ND_INIT(&nameidata, - nd->nd_flags, - lpath, - nd->nd_root, - !next.len ? nd->nd_intent : NULL); - nameidata.nd_slicnt = nd->nd_slicnt + 1; - err = - _sysio_path_walk(nd->nd_pno->p_parent, &nameidata); - free(lpath); - if (err) - break; - P_RELE(nd->nd_pno); - nd->nd_pno = nameidata.nd_pno; - ino = nd->nd_pno->p_base->pb_ino; - } -#ifdef AUTOMOUNT_FILE_NAME - else if (ino && - S_ISDIR(ino->i_stbuf.st_mode) && - (nd->nd_pno->p_mount->mnt_flags & MOUNT_F_AUTO) && - nd->nd_amcnt < MAX_MOUNT_DEPTH && - ino->i_stbuf.st_mode & S_ISUID) { - struct pnode *pno; - - /* - * We're committed to a lookup. It's time to see if - * we're going to do it in an automount-point and - * arrange the mount if so. - */ - assert(!nd->nd_pno->p_cover); - err = - lookup(nd->nd_pno, - &_sysio_mount_file_name, - &pno, - NULL, - NULL, - 1); - if (pno) - P_RELE(pno); - if (!err && _sysio_automount(pno) == 0) { - struct pnode *root; - - /* - * All went well. Need to switch - * parent pno and ino to the - * root of the newly mounted sub-tree. - * - * NB: - * We don't recurseively retry these - * things. It's OK to have the new root - * be an automount-point but it's going - * to take another lookup to accomplish it. - * The alternative could get us into an - * infinite loop. - */ - root = nd->nd_pno->p_cover; - assert(root); - P_RELE(nd->nd_pno); - nd->nd_pno = root; -#if 0 - P_REF(nd->nd_pno); -#endif - ino = nd->nd_pno->p_base->pb_ino; - assert(ino); - - /* - * Must send the intent-path again. - */ - path = nd->nd_path; - nd->nd_amcnt++; - - /* - * Must go back top and retry with this - * new pnode as parent. - */ - continue; - } - err = 0; /* it never happened */ - } -#endif - - /* - * Set up for next component. - */ - this = next; - if (path) - path = this.name; - if (!this.len) - break; - if (!ino) { - /* - * Should only be here if final component was - * target of a symlink. - */ - nd->nd_path = this.name + this.len; - err = -ENOENT; - break; - } - nd->nd_path = this.name + this.len; - _sysio_next_component(nd->nd_path, &next); - parent = nd->nd_pno; - nd->nd_pno = NULL; - - /* - * Parent must be a directory. - */ - if (ino && !S_ISDIR(ino->i_stbuf.st_mode)) { - err = -ENOTDIR; - break; - } - - /* - * The extra path arg is passed only on the first lookup in the - * walk as we cross into each file system, anew. The intent is - * passed both on the first lookup and when trying to look up - * the final component -- Of the original path, not on the - * file system. - * - * Confused? Me too and I came up with this weirdness. It's - * hints to the file system drivers. Read on. - * - * The first lookup will give everything one needs to ready - * everything for the entire operation before the path is - * walked. The file system driver knows it's the first lookup - * in the walk because it has both the path and the intent. - * - * Alternatively, one could split the duties; The first lookup - * can be used to prime the file system inode cache with the - * interior nodes we'll want in the path-walk. Then, when - * looking up the last component, ready everything for the - * operations(s) to come. The file system driver knows it's - * the last lookup in the walk because it has the intent, - * again, but without the path. - * - * One special case; If we were asked to look up a single - * component, we treat it as the last component. The file - * system driver never sees the extra path argument. It should - * be noted that the driver always has the fully qualified - * path, on the target file system, available to it for any - * node it is looking up, including the last, via the base - * path node and it's ancestor chain. - */ - err = - lookup(parent, - &this, - &nd->nd_pno, - (path || !next.len) - ? nd->nd_intent - : NULL, - (path && next.len) ? path : NULL, - !(nd->nd_flags & ND_NOPERMCHECK)); - if (err) { - if (err == -ENOENT && - !next.len && - (nd->nd_flags & ND_NEGOK)) - err = 0; - break; - } - path = NULL; /* Stop that! */ - if ((parent->p_mount->mnt_fs != - nd->nd_pno->p_mount->mnt_fs)) { - /* - * Crossed into a new fs. We'll want the next lookup - * to include the path again. - */ - path = nd->nd_path; - } - - /* - * Release the parent. - */ - P_RELE(parent); - parent = NULL; - } - - /* - * Trailing separators cause us to break from the loop with - * a parent set but no pnode. Check for that. - */ - if (!nd->nd_pno) { - nd->nd_pno = parent; - parent = NULL; - /* - * Make sure the last processed component was a directory. The - * trailing slashes are illegal behind anything else. - */ - if (!(err || - S_ISDIR(nd->nd_pno->p_base->pb_ino->i_stbuf.st_mode))) - err = -ENOTDIR; - } - - /* - * Drop reference to parent if set. Either we have a dup of the original - * parent or an intermediate reference. - */ - if (parent) - P_RELE(parent); - - /* - * On error, we will want to drop our reference to the current - * path node if at end. - */ - if (err && nd->nd_pno) { - P_RELE(nd->nd_pno); - nd->nd_pno = NULL; - } - - return err; -} - -#ifdef CPLANT_YOD -/* - * for backward compatibility w/protocol switch - * remove everything up to the first ':' - * fortran libs prepend cwd to path, so not much choice - */ -#define STRIP_PREFIX(p) strchr(p,':') ? strchr(p,':')+1 : p -#else -#define STRIP_PREFIX(p) p -#endif - -/* - * Expanded form of the path-walk routine, with the common arguments, builds - * the nameidata bundle and calls path-walk. - */ -int -_sysio_namei(struct pnode *parent, - const char *path, - unsigned flags, - struct intent *intnt, - struct pnode **pnop) -{ - struct nameidata nameidata; - int err; - - ND_INIT(&nameidata, flags, STRIP_PREFIX(path), _sysio_root, intnt); - err = _sysio_path_walk(parent, &nameidata); - if (!err) - *pnop = nameidata.nd_pno; - return err; -} diff --git a/libsysio/src/open.c b/libsysio/src/open.c deleted file mode 100644 index 86426da..0000000 --- a/libsysio/src/open.c +++ /dev/null @@ -1,308 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2006 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -/* - * Incorporate the GNU flags for open if we can. - */ -#define _GNU_SOURCE - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "file.h" -#include "fs.h" -#include "mount.h" -#include "sysio-symbols.h" - -/* - * Open file support. - */ - -mode_t _sysio_umask = 0; /* process umask. */ - -/* - * Internal form of open. - */ -int -_sysio_open(struct pnode *pno, int flags, mode_t mode) -{ - int ro; - int w; - int err; - struct inode *ino; - - ro = IS_RDONLY(pno); - w = flags & (O_WRONLY|O_RDWR); - if (w == (O_WRONLY|O_RDWR)) { - /* - * Huh? - */ - return -EINVAL; - } - if (w && ro) - return -EROFS; - ino = pno->p_base->pb_ino; - if ((flags & O_CREAT) && !ino) { - struct pnode *parent; - - /* - * Must create it. - */ - if (ro) - return -EROFS; - parent = pno->p_parent; - err = _sysio_p_validate(parent, NULL, NULL); - if (!err) { - ino = parent->p_base->pb_ino; - assert(ino); - err = (*ino->i_ops.inop_open)(pno, flags, mode); - } - } else if ((flags & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL)) - err = -EEXIST; - else if (!ino) - err = _sysio_p_validate(pno, NULL, NULL); -#ifdef O_NOFOLLOW - else if (flags & O_NOFOLLOW && S_ISLNK(ino->i_stbuf.st_mode)) - err = -ELOOP; -#endif - else { - /* - * Simple open of pre-existing file. - */ - err = (*ino->i_ops.inop_open)(pno, flags, mode); - } - - return err; -} - -#undef open - -int -SYSIO_INTERFACE_NAME(open)(const char *path, int flags, ...) -{ - mode_t mode; - unsigned ndflags; - struct intent intent; - int rtn; - struct pnode *pno; - struct file *fil; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - /* - * Get mode argument and determine parameters for namei - */ - mode = 0; - ndflags = 0; - intent.int_opmask = INT_OPEN; - if (flags & O_CREAT) { - va_list ap; - - /* - * Set ndflags to indicate return of negative alias is OK. - */ - ndflags |= ND_NEGOK; - - /* - * Will need mode too. - */ - va_start(ap, flags); - mode = -#ifndef REDSTORM - va_arg(ap, mode_t); -#else - va_arg(ap, int); -#endif - va_end(ap); - mode &= ~(_sysio_umask & 0777) | 07000; /* apply umask */ - intent.int_opmask |= INT_CREAT; - } -#ifdef O_NOFOLLOW - if (flags & O_NOFOLLOW) - ndflags |= ND_NOFOLLOW; -#endif - - /* - * Find the file. - */ - fil = NULL; - INTENT_INIT(&intent, intent.int_opmask, &mode, &flags); - pno = NULL; - rtn = _sysio_namei(_sysio_cwd, path, ndflags, &intent, &pno); - if (rtn) - goto error; - /* - * Ask for the open/creat. - */ - rtn = _sysio_open(pno, flags, mode); - if (rtn) - goto error; - /* - * Get a file descriptor. - */ - fil = _sysio_fnew(pno->p_base->pb_ino, flags); - if (!fil) { - rtn = -ENOMEM; - goto error; - } - rtn = _sysio_fd_set(fil, -1, 0); - if (rtn < 0) - goto error; - - P_RELE(pno); - - SYSIO_INTERFACE_RETURN(rtn, 0); - -error: - if (fil) - F_RELE(fil); - if (pno) - P_RELE(pno); - SYSIO_INTERFACE_RETURN(-1, rtn); -} - -#ifdef __GLIBC__ -#undef __open -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(open), - PREPEND(__, SYSIO_INTERFACE_NAME(open))) -#undef open64 -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(open), SYSIO_INTERFACE_NAME(open64)) -#undef __open64 -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(open), - PREPEND(__, SYSIO_INTERFACE_NAME(open64))) -#endif - -#ifdef REDSTORM -#undef __libc_open64 -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(open), - PREPEND(__, SYSIO_INTERFACE_NAME(libc_open64))) -#endif - -#ifdef BSD -#undef _open -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(open), - PREPEND(_, SYSIO_INTERFACE_NAME(open))) -#endif - -int -SYSIO_INTERFACE_NAME(close)(int fd) -{ - int err; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - err = _sysio_fd_close(fd); - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef __GLIBC__ -#undef __close -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(close), - PREPEND(__, SYSIO_INTERFACE_NAME(close))) -#endif - -#ifdef BSD -#undef _close -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(close), - PREPEND(_, SYSIO_INTERFACE_NAME(close))) -#endif - -int -SYSIO_INTERFACE_NAME(creat)(const char *path, mode_t mode) -{ - - return SYSIO_INTERFACE_NAME(open)(path, O_CREAT|O_WRONLY|O_TRUNC, mode); -} - -#ifdef __GLIBC__ -#undef __creat -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(creat), - PREPEND(__, SYSIO_INTERFACE_NAME(creat))) -#undef creat64 -#ifndef HAVE_LUSTRE_HACK -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(creat), SYSIO_INTERFACE_NAME(creat64)) -#else -/* XXX workaround SuSE SLES 8, glibc-2.2.5 */ -sysio_sym_strong_alias(SYSIO_INTERFACE_NAME(creat), - SYSIO_INTERFACE_NAME(creat64)) -#endif -#undef __creat64 -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(creat), - PREPEND(__, SYSIO_INTERFACE_NAME(creat64))) -#endif - -#ifdef REDSTORM -#undef __libc_creat -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(creat), - PREPEND(__, SYSIO_INTERFACE_NAME(libc_creat))) -#endif - -#ifdef BSD -#undef _creat -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(creat), - PREPEND(_, SYSIO_INTERFACE_NAME(creat))) -#endif - -mode_t -SYSIO_INTERFACE_NAME(umask)(mode_t mask) -{ - mode_t omask; - - omask = _sysio_umask; - _sysio_umask = mask & 0777; - return omask; -} - -#ifdef REDSTORM -#undef __umask -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(umask), - PREPEND(__, SYSIO_INTERFACE_NAME(umask))) -#endif diff --git a/libsysio/src/readdir.c b/libsysio/src/readdir.c deleted file mode 100644 index 2633f96..0000000 --- a/libsysio/src/readdir.c +++ /dev/null @@ -1,161 +0,0 @@ -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifdef __linux__ -#include -#if defined(__GLIBC__) && !defined(REDSTORM) - -#include -#include -#include -#include -#include -#include - -#include "sysio-symbols.h" - -#ifndef _READDIR -#define _READDIR SYSIO_INTERFACE_NAME(readdir) -#define _SCANDIR SYSIO_INTERFACE_NAME(scandir) -#define _GETDIRENTRIES SYSIO_INTERFACE_NAME(getdirentries) -#define _DIRENT_T struct dirent -#define _OFF_T off_t -#endif - -#include "stddir.h" - -_DIRENT_T * -_READDIR(DIR *dir) -{ - _DIRENT_T *dp = NULL; - _OFF_T dbase; - -#ifndef BSD - ssize_t rc; -#else - int rc; -#endif - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - - /* need to read new data? */ - rc = 0; - if (dir->cur >= dir->effective) { - dir->cur = 0; - dbase = (_OFF_T )dir->base; - if (sizeof(dbase) != sizeof(dir->base) && - dbase != dir->base) { - dir->effective = 0; - SYSIO_INTERFACE_RETURN(NULL, -EOVERFLOW); - } - rc = _GETDIRENTRIES(dir->fd, - dir->buf, -#ifndef BSD - (size_t )BUFSIZE, - (_OFF_T *) &dbase); -#else - (int )BUFSIZE, - (long *) __restrict dbase); -#endif - dir->base = (_SYSIO_OFF_T )dbase; - - /* error or end-of-file */ - if (rc == -ENOENT) - rc = 0; - if (rc <= 0) { - dir->effective = 0; - SYSIO_INTERFACE_RETURN(NULL, rc); - } - dir->effective = rc; - } - dp = (_DIRENT_T *)(dir->buf + dir->cur); - -#ifdef _DIRENT_HAVE_D_RECLEN - dir->cur += dp->d_reclen; -#else - dir->cur += sizeof(_DIRENT_T); -#endif -#ifdef _DIRENT_HAVE_D_OFF - dir->filepos = dp->d_off; -#else - dir->filepos = dir->cur; -#endif - - SYSIO_INTERFACE_RETURN(dp, 0); -} - -sysio_sym_weak_alias(_READDIR, PREPEND(__,_READDIR)) - -int -_SCANDIR(const char *dirname, - _DIRENT_T ***namelist, - int (*filter) (const _DIRENT_T *), -#ifdef HAVE_POSIX2008_SCANDIR - int(*compar)(const _DIRENT_T **, const _DIRENT_T **) -#else - int(*compar)(const void *, const void *) -#endif - ) -{ - DIR *dir = NULL; - _DIRENT_T *de = NULL, - *nextde = NULL, - **s = NULL; - int n = 32, i = 0; - size_t desize; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - - if ((dir = SYSIO_INTERFACE_NAME(opendir)(dirname)) == NULL) - SYSIO_INTERFACE_RETURN(-1, -errno); - - while ((de = _READDIR(dir)) != NULL) { - if ((filter == NULL) || filter(de)) { - if (i == 0 || i >= n) { - n = MAX(n, 2*i); - s = (_DIRENT_T **)realloc(s, - (size_t )(n * sizeof(_DIRENT_T *))); - if (!s) - SYSIO_INTERFACE_RETURN(-1, -ENOMEM); - } - desize = &de->d_name[_D_ALLOC_NAMLEN(de)] - (char * )de; - nextde = (_DIRENT_T *)malloc(desize); - if (!nextde) - SYSIO_INTERFACE_RETURN(-1, -ENOMEM); - - s[i++] = (_DIRENT_T *)memcpy(nextde, de, desize); - } - } - if (compar) - qsort (s, - i, - sizeof (*s), - (int (*)(const void *, const void *))compar); - - *namelist = s; - - SYSIO_INTERFACE_NAME(closedir)(dir); - - SYSIO_INTERFACE_RETURN(i, 0); -} - -sysio_sym_weak_alias(_SCANDIR, PREPEND(__,_SCANDIR)) - -#endif -#endif diff --git a/libsysio/src/readdir64.c b/libsysio/src/readdir64.c deleted file mode 100644 index f6d54a8..0000000 --- a/libsysio/src/readdir64.c +++ /dev/null @@ -1,10 +0,0 @@ -#ifdef _LARGEFILE64_SOURCE -#define _SCANDIR SYSIO_INTERFACE_NAME(scandir64) -#define _READDIR SYSIO_INTERFACE_NAME(readdir64) -#define _GETDIRENTRIES SYSIO_INTERFACE_NAME(getdirentries64) -#define _DIRENT_T struct dirent64 -#define _OFF_T _SYSIO_OFF_T - -#include "readdir.c" - -#endif diff --git a/libsysio/src/readlink.c b/libsysio/src/readlink.c deleted file mode 100644 index c8e7436..0000000 --- a/libsysio/src/readlink.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2004 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "sysio-symbols.h" - -#ifdef HAVE_POSIX_1003_READLINK -ssize_t -#else -int -#endif -SYSIO_INTERFACE_NAME(readlink)(const char *path, char *buf, size_t bufsiz) -{ - struct intent intent; - int err; - struct pnode *pno; - struct inode *ino; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - INTENT_INIT(&intent, INT_GETATTR, NULL, NULL); - err = _sysio_namei(_sysio_cwd, path, ND_NOFOLLOW, &intent, &pno); - if (err) - goto out; - ino = pno->p_base->pb_ino; - if (!S_ISLNK(ino->i_stbuf.st_mode)) { - err = -EINVAL; - goto error; - } - err = (*ino->i_ops.inop_readlink)(pno, buf, bufsiz); -error: - P_RELE(pno); -out: - SYSIO_INTERFACE_RETURN(err < 0 ? -1 : err, err >= 0 ? 0 : err); -} - -#ifdef REDSTORM -#undef __readlink -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(readlink), - PREPEND(__, SYSIO_INTERFACE_NAME(readlink))) -#endif diff --git a/libsysio/src/reconcile.c b/libsysio/src/reconcile.c deleted file mode 100644 index 8fa01fd..0000000 --- a/libsysio/src/reconcile.c +++ /dev/null @@ -1,356 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2004 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "xtio.h" - -/* - * Extent-vector IO support. - */ - -/* - * Arguments to IO vector enumerator callback when used by _sysio_doio(). - */ -struct doio_helper_args { - ssize_t (*f)(void *, size_t, _SYSIO_OFF_T, void *); /* base func */ - void *arg; /* caller arg */ -}; - -/* - * General help validating strided-IO vectors. - * - * A driver may call this to make sure underflow/overflow of an off_t can't - * occur and overflow of a ssize_t can't occur when writing. The sum - * of the reconciled transfer length is returned or some appropriate - * error depending on underflow/overflow. - * - * The following algorithm assumes: - * - * a) sizeof(size_t) >= sizeof(ssize_t) - * b) 2's complement arithmetic - * c) The compiler won't optimize away code because it's developers - * believed that something with an undefined result in `C' can't happen. - */ -ssize_t -_sysio_validx(const struct intnl_xtvec *xtv, size_t xtvlen, - const struct iovec *iov, size_t iovlen, - _SYSIO_OFF_T limit) -{ - ssize_t acc, cc; - struct iovec iovec; - struct intnl_xtvec xtvec; - _SYSIO_OFF_T off; - - if (!(xtvlen && iovlen)) - return -EINVAL; - - acc = 0; - xtvec.xtv_len = iovec.iov_len = 0; - do { - while (!xtvec.xtv_len) { - if (!xtvlen--) - break; - if (!xtv->xtv_len) { - xtv++; - continue; - } - xtvec = *xtv++; - if (xtvec.xtv_off < 0) - return -EINVAL; - } - if (!xtvec.xtv_len) - break; - do { - while (!iovec.iov_len) { - if (!iovlen--) - break; - if (!iov->iov_len) { - iov++; - continue; - } - iovec = *iov++; - } - if (!iovec.iov_len) - break; - cc = iovec.iov_len; - if (cc < 0) - return -EINVAL; - if ((size_t )cc > xtvec.xtv_len) - cc = xtvec.xtv_len; - xtvec.xtv_len -= cc; - iovec.iov_len -= cc; - off = xtvec.xtv_off + cc; - if (xtvec.xtv_off && off <= xtvec.xtv_off) - return off < 0 ? -EINVAL : -EOVERFLOW; - if (off > limit) - return -EFBIG; - xtvec.xtv_off = off; - cc += acc; - if (acc && (cc <= acc)) - return -EINVAL; - acc = cc; - } while (xtvec.xtv_len && iovlen); - } while ((xtvlen || xtvec.xtv_len) && iovlen); - return acc; -} - -/* - */ -ssize_t -_sysio_enumerate_extents(const struct intnl_xtvec *xtv, size_t xtvlen, - const struct iovec *iov, size_t iovlen, - ssize_t (*f)(const struct iovec *, int, - _SYSIO_OFF_T, - ssize_t, - void *), - void *arg) -{ - ssize_t acc, tmp, cc; - struct iovec iovec; - struct intnl_xtvec xtvec; - const struct iovec *start; - _SYSIO_OFF_T off; - size_t n; - size_t remain; - - acc = 0; - iovec.iov_len = 0; - while (xtvlen) { - /* - * Coalesce contiguous extent vector entries. - */ - off = xtvec.xtv_off = xtv->xtv_off; - off += xtvec.xtv_len = xtv->xtv_len; - while (++xtv, --xtvlen) { - if (off != xtv->xtv_off) { - /* - * Not contiguous. - */ - break; - } - if (!xtv->xtv_len) { - /* - * Zero length. - */ - continue; - } - off += xtv->xtv_len; - xtvec.xtv_len += xtv->xtv_len; - } - while (xtvec.xtv_len) { - if (iovec.iov_len) { - tmp = iovec.iov_len; - if (iovec.iov_len > xtvec.xtv_len) - iovec.iov_len = xtvec.xtv_len; - cc = - (*f)(&iovec, 1, - xtvec.xtv_off, - xtvec.xtv_len, - arg); - if (cc <= 0) { - if (acc) - return acc; - return cc; - } - iovec.iov_base = (char *)iovec.iov_base + cc; - iovec.iov_len = tmp - cc; - tmp = cc + acc; - if (acc && tmp <= acc) - abort(); /* paranoia */ - acc = tmp; - } else if (iovlen) { - start = iov; - n = xtvec.xtv_len; - do { - if (iov->iov_len > n) { - /* - * That'll do. - */ - break; - } - n -= iov->iov_len; - iov++; - } while (--iovlen); - if (iov == start) { - iovec = *iov++; - iovlen--; - continue; - } - remain = xtvec.xtv_len - n; - cc = - (*f)(start, iov - start, - xtvec.xtv_off, - remain, - arg); - if (cc <= 0) { - if (acc) - return acc; - return cc; - } - - tmp = cc + acc; - if (acc && tmp <= acc) - abort(); /* paranoia */ - acc = tmp; - - remain -= cc; - if (remain) - return acc; /* short */ - } else - return acc; /* short out */ - xtvec.xtv_off += cc; - xtvec.xtv_len -= cc; - } - } - return acc; -} - -ssize_t -_sysio_enumerate_iovec(const struct iovec *iov, size_t count, - _SYSIO_OFF_T off, - ssize_t limit, - ssize_t (*f)(void *, size_t, _SYSIO_OFF_T, void *), - void *arg) -{ - ssize_t acc, cc; - size_t n; - unsigned indx; - size_t remain; - - if (!count) - return -EINVAL; - assert(limit >= 0); - acc = 0; - n = limit; - for (indx = 0; n && indx < count; indx++) { - if (iov[indx].iov_len < n) { - cc = (ssize_t )iov[indx].iov_len; - if (cc < 0) - return -EINVAL; - } else - cc = (ssize_t )n; - if (!cc) - continue; - n -= cc; - cc += acc; - if (acc && cc <= acc) - return -EINVAL; - acc = cc; - } - if (!acc) - return 0; - acc = 0; - do { - if (!iov->iov_len) { - iov++; - continue; - } - n = - iov->iov_len < (size_t )limit - ? iov->iov_len - : (size_t )limit; - cc = (*f)(iov->iov_base, n, off, arg); - if (cc <= 0) { - if (acc) - return acc; - return cc; - } - off += cc; - limit -= cc; - remain = iov->iov_len - cc; - cc += acc; - if (acc && cc <= acc) - abort(); /* bad driver! */ - acc = cc; - if (remain || !limit) - break; /* short/limited read */ - iov++; - } while (--count); - return acc; -} - -static ssize_t -_sysio_doio_helper(const struct iovec *iov, int count, - _SYSIO_OFF_T off, - ssize_t limit, - struct doio_helper_args *args) -{ - - return _sysio_enumerate_iovec(iov, count, - off, limit, - args->f, - args->arg); -} - -/* - * A meta-driver for the whole strided-io process. Appropriate when - * the driver can't handle anything but simple p{read,write}-like - * interface. - */ -ssize_t -_sysio_doio(const struct intnl_xtvec *xtv, size_t xtvlen, - const struct iovec *iov, size_t iovlen, - ssize_t (*f)(void *, size_t, _SYSIO_OFF_T, void *), - void *arg) -{ - struct doio_helper_args arguments; - - arguments.f = f; - arguments.arg = arg; - return _sysio_enumerate_extents(xtv, xtvlen, - iov, iovlen, - (ssize_t (*)(const struct iovec *, int, - _SYSIO_OFF_T, - ssize_t, - void *))_sysio_doio_helper, - &arguments); -} diff --git a/libsysio/src/rename.c b/libsysio/src/rename.c deleted file mode 100644 index 05606ca..0000000 --- a/libsysio/src/rename.c +++ /dev/null @@ -1,190 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "mount.h" -#include "inode.h" - -int -SYSIO_INTERFACE_NAME(rename)(const char *oldpath, const char *newpath) -{ - struct intent intent; - int err; - struct pnode *old, *new; - struct pnode_base *nxtpb, *pb; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - - /* - * Neither old nor new may be the empty string. - */ - if (*oldpath == '\0' || *newpath == '\0') - SYSIO_INTERFACE_RETURN(-1, -ENOENT); - - /* - * Resolve oldpath to a path node. - */ - INTENT_INIT(&intent, INT_UPDPARENT, NULL, NULL); - err = _sysio_namei(_sysio_cwd, oldpath, ND_NOFOLLOW, &intent, &old); - if (err) - goto error3; - /* - * Resolve newpath to a path node. - */ - INTENT_INIT(&intent, INT_UPDPARENT, NULL, NULL); - err = - _sysio_namei(_sysio_cwd, - newpath, - ND_NOFOLLOW | ND_NEGOK, - &intent, - &new); - if (err) - goto error2; - - /* - * Don't allow mount points to move. - */ - if (old->p_mount->mnt_root == old || old->p_cover || - new->p_mount->mnt_root == new) { - err = -EBUSY; - goto error1; - } - - /* - * No xdev renames either. - */ - if (old->p_mount->mnt_fs != new->p_mount->mnt_fs) { - err = -EXDEV; - goto error1; - } - - /* - * Make sure the old pnode can't be found in the ancestor chain - * for the new. If it can, they are trying to move into a subdirectory - * of the old. - */ - nxtpb = new->p_base; - do { - pb = nxtpb; - nxtpb = pb->pb_parent; - if (pb == old->p_base) { - err = -EINVAL; - goto error1; - } - } while (nxtpb); - - /* - * If old == new, we're done. - */ - if (old->p_base->pb_ino == new->p_base->pb_ino) - goto short_out; - - if (new->p_base->pb_ino) { - /* - * Existing entry. We're replacing the new. Make sure that's - * ok. - */ - if (S_ISDIR(new->p_base->pb_ino->i_stbuf.st_mode)) { - if (!S_ISDIR(old->p_base->pb_ino->i_stbuf.st_mode)) { - err = -EISDIR; - goto error1; - } - if (new->p_base->pb_ino->i_stbuf.st_nlink > 2) { - err = -ENOTEMPTY; - goto error1; - } - } else if (S_ISDIR(old->p_base->pb_ino->i_stbuf.st_mode)) { - err = -ENOTDIR; - goto error1; - } - } - - /* - * It's not impossible to clean up the altered name space after - * a rename. However, it is onerous and I don't want to do it right - * now. If it becomes an issue, we can do it later. For now, I've - * elected to use the semantic that says, basically, the entire - * sub-tree must be unreferenced. That's per POSIX, but it's a nasty - * thing to do to the caller. - */ - if (_sysio_p_prune(new) != 1) { - err = -EBUSY; - goto error1; - } - /* - * Use the parent node operations to request the task in case the - * driver is implemented using differentiated inode operations based - * on file type, such as incore does. - */ - err = old->p_parent->p_base->pb_ino->i_ops.inop_rename(old, new); - if (err) - goto error1; - /* - * Reflect the successful rename in the active name space graph. - */ - if (new->p_base->pb_ino) - I_GONE(new->p_base->pb_ino); - new->p_base->pb_ino = old->p_base->pb_ino; - old->p_base->pb_ino = NULL; - -short_out: -error1: - P_RELE(new); -error2: - P_RELE(old); -error3: - if (err) - goto out; -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} diff --git a/libsysio/src/rmdir.c b/libsysio/src/rmdir.c deleted file mode 100644 index bf13fa2..0000000 --- a/libsysio/src/rmdir.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2006 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "fs.h" -#include "mount.h" -#include "sysio-symbols.h" - -int -SYSIO_INTERFACE_NAME(rmdir)(const char *path) -{ - struct intent intent; - int err; - struct pnode *pno; - struct inode *ino; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - INTENT_INIT(&intent, INT_UPDPARENT, NULL, NULL); - err = _sysio_namei(_sysio_cwd, path, 0, &intent, &pno); - if (err) - goto out; - if (!S_ISDIR(pno->p_base->pb_ino->i_stbuf.st_mode)) { - err = -ENOTDIR; - goto error; - } - err = _sysio_permitted(pno->p_parent, W_OK); - if (err) - goto error; - if (pno->p_ref > 1) { - err = -EBUSY; - goto error; - } - /* - * Use the parent node operations to request the task in case the - * driver is implemented using differentiated inode operations based - * on file type, such as incore does. - */ - err = (*pno->p_parent->p_base->pb_ino->i_ops.inop_rmdir)(pno); - if (err) - goto error; - /* - * Invalidate the path-base node and kill the i-node. - */ - ino = pno->p_base->pb_ino; - pno->p_base->pb_ino = NULL; - I_GONE(ino); -error: - P_RELE(pno); -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef REDSTORM -#undef __rmdir -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(rmdir), - PREPEND(__, SYSIO_INTERFACE_NAME(rmdir))) -#endif diff --git a/libsysio/src/rw.c b/libsysio/src/rw.c deleted file mode 100644 index ebbca58..0000000 --- a/libsysio/src/rw.c +++ /dev/null @@ -1,1337 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2004 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "xtio.h" -#include "file.h" -#include "inode.h" - -#include "sysio-symbols.h" - -#define IIOXOP_READ(ino) (ino)->i_ops.inop_read, 0 -#define IIOXOP_WRITE(ino) (ino)->i_ops.inop_write, 1 - -/* - * Decoding the interface routine names: - * - * Much of this carries legacy from the POSIX world and the Intel ASCI - * Red programming environment. Routine names are composed of prefix, - * basic POSIX names, and postfix. The basic POSIX names are read and write. - * Prefixes, left-to-right: - * - * - 'i' -- asynchronous operation (from ASCI Red) - * - 'p' -- positional (POSIX) - * Posfixes, only one: - * - 'v' -- vectored (POSIX) - * - 'x' -- extent-based (new for Red Storm) - * - * All valid combinations are available and symmetric. - */ - -/* - * Post op using iovec with regions specified by the passed extent vector. - * - * NOTE: There are enough parameters that we should really consider - * passing them in a structure. - */ -static int -_sysio_iiox(int (*f)(struct inode *, struct ioctx *), - int wr, - struct file *fil, - const struct iovec *iov, - size_t iov_count, - void (*iov_free)(struct ioctx *), - const struct intnl_xtvec *xtv, - size_t xtv_count, - void (*xtv_free)(struct ioctx *), - void (*completio)(struct ioctx *, void *), - struct ioctx **ioctxp) -{ - struct inode *ino; - ssize_t cc; - struct ioctx *ioctx; - int err; - struct ioctx_callback *cb; - - /* - * Check that it was opened with flags supporting the operation. - */ - if (!F_CHKRW(fil, wr ? 'w' : 'r')) - return -EBADF; - - ino = fil->f_ino; - if (!ino) { - /* - * Huh? It's dead. - */ - return -EBADF; - } - cc = - _sysio_validx(xtv, xtv_count, - iov, iov_count, -#if defined(_LARGEFILE64_SOURCE) && defined(O_LARGEFILE) - (fil->f_flags & O_LARGEFILE) == 0 - ? LONG_MAX - : -#endif - _SYSIO_OFF_T_MAX); - if (cc < 0) - return cc; - ioctx = _sysio_ioctx_new(ino, wr, iov, iov_count, xtv, xtv_count); - if (!ioctx) - return -ENOMEM; - if ((iov_free && - (err = _sysio_ioctx_cb(ioctx, - (void (*)(struct ioctx *, - void *))iov_free, - NULL))) || - (xtv_free && - (err = _sysio_ioctx_cb(ioctx, - (void (*)(struct ioctx *, - void *))xtv_free, - NULL))) || - (completio && - (err = _sysio_ioctx_cb(ioctx, - (void (*)(struct ioctx *, - void *))completio, - fil))) || - (err = (*f)(ino, ioctx))) { - /* - * Release the callback queue. Don't want it run after all. - */ - while ((cb = ioctx->ioctx_cbq.tqh_first)) { - TAILQ_REMOVE(&ioctx->ioctx_cbq, - cb, - iocb_next); - _sysio_ioctx_cb_free(cb); - } - _sysio_ioctx_complete(ioctx); - return err; - } - *ioctxp = ioctx; - return 0; -} - -/* - * Sum iovec entries, returning total found or error if range of ssize_t would - * be exceeded. - */ -static ssize_t -_sysio_sum_iovec(const struct iovec *iov, int count) -{ - ssize_t tmp, cc; - - if (count <= 0) - return -EINVAL; - - cc = 0; - while (count--) { - tmp = cc; - cc += iov->iov_len; - if (tmp && iov->iov_len && cc <= tmp) - return -EINVAL; - iov++; - } - return cc; -} - -/* - * Asynch IO from/to iovec from/to current file offset. - */ -static int -_sysio_iiov(int (*f)(struct inode *, struct ioctx *), - int wr, - struct file *fil, - const struct iovec *iov, - int count, - void (*iov_free)(struct ioctx *), - struct intnl_xtvec *xtv, - void (*xtv_free)(struct ioctx *), - struct ioctx **ioctxp) -{ - ssize_t cc; - _SYSIO_OFF_T off; - int err; - - cc = _sysio_sum_iovec(iov, count); - if (cc < 0) - return (int )cc; - xtv->xtv_off = fil->f_pos; - xtv->xtv_len = cc; - off = xtv->xtv_off + xtv->xtv_len; - if (xtv->xtv_off && off <= xtv->xtv_off) { - /* - * Ouch! The IO vector specifies more bytes than - * are addressable. Trim the region to limit how - * much of the IO vector is finally transferred. - */ - xtv->xtv_len = _SYSIO_OFF_T_MAX - xtv->xtv_off; - } - err = - _sysio_iiox(f, - wr, - fil, - iov, count, iov_free, - xtv, 1, xtv_free, - (void (*)(struct ioctx *, void *))_sysio_fcompletio, - ioctxp); - if (err) - return err; - return 0; -} - -static void -free_xtv(struct ioctx *ioctx) -{ - - free((struct iovec *)ioctx->ioctx_xtv); - ioctx->ioctx_iov = NULL; -} - -ioid_t -SYSIO_INTERFACE_NAME(ireadv)(int fd, const struct iovec *iov, int count) -{ - struct file *fil; - struct intnl_xtvec *xtv; - struct ioctx *ioctx; - int err; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!fil) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF); - - xtv = malloc(sizeof(struct intnl_xtvec)); - if (!xtv) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM); - - err = - _sysio_iiov(IIOXOP_READ(fil->f_ino), - fil, - iov, count, NULL, - xtv, free_xtv, - &ioctx); - if (err) { - free(xtv); - SYSIO_INTERFACE_RETURN(IOID_FAIL, err); - } - SYSIO_INTERFACE_RETURN(ioctx, 0); -} - -ssize_t -SYSIO_INTERFACE_NAME(readv)(int fd, const struct iovec *iov, int count) -{ - struct file *fil; - struct intnl_xtvec xtvector; - struct ioctx *ioctx; - int err; - ssize_t cc; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!fil) - SYSIO_INTERFACE_RETURN(-1, -EBADF); - - err = - _sysio_iiov(IIOXOP_READ(fil->f_ino), - fil, - iov, count, NULL, - &xtvector, NULL, - &ioctx); - if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0) - err = (int )cc; - - SYSIO_INTERFACE_RETURN(err ? -1 : cc, err); -} - -#if defined(__GLIBC__) -#undef __readv -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(readv), - PREPEND(__, SYSIO_INTERFACE_NAME(readv))) -#undef __libc_readv -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(readv), - PREPEND(__, SYSIO_INTERFACE_NAME(libc_readv))) -#endif - -static void -free_iov(struct ioctx *ioctx) -{ - - free((struct iovec *)ioctx->ioctx_iov); - ioctx->ioctx_iov = NULL; -} - -ioid_t -SYSIO_INTERFACE_NAME(iread)(int fd, void *buf, size_t count) -{ - struct iovec *iov; - struct file *fil; - struct intnl_xtvec *xtv; - struct ioctx *ioctx; - int err; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!fil) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF); - - iov = malloc(sizeof(struct iovec)); - if (!iov) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM); - - iov->iov_base = buf; - iov->iov_len = count; - xtv = malloc(sizeof(struct intnl_xtvec)); - if (!xtv) { - free(iov); - SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM); - } - err = - _sysio_iiov(IIOXOP_READ(fil->f_ino), - fil, - iov, 1, free_iov, - xtv, free_xtv, - &ioctx); - if (err) { - free(xtv); - free(iov); - SYSIO_INTERFACE_RETURN(IOID_FAIL, err); - } - SYSIO_INTERFACE_RETURN(ioctx, 0); -} - -ssize_t -SYSIO_INTERFACE_NAME(read)(int fd, void *buf, size_t count) -{ - struct file *fil; - struct iovec iovector; - struct intnl_xtvec xtvector; - int err; - struct ioctx *ioctx; - ssize_t cc; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!fil) - SYSIO_INTERFACE_RETURN(-1, -EBADF); - - iovector.iov_base = buf; - iovector.iov_len = count; - err = - _sysio_iiov(IIOXOP_READ(fil->f_ino), - fil, - &iovector, 1, NULL, - &xtvector, NULL, - &ioctx); - if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0) - err = (int )cc; - SYSIO_INTERFACE_RETURN(err ? -1 : cc, err); -} - -#ifdef __GLIBC__ -#undef __read -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(read), - PREPEND(__, SYSIO_INTERFACE_NAME(read))) -#undef __libc_read -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(read), - PREPEND(__, SYSIO_INTERFACE_NAME(libc_read))) -#endif - -/* - * Asynch IO between iovec and data at the given offset. - */ -static int -_sysio_ipiov(int (*f)(struct inode *, struct ioctx *), - int wr, - struct file *fil, - const struct iovec *iov, - int count, - void (*iov_free)(struct ioctx *), - _SYSIO_OFF_T off, - struct intnl_xtvec *xtv, - void (*xtv_free)(struct ioctx *), - struct ioctx **ioctxp) -{ - ssize_t cc; - int err; - - SYSIO_ENTER; - cc = _sysio_sum_iovec(iov, count); - if (cc < 0) { - SYSIO_LEAVE; - return (int )cc; - } - xtv->xtv_off = off, - xtv->xtv_len = cc; - err = - _sysio_iiox(f, - wr, - fil, - iov, count, iov_free, - xtv, 1, xtv_free, - NULL, - ioctxp); - SYSIO_LEAVE; - if (err) - return err; - return 0; -} - -static ioid_t -PREPEND(_, SYSIO_INTERFACE_NAME(ipreadv))(int fd, - const struct iovec *iov, - size_t count, - _SYSIO_OFF_T offset) -{ - struct file *fil; - struct intnl_xtvec *xtv; - struct ioctx *ioctx; - int err; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!fil) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF); - - xtv = malloc(sizeof(struct intnl_xtvec)); - if (!xtv) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM); - - err = - _sysio_ipiov(IIOXOP_READ(fil->f_ino), - fil, - iov, count, NULL, - offset, - xtv, free_xtv, - &ioctx); - if (err) { - free(xtv); - SYSIO_INTERFACE_RETURN(IOID_FAIL, err); - } - SYSIO_INTERFACE_RETURN(ioctx, 0); -} - -#ifdef _LARGEFILE64_SOURCE -#undef ipread64v -sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(ipreadv)), - SYSIO_INTERFACE_NAME(ipread64v)) -#endif - -ioid_t -SYSIO_INTERFACE_NAME(ipreadv)(int fd, - const struct iovec *iov, - size_t count, - off_t offset) -{ - - return PREPEND(_, SYSIO_INTERFACE_NAME(ipreadv))(fd, - iov, - count, - offset); -} - -static ssize_t -PREPEND(_, SYSIO_INTERFACE_NAME(preadv))(int fd, - const struct iovec *iov, - _SYSIO_PREADV_T count, - _SYSIO_OFF_T offset) -{ - struct file *fil; - struct intnl_xtvec xtvector; - struct ioctx *ioctx; - int err; - ssize_t cc; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!fil) - SYSIO_INTERFACE_RETURN(-1, -EBADF); - - err = - _sysio_ipiov(IIOXOP_READ(fil->f_ino), - fil, - iov, count, NULL, - offset, - &xtvector, NULL, - &ioctx); - if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0) - err = (int )cc; - - SYSIO_INTERFACE_RETURN(err ? -1 : cc, err); -} - -#ifdef _LARGEFILE64_SOURCE -#undef pread64v -sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(preadv)), - SYSIO_INTERFACE_NAME(pread64v)) -#endif - -ssize_t -SYSIO_INTERFACE_NAME(preadv)(int fd, - const struct iovec *iov, - _SYSIO_PREADV_T count, - off_t offset) -{ - - return PREPEND(_, SYSIO_INTERFACE_NAME(preadv))(fd, - iov, - count, - offset); -} - -static ioid_t -PREPEND(_, SYSIO_INTERFACE_NAME(ipread))(int fd, - void *buf, - size_t count, - _SYSIO_OFF_T offset) -{ - struct file *fil; - struct intnl_xtvec *xtv; - struct iovec *iov; - struct ioctx *ioctx; - int err; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!fil) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF); - - xtv = malloc(sizeof(struct intnl_xtvec)); - iov = malloc(sizeof(struct iovec)); - if (!(xtv && iov)) { - err = -ENOMEM; - goto error; - } - xtv->xtv_off = offset; - iov->iov_base = buf; - xtv->xtv_len = iov->iov_len = count; - err = - _sysio_ipiov(IIOXOP_READ(fil->f_ino), - fil, - iov, 1, free_iov, - offset, - xtv, free_xtv, - &ioctx); -error: - if (err) { - if (iov) - free(iov); - if (xtv) - free(xtv); - SYSIO_INTERFACE_RETURN(IOID_FAIL, err); - } - SYSIO_INTERFACE_RETURN(ioctx, 0); -} - -#ifdef _LARGEFILE64_SOURCE -#undef ipread64 -sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(ipread)), - SYSIO_INTERFACE_NAME(ipread64)) -#endif - -ioid_t -SYSIO_INTERFACE_NAME(ipread)(int fd, - void *buf, - size_t count, - off_t offset) -{ - - return PREPEND(_, SYSIO_INTERFACE_NAME(ipread))(fd, - buf, - count, - offset); -} - -ssize_t -PREPEND(_, SYSIO_INTERFACE_NAME(pread))(int fd, - void *buf, - size_t count, - _SYSIO_OFF_T offset) -{ - struct file *fil; - struct intnl_xtvec xtvec; - struct iovec iovec; - struct ioctx *ioctx; - int err; - ssize_t cc; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!fil) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF); - - xtvec.xtv_off = offset; - iovec.iov_base = buf; - xtvec.xtv_len = iovec.iov_len = count; - err = - _sysio_ipiov(IIOXOP_READ(fil->f_ino), - fil, - &iovec, 1, NULL, - offset, - &xtvec, NULL, - &ioctx); - if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0) - err = (int )cc; - - SYSIO_INTERFACE_RETURN(err ? -1 : cc, err); -} - -#ifdef _LARGEFILE64_SOURCE -#undef pread64 -sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(pread)), - SYSIO_INTERFACE_NAME(pread64)) -#if __GLIBC__ -#undef __pread64 -sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(pread)), - PREPEND(__, SYSIO_INTERFACE_NAME(pread64))) -#undef __libc_pread64 -sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(pread)), - PREPEND(__, SYSIO_INTERFACE_NAME(libc_pread64))) -#endif -#endif - -ssize_t -SYSIO_INTERFACE_NAME(pread)(int fd, void *buf, size_t count, off_t offset) -{ - - return PREPEND(_, SYSIO_INTERFACE_NAME(pread))(fd, - buf, - count, - offset); -} - -#if __GLIBC__ -#undef __pread -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(pread), - PREPEND(__, SYSIO_INTERFACE_NAME(pread))) -#undef __libc_pread -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(pread), - PREPEND(__, SYSIO_INTERFACE_NAME(libc_pread))) -#endif - -static ioid_t -PREPEND(_, SYSIO_INTERFACE_NAME(ireadx))(int fd, - const struct iovec *iov, - size_t iov_count, - const struct intnl_xtvec *xtv, - size_t xtv_count) -{ - struct file *fil; - int err; - struct ioctx *ioctx; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!fil) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF); - - /* Perform a check on the iov_count and xtv_count */ - if ((iov_count == 0) || (xtv_count == 0)) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -EINVAL); - - err = - _sysio_iiox(IIOXOP_READ(fil->f_ino), - fil, - iov, iov_count, NULL, - xtv, xtv_count, NULL, - NULL, - &ioctx); - - SYSIO_INTERFACE_RETURN(err ? IOID_FAIL : ioctx, err); -} - -#ifdef _LARGEFILE64_SOURCE -#undef iread64x -sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(ireadx)), - SYSIO_INTERFACE_NAME(iread64x)) -#endif - -#ifdef _LARGEFILE64_SOURCE -ioid_t -SYSIO_INTERFACE_NAME(ireadx)(int fd, - const struct iovec *iov, size_t iov_count, - const struct xtvec *xtv, size_t xtv_count) -{ - struct file *fil; - struct intnl_xtvec *ixtv, *ixtvent; - size_t count; - int err; - struct ioctx *ioctx; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!fil) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF); - - - /* Perform a check on the iov_count and xtv_count */ - if ((iov_count == 0) || (xtv_count == 0)) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -EINVAL); - - ixtv = ixtvent = malloc(xtv_count * sizeof(struct intnl_xtvec)); - if (!ixtv) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM); - - count = xtv_count; - while (count--) { - ixtvent->xtv_off = xtv->xtv_off; - ixtvent->xtv_len = xtv->xtv_len; - ixtvent++; - xtv++; - } - - err = - _sysio_iiox(IIOXOP_READ(fil->f_ino), - fil, - iov, iov_count, NULL, - ixtv, xtv_count, free_xtv, - NULL, - &ioctx); - if (err) { - free(ixtv); - SYSIO_INTERFACE_RETURN(IOID_FAIL, err); - } - SYSIO_INTERFACE_RETURN(ioctx, 0); -} -#else -#undef ireadx -sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(ireadx)), - SYSIO_INTERFACE_NAME(ireadx)) -#endif - -ssize_t -SYSIO_INTERFACE_NAME(readx)(int fd, - const struct iovec *iov, size_t iov_count, - const struct xtvec *xtv, size_t xtv_count) -{ - ioid_t ioid; - - if ((ioid = SYSIO_INTERFACE_NAME(ireadx)(fd, - iov, - iov_count, - xtv, - xtv_count)) == IOID_FAIL) - return -1; - return SYSIO_INTERFACE_NAME(iowait)(ioid); -} - -#ifdef _LARGEFILE64_SOURCE -#undef iread64x -ssize_t -SYSIO_INTERFACE_NAME(read64x)(int fd, - const struct iovec *iov, size_t iov_count, - const struct xtvec64 *xtv, size_t xtv_count) -{ - ioid_t ioid; - - if ((ioid = SYSIO_INTERFACE_NAME(iread64x)(fd, - iov, - iov_count, - xtv, - xtv_count)) == IOID_FAIL) - return -1; - return SYSIO_INTERFACE_NAME(iowait)(ioid); -} -#endif - -#ifdef notdef -int -read_list(int fd, - int mem_list_count, - char *mem_offsets[], - int mem_lengths[], - int file_list_count, - int64_t file_offsets[], - int32_t file_lengths[]) -{ - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - SYSIO_INTERFACE_RETURN(-1, -ENOSYS); -} -#endif - -ioid_t -SYSIO_INTERFACE_NAME(iwritev)(int fd, - const struct iovec *iov, - int count) -{ - struct file *fil; - struct intnl_xtvec *xtv; - struct ioctx *ioctx; - int err; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!fil) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF); - - xtv = malloc(sizeof(struct intnl_xtvec)); - if (!xtv) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM); - - err = - _sysio_iiov(IIOXOP_WRITE(fil->f_ino), - fil, - iov, count, NULL, - xtv, free_xtv, - &ioctx); - if (err) { - free(xtv); - SYSIO_INTERFACE_RETURN(IOID_FAIL, err); - } - SYSIO_INTERFACE_RETURN(ioctx, 0); -} - -ssize_t -SYSIO_INTERFACE_NAME(writev)(int fd, const struct iovec *iov, - int count) -{ - struct file *fil; - struct intnl_xtvec xtvector; - struct ioctx *ioctx; - int err; - ssize_t cc; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!fil) - SYSIO_INTERFACE_RETURN(-1, -EBADF); - - err = - _sysio_iiov(IIOXOP_WRITE(fil->f_ino), - fil, - iov, count, NULL, - &xtvector, NULL, - &ioctx); - if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0) - err = (int )cc; - - SYSIO_INTERFACE_RETURN(err < 0 ? -1 : cc, err); -} - -#ifdef __GLIBC__ -#undef __writev -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(writev), - PREPEND(__, SYSIO_INTERFACE_NAME(writev))) -#undef __libc_writev -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(writev), - PREPEND(__, SYSIO_INTERFACE_NAME(libc_writev))) -#endif - -ioid_t -SYSIO_INTERFACE_NAME(iwrite)(int fd, const void *buf, size_t count) -{ - struct iovec *iov; - struct file *fil; - struct intnl_xtvec *xtv; - struct ioctx *ioctx; - int err; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!fil) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF); - - iov = malloc(sizeof(struct iovec)); - if (!iov) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM); - - iov->iov_base = (void *)buf; - iov->iov_len = count; - xtv = malloc(sizeof(struct intnl_xtvec)); - if (!xtv) { - free(iov); - SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM); - } - err = - _sysio_iiov(IIOXOP_WRITE(fil->f_ino), - fil, - iov, 1, free_iov, - xtv, free_xtv, - &ioctx); - if (err) { - free(xtv); - free(iov); - SYSIO_INTERFACE_RETURN(IOID_FAIL, err); - } - SYSIO_INTERFACE_RETURN(ioctx, 0); -} - -ssize_t -SYSIO_INTERFACE_NAME(write)(int fd, const void *buf, size_t count) -{ - struct file *fil; - struct iovec iovector; - struct intnl_xtvec xtvector; - int err; - struct ioctx *ioctx; - ssize_t cc; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!fil) - SYSIO_INTERFACE_RETURN(-1, -EBADF); - - iovector.iov_base = (void *)buf; - iovector.iov_len = count; - err = - _sysio_iiov(IIOXOP_WRITE(fil->f_ino), - fil, - &iovector, 1, NULL, - &xtvector, NULL, - &ioctx); - if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0) - err = (int )cc; - - SYSIO_INTERFACE_RETURN(err < 0 ? -1 : cc, err); -} - -#ifdef __GLIBC__ -#undef __write -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(write), - PREPEND(__, SYSIO_INTERFACE_NAME(write))) -#undef __libc_write -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(write), - PREPEND(__, SYSIO_INTERFACE_NAME(libc_write))) -#endif - -static ioid_t -PREPEND(_, SYSIO_INTERFACE_NAME(ipwritev))(int fd, - const struct iovec *iov, - size_t count, - _SYSIO_OFF_T offset) -{ - struct file *fil; - struct intnl_xtvec *xtv; - struct ioctx *ioctx; - int err; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!fil) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF); - - xtv = malloc(sizeof(struct intnl_xtvec)); - if (!xtv) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM); - - err = - _sysio_ipiov(IIOXOP_WRITE(fil->f_ino), - fil, - iov, count, NULL, - offset, - xtv, free_xtv, - &ioctx); - if (err) { - free(xtv); - SYSIO_INTERFACE_RETURN(IOID_FAIL, err); - } - SYSIO_INTERFACE_RETURN(ioctx, 0); -} - -#ifdef _LARGEFILE64_SOURCE -#undef ipwrite64v -sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(ipwritev)), - SYSIO_INTERFACE_NAME(ipwrite64v)) -#endif - -ioid_t -SYSIO_INTERFACE_NAME(ipwritev)(int fd, - const struct iovec *iov, - size_t count, - off_t offset) -{ - - return PREPEND(_, SYSIO_INTERFACE_NAME(ipwritev))(fd, - iov, - count, - offset); -} - -static ssize_t -PREPEND(_, SYSIO_INTERFACE_NAME(pwritev))(int fd, - const struct iovec *iov, - _SYSIO_PREADV_T count, - _SYSIO_OFF_T offset) -{ - struct file *fil; - struct intnl_xtvec xtvector; - struct ioctx *ioctx; - int err; - ssize_t cc; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!fil) - SYSIO_INTERFACE_RETURN(-1, -EBADF); - - err = - _sysio_ipiov(IIOXOP_WRITE(fil->f_ino), - fil, - iov, count, NULL, - offset, - &xtvector, NULL, - &ioctx); - if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0) - err = (int )cc; - - SYSIO_INTERFACE_RETURN(err ? -1 : cc, err); -} - -#ifdef _LARGEFILE64_SOURCE -#undef pwrite64v -sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(pwritev)), - SYSIO_INTERFACE_NAME(pwrite64v)) -#endif - -ssize_t -SYSIO_INTERFACE_NAME(pwritev)(int fd, - const struct iovec *iov, - _SYSIO_PREADV_T count, - off_t offset) -{ - - return PREPEND(_, SYSIO_INTERFACE_NAME(pwritev))(fd, - iov, - count, - offset); -} - -static ioid_t -PREPEND(_, SYSIO_INTERFACE_NAME(ipwrite))(int fd, - const void *buf, - size_t count, - _SYSIO_OFF_T offset) -{ - struct file *fil; - struct intnl_xtvec *xtv; - struct iovec *iov; - struct ioctx *ioctx; - int err; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!fil) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF); - - xtv = malloc(sizeof(struct intnl_xtvec)); - iov = malloc(sizeof(struct iovec)); - if (!(xtv && iov)) { - err = -errno; - goto error; - } - xtv->xtv_off = offset; - iov->iov_base = (void *)buf; - xtv->xtv_len = iov->iov_len = count; - err = - _sysio_ipiov(IIOXOP_WRITE(fil->f_ino), - fil, - iov, 1, free_iov, - offset, - xtv, free_xtv, - &ioctx); -error: - if (err) { - if (iov) - free(iov); - if (xtv) - free(xtv); - SYSIO_INTERFACE_RETURN(IOID_FAIL, err); - } - SYSIO_INTERFACE_RETURN(ioctx, 0); -} - -#ifdef _LARGEFILE64_SOURCE -#undef ipwrite64 -sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(ipwrite)), - SYSIO_INTERFACE_NAME(ipwrite64)) -#endif - -ioid_t -SYSIO_INTERFACE_NAME(ipwrite)(int fd, - const void *buf, - size_t count, - off_t offset) -{ - - return PREPEND(_, SYSIO_INTERFACE_NAME(ipwrite))(fd, - buf, - count, - offset); -} - -ssize_t -PREPEND(_, SYSIO_INTERFACE_NAME(pwrite))(int fd, - const void *buf, - size_t count, - _SYSIO_OFF_T offset) -{ - struct file *fil; - struct intnl_xtvec xtvec; - struct iovec iovec; - struct ioctx *ioctx; - int err; - ssize_t cc; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!fil) - SYSIO_INTERFACE_RETURN(-1, -EBADF); - - xtvec.xtv_off = offset; - iovec.iov_base = (void *)buf; - xtvec.xtv_len = iovec.iov_len = count; - err = - _sysio_ipiov(IIOXOP_WRITE(fil->f_ino), - fil, - &iovec, 1, NULL, - offset, - &xtvec, NULL, - &ioctx); - if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0) - err = (int )cc; - - SYSIO_INTERFACE_RETURN(err ? -1 : cc, err); -} - -#ifdef _LARGEFILE64_SOURCE -#undef pwrite64 -sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(pwrite)), - SYSIO_INTERFACE_NAME(pwrite64)) -#ifdef __GLIBC -#undef __pwrite64 -sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(pwrite)), - PREPEND(__, SYSIO_INTERFACE_NAME(pwrite64))) -#undef __libc_pwrite64 -sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(pwrite)), - PREPEND(__, SYSIO_INTERFACE_NAME(libc_pwrite64))) -#endif -#endif - -ssize_t -SYSIO_INTERFACE_NAME(pwrite)(int fd, - const void *buf, - size_t count, - off_t offset) -{ - - return PREPEND(_, SYSIO_INTERFACE_NAME(pwrite))(fd, - buf, - count, - offset); -} - -#ifdef __GLIBC -#undef __libc_pwrite -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(pwrite), __libc_pwrite) - PREPEND(__, SYSIO_INTERFACE_NAME(libc_pwrite))) -#endif - -static ioid_t -PREPEND(_, SYSIO_INTERFACE_NAME(iwritex))(int fd, - const struct iovec *iov, - size_t iov_count, - const struct intnl_xtvec *xtv, - size_t xtv_count) -{ - struct file *fil; - int err; - struct ioctx *ioctx; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!(fil && xtv_count)) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF); - - err = - _sysio_iiox(IIOXOP_WRITE(fil->f_ino), - fil, - iov, iov_count, NULL, - xtv, xtv_count, NULL, - NULL, - &ioctx); - - SYSIO_INTERFACE_RETURN(err ? IOID_FAIL : ioctx, err); -} - -#ifdef _LARGEFILE64_SOURCE -#undef iwrite64x -sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(iwritex)), - SYSIO_INTERFACE_NAME(iwrite64x)) -#endif - -#ifdef _LARGEFILE64_SOURCE -ioid_t -SYSIO_INTERFACE_NAME(iwritex)(int fd, - const struct iovec *iov, size_t iov_count, - const struct xtvec *xtv, size_t xtv_count) -{ - struct file *fil; - struct intnl_xtvec *ixtv, *ixtvent; - size_t count; - int err; - struct ioctx *ioctx; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!fil) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF); - - /* Perform a check on the iov_count and xtv_count */ - if ((iov_count == 0) || (xtv_count == 0)) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -EINVAL); - - ixtv = ixtvent = malloc(xtv_count * sizeof(struct intnl_xtvec)); - if (!ixtv) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM); - - count = xtv_count; - while (count--) { - ixtvent->xtv_off = xtv->xtv_off; - ixtvent->xtv_len = xtv->xtv_len; - ixtvent++; - xtv++; - } - - err = - _sysio_iiox(IIOXOP_WRITE(fil->f_ino), - fil, - iov, iov_count, NULL, - ixtv, xtv_count, free_xtv, - NULL, - &ioctx); - if (err) { - free(ixtv); - SYSIO_INTERFACE_RETURN(IOID_FAIL, err); - } - SYSIO_INTERFACE_RETURN(ioctx, 0); -} -#else -#undef iwritex -sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(iwritex)), - SYSIO_INTERFACE_NAME(iwritex)) -#endif - -#undef writex -ssize_t -SYSIO_INTERFACE_NAME(writex)(int fd, - const struct iovec *iov, size_t iov_count, - const struct xtvec *xtv, size_t xtv_count) -{ - ioid_t ioid; - - if ((ioid = - SYSIO_INTERFACE_NAME(iwritex)(fd, - iov, - iov_count, - xtv, - xtv_count)) == IOID_FAIL) - return -1; - return SYSIO_INTERFACE_NAME(iowait)(ioid); -} - -#ifdef _LARGEFILE64_SOURCE -#undef write64x -ssize_t -SYSIO_INTERFACE_NAME(write64x)(int fd, - const struct iovec *iov, size_t iov_count, - const struct xtvec64 *xtv, size_t xtv_count) -{ - ioid_t ioid; - - if ((ioid = SYSIO_INTERFACE_NAME(iwrite64x)(fd, - iov, - iov_count, - xtv, - xtv_count)) == IOID_FAIL) - return -1; - return SYSIO_INTERFACE_NAME(iowait)(ioid); -} -#endif - -#ifdef notdef -int -write_list(int fd, - int mem_list_count, - char *mem_offsets[], - int mem_lengths[], - int file_list_count, - int64_t file_offsets[], - int32_t file_lengths[]) -{ - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - SYSIO_INTERFACE_RETURN(-1, -ENOSYS); -} -#endif diff --git a/libsysio/src/stat.c b/libsysio/src/stat.c deleted file mode 100644 index 607924a..0000000 --- a/libsysio/src/stat.c +++ /dev/null @@ -1,286 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "file.h" - -#include "sysio-symbols.h" - -#ifndef REDSTORM -#undef fstat -#undef stat -#undef lstat -#endif - -#undef __fxstat -#undef __xstat -#undef __lxstat - -#if !defined(_STAT_VER) -#define _STAT_VER 0 -#endif - -#ifdef _LARGEFILE64_SOURCE -static void -convstat(struct stat64 *st64_buf, struct stat *st_buf) -{ - - st_buf->st_dev = st64_buf->st_dev; - st_buf->st_ino = st64_buf->st_ino; - st_buf->st_mode = st64_buf->st_mode; - st_buf->st_nlink = st64_buf->st_nlink; - st_buf->st_uid = st64_buf->st_uid; - st_buf->st_gid = st64_buf->st_gid; - st_buf->st_rdev = st64_buf->st_rdev; - st_buf->st_size = st64_buf->st_size; - st_buf->st_blksize = st64_buf->st_blksize; - st_buf->st_blocks = st64_buf->st_blocks; - st_buf->st_atime = st64_buf->st_atime; - st_buf->st_mtime = st64_buf->st_mtime; - st_buf->st_ctime = st64_buf->st_ctime; -} -#endif - -int -PREPEND(__, SYSIO_INTERFACE_NAME(fxstat))(int __ver, - int __fildes, - struct stat *__stat_buf) -{ - struct file *fil; - int err; - struct intnl_stat *buf; -#ifdef _LARGEFILE64_SOURCE - struct stat64 st64; -#endif - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - if (__ver != _STAT_VER) { - err = -ENOSYS; - goto out; - } - - err = 0; - fil = _sysio_fd_find(__fildes); - if (!fil) { - err = -EBADF; - goto out; - } -#ifdef _LARGEFILE64_SOURCE - buf = &st64; -#else - buf = __stat_buf; -#endif - /* - * Never use the attributes cached in the inode record. Give the - * driver a chance to refresh them. - */ - err = - fil->f_ino->i_ops.inop_getattr(NULL, fil->f_ino, buf); -#ifdef _LARGEFILE64_SOURCE - if (!err) - convstat(buf, __stat_buf); -#endif -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef REDSTORM -#undef _fxstat -sysio_sym_weak_alias(PREPEND(__, SYSIO_INTERFACE_NAME(fxstat)), - PREPEND(_, SYSIO_INTERFACE_NAME(fxstat))) -#endif - -#ifndef REDSTORM -static int -PREPEND(__, SYSIO_INTERFACE_NAME(fstat))(int fd, struct stat *buf) -{ - - return PREPEND(__, SYSIO_INTERFACE_NAME(fxstat))(_STAT_VER, - fd, - buf); -} - -sysio_sym_weak_alias(PREPEND(__, SYSIO_INTERFACE_NAME(fstat)), - SYSIO_INTERFACE_NAME(fstat)) - -#ifdef BSD -#undef _fstat -sysio_sym_weak_alias(PREPEND(__, SYSIO_INTERFACE_NAME(fstat)), - PREPEND(_, SYSIO_INTERFACE_NAME(fstat))) -#endif -#endif - -int -PREPEND(__, SYSIO_INTERFACE_NAME(xstat))(int __ver, - const char *__filename, - struct stat *__stat_buf) -{ - struct intent intent; - int err; - struct pnode *pno; - struct inode *ino; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - if (__ver != _STAT_VER) { - err = -ENOSYS; - goto out; - } - - INTENT_INIT(&intent, INT_GETATTR, NULL, NULL); - err = _sysio_namei(_sysio_cwd, __filename, 0, &intent, &pno); - if (err) - goto out; - /* - * Leverage the INT_GETATTR intent above. We are counting - * on the FS driver to either make sure the attributes cached in - * the inode are always correct or refresh them in the lookup, above. - */ - ino = pno->p_base->pb_ino; -#ifdef _LARGEFILE64_SOURCE - convstat(&ino->i_stbuf, __stat_buf); -#else - (void )memcpy(__stat_buf, &ino->i_stbuf, sizeof(struct intnl_stat)); -#endif - P_RELE(pno); -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef REDSTORM -#undef _xstat -sysio_sym_weak_alias(PREPEND(__, SYSIO_INTERFACE_NAME(xstat)), - PREPEND(_, SYSIO_INTERFACE_NAME(xstat))) -#endif - -#ifndef REDSTORM -static int -PREPEND(__, SYSIO_INTERFACE_NAME(stat))(const char *filename, - struct stat *buf) -{ - - return PREPEND(__, SYSIO_INTERFACE_NAME(xstat))(_STAT_VER, - filename, - buf); -} - -sysio_sym_weak_alias(PREPEND(__, SYSIO_INTERFACE_NAME(stat)), - SYSIO_INTERFACE_NAME(stat)) - -#ifdef BSD -#undef _stat -sysio_sym_weak_alias(PREPEND(__, SYSIO_INTERFACE_NAME(stat)), - PREPEND(_, SYSIO_INTERFACE_NAME(stat))) -#endif -#endif - -int -PREPEND(__, SYSIO_INTERFACE_NAME(lxstat))(int __ver, - const char *__filename, - struct stat *__stat_buf) -{ - struct intent intent; - int err; - struct pnode *pno; - struct inode *ino; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - if (__ver != _STAT_VER) { - err = -ENOSYS; - goto out; - } - - INTENT_INIT(&intent, INT_GETATTR, NULL, NULL); - err = _sysio_namei(_sysio_cwd, __filename, ND_NOFOLLOW, &intent, &pno); - if (err) - goto out; - /* - * Leverage the INT_GETATTR intent above. We are counting - * on the FS driver to either make sure the attributes cached in - * the inode are always correct or refresh them in the lookup, above. - */ - ino = pno->p_base->pb_ino; -#ifdef _LARGEFILE64_SOURCE - convstat(&ino->i_stbuf, __stat_buf); -#else - (void )memcpy(__stat_buf, &ino->i_stbuf, sizeof(struct intnl_stat)); -#endif - P_RELE(pno); -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef REDSTORM -#undef _lxstat -sysio_sym_weak_alias(PREPEND(__, SYSIO_INTERFACE_NAME(lxstat)), - PREPEND(_, SYSIO_INTERFACE_NAME(lxstat))) -#endif - -#ifndef REDSTORM -static int -PREPEND(__, SYSIO_INTERFACE_NAME(lstat))(const char *filename, struct stat *buf) -{ - return PREPEND(__, SYSIO_INTERFACE_NAME(lxstat))(_STAT_VER, - filename, - buf); -} - -sysio_sym_weak_alias(PREPEND(__, SYSIO_INTERFACE_NAME(lstat)), - SYSIO_INTERFACE_NAME(lstat)) - -#ifdef BSD -#undef _lstat -sysio_sym_weak_alias(PREPEND(__, SYSIO_INTERFACE_NAME(lstat)), - PREPEND(_, SYSIO_INTERFACE_NAME(lstat))) -#endif -#endif diff --git a/libsysio/src/stat64.c b/libsysio/src/stat64.c deleted file mode 100644 index 70bd43a..0000000 --- a/libsysio/src/stat64.c +++ /dev/null @@ -1,194 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#ifdef _LARGEFILE64_SOURCE - -#include -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "file.h" - -#ifndef REDSTORM -#undef fstat64 -#undef stat64 -#undef lstat64 -#endif - -#undef __fxstat64 -#undef __xstat64 -#undef __lxstat64 - -int -PREPEND(__, SYSIO_INTERFACE_NAME(fxstat64))(int __ver, - int __fildes, - struct stat64 *__stat_buf) -{ - struct file *fil; - int err; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - if (__ver != _STAT_VER) { - err = -ENOSYS; - goto out; - } - - err = 0; - fil = _sysio_fd_find(__fildes); - if (!fil) { - err = -EBADF; - goto out; - } - /* - * Never use the attributes cached in the inode record. Give - * the driver a chance to refresh them. - */ - err = fil->f_ino->i_ops.inop_getattr(NULL, fil->f_ino, __stat_buf); -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifndef REDSTORM -int -SYSIO_INTERFACE_NAME(fstat64)(int fd, struct stat64 *buf) -{ - - return PREPEND(__, SYSIO_INTERFACE_NAME(fxstat64))(_STAT_VER, fd, buf); -} -#endif - -int -PREPEND(__, SYSIO_INTERFACE_NAME(xstat64))(int __ver, - const char *__filename, - struct stat64 *__stat_buf) -{ - struct intent intent; - int err; - struct pnode *pno; - struct inode *ino; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - if (__ver != _STAT_VER) { - err = -ENOSYS; - goto out; - } - - INTENT_INIT(&intent, INT_GETATTR, NULL, NULL); - err = _sysio_namei(_sysio_cwd, __filename, 0, &intent, &pno); - if (err) - goto out; - /* - * Leverage the INT_GETATTR intent above. We are counting - * on the FS driver to either make sure the attributes cached in - * the inode are always correct or refresh them in the lookup, above. - */ - ino = pno->p_base->pb_ino; - (void )memcpy(__stat_buf, &ino->i_stbuf, sizeof(struct intnl_stat)); - P_RELE(pno); -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifndef REDSTORM -int -SYSIO_INTERFACE_NAME(stat64)(const char *filename, struct stat64 *buf) -{ - - return PREPEND(__, SYSIO_INTERFACE_NAME(xstat64))(_STAT_VER, - filename, - buf); -} -#endif - -int -PREPEND(__, SYSIO_INTERFACE_NAME(lxstat64))(int __ver, - const char *__filename, - struct stat64 *__stat_buf) -{ - struct intent intent; - int err; - struct pnode *pno; - struct inode *ino; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - if (__ver != _STAT_VER) { - err = -ENOSYS; - goto out; - } - - INTENT_INIT(&intent, INT_GETATTR, NULL, NULL); - err = _sysio_namei(_sysio_cwd, __filename, ND_NOFOLLOW, &intent, &pno); - if (err) - goto out; - /* - * Leverage the INT_GETATTR intent above. We are counting - * on the FS driver to either make sure the attributes cached in - * the inode are always correct or refresh them in the lookup, above. - */ - ino = pno->p_base->pb_ino; - (void )memcpy(__stat_buf, &ino->i_stbuf, sizeof(struct intnl_stat)); - P_RELE(pno); -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifndef REDSTORM -int -SYSIO_INTERFACE_NAME(lstat64)(const char *filename, struct stat64 *buf) -{ - - return PREPEND(__, SYSIO_INTERFACE_NAME(lxstat64))(_STAT_VER, - filename, - buf); -} -#endif -#endif /* !_LARGEFILE64_SOURCE */ diff --git a/libsysio/src/statvfs.c b/libsysio/src/statvfs.c deleted file mode 100644 index 5f07387..0000000 --- a/libsysio/src/statvfs.c +++ /dev/null @@ -1,155 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#ifndef BSD - -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "file.h" -#include "sysio-symbols.h" - -#undef statvfs -#undef fstatvfs - -#ifndef INTNL_STATVFS_IS_NATURAL -static void -convstatvfs(struct statvfs *stvfsbuf, struct intnl_statvfs *istvfsbuf) -{ - stvfsbuf->f_bsize = istvfsbuf->f_bsize; - stvfsbuf->f_frsize = istvfsbuf->f_frsize; - stvfsbuf->f_blocks = (unsigned long )istvfsbuf->f_blocks; - stvfsbuf->f_bfree = (unsigned long )istvfsbuf->f_bfree; - stvfsbuf->f_bavail = (unsigned long )istvfsbuf->f_bavail; - stvfsbuf->f_files = (unsigned long )istvfsbuf->f_files; - stvfsbuf->f_ffree = (unsigned long )istvfsbuf->f_ffree; - stvfsbuf->f_favail = (unsigned long )istvfsbuf->f_favail; - stvfsbuf->f_fsid = istvfsbuf->f_fsid; - stvfsbuf->f_flag = istvfsbuf->f_flag; - stvfsbuf->f_namemax = istvfsbuf->f_namemax; -} -#endif - -int -SYSIO_INTERFACE_NAME(statvfs)(const char *path, struct statvfs *buf) -{ - int err; - struct pnode *pno; -#ifdef INTNL_STATVFS_IS_NATURAL -#define _call_buf buf -#else - struct intnl_statvfs _call_buffer; - struct intnl_statvfs *_call_buf = &_call_buffer; -#endif - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - err = _sysio_namei(_sysio_cwd, path, 0, NULL, &pno); - if (err) - goto out; - - err = pno->p_base->pb_ino->i_ops.inop_statvfs(pno, NULL, _call_buf); - P_RELE(pno); - if (err) - goto err; -#ifndef INTNL_STATVFS_IS_NATURAL - convstatvfs(buf, _call_buf); -#endif - goto out; -err: -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef REDSTORM -#undef __statvfs -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(statvfs), - PREPEND(__, SYSIO_INTERFACE_NAME(statvfs))) -#endif - -int -SYSIO_INTERFACE_NAME(fstatvfs)(int fd, struct statvfs *buf) -{ - int err; - struct file *filp; -#ifdef INTNL_STATVFS_IS_NATURAL -#define _call_buf buf -#else - struct intnl_statvfs _call_buffer; - struct intnl_statvfs *_call_buf = &_call_buffer; -#endif - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - err = 0; - filp = _sysio_fd_find(fd); - if (!filp) { - err = -EBADF; - goto out; - } - - err = filp->f_ino->i_ops.inop_statvfs(NULL, filp->f_ino, _call_buf); - if (err) - goto err; -#ifndef INTNL_STATVFS_IS_NATURAL - convstatvfs(buf, _call_buf); -#endif - goto out; -err: -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef REDSTORM -#undef __fstatvfs -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(fstatvfs), - PREPEND(__, SYSIO_INTERFACE_NAME(fstatvfs))) -#endif - -#endif /* ifndef BSD */ diff --git a/libsysio/src/statvfs64.c b/libsysio/src/statvfs64.c deleted file mode 100644 index c89c969..0000000 --- a/libsysio/src/statvfs64.c +++ /dev/null @@ -1,107 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#ifndef BSD -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "file.h" -#include "sysio-symbols.h" - -int -SYSIO_INTERFACE_NAME(statvfs64)(const char *path, struct statvfs64 *buf) -{ - int err; - struct pnode *pno; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - err = _sysio_namei(_sysio_cwd, path, 0, NULL, &pno); - if (err) - goto out; - - err = pno->p_base->pb_ino->i_ops.inop_statvfs(pno, NULL, buf); - P_RELE(pno); -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef REDSTORM -#undef __statvfs64 -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(statvfs64), - PREPEND(__, SYSIO_INTERFACE_NAME(statvfs64))) -#endif - -int -SYSIO_INTERFACE_NAME(fstatvfs64)(int fd, struct statvfs64 *buf) -{ - int err; - struct file *filp; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - err = 0; - filp = _sysio_fd_find(fd); - if (!filp) { - err = -EBADF; - goto out; - } - - err = filp->f_ino->i_ops.inop_statvfs(NULL, filp->f_ino, buf); -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef REDSTORM -#undef __fstatvfs64 -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(fstatvfs64), - PREPEND(__, SYSIO_INTERFACE_NAME(fstatvfs64))) -#endif - -#endif /* ifndef BSD */ diff --git a/libsysio/src/stddir.c b/libsysio/src/stddir.c deleted file mode 100644 index 41f589b..0000000 --- a/libsysio/src/stddir.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifdef __linux__ -#include -#if defined(__GLIBC__) && !defined(REDSTORM) - -/* - * stddir.c - * - * As of glibc 2.3, the new capability to define functions with a 'hidden' - * attribute means that any time glibc decides to use that capability - * we will no longer be able to successfully intercept low level calls - * in a link against default system glibc. Thus the following imported - * functions. - */ - -#include -#include -#include -#include -#include - -#include - -#include "sysio-symbols.h" -#include "stddir.h" - -/*********************************************************** - * dir series functions * - ***********************************************************/ - -DIR* -SYSIO_INTERFACE_NAME(opendir)(const char *name) -{ - DIR *dir; - - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - - dir = (DIR * )calloc(1, sizeof(DIR)); - if (!dir) - SYSIO_INTERFACE_RETURN(NULL, -ENOMEM); - - dir->fd = SYSIO_INTERFACE_NAME(open)(name, O_RDONLY); - if (dir->fd < 0) { - free(dir); - SYSIO_INTERFACE_RETURN(NULL, -errno); - } - return dir; -} - -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(opendir), - PREPEND(__, SYSIO_INTERFACE_NAME(opendir))) - -int -SYSIO_INTERFACE_NAME(closedir)(DIR *dir) -{ - int rc; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - - rc = SYSIO_INTERFACE_NAME(close)(dir->fd); - free(dir); - - SYSIO_INTERFACE_RETURN(rc, 0); -} - -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(closedir), - PREPEND(__, SYSIO_INTERFACE_NAME(closedir))) - -int -SYSIO_INTERFACE_NAME(dirfd)(DIR *dir) -{ - return(dir->fd); -} - -long int -SYSIO_INTERFACE_NAME(telldir)(DIR *dir) -{ - return(dir->filepos); -} - -void -SYSIO_INTERFACE_NAME(seekdir)(DIR *dir, long int offset) -{ - dir->filepos = offset; - dir->base = offset; - dir->effective = 0; - dir->cur = 0; -} - -void -SYSIO_INTERFACE_NAME(rewinddir)(DIR *dir) -{ - dir->base = 0; - dir->filepos = 0; - dir->cur = 0; - dir->effective = 0; -} - -#endif -#endif diff --git a/libsysio/src/stdlib.c b/libsysio/src/stdlib.c deleted file mode 100644 index 03bf1c7..0000000 --- a/libsysio/src/stdlib.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/* - * stdlib.c - * - * The only purpose of this file is help liblustre adaptive to more - * applications, and specifically for running on Linux. The ideal - * final solution would be remove this completely and only rely on - * system call interception. Unfortunately we failed to find that - * way at the moment. - * - * Initially we try the simplest implementation here, just get a confidence - * it could work. - * - */ -#if !(defined(BSD) || defined(REDSTORM)) - -#include -#include -#include -#include - -#include - -#include "sysio-symbols.h" - -/*********************************************************** - * FIXME workaround for linux only * - ***********************************************************/ - -#define LINUX -#if defined(LINUX) -ssize_t getxattr(char *path, char *name, void *value, size_t size) -{ - errno = ENOSYS; - return -1; -} - -ssize_t lgetxattr(char *path, char *name, void *value, size_t size) -{ - errno = ENOSYS; - return -1; -} - -ssize_t fgetxattr(int fd, char *name, void *value, size_t size) -{ - errno = ENOSYS; - return -1; -} - -long setxattr(char *path, char *name, void *value, size_t size, int flags) -{ - errno = ENOSYS; - return -1; -} - -long lsetxattr(char *path, char *name, void *value, size_t size, int flags) -{ - errno = ENOSYS; - return -1; -} - -long fsetxattr(int fd, char *name, void *value, size_t size, int flags) -{ - errno = ENOSYS; - return -1; -} - -long listxattr(char *path, char *list, size_t size) -{ - errno = ENOSYS; - return -1; -} - -long llistxattr(char *path, char *list, size_t size) -{ - errno = ENOSYS; - return -1; -} - -long flistxattr(int fd, char *list, size_t size) -{ - errno = ENOSYS; - return -1; -} - -long removexattr(char *path, char *name) -{ - errno = ENOSYS; - return -1; -} - -long lremovexattr(char *path, char *name) -{ - errno = ENOSYS; - return -1; -} - -long fremovexattr(int fd, char *name) -{ - errno = ENOSYS; - return -1; -} -#endif - -#endif diff --git a/libsysio/src/symlink.c b/libsysio/src/symlink.c deleted file mode 100644 index 2a31e37..0000000 --- a/libsysio/src/symlink.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2006 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "fs.h" -#include "mount.h" -#include "sysio-symbols.h" - -int -SYSIO_INTERFACE_NAME(symlink)(const char *oldpath, const char *newpath) -{ - int err; - struct intent intent; - struct pnode *pno; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - INTENT_INIT(&intent, INT_CREAT, NULL, NULL); - err = - _sysio_namei(_sysio_cwd, - newpath, - ND_NOFOLLOW|ND_NEGOK, - &intent, - &pno); - if (err) - goto out; - if (pno->p_base->pb_ino) { - err = -EEXIST; - goto error; - } - err = _sysio_permitted(pno->p_parent, W_OK); - if (err) - goto error; - - /* - * Use the parent node operations to request the task in case the - * driver is implemented using differentiated inode operations based - * on file type, such as incore does. - */ - err = - (*pno->p_parent->p_base->pb_ino->i_ops.inop_symlink)(pno, oldpath); -error: - P_RELE(pno); -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef REDSTORM -#undef __symlink -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(symlink), - PREPEND(__, SYSIO_INTERFACE_NAME(symlink))) -#endif diff --git a/libsysio/src/truncate.c b/libsysio/src/truncate.c deleted file mode 100644 index 27ef6b6..0000000 --- a/libsysio/src/truncate.c +++ /dev/null @@ -1,164 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "file.h" -#include "fs.h" -#include "mount.h" - -#include "sysio-symbols.h" - -/* - * Truncate file, given path (alias) or index node. - */ -static int -do_truncate(struct pnode *pno, struct inode *ino, _SYSIO_OFF_T length) -{ - struct intnl_stat stbuf; - unsigned mask; - - if (length < 0) - return -EINVAL; - - if (!ino && pno->p_base->pb_ino) - ino = pno->p_base->pb_ino; - if (!ino) - return -EBADF; - if (S_ISDIR(ino->i_stbuf.st_mode)) /* for others too? */ - return -EISDIR; - if (!S_ISREG(ino->i_stbuf.st_mode)) - return -EINVAL; - - (void )memset(&stbuf, 0, sizeof(stbuf)); - stbuf.st_size = length; - mask = SETATTR_LEN; - return _sysio_setattr(pno, ino, mask, &stbuf); -} - -static int -PREPEND(_, SYSIO_INTERFACE_NAME(truncate))(const char *path, - _SYSIO_OFF_T length) -{ - int err; - struct pnode *pno; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - err = _sysio_namei(_sysio_cwd, path, 0, NULL, &pno); - if (err) - goto out; - err = do_truncate(pno, pno->p_base->pb_ino, length); - P_RELE(pno); - -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef _LARGEFILE64_SOURCE -#undef truncate64 -sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(truncate)), - SYSIO_INTERFACE_NAME(truncate64)) - -#undef truncate -int -SYSIO_INTERFACE_NAME(truncate)(const char *path, off_t length) -{ - - return PREPEND(_, SYSIO_INTERFACE_NAME(truncate))(path, length); -} -#else -#undef truncate -sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(truncate)), - SYSIO_INTERFACE_NAME(truncate)) -#endif - -static int -PREPEND(_, SYSIO_INTERFACE_NAME(ftruncate))(int fd, _SYSIO_OFF_T length) -{ - int err; - struct file *fil; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - err = 0; - fil = _sysio_fd_find(fd); - if (!fil) { - err = -EBADF; - goto out; - } - if (!F_CHKRW(fil, 'w')) { - err = -EBADF; - goto out; - } - err = do_truncate(NULL, fil->f_ino, length); -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef _LARGEFILE64_SOURCE -#undef ftruncate64 -sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(ftruncate)), - SYSIO_INTERFACE_NAME(ftruncate64)) - -#undef ftruncate -int -SYSIO_INTERFACE_NAME(ftruncate)(int fd, off_t length) -{ - - return PREPEND(_, SYSIO_INTERFACE_NAME(ftruncate))(fd, length); -} -#else -#undef ftruncate -sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(ftruncate)), - SYSIO_INTERFACE_NAME(ftruncate)) -#endif diff --git a/libsysio/src/unlink.c b/libsysio/src/unlink.c deleted file mode 100644 index 8732efa4..0000000 --- a/libsysio/src/unlink.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2006 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "fs.h" -#include "mount.h" -#include "sysio-symbols.h" - -int -SYSIO_INTERFACE_NAME(unlink)(const char *path) -{ - struct intent intent; - int err; - struct pnode *pno; - struct inode *ino; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - INTENT_INIT(&intent, INT_UPDPARENT, NULL, NULL); - err = _sysio_namei(_sysio_cwd, path, ND_NOFOLLOW, &intent, &pno); - if (err) - goto out; - - err = _sysio_permitted(pno->p_parent, W_OK); - if (err) - goto error; - - ino = pno->p_base->pb_ino; - /* - * Use the parent node operations to request the task in case the - * driver is implemented using differentiated inode operations based - * on file type, such as incore does. - */ - err = (*pno->p_parent->p_base->pb_ino->i_ops.inop_unlink)(pno); - if (err) - goto error; - assert(pno->p_base->pb_ino); - /* - * Invalidate the path node. - */ - ino = pno->p_base->pb_ino; - pno->p_base->pb_ino = NULL; - /* - * Kill the i-node. I've thought and thought about this. We - * can't allow it to be found via namei any longer because we - * can't count on generation numbers support and have no - * clue why there might be other soft-references -- Could - * be an open file. - */ - I_GONE(ino); - -error: - P_RELE(pno); -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef REDSTORM -#undef __unlink -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(unlink), - PREPEND(__, SYSIO_INTERFACE_NAME(unlink))) -#endif diff --git a/libsysio/src/utime.c b/libsysio/src/utime.c deleted file mode 100644 index d4f15cc3..0000000 --- a/libsysio/src/utime.c +++ /dev/null @@ -1,98 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "file.h" - -time_t -_sysio_local_time() -{ - struct timeval tv; - - if (gettimeofday(&tv, NULL) != 0) - abort(); - return tv.tv_sec; -} - -int -SYSIO_INTERFACE_NAME(utime)(const char *path, const struct utimbuf *buf) -{ - int err; - struct pnode *pno; - struct utimbuf _utbuffer; - struct intnl_stat stbuf; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - err = _sysio_namei(_sysio_cwd, path, 0, NULL, &pno); - if (err) - goto out; - if (!buf) { - _utbuffer.actime = _utbuffer.modtime = _SYSIO_LOCAL_TIME(); - buf = &_utbuffer; - } - (void )memset(&stbuf, 0, sizeof(struct intnl_stat)); - stbuf.st_atime = buf->actime; - stbuf.st_mtime = buf->modtime; - err = - _sysio_setattr(pno, - pno->p_base->pb_ino, - SETATTR_ATIME | SETATTR_MTIME, - &stbuf); - P_RELE(pno); -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} diff --git a/libsysio/tests/.gitignore b/libsysio/tests/.gitignore deleted file mode 100644 index 10a7e8d..0000000 --- a/libsysio/tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/Makefile.in diff --git a/libsysio/tests/Makefile.am b/libsysio/tests/Makefile.am deleted file mode 100644 index 2901e5a..0000000 --- a/libsysio/tests/Makefile.am +++ /dev/null @@ -1,114 +0,0 @@ -noinst_PROGRAMS = test_copy test_stats test_path test_list \ - test_getcwd test_link test_unlink test_symlink test_rename \ - test_regions test_stddir test_fcntl_lock test_mknod test_mkdir \ - test_chown - -CLEANFILES=drv_data.c - -if WITH_NATIVE_DRIVER -NATIVE_DRIVER_NAME=native -NATIVE_DRIVER_CFLAGS= -I$(top_srcdir)/drivers/native -else -NATIVE_DRIVER_NAME= -NATIVE_DRIVER_CFLAGS= -endif - -if WITH_INCORE_DRIVER -INCORE_DRIVER_NAME=incore -INCORE_DRIVER_CFLAGS= -I$(top_srcdir)/drivers/incore -else -INCORE_DRIVER_NAME= -INCORE_DRIVER_CFLAGS= -endif - -if WITH_CPLANT_YOD -YOD_DRIVER_NAME=yod -YOD_DRIVER_CFLAGS= -DCPLANT_YOD -else -YOD_DRIVER_NAME= -YOD_DRIVER_CFLAGS= -endif - -DRIVERS=$(NATIVE_DRIVER_NAME) $(INCORE_DRIVER_NAME) $(YOD_DRIVER_NAME) \ - $(STFD_DEV_NAME) - -CMNSRC=startup.c drv_init_all.c drv_data.c - -BUILT_SOURCES=drv_data.c - -CFL=$(AM_CFLAGS) $(AM_CPPFLAGS) \ - $(NATIVE_DRIVER_CFLAGS) $(INCORE_DRIVER_CFLAGS) \ - $(STDFD_DEV_CFLAGS) $(YOD_DRIVER_CFLAGS) - -LIBS=$(LIBBUILD_DIR)/libsysio.a - -test_copy_SOURCES=test_copy.c $(CMNSRC) -test_copy_CFLAGS=$(CFL) -test_copy_DEPENDENCIES=$(LIBS) - -test_stats_SOURCES=test_stats.c $(CMNSRC) -test_stats_CFLAGS=$(CFL) -test_stats_DEPENDENCIES=$(LIBS) - -test_path_SOURCES=test_path.c $(CMNSRC) -test_path_CFLAGS=$(CFL) -test_path_DEPENDENCIES=$(LIBS) - -test_list_SOURCES=test_list.c $(CMNSRC) -test_list_CFLAGS=$(CFL) -test_list_DEPENDENCIES=$(LIBS) - -test_getcwd_SOURCES=test_getcwd.c $(CMNSRC) -test_getcwd_CFLAGS=$(CFL) -test_getcwd_DEPENDENCIES=$(LIBS) - -test_link_SOURCES=test_link.c $(CMNSRC) -test_link_CFLAGS=$(CFL) -test_link_DEPENDENCIES=$(LIBS) - -test_unlink_SOURCES=test_unlink.c $(CMNSRC) -test_unlink_CFLAGS=$(CFL) -test_unlink_DEPENDENCIES=$(LIBS) - -test_symlink_SOURCES=test_symlink.c $(CMNSRC) -test_symlink_CFLAGS=$(CFL) -test_symlink_DEPENDENCIES=$(LIBS) - -test_rename_SOURCES=test_rename.c $(CMNSRC) -test_rename_CFLAGS=$(CFL) -test_rename_DEPENDENCIES=$(LIBS) - -test_regions_SOURCES=test_regions.c $(CMNSRC) -test_regions_CFLAGS=$(CFL) -test_regions_DEPENDENCIES=$(LIBS) - -test_stddir_SOURCES=test_stddir.c $(CMNSRC) -test_stddir_CFLAGS=$(CFL) -test_stddir_DEPENDENCIES=$(LIBS) - -test_fcntl_lock_SOURCES=test_fcntl_lock.c $(CMNSRC) -test_fcntl_lock_CFLAGS=$(CFL) -test_fcntl_lock_DEPENDENCIES=$(LIBS) - -test_mknod_SOURCES=test_mknod.c $(CMNSRC) -test_mknod_CFLAGS=$(CFL) -test_mknod_DEPENDENCIES=$(LIBS) - -test_mkdir_SOURCES=test_mkdir.c $(CMNSRC) -test_mkdir_CFLAGS=$(CFL) -test_mkdir_DEPENDENCIES=$(LIBS) - -test_chown_SOURCES=test_chown.c $(CMNSRC) -test_chown_CFLAGS=$(CFL) -test_chown_DEPENDENCIES=$(LIBS) - -drv_data.c: $(CONFIG_DEPENDENCIES) $(top_srcdir)/tests/gendrvdata.sh - test -z "drv_data.c" && rm -f drv_data.c; \ - $(SHELL) $(top_srcdir)/tests/gendrvdata.sh $(DRIVERS) > drv_data.c - -lib_LIBRARIES=libruntime.a - -libruntime_a_SOURCES=sysio-run-start.c startup.c drv_init_all.c drv_data.c - -AM_CFLAGS = -L$(LIBBUILD_DIR) -include $(top_srcdir)/Rules.make diff --git a/libsysio/tests/README b/libsysio/tests/README deleted file mode 100644 index a8cb7a8..0000000 --- a/libsysio/tests/README +++ /dev/null @@ -1,185 +0,0 @@ -To run the tests, just do a "make check" in the tests subdirectory. -On the CPlant alpha systems, 3 of the 7 tests in test_all.pl are excluded -due to known problems (problems as of the date of writing this; they -may have since been fixed). You can also manually run the individual -tests or ./test_all.pl. If you are running on CPlant, you need to -run test_all.pl with a -alpha argument. Either "make check" or -test_all.pl will run the 7 basic functionality tests (explained -below) and report the total number of passes and failures. -number of passes and failures. - ------------------------SCRIPTS--------------------------------- - -There are a total of 8 scripts: test_copy.pl, test_list.pl, -test_getcwd.pl, test_stats.pl, test_stdfd.pl, test_path.pl, -populator.pl, and verifier.pl. All but the last two scripts -are ran with the test_all.pl script. Here is an explanation -of the scripts. All scripts take an optional "-alpha" arg -for running the scripts in an alpha/cplant environment. The -alpha arg makes certain assumptions about the running of the -environment; for example, it does not initilization and it -starts off the test driver with yod. - -test_copy.pl : This copies a file from src to dest. - : It runs a system cmp to verify that - : the two files are equivalent - -test_list.pl [-p] : This comes in two forms. -test_list.pl [-p] : In the first form, it will - : parse through the getdirentries - : result in order to generate a - : a listing. If the -p option is - : given, it will print out the - : listing. In the second form, it - : mounts mdir into dir and then does - : the listing - -test_getcwd.pl : Tests getcwd by verifying that setting the current - : working directory to dir and then calling getcwd - : returns dir - -test_stats.pl : Verifies that the set of stat calls (stat, fstat, - : fstatvfs, statvfs) return the same set of stats for file - : and that the calls return the same items as Perl's stat - : call (which would use a native library and not libsysio) - -test_stdfd.pl : Verified that stdin, stdout, and stderr can be opened and - : either written to or read from - -test_path.pl ... : Print each path listed and its type. - : If no paths are given, paths are read - : from stdin until a "quit" is given - -populator.pl [-seed seed] : Create a file and populate with random numbers. - [-file filename] : Will use the given seed for the random number - [-bytes bytes] : generator if it is given, otherwise it uses the - : the current time as a seed. The seed used is - : returned. If no filename is given, the file - : will be named randfile.seed.procnum, where seed - : is the seed used and procnum is the process number - : of the script. If no bytes are given, 1024 bytes - : are written. All write commands use libsysio - - -verifier.pl <-seed seed> <-file fname> : Verifies that all bytes in the file fname - : (which was created with populator) match the - : random numbers which would have been used with - : the populator, using the given seed. - - - ------------------------------TEST DRIVER--------------------------------- - - -There are 6 basic commands for the test driver, CALL, PRINT, -ALLOC, FREE, HELP, and exit (EXIT, quit, or QUIT will also work). - -CALL is the main command for running libsysio calls. The format -will depend on the particular libsysio command being ran. -Basically, the format is CALL cmd args. The available commands -used with CALL are (in no particular order): - -fstat iwrite read chdir -fstatvfs iwritev readv chmod -fsync list rmdir chown -ftruncate lseek sizeof close -getcwd lstat stat cmpstr -getdirentries mkdir statvfs creat -init mknod symlink debug -ioctl mount truncate dup -iodone open umask dup2 -iowait umount endian ipread -printline unlink ipreadv pread -write fcntl ipwrite preadv -writev fdatasync ipwritev pwritev -fill iread pwrite ireadv - -The specifics of the commands are explained later. - -The return value from a command can be saved and referenced later -by using a syntax similar to $foo = x. Commands can be combined, such -as: - -CALL fstat ( $fd = CALL open foo ) ( $buf = ALLOC 128 ), - -with some cautionary notes. First, everything needs to be -seperated by a space. File names with spaces in them need to be quoted, -as in: - -$fd = CALL open "file with spaces" O_RDONLY - -Second, any value that is used needs to be identified with an identifier. -In other words, the command: - -$buf = ALLOC ( CALL sizeof stat ) - -will not work, but the command - -$buf = ALLOC ( $size = CALL sizeof stat ) - -will. - - -All commands return a 4 digit status code. The codes are: - -0000 : Success. This does NOT necessarily mean that the libsysio - : command returned success, only that there were no errors - : in issuing the command to libsysio. To get the result of - : the libsysio command, use PRINT $$ . PRINT $errno will return - : the last error code. -0x001 : Invalid arguments given to command -0x002 : Invalid command issued -0x004 : Invalid variable identifier given - - -ALLOC takes a size argument and an optional alignment argument. -FREE takes the variable to free as an argument. -HELP without any arguments displays the list of commands. -HELP will give information on the specific command - -PRINT take several forms. To just print out a variable, type -PRINT $var-name. If the variable is an integer, it will return -the integer. If it is a string, it will print out the string. -If it is a buffer, it will print out the buffer as a series of -hex digits. Note for most buffers, the test driver will not -know what it contains--just because it should contain a string -does not mean that the driver will know that. - -The other form of PRINT is: - -PRINT $var_name - -which will print out length units of the given type starting at -the given offset. The length is the total length in bytes, so -for an integer, a length of 4 would only print out one integer. -The length argument is ignored for strings. Allowable types are -INT SHORT CHAR and LONG. - -For most of the CALL commands, their format is similar to the -related sysio call. The ones that do not have a corresponding -sysio call are listed below: - -init: This MUST be called prior to any sysio calls. It initilizes - : libsysio - -printline: If debugging is turned on, this will print a line number - : with any debug lines - -fill : Fills buffer buf with size - : bytes of val starting at - : buf+offset. The type of val - : can be UINT. STR, or PTR and - : is given by the type arg - -list : Lists contents of dir. If no dir is given, uses cwd - -debug : Sets debug level to num - -sizeof : Gives the size of the obj. Valid objs are char, int, - : long, flock, stat, and statvfs - -endian: returns 0 if the machine is little endian, one otherwise - -cmpstr : Issues a strcmp call on the two buffers to - : see if they are the same. Returns 0 for a - : match diff --git a/libsysio/tests/drv_init_all.c b/libsysio/tests/drv_init_all.c deleted file mode 100644 index 6a3ad2b..0000000 --- a/libsysio/tests/drv_init_all.c +++ /dev/null @@ -1,23 +0,0 @@ -#include - -extern int (*drvinits[])(void); - -/* - * Init all the drivers we know about. - */ -int -drv_init_all() -{ - int (**f)(void); - int err; - - err = 0; - f = drvinits; - while (*f) { - err = (**f++)(); - if (err) - return err; - } - - return 0; -} diff --git a/libsysio/tests/gendrvdata.sh b/libsysio/tests/gendrvdata.sh deleted file mode 100644 index 8b84d82..0000000 --- a/libsysio/tests/gendrvdata.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/sh - -# This Cplant(TM) source code is the property of Sandia National -# Laboratories. -# -# This Cplant(TM) source code is copyrighted by Sandia National -# Laboratories. -# -# The redistribution of this Cplant(TM) source code is subject to the -# terms of the GNU Lesser General Public License -# (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) -# -# Cplant(TM) Copyright 1998-2003 Sandia Corporation. -# Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive -# license for use of this work by or on behalf of the US Government. -# Export of this program may require a license from the United States -# Government. - -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# Questions or comments about this library should be sent to: -# -# Lee Ward -# Sandia National Laboratories, New Mexico -# P.O. Box 5800 -# Albuquerque, NM 87185-1110 -# -# lee@sandia.gov - -echo '/*' -echo ' * This file automatically generated by gendrvdata.sh. All changes' -echo ' * will be lost!' -echo ' */' -echo -echo '#include ' -echo -echo '#include "test.h"' -echo -for i in $@; do - echo "extern int _sysio_${i}_init(void);" -done -echo -echo 'int (*drvinits[])(void) = {' - -for i in $@; do - echo " _sysio_${i}_init," -done -echo " NULL" -echo "};" diff --git a/libsysio/tests/module.mk b/libsysio/tests/module.mk deleted file mode 100644 index c23f6bd..0000000 --- a/libsysio/tests/module.mk +++ /dev/null @@ -1,7 +0,0 @@ -TESTS_EXTRA = tests/drv_init_all.c tests/startup.c tests/sysio-run-start.c \ - tests/test_chown.c tests/test_copy.c tests/test_fcntl_lock.c \ - tests/test_getcwd.c tests/test.h tests/test_link.c tests/test_list.c \ - tests/test_mkdir.c tests/test_mknod.c tests/test_path.c \ - tests/test_regions.c tests/test_rename.c tests/test_stats.c \ - tests/test_stddir.c tests/test_symlink.c tests/test_unlink.c \ - tests/Makefile.am tests/Makefile.in tests/module.mk diff --git a/libsysio/tests/startup.c b/libsysio/tests/startup.c deleted file mode 100644 index 033b325..0000000 --- a/libsysio/tests/startup.c +++ /dev/null @@ -1,65 +0,0 @@ -#include -#include -#include -#include -#include - -#include "test.h" - -#include "sysio.h" -#include "xtio.h" - -int -_test_sysio_startup() -{ - int err; - char *arg; - - err = _sysio_init(); - if (err) - return err; - err = drv_init_all(); - if (err) - return err; -#ifdef SYSIO_TRACING - /* - * tracing - */ - arg = getenv("SYSIO_TRACING"); - err = _sysio_boot("trace", arg); - if (err) - return err; -#endif - /* - * namespace - */ - arg = getenv("SYSIO_NAMESPACE"); - if (!(arg || (arg = getenv("SYSIO_MANUAL")))) { - /* - * Assume a native mount at root with automounts enabled. - */ - arg = "{mnt,dev=\"native:/\",dir=/,fl=2}"; - } - err = _sysio_boot("namespace", arg); - if (err) - return err; -#ifdef DEFER_INIT_CWD - /* - * Current working directory. - */ - arg = getenv("SYSIO_CWD"); - if (!arg) - arg = "/"; - err = _sysio_boot("cwd", arg); - if (err) - return err; -#endif - return 0; -} - -void -_test_sysio_shutdown() -{ - - _sysio_shutdown(); -} diff --git a/libsysio/tests/sysio-run-start.c b/libsysio/tests/sysio-run-start.c deleted file mode 100644 index d09fba4..0000000 --- a/libsysio/tests/sysio-run-start.c +++ /dev/null @@ -1,26 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include "test.h" - -void _sysio_startup(void) __attribute__ ((constructor)); - -void -_sysio_startup() -{ - int err; - - err = _test_sysio_startup(); - if (err) { - errno = -err; - perror("sysio startup"); - abort(); - } - if (atexit(_test_sysio_shutdown) != 0) { - perror("atexit"); - abort(); - } -} diff --git a/libsysio/tests/test.h b/libsysio/tests/test.h deleted file mode 100644 index 781d59b..0000000 --- a/libsysio/tests/test.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -extern int (*drvinits[])(void); - -extern int drv_init_all(void); -extern int _test_sysio_startup(void); -extern void _test_sysio_shutdown(void); diff --git a/libsysio/tests/test_chown.c b/libsysio/tests/test_chown.c deleted file mode 100644 index 251f299..0000000 --- a/libsysio/tests/test_chown.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2007 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(SYSIO_LABEL_NAMES) -#include "sysio.h" -#endif -#include "test.h" - -/* - * Test chown call - * - * Usage: chown - * - */ - -static void usage(void); - -int -main(int argc, char *const argv[]) -{ - int (*chown_func)(const char *, uid_t, gid_t); - int (*stat_func)(const char *, struct stat *); - int i; - int err; - int n; - char *path; - uid_t uid; - gid_t gid; - struct stat stbuf; - extern int _test_sysio_startup(void); - - chown_func = SYSIO_INTERFACE_NAME(chown); - stat_func = SYSIO_INTERFACE_NAME(stat); - - /* - * Parse command line arguments. - */ - while ((i = getopt(argc, argv, "")) != -1) - switch (i) { - - default: - usage(); - } - - /* - * Init sysio lib. - */ - err = _test_sysio_startup(); - if (err) { - errno = -err; - perror("sysio startup"); - exit(1); - } - - n = argc - optind; - if (n < 3) usage(); - - path = argv[optind++]; - uid = atoi(argv[optind++]); - gid = atoi(argv[optind++]); - - do { - err = (*chown_func)(path, uid, gid); - if (err != 0) { - perror(path); - break; - } - err = (*stat_func)(path, &stbuf); - if (err != 0) { - perror(path); - break; - } - (void )printf("uid now %ld, gid now %ld\n", - (long )stbuf.st_uid, (long )stbuf.st_gid); - } while (0); - - /* - * Clean up. - */ - _test_sysio_shutdown(); - - return err ? -1 : 0; -} - -static void -usage() -{ - - (void )fprintf(stderr, - "Usage: chown" - " \n"); - - exit(1); -} diff --git a/libsysio/tests/test_copy.c b/libsysio/tests/test_copy.c deleted file mode 100644 index e1954ff..0000000 --- a/libsysio/tests/test_copy.c +++ /dev/null @@ -1,217 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(SYSIO_LABEL_NAMES) -#include "sysio.h" -#endif -#include "xtio.h" -#include "test.h" - -/* - * Copy one file to another. - * - * Usage: test_copy [-o] - * - * Destination will not be overwritten if it already exist. - */ - -static int overwrite = 0; /* over-write? */ - -void usage(void); -int copy_file(const char *spath, const char *dpath); - -int -main(int argc, char * const argv[]) -{ - int i; - int err; - const char *spath, *dpath; - - /* - * Parse command-line args. - */ - while ((i = getopt(argc, - argv, - "o" - )) != -1) - switch (i) { - - case 'o': - overwrite = 1; - break; - default: - usage(); - } - - if (!(argc - optind)) - usage(); - err = _test_sysio_startup(); - if (err) { - errno = -err; - perror("sysio startup"); - exit(1); - } - - /* - * Source - */ - spath = argv[optind++]; - if (!(argc - optind)) - usage(); - /* - * Destination - */ - dpath = argv[optind++]; - if (argc - optind) - usage(); - - err = copy_file(spath, dpath); - - _test_sysio_shutdown(); - - return err; -} - -void -usage() -{ - - (void )fprintf(stderr, - "Usage: test_copy " - " source destination\n"); - exit(1); -} - -int -open_file(const char *path, int flags, mode_t mode) -{ - int fd; - - fd = SYSIO_INTERFACE_NAME(open)(path, flags, mode); - if (fd < 0) - perror(path); - - return fd; -} - -int -copy_file(const char *spath, const char *dpath) -{ - int sfd, dfd; - int flags; - int rtn; - struct stat stat; - char *buf; - size_t bufsiz; - ssize_t cc, wcc; - - sfd = dfd = -1; - rtn = -1; - buf = NULL; - - sfd = open_file(spath, O_RDONLY, 0); - if (sfd < 0) - goto out; - flags = O_CREAT|O_WRONLY; - if (!overwrite) - flags |= O_EXCL; - dfd = open_file(dpath, flags, 0666); - if (dfd < 0) - goto out; - - rtn = SYSIO_INTERFACE_NAME(fstat)(dfd, &stat); - if (rtn != 0) { - perror(dpath); - goto out; - } - bufsiz = stat.st_blksize; - if (bufsiz < (64 * 1024)) - bufsiz = - (((64 * 1024) / stat.st_blksize - 1) + 1) * (64 * 1024); - buf = malloc(bufsiz); - if (!buf) { - perror(dpath); - goto out; - } - - while ((cc = SYSIO_INTERFACE_NAME(read)(sfd, buf, bufsiz)) > 0) - if ((wcc = SYSIO_INTERFACE_NAME(write)(dfd, buf, cc)) != cc) { - if (wcc < 0) { - perror(dpath); - break; - } - (void )fprintf(stderr, - "%s: short write (%u/%u)\n", - dpath, - (unsigned )wcc, - (unsigned )cc); - break; - } - if (cc < 0) { - perror(spath); - rtn = -1; - } - -out: - if (buf) - free(buf); - if (sfd >= 0 && SYSIO_INTERFACE_NAME(close)(sfd) != 0) - perror(spath); - if (dfd >= 0 && - (SYSIO_INTERFACE_NAME(fsync)(dfd) != 0 || - SYSIO_INTERFACE_NAME(close)(dfd) != 0)) - perror(dpath); - - return rtn; -} diff --git a/libsysio/tests/test_fcntl_lock.c b/libsysio/tests/test_fcntl_lock.c deleted file mode 100644 index c5e79b5..0000000 --- a/libsysio/tests/test_fcntl_lock.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2005 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(SYSIO_LABEL_NAMES) -#include "sysio.h" -#endif -#include "xtio.h" -#include "test.h" - -/* - * fcntl lock tests - * - * Usage: test_fcnt_lock [ ...] - */ - -void usage(void); -void do_tests(const char *path); - -int -main(int argc, char * const argv[]) -{ - int i; - int err; - extern int _test_sysio_startup(void); - - /* - * Parse command-line args. - */ - while ((i = getopt(argc, argv, "")) != -1) - switch (i) { - - default: - usage(); - } - - err = _test_sysio_startup(); - if (err) { - errno = -err; - perror("sysio startup"); - exit(1); - } - - while (optind < argc) - do_tests(argv[optind++]); - - /* - * Clean up. - */ - _test_sysio_shutdown(); - - return 0; -} - -void -usage() -{ - - (void )fprintf(stderr, - "Usage: test_fcntl_lock" - " source...\n"); - exit(1); -} - -void -do_tests(const char *path) -{ - int fd; - int err; - struct flock flock; - - fd = SYSIO_INTERFACE_NAME(open)(path, O_RDONLY); - if (fd < 0) { - perror(path); - return; - } - do { - flock.l_type = F_RDLCK; - flock.l_whence = SEEK_CUR; - flock.l_start = 0; - flock.l_len = 0; - flock.l_pid = 0; - err = SYSIO_INTERFACE_NAME(fcntl)(fd, F_SETLK, &flock); - if (err) - break; - flock.l_type = F_UNLCK; - err = SYSIO_INTERFACE_NAME(fcntl)(fd, F_SETLK, &flock); - if (err) - break; - } while (0); - - if (err) - perror(path); - if (SYSIO_INTERFACE_NAME(close)(fd) != 0) - perror(path); -} diff --git a/libsysio/tests/test_getcwd.c b/libsysio/tests/test_getcwd.c deleted file mode 100644 index fb56c24..0000000 --- a/libsysio/tests/test_getcwd.c +++ /dev/null @@ -1,174 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(SYSIO_LABEL_NAMES) -#include "sysio.h" -#endif -#include "xtio.h" -#include "mount.h" - -#include "test.h" - -/* - * Test getcwd() - * - * Usage: test_cwd [...] - * - * Without any path arguments, the program reads from standard-in, dealing with - * each line as an absolute or relative path until EOF. - */ - -static int doit(const char *path); -static void usage(void); - -int -main(int argc, char *const argv[]) -{ - int i; - int err; - int n; - extern int _test_sysio_startup(void); - - /* - * Parse command line arguments. - */ - while ((i = getopt(argc, argv, "")) != -1) - switch (i) { - - default: - usage(); - } - /* - * Init sysio lib. - */ - err = _test_sysio_startup(); - if (err) { - errno = -err; - perror("sysio startup"); - exit(1); - } - - n = argc - optind; - - /* - * Try path(s) listed on command-line. - */ - while (optind < argc) { - const char *path; - - path = argv[optind++]; - (void )doit(path); - } - - /* - * If no command-line arguments, read from stdin until EOF. - */ - if (!n) { - int doflush; - static char buf[4096]; - size_t len; - char *cp; - char c; - - doflush = 0; - while (fgets(buf, sizeof(buf), stdin) != NULL) { - len = strlen(buf); - cp = buf + len - 1; - c = *cp; - *cp = '\0'; - if (!doflush) - doit(buf); - doflush = c == '\n' ? 0 : 1; - } - } - - /* - * Clean up. - */ - _test_sysio_shutdown(); - - return 0; -} - -static int -doit(const char *path) -{ - char *buf; - - if (SYSIO_INTERFACE_NAME(chdir)(path) != 0) { - perror(path); - return -1; - } - buf = SYSIO_INTERFACE_NAME(getcwd)(NULL, 0); - if (!buf) { - perror(path); - return -1; - } - (void )printf("%s\n", buf); - free(buf); - return 0; -} - -static void -usage() -{ - - (void )fprintf(stderr, - "Usage: test_getcwd " - " [ ...\n]"); - - exit(1); -} diff --git a/libsysio/tests/test_link.c b/libsysio/tests/test_link.c deleted file mode 100644 index 317bc5e..0000000 --- a/libsysio/tests/test_link.c +++ /dev/null @@ -1,140 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include -#if 0 -#include -#endif -#include -#include -#include - -#if defined(SYSIO_LABEL_NAMES) -#include "sysio.h" -#endif -#include "xtio.h" -#include "test.h" - -/* - * Test hard link - * - * Usage: link oldpath newpath - * - */ - -static void usage(void); - -int -main(int argc, char *const argv[]) -{ - int i; - int err; - int n; - extern int _test_sysio_startup(void); - - /* - * Parse command line arguments. - */ - while ((i = getopt(argc, argv, "")) != -1) - switch (i) { - - default: - usage(); - } - - /* - * Init sysio lib. - */ - err = _test_sysio_startup(); - if (err) { - errno = -err; - perror("sysio startup"); - exit(1); - } - - n = argc - optind; - if (n < 2) usage(); - - /* - * Try paths listed on command-line. - */ - while (optind < argc) { - const char *old, *new; - struct stat stbuf; - - old = argv[optind++]; - new = argv[optind++]; - if ((err = SYSIO_INTERFACE_NAME(link)(old, new)) != 0) { - perror("link"); - break; - } - if ((err = SYSIO_INTERFACE_NAME(lstat)(new, &stbuf)) != 0) { - perror(new); - break; - } - } - - /* - * Clean up. - */ - _test_sysio_shutdown(); - - return err ? -1 : 0; -} - -static void -usage() -{ - - (void )fprintf(stderr, - "Usage: unlink" - " oldpath newpath\n"); - - exit(1); -} diff --git a/libsysio/tests/test_list.c b/libsysio/tests/test_list.c deleted file mode 100644 index b9e4c0d..0000000 --- a/libsysio/tests/test_list.c +++ /dev/null @@ -1,212 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(SYSIO_LABEL_NAMES) -#include "sysio.h" -#endif -#include "xtio.h" -#include "test.h" - -/* - * Stat files. - * - * Usage: test_list [path...] - * - * Without any path arguments, the program reads from standard-in, dealing with - * each line as an absolute or relative path until EOF. - */ - -static int listit(const char *path); -static void usage(void); - -int -main(int argc, char *const argv[]) -{ - int i; - int err; - int n; - extern int _test_sysio_startup(void); - - /* - * Parse command line arguments. - */ - while ((i = getopt(argc, argv, "")) != -1) - switch (i) { - - default: - usage(); - } - - /* - * Init sysio lib. - */ - err = _test_sysio_startup(); - if (err) { - errno = -err; - perror("sysio startup"); - exit(1); - } - - n = argc - optind; - - /* - * Try path(s) listed on command-line. - */ - while (optind < argc) { - const char *path; - - path = argv[optind++]; - (void )listit(path); - } - - /* - * If no command-line arguments, read from stdin until EOF. - */ - if (!n) { - int doflush; - static char buf[4096]; - size_t len; - char *cp; - char c; - - doflush = 0; - while (fgets(buf, sizeof(buf), stdin) != NULL) { - len = strlen(buf); - cp = buf + len - 1; - c = *cp; - *cp = '\0'; - if (!doflush) - listit(buf); - doflush = c == '\n' ? 0 : 1; - } - } - - /* - * Clean up. - */ - _test_sysio_shutdown(); - - return 0; -} - -static int -listit(const char *path) -{ - int fd; - size_t n; - struct dirent *buf, *dp; - off_t base; - ssize_t cc; - - fd = SYSIO_INTERFACE_NAME(open)(path, O_RDONLY); - if (fd < 0) { - perror(path); - return -1; - } - - n = 16 * 1024; - buf = malloc(n); - if (!buf) { - perror(path); - cc = -1; - goto out; - } - - while ((cc = SYSIO_INTERFACE_NAME(getdirentries)(fd, - (char *)buf, - n, - &base)) > 0) { - dp = buf; - while (cc > 0) { - (void )printf("\t%s: ino %llu type %u\n", - dp->d_name, - (unsigned long long )dp->d_ino, - (int )dp->d_type); - cc -= dp->d_reclen; - dp = (struct dirent *)((char *)dp + dp->d_reclen); - } - } - -out: - if (cc < 0) - perror(path); - - free(buf); - { - int oerrno = errno; - - if (SYSIO_INTERFACE_NAME(close)(fd) != 0) { - perror(path); - if (cc < 0) - errno = oerrno; - else - cc = -1; - } - } - - return (int )cc; -} - -static void -usage() -{ - - (void )fprintf(stderr, - "Usage: list_path" - " [ ...\n]"); - - exit(1); -} diff --git a/libsysio/tests/test_mkdir.c b/libsysio/tests/test_mkdir.c deleted file mode 100644 index e8711f8..0000000 --- a/libsysio/tests/test_mkdir.c +++ /dev/null @@ -1,163 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2006 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#if 0 -#include -#endif -#include - -#if defined(SYSIO_LABEL_NAMES) -#include "sysio.h" -#endif -#include "test.h" - -/* - * Make directories. - * - * Usage: mkdir [path...] - * - * Without any path arguments, the program creates directories named - * by the command line args. - */ - -static int do_mkdir(const char *path); -static void usage(void); - -int -main(int argc, char *const argv[]) -{ - int i; - int err; - int n; - extern int _test_sysio_startup(void); - - /* - * Parse command line arguments. - */ - while ((i = getopt(argc, argv, "")) != -1) - switch (i) { - - default: - usage(); - } - - /* - * Init sysio lib. - */ - err = _test_sysio_startup(); - if (err) { - errno = -err; - perror("sysio startup"); - exit(1); - } - - n = argc - optind; - - /* - * Try path(s) listed on command-line. - */ - while (optind < argc) { - const char *path; - - path = argv[optind++]; - (void )do_mkdir(path); - } - - /* - * If no command-line arguments, read from stdin until EOF. - */ - if (!n) { - int doflush; - static char buf[4096]; - size_t len; - char *cp; - char c; - - doflush = 0; - while (fgets(buf, sizeof(buf), stdin) != NULL) { - len = strlen(buf); - cp = buf + len - 1; - c = *cp; - *cp = '\0'; - if (!doflush) - do_mkdir(buf); - doflush = c == '\n' ? 0 : 1; - } - } - - /* - * Clean up. - */ - _test_sysio_shutdown(); - - return 0; -} - -static int -do_mkdir(const char *path) -{ - - if (SYSIO_INTERFACE_NAME(mkdir)(path, 777) != 0) { - perror(path); - return -1; - } - - return 0; -} - -static void -usage() -{ - - (void )fprintf(stderr, - "Usage: mkdir" - " [ ...\n]"); - - exit(1); -} diff --git a/libsysio/tests/test_mknod.c b/libsysio/tests/test_mknod.c deleted file mode 100644 index 7f1d937..0000000 --- a/libsysio/tests/test_mknod.c +++ /dev/null @@ -1,162 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2006 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -/* - * Can't provoke a definition of the S_IFMT macros without a little extra work. - */ -#define _BSD_SOURCE - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(SYSIO_LABEL_NAMES) -#include "sysio.h" -#endif -#include "test.h" - -/* - * Create a node. - * - * Usage: mknod path {f|b|c} [dev] - * - * The dev argument should not be present for regular file and FIFO object - * creation. - */ - -static int do_mknod(const char *path, mode_t mode, dev_t dev); -static void usage(void); - -int -main(int argc, char *const argv[]) -{ - int i; - int err; - mode_t mode; - dev_t dev; - extern int _test_sysio_startup(void); - - /* - * Parse command line arguments. - */ - while ((i = getopt(argc, argv, "")) != -1) - switch (i) { - - default: - usage(); - } - - /* - * Init sysio lib. - */ - err = _test_sysio_startup(); - if (err) { - errno = -err; - perror("sysio startup"); - exit(1); - } - - if (argc - optind < 2) - usage(); - if (strlen(argv[optind + 1]) != 1) - usage(); - mode = 0666; - switch (*argv[optind + 1]) { - - case 'f': - mode |= S_IFREG; - break; - case 'b': - mode |= S_IFBLK; - break; - case 'c': - mode |= S_IFCHR; - break; - case 'p': - mode |= S_IFIFO; - break; - default: - usage(); - } - dev = 0; - if (!(S_ISREG(mode) || S_ISFIFO(mode))) - dev = atoi(argv[optind + 2]); - else if (argc - optind != 2) { - (void )fprintf(stderr, "Too many arguments\n"); - usage(); - } - (void )do_mknod(argv[optind + 0], mode, dev); - - /* - * Clean up. - */ - _test_sysio_shutdown(); - - return 0; -} - -static int -do_mknod(const char *path, mode_t mode, dev_t dev) -{ - - if (SYSIO_INTERFACE_NAME(mknod)(path, mode, dev) != 0) { - perror(path); - return -1; - } - - return 0; -} - -static void -usage() -{ - - (void )fprintf(stderr, "Usage: mknod path {f|b|c|p} dev\n"); - exit(1); -} diff --git a/libsysio/tests/test_path.c b/libsysio/tests/test_path.c deleted file mode 100644 index 8776b6e..0000000 --- a/libsysio/tests/test_path.c +++ /dev/null @@ -1,225 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(SYSIO_LABEL_NAMES) -#include "sysio.h" -#endif -#include "xtio.h" -#include "test.h" - -/* - * Stat files. - * - * Usage: test_path [path...] - * - * Without any path arguments, the program reads from standard-in, dealing with - * each line as an absolute or relative path until EOF. - */ - -static int statit(const char *path); -static void usage(void); - -int -main(int argc, char *const argv[]) -{ - int i; - int err; - int n; - extern int _test_sysio_startup(void); - - /* - * Parse command line arguments. - */ - while ((i = getopt(argc, argv, "")) != -1) - switch (i) { - - default: - usage(); - } - - /* - * Init sysio lib. - */ - err = _test_sysio_startup(); - if (err) { - errno = -err; - perror("sysio startup"); - exit(1); - } - - n = argc - optind; - - /* - * Try path(s) listed on command-line. - */ - while (optind < argc) { - const char *path; - - path = argv[optind++]; - (void )statit(path); - } - - /* - * If no command-line arguments, read from stdin until EOF. - */ - if (!n) { - int doflush; - static char buf[4096]; - size_t len; - char *cp; - char c; - - doflush = 0; - while (fgets(buf, sizeof(buf), stdin) != NULL) { - len = strlen(buf); - cp = buf + len - 1; - c = *cp; - *cp = '\0'; - if (!doflush) - statit(buf); - doflush = c == '\n' ? 0 : 1; - } - } - - /* - * Clean up. - */ - _test_sysio_shutdown(); - - return 0; -} - -static int -statit(const char *path) -{ - int err; - struct stat stbuf; - char t; - static char buf[4096]; - ssize_t cc; - - /* - * Get file attrs. - */ - err = SYSIO_INTERFACE_NAME(lstat)(path, &stbuf); - if (err) { - perror(path); - return -1; - } - - /* - * Get readable representation of file type. - */ - if (S_ISDIR(stbuf.st_mode)) - t = 'd'; - else if (S_ISCHR(stbuf.st_mode)) - t = 'c'; - else if (S_ISBLK(stbuf.st_mode)) - t = 'b'; - else if (S_ISREG(stbuf.st_mode)) - t = 'f'; -#ifdef S_ISFIFO - else if (S_ISFIFO(stbuf.st_mode)) - t = 'p'; -#endif -#ifdef S_ISLNK - else if (S_ISLNK(stbuf.st_mode)) - t = 'S'; -#endif -#ifdef S_ISSOCK - else if (S_ISSOCK(stbuf.st_mode)) - t = 's'; -#endif -#ifdef S_TYPEISMQ - else if (S_TYPEISMQ(&stbuf)) - t = 'q'; -#endif -#ifdef S_TYPEISSEM - else if (S_TYPEISSEM(&stbuf)) - t = 'M'; -#endif -#ifdef S_TYPEISSHM - else if (S_TYPEISSHM(&stbuf)) - t = 'm'; -#endif - else - t = '?'; - - /* - * Print path and type. - */ - if (S_ISLNK(stbuf.st_mode)) { - cc = SYSIO_INTERFACE_NAME(readlink)(path, buf, sizeof(buf)); - if (cc < 0) { - perror(path); - return -1; - } - } - (void )printf("%s: %c", path, t); - if (S_ISLNK(stbuf.st_mode) && (size_t )cc < sizeof(buf)) - (void )printf(" %.*s", (int )cc, buf); - (void )putchar('\n'); - - return 0; -} - -static void -usage() -{ - - (void )fprintf(stderr, - "Usage: test_path" - " [ ...\n]"); - - exit(1); -} diff --git a/libsysio/tests/test_regions.c b/libsysio/tests/test_regions.c deleted file mode 100644 index e253a30..0000000 --- a/libsysio/tests/test_regions.c +++ /dev/null @@ -1,281 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is regionsrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2004 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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 regions of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(SYSIO_LABEL_NAMES) -#include "sysio.h" -#endif -#include "xtio.h" -#include "test.h" - -/* - * Copy one file to another. - * - * Usage: test_regions [-x] \ - * {r,w} - * - * Destination will not be overwritten if it already exist. - */ - -#if defined(_LARGEFILE64_SOURCE) && _LARGEFILE64_SOURCE -#define GO64 -#else -#warning Cannot prompt the 64-bit interface -#endif - -char which; -#ifdef GO64 -int use64 = 0; /* 64-bit interface? */ -#endif - -void usage(void); - -int -main(int argc, char * const argv[]) -{ - int i; - int err; - long l; - off_t off; -#ifdef GO64 - long long ll; - off64_t off64; -#endif - char *cp; - unsigned long nbytes; - const char *path; - char *buf; - int flags; - int fd; - ssize_t cc; - extern int _test_sysio_startup(void); - - /* - * Parse command-line args. - */ - while ((i = getopt(argc, - argv, -#ifdef __GLIBC__ - "+" -#endif -#ifdef GO64 - "x" -#endif - "")) != -1) - switch (i) { - -#ifdef GO64 - case 'x': - use64 = 1; - break; -#endif - default: - usage(); - } - - if (argc - optind != 4) - usage(); - - which = *argv[optind]; - if (strlen(argv[optind]) != 1 || !(which == 'r' || which == 'w')) { - (void )fprintf(stderr, "Which op?\n"); - exit(1); - } - optind++; - off = l = -#ifdef GO64 - ll = strtoll(argv[optind++], &cp, 0); -#else - strtol(argv[optind++], &cp, 0); -#endif -#ifdef GO64 - off64 = ll; -#endif - if (*cp != '\0' || -#ifdef GO64 - ((ll == LLONG_MIN || ll == LLONG_MAX) && errno == ERANGE) || - off64 != ll || (!use64 && off != ll) -#else - ((l == LONG_MIN || l == LONG_MAX) && errno == ERANGE) || - off != l -#endif - ) { - (void )fprintf(stderr, "Offset out of range\n"); - exit(1); - } - nbytes = strtoul(argv[optind++], &cp, 0); - if (*cp != '\0' || (nbytes == ULONG_MAX && errno == ERANGE)) { - (void )fprintf(stderr, "Transfer count out of range\n"); - exit(1); - } - if (!(argc - optind)) - usage(); - path = argv[optind++]; - - err = _test_sysio_startup(); - if (err) { - errno = -err; - perror("sysio startup"); - exit(1); - } - - (void )umask(022); - - buf = malloc(nbytes); - if (!buf) { - perror("malloc"); - err = 1; - goto out; - } - (void )memset(buf, 0, nbytes); - - err = 0; - flags = which == 'r' ? O_RDONLY : (O_WRONLY|O_CREAT|O_EXCL); -#ifdef GO64 - if (use64) - flags |= O_LARGEFILE; -#endif - fd = SYSIO_INTERFACE_NAME(open)(path, flags, 0666); - if (fd < 0) { - perror(path); - err = 1; - goto error; - } -#ifdef GO64 - if (use64) - off64 = SYSIO_INTERFACE_NAME(lseek64)(fd, off64, SEEK_SET); - else - off64 = -#endif - off = SYSIO_INTERFACE_NAME(lseek)(fd, off, SEEK_SET); -#ifdef GO64 - if ((use64 && off64 < 0) || (!use64 && off < 0)) { - perror(use64 ? "lseek64" : "lseek"); - err = 1; - goto error; - } -#else - if (off < 0) { - perror("lseek"); - err = 1; - goto error; - } -#endif - if (which == 'r') - cc = SYSIO_INTERFACE_NAME(read)(fd, buf, nbytes); - else - cc = SYSIO_INTERFACE_NAME(write)(fd, buf, nbytes); - if (cc < 0) { - perror(path); - err = 1; - goto error; - } -#ifdef GO64 - if (use64) { - off64 = SYSIO_INTERFACE_NAME(lseek64)(fd, 0, SEEK_CUR); - } else - off64 = -#endif - off = SYSIO_INTERFACE_NAME(lseek)(fd, 0, SEEK_CUR); - (void )printf(("%s%s@" -#ifdef GO64 - "%lld" -#else - "%ld" -#endif - ": %ld, off " -#ifdef GO64 - "%lld" -#else - "%ld" -#endif - "\n"), - which == 'r' ? "read" : "write", -#ifdef GO64 - use64 ? "64" : "", - ll, -#else - "", - l, -#endif - (long )cc, -#ifdef GO64 - (long long int)off64 -#else - off -#endif - ); - -error: - if (fd > 0 && SYSIO_INTERFACE_NAME(close)(fd) != 0) - perror(path); - free(buf); -out: - _test_sysio_shutdown(); - - return err; -} - -void -usage() -{ - - (void )fprintf(stderr, - "Usage: test_regions " -#ifdef GO64 - "[-x] " -#endif - " {r,w} \n"); - exit(1); -} diff --git a/libsysio/tests/test_rename.c b/libsysio/tests/test_rename.c deleted file mode 100644 index 13aa1ee..0000000 --- a/libsysio/tests/test_rename.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(SYSIO_LABEL_NAMES) -#include "sysio.h" -#endif -#include "xtio.h" -#include "test.h" - -/* - * Rename a file system object. - * - * Usage: test_rename - */ - -void usage(void); -int rename_file(const char *spath, const char *dpath); - -int -main(int argc, char * const argv[]) -{ - int i; - int err; - const char *spath, *dpath; - extern int _test_sysio_startup(void); - - /* - * Parse command-line args. - */ - while ((i = getopt(argc, - argv, - "" - )) != -1) - switch (i) { - - default: - usage(); - } - - if (!(argc - optind)) - usage(); - - err = _test_sysio_startup(); - if (err) { - errno = -err; - perror("sysio startup"); - exit(1); - } - - (void )SYSIO_INTERFACE_NAME(umask)(022); - - /* - * Source - */ - spath = argv[optind++]; - if (!(argc - optind)) - usage(); - /* - * Destination - */ - dpath = argv[optind++]; - if (argc - optind) - usage(); - - err = SYSIO_INTERFACE_NAME(rename)(spath, dpath); - if (err) - perror("rename"); - - _test_sysio_shutdown(); - - return err; -} - -void -usage() -{ - - (void )fprintf(stderr, - "Usage: test_rename" - " source destination\n"); - exit(1); -} diff --git a/libsysio/tests/test_stats.c b/libsysio/tests/test_stats.c deleted file mode 100644 index e604d9d..0000000 --- a/libsysio/tests/test_stats.c +++ /dev/null @@ -1,189 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include -#ifdef notdef -#include -#endif -#include -#include - -#if defined(SYSIO_LABEL_NAMES) -#include "sysio.h" -#endif -#include "xtio.h" -#include "test.h" - -/* - * Get stats of file and file system. - * - * Usage: test_stats [ ...] - */ - -void usage(void); -void do_stats(const char *path); - -int -main(int argc, char * const argv[]) -{ - int i; - int err; - extern int _test_sysio_startup(void); - - /* - * Parse command-line args. - */ - while ((i = getopt(argc, argv, "")) != -1) - switch (i) { - - default: - usage(); - } - - err = _test_sysio_startup(); - if (err) { - errno = -err; - perror("sysio startup"); - exit(1); - } - - (void )SYSIO_INTERFACE_NAME(umask)(022); - - while (optind < argc) - do_stats(argv[optind++]); - - /* - * Clean up. - */ - _test_sysio_shutdown(); - - return 0; -} - -void -usage() -{ - - (void )fprintf(stderr, - "Usage: test_stats" - " source destination\n"); - exit(1); -} - -void -do_stats(const char *path) -{ - int fd; - int err; - struct stat stbuf1, stbuf2; -#ifdef notdef - struct statvfs stvfsbuf1, stvfsbuf2; -#endif - - fd = SYSIO_INTERFACE_NAME(open)(path, O_RDONLY); - if (fd < 0) { - perror(path); - return; - } - err = SYSIO_INTERFACE_NAME(fstat)(fd, &stbuf1); - if (!err) - err = SYSIO_INTERFACE_NAME(stat)(path, &stbuf2); -#ifdef notdef - if (!err) - err = SYSIO_INTERFACE_NAME(fstatvfs)(fd, &stvfsbuf1); - if (!err) - err = SYSIO_INTERFACE_NAME(statvfs)(path, &stvfsbuf1); -#endif - if (err) { - perror(path); - goto out; - } - if (stbuf1.st_dev != stbuf2.st_dev || - stbuf1.st_ino != stbuf2.st_ino) { - (void )fprintf(stderr, "%s: [f]stat info mismatch\n", path); - goto out; - } -#ifdef notdef - if (stvfsbuf1.f_fsid != stvfsbuf2.f_fsid) { - (void )fprintf(stderr, "%s: [f]statvfs info mismatch\n", path); - } -#endif - printf("%s:" - " dev %lu," - " ino %lu," - " mode %lu," - " nlink %lu," - " uid %lu," - " gid %lu," - " rdev %lu," - " size %llu," - " blksize %lu," - " blocks %lu," - " atime %lu," - " mtime %lu," - " ctime %lu" - "\n", - path, - (unsigned long )stbuf1.st_dev, - (unsigned long )stbuf1.st_ino, - (unsigned long )stbuf1.st_mode, - (unsigned long )stbuf1.st_nlink, - (unsigned long )stbuf1.st_uid, - (unsigned long )stbuf1.st_gid, - (unsigned long )stbuf1.st_rdev, - (unsigned long long)stbuf1.st_size, - (unsigned long )stbuf1.st_blksize, - (unsigned long )stbuf1.st_blocks, - (unsigned long )stbuf1.st_atime, - (unsigned long )stbuf1.st_mtime, - (unsigned long )stbuf1.st_ctime); -out: - if (SYSIO_INTERFACE_NAME(close)(fd) != 0) - perror("closing file"); -} diff --git a/libsysio/tests/test_stddir.c b/libsysio/tests/test_stddir.c deleted file mode 100644 index b122f93..0000000 --- a/libsysio/tests/test_stddir.c +++ /dev/null @@ -1,171 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include - -#if defined(SYSIO_LABEL_NAMES) -#include "sysio.h" -#endif -#include "xtio.h" -#include "test.h" - -/* - * Test {open, read, close}dir functions - * - * Usage: test_stddir [path, ...] - */ -static int testit(const char *); -static void usage(void); - -int -main (int argc, char** argv) -{ - int err; - int i; - int n; - const char *path; - - /* - * Parse command line arguments. - */ - while ((i = getopt(argc, argv, "")) != -1) - switch (i) { - - default: - usage(); - } - - /* - * Init sysio lib. - */ - err = _test_sysio_startup(); - if (err) { - errno = -err; - perror("sysio startup"); - exit(1); - } - - /* - * If no command-line arguments, read from stdin until EOF. - */ - n = argc - optind; - if (!n) { - int doflush; - static char buf[4096]; - size_t len; - char *cp; - char c; - - doflush = 0; - while (fgets(buf, sizeof(buf), stdin) != NULL) { - len = strlen(buf); - cp = buf + len - 1; - c = *cp; - *cp = '\0'; - if (!doflush) - err = testit(buf); - if (err) - break; - doflush = c == '\n' ? 0 : 1; - } - } - - /* - * Try path(s) listed on command-line. - */ - while (optind < argc) { - path = argv[optind++]; - err = testit(path); - if (err) - break; - } - - /* - * Clean up. - */ - _test_sysio_shutdown(); - - return err; -} - -int -testit(const char *path) -{ - DIR *d; - struct dirent *de; - - printf("testing directory functions on %s\n", path); - - if ((d = SYSIO_INTERFACE_NAME(opendir)(path)) == NULL) { - perror(path); - return errno; - } - - while ((de = SYSIO_INTERFACE_NAME(readdir)(d)) != NULL) - printf("\t %s: ino %lu off %lu type %u\n", - de->d_name, (unsigned long )de->d_ino, - (unsigned long )de->d_off, (int )de->d_type); - - if (SYSIO_INTERFACE_NAME(closedir)(d)) { - perror("closedir"); - return errno; - } - - return 0; -} - -static void -usage() -{ - - (void )fprintf(stderr, - "Usage: test_stddir [ ...]\n"); - - exit(1); -} diff --git a/libsysio/tests/test_symlink.c b/libsysio/tests/test_symlink.c deleted file mode 100644 index a8e134a2..0000000 --- a/libsysio/tests/test_symlink.c +++ /dev/null @@ -1,140 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2006 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include -#if 0 -#include -#endif -#include -#include -#include - -#if defined(SYSIO_LABEL_NAMES) -#include "sysio.h" -#endif -#include "xtio.h" -#include "test.h" - -/* - * Test soft links - * - * Usage: symlink oldpath newpath - * - */ - -static void usage(void); - -int -main(int argc, char *const argv[]) -{ - int i; - int err; - int n; - extern int _test_sysio_startup(void); - - /* - * Parse command line arguments. - */ - while ((i = getopt(argc, argv, "")) != -1) - switch (i) { - - default: - usage(); - } - - /* - * Init sysio lib. - */ - err = _test_sysio_startup(); - if (err) { - errno = -err; - perror("sysio startup"); - exit(1); - } - - n = argc - optind; - if (n < 2) usage(); - - /* - * Try paths listed on command-line. - */ - while (optind < argc) { - const char *old, *new; - struct stat stbuf; - - old = argv[optind++]; - new = argv[optind++]; - if ((err = SYSIO_INTERFACE_NAME(symlink)(old, new)) != 0) { - perror("link"); - break; - } - if ((err = SYSIO_INTERFACE_NAME(lstat)(new, &stbuf)) != 0) { - perror(new); - break; - } - } - - /* - * Clean up. - */ - _test_sysio_shutdown(); - - return err ? -1 : 0; -} - -static void -usage() -{ - - (void )fprintf(stderr, - "Usage: symlink" - " oldpath newpath\n"); - - exit(1); -} diff --git a/libsysio/tests/test_unlink.c b/libsysio/tests/test_unlink.c deleted file mode 100644 index 3b02a9f..0000000 --- a/libsysio/tests/test_unlink.c +++ /dev/null @@ -1,165 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#if 0 -#include -#endif -#include -#include - -#if defined(SYSIO_LABEL_NAMES) -#include "sysio.h" -#endif -#include "xtio.h" -#include "test.h" - -/* - * Unlink files. - * - * Usage: unlink [path...] - * - * Without any path arguments, the program unlinks files named - * by the ocmmand line args. - */ - -static int unlinkit(const char *path); -static void usage(void); - -int -main(int argc, char *const argv[]) -{ - int i; - int err; - int n; - extern int _test_sysio_startup(void); - - /* - * Parse command line arguments. - */ - while ((i = getopt(argc, argv, "")) != -1) - switch (i) { - - default: - usage(); - } - - /* - * Init sysio lib. - */ - err = _test_sysio_startup(); - if (err) { - errno = -err; - perror("sysio startup"); - exit(1); - } - - n = argc - optind; - - /* - * Try path(s) listed on command-line. - */ - while (optind < argc) { - const char *path; - - path = argv[optind++]; - (void )unlinkit(path); - } - - /* - * If no command-line arguments, read from stdin until EOF. - */ - if (!n) { - int doflush; - static char buf[4096]; - size_t len; - char *cp; - char c; - - doflush = 0; - while (fgets(buf, sizeof(buf), stdin) != NULL) { - len = strlen(buf); - cp = buf + len - 1; - c = *cp; - *cp = '\0'; - if (!doflush) - unlinkit(buf); - doflush = c == '\n' ? 0 : 1; - } - } - - /* - * Clean up. - */ - _test_sysio_shutdown(); - - return 0; -} - -static int -unlinkit(const char *path) -{ - - if (SYSIO_INTERFACE_NAME(unlink)(path) != 0) { - perror(path); - return -1; - } - - return 0; -} - -static void -usage() -{ - - (void )fprintf(stderr, - "Usage: unlink" - " [ ...\n]"); - - exit(1); -} diff --git a/lustre/liblustre/.gitignore b/lustre/liblustre/.gitignore deleted file mode 100644 index 3609346..0000000 --- a/lustre/liblustre/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/Makefile.in -/libtest diff --git a/lustre/liblustre/Makefile.am b/lustre/liblustre/Makefile.am deleted file mode 100644 index 9cb3682..0000000 --- a/lustre/liblustre/Makefile.am +++ /dev/null @@ -1,69 +0,0 @@ -## Liblustre excecutables & libraries Makefile -SUBDIRS = . tests - -AM_CPPFLAGS = $(HAVE_EFENCE) -I$(SYSIO)/include \ - $(LLCPPFLAGS) -I$(top_srcdir)/lnet/ulnds -AM_CFLAGS = $(LLCFLAGS) - -AM_LIBS = $(LIBEFENCE) - - - -LUSTRE_LIBS = libllite.a \ - $(top_builddir)/lustre/lov/liblov.a \ - $(top_builddir)/lustre/obdecho/libobdecho.a \ - $(top_builddir)/lustre/osc/libosc.a \ - $(top_builddir)/lustre/fid/libfid.a \ - $(top_builddir)/lustre/fld/libfld.a \ - $(top_builddir)/lustre/lmv/liblmv.a \ - $(top_builddir)/lustre/mdc/libmdc.a \ - $(top_builddir)/lustre/mgc/libmgc.a \ - $(top_builddir)/lustre/ptlrpc/libptlrpc.a \ - $(top_builddir)/lustre/obdclass/liblustreclass.a - -LND_LIBS = -if BUILD_USOCKLND -LND_LIBS += $(top_builddir)/lnet/ulnds/socklnd/libsocklnd.a -endif - -LNET_LIBS = $(top_builddir)/lnet/utils/libuptlctl.a \ - $(top_builddir)/lnet/lnet/liblnet.a - -SYSIO_LIBS = $(SYSIO)/lib/libsysio.a - -if LIBLUSTRE -lib_LIBRARIES = liblustre.a -noinst_LIBRARIES = libllite.a - -install-exec-hook: liblustre.so - @$(NORMAL_INSTALL) - $(mkinstalldirs) $(DESTDIR)$(libdir) - @list=$< ; for p in $$list; do \ - if test -f $$p; then \ - f="`echo $$p | sed -e 's|^.*/||'`"; \ - echo " $(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/$$f"; \ - $(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/$$f; \ - else :; fi; \ - done -else -install-exec-hook: -endif - -libllite_a_SOURCES = llite_lib.c super.c namei.c rw.c file.c dir.c \ - lutil.c lutil.h llite_lib.h llite_cl.c - -# for make rpms -- need cleanup -liblustre_a_SOURCES = llite_lib.c super.c namei.c rw.c file.c dir.c \ - llite_lib.h llite_cl.c - -export CC -export LDFLAGS -export AR -export RANLIB - -liblustre.a : $(LUSTRE_LIBS) $(LND_LIBS) $(LNET_LIBS) $(SYSIO_LIBS) - sh $(srcdir)/genlib.sh "$(SYSIO)" "$(LIBS)" "$(LND_LIBS)" "$(PTHREAD_LIBS)" "$(CAP_LIBS)" - -EXTRA_DIST = genlib.sh - -CLEANFILES = liblsupport.a liblustre.so diff --git a/lustre/liblustre/dir.c b/lustre/liblustre/dir.c deleted file mode 100644 index 2b41e8f..0000000 --- a/lustre/liblustre/dir.c +++ /dev/null @@ -1,300 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * 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 version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2011, 2012, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * lustre/liblustre/dir.c - * - * Lustre Light directory handling - */ - -#define DEBUG_SUBSYSTEM S_LLITE - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "llite_lib.h" -#include - -/* (new) readdir implementation overview can be found in lustre/llite/dir.c */ -static int llu_dir_do_readpage(struct inode *inode, struct page *page) -{ - struct llu_inode_info *lli = llu_i2info(inode); - struct intnl_stat *st = llu_i2stat(inode); - struct llu_sb_info *sbi = llu_i2sbi(inode); - struct ptlrpc_request *request; - struct lustre_handle lockh; - struct mdt_body *body; - struct lookup_intent it = { .it_op = IT_READDIR }; - struct md_op_data op_data = {{ 0 }}; - ldlm_policy_data_t policy = { .l_inodebits = { MDS_INODELOCK_UPDATE } }; - int rc = 0; - ENTRY; - - llu_prep_md_op_data(&op_data, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY); - rc = md_lock_match(sbi->ll_md_exp, LDLM_FL_BLOCK_GRANTED, - &lli->lli_fid, LDLM_IBITS, &policy, LCK_CR, &lockh); - if (!rc) { - struct ldlm_enqueue_info einfo = { - .ei_type = LDLM_IBITS, - .ei_mode = LCK_CR, - .ei_cb_bl = llu_md_blocking_ast, - .ei_cb_cp = ldlm_completion_ast, - .ei_cbdata = inode, - }; - - rc = md_enqueue(sbi->ll_md_exp, &einfo, NULL, &it, &op_data, - &lockh, LDLM_FL_CANCEL_ON_BLOCK); - request = (struct ptlrpc_request *)it.d.lustre.it_data; - if (request) - ptlrpc_req_finished(request); - if (rc < 0) { - CERROR("lock enqueue: err: %d\n", rc); - RETURN(rc); - } - } - ldlm_lock_dump_handle(D_OTHER, &lockh); - - op_data.op_npages = 1; - rc = md_readpage(sbi->ll_md_exp, &op_data, &page, &request); - if (!rc) { - body = req_capsule_server_get(&request->rq_pill, &RMF_MDT_BODY); - LASSERT(body != NULL); /* checked by md_readpage() */ - - if (body->valid & OBD_MD_FLSIZE) - st->st_size = body->size; - } else { - CERROR("read_dir_page(%ld) error %d\n", page->index, rc); - } - ptlrpc_req_finished(request); - EXIT; - - ldlm_lock_decref(&lockh, LCK_CR); - return rc; -} - -static struct page *llu_dir_read_page(struct inode *ino, __u64 hash, - int exact, struct ll_dir_chain *chain) -{ - struct page *page; - int rc; - ENTRY; - - OBD_PAGE_ALLOC(page, 0); - if (!page) - RETURN(ERR_PTR(-ENOMEM)); - page->index = hash_x_index(hash, 0); - - rc = llu_dir_do_readpage(ino, page); - if (rc) { - OBD_PAGE_FREE(page); - RETURN(ERR_PTR(rc)); - } - - return page; -} - -static void *(*memmover)(void *, const void *, size_t) = memmove; - -#define NAME_OFFSET(de) ((int) ((de)->d_name - (char *) (de))) -#define ROUND_UP64(x) (((x)+sizeof(__u64)-1) & ~(sizeof(__u64)-1)) -static int filldir(char *buf, int buflen, const char *name, int namelen, - loff_t offset, ino_t ino, unsigned int d_type, int *filled) -{ - struct intnl_dirent *dirent = (struct intnl_dirent *)(buf + *filled); - struct intnl_dirent holder; - int reclen = ROUND_UP64(NAME_OFFSET(dirent) + namelen + 1); - - /* - * @buf is not guaranteed to be properly aligned. To work around, - * first fill stack-allocated @holder, then copy @holder into @buf by - * memmove(). - */ - - /* check overflow */ - if ((*filled + reclen) > buflen) - return 1; - - holder.d_ino = ino; -#ifdef _DIRENT_HAVE_D_OFF - holder.d_off = offset; -#endif - holder.d_reclen = reclen; -#ifdef _DIRENT_HAVE_D_TYPE - holder.d_type = (unsigned short) d_type; -#endif - /* gcc unrolls memcpy() of structs into field-wise assignments, - * assuming proper alignment. Humor it. */ - (*memmover)(dirent, &holder, NAME_OFFSET(dirent)); - memcpy(dirent->d_name, name, namelen); - dirent->d_name[namelen] = 0; - - *filled += reclen; - - return 0; -} - -/* - * TODO: much of the code here is similar/identical to llite ll_readdir(). - * These code can be factored out and shared in a common module. - */ - -ssize_t llu_iop_filldirentries(struct inode *dir, _SYSIO_OFF_T *basep, - char *buf, size_t nbytes) -{ - struct llu_inode_info *lli = llu_i2info(dir); - struct intnl_stat *st = llu_i2stat(dir); - loff_t pos = *basep; - struct ll_dir_chain chain; - struct page *page; - int filled = 0; - int rc; - int done; - __u16 type; - ENTRY; - - liblustre_wait_event(0); - - if (st->st_size == 0) { - CWARN("dir size is 0?\n"); - RETURN(0); - } - - if (pos == MDS_DIR_END_OFF) - /* - * end-of-file. - */ - RETURN(0); - - rc = 0; - done = 0; - ll_dir_chain_init(&chain); - - page = llu_dir_read_page(dir, pos, 0, &chain); - while (rc == 0 && !done) { - struct lu_dirpage *dp; - struct lu_dirent *ent; - - if (!IS_ERR(page)) { - /* - * If page is empty (end of directoryis reached), - * use this value. - */ - __u64 hash = MDS_DIR_END_OFF; - __u64 next; - - dp = page->addr; - for (ent = lu_dirent_start(dp); ent != NULL && !done; - ent = lu_dirent_next(ent)) { - char *name; - int namelen; - struct lu_fid fid; - __u64 ino; - - hash = le64_to_cpu(ent->lde_hash); - namelen = le16_to_cpu(ent->lde_namelen); - - if (hash < pos) - /* - * Skip until we find target hash - * value. - */ - continue; - - if (namelen == 0) - /* - * Skip dummy record. - */ - continue; - - fid = ent->lde_fid; - name = ent->lde_name; - fid_le_to_cpu(&fid, &fid); - ino = cl_fid_build_ino(&fid, 0); - type = ll_dirent_type_get(ent); - done = filldir(buf, nbytes, name, namelen, - (loff_t)hash, ino, type, - &filled); - } - next = le64_to_cpu(dp->ldp_hash_end); - OBD_PAGE_FREE(page); - if (!done) { - pos = next; - if (pos == MDS_DIR_END_OFF) - /* - * End of directory reached. - */ - done = 1; - else if (1 /* chain is exhausted*/) - /* - * Normal case: continue to the next - * page. - */ - page = llu_dir_read_page(dir, pos, 1, - &chain); - else { - /* - * go into overflow page. - */ - } - } else { - pos = hash; - if (filled == 0) - GOTO(out, filled = -EINVAL); - } - } else { - rc = PTR_ERR(page); - CERROR("error reading dir "DFID" at %lu: rc %d\n", - PFID(&lli->lli_fid), (unsigned long)pos, rc); - } - } - lli->lli_dir_pos = (loff_t)pos; - *basep = lli->lli_dir_pos; -out: - ll_dir_chain_fini(&chain); - liblustre_wait_event(0); - RETURN(filled); -} diff --git a/lustre/liblustre/file.c b/lustre/liblustre/file.c deleted file mode 100644 index 5a30299..0000000 --- a/lustre/liblustre/file.c +++ /dev/null @@ -1,533 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * 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 version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2011, 2013, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * lustre/liblustre/file.c - * - * Lustre Light file operations - */ - -#define DEBUG_SUBSYSTEM S_LLITE - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "llite_lib.h" - -/* Pack the required supplementary groups into the supplied groups array. - * If we don't need to use the groups from the target inode(s) then we - * instead pack one or more groups from the user's supplementary group - * array in case it might be useful. Not needed if doing an MDS-side upcall. */ -void ll_i2gids(__u32 *suppgids, struct inode *i1, struct inode *i2) -{ - LASSERT(i1 != NULL); - LASSERT(suppgids != NULL); - - if (in_group_p(i1->i_stbuf.st_gid)) - suppgids[0] = i1->i_stbuf.st_gid; - else - suppgids[0] = -1; - - if (i2) { - if (in_group_p(i2->i_stbuf.st_gid)) - suppgids[1] = i2->i_stbuf.st_gid; - else - suppgids[1] = -1; - } else { - suppgids[1] = -1; - } -} - -void llu_prep_md_op_data(struct md_op_data *op_data, struct inode *i1, - struct inode *i2, const char *name, int namelen, - int mode, __u32 opc) -{ - LASSERT(i1 != NULL || i2 != NULL); - LASSERT(op_data); - - if (i1) { - ll_i2gids(op_data->op_suppgids, i1, i2); - op_data->op_fid1 = *ll_inode2fid(i1); - }else { - ll_i2gids(op_data->op_suppgids, i2, i1); - op_data->op_fid1 = *ll_inode2fid(i2); - } - - if (i2) - op_data->op_fid2 = *ll_inode2fid(i2); - else - fid_zero(&op_data->op_fid2); - - op_data->op_name = name; - op_data->op_mode = mode; - op_data->op_namelen = namelen; - op_data->op_mod_time = CFS_CURRENT_TIME; - op_data->op_data = NULL; -} - -void obdo_refresh_inode(struct inode *dst, - struct obdo *src, - obd_flag valid) -{ - struct intnl_stat *st = llu_i2stat(dst); - valid &= src->o_valid; - - if (valid & (OBD_MD_FLCTIME | OBD_MD_FLMTIME)) - CDEBUG(D_INODE,"valid "LPX64", cur time "CFS_TIME_T"/"CFS_TIME_T - ", new %lu/%lu\n", - src->o_valid, LTIME_S(st->st_mtime), - LTIME_S(st->st_ctime), - (long)src->o_mtime, (long)src->o_ctime); - - if (valid & OBD_MD_FLATIME && src->o_atime > LTIME_S(st->st_atime)) - LTIME_S(st->st_atime) = src->o_atime; - if (valid & OBD_MD_FLMTIME && src->o_mtime > LTIME_S(st->st_mtime)) - LTIME_S(st->st_mtime) = src->o_mtime; - if (valid & OBD_MD_FLCTIME && src->o_ctime > LTIME_S(st->st_ctime)) - LTIME_S(st->st_ctime) = src->o_ctime; - if (valid & OBD_MD_FLSIZE && src->o_size > st->st_size) - st->st_size = src->o_size; - /* optimum IO size */ - if (valid & OBD_MD_FLBLKSZ) - st->st_blksize = src->o_blksize; - /* allocation of space */ - if (valid & OBD_MD_FLBLOCKS && src->o_blocks > st->st_blocks) - st->st_blocks = src->o_blocks; -} - -/** - * Assign an obtained @ioepoch to client's inode. No lock is needed, MDS does - * not believe attributes if a few ioepoch holders exist. Attributes for - * previous ioepoch if new one is opened are also skipped by MDS. - */ -void llu_ioepoch_open(struct llu_inode_info *lli, __u64 ioepoch) -{ - if (ioepoch && lli->lli_ioepoch != ioepoch) { - lli->lli_ioepoch = ioepoch; - CDEBUG(D_INODE, "Epoch "LPU64" opened on "DFID" for truncate\n", - ioepoch, PFID(&lli->lli_fid)); - } -} - -int llu_local_open(struct llu_inode_info *lli, struct lookup_intent *it) -{ - struct ptlrpc_request *req = it->d.lustre.it_data; - struct ll_file_data *fd; - struct mdt_body *body; - ENTRY; - - body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); - LASSERT(body != NULL); - - /* already opened? */ - if (lli->lli_open_count++) - RETURN(0); - - LASSERT(!lli->lli_file_data); - - OBD_ALLOC(fd, sizeof(*fd)); - /* We can't handle this well without reorganizing ll_file_open and - * ll_md_close, so don't even try right now. */ - LASSERT(fd != NULL); - - memcpy(&fd->fd_mds_och.och_fh, &body->handle, sizeof(body->handle)); - fd->fd_mds_och.och_magic = OBD_CLIENT_HANDLE_MAGIC; - fd->fd_mds_och.och_fid = lli->lli_fid; - lli->lli_file_data = fd; - llu_ioepoch_open(lli, body->ioepoch); - md_set_open_replay_data(lli->lli_sbi->ll_md_exp, &fd->fd_mds_och, it); - - RETURN(0); -} - -int llu_iop_open(struct pnode *pnode, int flags, mode_t mode) -{ - struct inode *inode = pnode->p_base->pb_ino; - struct llu_inode_info *lli = llu_i2info(inode); - struct intnl_stat *st = llu_i2stat(inode); - struct ptlrpc_request *request; - struct lookup_intent *it; - int rc = 0; - ENTRY; - - liblustre_wait_event(0); - - /* don't do anything for '/' */ - if (llu_is_root_inode(inode)) - RETURN(0); - - CDEBUG(D_VFSTRACE, "VFS Op:inode=%llu\n", (long long)st->st_ino); - LL_GET_INTENT(inode, it); - - if (!it->d.lustre.it_disposition) { - LBUG(); - } - - rc = it_open_error(DISP_OPEN_OPEN, it); - if (rc) - GOTO(out_release, rc); - - rc = llu_local_open(lli, it); - if (rc) - LBUG(); - - if (!S_ISREG(st->st_mode)) - GOTO(out_release, rc = 0); - - if (lli->lli_has_smd && cl_is_lov_delay_create(flags)) { - /* a bit ugly, but better than changing the open() API */ - unsigned int tmp_flags = flags; - - cl_lov_delay_create_clear(&tmp_flags); - flags = tmp_flags; - } - /*XXX: open_flags are overwritten and the previous ones are lost */ - lli->lli_open_flags = flags & ~(O_CREAT | O_EXCL | O_TRUNC); - - out_release: - request = it->d.lustre.it_data; - ptlrpc_req_finished(request); - - it->it_op_release(it); - OBD_FREE(it, sizeof(*it)); - - /* libsysio hasn't done anything for O_TRUNC. here we - * simply simulate it as open(...); truncate(...); */ - if (rc == 0 && (flags & O_TRUNC) && S_ISREG(st->st_mode)) { - struct iattr attr; - - memset(&attr, 0, sizeof(attr)); - attr.ia_size = 0; - attr.ia_valid |= ATTR_SIZE | ATTR_RAW; - rc = llu_setattr_raw(inode, &attr); - if (rc) - CERROR("error %d truncate in open()\n", rc); - } - - liblustre_wait_event(0); - RETURN(rc); -} - -int llu_objects_destroy(struct ptlrpc_request *req, struct inode *dir) -{ - struct mdt_body *body; - struct lov_mds_md *eadata; - struct lov_stripe_md *lsm = NULL; - struct obd_trans_info oti = { 0 }; - struct obdo *oa; - int rc; - ENTRY; - - body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); - - if (!(body->valid & OBD_MD_FLEASIZE)) - RETURN(0); - - if (body->eadatasize == 0) { - CERROR("OBD_MD_FLEASIZE set but eadatasize zero\n"); - GOTO(out, rc = -EPROTO); - } - - /* The MDS sent back the EA because we unlinked the last reference - * to this file. Use this EA to unlink the objects on the OST. - * It's opaque so we don't swab here; we leave it to obd_unpackmd() to - * check it is complete and sensible. */ - eadata = req_capsule_server_sized_get(&req->rq_pill, &RMF_MDT_MD, - body->eadatasize); - - LASSERT(eadata != NULL); - - rc = obd_unpackmd(llu_i2obdexp(dir), &lsm, eadata,body->eadatasize); - if (rc < 0) { - CERROR("obd_unpackmd: %d\n", rc); - GOTO(out, rc); - } - LASSERT(rc >= sizeof(*lsm)); - - OBDO_ALLOC(oa); - if (oa == NULL) - GOTO(out_free_memmd, rc = -ENOMEM); - - oa->o_oi = lsm->lsm_oi; - oa->o_mode = body->mode & S_IFMT; - oa->o_valid = OBD_MD_FLID | OBD_MD_FLTYPE | OBD_MD_FLGROUP; - obdo_set_parent_fid(oa, &llu_i2info(dir)->lli_fid); - if (body->valid & OBD_MD_FLCOOKIE) { - oa->o_valid |= OBD_MD_FLCOOKIE; - oti.oti_logcookies = - req_capsule_server_sized_get(&req->rq_pill, - &RMF_LOGCOOKIES, - sizeof(struct llog_cookie) * - lsm->lsm_stripe_count); - if (oti.oti_logcookies == NULL) { - oa->o_valid &= ~OBD_MD_FLCOOKIE; - body->valid &= ~OBD_MD_FLCOOKIE; - } - } - - rc = obd_destroy(NULL, llu_i2obdexp(dir), oa, lsm, &oti, NULL, NULL); - OBDO_FREE(oa); - if (rc) - CERROR("obd destroy objid "DOSTID" error %d\n", - POSTID(&lsm->lsm_oi), rc); -out_free_memmd: - obd_free_memmd(llu_i2obdexp(dir), &lsm); -out: - return rc; -} - -/** Cliens updates SOM attributes on MDS: obd_getattr and md_setattr. */ -int llu_som_update(struct inode *inode, struct md_op_data *op_data) -{ - struct llu_inode_info *lli = llu_i2info(inode); - struct llu_sb_info *sbi = llu_i2sbi(inode); - struct obdo oa = { 0 }; - __u32 old_flags; - int rc; - ENTRY; - - LASSERT(!(lli->lli_flags & LLIF_MDS_SIZE_LOCK)); - LASSERT(sbi->ll_lco.lco_flags & OBD_CONNECT_SOM); - - old_flags = op_data->op_flags; - op_data->op_flags = MF_SOM_CHANGE; - - /* If inode is already in another epoch, skip getattr from OSTs. */ - if (lli->lli_ioepoch == op_data->op_ioepoch) { - rc = llu_inode_getattr(inode, &oa, op_data->op_ioepoch, - old_flags & MF_GETATTR_LOCK); - if (rc) { - oa.o_valid = 0; - if (rc != -ENOENT) - CERROR("inode_getattr failed (%d): unable to " - "send a Size-on-MDS attribute update " - "for inode %llu/%lu\n", rc, - (long long)llu_i2stat(inode)->st_ino, - lli->lli_st_generation); - } else { - CDEBUG(D_INODE, "Size-on-MDS update on "DFID"\n", - PFID(&lli->lli_fid)); - } - - /* Install attributes into op_data. */ - md_from_obdo(op_data, &oa, oa.o_valid); - } - - rc = llu_md_setattr(inode, op_data, NULL); - RETURN(rc); -} - -void llu_pack_inode2opdata(struct inode *inode, struct md_op_data *op_data, - struct lustre_handle *fh) -{ - struct llu_inode_info *lli = llu_i2info(inode); - struct intnl_stat *st = llu_i2stat(inode); - ENTRY; - - op_data->op_fid1 = lli->lli_fid; - op_data->op_attr.ia_atime = st->st_atime; - op_data->op_attr.ia_mtime = st->st_mtime; - op_data->op_attr.ia_ctime = st->st_ctime; - op_data->op_attr.ia_size = st->st_size; - op_data->op_attr_blocks = st->st_blocks; - op_data->op_attr.ia_attr_flags = lli->lli_st_flags; - op_data->op_ioepoch = lli->lli_ioepoch; - if (fh) - op_data->op_handle = *fh; - EXIT; -} - -/** Pack SOM attributes info @opdata for CLOSE, DONE_WRITING rpc. */ -void llu_done_writing_attr(struct inode *inode, struct md_op_data *op_data) -{ - struct llu_inode_info *lli = llu_i2info(inode); - ENTRY; - - op_data->op_flags |= MF_SOM_CHANGE; - - /* Pack Size-on-MDS attributes if we are in IO - * epoch and attributes are valid. */ - LASSERT(!(lli->lli_flags & LLIF_MDS_SIZE_LOCK)); - if (!cl_local_size(inode)) - op_data->op_attr.ia_valid |= ATTR_MTIME_SET | ATTR_CTIME_SET | - ATTR_ATIME_SET | ATTR_SIZE | ATTR_BLOCKS; - - EXIT; -} - -static void llu_prepare_close(struct inode *inode, struct md_op_data *op_data, - struct ll_file_data *fd) -{ - struct obd_client_handle *och = &fd->fd_mds_och; - - op_data->op_attr.ia_valid = ATTR_MODE | ATTR_ATIME_SET | - ATTR_MTIME_SET | ATTR_CTIME_SET; - - if (fd->fd_flags & FMODE_WRITE) { - struct llu_sb_info *sbi = llu_i2sbi(inode); - if (!(sbi->ll_lco.lco_flags & OBD_CONNECT_SOM) || - !S_ISREG(llu_i2stat(inode)->st_mode)) { - op_data->op_attr.ia_valid |= ATTR_SIZE | ATTR_BLOCKS; - } else { - /* Inode cannot be dirty. Close the epoch. */ - op_data->op_flags |= MF_EPOCH_CLOSE; - /* XXX: Send SOM attributes only if they are really - * changed. */ - llu_done_writing_attr(inode, op_data); - } - } - llu_pack_inode2opdata(inode, op_data, &och->och_fh); - llu_prep_md_op_data(op_data, inode, NULL, NULL, - 0, 0, LUSTRE_OPC_ANY); -} - -int llu_md_close(struct obd_export *md_exp, struct inode *inode) -{ - struct llu_inode_info *lli = llu_i2info(inode); - struct ll_file_data *fd = lli->lli_file_data; - struct ptlrpc_request *req = NULL; - struct obd_client_handle *och = &fd->fd_mds_och; - struct intnl_stat *st = llu_i2stat(inode); - struct md_op_data op_data = { { 0 } }; - int rc; - ENTRY; - - /* clear group lock, if present */ - if (fd->fd_flags & LL_FILE_GROUP_LOCKED) - llu_put_grouplock(inode, fd->fd_grouplock.cg_gid); - - llu_prepare_close(inode, &op_data, fd); - rc = md_close(md_exp, &op_data, och->och_mod, &req); - if (rc == -EAGAIN) { - /* We are the last writer, so the MDS has instructed us to get - * the file size and any write cookies, then close again. */ - LASSERT(lli->lli_open_flags & FMODE_WRITE); - rc = llu_som_update(inode, &op_data); - if (rc) { - CERROR("inode %llu mdc Size-on-MDS update failed: " - "rc = %d\n", (long long)st->st_ino, rc); - rc = 0; - } - } else if (rc) { - CERROR("inode %llu close failed: rc %d\n", - (long long)st->st_ino, rc); - } else { - rc = llu_objects_destroy(req, inode); - if (rc) - CERROR("inode %llu ll_objects destroy: rc = %d\n", - (long long)st->st_ino, rc); - } - - md_clear_open_replay_data(md_exp, och); - ptlrpc_req_finished(req); - och->och_fh.cookie = DEAD_HANDLE_MAGIC; - lli->lli_file_data = NULL; - OBD_FREE(fd, sizeof(*fd)); - - RETURN(rc); -} - -int llu_file_release(struct inode *inode) -{ - struct ll_file_data *fd; - struct llu_sb_info *sbi = llu_i2sbi(inode); - struct llu_inode_info *lli = llu_i2info(inode); - int rc = 0, rc2; - - ENTRY; - CDEBUG(D_VFSTRACE, "VFS Op:inode=%llu/%lu\n", - (long long)llu_i2stat(inode)->st_ino, lli->lli_st_generation); - - if (llu_is_root_inode(inode)) - RETURN(0); - - /* still opened by others? */ - if (--lli->lli_open_count) - RETURN(0); - - fd = lli->lli_file_data; - if (!fd) /* no process opened the file after an mcreate */ - RETURN(0); - - rc2 = llu_md_close(sbi->ll_md_exp, inode); - if (rc2 && !rc) - rc = rc2; - - RETURN(rc); -} - -/* - * libsysio require us return 0 - */ -int llu_iop_close(struct inode *inode) -{ - int rc; - - liblustre_wait_event(0); - - rc = llu_file_release(inode); - if (rc) { - CERROR("file close error %d\n", rc); - } - /* if open count == 0 && stale_flag is set, should we - * remove the inode immediately? */ - liblustre_wait_idle(); - return 0; -} - -_SYSIO_OFF_T llu_iop_pos(struct inode *ino, _SYSIO_OFF_T off) -{ - ENTRY; - - liblustre_wait_event(0); - - if (off < 0 || off > ll_file_maxbytes(ino)) - RETURN(-EINVAL); - - RETURN(off); -} diff --git a/lustre/liblustre/genlib.sh b/lustre/liblustre/genlib.sh deleted file mode 100755 index a80ebeb..0000000 --- a/lustre/liblustre/genlib.sh +++ /dev/null @@ -1,114 +0,0 @@ -#!/bin/bash -#set -xv -set -e - -# -# This script is to generate lib lustre library as a whole. It will leave -# two files on current directory: liblustre.a and liblustre.so. -# -# Most concern here is the libraries linking order -# -# FIXME: How to do this cleanly use makefile? -# - -# see http://osdir.com/ml/gmane.comp.gnu.binutils.bugs/2006-01/msg00016.php -ppc64_CPU=`uname -p` -if [ "x${ppc64_CPU}" = "xppc64" ]; then - LD="$CC -m64" -else - LD=$CC -fi - -CWD=`pwd` - -SYSIO=$1 -LIBS=$2 -LND_LIBS=$3 -PTHREAD_LIBS=$4 -CAP_LIBS=$5 - -if [ ! -f $SYSIO/lib/libsysio.a ]; then - echo "ERROR: $SYSIO/lib/libsysio.a dosen't exist" - exit 1 -fi - -# do cleanup at first -rm -f liblustre.so - -ALL_OBJS= - -build_obj_list() { - _objs=`$AR -t $1/$2 | grep -v SYMDEF | grep -v SORTED` - for _lib in $_objs; do - ALL_OBJS=$ALL_OBJS"$1/$_lib "; - done; -} - -# -# special treatment for libsysio -# -sysio_tmp=$CWD/sysio_tmp_`date +%s` -rm -rf $sysio_tmp -build_sysio_obj_list() { - _objs=`$AR -t $1 | grep -v SYMDEF | grep -v SORTED` - mkdir -p $sysio_tmp - cd $sysio_tmp - $AR -x $1 - cd .. - for _lib in $_objs; do - ALL_OBJS=$ALL_OBJS"$sysio_tmp/$_lib "; - done -} - -# lustre components libs -build_obj_list . libllite.a -build_obj_list ../lov liblov.a -build_obj_list ../obdecho libobdecho.a -build_obj_list ../osc libosc.a -build_obj_list ../lmv liblmv.a -build_obj_list ../mdc libmdc.a -build_obj_list ../fid libfid.a -build_obj_list ../fld libfld.a -build_obj_list ../mgc libmgc.a -build_obj_list ../ptlrpc libptlrpc.a -build_obj_list ../obdclass liblustreclass.a - -# lnet components libs -build_obj_list ../../lnet/utils libuptlctl.a -build_obj_list ../../libcfs/libcfs libcfs.a -build_obj_list ../../libcfs/libcfs libcfsutil.a -if $(echo "$LND_LIBS" | grep "socklnd" >/dev/null) ; then - build_obj_list ../../lnet/ulnds/socklnd libsocklnd.a -fi -build_obj_list ../../lnet/lnet liblnet.a - -# create static lib lsupport -rm -f $CWD/liblsupport.a -$AR -cru $CWD/liblsupport.a $ALL_OBJS -$RANLIB $CWD/liblsupport.a - -# if libsysio is already in our LIBS we don't need to link against it here -if $(echo "$LIBS" | grep -v -- "-lsysio" >/dev/null) ; then - build_sysio_obj_list $SYSIO/lib/libsysio.a -fi - -# create static lib lustre -rm -f $CWD/liblustre.a -$AR -cru $CWD/liblustre.a $ALL_OBJS -$RANLIB $CWD/liblustre.a - -# create shared lib lustre -rm -f $CWD/liblustre.so -OS=`uname` -if test x$OS = xAIX; then - $LD $LDFLAGS -shared -o $CWD/liblustre.so $ALL_OBJS -lpthread -Xlinker -bnoipath ../../libsyscall.so -else -# using -nostdlib on Ubuntu causes errors such as: -#./llite_lib.o: In function `liblustre_process_log': -#/home/brian/rpm/BUILD/lustre-1.8.2.50/lustre/liblustre/llite_lib.c:234: undefined reference to `__stack_chk_fail_local' -# due to the use of SSP -#$LD -shared -nostdlib -o $CWD/liblustre.so $ALL_OBJS $CAP_LIBS $PTHREAD_LIBS - $LD $LDFLAGS -shared -o $CWD/liblustre.so $ALL_OBJS $CAP_LIBS $PTHREAD_LIBS -fi - -rm -rf $sysio_tmp diff --git a/lustre/liblustre/llite_cl.c b/lustre/liblustre/llite_cl.c deleted file mode 100644 index e4ed309..0000000 --- a/lustre/liblustre/llite_cl.c +++ /dev/null @@ -1,769 +0,0 @@ -/* - * Copyright (c) 2007 Cluster File Systems, Inc. - * Author: Nikita Danilov - * - * This file is part of Lustre, http://www.lustre.org. - * - * Lustre is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * Lustre 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 Lustre; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Copyright (c) 2011, 2013, Intel Corporation. - */ - -#define DEBUG_SUBSYSTEM S_LLITE - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "llite_lib.h" - -/* - * slp_ prefix stands for "Sysio Library Posix". It corresponds to historical - * "llu_" prefix. - */ - -static int slp_type_init (struct lu_device_type *t); -static void slp_type_fini (struct lu_device_type *t); - -static int slp_page_init(const struct lu_env *env, struct cl_object *obj, - struct cl_page *page, pgoff_t index); -static int slp_attr_get (const struct lu_env *env, struct cl_object *obj, - struct cl_attr *attr); - -static struct lu_device *slp_device_alloc(const struct lu_env *env, - struct lu_device_type *t, - struct lustre_cfg *cfg); - -static int slp_io_init(const struct lu_env *env, struct cl_object *obj, - struct cl_io *io); -static struct slp_io *cl2slp_io(const struct lu_env *env, - const struct cl_io_slice *slice); - - -static void llu_free_user_page(struct page *page); - -static const struct lu_object_operations slp_lu_obj_ops; -static const struct lu_device_operations slp_lu_ops; -static const struct cl_device_operations slp_cl_ops; -static const struct cl_io_operations ccc_io_ops; -static const struct lu_device_type_operations slp_device_type_ops; - //struct lu_device_type slp_device_type; -static const struct cl_page_operations slp_transient_page_ops; -static const struct cl_lock_operations slp_lock_ops; - - -/***************************************************************************** - * - * Slp device and device type functions. - * - */ - -static void *slp_session_key_init(const struct lu_context *ctx, - struct lu_context_key *key) -{ - struct slp_session *session; - - OBD_ALLOC_PTR(session); - if (session == NULL) - session = ERR_PTR(-ENOMEM); - return session; -} - -static void slp_session_key_fini(const struct lu_context *ctx, - struct lu_context_key *key, void *data) -{ - struct slp_session *session = data; - OBD_FREE_PTR(session); -} - -struct lu_context_key slp_session_key = { - .lct_tags = LCT_SESSION, - .lct_init = slp_session_key_init, - .lct_fini = slp_session_key_fini -}; - -/* type constructor/destructor: slp_type_{init,fini,start,stop}(). */ -LU_TYPE_INIT_FINI(slp, &ccc_key, &ccc_session_key, &slp_session_key); - -static struct lu_device *slp_device_alloc(const struct lu_env *env, - struct lu_device_type *t, - struct lustre_cfg *cfg) -{ - return ccc_device_alloc(env, t, cfg, &slp_lu_ops, &slp_cl_ops); -} - -static int slp_lock_init(const struct lu_env *env, - struct cl_object *obj, struct cl_lock *lock, - const struct cl_io *io) -{ - return ccc_lock_init(env, obj, lock, io, &slp_lock_ops); -} - -static const struct cl_object_operations slp_ops = { - .coo_page_init = slp_page_init, - .coo_lock_init = slp_lock_init, - .coo_io_init = slp_io_init, - .coo_attr_get = slp_attr_get, - .coo_attr_set = ccc_attr_set, - .coo_conf_set = ccc_conf_set, - .coo_glimpse = ccc_object_glimpse -}; - -static int slp_object_print(const struct lu_env *env, void *cookie, - lu_printer_t p, const struct lu_object *o) -{ - struct ccc_object *obj = lu2ccc(o); - struct inode *inode = obj->cob_inode; - struct intnl_stat *st = NULL; - - if (inode) - st = llu_i2stat(inode); - - return (*p)(env, cookie, LUSTRE_SLP_NAME"-object@%p(%p:%lu/%u)", - obj, inode, - st ? (unsigned long)st->st_ino : 0UL, - inode ? (unsigned int)llu_i2info(inode)->lli_st_generation - : 0); -} - -static const struct lu_object_operations slp_lu_obj_ops = { - .loo_object_init = ccc_object_init, - .loo_object_start = NULL, - .loo_object_delete = NULL, - .loo_object_release = NULL, - .loo_object_free = ccc_object_free, - .loo_object_print = slp_object_print, - .loo_object_invariant = NULL -}; - -static struct lu_object *slp_object_alloc(const struct lu_env *env, - const struct lu_object_header *hdr, - struct lu_device *dev) -{ - return ccc_object_alloc(env, hdr, dev, &slp_ops, &slp_lu_obj_ops); -} - -static const struct lu_device_operations slp_lu_ops = { - .ldo_object_alloc = slp_object_alloc -}; - -static const struct cl_device_operations slp_cl_ops = { - .cdo_req_init = ccc_req_init -}; - -static const struct lu_device_type_operations slp_device_type_ops = { - .ldto_init = slp_type_init, - .ldto_fini = slp_type_fini, - - .ldto_start = slp_type_start, - .ldto_stop = slp_type_stop, - - .ldto_device_alloc = slp_device_alloc, - .ldto_device_free = ccc_device_free, - .ldto_device_init = ccc_device_init, - .ldto_device_fini = ccc_device_fini -}; - -static struct lu_device_type slp_device_type = { - .ldt_tags = LU_DEVICE_CL, - .ldt_name = LUSTRE_SLP_NAME, - .ldt_ops = &slp_device_type_ops, - .ldt_ctx_tags = LCT_CL_THREAD -}; - -int slp_global_init(void) -{ - int result; - - result = ccc_global_init(&slp_device_type); - return result; -} - -void slp_global_fini(void) -{ - ccc_global_fini(&slp_device_type); -} - -/***************************************************************************** - * - * Object operations. - * - */ - -static int slp_page_init(const struct lu_env *env, struct cl_object *obj, - struct cl_page *page, pgoff_t index) -{ - struct ccc_page *cpg = cl_object_page_slice(obj, page); - - CLOBINVRNT(env, obj, ccc_object_invariant(obj)); - - cpg->cpg_page = page->cp_vmpage; - - if (page->cp_type == CPT_CACHEABLE) { - LBUG(); - } else { - struct ccc_object *clobj = cl2ccc(obj); - - cl_page_slice_add(page, &cpg->cpg_cl, obj, index, - &slp_transient_page_ops); - clobj->cob_transient_pages++; - } - - return 0; -} - -static int slp_io_init(const struct lu_env *env, struct cl_object *obj, - struct cl_io *io) -{ - struct ccc_io *vio = ccc_env_io(env); - int result = 0; - - CLOBINVRNT(env, obj, ccc_object_invariant(obj)); - - cl_io_slice_add(io, &vio->cui_cl, obj, &ccc_io_ops); - if (io->ci_type == CIT_READ || io->ci_type == CIT_WRITE) { - size_t count; - - count = io->u.ci_rw.crw_count; - /* "If nbyte is 0, read() will return 0 and have no other - * results." -- Single Unix Spec */ - if (count == 0) - result = 1; - else { - vio->cui_tot_count = count; - vio->cui_tot_nrsegs = 0; - } - - } - return result; -} - -static int slp_attr_get(const struct lu_env *env, struct cl_object *obj, - struct cl_attr *attr) -{ - struct inode *inode = ccc_object_inode(obj); - struct intnl_stat *st = llu_i2stat(inode); - - attr->cat_size = st->st_size; - attr->cat_blocks = st->st_blocks; - attr->cat_mtime = st->st_mtime; - attr->cat_atime = st->st_atime; - attr->cat_ctime = st->st_ctime; - /* KMS is not known by this layer */ - return 0; /* layers below have to fill in the rest */ -} - -/***************************************************************************** - * - * Page operations. - * - */ - -static void slp_page_fini_common(struct ccc_page *cp) -{ - struct page *vmpage = cp->cpg_page; - - LASSERT(vmpage != NULL); - llu_free_user_page(vmpage); - OBD_FREE_PTR(cp); -} - -static void slp_page_completion_common(const struct lu_env *env, - struct ccc_page *cp, int ioret) -{ - LASSERT(cp->cpg_cl.cpl_page->cp_sync_io != NULL); -} - -static void slp_page_completion_read(const struct lu_env *env, - const struct cl_page_slice *slice, - int ioret) -{ - struct ccc_page *cp = cl2ccc_page(slice); - ENTRY; - - slp_page_completion_common(env, cp, ioret); - - EXIT; -} - -static void slp_page_completion_write_common(const struct lu_env *env, - const struct cl_page_slice *slice, - int ioret) -{ - struct ccc_page *cp = cl2ccc_page(slice); - - if (ioret == 0) { - cp->cpg_write_queued = 0; - /* - * Only ioret == 0, write succeed, then this page could be - * deleted from the pending_writing count. - */ - } - slp_page_completion_common(env, cp, ioret); -} - -static int slp_page_is_vmlocked(const struct lu_env *env, - const struct cl_page_slice *slice) -{ - return -EBUSY; -} - -static void slp_transient_page_fini(const struct lu_env *env, - struct cl_page_slice *slice) -{ - struct ccc_page *cp = cl2ccc_page(slice); - struct cl_page *clp = slice->cpl_page; - struct ccc_object *clobj = cl2ccc(clp->cp_obj); - - slp_page_fini_common(cp); - clobj->cob_transient_pages--; -} - - -static const struct cl_page_operations slp_transient_page_ops = { - .cpo_own = ccc_transient_page_own, - .cpo_assume = ccc_transient_page_assume, - .cpo_unassume = ccc_transient_page_unassume, - .cpo_disown = ccc_transient_page_disown, - .cpo_discard = ccc_transient_page_discard, - .cpo_is_vmlocked = slp_page_is_vmlocked, - .cpo_fini = slp_transient_page_fini, - .io = { - [CRT_READ] = { - .cpo_completion = slp_page_completion_read, - }, - [CRT_WRITE] = { - .cpo_completion = slp_page_completion_write_common, - } - } -}; - -/***************************************************************************** - * - * Lock operations. - * - */ - -static int slp_lock_enqueue(const struct lu_env *env, - const struct cl_lock_slice *slice, - struct cl_io *unused, __u32 enqflags) -{ - CLOBINVRNT(env, slice->cls_obj, ccc_object_invariant(slice->cls_obj)); - - liblustre_wait_event(0); - return 0; -} - -static const struct cl_lock_operations slp_lock_ops = { - .clo_delete = ccc_lock_delete, - .clo_fini = ccc_lock_fini, - .clo_enqueue = slp_lock_enqueue, - .clo_wait = ccc_lock_wait, - .clo_unuse = ccc_lock_unuse, - .clo_fits_into = ccc_lock_fits_into, -}; - -/***************************************************************************** - * - * io operations. - * - */ - -static int slp_io_rw_lock(const struct lu_env *env, - const struct cl_io_slice *ios) -{ - struct ccc_io *cio = ccc_env_io(env); - struct cl_io *io = ios->cis_io; - loff_t start; - loff_t end; - - if (cl_io_is_append(io)) { - start = 0; - end = OBD_OBJECT_EOF; - } else { - start = io->u.ci_wr.wr.crw_pos; - end = start + io->u.ci_wr.wr.crw_count - 1; - } - - ccc_io_update_iov(env, cio, io); - - /* - * This acquires real DLM lock only in O_APPEND case, because of - * the io->ci_lockreq setting in llu_io_init(). - */ - LASSERT(ergo(cl_io_is_append(io), io->ci_lockreq == CILR_MANDATORY)); - LASSERT(ergo(!cl_io_is_append(io), io->ci_lockreq == CILR_NEVER)); - return ccc_io_one_lock(env, io, 0, - io->ci_type == CIT_READ ? CLM_READ : CLM_WRITE, - start, end); - -} - -static int slp_io_setattr_iter_init(const struct lu_env *env, - const struct cl_io_slice *ios) -{ - return 0; -} - -static int slp_io_setattr_start(const struct lu_env *env, - const struct cl_io_slice *ios) -{ - return 0; -} - -static struct page *llu_get_user_page(int index, void *addr, int offset, - int count) -{ - struct page *page; - - OBD_ALLOC_PTR(page); - if (!page) - return NULL; - page->index = index; - page->addr = addr; - page->_offset = offset; - page->_count = count; - - CFS_INIT_LIST_HEAD(&page->list); - CFS_INIT_LIST_HEAD(&page->_node); - - return page; -} - -static void llu_free_user_page(struct page *page) -{ - OBD_FREE_PTR(page); -} - - -static int llu_queue_pio(const struct lu_env *env, struct cl_io *io, - struct llu_io_group *group, - char *buf, size_t count, loff_t pos) -{ - struct cl_object *obj = io->ci_obj; - struct inode *inode = ccc_object_inode(obj); - struct intnl_stat *st = llu_i2stat(inode); - struct obd_export *exp = llu_i2obdexp(inode); - struct page *page; - int rc = 0, ret_bytes = 0; - struct cl_page *clp; - struct cl_2queue *queue; - ENTRY; - - if (!exp) - RETURN(-EINVAL); - - queue = &io->ci_queue; - cl_2queue_init(queue); - - - /* prepare the pages array */ - do { - unsigned long index, offset, bytes; - - offset = (pos & ~CFS_PAGE_MASK); - index = pos >> PAGE_CACHE_SHIFT; - bytes = PAGE_CACHE_SIZE - offset; - if (bytes > count) - bytes = count; - - /* prevent read beyond file range */ - if (/* local_lock && */ - io->ci_type == CIT_READ && pos + bytes >= st->st_size) { - if (pos >= st->st_size) - break; - bytes = st->st_size - pos; - } - - /* prepare page for this index */ - page = llu_get_user_page(index, buf - offset, offset, bytes); - if (!page) { - rc = -ENOMEM; - break; - } - - clp = cl_page_find(env, obj, - cl_index(obj, pos), - page, CPT_TRANSIENT); - - if (IS_ERR(clp)) { - rc = PTR_ERR(clp); - break; - } - - rc = cl_page_own(env, io, clp); - if (rc) { - LASSERT(clp->cp_state == CPS_FREEING); - cl_page_put(env, clp); - break; - } - - cl_2queue_add(queue, clp); - - /* drop the reference count for cl_page_find, so that the page - * will be freed in cl_2queue_fini. */ - cl_page_put(env, clp); - - cl_page_clip(env, clp, offset, offset+bytes); - - count -= bytes; - pos += bytes; - buf += bytes; - - group->lig_rwcount += bytes; - ret_bytes += bytes; - page++; - } while (count); - - if (rc == 0) { - enum cl_req_type iot; - iot = io->ci_type == CIT_READ ? CRT_READ : CRT_WRITE; - rc = cl_io_submit_sync(env, io, iot, queue, 0); - } - - group->lig_rc = rc; - - cl_2queue_discard(env, io, queue); - cl_2queue_disown(env, io, queue); - cl_2queue_fini(env, queue); - - RETURN(ret_bytes); -} - -static -struct llu_io_group *get_io_group(struct inode *inode, int maxpages) -{ - struct llu_io_group *group; - - OBD_ALLOC_PTR(group); - if (!group) - return ERR_PTR(-ENOMEM); - - return group; -} - -static int max_io_pages(ssize_t len, int iovlen) -{ - return ((len + PAGE_CACHE_SIZE - 1) / PAGE_CACHE_SIZE) + - 2 + iovlen - 1; -} - -void put_io_group(struct llu_io_group *group) -{ - OBD_FREE_PTR(group); -} - -/** - * True, if \a io is a normal io, False for sendfile() / splice_{read|write} - */ -int cl_is_normalio(const struct lu_env *env, const struct cl_io *io) -{ - return 1; -} - -static int slp_io_start(const struct lu_env *env, const struct cl_io_slice *ios) -{ - struct ccc_io *cio = cl2ccc_io(env, ios); - struct cl_io *io = ios->cis_io; - struct cl_object *obj = io->ci_obj; - struct inode *inode = ccc_object_inode(obj); - int err, ret; - loff_t pos; - long cnt; - struct llu_io_group *iogroup; - int iovidx; - struct intnl_stat *st = llu_i2stat(inode); - struct llu_inode_info *lli = llu_i2info(inode); - struct llu_io_session *session = cl2slp_io(env, ios)->sio_session; - int write = io->ci_type == CIT_WRITE; - int exceed = 0; - - CLOBINVRNT(env, obj, ccc_object_invariant(obj)); - - if (write) { - pos = io->u.ci_wr.wr.crw_pos; - cnt = io->u.ci_wr.wr.crw_count; - } else { - pos = io->u.ci_rd.rd.crw_pos; - cnt = io->u.ci_rd.rd.crw_count; - } - - iogroup = get_io_group(inode, max_io_pages(cnt, cio->cui_nrsegs)); - if (IS_ERR(iogroup)) - RETURN(PTR_ERR(iogroup)); - - err = ccc_prep_size(env, obj, io, pos, cnt, &exceed); - if (err != 0 || (write == 0 && exceed != 0)) - GOTO(out, err); - - CDEBUG(D_INODE, - "%s ino %lu, %lu bytes, offset "LPU64", i_size "LPU64"\n", - write ? "Write" : "Read", (unsigned long)st->st_ino, - cnt, (__u64)pos, (__u64)st->st_size); - - if (write && io->u.ci_wr.wr_append) - pos = io->u.ci_wr.wr.crw_pos = st->st_size; /* XXX? Do we need to change io content too here? */ - /* XXX What about if one write syscall writes at 2 different offsets? */ - - for (iovidx = 0; iovidx < cio->cui_nrsegs; iovidx++) { - char *buf = (char *) cio->cui_iov[iovidx].iov_base; - long count = cio->cui_iov[iovidx].iov_len; - - if (!count) - continue; - if (cnt < count) - count = cnt; - if (IS_BAD_PTR(buf) || IS_BAD_PTR(buf + count)) { - GOTO(out, err = -EFAULT); - } - - if (io->ci_type == CIT_READ) { - if (/* local_lock && */ pos >= st->st_size) - break; - } else if (io->ci_type == CIT_WRITE) { - if (pos >= lli->lli_maxbytes) { - GOTO(out, err = -EFBIG); - } - if (pos + count >= lli->lli_maxbytes) - count = lli->lli_maxbytes - pos; - } else { - LBUG(); - } - - ret = llu_queue_pio(env, io, iogroup, buf, count, pos); - if (ret < 0) { - GOTO(out, err = ret); - } else { - io->ci_nob += ret; - pos += ret; - cnt -= ret; - if (io->ci_type == CIT_WRITE) { -// obd_adjust_kms(exp, lsm, pos, 0); // XXX - if (pos > st->st_size) - st->st_size = pos; - } - if (!cnt) - break; - } - } - LASSERT(cnt == 0 || io->ci_type == CIT_READ); /* libsysio should guarantee this */ - - if (!iogroup->lig_rc) - session->lis_rwcount += iogroup->lig_rwcount; - else if (!session->lis_rc) - session->lis_rc = iogroup->lig_rc; - err = 0; - -out: - put_io_group(iogroup); - return err; -} - -static const struct cl_io_operations ccc_io_ops = { - .op = { - [CIT_READ] = { - .cio_fini = ccc_io_fini, - .cio_lock = slp_io_rw_lock, - .cio_start = slp_io_start, - .cio_end = ccc_io_end, - .cio_advance = ccc_io_advance - }, - [CIT_WRITE] = { - .cio_fini = ccc_io_fini, - .cio_lock = slp_io_rw_lock, - .cio_start = slp_io_start, - .cio_end = ccc_io_end, - .cio_advance = ccc_io_advance - }, - [CIT_SETATTR] = { - .cio_fini = ccc_io_fini, - .cio_iter_init = slp_io_setattr_iter_init, - .cio_start = slp_io_setattr_start - }, - [CIT_MISC] = { - .cio_fini = ccc_io_fini - } - } -}; - -static struct slp_io *cl2slp_io(const struct lu_env *env, - const struct cl_io_slice *slice) -{ - /* We call it just for assertion here */ - cl2ccc_io(env, slice); - - return slp_env_io(env); -} - -/***************************************************************************** - * - * Temporary prototype thing: mirror obd-devices into cl devices. - * - */ - -int cl_sb_init(struct llu_sb_info *sbi) -{ - struct cl_device *cl; - struct lu_env *env; - int rc = 0; - int refcheck; - - env = cl_env_get(&refcheck); - if (IS_ERR(env)) - RETURN(PTR_ERR(env)); - - cl = cl_type_setup(env, NULL, &slp_device_type, - sbi->ll_dt_exp->exp_obd->obd_lu_dev); - if (IS_ERR(cl)) - GOTO(out, rc = PTR_ERR(cl)); - - sbi->ll_cl = cl; - sbi->ll_site = cl2lu_dev(cl)->ld_site; -out: - cl_env_put(env, &refcheck); - RETURN(rc); -} - -int cl_sb_fini(struct llu_sb_info *sbi) -{ - struct lu_env *env; - int refcheck; - - ENTRY; - - env = cl_env_get(&refcheck); - if (IS_ERR(env)) - RETURN(PTR_ERR(env)); - - if (sbi->ll_cl != NULL) { - cl_stack_fini(env, sbi->ll_cl); - sbi->ll_cl = NULL; - sbi->ll_site = NULL; - } - cl_env_put(env, &refcheck); - cl_env_cache_purge(~0); - - RETURN(0); -} diff --git a/lustre/liblustre/llite_lib.c b/lustre/liblustre/llite_lib.c deleted file mode 100644 index e108220..0000000 --- a/lustre/liblustre/llite_lib.c +++ /dev/null @@ -1,413 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * 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 version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2012, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * lustre/liblustre/llite_lib.c - * - * Lustre Light common routines - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "llite_lib.h" -#include "lutil.h" - -static int lllib_init(void) -{ - if (liblustre_init_current("liblustre") || - init_lib_portals() || - init_obdclass() || - ptlrpc_init() || - mgc_init() || - lmv_init() || - mdc_init() || - lov_init() || - osc_init() || - slp_global_init()) - return -1; - - return _sysio_fssw_register("lustre", &llu_fssw_ops); -} - -int liblustre_process_log(struct config_llog_instance *cfg, - char *mgsnid, char *profile, - int allow_recov) -{ - struct lustre_cfg_bufs bufs; - struct lustre_cfg *lcfg; - char *peer = "MGS_UUID"; - struct obd_device *obd; - struct obd_export *exp; - char *name = "mgc_dev"; - class_uuid_t uuid; - struct obd_uuid mgc_uuid; - struct llog_ctxt *ctxt; - lnet_nid_t nid = 0; - char *mdsnid; - int err, rc = 0; - struct obd_connect_data *ocd = NULL; - ENTRY; - - ll_generate_random_uuid(uuid); - class_uuid_unparse(uuid, &mgc_uuid); - - nid = libcfs_str2nid(mgsnid); - if (nid == LNET_NID_ANY) { - CERROR("Can't parse NID %s\n", mgsnid); - RETURN(-EINVAL); - } - - lustre_cfg_bufs_reset(&bufs, NULL); - lustre_cfg_bufs_set_string(&bufs, 1, peer); - lcfg = lustre_cfg_new(LCFG_ADD_UUID, &bufs); - lcfg->lcfg_nid = nid; - rc = class_process_config(lcfg); - lustre_cfg_free(lcfg); - if (rc < 0) - GOTO(out, rc); - - lustre_cfg_bufs_reset(&bufs, name); - lustre_cfg_bufs_set_string(&bufs, 1, LUSTRE_MGC_NAME); - lustre_cfg_bufs_set_string(&bufs, 2, mgc_uuid.uuid); - lcfg = lustre_cfg_new(LCFG_ATTACH, &bufs); - rc = class_process_config(lcfg); - lustre_cfg_free(lcfg); - if (rc < 0) - GOTO(out_del_uuid, rc); - - lustre_cfg_bufs_reset(&bufs, name); - lustre_cfg_bufs_set_string(&bufs, 1, LUSTRE_MGS_OBDNAME); - lustre_cfg_bufs_set_string(&bufs, 2, peer); - lcfg = lustre_cfg_new(LCFG_SETUP, &bufs); - rc = class_process_config(lcfg); - lustre_cfg_free(lcfg); - if (rc < 0) - GOTO(out_detach, rc); - - while ((mdsnid = strsep(&mgsnid, ","))) { - nid = libcfs_str2nid(mdsnid); - lustre_cfg_bufs_reset(&bufs, NULL); - lustre_cfg_bufs_set_string(&bufs, 1, libcfs_nid2str(nid)); - lcfg = lustre_cfg_new(LCFG_ADD_UUID, &bufs); - lcfg->lcfg_nid = nid; - rc = class_process_config(lcfg); - lustre_cfg_free(lcfg); - if (rc) { - CERROR("Add uuid for %s failed %d\n", - libcfs_nid2str(nid), rc); - continue; - } - - lustre_cfg_bufs_reset(&bufs, name); - lustre_cfg_bufs_set_string(&bufs, 1, libcfs_nid2str(nid)); - lcfg = lustre_cfg_new(LCFG_ADD_CONN, &bufs); - lcfg->lcfg_nid = nid; - rc = class_process_config(lcfg); - lustre_cfg_free(lcfg); - if (rc) { - CERROR("Add conn for %s failed %d\n", - libcfs_nid2str(nid), rc); - continue; - } - } - - obd = class_name2obd(name); - if (obd == NULL) - GOTO(out_cleanup, rc = -EINVAL); - - OBD_ALLOC(ocd, sizeof(*ocd)); - if (ocd == NULL) - GOTO(out_cleanup, rc = -ENOMEM); - - ocd->ocd_connect_flags = OBD_CONNECT_VERSION | OBD_CONNECT_AT | - OBD_CONNECT_FULL20; - ocd->ocd_version = LUSTRE_VERSION_CODE; - - rc = obd_connect(NULL, &exp, obd, &mgc_uuid, ocd, NULL); - if (rc) { - CERROR("cannot connect to %s at %s: rc = %d\n", - LUSTRE_MGS_OBDNAME, mgsnid, rc); - GOTO(out_cleanup, rc); - } - - ctxt = llog_get_context(exp->exp_obd, LLOG_CONFIG_REPL_CTXT); - cfg->cfg_flags |= CFG_F_COMPAT146; - rc = class_config_parse_llog(NULL, ctxt, profile, cfg); - llog_ctxt_put(ctxt); - if (rc) { - CERROR("class_config_parse_llog failed: rc = %d\n", rc); - } - - /* We don't so much care about errors in cleaning up the config llog - * connection, as we have already read the config by this point. */ - err = obd_disconnect(exp); - if (err) - CERROR("obd_disconnect failed: rc = %d\n", err); - -out_cleanup: - if (ocd) - OBD_FREE(ocd, sizeof(*ocd)); - - lustre_cfg_bufs_reset(&bufs, name); - lcfg = lustre_cfg_new(LCFG_CLEANUP, &bufs); - err = class_process_config(lcfg); - lustre_cfg_free(lcfg); - if (err) - CERROR("md_cleanup failed: rc = %d\n", err); - -out_detach: - lustre_cfg_bufs_reset(&bufs, name); - lcfg = lustre_cfg_new(LCFG_DETACH, &bufs); - err = class_process_config(lcfg); - lustre_cfg_free(lcfg); - if (err) - CERROR("md_detach failed: rc = %d\n", err); - -out_del_uuid: - lustre_cfg_bufs_reset(&bufs, name); - lustre_cfg_bufs_set_string(&bufs, 1, peer); - lcfg = lustre_cfg_new(LCFG_DEL_UUID, &bufs); - err = class_process_config(lcfg); - if (err) - CERROR("del MDC UUID failed: rc = %d\n", err); - lustre_cfg_free(lcfg); -out: - - RETURN(rc); -} - -/* parse host:/fsname string */ -int ll_parse_mount_target(const char *target, char **mgsnid, - char **fsname) -{ - static char buf[256]; - char *s; - - buf[255] = 0; - strncpy(buf, target, 255); - - if ((s = strchr(buf, ':'))) { - *mgsnid = buf; - *s = '\0'; - - while (*++s == '/') - ; - sprintf(s + strlen(s), "-client"); - *fsname = s; - - return 0; - } - - return -1; -} - -/* - * early liblustre init - * called from C startup in catamount apps, before main() - * - * The following is a skeleton sysio startup sequence, - * as implemented in C startup (skipping error handling). - * In this framework none of these calls need be made here - * or in the apps themselves. The NAMESPACE_STRING specifying - * the initial set of fs ops (creates, mounts, etc.) is passed - * as an environment variable. - * - * _sysio_init(); - * _sysio_incore_init(); - * _sysio_native_init(); - * _sysio_lustre_init(); - * _sysio_boot(NAMESPACE_STRING); - * - * the name _sysio_lustre_init() follows the naming convention - * established in other fs drivers from libsysio: - * _sysio_incore_init(), _sysio_native_init() - * - * _sysio_lustre_init() must be called before _sysio_boot() - * to enable libsysio's processing of namespace init strings containing - * lustre filesystem operations - */ -static int _sysio_lustre_init(void) -{ - int err; - char *envstr; -#ifndef INIT_SYSIO - extern void __liblustre_cleanup_(void); -#endif - - liblustre_init_random(); - - err = lllib_init(); - if (err) { - perror("init llite driver"); - return err; - } - - envstr = getenv("LIBLUSTRE_TIMEOUT"); - if (envstr != NULL) { - obd_timeout = (unsigned int)strtol(envstr, NULL, 0); - printf("LibLustre: obd timeout=%u seconds\n", - obd_timeout); - } - - /* debug peer on timeout? */ - envstr = getenv("LIBLUSTRE_DEBUG_PEER_ON_TIMEOUT"); - if (envstr != NULL) { - obd_debug_peer_on_timeout = - (unsigned int)strtol(envstr, NULL, 0); - printf("LibLustre: debug peer on timeout=%d\n", - obd_debug_peer_on_timeout ? 0 : 1); - } - -#ifndef INIT_SYSIO - (void)atexit(__liblustre_cleanup_); -#endif - return err; -} - -extern int _sysio_native_init(); - -static int mnt_retry = 0; - -char *lustre_path = NULL; - -void __liblustre_setup_(void) -{ - char *target = NULL; - char *lustre_driver = "lustre"; - unsigned mntflgs = 0; - int err, count; - - lustre_path = getenv("LIBLUSTRE_MOUNT_POINT"); - if (!lustre_path) { - lustre_path = "/mnt/lustre"; - } - - target = getenv("LIBLUSTRE_MOUNT_RETRY"); - if (target) { - mnt_retry = atoi(target); - if (mnt_retry < 0) - mnt_retry = 0; - } - - /* mount target */ - target = getenv("LIBLUSTRE_MOUNT_TARGET"); - if (!target) { - printf("LibLustre: no mount target specified\n"); - exit(1); - } - - CDEBUG(D_CONFIG, "LibLustre: mount point %s, target %s\n", - lustre_path, target); - -#ifdef INIT_SYSIO - /* initialize libsysio & mount rootfs */ - if (_sysio_init()) { - perror("init sysio"); - exit(1); - } - _sysio_native_init(); - - err = _sysio_mount_root("/", "native", mntflgs, NULL); - if (err) { - fprintf(stderr, "sysio mount failed: %s\n", strerror(errno)); - exit(1); - } - - if (_sysio_lustre_init()) - exit(1); -#endif /* INIT_SYSIO */ - - count = mnt_retry; - do { - err = mount(target, lustre_path, lustre_driver, mntflgs, NULL); - if (err && mnt_retry && (-- count)) { - fprintf(stderr, "Lustre mount failed: %s. " - "Will retry %d more times\n", - strerror(errno), mnt_retry - count ); - sleep(2); - } - } while (err && count > 0); - if (err) { - fprintf(stderr, "Lustre mount failed: %s\n", strerror(errno)); - exit(1); - } -} - -void __liblustre_cleanup_(void) -{ -#ifndef INIT_SYSIO - /* guard against being called multiple times */ - static int cleaned = 0; - - if (cleaned) - return; - cleaned++; -#endif - - /* user app might chdir to a lustre directory, and leave busy pnode - * during finaly libsysio cleanup. here we chdir back to "/". - * but it can't fix the situation that liblustre is mounted - * at "/". - */ - if (!chdir("/")) {} -#if 0 - umount(lustre_path); -#endif - /* we can't call umount here, because libsysio will not cleanup - * opening files for us. _sysio_shutdown() will cleanup fds at - * first but which will also close the sockets we need for umount - * liblutre. this dilema lead to another hack in - * libsysio/src/file_hack.c FIXME - */ -#ifdef INIT_SYSIO - _sysio_shutdown(); - cleanup_lib_portals(); - LNetFini(); -#endif -} diff --git a/lustre/liblustre/llite_lib.h b/lustre/liblustre/llite_lib.h deleted file mode 100644 index 090a06d..0000000 --- a/lustre/liblustre/llite_lib.h +++ /dev/null @@ -1,393 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * 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 version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2012, 2013, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - */ - -#ifndef __LLU_H_ -#define __LLU_H_ - -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef HAVE_XTIO_H -# include -#endif -#include -#include -#include -#ifdef HAVE_FILE_H -# include -#endif -#include -#include -#include -#include -#include - -enum cl_req_type; - -/* This should not be "optimized" use ~0ULL because page->index is a long and - * 32-bit systems are therefore limited to 16TB in a mapping */ -#define MAX_LFS_FILESIZE ((__u64)(~0UL) << PAGE_CACHE_SHIFT) -struct ll_file_data { - struct obd_client_handle fd_mds_och; - __u32 fd_flags; - struct ccc_grouplock fd_grouplock; -}; - -struct llu_sb_info { - struct obd_uuid ll_sb_uuid; - struct obd_export *ll_md_exp; - struct obd_export *ll_dt_exp; - struct lu_fid ll_root_fid; - struct lustre_client_ocd ll_lco; - cfs_list_t ll_conn_chain; - struct lu_site *ll_site; - struct cl_device *ll_cl; -}; - -enum lli_flags { - /* MDS has an authority for the Size-on-MDS attributes. */ - LLIF_MDS_SIZE_LOCK = (1 << 0), -}; - -struct llu_inode_info { - struct llu_sb_info *lli_sbi; - struct lu_fid lli_fid; - - char *lli_symlink_name; - __u64 lli_maxbytes; - unsigned long lli_flags; - __u64 lli_ioepoch; - - /* for libsysio */ - struct file_identifier lli_sysio_fid; - - struct lookup_intent *lli_it; - - /* XXX workaround for libsysio readdir */ - loff_t lli_dir_pos; - - /* in libsysio we have no chance to store data in file, - * so place it here. since it's possible that an file - * was opened several times without close, we track an - * open_count here */ - struct ll_file_data *lli_file_data; - /* checking lli_has_smd is reliable only inside an IO - * i.e, lov stripe has been held. */ - bool lli_has_smd; - int lli_open_flags; - int lli_open_count; - - /* not for stat, change it later */ - int lli_st_flags; - unsigned long lli_st_generation; - struct cl_object *lli_clob; - /* the most recent timestamps obtained from mds */ - struct ost_lvb lli_lvb; -}; - -static inline struct llu_sb_info *llu_fs2sbi(struct filesys *fs) -{ - return (struct llu_sb_info*)(fs->fs_private); -} - -static inline struct llu_inode_info *llu_i2info(struct inode *inode) -{ - return (struct llu_inode_info*)(inode->i_private); -} - -static inline int ll_inode_flags(struct inode *inode) -{ - return llu_i2info(inode)->lli_st_flags; -} - -static inline struct intnl_stat *llu_i2stat(struct inode *inode) -{ - return &inode->i_stbuf; -} - -#define ll_inode_blksize(inode) (llu_i2stat(inode)->st_blksize) - -static inline struct llu_sb_info *llu_i2sbi(struct inode *inode) -{ - return llu_i2info(inode)->lli_sbi; -} - -static inline struct obd_export *llu_i2obdexp(struct inode *inode) -{ - return llu_i2info(inode)->lli_sbi->ll_dt_exp; -} - -static inline struct obd_export *llu_i2mdexp(struct inode *inode) -{ - return llu_i2info(inode)->lli_sbi->ll_md_exp; -} - -static inline int llu_is_root_inode(struct inode *inode) -{ - return (fid_seq(&llu_i2info(inode)->lli_fid) == - fid_seq(&llu_i2info(inode)->lli_sbi->ll_root_fid) && - fid_oid(&llu_i2info(inode)->lli_fid) == - fid_oid(&llu_i2info(inode)->lli_sbi->ll_root_fid)); -} - -#define LL_SAVE_INTENT(inode, it) \ -do { \ - struct lookup_intent *temp; \ - LASSERT(llu_i2info(inode)->lli_it == NULL); \ - OBD_ALLOC(temp, sizeof(*temp)); \ - memcpy(temp, it, sizeof(*temp)); \ - llu_i2info(inode)->lli_it = temp; \ - CDEBUG(D_DENTRY, "alloc intent %p to inode %p(ino %llu)\n", \ - temp, inode, (long long)llu_i2stat(inode)->st_ino); \ -} while(0) - - -#define LL_GET_INTENT(inode, it) \ -do { \ - it = llu_i2info(inode)->lli_it; \ - \ - LASSERT(it); \ - llu_i2info(inode)->lli_it = NULL; \ - CDEBUG(D_DENTRY, "dettach intent %p from inode %p(ino %llu)\n", \ - it, inode, (long long)llu_i2stat(inode)->st_ino); \ -} while(0) - -static inline struct lu_fid *ll_inode2fid(struct inode *inode) -{ - LASSERT(inode != NULL); - return &llu_i2info(inode)->lli_fid; -} - -void ll_i2gids(__u32 *suppgids, struct inode *i1,struct inode *i2); - -static inline __u64 ll_file_maxbytes(struct inode *inode) -{ - return llu_i2info(inode)->lli_maxbytes; -} - -#define IS_BAD_PTR(ptr) \ - ((unsigned long)(ptr) == 0 || (unsigned long)(ptr) > -1000UL) - -/* llite_lib.c */ -int liblustre_process_log(struct config_llog_instance *cfg, char *mgsnid, - char *profile, int allow_recov); -int ll_parse_mount_target(const char *target, char **mgsnid, - char **fsname); -extern char *lustre_path; - -/* super.c */ -void llu_update_inode(struct inode *inode, struct lustre_md *md); -struct inode *llu_iget(struct filesys *fs, struct lustre_md *md); -int llu_inode_getattr(struct inode *inode, struct obdo *obdo, - __u64 ioepoch, int sync); -int llu_md_setattr(struct inode *inode, struct md_op_data *op_data, - struct md_open_data **mod); -int llu_setattr_raw(struct inode *inode, struct iattr *attr); -int llu_put_grouplock(struct inode *inode, unsigned long arg); - -extern struct fssw_ops llu_fssw_ops; - -/* file.c */ -void llu_prep_md_op_data(struct md_op_data *op_data, struct inode *i1, - struct inode *i2, const char *name, int namelen, - int mode, __u32 opc); -int llu_local_open(struct llu_inode_info *lli, struct lookup_intent *it); -int llu_iop_open(struct pnode *pnode, int flags, mode_t mode); -void llu_done_writing_attr(struct inode *inode, struct md_op_data *op_data); -int llu_md_close(struct obd_export *md_exp, struct inode *inode); -void llu_pack_inode2opdata(struct inode *inode, struct md_op_data *op_data, - struct lustre_handle *fh); -int llu_file_release(struct inode *inode); -int llu_som_update(struct inode *inode, struct md_op_data *op_data); -int llu_iop_close(struct inode *inode); -_SYSIO_OFF_T llu_iop_pos(struct inode *ino, _SYSIO_OFF_T off); -void obdo_refresh_inode(struct inode *dst, struct obdo *src, obd_flag valid); -int llu_objects_destroy(struct ptlrpc_request *request, struct inode *dir); -void llu_ioepoch_open(struct llu_inode_info *lli, __u64 ioepoch); - -/* rw.c */ -int llu_iop_read(struct inode *ino, struct ioctx *ioctxp); -int llu_iop_write(struct inode *ino, struct ioctx *ioctxp); -int llu_iop_iodone(struct ioctx *ioctxp); - -/* namei.c */ -int llu_iop_lookup(struct pnode *pnode, - struct inode **inop, - struct intent *intnt, - const char *path); -struct inode *llu_inode_from_resource_lock(struct ldlm_lock *lock); -int llu_md_blocking_ast(struct ldlm_lock *lock, - struct ldlm_lock_desc *desc, - void *data, int flag); - -/* dir.c */ -ssize_t llu_iop_filldirentries(struct inode *ino, _SYSIO_OFF_T *basep, - char *buf, size_t nbytes); - -/* ext2 related */ -#define EXT2_NAME_LEN (255) - -struct ext2_dirent { - __u32 inode; - __u16 rec_len; - __u8 name_len; - __u8 file_type; - char name[EXT2_NAME_LEN]; -}; - -static inline struct ext2_dirent *ext2_next_entry(struct ext2_dirent *p) -{ - return (struct ext2_dirent*)((char*) p + le16_to_cpu(p->rec_len)); -} - -int llu_merge_lvb(const struct lu_env *env, struct inode *inode); - -static inline void inode_init_lvb(struct inode *inode, struct ost_lvb *lvb) -{ - struct intnl_stat *st = llu_i2stat(inode); - lvb->lvb_size = st->st_size; - lvb->lvb_blocks = st->st_blocks; - lvb->lvb_mtime = st->st_mtime; - lvb->lvb_atime = st->st_atime; - lvb->lvb_ctime = st->st_ctime; -} - -struct llu_io_session { - struct inode *lis_inode; - int lis_cmd; - int lis_rc; - __u64 lis_rwcount; -}; - -struct llu_io_group -{ - int lig_rc; - __u64 lig_rwcount; -}; - -struct llu_io_session; -void put_io_group(struct llu_io_group *group); - -int cl_sb_init(struct llu_sb_info *sbi); -int cl_sb_fini(struct llu_sb_info *sbi); - -void llu_io_init(struct cl_io *io, struct inode *inode, int write); - -struct slp_io { - struct llu_io_session *sio_session; -}; - -struct slp_session { - struct slp_io ss_ios; -}; - -int slp_global_init(void); -void slp_global_fini(void); - -static inline struct slp_session *slp_env_session(const struct lu_env *env) -{ - extern struct lu_context_key slp_session_key; - struct slp_session *ses; - ses = lu_context_key_get(env->le_ses, &slp_session_key); - LASSERT(ses != NULL); - return ses; -} -static inline struct slp_io *slp_env_io(const struct lu_env *env) -{ - return &slp_env_session(env)->ss_ios; -} - -/* lclient compat stuff */ -#define cl_inode_info llu_inode_info -#define cl_i2info(info) llu_i2info(info) -#define cl_inode_mode(inode) (llu_i2stat(inode)->st_mode) -#define cl_i2sbi llu_i2sbi -#define cl_isize_read(inode) (llu_i2stat(inode)->st_size) -#define cl_isize_write(inode,kms) do{llu_i2stat(inode)->st_size = kms;}while(0) -#define cl_isize_write_nolock(inode,kms) cl_isize_write(inode,kms) - -static inline struct ll_file_data *cl_iattr2fd(struct inode *inode, - const struct iattr *attr) -{ - return llu_i2info(inode)->lli_file_data; -} - -static inline void cl_isize_lock(struct inode *inode) -{ -} - -static inline void cl_isize_unlock(struct inode *inode) -{ -} - -static inline int cl_merge_lvb(const struct lu_env *env, struct inode *inode) -{ - return llu_merge_lvb(env, inode); -} - -#define cl_inode_atime(inode) (llu_i2stat(inode)->st_atime) -#define cl_inode_ctime(inode) (llu_i2stat(inode)->st_ctime) -#define cl_inode_mtime(inode) (llu_i2stat(inode)->st_mtime) - -static inline struct obd_capa *cl_capa_lookup(struct inode *inode, - enum cl_req_type crt) -{ - return NULL; -} - -static inline void cl_stats_tally(struct cl_device *dev, enum cl_req_type crt, - int rc) -{ -} - -static inline loff_t i_size_read(struct inode *inode) -{ - return inode->i_stbuf.st_size; -} - -static inline __u64 hash_x_index(__u64 hash, int hash64) -{ - if (BITS_PER_LONG == 32 && hash64) - hash >>= 32; - /* save hash 0 with hash 1 */ - return ~0ULL - (hash + !hash); -} -#endif diff --git a/lustre/liblustre/lutil.c b/lustre/liblustre/lutil.c deleted file mode 100644 index ba1c35b..0000000 --- a/lustre/liblustre/lutil.c +++ /dev/null @@ -1,250 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * 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 version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2012, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "lutil.h" - -struct task_struct *current; - -/* - * random number generator stuff - */ - -#ifdef HAVE_GETHOSTBYNAME -static int get_ipv4_addr() -{ - struct utsname myname; - struct hostent *hptr; - int ip; - - if (uname(&myname) < 0) - return 0; - - hptr = gethostbyname(myname.nodename); - if (hptr == NULL || - hptr->h_addrtype != AF_INET || - *hptr->h_addr_list == NULL) { - CWARN("Warning: fail to get local IPv4 address\n"); - return 0; - } - - ip = ntohl(*((int *) *hptr->h_addr_list)); - - return ip; -} -#endif - -void liblustre_init_random() -{ - int seed[2]; - struct timeval tv; - -#ifdef LIBLUSTRE_USE_URANDOM - int _rand_dev_fd; - _rand_dev_fd = syscall(SYS_open, "/dev/urandom", O_RDONLY); - if (_rand_dev_fd >= 0) { - if (syscall(SYS_read, _rand_dev_fd, - &seed, sizeof(seed)) == sizeof(seed)) { - cfs_srand(seed[0], seed[1]); - syscall(SYS_close, _rand_dev_fd); - return; - } - syscall(SYS_close, _rand_dev_fd); - } -#endif /* LIBLUSTRE_USE_URANDOM */ - -#ifdef HAVE_GETHOSTBYNAME - seed[0] = get_ipv4_addr(); -#else - seed[0] = _my_pnid; -#endif - gettimeofday(&tv, NULL); - cfs_srand(tv.tv_sec ^ __swab32(seed[0]), tv.tv_usec ^__swab32(getpid())); -} - -static void init_capability(__u32 *res) -{ -#ifdef HAVE_LIBCAP - cap_t syscap; - cap_flag_value_t capval; - int i; - - *res = 0; - - syscap = cap_get_proc(); - if (!syscap) { - CWARN("Warning: failed to get system capability, " - "set to minimal\n"); - return; - } - - for (i = 0; i < sizeof(cap_value_t) * 8; i++) { - if (!cap_get_flag(syscap, i, CAP_EFFECTIVE, &capval)) { - if (capval == CAP_SET) { - *res |= 1 << i; - } - } - } -#else - /* - * set fake cap flags to ship to linux server - * from client platforms that have none (eg. catamount) - * full capability for root - * no capability for anybody else - */ -#define FAKE_ROOT_CAP 0x1ffffeff -#define FAKE_USER_CAP 0 - - *res = (current->fsuid == 0) ? FAKE_ROOT_CAP: FAKE_USER_CAP; -#endif -} - -int in_group_p(gid_t gid) -{ - int i; - - if (gid == current->fsgid) - return 1; - - for (i = 0; i < current->ngroups; i++) { - if (gid == current->groups[i]) - return 1; - } - - return 0; -} - -int liblustre_init_current(char *comm) -{ - current = malloc(sizeof(*current)); - if (!current) { - CERROR("Not enough memory\n"); - return -ENOMEM; - } - - strncpy(current->comm, comm, sizeof(current->comm)); - current->pid = getpid(); - current->gid = getgid(); - current->fsuid = geteuid(); - current->fsgid = getegid(); - - current->max_groups = sysconf(_SC_NGROUPS_MAX); - current->groups = malloc(sizeof(gid_t) * current->max_groups); - if (!current->groups) { - CERROR("Not enough memory\n"); - return -ENOMEM; - } - current->ngroups = getgroups(current->max_groups, current->groups); - if (current->ngroups < 0) { - perror("Error getgroups"); - return -EINVAL; - } - - init_capability(¤t->cap_effective); - - return 0; -} - -void cfs_cap_raise(cfs_cap_t cap) -{ - current->cap_effective |= (1 << cap); -} - -void cfs_cap_lower(cfs_cap_t cap) -{ - current->cap_effective &= ~(1 << cap); -} - -int cfs_cap_raised(cfs_cap_t cap) -{ - return current->cap_effective & (1 << cap); -} - -cfs_cap_t cfs_curproc_cap_pack(void) { - return current->cap_effective; -} - -void cfs_curproc_cap_unpack(cfs_cap_t cap) { - current->cap_effective = cap; -} - -int cfs_capable(cfs_cap_t cap) -{ - return cfs_cap_raised(cap); -} - -int init_lib_portals() -{ - int rc; - ENTRY; - - rc = libcfs_debug_init(5 * 1024 * 1024); - if (rc != 0) { - CERROR("libcfs_debug_init() failed: %d\n", rc); - RETURN (-ENXIO); - } - - rc = LNetInit(); - if (rc != 0) { - CERROR("LNetInit() failed: %d\n", rc); - RETURN (-ENXIO); - } - RETURN(0); -} - -extern void ptlrpc_exit_portals(void); -void cleanup_lib_portals() -{ - libcfs_debug_cleanup(); - ptlrpc_exit_portals(); -} diff --git a/lustre/liblustre/lutil.h b/lustre/liblustre/lutil.h deleted file mode 100644 index 45a79d3..0000000 --- a/lustre/liblustre/lutil.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * 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 version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - */ - -#ifndef __LUTIL_H_ -#define __LUTIL_H_ - -void liblustre_init_random(void); -int liblustre_init_current(char *comm); -int init_lib_portals(void); -void cleanup_lib_portals(void); - -#endif diff --git a/lustre/liblustre/namei.c b/lustre/liblustre/namei.c deleted file mode 100644 index c129f0b..0000000 --- a/lustre/liblustre/namei.c +++ /dev/null @@ -1,581 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * 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 version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2011, 2012, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * lustre/liblustre/namei.c - * - * Lustre Light name resolution - */ - -#define DEBUG_SUBSYSTEM S_LLITE - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "llite_lib.h" - -static void ll_intent_drop_lock(struct lookup_intent *it) -{ - struct lustre_handle *handle; - - if (it->it_op && it->d.lustre.it_lock_mode) { - handle = (struct lustre_handle *)&it->d.lustre.it_lock_handle; - CDEBUG(D_DLMTRACE, "releasing lock with cookie "LPX64 - " from it %p\n", handle->cookie, it); - ldlm_lock_decref(handle, it->d.lustre.it_lock_mode); - - /* bug 494: intent_release may be called multiple times, from - * this thread and we don't want to double-decref this lock */ - it->d.lustre.it_lock_mode = 0; - } -} - -static void ll_intent_release(struct lookup_intent *it) -{ - ENTRY; - - ll_intent_drop_lock(it); - it->it_magic = 0; - it->it_op_release = 0; - it->d.lustre.it_disposition = 0; - it->d.lustre.it_data = NULL; - EXIT; -} - -static void -llu_lookup_finish_locks(struct lookup_intent *it, struct pnode *pnode) -{ - struct inode *inode; - LASSERT(it); - LASSERT(pnode); - - inode = pnode->p_base->pb_ino; - if (it->d.lustre.it_lock_mode && inode != NULL) { - struct llu_sb_info *sbi; - - CDEBUG(D_DLMTRACE, "setting l_data to inode %p (%llu/%lu)\n", - inode, (long long)llu_i2stat(inode)->st_ino, - llu_i2info(inode)->lli_st_generation); - - sbi = llu_i2sbi(inode); - md_set_lock_data(sbi->ll_md_exp, - &it->d.lustre.it_lock_handle, inode, NULL); - } - - /* drop lookup/getattr locks */ - if (it->it_op & (IT_LOOKUP | IT_GETATTR)) - ll_intent_release(it); - -} - -static inline void llu_invalidate_inode_pages(struct inode * inode) -{ - /* do nothing */ -} - -int llu_md_blocking_ast(struct ldlm_lock *lock, - struct ldlm_lock_desc *desc, - void *data, int flag) -{ - struct lustre_handle lockh; - int rc; - ENTRY; - - - switch (flag) { - case LDLM_CB_BLOCKING: - ldlm_lock2handle(lock, &lockh); - rc = ldlm_cli_cancel(&lockh, 0); - if (rc < 0) { - CDEBUG(D_INODE, "ldlm_cli_cancel: %d\n", rc); - RETURN(rc); - } - break; - case LDLM_CB_CANCELING: { - struct inode *inode = llu_inode_from_resource_lock(lock); - struct llu_inode_info *lli; - struct intnl_stat *st; - __u64 bits = lock->l_policy_data.l_inodebits.bits; - struct lu_fid *fid; - - /* Inode is set to lock->l_resource->lr_lvb_inode - * for mdc - bug 24555 */ - LASSERT(lock->l_ast_data == NULL); - - /* Invalidate all dentries associated with this inode */ - if (inode == NULL) - break; - - lli = llu_i2info(inode); - st = llu_i2stat(inode); - - if (bits & MDS_INODELOCK_UPDATE) - lli->lli_flags &= ~LLIF_MDS_SIZE_LOCK; - - fid = &lli->lli_fid; - if (!fid_res_name_eq(fid, &lock->l_resource->lr_name)) - LDLM_ERROR(lock, "data mismatch with object " - DFID" (%p)", PFID(fid), inode); - if (S_ISDIR(st->st_mode) && - (bits & MDS_INODELOCK_UPDATE)) { - CDEBUG(D_INODE, "invalidating inode %llu\n", - (long long)st->st_ino); - - llu_invalidate_inode_pages(inode); - } - -/* - if (inode->i_sb->s_root && - inode != inode->i_sb->s_root->d_inode) - ll_unhash_aliases(inode); -*/ - I_RELE(inode); - break; - } - default: - LBUG(); - } - - RETURN(0); -} - -static int pnode_revalidate_finish(struct ptlrpc_request *req, - struct lookup_intent *it, - struct pnode *pnode) -{ - struct inode *inode = pnode->p_base->pb_ino; - struct lustre_md md; - int rc = 0; - ENTRY; - - LASSERT(inode); - - if (!req) - RETURN(0); - - if (it_disposition(it, DISP_LOOKUP_NEG)) - RETURN(-ENOENT); - - rc = md_get_lustre_md(llu_i2sbi(inode)->ll_md_exp, req, - llu_i2sbi(inode)->ll_dt_exp, - llu_i2sbi(inode)->ll_md_exp, &md); - if (rc) - RETURN(rc); - - llu_update_inode(inode, &md); - - RETURN(rc); -} - -static int llu_pb_revalidate(struct pnode *pnode, int flags, - struct lookup_intent *it) -{ - struct pnode_base *pb = pnode->p_base; - struct md_op_data op_data = {{ 0 }}; - struct ptlrpc_request *req = NULL; - struct lookup_intent lookup_it = { .it_op = IT_LOOKUP }; - struct obd_export *exp; - int rc; - ENTRY; - - CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,intent=%x\n", - (int)pb->pb_name.len, pb->pb_name.name, it ? it->it_op : 0); - - /* We don't want to cache negative dentries, so return 0 immediately. - * We believe that this is safe, that negative dentries cannot be - * pinned by someone else */ - if (pb->pb_ino == NULL) { - CDEBUG(D_INODE, "negative pb\n"); - RETURN(0); - } - - /* This is due to bad interaction with libsysio. remove this when we - * switched to libbsdio XXX - */ - { - struct llu_inode_info *lli = llu_i2info(pb->pb_ino); - struct intnl_stat *st = llu_i2stat(pb->pb_ino); - if (lli->lli_it) { - CDEBUG(D_INODE, "inode %llu still have intent " - "%p(opc 0x%x), release it\n", - (long long) st->st_ino, lli->lli_it, - lli->lli_it->it_op); - ll_intent_release(lli->lli_it); - OBD_FREE(lli->lli_it, sizeof(*lli->lli_it)); - lli->lli_it = NULL; - } - } - - exp = llu_i2mdexp(pb->pb_ino); - - if (!it) { - it = &lookup_it; - it->it_op_release = ll_intent_release; - } - - llu_prep_md_op_data(&op_data, pnode->p_parent->p_base->pb_ino, - pb->pb_ino, pb->pb_name.name, pb->pb_name.len, - 0, LUSTRE_OPC_ANY); - - rc = md_intent_lock(exp, &op_data, it, &req, &llu_md_blocking_ast, - LDLM_FL_CANCEL_ON_BLOCK); - /* If req is NULL, then md_intent_lock only tried to do a lock match; - * if all was well, it will return 1 if it found locks, 0 otherwise. */ - if (req == NULL && rc >= 0) - GOTO(out, rc); - - if (rc < 0) - GOTO(out, rc = 0); - - rc = pnode_revalidate_finish(req, it, pnode); - if (rc != 0) { - ll_intent_release(it); - GOTO(out, rc = 0); - } - rc = 1; - - /* Note: ll_intent_lock may cause a callback, check this! */ - - if (it->it_op & IT_OPEN) - LL_SAVE_INTENT(pb->pb_ino, it); - - out: - if (req && rc == 1) - ptlrpc_req_finished(req); - if (rc == 0) { - LASSERT(pb->pb_ino); - I_RELE(pb->pb_ino); - pb->pb_ino = NULL; - } else { - llu_lookup_finish_locks(it, pnode); - } - RETURN(rc); -} - -static int lookup_it_finish(struct ptlrpc_request *request, int offset, - struct lookup_intent *it, - struct inode *parent, struct pnode *child) -{ - struct llu_sb_info *sbi = llu_i2sbi(parent); - struct inode *inode = NULL; - int rc; - - /* libsysio require us generate inode right away if success. - * so if mds created new inode for us we need make sure it - * succeeded. thus for any error we can't delay to the - * llu_file_open() time. */ - if (it_disposition(it, DISP_OPEN_CREATE) && - it_open_error(DISP_OPEN_CREATE, it)) { - CDEBUG(D_INODE, "detect mds create error\n"); - return it_open_error(DISP_OPEN_CREATE, it); - } - if (it_disposition(it, DISP_OPEN_OPEN) && - it_open_error(DISP_OPEN_OPEN, it)) { - CDEBUG(D_INODE, "detect mds open error\n"); - /* undo which did by md_intent_lock */ - if (it_disposition(it, DISP_OPEN_CREATE) && - !it_open_error(DISP_OPEN_CREATE, it)) { - LASSERT(request); - LASSERT(atomic_read(&request->rq_refcount) > 1); - CDEBUG(D_INODE, "dec a ref of req %p\n", request); - ptlrpc_req_finished(request); - } - return it_open_error(DISP_OPEN_OPEN, it); - } - - /* NB 1 request reference will be taken away by ll_intent_lock() - * when I return - */ - if (!it_disposition(it, DISP_LOOKUP_NEG) || (it->it_op & IT_CREAT)) { - struct lustre_md md; - struct llu_inode_info *lli; - struct intnl_stat *st; - ENTRY; - - if (it_disposition(it, DISP_OPEN_CREATE)) - ptlrpc_req_finished(request); - - rc = md_get_lustre_md(sbi->ll_md_exp, request, - sbi->ll_dt_exp, sbi->ll_md_exp, &md); - if (rc) - RETURN(rc); - - inode = llu_iget(parent->i_fs, &md); - if (!inode || IS_ERR(inode)) { - /* free the lsm if we allocated one above */ - if (md.lsm != NULL) - obd_free_memmd(sbi->ll_dt_exp, &md.lsm); - RETURN(inode ? PTR_ERR(inode) : -ENOMEM); - } else if (md.lsm != NULL) { - obd_free_memmd(sbi->ll_dt_exp, &md.lsm); - } - - lli = llu_i2info(inode); - st = llu_i2stat(inode); - - /* If this is a stat, get the authoritative file size */ - if (it->it_op == IT_GETATTR && S_ISREG(st->st_mode) && - lli->lli_has_smd) { - ldlm_error_t rc; - - /* bug 2334: drop MDS lock before acquiring OST lock */ - ll_intent_drop_lock(it); - - rc = cl_glimpse_size(inode); - if (rc) { - I_RELE(inode); - RETURN(rc); - } - } - } else { - ENTRY; - } - - /* intent will be further used in cases of open()/getattr() */ - if (inode && (it->it_op & IT_OPEN)) - LL_SAVE_INTENT(inode, it); - - child->p_base->pb_ino = inode; - - RETURN(0); -} - -struct inode *llu_inode_from_resource_lock(struct ldlm_lock *lock) -{ - struct inode *inode; - lock_res_and_lock(lock); - - if (lock->l_resource->lr_lvb_inode) { - inode = (struct inode *)lock->l_resource->lr_lvb_inode; - I_REF(inode); - } else - inode = NULL; - - unlock_res_and_lock(lock); - return inode; -} - -static int llu_lookup_it(struct inode *parent, struct pnode *pnode, - struct lookup_intent *it, int flags) -{ - struct md_op_data op_data = {{ 0 }}; - struct ptlrpc_request *req = NULL; - struct lookup_intent lookup_it = { .it_op = IT_LOOKUP }; - __u32 opc; - int rc; - ENTRY; - - if (pnode->p_base->pb_name.len > EXT2_NAME_LEN) - RETURN(-ENAMETOOLONG); - - if (!it) { - it = &lookup_it; - it->it_op_release = ll_intent_release; - } - - if (it->it_op & IT_CREAT) - opc = LUSTRE_OPC_CREATE; - else - opc = LUSTRE_OPC_ANY; - - llu_prep_md_op_data(&op_data, parent, NULL, - pnode->p_base->pb_name.name, - pnode->p_base->pb_name.len, flags, opc); - - rc = md_intent_lock(llu_i2mdexp(parent), &op_data, it, &req, - &llu_md_blocking_ast, LDLM_FL_CANCEL_ON_BLOCK); - if (rc < 0) - GOTO(out, rc); - - rc = lookup_it_finish(req, DLM_REPLY_REC_OFF, it, parent, pnode); - if (rc != 0) { - ll_intent_release(it); - GOTO(out, rc); - } - - llu_lookup_finish_locks(it, pnode); - - out: - if (req) - ptlrpc_req_finished(req); - return rc; -} - -static struct lookup_intent* -translate_lookup_intent(struct intent *intent, const char *path) -{ - struct lookup_intent *it; - int fmode; - - /* libsysio trick */ - if (!intent || path) { - CDEBUG(D_VFSTRACE, "not intent needed\n"); - return NULL; - } - - OBD_ALLOC(it, sizeof(*it)); - LASSERT(it); - - memset(it, 0, sizeof(*it)); - - /* libsysio will assign intent like following: - * NOTE: INT_CREAT has include INT_UPDPARENT - * - * open: INT_OPEN [| INT_CREAT] - * mkdir: INT_CREAT - * symlink: INT_CREAT - * unlink: INT_UPDPARENT - * rmdir: INT_UPDPARENT - * mknod: INT_CREAT - * stat: INT_GETATTR - * setattr: NULL - * - * following logic is adjusted for libsysio - */ - - it->it_flags = intent->int_arg2 ? *((int*)intent->int_arg2) : 0; - - if (intent->int_opmask & INT_OPEN) { - it->it_op |= IT_OPEN; - - /* convert access mode from O_ to FMODE_ */ - if (it->it_flags & O_WRONLY) - fmode = FMODE_WRITE; - else if (it->it_flags & O_RDWR) - fmode = FMODE_READ | FMODE_WRITE; - else - fmode = FMODE_READ; - it->it_flags &= ~O_ACCMODE; - it->it_flags |= fmode; - } - - /* XXX libsysio has strange code on intent handling, - * more check later */ - if (it->it_flags & O_CREAT) { - it->it_op |= IT_CREAT; - it->it_create_mode = *((int*)intent->int_arg1); - /* bug 7278: libsysio hack. For O_EXCL, libsysio depends on - this lookup to return negative result, but then there is no - way to find out original intent in ll_iop_open(). So we just - clear O_EXCL from libsysio flags here to avoid checking - for negative result. O_EXCL will be enforced by MDS. */ - *((int*)intent->int_arg2) &= ~O_EXCL; - } - - if (intent->int_opmask & INT_GETATTR) - it->it_op |= IT_GETATTR; - - LASSERT(!(intent->int_opmask & INT_SETATTR)); - - /* libsysio is different to linux vfs when doing unlink/rmdir, - * INT_UPDPARENT was passed down during name resolution. Here - * we treat it as normal lookup, later unlink()/rmdir() will - * do the actual work */ - - /* conform to kernel code, if only IT_LOOKUP was set, don't - * pass down it */ - if (!it->it_op || it->it_op & IT_LOOKUP) { - OBD_FREE(it, sizeof(*it)); - it = NULL; - } - if (it) - it->it_op_release = ll_intent_release; - - CDEBUG(D_VFSTRACE, "final intent 0x%x\n", it ? it->it_op : 0); - return it; -} - -int llu_iop_lookup(struct pnode *pnode, - struct inode **inop, - struct intent *intnt, - const char *path) -{ - struct lookup_intent *it; - int rc; - ENTRY; - - liblustre_wait_event(0); - - *inop = NULL; - - /* the mount root inode have no name, so don't call - * remote in this case. but probably we need revalidate - * it here? FIXME */ - if (pnode->p_mount->mnt_root == pnode) { - struct inode *i = pnode->p_base->pb_ino; - *inop = i; - RETURN(0); - } - - if (!pnode->p_base->pb_name.len) - RETURN(-EINVAL); - - it = translate_lookup_intent(intnt, path); - - /* param flags is not used, let it be 0 */ - if (llu_pb_revalidate(pnode, 0, it)) { - LASSERT(pnode->p_base->pb_ino); - *inop = pnode->p_base->pb_ino; - GOTO(out, rc = 0); - } - - rc = llu_lookup_it(pnode->p_parent->p_base->pb_ino, pnode, it, 0); - if (!rc) { - if (!pnode->p_base->pb_ino) - rc = -ENOENT; - else - *inop = pnode->p_base->pb_ino; - } - -out: - if (it) - OBD_FREE(it, sizeof(*it)); - liblustre_wait_event(0); - RETURN(rc); -} diff --git a/lustre/liblustre/rw.c b/lustre/liblustre/rw.c deleted file mode 100644 index 6c175b6..0000000 --- a/lustre/liblustre/rw.c +++ /dev/null @@ -1,320 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * 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 version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2011, 2013, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * lustre/liblustre/rw.c - * - * Lustre Light block IO - */ - -#define DEBUG_SUBSYSTEM S_LLITE - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "llite_lib.h" - -int llu_merge_lvb(const struct lu_env *env, struct inode *inode) -{ - struct llu_inode_info *lli = llu_i2info(inode); - struct cl_object *obj = lli->lli_clob; - struct intnl_stat *st = llu_i2stat(inode); - struct cl_attr *attr = ccc_env_thread_attr(env); - struct ost_lvb lvb; - int rc; - ENTRY; - - /* merge timestamps the most recently obtained from mds with - timestamps obtained from osts */ - LTIME_S(inode->i_atime) = lli->lli_lvb.lvb_atime; - LTIME_S(inode->i_mtime) = lli->lli_lvb.lvb_mtime; - LTIME_S(inode->i_ctime) = lli->lli_lvb.lvb_ctime; - - inode_init_lvb(inode, &lvb); - - cl_object_attr_lock(obj); - rc = cl_object_attr_get(env, obj, attr); - cl_object_attr_unlock(obj); - if (rc == 0) { - if (lvb.lvb_atime < attr->cat_atime) - lvb.lvb_atime = attr->cat_atime; - if (lvb.lvb_ctime < attr->cat_ctime) - lvb.lvb_ctime = attr->cat_ctime; - if (lvb.lvb_mtime < attr->cat_mtime) - lvb.lvb_mtime = attr->cat_mtime; - - st->st_size = lvb.lvb_size; - st->st_blocks = lvb.lvb_blocks; - st->st_mtime = lvb.lvb_mtime; - st->st_atime = lvb.lvb_atime; - st->st_ctime = lvb.lvb_ctime; - } - - RETURN(rc); -} - -static -ssize_t llu_file_prwv(const struct iovec *iovec, int iovlen, - _SYSIO_OFF_T pos, ssize_t len, - void *private) -{ - struct llu_io_session *session = (struct llu_io_session *) private; - struct inode *inode = session->lis_inode; - struct llu_inode_info *lli = llu_i2info(inode); - int err; - struct lu_env *env; - struct cl_io *io; - struct slp_io *sio; - int refcheck; - ENTRY; - - /* in a large iov read/write we'll be repeatedly called. - * so give a chance to answer cancel ast here - */ - liblustre_wait_event(0); - - if (len == 0 || iovlen == 0) - RETURN(0); - - if (pos + len > lli->lli_maxbytes) - RETURN(-ERANGE); - - env = cl_env_get(&refcheck); - if (IS_ERR(env)) - RETURN(PTR_ERR(env)); - - /* Do NOT call "ccc_env_thread_io()" again to prevent reinitializing */ - io = &ccc_env_info(env)->cti_io; - if (cl_io_rw_init(env, io, session->lis_cmd == OBD_BRW_WRITE?CIT_WRITE: - CIT_READ, - pos, len) == 0) { - struct ccc_io *cio; - sio = slp_env_io(env); - cio = ccc_env_io(env); - /* XXX this is not right: cio->cui_iov can be modified. */ - cio->cui_iov = (struct iovec *)iovec; - cio->cui_nrsegs = iovlen; - cio->cui_tot_nrsegs = iovlen; - sio->sio_session = session; - err = cl_io_loop(env, io); - } else { - /* XXX WTF? */ - LBUG(); - } - cl_io_fini(env, io); - cl_env_put(env, &refcheck); - - if (err < 0) - RETURN(err); - - RETURN(len); -} - -static -struct llu_io_session *get_io_session(struct inode *ino, int ngroups, int cmd) -{ - struct llu_io_session *session; - - OBD_ALLOC_PTR(session); - if (!session) - return NULL; - - I_REF(ino); - session->lis_inode = ino; - session->lis_cmd = cmd; - return session; -} - -static void put_io_session(struct llu_io_session *session) -{ - I_RELE(session->lis_inode); - OBD_FREE_PTR(session); -} - -static int llu_file_rwx(struct inode *ino, - struct ioctx *ioctx, - int read) -{ - struct llu_io_session *session; - ssize_t cc; - int cmd = read ? OBD_BRW_READ : OBD_BRW_WRITE; - ENTRY; - - LASSERT(ioctx->ioctx_iovlen > 0); - - liblustre_wait_event(0); - - if (ioctx->ioctx_xtvlen == 0) - RETURN(0); - - /* XXX consider other types later */ - if (S_ISDIR(llu_i2stat(ino)->st_mode)) - RETURN(-EISDIR); - if (!S_ISREG(llu_i2stat(ino)->st_mode)) - RETURN(-EOPNOTSUPP); - - session = get_io_session(ino, ioctx->ioctx_xtvlen * 2, cmd); - if (!session) - RETURN(-ENOMEM); - - cc = _sysio_enumerate_extents(ioctx->ioctx_xtv, ioctx->ioctx_xtvlen, - ioctx->ioctx_iov, ioctx->ioctx_iovlen, - llu_file_prwv, session); - - if (cc >= 0) { - LASSERT(!ioctx->ioctx_cc); - ioctx->ioctx_private = session; - cc = 0; - } else { - put_io_session(session); - } - - liblustre_wait_event(0); - RETURN(cc); -} - -void llu_io_init(struct cl_io *io, struct inode *inode, int write) -{ - struct llu_inode_info *lli = llu_i2info(inode); - - io->u.ci_rw.crw_nonblock = lli->lli_open_flags & O_NONBLOCK; - if (write) - io->u.ci_wr.wr_append = lli->lli_open_flags & O_APPEND; - io->ci_obj = llu_i2info(inode)->lli_clob; - - if ((lli->lli_open_flags & O_APPEND) && write) - io->ci_lockreq = CILR_MANDATORY; - else - io->ci_lockreq = CILR_NEVER; -} - -int llu_iop_read(struct inode *ino, - struct ioctx *ioctx) -{ - struct intnl_stat *st = llu_i2stat(ino); - struct lu_env *env; - struct cl_io *io; - int refcheck; - int ret; - - /* BUG: 5972 */ - st->st_atime = CFS_CURRENT_TIME; - - env = cl_env_get(&refcheck); - if (IS_ERR(env)) - RETURN(PTR_ERR(env)); - - io = ccc_env_thread_io(env); - llu_io_init(io, ino, 0); - - ret = llu_file_rwx(ino, ioctx, 1); - - cl_env_put(env, &refcheck); - return ret; -} - -int llu_iop_write(struct inode *ino, - struct ioctx *ioctx) -{ - struct intnl_stat *st = llu_i2stat(ino); - struct lu_env *env; - struct cl_io *io; - int refcheck; - int ret; - - st->st_mtime = st->st_ctime = CFS_CURRENT_TIME; - - env = cl_env_get(&refcheck); - if (IS_ERR(env)) - RETURN(PTR_ERR(env)); - - io = ccc_env_thread_io(env); - llu_io_init(io, ino, 1); - - ret = llu_file_rwx(ino, ioctx, 0); - cl_env_put(env, &refcheck); - return ret; -} - -int llu_iop_iodone(struct ioctx *ioctx) -{ - struct llu_io_session *session; - struct lu_env *env; - struct cl_io *io; - int refcheck; - ENTRY; - - liblustre_wait_event(0); - - env = cl_env_get(&refcheck); - if (IS_ERR(env)) - RETURN(PTR_ERR(env)); - - io = &ccc_env_info(env)->cti_io; - cl_io_fini(env, io); - cl_env_put(env, &refcheck); - session = (struct llu_io_session *) ioctx->ioctx_private; - LASSERT(session); - LASSERT(!IS_ERR(session)); - - if (session->lis_rc == 0) { - ioctx->ioctx_cc = session->lis_rwcount; - } else { - LASSERT(session->lis_rc < 0); - ioctx->ioctx_cc = -1; - ioctx->ioctx_errno = -session->lis_rc; - } - - put_io_session(session); - ioctx->ioctx_private = NULL; - liblustre_wait_event(0); - - RETURN(1); -} diff --git a/lustre/liblustre/super.c b/lustre/liblustre/super.c deleted file mode 100644 index 9980b95..0000000 --- a/lustre/liblustre/super.c +++ /dev/null @@ -1,2059 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * 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 version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2011, 2013, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * lustre/liblustre/super.c - * - * Lustre Light Super operations - */ - -#define DEBUG_SUBSYSTEM S_LLITE - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "llite_lib.h" - -#ifndef MAY_EXEC -#define MAY_EXEC 1 -#define MAY_WRITE 2 -#define MAY_READ 4 -#endif - -#define S_IXUGO (S_IXUSR|S_IXGRP|S_IXOTH) - -static int ll_permission(struct inode *inode, int mask) -{ - struct intnl_stat *st = llu_i2stat(inode); - mode_t mode = st->st_mode; - - if (current->fsuid == st->st_uid) - mode >>= 6; - else if (in_group_p(st->st_gid)) - mode >>= 3; - - if ((mode & mask & (MAY_READ|MAY_WRITE|MAY_EXEC)) == mask) - return 0; - - if ((mask & (MAY_READ|MAY_WRITE)) || - (st->st_mode & S_IXUGO)) - if (cfs_capable(CFS_CAP_DAC_OVERRIDE)) - return 0; - - if (mask == MAY_READ || - (S_ISDIR(st->st_mode) && !(mask & MAY_WRITE))) { - if (cfs_capable(CFS_CAP_DAC_READ_SEARCH)) - return 0; - } - - return -EACCES; -} - -static void llu_fsop_gone(struct filesys *fs) -{ - struct llu_sb_info *sbi = (struct llu_sb_info *) fs->fs_private; - struct obd_device *obd = class_exp2obd(sbi->ll_md_exp); - int next = 0; - ENTRY; - - cfs_list_del(&sbi->ll_conn_chain); - cl_sb_fini(sbi); - obd_disconnect(sbi->ll_dt_exp); - obd_disconnect(sbi->ll_md_exp); - - while ((obd = class_devices_in_group(&sbi->ll_sb_uuid, &next)) != NULL) - class_manual_cleanup(obd); - - OBD_FREE(sbi, sizeof(*sbi)); - - liblustre_wait_idle(); - EXIT; -} - -static struct inode_ops llu_inode_ops; - -static ldlm_mode_t llu_take_md_lock(struct inode *inode, __u64 bits, - struct lustre_handle *lockh) -{ - ldlm_policy_data_t policy = { .l_inodebits = {bits}}; - struct lu_fid *fid; - ldlm_mode_t rc; - __u64 flags; - ENTRY; - - fid = &llu_i2info(inode)->lli_fid; - CDEBUG(D_INFO, "trying to match res "DFID"\n", PFID(fid)); - - flags = LDLM_FL_BLOCK_GRANTED | LDLM_FL_CBPENDING; - rc = md_lock_match(llu_i2mdexp(inode), flags, fid, LDLM_IBITS, &policy, - LCK_CR|LCK_CW|LCK_PR|LCK_PW, lockh); - RETURN(rc); -} - -void llu_update_inode(struct inode *inode, struct lustre_md *md) -{ - struct llu_inode_info *lli = llu_i2info(inode); - struct mdt_body *body = md->body; - struct lov_stripe_md *lsm = md->lsm; - struct intnl_stat *st = llu_i2stat(inode); - - LASSERT ((lsm != NULL) == ((body->valid & OBD_MD_FLEASIZE) != 0)); - - if (body->valid & OBD_MD_FLMODE) - st->st_mode = (st->st_mode & S_IFMT)|(body->mode & ~S_IFMT); - if (body->valid & OBD_MD_FLTYPE) - st->st_mode = (st->st_mode & ~S_IFMT)|(body->mode & S_IFMT); - - if (lsm != NULL) { - if (!lli->lli_has_smd) { - cl_file_inode_init(inode, md); - lli->lli_has_smd = true; - lli->lli_maxbytes = lsm->lsm_maxbytes; - if (lli->lli_maxbytes > MAX_LFS_FILESIZE) - lli->lli_maxbytes = MAX_LFS_FILESIZE; - } - if (md->lsm != NULL) - obd_free_memmd(llu_i2obdexp(inode), &md->lsm); - } - - if (body->valid & OBD_MD_FLATIME) { - if (body->atime > LTIME_S(st->st_atime)) - LTIME_S(st->st_atime) = body->atime; - lli->lli_lvb.lvb_atime = body->atime; - } - if (body->valid & OBD_MD_FLMTIME) { - if (body->mtime > LTIME_S(st->st_mtime)) - LTIME_S(st->st_mtime) = body->mtime; - lli->lli_lvb.lvb_mtime = body->mtime; - } - if (body->valid & OBD_MD_FLCTIME) { - if (body->ctime > LTIME_S(st->st_ctime)) - LTIME_S(st->st_ctime) = body->ctime; - lli->lli_lvb.lvb_ctime = body->ctime; - } - if (S_ISREG(st->st_mode)) - st->st_blksize = min(2UL * PTLRPC_MAX_BRW_SIZE, LL_MAX_BLKSIZE); - else - st->st_blksize = 4096; - if (body->valid & OBD_MD_FLUID) - st->st_uid = body->uid; - if (body->valid & OBD_MD_FLGID) - st->st_gid = body->gid; - if (body->valid & OBD_MD_FLNLINK) - st->st_nlink = body->nlink; - if (body->valid & OBD_MD_FLRDEV) - st->st_rdev = body->rdev; - if (body->valid & OBD_MD_FLFLAGS) - lli->lli_st_flags = body->flags; - if (body->valid & OBD_MD_FLSIZE) { - if ((llu_i2sbi(inode)->ll_lco.lco_flags & OBD_CONNECT_SOM) && - S_ISREG(st->st_mode) && lli->lli_has_smd) { - struct lustre_handle lockh; - ldlm_mode_t mode; - - /* As it is possible a blocking ast has been processed - * by this time, we need to check there is an UPDATE - * lock on the client and set LLIF_MDS_SIZE_LOCK holding - * it. */ - mode = llu_take_md_lock(inode, MDS_INODELOCK_UPDATE, - &lockh); - if (mode) { - st->st_size = body->size; - lli->lli_flags |= LLIF_MDS_SIZE_LOCK; - ldlm_lock_decref(&lockh, mode); - } - } else { - st->st_size = body->size; - } - - if (body->valid & OBD_MD_FLBLOCKS) - st->st_blocks = body->blocks; - } -} - -/** - * Performs the getattr on the inode and updates its fields. - * If @sync != 0, perform the getattr under the server-side lock. - */ -int llu_inode_getattr(struct inode *inode, struct obdo *obdo, - __u64 ioepoch, int sync) -{ - struct ptlrpc_request_set *set; - struct lov_stripe_md *lsm = NULL; - struct obd_info oinfo = { { { 0 } } }; - int rc; - ENTRY; - - lsm = ccc_inode_lsm_get(inode); - LASSERT(lsm); - - oinfo.oi_md = lsm; - oinfo.oi_oa = obdo; - oinfo.oi_oa->o_oi = lsm->lsm_oi; - oinfo.oi_oa->o_mode = S_IFREG; - oinfo.oi_oa->o_ioepoch = ioepoch; - oinfo.oi_oa->o_valid = OBD_MD_FLID | OBD_MD_FLTYPE | - OBD_MD_FLSIZE | OBD_MD_FLBLOCKS | - OBD_MD_FLBLKSZ | OBD_MD_FLMTIME | - OBD_MD_FLCTIME | OBD_MD_FLGROUP | - OBD_MD_FLATIME | OBD_MD_FLEPOCH; - obdo_set_parent_fid(oinfo.oi_oa, &llu_i2info(inode)->lli_fid); - if (sync) { - oinfo.oi_oa->o_valid |= OBD_MD_FLFLAGS; - oinfo.oi_oa->o_flags |= OBD_FL_SRVLOCK; - } - - set = ptlrpc_prep_set(); - if (set == NULL) { - CERROR ("ENOMEM allocing request set\n"); - rc = -ENOMEM; - } else { - rc = obd_getattr_async(llu_i2obdexp(inode), &oinfo, set); - if (rc == 0) - rc = ptlrpc_set_wait(set); - ptlrpc_set_destroy(set); - } - ccc_inode_lsm_put(inode, lsm); - if (rc) - RETURN(rc); - - oinfo.oi_oa->o_valid = OBD_MD_FLBLOCKS | OBD_MD_FLBLKSZ | - OBD_MD_FLMTIME | OBD_MD_FLCTIME | - OBD_MD_FLSIZE; - - obdo_refresh_inode(inode, oinfo.oi_oa, oinfo.oi_oa->o_valid); - CDEBUG(D_INODE, "objid "DOSTID" size %llu, blocks %llu, " - "blksize %llu\n", POSTID(&oinfo.oi_oa->o_oi), - (long long unsigned)llu_i2stat(inode)->st_size, - (long long unsigned)llu_i2stat(inode)->st_blocks, - (long long unsigned)llu_i2stat(inode)->st_blksize); - RETURN(0); -} - -static struct inode* llu_new_inode(struct filesys *fs, - struct lu_fid *fid) -{ - struct inode *inode; - struct llu_inode_info *lli; - struct intnl_stat st = { - .st_dev = 0, -#if 0 -#ifndef AUTOMOUNT_FILE_NAME - .st_mode = fid->f_type & S_IFMT, -#else - .st_mode = fid->f_type /* all of the bits! */ -#endif -#endif - /* FIXME: fix this later */ - .st_mode = 0, - - .st_uid = geteuid(), - .st_gid = getegid(), - }; - - OBD_ALLOC(lli, sizeof(*lli)); - if (!lli) - return NULL; - - /* initialize lli here */ - lli->lli_sbi = llu_fs2sbi(fs); - lli->lli_has_smd = false; - lli->lli_symlink_name = NULL; - lli->lli_flags = 0; - lli->lli_maxbytes = (__u64)(~0UL); - lli->lli_file_data = NULL; - - lli->lli_sysio_fid.fid_data = &lli->lli_fid; - lli->lli_sysio_fid.fid_len = sizeof(lli->lli_fid); - lli->lli_fid = *fid; - - /* file identifier is needed by functions like _sysio_i_find() */ - inode = _sysio_i_new(fs, &lli->lli_sysio_fid, - &st, 0, &llu_inode_ops, lli); - - if (!inode) - OBD_FREE(lli, sizeof(*lli)); - - return inode; -} - -static int llu_have_md_lock(struct inode *inode, __u64 lockpart) -{ - struct lustre_handle lockh; - ldlm_policy_data_t policy = { .l_inodebits = { lockpart } }; - struct lu_fid *fid; - __u64 flags; - ENTRY; - - LASSERT(inode); - - fid = &llu_i2info(inode)->lli_fid; - CDEBUG(D_INFO, "trying to match res "DFID"\n", PFID(fid)); - - flags = LDLM_FL_BLOCK_GRANTED | LDLM_FL_CBPENDING | LDLM_FL_TEST_LOCK; - if (md_lock_match(llu_i2mdexp(inode), flags, fid, LDLM_IBITS, &policy, - LCK_CR|LCK_CW|LCK_PR|LCK_PW, &lockh)) { - RETURN(1); - } - RETURN(0); -} - -static int llu_inode_revalidate(struct inode *inode) -{ - struct llu_inode_info *lli = llu_i2info(inode); - struct intnl_stat *st = llu_i2stat(inode); - ENTRY; - - if (!llu_have_md_lock(inode, MDS_INODELOCK_UPDATE)) { - struct lustre_md md; - struct ptlrpc_request *req = NULL; - struct llu_sb_info *sbi = llu_i2sbi(inode); - struct md_op_data op_data = { { 0 } }; - unsigned long valid = OBD_MD_FLGETATTR; - int rc, ealen = 0; - - /* Why don't we update all valid MDS fields here, if we're - * doing an RPC anyways? -phil */ - if (S_ISREG(st->st_mode)) { - ealen = obd_size_diskmd(sbi->ll_dt_exp, NULL); - valid |= OBD_MD_FLEASIZE; - } - - llu_prep_md_op_data(&op_data, inode, NULL, NULL, 0, ealen, - LUSTRE_OPC_ANY); - op_data.op_valid = valid; - - rc = md_getattr(sbi->ll_md_exp, &op_data, &req); - if (rc) { - CERROR("failure %d inode %llu\n", rc, - (long long)st->st_ino); - RETURN(-abs(rc)); - } - rc = md_get_lustre_md(sbi->ll_md_exp, req, - sbi->ll_dt_exp, sbi->ll_md_exp, &md); - - /* XXX Too paranoid? */ - if (((md.body->valid ^ valid) & OBD_MD_FLEASIZE) && - !((md.body->valid & OBD_MD_FLNLINK) && - (md.body->nlink == 0))) { - CERROR("Asked for %s eadata but got %s (%d)\n", - (valid & OBD_MD_FLEASIZE) ? "some" : "no", - (md.body->valid & OBD_MD_FLEASIZE) ? "some":"none", - md.body->eadatasize); - } - if (rc) { - ptlrpc_req_finished(req); - RETURN(rc); - } - - - llu_update_inode(inode, &md); - if (md.lsm != NULL) - obd_free_memmd(sbi->ll_dt_exp, &md.lsm); - ptlrpc_req_finished(req); - } - - if (!lli->lli_has_smd) { - /* object not yet allocated, don't validate size */ - st->st_atime = lli->lli_lvb.lvb_atime; - st->st_mtime = lli->lli_lvb.lvb_mtime; - st->st_ctime = lli->lli_lvb.lvb_ctime; - RETURN(0); - } - - /* ll_glimpse_size will prefer locally cached writes if they extend - * the file */ - RETURN(cl_glimpse_size(inode)); -} - -static void copy_stat_buf(struct inode *ino, struct intnl_stat *b) -{ - *b = *llu_i2stat(ino); -} - -static int llu_iop_getattr(struct pnode *pno, - struct inode *ino, - struct intnl_stat *b) -{ - int rc; - ENTRY; - - liblustre_wait_event(0); - - if (!ino) { - LASSERT(pno); - LASSERT(pno->p_base->pb_ino); - ino = pno->p_base->pb_ino; - } else { - LASSERT(!pno || pno->p_base->pb_ino == ino); - } - - /* libsysio might call us directly without intent lock, - * we must re-fetch the attrs here - */ - rc = llu_inode_revalidate(ino); - if (!rc) { - copy_stat_buf(ino, b); - LASSERT(!llu_i2info(ino)->lli_it); - } - - liblustre_wait_event(0); - RETURN(rc); -} - -static int null_if_equal(struct ldlm_lock *lock, void *data) -{ - if (data == lock->l_ast_data) { - lock->l_ast_data = NULL; - - if (lock->l_req_mode != lock->l_granted_mode) - LDLM_ERROR(lock,"clearing inode with ungranted lock\n"); - } - - return LDLM_ITER_CONTINUE; -} - -static void llu_clear_inode(struct inode *inode) -{ - struct llu_inode_info *lli = llu_i2info(inode); - struct llu_sb_info *sbi = llu_i2sbi(inode); - struct lov_stripe_md *lsm; - ENTRY; - - CDEBUG(D_VFSTRACE, "VFS Op:inode=%llu/%lu(%p)\n", - (long long)llu_i2stat(inode)->st_ino, lli->lli_st_generation, - inode); - - lli->lli_flags &= ~LLIF_MDS_SIZE_LOCK; - md_null_inode(sbi->ll_md_exp, ll_inode2fid(inode)); - - lsm = ccc_inode_lsm_get(inode); - if (lsm != NULL) - obd_change_cbdata(sbi->ll_dt_exp, lsm, null_if_equal, inode); - ccc_inode_lsm_put(inode, lsm); - - cl_inode_fini(inode); - lli->lli_has_smd = false; - - if (lli->lli_symlink_name) { - OBD_FREE(lli->lli_symlink_name, - strlen(lli->lli_symlink_name) + 1); - lli->lli_symlink_name = NULL; - } - - EXIT; -} - -static void llu_iop_gone(struct inode *inode) -{ - struct llu_inode_info *lli = llu_i2info(inode); - ENTRY; - - liblustre_wait_event(0); - llu_clear_inode(inode); - - OBD_FREE(lli, sizeof(*lli)); - EXIT; -} - -static int inode_setattr(struct inode * inode, struct iattr * attr) -{ - unsigned int ia_valid = attr->ia_valid; - struct intnl_stat *st = llu_i2stat(inode); - int error = 0; - - /* - * inode_setattr() is only ever invoked with ATTR_SIZE (by - * llu_setattr_raw()) when file has no bodies. Check this. - */ - LASSERT(ergo(ia_valid & ATTR_SIZE, !llu_i2info(inode)->lli_has_smd)); - - if (ia_valid & ATTR_SIZE) - st->st_size = attr->ia_size; - if (ia_valid & ATTR_UID) - st->st_uid = attr->ia_uid; - if (ia_valid & ATTR_GID) - st->st_gid = attr->ia_gid; - if (ia_valid & ATTR_ATIME) - st->st_atime = attr->ia_atime; - if (ia_valid & ATTR_MTIME) - st->st_mtime = attr->ia_mtime; - if (ia_valid & ATTR_CTIME) - st->st_ctime = attr->ia_ctime; - if (ia_valid & ATTR_MODE) { - st->st_mode = attr->ia_mode; - if (!in_group_p(st->st_gid) && - !cfs_capable(CFS_CAP_FSETID)) - st->st_mode &= ~S_ISGID; - } - /* mark_inode_dirty(inode); */ - return error; -} - -int llu_md_setattr(struct inode *inode, struct md_op_data *op_data, - struct md_open_data **mod) -{ - struct lustre_md md; - struct llu_sb_info *sbi = llu_i2sbi(inode); - struct ptlrpc_request *request = NULL; - int rc; - ENTRY; - - llu_prep_md_op_data(op_data, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY); - rc = md_setattr(sbi->ll_md_exp, op_data, NULL, 0, NULL, - 0, &request, mod); - - if (rc) { - ptlrpc_req_finished(request); - if (rc != -EPERM && rc != -EACCES) - CERROR("md_setattr fails: rc = %d\n", rc); - RETURN(rc); - } - - rc = md_get_lustre_md(sbi->ll_md_exp, request, - sbi->ll_dt_exp, sbi->ll_md_exp, &md); - if (rc) { - ptlrpc_req_finished(request); - RETURN(rc); - } - - /* We call inode_setattr to adjust timestamps. - * If there is at least some data in file, we cleared ATTR_SIZE - * above to avoid invoking vmtruncate, otherwise it is important - * to call vmtruncate in inode_setattr to update inode->i_size - * (bug 6196) */ - inode_setattr(inode, &op_data->op_attr); - llu_update_inode(inode, &md); - ptlrpc_req_finished(request); - - RETURN(rc); -} - -/* Close IO epoch and send Size-on-MDS attribute update. */ -static int llu_setattr_done_writing(struct inode *inode, - struct md_op_data *op_data, - struct md_open_data *mod) -{ - struct llu_inode_info *lli = llu_i2info(inode); - struct intnl_stat *st = llu_i2stat(inode); - int rc = 0; - ENTRY; - - LASSERT(op_data != NULL); - if (!S_ISREG(st->st_mode)) - RETURN(0); - - /* XXX: pass och here for the recovery purpose. */ - CDEBUG(D_INODE, "Epoch "LPU64" closed on "DFID" for truncate\n", - op_data->op_ioepoch, PFID(&lli->lli_fid)); - - op_data->op_flags = MF_EPOCH_CLOSE; - llu_done_writing_attr(inode, op_data); - llu_pack_inode2opdata(inode, op_data, NULL); - - rc = md_done_writing(llu_i2sbi(inode)->ll_md_exp, op_data, mod); - if (rc == -EAGAIN) { - /* MDS has instructed us to obtain Size-on-MDS attribute - * from OSTs and send setattr to back to MDS. */ - rc = llu_som_update(inode, op_data); - } else if (rc) { - CERROR("inode %llu mdc truncate failed: rc = %d\n", - (unsigned long long)st->st_ino, rc); - } - RETURN(rc); -} - -/* If this inode has objects allocated to it (lsm != NULL), then the OST - * object(s) determine the file size and mtime. Otherwise, the MDS will - * keep these values until such a time that objects are allocated for it. - * We do the MDS operations first, as it is checking permissions for us. - * We don't to the MDS RPC if there is nothing that we want to store there, - * otherwise there is no harm in updating mtime/atime on the MDS if we are - * going to do an RPC anyways. - * - * If we are doing a truncate, we will send the mtime and ctime updates - * to the OST with the punch RPC, otherwise we do an explicit setattr RPC. - * I don't believe it is possible to get e.g. ATTR_MTIME_SET and ATTR_SIZE - * at the same time. - */ -int llu_setattr_raw(struct inode *inode, struct iattr *attr) -{ - int has_lsm = llu_i2info(inode)->lli_has_smd; - struct intnl_stat *st = llu_i2stat(inode); - int ia_valid = attr->ia_valid; - struct md_op_data op_data = { { 0 } }; - struct md_open_data *mod = NULL; - int rc = 0, rc1 = 0; - ENTRY; - - CDEBUG(D_VFSTRACE, "VFS Op:inode=%llu\n", (long long)st->st_ino); - - if (ia_valid & ATTR_SIZE) { - if (attr->ia_size > ll_file_maxbytes(inode)) { - CDEBUG(D_INODE, "file too large %llu > "LPU64"\n", - (long long)attr->ia_size, - ll_file_maxbytes(inode)); - RETURN(-EFBIG); - } - - attr->ia_valid |= ATTR_MTIME | ATTR_CTIME; - } - - /* We mark all of the fields "set" so MDS/OST does not re-set them */ - if (attr->ia_valid & ATTR_CTIME) { - attr->ia_ctime = CFS_CURRENT_TIME; - attr->ia_valid |= ATTR_CTIME_SET; - } - if (!(ia_valid & ATTR_ATIME_SET) && (attr->ia_valid & ATTR_ATIME)) { - attr->ia_atime = CFS_CURRENT_TIME; - attr->ia_valid |= ATTR_ATIME_SET; - } - if (!(ia_valid & ATTR_MTIME_SET) && (attr->ia_valid & ATTR_MTIME)) { - attr->ia_mtime = CFS_CURRENT_TIME; - attr->ia_valid |= ATTR_MTIME_SET; - } - - if (attr->ia_valid & (ATTR_MTIME | ATTR_CTIME)) - CDEBUG(D_INODE, "setting mtime "CFS_TIME_T", ctime "CFS_TIME_T - ", now = "CFS_TIME_T"\n", - LTIME_S(attr->ia_mtime), LTIME_S(attr->ia_ctime), - LTIME_S(CFS_CURRENT_TIME)); - - /* NB: ATTR_SIZE will only be set after this point if the size - * resides on the MDS, ie, this file has no objects. */ - if (has_lsm) - attr->ia_valid &= ~ATTR_SIZE; - - /* If only OST attributes being set on objects, don't do MDS RPC. - * In that case, we need to check permissions and update the local - * inode ourselves so we can call obdo_from_inode() always. */ - if (ia_valid & (has_lsm ? ~(ATTR_FROM_OPEN | ATTR_RAW) : ~0)) { - memcpy(&op_data.op_attr, attr, sizeof(*attr)); - - /* Open epoch for truncate. */ - if (exp_connect_som(llu_i2mdexp(inode)) && - (ia_valid & ATTR_SIZE)) - op_data.op_flags = MF_EPOCH_OPEN; - rc = llu_md_setattr(inode, &op_data, &mod); - if (rc) - RETURN(rc); - - llu_ioepoch_open(llu_i2info(inode), op_data.op_ioepoch); - if (!has_lsm || !S_ISREG(st->st_mode)) { - CDEBUG(D_INODE, "no lsm: not setting attrs on OST\n"); - GOTO(out, rc); - } - } else { - /* The OST doesn't check permissions, but the alternative is - * a gratuitous RPC to the MDS. We already rely on the client - * to do read/write/truncate permission checks, so is mtime OK? - */ - if (ia_valid & (ATTR_MTIME | ATTR_ATIME)) { - /* from sys_utime() */ - if (!(ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET))) { - if (current->fsuid != st->st_uid && - (rc = ll_permission(inode, MAY_WRITE)) != 0) - RETURN(rc); - } else { - /* from inode_change_ok() */ - if (current->fsuid != st->st_uid && - !cfs_capable(CFS_CAP_FOWNER)) - RETURN(-EPERM); - } - } - - - /* Won't invoke llu_vmtruncate(), as we already cleared - * ATTR_SIZE */ - inode_setattr(inode, attr); - } - - if (ia_valid & ATTR_SIZE) - attr->ia_valid |= ATTR_SIZE; - if (ia_valid & (ATTR_SIZE | - ATTR_ATIME | ATTR_ATIME_SET | - ATTR_MTIME | ATTR_MTIME_SET)) - /* on truncate and utimes send attributes to osts, setting - * mtime/atime to past will be performed under PW 0:EOF extent - * lock (new_size:EOF for truncate) - * it may seem excessive to send mtime/atime updates to osts - * when not setting times to past, but it is necessary due to - * possible time de-synchronization */ - rc = cl_setattr_ost(inode, attr, NULL); - EXIT; -out: - if (op_data.op_ioepoch) - rc1 = llu_setattr_done_writing(inode, &op_data, mod); - return rc ? rc : rc1; -} - -/* here we simply act as a thin layer to glue it with - * llu_setattr_raw(), which is copy from kernel - */ -static int llu_iop_setattr(struct pnode *pno, - struct inode *ino, - unsigned mask, - struct intnl_stat *stbuf) -{ - struct iattr iattr; - int rc; - ENTRY; - - liblustre_wait_event(0); - - LASSERT(!(mask & ~(SETATTR_MTIME | SETATTR_ATIME | - SETATTR_UID | SETATTR_GID | - SETATTR_LEN | SETATTR_MODE))); - memset(&iattr, 0, sizeof(iattr)); - - if (mask & SETATTR_MODE) { - iattr.ia_mode = stbuf->st_mode; - iattr.ia_valid |= ATTR_MODE; - } - if (mask & SETATTR_MTIME) { - iattr.ia_mtime = stbuf->st_mtime; - iattr.ia_valid |= ATTR_MTIME | ATTR_MTIME_SET; - } - if (mask & SETATTR_ATIME) { - iattr.ia_atime = stbuf->st_atime; - iattr.ia_valid |= ATTR_ATIME | ATTR_ATIME_SET; - } - if (mask & SETATTR_UID) { - iattr.ia_uid = stbuf->st_uid; - iattr.ia_valid |= ATTR_UID; - } - if (mask & SETATTR_GID) { - iattr.ia_gid = stbuf->st_gid; - iattr.ia_valid |= ATTR_GID; - } - if (mask & SETATTR_LEN) { - iattr.ia_size = stbuf->st_size; /* XXX signed expansion problem */ - iattr.ia_valid |= ATTR_SIZE; - } - - iattr.ia_valid |= ATTR_RAW | ATTR_CTIME; - iattr.ia_ctime = CFS_CURRENT_TIME; - - rc = llu_setattr_raw(ino, &iattr); - liblustre_wait_idle(); - RETURN(rc); -} - -#define EXT2_LINK_MAX 32000 - -static int llu_iop_symlink_raw(struct pnode *pno, const char *tgt) -{ - struct inode *dir = pno->p_base->pb_parent->pb_ino; - struct qstr *qstr = &pno->p_base->pb_name; - const char *name = qstr->name; - int len = qstr->len; - struct ptlrpc_request *request = NULL; - struct llu_sb_info *sbi = llu_i2sbi(dir); - struct md_op_data op_data = {{ 0 }}; - int err = -EMLINK; - ENTRY; - - liblustre_wait_event(0); - if (llu_i2stat(dir)->st_nlink >= EXT2_LINK_MAX) - RETURN(err); - - llu_prep_md_op_data(&op_data, dir, NULL, name, len, 0, - LUSTRE_OPC_SYMLINK); - - err = md_create(sbi->ll_md_exp, &op_data, tgt, strlen(tgt) + 1, - S_IFLNK | S_IRWXUGO, current->fsuid, current->fsgid, - cfs_curproc_cap_pack(), 0, &request); - ptlrpc_req_finished(request); - liblustre_wait_event(0); - RETURN(err); -} - -static int llu_readlink_internal(struct inode *inode, - struct ptlrpc_request **request, - char **symname) -{ - struct llu_inode_info *lli = llu_i2info(inode); - struct llu_sb_info *sbi = llu_i2sbi(inode); - struct mdt_body *body; - struct intnl_stat *st = llu_i2stat(inode); - struct md_op_data op_data = {{ 0 }}; - int rc, symlen = st->st_size + 1; - ENTRY; - - *request = NULL; - *symname = NULL; - - if (lli->lli_symlink_name) { - *symname = lli->lli_symlink_name; - CDEBUG(D_INODE, "using cached symlink %s\n", *symname); - RETURN(0); - } - - llu_prep_md_op_data(&op_data, inode, NULL, NULL, 0, symlen, - LUSTRE_OPC_ANY); - op_data.op_valid = OBD_MD_LINKNAME; - - rc = md_getattr(sbi->ll_md_exp, &op_data, request); - if (rc) { - CERROR("inode %llu: rc = %d\n", (long long)st->st_ino, rc); - RETURN(rc); - } - - body = req_capsule_server_get(&(*request)->rq_pill, &RMF_MDT_BODY); - LASSERT(body != NULL); - - if ((body->valid & OBD_MD_LINKNAME) == 0) { - CERROR ("OBD_MD_LINKNAME not set on reply\n"); - GOTO (failed, rc = -EPROTO); - } - - LASSERT(symlen != 0); - if (body->eadatasize != symlen) { - CERROR("inode %llu: symlink length %d not expected %d\n", - (long long)st->st_ino, body->eadatasize - 1, symlen - 1); - GOTO(failed, rc = -EPROTO); - } - - *symname = req_capsule_server_get(&(*request)->rq_pill, &RMF_MDT_MD); - if (*symname == NULL || - strnlen(*symname, symlen) != symlen - 1) { - /* not full/NULL terminated */ - CERROR("inode %llu: symlink not NULL terminated string" - "of length %d\n", (long long)st->st_ino, symlen - 1); - GOTO(failed, rc = -EPROTO); - } - - OBD_ALLOC(lli->lli_symlink_name, symlen); - /* do not return an error if we cannot cache the symlink locally */ - if (lli->lli_symlink_name) - memcpy(lli->lli_symlink_name, *symname, symlen); - - RETURN(0); - - failed: - ptlrpc_req_finished (*request); - RETURN (-EPROTO); -} - -static int llu_iop_readlink(struct pnode *pno, char *data, size_t bufsize) -{ - struct inode *inode = pno->p_base->pb_ino; - struct ptlrpc_request *request; - char *symname; - int rc; - ENTRY; - - liblustre_wait_event(0); - rc = llu_readlink_internal(inode, &request, &symname); - if (rc) - GOTO(out, rc); - - LASSERT(symname); - strncpy(data, symname, bufsize); - rc = strlen(symname); - - ptlrpc_req_finished(request); - out: - liblustre_wait_event(0); - RETURN(rc); -} - -static int llu_iop_mknod_raw(struct pnode *pno, - mode_t mode, - dev_t dev) -{ - struct ptlrpc_request *request = NULL; - struct inode *dir = pno->p_parent->p_base->pb_ino; - struct llu_sb_info *sbi = llu_i2sbi(dir); - struct md_op_data op_data = {{ 0 }}; - int err = -EMLINK; - ENTRY; - - liblustre_wait_event(0); - CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%llu\n", - (int)pno->p_base->pb_name.len, pno->p_base->pb_name.name, - (long long)llu_i2stat(dir)->st_ino); - - if (llu_i2stat(dir)->st_nlink >= EXT2_LINK_MAX) - RETURN(err); - - switch (mode & S_IFMT) { - case 0: - case S_IFREG: - mode |= S_IFREG; /* for mode = 0 case, fallthrough */ - case S_IFCHR: - case S_IFBLK: - case S_IFIFO: - case S_IFSOCK: - llu_prep_md_op_data(&op_data, dir, NULL, - pno->p_base->pb_name.name, - pno->p_base->pb_name.len, 0, - LUSTRE_OPC_MKNOD); - - err = md_create(sbi->ll_md_exp, &op_data, NULL, 0, mode, - current->fsuid, current->fsgid, - cfs_curproc_cap_pack(), dev, &request); - ptlrpc_req_finished(request); - break; - case S_IFDIR: - err = -EPERM; - break; - default: - err = -EINVAL; - } - liblustre_wait_event(0); - RETURN(err); -} - -static int llu_iop_link_raw(struct pnode *old, struct pnode *new) -{ - struct inode *src = old->p_base->pb_ino; - struct inode *dir = new->p_parent->p_base->pb_ino; - const char *name = new->p_base->pb_name.name; - int namelen = new->p_base->pb_name.len; - struct ptlrpc_request *request = NULL; - struct md_op_data op_data = {{ 0 }}; - int rc; - ENTRY; - - LASSERT(src); - LASSERT(dir); - - liblustre_wait_event(0); - llu_prep_md_op_data(&op_data, src, dir, name, namelen, 0, - LUSTRE_OPC_ANY); - rc = md_link(llu_i2sbi(src)->ll_md_exp, &op_data, &request); - ptlrpc_req_finished(request); - liblustre_wait_event(0); - - RETURN(rc); -} - -/* - * libsysio will clear the inode immediately after return - */ -static int llu_iop_unlink_raw(struct pnode *pno) -{ - struct inode *dir = pno->p_base->pb_parent->pb_ino; - struct qstr *qstr = &pno->p_base->pb_name; - const char *name = qstr->name; - int len = qstr->len; - struct inode *target = pno->p_base->pb_ino; - struct ptlrpc_request *request = NULL; - struct md_op_data op_data = { { 0 } }; - int rc; - ENTRY; - - LASSERT(target); - - liblustre_wait_event(0); - llu_prep_md_op_data(&op_data, dir, NULL, name, len, 0, - LUSTRE_OPC_ANY); - rc = md_unlink(llu_i2sbi(dir)->ll_md_exp, &op_data, &request); - if (!rc) - rc = llu_objects_destroy(request, dir); - ptlrpc_req_finished(request); - liblustre_wait_idle(); - - RETURN(rc); -} - -static int llu_iop_rename_raw(struct pnode *old, struct pnode *new) -{ - struct inode *src = old->p_parent->p_base->pb_ino; - struct inode *tgt = new->p_parent->p_base->pb_ino; - const char *oldname = old->p_base->pb_name.name; - int oldnamelen = old->p_base->pb_name.len; - const char *newname = new->p_base->pb_name.name; - int newnamelen = new->p_base->pb_name.len; - struct ptlrpc_request *request = NULL; - struct md_op_data op_data = { { 0 } }; - int rc; - ENTRY; - - LASSERT(src); - LASSERT(tgt); - - liblustre_wait_event(0); - llu_prep_md_op_data(&op_data, src, tgt, NULL, 0, 0, - LUSTRE_OPC_ANY); - rc = md_rename(llu_i2sbi(src)->ll_md_exp, &op_data, - oldname, oldnamelen, newname, newnamelen, - &request); - if (!rc) { - rc = llu_objects_destroy(request, src); - } - - ptlrpc_req_finished(request); - liblustre_wait_idle(); - - RETURN(rc); -} - -#ifdef _HAVE_STATVFS -static int llu_statfs_internal(struct llu_sb_info *sbi, - struct obd_statfs *osfs, __u64 max_age) -{ - struct obd_statfs obd_osfs; - int rc; - ENTRY; - - rc = obd_statfs(NULL, sbi->ll_md_exp, osfs, max_age, 0); - if (rc) { - CERROR("md_statfs fails: rc = %d\n", rc); - RETURN(rc); - } - - CDEBUG(D_SUPER, "MDC blocks "LPU64"/"LPU64" objects "LPU64"/"LPU64"\n", - osfs->os_bavail, osfs->os_blocks, osfs->os_ffree,osfs->os_files); - - rc = obd_statfs_rqset(class_exp2obd(sbi->ll_dt_exp), - &obd_statfs, max_age, 0); - if (rc) { - CERROR("obd_statfs fails: rc = %d\n", rc); - RETURN(rc); - } - - CDEBUG(D_SUPER, "OSC blocks "LPU64"/"LPU64" objects "LPU64"/"LPU64"\n", - obd_osfs.os_bavail, obd_osfs.os_blocks, obd_osfs.os_ffree, - obd_osfs.os_files); - - osfs->os_blocks = obd_osfs.os_blocks; - osfs->os_bfree = obd_osfs.os_bfree; - osfs->os_bavail = obd_osfs.os_bavail; - - /* If we don't have as many objects free on the OST as inodes - * on the MDS, we reduce the total number of inodes to - * compensate, so that the "inodes in use" number is correct. - */ - if (obd_osfs.os_ffree < osfs->os_ffree) { - osfs->os_files = (osfs->os_files - osfs->os_ffree) + - obd_osfs.os_ffree; - osfs->os_ffree = obd_osfs.os_ffree; - } - - RETURN(rc); -} - -static int llu_statfs(struct llu_sb_info *sbi, struct statfs *sfs) -{ - struct obd_statfs osfs; - int rc; - - CDEBUG(D_VFSTRACE, "VFS Op:\n"); - - /* For now we will always get up-to-date statfs values, but in the - * future we may allow some amount of caching on the client (e.g. - * from QOS or lprocfs updates). */ - rc = llu_statfs_internal(sbi, &osfs, - cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS)); - if (rc) - return rc; - - statfs_unpack(sfs, &osfs); - - if (sizeof(sfs->f_blocks) == 4) { - while (osfs.os_blocks > ~0UL) { - sfs->f_bsize <<= 1; - - osfs.os_blocks >>= 1; - osfs.os_bfree >>= 1; - osfs.os_bavail >>= 1; - } - } - - sfs->f_blocks = osfs.os_blocks; - sfs->f_bfree = osfs.os_bfree; - sfs->f_bavail = osfs.os_bavail; - - return 0; -} - -static int llu_iop_statvfs(struct pnode *pno, - struct inode *ino, - struct intnl_statvfs *buf) -{ - struct statfs fs; - int rc; - ENTRY; - - liblustre_wait_event(0); - -#ifndef __CYGWIN__ - LASSERT(pno->p_base->pb_ino); - rc = llu_statfs(llu_i2sbi(pno->p_base->pb_ino), &fs); - if (rc) - RETURN(rc); - - /* from native driver */ - buf->f_bsize = fs.f_bsize; /* file system block size */ - buf->f_frsize = fs.f_bsize; /* file system fundamental block size */ - buf->f_blocks = fs.f_blocks; - buf->f_bfree = fs.f_bfree; - buf->f_bavail = fs.f_bavail; - buf->f_files = fs.f_files; /* Total number serial numbers */ - buf->f_ffree = fs.f_ffree; /* Number free serial numbers */ - buf->f_favail = fs.f_ffree; /* Number free ser num for non-privileged*/ - buf->f_fsid = fs.f_fsid.__val[1]; - buf->f_flag = 0; /* No equiv in statfs; maybe use type? */ - buf->f_namemax = fs.f_namelen; -#endif - - liblustre_wait_event(0); - RETURN(0); -} -#endif /* _HAVE_STATVFS */ - -static int llu_iop_mkdir_raw(struct pnode *pno, mode_t mode) -{ - struct inode *dir = pno->p_base->pb_parent->pb_ino; - struct qstr *qstr = &pno->p_base->pb_name; - const char *name = qstr->name; - int len = qstr->len; - struct ptlrpc_request *request = NULL; - struct intnl_stat *st = llu_i2stat(dir); - struct md_op_data op_data = {{ 0 }}; - int err = -EMLINK; - ENTRY; - - liblustre_wait_event(0); - CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%llu/%lu(%p)\n", len, name, - (long long)st->st_ino, llu_i2info(dir)->lli_st_generation, dir); - - if (st->st_nlink >= EXT2_LINK_MAX) - RETURN(err); - - llu_prep_md_op_data(&op_data, dir, NULL, name, len, 0, - LUSTRE_OPC_MKDIR); - - err = md_create(llu_i2sbi(dir)->ll_md_exp, &op_data, NULL, 0, - mode | S_IFDIR, current->fsuid, current->fsgid, - cfs_curproc_cap_pack(), 0, &request); - ptlrpc_req_finished(request); - liblustre_wait_event(0); - RETURN(err); -} - -static int llu_iop_rmdir_raw(struct pnode *pno) -{ - struct inode *dir = pno->p_base->pb_parent->pb_ino; - struct qstr *qstr = &pno->p_base->pb_name; - const char *name = qstr->name; - int len = qstr->len; - struct ptlrpc_request *request = NULL; - struct md_op_data op_data = {{ 0 }}; - int rc; - ENTRY; - - liblustre_wait_event(0); - CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%llu/%lu(%p)\n", len, name, - (long long)llu_i2stat(dir)->st_ino, - llu_i2info(dir)->lli_st_generation, dir); - - llu_prep_md_op_data(&op_data, dir, NULL, name, len, S_IFDIR, - LUSTRE_OPC_ANY); - rc = md_unlink(llu_i2sbi(dir)->ll_md_exp, &op_data, &request); - ptlrpc_req_finished(request); - - liblustre_wait_event(0); - RETURN(rc); -} - -#ifdef O_DIRECT -#define FCNTL_FLMASK (O_APPEND|O_NONBLOCK|O_ASYNC|O_DIRECT) -#else -#define FCNTL_FLMASK (O_APPEND|O_NONBLOCK|O_ASYNC) -#endif -#define FCNTL_FLMASK_INVALID (O_NONBLOCK|O_ASYNC) - -/* refer to ll_file_flock() for details */ -static int llu_file_flock(struct inode *ino, - int cmd, - struct file_lock *file_lock) -{ - struct llu_inode_info *lli = llu_i2info(ino); - struct ldlm_res_id res_id = - { .name = {fid_seq(&lli->lli_fid), - fid_oid(&lli->lli_fid), - fid_ver(&lli->lli_fid), - LDLM_FLOCK} }; - struct ldlm_enqueue_info einfo = { - .ei_type = LDLM_FLOCK, - .ei_mode = 0, - .ei_cb_cp = ldlm_flock_completion_ast, - .ei_cbdata = file_lock, - }; - struct intnl_stat *st = llu_i2stat(ino); - struct lustre_handle lockh = {0}; - ldlm_policy_data_t flock; - __u64 flags = 0; - int rc; - - CDEBUG(D_VFSTRACE, "VFS Op:inode=%llu file_lock=%p\n", - (unsigned long long)st->st_ino, file_lock); - - flock.l_flock.pid = file_lock->fl_pid; - flock.l_flock.start = file_lock->fl_start; - flock.l_flock.end = file_lock->fl_end; - - switch (file_lock->fl_type) { - case F_RDLCK: - einfo.ei_mode = LCK_PR; - break; - case F_UNLCK: - einfo.ei_mode = LCK_NL; - break; - case F_WRLCK: - einfo.ei_mode = LCK_PW; - break; - default: - CERROR("unknown fcntl lock type: %d\n", file_lock->fl_type); - LBUG(); - } - - switch (cmd) { - case F_SETLKW: -#ifdef F_SETLKW64 -#if F_SETLKW64 != F_SETLKW - case F_SETLKW64: -#endif -#endif - flags = 0; - break; - case F_SETLK: -#ifdef F_SETLK64 -#if F_SETLK64 != F_SETLK - case F_SETLK64: -#endif -#endif - flags = LDLM_FL_BLOCK_NOWAIT; - break; - case F_GETLK: -#ifdef F_GETLK64 -#if F_GETLK64 != F_GETLK - case F_GETLK64: -#endif -#endif - flags = LDLM_FL_TEST_LOCK; - file_lock->fl_type = einfo.ei_mode; - break; - default: - CERROR("unknown fcntl cmd: %d\n", cmd); - LBUG(); - } - - CDEBUG(D_DLMTRACE, "inode=%llu, pid=%u, cmd=%d, flags="LPX64", " - "mode=%u, start="LPX64", end="LPX64"\n", - (unsigned long long)st->st_ino, - flock.l_flock.pid, cmd, flags, einfo.ei_mode, - flock.l_flock.start, flock.l_flock.end); - { - struct lmv_obd *lmv; - struct obd_device *lmv_obd; - lmv_obd = class_exp2obd(llu_i2mdexp(ino)); - lmv = &lmv_obd->u.lmv; - - if (lmv->desc.ld_tgt_count < 1) - RETURN(rc = -ENODEV); - - if (lmv->tgts[0] != NULL && lmv->tgts[0]->ltd_exp != NULL) - rc = ldlm_cli_enqueue(lmv->tgts[0]->ltd_exp, NULL, - &einfo, &res_id, &flock, &flags, - NULL, 0, LVB_T_NONE, &lockh, 0); - else - rc = -ENODEV; - } - RETURN(rc); -} - -static int assign_type(struct file_lock *fl, int type) -{ - switch (type) { - case F_RDLCK: - case F_WRLCK: - case F_UNLCK: - fl->fl_type = type; - return 0; - default: - return -EINVAL; - } -} - -static int flock_to_posix_lock(struct inode *ino, - struct file_lock *fl, - struct flock *l) -{ - switch (l->l_whence) { - /* XXX: only SEEK_SET is supported in lustre */ - case SEEK_SET: - fl->fl_start = 0; - break; - default: - return -EINVAL; - } - - fl->fl_end = l->l_len - 1; - if (l->l_len < 0) - return -EINVAL; - if (l->l_len == 0) - fl->fl_end = OFFSET_MAX; - - fl->fl_pid = getpid(); - fl->fl_flags = FL_POSIX; - fl->fl_notify = NULL; - fl->fl_insert = NULL; - fl->fl_remove = NULL; - /* XXX: these fields can't be filled with suitable values, - but I think lustre doesn't use them. - */ - fl->fl_owner = NULL; - fl->fl_file = NULL; - - return assign_type(fl, l->l_type); -} - -static int llu_fcntl_getlk(struct inode *ino, struct flock *flock) -{ - struct file_lock fl; - int error; - - error = EINVAL; - if ((flock->l_type != F_RDLCK) && (flock->l_type != F_WRLCK)) - goto out; - - error = flock_to_posix_lock(ino, &fl, flock); - if (error) - goto out; - - error = llu_file_flock(ino, F_GETLK, &fl); - if (error) - goto out; - - flock->l_type = F_UNLCK; - if (fl.fl_type != F_UNLCK) { - flock->l_pid = fl.fl_pid; - flock->l_start = fl.fl_start; - flock->l_len = fl.fl_end == OFFSET_MAX ? 0: - fl.fl_end - fl.fl_start + 1; - flock->l_whence = SEEK_SET; - flock->l_type = fl.fl_type; - } - -out: - return error; -} - -static int llu_fcntl_setlk(struct inode *ino, int cmd, struct flock *flock) -{ - struct file_lock fl; - int flags = llu_i2info(ino)->lli_open_flags + 1; - int error; - - error = flock_to_posix_lock(ino, &fl, flock); - if (error) - goto out; - if (cmd == F_SETLKW) - fl.fl_flags |= FL_SLEEP; - - error = -EBADF; - switch (flock->l_type) { - case F_RDLCK: - if (!(flags & FMODE_READ)) - goto out; - break; - case F_WRLCK: - if (!(flags & FMODE_WRITE)) - goto out; - break; - case F_UNLCK: - break; - default: - error = -EINVAL; - goto out; - } - - error = llu_file_flock(ino, cmd, &fl); - if (error) - goto out; - -out: - return error; -} - -static int llu_iop_fcntl(struct inode *ino, int cmd, va_list ap, int *rtn) -{ - struct llu_inode_info *lli = llu_i2info(ino); - long flags; - struct flock *flock; - long err = 0; - - liblustre_wait_event(0); - switch (cmd) { - case F_GETFL: - *rtn = lli->lli_open_flags; - break; - case F_SETFL: - flags = va_arg(ap, long); - flags &= FCNTL_FLMASK; - if (flags & FCNTL_FLMASK_INVALID) { - LCONSOLE_ERROR_MSG(0x010, "liblustre does not support " - "the O_NONBLOCK or O_ASYNC flags. " - "Please fix your application.\n"); - *rtn = -EINVAL; - err = EINVAL; - break; - } - lli->lli_open_flags = (int)(flags & FCNTL_FLMASK) | - (lli->lli_open_flags & ~FCNTL_FLMASK); - *rtn = 0; - break; - case F_GETLK: -#ifdef F_GETLK64 -#if F_GETLK64 != F_GETLK - case F_GETLK64: -#endif -#endif - flock = va_arg(ap, struct flock *); - err = llu_fcntl_getlk(ino, flock); - *rtn = err? -1: 0; - break; - case F_SETLK: -#ifdef F_SETLKW64 -#if F_SETLKW64 != F_SETLKW - case F_SETLKW64: -#endif -#endif - case F_SETLKW: -#ifdef F_SETLK64 -#if F_SETLK64 != F_SETLK - case F_SETLK64: -#endif -#endif - flock = va_arg(ap, struct flock *); - err = llu_fcntl_setlk(ino, cmd, flock); - *rtn = err? -1: 0; - break; - default: - CERROR("unsupported fcntl cmd %x\n", cmd); - *rtn = -ENOSYS; - err = ENOSYS; - break; - } - - liblustre_wait_event(0); - return err; -} - -static int llu_get_grouplock(struct inode *inode, unsigned long arg) -{ - struct llu_inode_info *lli = llu_i2info(inode); - struct ll_file_data *fd = lli->lli_file_data; - int rc; - struct ccc_grouplock grouplock; - ENTRY; - - if (fd->fd_flags & LL_FILE_IGNORE_LOCK) { - RETURN(-ENOTSUPP); - } - if (fd->fd_flags & LL_FILE_GROUP_LOCKED) { - RETURN(-EINVAL); - } - LASSERT(fd->fd_grouplock.cg_lock == NULL); - - rc = cl_get_grouplock(cl_i2info(inode)->lli_clob, - arg, (lli->lli_open_flags & O_NONBLOCK), - &grouplock); - - if (rc) - RETURN(rc); - - fd->fd_flags |= LL_FILE_GROUP_LOCKED; - fd->fd_grouplock = grouplock; - - RETURN(0); -} - -int llu_put_grouplock(struct inode *inode, unsigned long arg) -{ - struct llu_inode_info *lli = llu_i2info(inode); - struct ll_file_data *fd = lli->lli_file_data; - struct ccc_grouplock grouplock; - ENTRY; - - if (!(fd->fd_flags & LL_FILE_GROUP_LOCKED)) - RETURN(-EINVAL); - - LASSERT(fd->fd_grouplock.cg_lock != NULL); - - if (fd->fd_grouplock.cg_gid != arg) - RETURN(-EINVAL); - - grouplock = fd->fd_grouplock; - memset(&fd->fd_grouplock, 0, sizeof(fd->fd_grouplock)); - fd->fd_flags &= ~LL_FILE_GROUP_LOCKED; - - cl_put_grouplock(&grouplock); - - RETURN(0); -} - -static int llu_lov_dir_setstripe(struct inode *ino, unsigned long arg) -{ - struct llu_sb_info *sbi = llu_i2sbi(ino); - struct ptlrpc_request *request = NULL; - struct md_op_data op_data = {{ 0 }}; - struct lov_user_md lum, *lump = (struct lov_user_md *)arg; - int rc = 0; - - llu_prep_md_op_data(&op_data, ino, NULL, NULL, 0, 0, - LUSTRE_OPC_ANY); - - LASSERT(sizeof(lum) == sizeof(*lump)); - LASSERT(sizeof(lum.lmm_objects[0]) == - sizeof(lump->lmm_objects[0])); - if (copy_from_user(&lum, lump, sizeof(lum))) - return(-EFAULT); - - switch (lum.lmm_magic) { - case LOV_USER_MAGIC_V1: { - if (lum.lmm_magic != cpu_to_le32(LOV_USER_MAGIC_V1)) - lustre_swab_lov_user_md_v1(&lum); - break; - } - case LOV_USER_MAGIC_V3: { - if (lum.lmm_magic != cpu_to_le32(LOV_USER_MAGIC_V3)) - lustre_swab_lov_user_md_v3((struct lov_user_md_v3 *)&lum); - break; - } - default: { - CDEBUG(D_IOCTL, "bad userland LOV MAGIC:" - " %#08x != %#08x nor %#08x\n", - lum.lmm_magic, LOV_USER_MAGIC_V1, - LOV_USER_MAGIC_V3); - RETURN(-EINVAL); - } - } - - /* swabbing is done in lov_setstripe() on server side */ - rc = md_setattr(sbi->ll_md_exp, &op_data, &lum, - sizeof(lum), NULL, 0, &request, NULL); - if (rc) { - ptlrpc_req_finished(request); - if (rc != -EPERM && rc != -EACCES) - CERROR("md_setattr fails: rc = %d\n", rc); - return rc; - } - ptlrpc_req_finished(request); - - return rc; -} - -static int llu_lov_setstripe_ea_info(struct inode *ino, int flags, - struct lov_user_md *lum, int lum_size) -{ - struct llu_sb_info *sbi = llu_i2sbi(ino); - struct llu_inode_info *lli = llu_i2info(ino); - struct lookup_intent oit = {.it_op = IT_OPEN, .it_flags = flags}; - struct ldlm_enqueue_info einfo = { - .ei_type = LDLM_IBITS, - .ei_mode = LCK_CR, - .ei_cb_bl = llu_md_blocking_ast, - .ei_cb_cp = ldlm_completion_ast, - }; - struct ptlrpc_request *req = NULL; - struct lustre_md md; - struct md_op_data data = {{ 0 }}; - struct lustre_handle lockh; - int rc = 0; - ENTRY; - - if (lli->lli_has_smd) { - CDEBUG(D_IOCTL, "stripe already exists for ino "DFID"\n", - PFID(&lli->lli_fid)); - return -EEXIST; - } - - llu_prep_md_op_data(&data, NULL, ino, NULL, 0, O_RDWR, - LUSTRE_OPC_ANY); - rc = md_enqueue(sbi->ll_md_exp, &einfo, NULL, &oit, &data, &lockh, - LDLM_FL_INTENT_ONLY); - if (rc) - GOTO(out, rc); - - req = oit.d.lustre.it_data; - rc = it_open_error(DISP_IT_EXECD, &oit); - if (rc) { - req->rq_replay = 0; - GOTO(out, rc); - } - - rc = it_open_error(DISP_OPEN_OPEN, &oit); - if (rc) { - req->rq_replay = 0; - GOTO(out, rc); - } - - rc = md_get_lustre_md(sbi->ll_md_exp, req, - sbi->ll_dt_exp, sbi->ll_md_exp, &md); - if (rc) - GOTO(out, rc); - - llu_update_inode(ino, &md); - llu_local_open(lli, &oit); - /* release intent */ - if (lustre_handle_is_used(&lockh)) - ldlm_lock_decref(&lockh, LCK_CR); - ptlrpc_req_finished(req); - req = NULL; - rc = llu_file_release(ino); - EXIT; - -out: - if (req != NULL) - ptlrpc_req_finished(req); - return rc; -} - -static int llu_lov_file_setstripe(struct inode *ino, unsigned long arg) -{ - struct lov_user_md lum, *lump = (struct lov_user_md *)arg; - int rc; - int flags = FMODE_WRITE; - ENTRY; - - LASSERT(sizeof(lum) == sizeof(*lump)); - LASSERT(sizeof(lum.lmm_objects[0]) == sizeof(lump->lmm_objects[0])); - if (copy_from_user(&lum, lump, sizeof(lum))) - RETURN(-EFAULT); - - rc = llu_lov_setstripe_ea_info(ino, flags, &lum, sizeof(lum)); - RETURN(rc); -} - -static int llu_lov_setstripe(struct inode *ino, unsigned long arg) -{ - struct intnl_stat *st = llu_i2stat(ino); - if (S_ISREG(st->st_mode)) - return llu_lov_file_setstripe(ino, arg); - if (S_ISDIR(st->st_mode)) - return llu_lov_dir_setstripe(ino, arg); - - return -EINVAL; -} - -static int llu_lov_getstripe(struct inode *ino, unsigned long arg) -{ - struct lov_stripe_md *lsm = NULL; - int rc = -ENODATA; - - lsm = ccc_inode_lsm_get(ino); - if (lsm != NULL) - rc = obd_iocontrol(LL_IOC_LOV_GETSTRIPE, llu_i2obdexp(ino), 0, lsm, - (void *)arg); - ccc_inode_lsm_put(ino, lsm); - return rc; -} - -static int llu_iop_ioctl(struct inode *ino, unsigned long int request, - va_list ap) -{ - unsigned long arg; - int rc; - - liblustre_wait_event(0); - - switch (request) { - case LL_IOC_GROUP_LOCK: - arg = va_arg(ap, unsigned long); - rc = llu_get_grouplock(ino, arg); - break; - case LL_IOC_GROUP_UNLOCK: - arg = va_arg(ap, unsigned long); - rc = llu_put_grouplock(ino, arg); - break; - case LL_IOC_LOV_SETSTRIPE: - arg = va_arg(ap, unsigned long); - rc = llu_lov_setstripe(ino, arg); - break; - case LL_IOC_LOV_GETSTRIPE: - arg = va_arg(ap, unsigned long); - rc = llu_lov_getstripe(ino, arg); - break; - default: - CERROR("did not support ioctl cmd %lx\n", request); - rc = -ENOSYS; - break; - } - - liblustre_wait_event(0); - return rc; -} - -/* - * we already do syncronous read/write - */ -static int llu_iop_sync(struct inode *inode) -{ - liblustre_wait_event(0); - return 0; -} - -static int llu_iop_datasync(struct inode *inode) -{ - liblustre_wait_event(0); - return 0; -} - -static struct filesys_ops llu_filesys_ops = { - .fsop_gone = llu_fsop_gone, -}; - -struct inode *llu_iget(struct filesys *fs, struct lustre_md *md) -{ - struct inode *inode; - struct lu_fid fid; - struct file_identifier fileid = {&fid, sizeof(fid)}; - - if ((md->body->valid & (OBD_MD_FLID | OBD_MD_FLTYPE)) != - (OBD_MD_FLID | OBD_MD_FLTYPE)) { - CERROR("bad md body valid mask "LPX64"\n", md->body->valid); - LBUG(); - return ERR_PTR(-EPERM); - } - - /* try to find existing inode */ - fid = md->body->fid1; - - inode = _sysio_i_find(fs, &fileid); - if (inode) { - if (inode->i_zombie/* || - lli->lli_st_generation != md->body->generation*/) { - I_RELE(inode); - } - else { - llu_update_inode(inode, md); - return inode; - } - } - - inode = llu_new_inode(fs, &fid); - if (inode) - llu_update_inode(inode, md); - - return inode; -} - -static int -llu_fsswop_mount(const char *source, - unsigned flags, - const void *data __IS_UNUSED, - struct pnode *tocover, - struct mount **mntp) -{ - struct filesys *fs; - struct inode *root; - struct pnode_base *rootpb; - struct obd_device *obd; - struct llu_sb_info *sbi; - struct obd_statfs osfs; - static struct qstr noname = { NULL, 0, 0 }; - struct ptlrpc_request *request = NULL; - struct lustre_md md; - class_uuid_t uuid; - struct config_llog_instance cfg = {0, }; - struct lustre_profile *lprof; - char *zconf_mgsnid, *zconf_profile; - char *osc = NULL, *mdc = NULL; - int async = 1, err = -EINVAL; - struct obd_connect_data ocd = {0,}; - struct md_op_data op_data = {{0}}; - /* %p for void* in printf needs 16+2 characters: 0xffffffffffffffff */ - const int instlen = sizeof(cfg.cfg_instance) * 2 + 2; - - ENTRY; - - if (ll_parse_mount_target(source, - &zconf_mgsnid, - &zconf_profile)) { - CERROR("mal-formed target %s\n", source); - RETURN(err); - } - if (!zconf_mgsnid || !zconf_profile) { - printf("Liblustre: invalid target %s\n", source); - RETURN(err); - } - /* allocate & initialize sbi */ - OBD_ALLOC(sbi, sizeof(*sbi)); - if (!sbi) - RETURN(-ENOMEM); - - CFS_INIT_LIST_HEAD(&sbi->ll_conn_chain); - ll_generate_random_uuid(uuid); - class_uuid_unparse(uuid, &sbi->ll_sb_uuid); - - /* generate a string unique to this super, let's try - the address of the super itself.*/ - cfg.cfg_instance = sbi; - - /* retrive & parse config log */ - cfg.cfg_uuid = sbi->ll_sb_uuid; - err = liblustre_process_log(&cfg, zconf_mgsnid, zconf_profile, 1); - if (err < 0) { - CERROR("Unable to process log: %s\n", zconf_profile); - GOTO(out_free, err); - } - - lprof = class_get_profile(zconf_profile); - if (lprof == NULL) { - CERROR("No profile found: %s\n", zconf_profile); - GOTO(out_free, err = -EINVAL); - } - OBD_ALLOC(osc, strlen(lprof->lp_dt) + instlen + 2); - sprintf(osc, "%s-%p", lprof->lp_dt, cfg.cfg_instance); - - OBD_ALLOC(mdc, strlen(lprof->lp_md) + instlen + 2); - sprintf(mdc, "%s-%p", lprof->lp_md, cfg.cfg_instance); - - if (!osc) { - CERROR("no osc\n"); - GOTO(out_free, err = -EINVAL); - } - if (!mdc) { - CERROR("no mdc\n"); - GOTO(out_free, err = -EINVAL); - } - - fs = _sysio_fs_new(&llu_filesys_ops, flags, sbi); - if (!fs) { - err = -ENOMEM; - goto out_free; - } - - obd = class_name2obd(mdc); - if (!obd) { - CERROR("MDC %s: not setup or attached\n", mdc); - GOTO(out_free, err = -EINVAL); - } - obd_set_info_async(NULL, obd->obd_self_export, sizeof(KEY_ASYNC), - KEY_ASYNC, sizeof(async), &async, NULL); - - ocd.ocd_connect_flags = OBD_CONNECT_IBITS | OBD_CONNECT_VERSION | - OBD_CONNECT_FID | OBD_CONNECT_AT | - OBD_CONNECT_VBR | OBD_CONNECT_FULL20 | - OBD_CONNECT_LVB_TYPE; - -#ifdef LIBLUSTRE_POSIX_ACL - ocd.ocd_connect_flags |= OBD_CONNECT_ACL; -#endif - ocd.ocd_ibits_known = MDS_INODELOCK_FULL; - ocd.ocd_version = LUSTRE_VERSION_CODE; - - /* setup mdc */ - err = obd_connect(NULL, &sbi->ll_md_exp, obd, &sbi->ll_sb_uuid, &ocd, NULL); - if (err) { - CERROR("cannot connect to %s: rc = %d\n", mdc, err); - GOTO(out_free, err); - } - - err = obd_statfs(NULL, sbi->ll_md_exp, &osfs, 100000000, 0); - if (err) - GOTO(out_md, err); - - /* - * FIXME fill fs stat data into sbi here!!! FIXME - */ - - /* setup osc */ - obd = class_name2obd(osc); - if (!obd) { - CERROR("OSC %s: not setup or attached\n", osc); - GOTO(out_md, err = -EINVAL); - } - obd_set_info_async(NULL, obd->obd_self_export, sizeof(KEY_ASYNC), - KEY_ASYNC, sizeof(async), &async, NULL); - - obd->obd_upcall.onu_owner = &sbi->ll_lco; - obd->obd_upcall.onu_upcall = cl_ocd_update; - - ocd.ocd_connect_flags = OBD_CONNECT_SRVLOCK | OBD_CONNECT_REQPORTAL | - OBD_CONNECT_VERSION | OBD_CONNECT_TRUNCLOCK | - OBD_CONNECT_FID | OBD_CONNECT_AT | - OBD_CONNECT_FULL20 | OBD_CONNECT_EINPROGRESS | - OBD_CONNECT_LVB_TYPE; - - ocd.ocd_version = LUSTRE_VERSION_CODE; - err = obd_connect(NULL, &sbi->ll_dt_exp, obd, &sbi->ll_sb_uuid, &ocd, NULL); - if (err) { - CERROR("cannot connect to %s: rc = %d\n", osc, err); - GOTO(out_md, err); - } - sbi->ll_lco.lco_flags = ocd.ocd_connect_flags; - sbi->ll_lco.lco_md_exp = sbi->ll_md_exp; - sbi->ll_lco.lco_dt_exp = sbi->ll_dt_exp; - - fid_zero(&sbi->ll_root_fid); - err = md_getstatus(sbi->ll_md_exp, &sbi->ll_root_fid, NULL); - if (err) { - CERROR("cannot mds_connect: rc = %d\n", err); - GOTO(out_lock_cn_cb, err); - } - if (!fid_is_sane(&sbi->ll_root_fid)) { - CERROR("Invalid root fid during mount\n"); - GOTO(out_lock_cn_cb, err = -EINVAL); - } - CDEBUG(D_SUPER, "rootfid "DFID"\n", PFID(&sbi->ll_root_fid)); - - op_data.op_fid1 = sbi->ll_root_fid; - op_data.op_valid = OBD_MD_FLGETATTR | OBD_MD_FLBLOCKS; - /* fetch attr of root inode */ - err = md_getattr(sbi->ll_md_exp, &op_data, &request); - if (err) { - CERROR("md_getattr failed for root: rc = %d\n", err); - GOTO(out_lock_cn_cb, err); - } - - err = md_get_lustre_md(sbi->ll_md_exp, request, - sbi->ll_dt_exp, sbi->ll_md_exp, &md); - if (err) { - CERROR("failed to understand root inode md: rc = %d\n",err); - GOTO(out_request, err); - } - - LASSERT(fid_is_sane(&sbi->ll_root_fid)); - - root = llu_iget(fs, &md); - if (!root || IS_ERR(root)) { - CERROR("fail to generate root inode\n"); - GOTO(out_request, err = -EBADF); - } - - /* - * Generate base path-node for root. - */ - rootpb = _sysio_pb_new(&noname, NULL, root); - if (!rootpb) { - err = -ENOMEM; - goto out_inode; - } - - err = _sysio_do_mount(fs, rootpb, flags, tocover, mntp); - if (err) { - _sysio_pb_gone(rootpb); - goto out_inode; - } - - cl_sb_init(sbi); - - ptlrpc_req_finished(request); - - CDEBUG(D_SUPER, "LibLustre: %s mounted successfully!\n", source); - err = 0; - goto out_free; - -out_inode: - _sysio_i_gone(root); -out_request: - ptlrpc_req_finished(request); -out_lock_cn_cb: - obd_disconnect(sbi->ll_dt_exp); -out_md: - obd_disconnect(sbi->ll_md_exp); -out_free: - if (osc) - OBD_FREE(osc, strlen(lprof->lp_dt) + instlen + 2); - if (mdc) - OBD_FREE(mdc, strlen(lprof->lp_md) + instlen + 2); - if (err != 0) - OBD_FREE(sbi, sizeof(*sbi)); - liblustre_wait_idle(); - return err; -} - -struct fssw_ops llu_fssw_ops = { - .fsswop_mount = llu_fsswop_mount, -}; - -static struct inode_ops llu_inode_ops = { - .inop_lookup = llu_iop_lookup, - .inop_getattr = llu_iop_getattr, - .inop_setattr = llu_iop_setattr, - .inop_filldirentries = llu_iop_filldirentries, - .inop_mkdir = llu_iop_mkdir_raw, - .inop_rmdir = llu_iop_rmdir_raw, - .inop_symlink = llu_iop_symlink_raw, - .inop_readlink = llu_iop_readlink, - .inop_open = llu_iop_open, - .inop_close = llu_iop_close, - .inop_link = llu_iop_link_raw, - .inop_unlink = llu_iop_unlink_raw, - .inop_rename = llu_iop_rename_raw, - .inop_pos = llu_iop_pos, - .inop_read = llu_iop_read, - .inop_write = llu_iop_write, - .inop_iodone = llu_iop_iodone, - .inop_fcntl = llu_iop_fcntl, - .inop_sync = llu_iop_sync, - .inop_datasync = llu_iop_datasync, - .inop_ioctl = llu_iop_ioctl, - .inop_mknod = llu_iop_mknod_raw, -#ifdef _HAVE_STATVFS - .inop_statvfs = llu_iop_statvfs, -#endif - .inop_gone = llu_iop_gone, -}; diff --git a/lustre/liblustre/tests/.gitignore b/lustre/liblustre/tests/.gitignore deleted file mode 100644 index 3214fcb..0000000 --- a/lustre/liblustre/tests/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/Makefile.in -/echo_test -/recovery_small -/replay_ost_single -/replay_single -/sanity diff --git a/lustre/liblustre/tests/Makefile.am b/lustre/liblustre/tests/Makefile.am deleted file mode 100644 index c6c7e27..0000000 --- a/lustre/liblustre/tests/Makefile.am +++ /dev/null @@ -1,50 +0,0 @@ -## Liblustre excecutables & libraries Makefile - -AM_CPPFLAGS = -I$(SYSIO)/include -I/opt/lam/include $(LLCPPFLAGS) -I$(top_srcdir)/lnet/ulnds -AM_CFLAGS = $(LLCFLAGS) -AM_LIBS = $(LIBEFENCE) $(LIBREADLINE) - -LLIB_EXEC = $(top_builddir)/lustre/utils/liblustreapi.a $(top_builddir)/lustre/liblustre/liblustre.a $(CAP_LIBS) $(PTHREAD_LIBS) - -if LIBLUSTRE -noinst_LIBRARIES = libtestcommon.a - -if LIBLUSTRE_TESTS -if MPITESTS -SUBDIRS = mpi -endif # MPITESTS - -noinst_PROGRAMS = sanity - -noinst_PROGRAMS += recovery_small replay_single replay_ost_single - -liblustre_testdir=$(libdir)/lustre/liblustre/tests -liblustre_test_PROGRAMS = $(noinst_PROGRAMS) -liblustre_test_LIBRARIES = $(noinst_LIBRARIES) - -endif # LIBLUSTRE_TESTS -endif # LIBLUSTRE - -DIST_SUBDIRS = mpi - -libtestcommon_a_SOURCES = test_common.c test_common.h - -sanity_SOURCES = sanity.c -sanity_CFLAGS = $(LL_CFLAGS) -sanity_LDADD := libtestcommon.a $(LLIB_EXEC) -sanity_DEPENDENCIES = $(top_builddir)/lustre/liblustre/liblustre.a libtestcommon.a - -recovery_small_SOURCES = recovery_small.c -recovery_small_CFLAGS = $(LL_CFLAGS) -recovery_small_LDADD := libtestcommon.a $(LLIB_EXEC) -recovery_small_DEPENDENCIES = $(top_builddir)/lustre/liblustre/liblustre.a libtestcommon.a - -replay_single_SOURCES = replay_single.c -replay_single_CFLAGS = $(LL_CFLAGS) -replay_single_LDADD := libtestcommon.a $(LLIB_EXEC) -replay_single_DEPENDENCIES = $(top_builddir)/lustre/liblustre/liblustre.a libtestcommon.a - -replay_ost_single_SOURCES = replay_ost_single.c -replay_ost_single_CFLAGS = $(LL_CFLAGS) -replay_ost_single_LDADD := libtestcommon.a $(LLIB_EXEC) -replay_ost_single_DEPENDENCIES = $(top_builddir)/lustre/liblustre/liblustre.a libtestcommon.a diff --git a/lustre/liblustre/tests/echo_test.c b/lustre/liblustre/tests/echo_test.c deleted file mode 100644 index b2fab3c..0000000 --- a/lustre/liblustre/tests/echo_test.c +++ /dev/null @@ -1,299 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * 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 version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * lustre/liblustre/tests/echo_test.c - * - * Lustre Light user test program - */ - -#include -#include -#include - -#define LIBLUSTRE_TEST 1 -#include "../utils/lctl.c" - -#include "../lutil.h" - -extern int class_handle_ioctl(unsigned int cmd, unsigned long arg); - -static int liblustre_ioctl(int dev_id, unsigned int opc, void *ptr) -{ - int rc = -EINVAL; - - switch (dev_id) { - default: - fprintf(stderr, "Unexpected device id %d\n", dev_id); - abort(); - break; - - case OBD_DEV_ID: - rc = class_handle_ioctl(opc, (unsigned long)ptr); - break; - } - - return rc; -} - -static char *echo_server_nid = NULL; -static char *echo_server_ostname = "obd1"; -static char *osc_dev_name = "OSC_DEV_NAME"; -static char *echo_dev_name = "ECHO_CLIENT_DEV_NAME"; - -static int connect_echo_client(void) -{ - struct lustre_cfg *lcfg; - struct lustre_cfg_bufs bufs; - lnet_nid_t nid; - char *peer = "ECHO_PEER_NID"; - class_uuid_t osc_uuid, echo_uuid; - struct obd_uuid osc_uuid_str, echo_uuid_str; - int err; - ENTRY; - - ll_generate_random_uuid(osc_uuid); - class_uuid_unparse(osc_uuid, &osc_uuid_str); - ll_generate_random_uuid(echo_uuid); - class_uuid_unparse(echo_uuid, &echo_uuid_str); - - nid = libcfs_str2nid(echo_server_nid); - if (nid == LNET_NID_ANY) { - CERROR("Can't parse NID %s\n", echo_server_nid); - RETURN(-EINVAL); - } - - /* add uuid */ - lustre_cfg_bufs_reset(&bufs, NULL); - lustre_cfg_bufs_set_string(&bufs, 1, peer); - lcfg = lustre_cfg_new(LCFG_ADD_UUID, &bufs); - lcfg->lcfg_nid = nid; - err = class_process_config(lcfg); - lustre_cfg_free(lcfg); - if (err < 0) { - CERROR("failed add_uuid\n"); - RETURN(-EINVAL); - } - - /* attach osc */ - lustre_cfg_bufs_reset(&bufs, osc_dev_name); - lustre_cfg_bufs_set_string(&bufs, 1, LUSTRE_OSC_NAME); - lustre_cfg_bufs_set_string(&bufs, 2, osc_uuid_str.uuid); - lcfg = lustre_cfg_new(LCFG_ATTACH, &bufs); - err = class_process_config(lcfg); - lustre_cfg_free(lcfg); - if (err < 0) { - CERROR("failed attach osc\n"); - RETURN(-EINVAL); - } - - /* setup osc */ - lustre_cfg_bufs_reset(&bufs, osc_dev_name); - lustre_cfg_bufs_set_string(&bufs, 1, echo_server_ostname); - lustre_cfg_bufs_set_string(&bufs, 2, peer); - lcfg = lustre_cfg_new(LCFG_SETUP, &bufs); - err = class_process_config(lcfg); - lustre_cfg_free(lcfg); - if (err < 0) { - CERROR("failed setup osc\n"); - RETURN(-EINVAL); - } - - /* attach echo_client */ - lustre_cfg_bufs_reset(&bufs, echo_dev_name); - lustre_cfg_bufs_set_string(&bufs, 1, "echo_client"); - lustre_cfg_bufs_set_string(&bufs, 2, echo_uuid_str.uuid); - lcfg = lustre_cfg_new(LCFG_ATTACH, &bufs); - err = class_process_config(lcfg); - lustre_cfg_free(lcfg); - if (err < 0) { - CERROR("failed attach echo_client\n"); - RETURN(-EINVAL); - } - - /* setup echo_client */ - lustre_cfg_bufs_reset(&bufs, echo_dev_name); - lustre_cfg_bufs_set_string(&bufs, 1, osc_dev_name); - lustre_cfg_bufs_set_string(&bufs, 2, NULL); - lcfg = lustre_cfg_new(LCFG_SETUP, &bufs); - err = class_process_config(lcfg); - lustre_cfg_free(lcfg); - if (err < 0) { - CERROR("failed setup echo_client\n"); - RETURN(-EINVAL); - } - - RETURN(0); -} - -static int disconnect_echo_client(void) -{ - struct lustre_cfg_bufs bufs; - struct lustre_cfg *lcfg = NULL; - int err; - ENTRY; - - /* cleanup echo_client */ - lustre_cfg_bufs_reset(&bufs, echo_dev_name); - lcfg = lustre_cfg_new(LCFG_CLEANUP, &bufs); - err = class_process_config(lcfg); - if (err < 0) { - lustre_cfg_free(lcfg); - CERROR("failed cleanup echo_client\n"); - RETURN(-EINVAL); - } - - /* detach echo_client */ - lcfg->lcfg_command = LCFG_DETACH; - err = class_process_config(lcfg); - lustre_cfg_free(lcfg); - if (err < 0) { - CERROR("failed detach echo_client\n"); - RETURN(-EINVAL); - } - - /* cleanup osc */ - lustre_cfg_bufs_reset(&bufs, osc_dev_name); - lcfg = lustre_cfg_new(LCFG_CLEANUP, &bufs); - err = class_process_config(lcfg); - if (err < 0) { - lustre_cfg_free(lcfg); - CERROR("failed cleanup osc device\n"); - RETURN(-EINVAL); - } - - /* detach osc */ - lcfg->lcfg_command = LCFG_DETACH; - err = class_process_config(lcfg); - lustre_cfg_free(lcfg); - if (err < 0) { - CERROR("failed detach osc device\n"); - RETURN(-EINVAL); - } - - RETURN(0); -} - -static void usage(const char *s) -{ - printf("Usage: %s -s ost_host_name [-n ost_name] [-x lctl_options ...]\n", s); - printf(" ost_host_name: the host name of echo server\n"); - printf(" ost_name: ost name, default is \"obd1\"\n"); - printf(" lctl_options: options to pass to lctl.\n"); - printf(" (e.g. -x --device 1 test_getattr 10000 -5)\n"); -} - -extern int time_ptlwait1; -extern int time_ptlwait2; -extern int time_ptlselect; - -int main(int argc, char **argv) -{ - int c, rc; - int xindex = -1; /* index of -x option */ - - /* loop until all options are consumed or we hit - * a -x option - */ - while ((c = getopt(argc, argv, "s:n:x:")) != -1 && - xindex == -1) { - switch (c) { - case 's': - echo_server_nid = optarg; - break; - case 'n': - echo_server_ostname = optarg; - break; - case 'x': - xindex = optind-1; - break; - default: - usage(argv[0]); - return 1; - } - } - - /* - * Only warn with usage() if the -x option isn't specificed - * because when using -x this check is not valid. - */ - if (optind != argc && xindex == -1) - usage(argv[0]); - - if (!echo_server_nid) { - usage(argv[0]); - return 1; - } - - libcfs_debug = 0; - libcfs_subsystem_debug = 0; - - liblustre_init_random(); - - if (liblustre_init_current(argv[0]) || - init_obdclass() || init_lib_portals() || - ptlrpc_init() || - lmv_init() || - mdc_init() || - lov_init() || - osc_init() || - echo_client_init()) { - printf("error\n"); - return 1; - } - - rc = connect_echo_client(); - if (rc) - return rc; - - set_ioc_handler(liblustre_ioctl); - - - /* - * If the -x option is not specified pass no args to lctl - * otherwise pass all the options after the "-x" to lctl - * - * HACK: in the case when the -x option is specified - * lctl sees argv[0] == "-x" and not the real argv[0] seen - * in this function. If that is a problem, a mapping will - * have to be done to fix that. However for normal functioning - * it seems to be irrelavant - */ - if( xindex == -1 ) - rc = lctl_main(1, &argv[0]); - else - rc = lctl_main(argc-xindex+1, &argv[xindex-1]); - - rc |= disconnect_echo_client(); - - return rc; -} diff --git a/lustre/liblustre/tests/mpi/.gitignore b/lustre/liblustre/tests/mpi/.gitignore deleted file mode 100644 index 2dc2b0a..0000000 --- a/lustre/liblustre/tests/mpi/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/Makefile.in -/test_lock_cancel diff --git a/lustre/liblustre/tests/mpi/Makefile.am b/lustre/liblustre/tests/mpi/Makefile.am deleted file mode 100644 index f354e9f..0000000 --- a/lustre/liblustre/tests/mpi/Makefile.am +++ /dev/null @@ -1,17 +0,0 @@ -## Liblustre MPI tests Makefile - -AM_CPPFLAGS = -I$(SYSIO)/include $(LLCPPFLAGS) -I$(top_srcdir)/lnet/ulnds -AM_CFLAGS = $(LLCFLAGS) - -LLIB_EXEC = $(top_builddir)/lustre/utils/liblustreapi.a $(top_builddir)/lustre/liblustre/liblustre.a $(CAP_LIBS) $(PTHREAD_LIBS) - -CC = @MPICC_WRAPPER@ - -if LIBLUSTRE -if LIBLUSTRE_TESTS -noinst_PROGRAMS = test_lock_cancel -endif # LIBLUSTRE_TESTS -endif # LIBLUSTRE - -test_lock_cancel_SOURCES = test_lock_cancel.c -test_lock_cancel_LDADD := $(LLIB_EXEC) diff --git a/lustre/liblustre/tests/mpi/test_lock_cancel.c b/lustre/liblustre/tests/mpi/test_lock_cancel.c deleted file mode 100644 index 52e939a..0000000 --- a/lustre/liblustre/tests/mpi/test_lock_cancel.c +++ /dev/null @@ -1,209 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * 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 version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * lustre/liblustre/tests/test_lock_cancel.c - * - * Lustre Light user test program - */ - -#define _BSD_SOURCE - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include <../test_common.h> - -#include - -/******************************************************************************/ -/* - * MPI_CHECK will display a custom error message as well as an error string - * from the MPI_STATUS and then exit the program - */ - -#define MPI_CHECK(MPI_STATUS, MSG) do { \ - char resultString[MPI_MAX_ERROR_STRING]; \ - int resultLength; \ - \ - if (MPI_STATUS != MPI_SUCCESS) { \ - fprintf(stdout, "** error **\n"); \ - fprintf(stdout, "ERROR in %s (line %d): %s.\n", \ - __FILE__, __LINE__, MSG); \ - MPI_Error_string(MPI_STATUS, resultString, &resultLength); \ - fprintf(stdout, "MPI %s\n", resultString); \ - fprintf(stdout, "** exiting **\n"); \ - MPI_Abort(MPI_COMM_WORLD, 1); \ - } \ -} while(0) - -int numTasks = 0, /* MPI variables */ - rank = 0, - tasksPerNode = 0; /* tasks per node */ - - - - -static char *test_file_name = "/mnt/lustre/test_lock_cancel"; - -extern void __liblustre_setup_(void); -extern void __liblustre_cleanup_(void); - -void usage(char *cmd) -{ - printf("Usage: \t%s --target mdsnid:/mdsname/profile\n", cmd); - printf(" \t%s --dumpfile dumpfile\n", cmd); - exit(-1); -} - -int main(int argc, char *argv[]) -{ - int opt_index, c; - static struct option long_opts[] = { - {"target", 1, 0, 0}, - {"dumpfile", 1, 0, 0}, - {0, 0, 0, 0} - }; - int fd; - long time1, time2; - struct stat statbuf; - - if (argc < 3) - usage(argv[0]); - - while ((c = getopt_long(argc, argv, "", long_opts, &opt_index)) != -1) { - switch (c) { - case 0: { - if (!optarg[0]) - usage(argv[0]); - - if (!strcmp(long_opts[opt_index].name, "target")) { - setenv(ENV_LUSTRE_MNTTGT, optarg, 1); - } else if (!strcmp(long_opts[opt_index].name, "dumpfile")) { - setenv(ENV_LUSTRE_DUMPFILE, optarg, 1); - } else - usage(argv[0]); - break; - } - default: - usage(argv[0]); - } - } - - if (optind != argc) - usage(argv[0]); - - __liblustre_setup_(); - - MPI_CHECK(MPI_Init(&argc, &argv), "MPI_Init()"); - MPI_CHECK(MPI_Comm_size(MPI_COMM_WORLD, &numTasks), "MPI_Comm_size"); - MPI_CHECK(MPI_Comm_rank(MPI_COMM_WORLD, &rank), "MPI_Comm_rank"); - - if (numTasks < 2) { - printf("this demo can't run on single node!\n"); - goto cleanup; - } - - if (rank == 0) { - unlink(test_file_name); - } - - MPI_Barrier(MPI_COMM_WORLD); - if (rank == 1) { - printf("Node 1: creating file %s ...\n", test_file_name); - fflush(stdout); - - fd = open(test_file_name, O_CREAT|O_RDWR, 0755); - if (fd < 0) { - printf("Node %d: creat file err: %d", rank, fd); - fflush(stdout); - goto cleanup; - } - close(fd); - printf("Node 1: done creation. perform stat on file %s ...\n", test_file_name); - fflush(stdout); - - if (stat(test_file_name, &statbuf)) { - printf("Node %d: stat file err: %d", rank, fd); - fflush(stdout); - goto cleanup; - } - - printf("Node %d: done stat on file\n", rank); - fflush(stdout); - } else { - printf("Node %d: waiting node 1 create & stat file\n", rank); - fflush(stdout); - } - - MPI_Barrier(MPI_COMM_WORLD); - - if (rank == 1) { - printf("Node 1: file has been create+stat, abort excution here!!!!!!!\n"); - fflush(stdout); - exit(0); - } - - sleep(1); - printf("Node %d: synced with Node 1. sleep 5 seconds...\n", rank); - fflush(stdout); - sleep(5); - printf("Node %d: wakeup from sleep. perform unlink()...\n", rank); - fflush(stdout); - - time1 = time(NULL); - if (unlink(test_file_name)) { - printf("Node %d: error unlink file: %s\n", rank, test_file_name); - fflush(stdout); - goto cleanup; - } - time2 = time(NULL); - printf("Node %d: successfully unlink file, cost %ld seconds.\n", - rank, time2 - time1); - fflush(stdout); - -cleanup: - __liblustre_cleanup_(); - printf("Node %d: end sucessfully.\n", rank); - return 0; -} diff --git a/lustre/liblustre/tests/recovery_small.c b/lustre/liblustre/tests/recovery_small.c deleted file mode 100644 index 8d0f255..0000000 --- a/lustre/liblustre/tests/recovery_small.c +++ /dev/null @@ -1,407 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * 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 version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * lustre/liblustre/tests/recovery_small.c - * - * Lustre Light user test program - */ - -#define _BSD_SOURCE - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "test_common.h" - -#define MAX_STRING_SIZE 2048 - -static struct { - const char *name; - unsigned long code; -} drop_arr [] = -{ - {"MDS_REQUEST", 0x123}, - {"MDS_REPLY", 0x122}, - {NULL, 0} -}; - -static int drop_index = 0; - -static char mds_server[1024] = {0, }; -static char ssh_cmd[MAX_STRING_SIZE] = {0,}; - -int do_stat(const char *name, struct stat *buf) -{ - struct stat stat; - int rc; - - rc = lstat(name, &stat); - if (rc) { - printf("error %d stat %s\n", rc, name); - exit(1); - } - if (buf) - memcpy(buf, &stat, sizeof(*buf)); - - return 0; -} - -void prepare_reg(const char *path) -{ - int fd, rc; - - fd = open(path, O_RDWR|O_CREAT, 00644); - if (fd < 0) { - printf("error %d create %s\n", fd, path); - exit(1); - } - - rc = close(fd); - if (rc) { - printf("error %d close %s\n", rc, path); - exit(1); - } -} - -void cleanup_reg(const char *path) -{ - int rc; - - rc = unlink(path); - if (rc) { - printf("error %d unlink %s\n", rc, path); - exit(1); - } -} - -void prepare_dir(const char *path) -{ - int rc; - - rc = mkdir(path, 00644); - if (rc < 0) { - printf("error %d mkdir %s\n", rc, path); - exit(1); - } -} - -void cleanup_dir(const char *path) -{ - int rc; - - rc = rmdir(path); - if (rc) { - printf("error %d unlink %s\n", rc, path); - exit(1); - } -} - -#define FAIL() \ - do { \ - char cmd[MAX_STRING_SIZE]; \ - int rc; \ - \ - if (drop_arr[drop_index].name) { \ - printf("server drops next %s\n", drop_arr[drop_index].name); \ - sprintf(cmd, \ - "%s %s \"lctl set_param fail_loc=%lu\"", \ - ssh_cmd, mds_server, drop_arr[drop_index].code); \ - if ((rc = system(cmd)) != 0) { \ - rc = WEXITSTATUS(rc); \ - printf("error excuting remote command: %d\n", rc); \ - exit(rc); \ - } \ - } \ - } while (0) - -#define RECOVER() \ - do { \ - char cmd[1024]; \ - \ - if (drop_arr[drop_index].name) { \ - sprintf(cmd, "%s %s \"lctl set_param fail_loc=0\"", \ - ssh_cmd, mds_server); \ - if (!system(cmd)) {} \ - } \ - } while (0) - -#define ENTRY(str) \ - do { \ - char buf[100]; \ - int len; \ - sprintf(buf, "===== START: %s ", (str)); \ - len = strlen(buf); \ - if (len < 79) { \ - memset(buf+len, '=', 100-len); \ - buf[79] = '\n'; \ - buf[80] = 0; \ - } \ - printf("%s", buf); \ - } while (0) - -#define LEAVE() \ - do { \ - printf("----- END TEST successfully ---"); \ - printf("-----------------------------"); \ - printf("-------------------\n"); \ - } while (0) - - -void t1() -{ - char *path="/mnt/lustre/test_t1"; - ENTRY("create/delete"); - - FAIL(); - t_touch(path); - RECOVER(); - FAIL(); - t_unlink(path); - RECOVER(); - LEAVE(); -} - -void t2() -{ - char *path="/mnt/lustre/test_t2"; - ENTRY("mkdir/rmdir"); - - FAIL(); - t_mkdir(path); - RECOVER(); - FAIL(); - t_rmdir(path); - RECOVER(); - LEAVE(); -} - -void t3() -{ - char *path="/mnt/lustre/test_t3"; - ENTRY("regular stat"); - - t_touch(path); - FAIL(); - t_check_stat(path, NULL); - RECOVER(); - t_unlink(path); - LEAVE(); -} - -void t4() -{ - char *path="/mnt/lustre/test_t4"; - ENTRY("dir stat"); - - t_mkdir(path); - FAIL(); - t_check_stat(path, NULL); - RECOVER(); - t_rmdir(path); - LEAVE(); -} - -void t5() -{ - char *path="/mnt/lustre/test_t5"; - const int bufsize = 4096; - char wbuf[bufsize], rbuf[bufsize]; - int npages = 100; - int fd, rc, i; - ENTRY("sequential page aligned file I/O"); - - t_touch(path); - - fd = t_open(path); - - for (i = 0; i < npages; i++ ) { - memset(wbuf, i, bufsize); - rc = write(fd, wbuf, bufsize); - if (rc != bufsize) { - printf("write error %d (i = %d)\n", rc, i); - exit(1); - } - } - printf("succefully write %d pages\n", npages); - - lseek(fd, 0, SEEK_SET); - - for (i = 0; i < npages; i++ ) { - memset(rbuf, 0, bufsize); - rc = read(fd, rbuf, bufsize); - if (rc != bufsize) { - printf("read error %d (i = %d)\n", rc, i); - exit(1); - } - } - printf("succefully read & verified %d pages\n", npages); - - t_close(fd); - - t_unlink(path); - LEAVE(); -} - -void t6() -{ - char *path="/mnt/lustre/test_t6"; - char *path2="/mnt/lustre/test_t6_link"; - ENTRY("symlink"); - - t_touch(path); - FAIL(); - t_symlink(path, path2); - RECOVER(); - t_check_stat(path2, NULL); - t_unlink(path2); - t_unlink(path); - LEAVE(); -} - -void t7() -{ - char *path="/mnt/lustre/test_t7"; - ENTRY("mknod"); - - FAIL(); - t_mknod(path, S_IFCHR | 0644, 5, 4); - RECOVER(); - t_check_stat(path, NULL); - t_unlink(path); - LEAVE(); -} - -extern int libcfs_debug; -extern int libcfs_subsystem_debug; - -extern void __liblustre_setup_(void); -extern void __liblustre_cleanup_(void); - -void usage(const char *cmd) -{ - printf("Usage: \t%s -s mds_hostname --target mdsnid:/mdsname/profile\n", cmd); - printf(" \t%s -s mds_hostname --dumpfile dumpfile\n", cmd); - exit(-1); -} - -int main(int argc, char * argv[]) -{ - int opt_index, c; - char cmd[1024]; - static struct option long_opts[] = { - {"target", 1, 0, 0}, - {"dumpfile", 1, 0, 0}, - {"ssh", 1, 0, 0}, - {0, 0, 0, 0} - }; - - if (argc < 3 - (getenv(ENV_LUSTRE_MNTTGT)||getenv(ENV_LUSTRE_DUMPFILE))) - usage(argv[0]); - - while ((c = getopt_long(argc, argv, "s:", long_opts, &opt_index)) != -1) { - switch (c) { - case 0: { - if (!optarg[0]) - usage(argv[0]); - - if (!strcmp(long_opts[opt_index].name, "target")) { - setenv(ENV_LUSTRE_MNTTGT, optarg, 1); - } else if (!strcmp(long_opts[opt_index].name, "dumpfile")) { - setenv(ENV_LUSTRE_DUMPFILE, optarg, 1); - } else if (!strcmp(long_opts[opt_index].name, "ssh")) { - safe_strncpy(ssh_cmd, optarg, MAX_STRING_SIZE); - } else - usage(argv[0]); - break; - } - case 's': - safe_strncpy(mds_server, optarg, MAX_STRING_SIZE); - break; - default: - usage(argv[0]); - } - } - - if (optind != argc) - usage(argv[0]); - - if (strlen(mds_server) == 0) - usage(argv[0]); - - /* default to using ssh */ - if (!strlen(ssh_cmd)) { - safe_strncpy(ssh_cmd, "ssh", MAX_STRING_SIZE); - } - - sprintf(cmd, "%s %s cat /dev/null", ssh_cmd, mds_server); - if (system(cmd)) { - printf("Can't access server node: %s using method: %s\n", mds_server, ssh_cmd); - exit(-1); - } - - setenv(ENV_LUSTRE_TIMEOUT, "5", 1); - - __liblustre_setup_(); - - while (drop_arr[drop_index].name) { - t1(); - t2(); - t3(); - t4(); -#if 0 - t5(); -#endif - t6(); - t7(); - - drop_index++; - } - - printf("liblustre is about shutdown\n"); - __liblustre_cleanup_(); - - printf("complete successfully\n"); - return (0); -} diff --git a/lustre/liblustre/tests/replay_ost_single.c b/lustre/liblustre/tests/replay_ost_single.c deleted file mode 100644 index e0e0fe2..0000000 --- a/lustre/liblustre/tests/replay_ost_single.c +++ /dev/null @@ -1,353 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * 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 version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * lustre/liblustre/tests/replay_ost_single.c - * - * Lustre Light user test program - */ - -#define _BSD_SOURCE - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "test_common.h" - - - -static char mds_server[1024] = {0,}; -static char barrier_script[1024] = {0,}; -static char failover_script[1024] = {0,}; -static char barrier_cmd[1024] = {0,}; -static char failover_cmd[1024] = {0,}; - -static void replay_barrier() -{ - int rc; - - if ((rc = system(barrier_cmd))) { - printf("excute barrier error: %d\n", rc); - exit(rc); - } -} - -static void mds_failover() -{ - int rc; - - if ((rc = system(failover_cmd))) { - printf("excute failover error: %d\n", rc); - exit(rc); - } -} - - -#define ENTRY(str) \ - do { \ - char buf[100]; \ - int len; \ - sprintf(buf, "===== START: %s ", (str)); \ - len = strlen(buf); \ - if (len < 79) { \ - memset(buf+len, '=', 100-len); \ - buf[79] = '\n'; \ - buf[80] = 0; \ - } \ - printf("%s", buf); \ - } while (0) - -#define LEAVE() \ - do { \ - printf("----- END TEST successfully ---"); \ - printf("-----------------------------"); \ - printf("-------------------\n"); \ - } while (0) - -void t0() -{ - const int bufsize = 4096; - char *path = "/mnt/lustre/rp_ost_t0_file"; - char buf[bufsize]; - int fd, i, j, rc; - ENTRY("open-failover-write-verification (no ping involved)"); - - printf("create/open file...\n"); - t_touch(path); - fd = t_open(path); - printf("OST failover...\n"); - replay_barrier(); - mds_failover(); - - printf("write file...\n"); - for (i = 0; i < 20; i++) { - memset(buf, i, bufsize); - if ((rc = write(fd, buf, bufsize)) != bufsize) { - perror("write error after failover"); - printf("i = %d, rc = %d\n", i, rc); - exit(-1); - } - } - - /* verify */ - printf("read & verify...\n"); - lseek(fd, 0, SEEK_SET); - for (i = 0; i < 20; i++) { - memset(buf, -1, bufsize); - if ((rc = read(fd, buf, bufsize)) != bufsize) { - perror("read error rc"); - printf("i = %d, rc = %d\n", i, rc); - exit(-1); - } - for (j = 0; j < bufsize; j++) { - if (buf[j] != i) { - printf("verify error!\n"); - exit(-1); - } - } - } - t_close(fd); - t_unlink(path); - LEAVE(); -} - -void t1() -{ - const int bufsize = 4096; - char *path = "/mnt/lustre/rp_ost_t1_file"; - char buf[bufsize]; - int fd, i, j; - ENTRY("open-write-close-open-failover-read (no ping involved)"); - - printf("create/open file...\n"); - t_touch(path); - fd = t_open(path); - printf("write file...\n"); - for (i = 0; i < 20; i++) { - memset(buf, i, bufsize); - if (write(fd, buf, bufsize) != bufsize) { - perror("write error"); - exit(-1); - } - } - printf("close/reopen...\n"); - t_close(fd); - fd = t_open(path); - lseek(fd, 0, SEEK_SET); - - printf("OST failover...\n"); - replay_barrier(); - mds_failover(); - - printf("read & verify...\n"); - for (i = 0; i < 20; i++) { - memset(buf, -1, bufsize); - if (read(fd, buf, bufsize) != bufsize) { - perror("read error after failover"); - exit(-1); - } - for (j = 0; j < bufsize; j++) { - if (buf[j] != i) { - printf("verify error after failover\n"); - exit(-1); - } - } - } - - t_close(fd); - t_unlink(path); - LEAVE(); -} - -void t2() -{ - char *path = "/mnt/lustre/rp_ost_t2_file"; - char *str = "xxxxjoiwlsdf98lsjdfsjfoajflsjfajfoaidfojaj08eorje;"; - ENTRY("empty replay"); - - replay_barrier(); - mds_failover(); - - t_echo_create(path, str); - t_grep(path, str); - t_unlink(path); -} - -void t3() -{ - char *path = "/mnt/lustre/rp_ost_t3_file"; - char *str = "xxxxjoiwlsdf98lsjdfsjfoajflsjfajfoaidfojaj08eorje;"; - ENTRY("touch"); - - printf("touch to create a file\n"); - t_echo_create(path, str); - replay_barrier(); - mds_failover(); - - printf("read & verify\n"); - t_grep(path, str); - t_unlink(path); - /* XXX have problem without this, seems server side problem XXX */ - sleep(5); -} - -void t4() -{ - char *path = "/mnt/lustre/rp_ost_t4_file"; - char namebuf[1024]; - char str[1024]; - int count = 10, i; - ENTRY("|X| 10 open(CREAT)s (ping involved)"); - - printf("create %d files\n", count); - for (i = 0; i < count; i++) { - sprintf(namebuf, "%s%02d", path, i); - sprintf(str, "%s-%08d-%08x-AAAAA", "content", i, i); - t_echo_create(namebuf, str); - } - replay_barrier(); - mds_failover(); - - printf("read & verify\n"); - for (i = 0; i < count; i++) { - sprintf(namebuf, "%s%02d", path, i); - sprintf(str, "%s-%08d-%08x-AAAAA", "content", i, i); - t_grep(namebuf, str); - t_unlink(namebuf); - } -} - -extern int libcfs_debug; -extern int libcfs_subsystem_debug; - -extern void __liblustre_setup_(void); -extern void __liblustre_cleanup_(void); - -void usage(const char *cmd) -{ - printf("Usage: \t%s --target mdsnid:/mdsname/profile -s ost_hostname " - "-b \"barrier cmd\" -f \"failover cmd\"\n", cmd); - printf(" \t%s --dumpfile dumpfile -s ost_hostname -b \"barrier cmd\" " - "-f \"failover cmd\"\n", cmd); - exit(-1); -} - -void test_ssh() -{ - char cmd[1024]; - - sprintf(cmd, "ssh %s cat /dev/null", mds_server); - if (system(cmd)) { - printf("ssh can't access server node: %s\n", mds_server); - exit(-1); - } -} - -int main(int argc, char * const argv[]) -{ - int opt_index, c; - static struct option long_opts[] = { - {"target", 1, 0, 0}, - {"dumpfile", 1, 0, 0}, - {0, 0, 0, 0} - }; - - if (argc < 4) - usage(argv[0]); - - while ((c = getopt_long(argc, argv, "s:b:f:", long_opts, &opt_index)) != -1) { - switch (c) { - case 0: { - if (!optarg[0]) - usage(argv[0]); - - if (!strcmp(long_opts[opt_index].name, "target")) { - setenv(ENV_LUSTRE_MNTTGT, optarg, 1); - } else if (!strcmp(long_opts[opt_index].name, "dumpfile")) { - setenv(ENV_LUSTRE_DUMPFILE, optarg, 1); - } else - usage(argv[0]); - break; - } - case 's': - strcpy(mds_server, optarg); - break; - case 'b': - strcpy(barrier_script, optarg); - break; - case 'f': - strcpy(failover_script, optarg); - break; - default: - usage(argv[0]); - } - } - - if (optind != argc) - usage(argv[0]); - if (!strlen(mds_server) || !strlen(barrier_script) || - !strlen(failover_script)) - usage(argv[0]); - - test_ssh(); - - /* prepare remote command */ - sprintf(barrier_cmd, "ssh %s \"%s\"", mds_server, barrier_script); - sprintf(failover_cmd, "ssh %s \"%s\"", mds_server, failover_script); - - setenv(ENV_LUSTRE_TIMEOUT, "5", 1); - - __liblustre_setup_(); - - t0(); - t1(); - t2(); - t3(); - t4(); - - printf("liblustre is about shutdown\n"); - __liblustre_cleanup_(); - - printf("complete successfully\n"); - return 0; -} diff --git a/lustre/liblustre/tests/replay_single.c b/lustre/liblustre/tests/replay_single.c deleted file mode 100644 index 45d9d16..0000000 --- a/lustre/liblustre/tests/replay_single.c +++ /dev/null @@ -1,439 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * 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 version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * lustre/liblustre/tests/replay_single.c - * - * Lustre Light user test program - */ - -#define _BSD_SOURCE - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "test_common.h" - -#define MAX_STRING_SIZE 2048 - -static char mds_server[MAX_STRING_SIZE] = {0,}; -static char barrier_script[MAX_STRING_SIZE] = {0,}; -static char failover_script[MAX_STRING_SIZE] = {0,}; -static char barrier_cmd[MAX_STRING_SIZE] = {0,}; -static char failover_cmd[MAX_STRING_SIZE] = {0,}; -static char ssh_cmd[MAX_STRING_SIZE] = {0,}; - -static void replay_barrier() -{ - int rc; - - if ((rc = system(barrier_cmd))) { - printf("excute barrier error: %d\n", rc); - exit(rc); - } -} - -static void mds_failover() -{ - int rc; - - if ((rc = system(failover_cmd))) { - printf("excute failover error: %d\n", rc); - exit(rc); - } -} - - -#define ENTRY(str) \ - do { \ - char buf[100]; \ - int len; \ - sprintf(buf, "===== START: %s ", (str)); \ - len = strlen(buf); \ - if (len < 79) { \ - memset(buf+len, '=', 100-len); \ - buf[79] = '\n'; \ - buf[80] = 0; \ - } \ - printf("%s", buf); \ - } while (0) - -#define LEAVE() \ - do { \ - printf("----- END TEST successfully ---"); \ - printf("-----------------------------"); \ - printf("-------------------\n"); \ - } while (0) - -void t0() -{ - char *path="/mnt/lustre/f0"; - ENTRY("empty replay"); - - replay_barrier(); - mds_failover(); - t_check_stat_fail(path); - LEAVE(); -} - -void t1() -{ - char *path="/mnt/lustre/f1"; - ENTRY("simple create"); - - replay_barrier(); - t_create(path); - mds_failover(); - t_check_stat(path, NULL); - t_unlink(path); - LEAVE(); -} - -void t2a() -{ - char *path="/mnt/lustre/f2a"; - ENTRY("touch"); - - replay_barrier(); - t_touch(path); - mds_failover(); - t_check_stat(path, NULL); - t_unlink(path); - LEAVE(); -} - -void t2b() -{ - char *path="/mnt/lustre/f2b"; - ENTRY("mcreate+touch"); - - t_create(path); - replay_barrier(); - t_touch(path); - mds_failover(); - t_check_stat(path, NULL); - t_unlink(path); - LEAVE(); -} - - -void n_create_delete(int nfiles) -{ - char *base="/mnt/lustre/f3_"; - char path[100]; - char str[100]; - int i; - - replay_barrier(); - for (i = 0; i < nfiles; i++) { - sprintf(path, "%s%d\n", base, i); - sprintf(str, "TEST#%d CONTENT\n", i); - t_echo_create(path, str); - } - mds_failover(); - for (i = 0; i < nfiles; i++) { - sprintf(path, "%s%d\n", base, i); - sprintf(str, "TEST#%d CONTENT\n", i); - t_grep(path, str); - } - replay_barrier(); - for (i = 0; i < nfiles; i++) { - sprintf(path, "%s%d\n", base, i); - t_unlink(path); - } - mds_failover(); - for (i = 0; i < nfiles; i++) { - sprintf(path, "%s%d\n", base, i); - t_check_stat_fail(path); - } - LEAVE(); -} - -void t3a() -{ - ENTRY("10 create/delete"); - n_create_delete(10); - LEAVE(); -} - -void t3b() -{ - ENTRY("30 create/delete(>1'st block precreated)"); - n_create_delete(30); - LEAVE(); -} - -void t4() -{ - char *dir="/mnt/lustre/d4"; - char *path="/mnt/lustre/d4/f1"; - ENTRY("mkdir + contained create"); - - replay_barrier(); - t_mkdir(dir); - t_create(path); - mds_failover(); - t_check_stat(dir, NULL); - t_check_stat(path, NULL); - sleep(2); /* wait for log process thread */ - - replay_barrier(); - t_unlink(path); - t_rmdir(dir); - mds_failover(); - t_check_stat_fail(dir); - t_check_stat_fail(path); - LEAVE(); -} - -void t5() -{ - char *dir="/mnt/lustre/d5"; - char *path="/mnt/lustre/d5/f1"; - ENTRY("mkdir |X| contained create"); - - t_mkdir(dir); - replay_barrier(); - t_create(path); - mds_failover(); - t_check_stat(dir, NULL); - t_check_stat(path, NULL); - t_unlink(path); - t_rmdir(dir); - LEAVE(); -} - -void t6() -{ - char *path="/mnt/lustre/f6"; - int fd; - ENTRY("open |X| close"); - - replay_barrier(); - t_create(path); - fd = t_open(path); - sleep(1); - mds_failover(); - t_check_stat(path, NULL); - t_close(fd); - t_unlink(path); - LEAVE(); -} - -void t7() -{ - char *path="/mnt/lustre/f7"; - char *path2="/mnt/lustre/f7-2"; - ENTRY("create |X| rename unlink"); - - t_create(path); - replay_barrier(); - t_rename(path, path2); - mds_failover(); - t_check_stat_fail(path); - t_check_stat(path2, NULL); - t_unlink(path2); -} - -void t8() -{ - char *path="/mnt/lustre/f8"; - char *path2="/mnt/lustre/f8-2"; - ENTRY("create open write rename |X| create-old-name read"); - - t_create(path); - t_echo_create(path, "old"); - t_rename(path, path2); - replay_barrier(); - t_echo_create(path, "new"); - mds_failover(); - t_grep(path, "new"); - t_grep(path2, "old"); - t_unlink(path); - t_unlink(path2); -} - -void t9() -{ - char *path="/mnt/lustre/f9"; - char *path2="/mnt/lustre/f9-2"; - ENTRY("|X| open(O_CREAT), unlink, touch new, unlink new"); - - replay_barrier(); - t_create(path); - t_unlink(path); - t_create(path2); - mds_failover(); - t_check_stat_fail(path); - t_check_stat(path2, NULL); - t_unlink(path2); -} - -void t10() -{ - char *path="/mnt/lustre/f10"; - char *path2="/mnt/lustre/f10-2"; - ENTRY("|X| mcreate, open write, rename"); - - replay_barrier(); - t_create(path); - t_echo_create(path, "old"); - t_rename(path, path2); - t_grep(path2, "old"); - mds_failover(); - t_grep(path2, "old"); - t_unlink(path2); -} - -extern int libcfs_debug; -extern int libcfs_subsystem_debug; - -extern void __liblustre_setup_(void); -extern void __liblustre_cleanup_(void); - -void usage(const char *cmd) -{ - printf("Usage: \t%s --target mdsnid:/mdsname/profile -s mds_hostname " - "-b \"barrier cmd\" -f \"failover cmd\" [--rsh \"rsh_cmd\"]\n", cmd); - printf(" \t%s --dumpfile dumpfile -s mds_hostname -b \"barrier cmd\" " - "-f \"failover cmd\" [--rsh \"rsh_cmd\"]\n", cmd); - exit(-1); -} - -void test_ssh() -{ - char cmd[MAX_STRING_SIZE]; - - sprintf(cmd, "%s %s cat /dev/null", ssh_cmd, mds_server); - if (system(cmd)) { - printf("Can't access server node: %s using method: %s\n", mds_server, ssh_cmd); - exit(-1); - } -} - -int main(int argc, char * const argv[]) -{ - int opt_index, c; - static struct option long_opts[] = { - {"target", 1, 0, 0}, - {"dumpfile", 1, 0, 0}, - {"ssh", 1, 0, 0}, - {0, 0, 0, 0} - }; - - if (argc < 4 - (getenv(ENV_LUSTRE_MNTTGT)||getenv(ENV_LUSTRE_DUMPFILE))) - usage(argv[0]); - - while ((c = getopt_long(argc, argv, "s:b:f:", long_opts, &opt_index)) != -1) { - switch (c) { - case 0: { - if (!optarg[0]) - usage(argv[0]); - - if (!strcmp(long_opts[opt_index].name, "target")) { - setenv(ENV_LUSTRE_MNTTGT, optarg, 1); - } else if (!strcmp(long_opts[opt_index].name, "dumpfile")) { - setenv(ENV_LUSTRE_DUMPFILE, optarg, 1); - } else if (!strcmp(long_opts[opt_index].name, "ssh")) { - safe_strncpy(ssh_cmd, optarg, MAX_STRING_SIZE); - } else - usage(argv[0]); - break; - } - case 's': - safe_strncpy(mds_server, optarg, MAX_STRING_SIZE); - break; - case 'b': - safe_strncpy(barrier_script, optarg, MAX_STRING_SIZE); - break; - case 'f': - safe_strncpy(failover_script, optarg, MAX_STRING_SIZE); - break; - default: - usage(argv[0]); - } - } - - if (optind != argc) - usage(argv[0]); - if (!strlen(mds_server) || !strlen(barrier_script) || - !strlen(failover_script)) - usage(argv[0]); - - /* default to using ssh */ - if (!strlen(ssh_cmd)) { - safe_strncpy(ssh_cmd, "ssh", MAX_STRING_SIZE); - } - - test_ssh(); - - /* prepare remote command */ - sprintf(barrier_cmd, "%s %s \"%s\"", - ssh_cmd, mds_server, barrier_script); - sprintf(failover_cmd, "%s %s \"%s\"", - ssh_cmd, mds_server, failover_script); - - setenv(ENV_LUSTRE_TIMEOUT, "10", 1); - - __liblustre_setup_(); - - t0(); - t1(); - t2a(); - t2b(); - t3a(); - t3b(); - t4(); - t5(); - t6(); - t7(); - t8(); - t9(); - t10(); - - printf("liblustre is about shutdown\n"); - __liblustre_cleanup_(); - - printf("complete successfully\n"); - return 0; -} diff --git a/lustre/liblustre/tests/sanity.c b/lustre/liblustre/tests/sanity.c deleted file mode 100644 index 21deed3..0000000 --- a/lustre/liblustre/tests/sanity.c +++ /dev/null @@ -1,1578 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * 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 version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2013, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * lustre/liblustre/tests/sanity.c - * - * Lustre Light user test program - */ - -#define _BSD_SOURCE -#define _FILE_OFFSET_BITS 64 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include "test_common.h" -#include - -#define _npages (2048) - -void *buf_alloc; -int buf_size; -int opt_verbose; -struct timeval start; - -extern char *lustre_path; - -#define ENTER(str) \ - do { \ - char buf[100]; \ - int len; \ - gettimeofday(&start, NULL); \ - sprintf(buf, "===== START %s: %s %ld", __FUNCTION__, \ - (str), (long)start.tv_sec); \ - len = strlen(buf); \ - if (len < 79) { \ - memset(buf+len, '=', 100-len); \ - buf[79] = '\n'; \ - buf[80] = 0; \ - } \ - printf("%s", buf); \ - } while (0) - -#define LEAVE() \ - do { \ - struct timeval stop; \ - char buf[100] = { '\0' }; \ - int len = sizeof(buf) - 1; \ - long usec; \ - gettimeofday(&stop, NULL); \ - usec = (stop.tv_sec - start.tv_sec) * 1000000 + \ - (stop.tv_usec - start.tv_usec); \ - len = snprintf(buf, len, \ - "===== END TEST %s: successfully (%gs)", \ - __FUNCTION__, (double)usec / 1000000); \ - if (len < 79) { \ - memset(buf+len, '=', sizeof(buf) - len); \ - buf[79] = '\n'; \ - buf[80] = 0; \ - } \ - printf("%s", buf); \ - return 0; \ - } while (0) - -#define MAX_PATH_LENGTH 4096 - -int t1(char *name) -{ - char path[MAX_PATH_LENGTH] = ""; - - ENTER("touch+unlink"); - snprintf(path, MAX_PATH_LENGTH, "%s/test_t1", lustre_path); - - if (opt_verbose) - printf("touch+unlink %s\n", path); - - t_touch(path); - t_unlink(path); - LEAVE(); -} - -int t2(char *name) -{ - char path[MAX_PATH_LENGTH] = ""; - - ENTER("mkdir/rmdir"); - snprintf(path, MAX_PATH_LENGTH, "%s/test_t2", lustre_path); - - t_mkdir(path); - t_rmdir(path); - LEAVE(); -} - -int t3(char *name) -{ - char path[MAX_PATH_LENGTH] = ""; - - ENTER("regular stat"); - snprintf(path, MAX_PATH_LENGTH, "%s/test_t3", lustre_path); - - t_touch(path); - t_check_stat(path, NULL); - t_unlink(path); - LEAVE(); -} - -int t4(char *name) -{ - char path[MAX_PATH_LENGTH] = ""; - - ENTER("dir stat"); - snprintf(path, MAX_PATH_LENGTH, "%s/test_t4", lustre_path); - - t_mkdir(path); - t_check_stat(path, NULL); - t_rmdir(path); - LEAVE(); -} - -int t6(char *name) -{ - char path[MAX_PATH_LENGTH] = ""; - char path2[MAX_PATH_LENGTH] = ""; - - ENTER("symlink"); - snprintf(path, MAX_PATH_LENGTH, "%s/test_t6", lustre_path); - snprintf(path2, MAX_PATH_LENGTH, "%s/test_t6_link", lustre_path); - - t_touch(path); - t_symlink(path, path2); - t_check_stat(path2, NULL); - t_unlink(path2); - t_unlink(path); - LEAVE(); -} - -int t6b(char *name) -{ - char path[MAX_PATH_LENGTH] = ""; - char path2[MAX_PATH_LENGTH] = ""; - char cwd[MAX_PATH_LENGTH] = ""; - char *tmp; - int fd; - - ENTER("symlink + chdir and open"); - snprintf(path, MAX_PATH_LENGTH, "%s/test_t6b", lustre_path); - snprintf(path2, MAX_PATH_LENGTH, "%s/test_t6b_link", lustre_path); - - t_mkdir(path); - t_symlink(path, path2); - t_check_stat(path2, NULL); - - tmp = getcwd(cwd, MAX_PATH_LENGTH); - if (tmp == NULL) { - fprintf(stderr, "current path too long to fit in " - "MAX_PATH_LENGTH?\n"); - LEAVE(); - } - t_chdir(path2); - t_chdir(cwd); - t_rmdir(path); - t_touch(path); - - fd = t_open(path2); - t_close(fd); - - t_unlink(path2); - t_unlink(path); - LEAVE(); -} - -int t7(char *name) -{ - char path[MAX_PATH_LENGTH] = ""; - int rc; - - ENTER("mknod"); - snprintf(path, MAX_PATH_LENGTH, "%s/test_t7", lustre_path); - - if (geteuid() != 0) { - rc = mknod(path, S_IFCHR | 0644, (5<<8 | 4)); - if (rc != -1 || errno != EPERM) { - printf("mknod shouldn't success: rc %d, errno %d\n", - rc, errno); - } - } else { - t_mknod(path, S_IFCHR | 0644, 5, 4); - t_check_stat(path, NULL); - t_unlink(path); - } - LEAVE(); -} - -int t8(char *name) -{ - char path[MAX_PATH_LENGTH] = ""; - - ENTER("chmod"); - snprintf(path, MAX_PATH_LENGTH, "%s/test_t8", lustre_path); - - /* Check file. */ - t_touch(path); - t_chmod_raw(path, 0700); - t_check_stat(path, NULL); - t_unlink(path); - - /* Check dir. */ - t_mkdir(path); - t_chmod_raw(path, 0700); - t_check_stat(path, NULL); - t_rmdir(path); - - LEAVE(); -} - -int t9(char *name) -{ - char path[MAX_PATH_LENGTH] = ""; - char path2[MAX_PATH_LENGTH] = ""; - - ENTER("hard link"); - snprintf(path, MAX_PATH_LENGTH, "%s/test_t9", lustre_path); - snprintf(path2, MAX_PATH_LENGTH, "%s/test_t9_link", lustre_path); - - t_touch(path); - t_link(path, path2); - t_check_stat(path, NULL); - t_check_stat(path2, NULL); - t_unlink(path); - t_unlink(path2); - LEAVE(); -} - -int t10(char *name) -{ - char dir1[MAX_PATH_LENGTH] = ""; - char dir2[MAX_PATH_LENGTH] = ""; - char path1[MAX_PATH_LENGTH] = ""; - char path2[MAX_PATH_LENGTH] = ""; - char rename1[MAX_PATH_LENGTH] = ""; - char rename2[MAX_PATH_LENGTH] = ""; - char rename3[MAX_PATH_LENGTH] = ""; - - ENTER("rename"); - snprintf(dir1, MAX_PATH_LENGTH, "%s/test_t10_dir1", lustre_path); - snprintf(dir2, MAX_PATH_LENGTH, "%s/test_t10_dir2", lustre_path); - snprintf(path1, MAX_PATH_LENGTH, "%s/test_t10_reg1", lustre_path); - snprintf(path2, MAX_PATH_LENGTH, "%s/test_t10_reg2", lustre_path); - snprintf(rename1, MAX_PATH_LENGTH, "%s/test_t10_dir1/rename1", lustre_path); - snprintf(rename2, MAX_PATH_LENGTH, "%s/test_t10_dir2/rename2", lustre_path); - snprintf(rename3, MAX_PATH_LENGTH, "%s/test_t10_dir2/rename3", lustre_path); - - t_mkdir(dir1); - t_mkdir(dir2); - t_touch(path1); - t_touch(path2); - t_rename(path1, rename1); - t_rename(path2, rename2); - t_rename(rename1, rename2); - t_rename(dir1, rename3); - t_unlink(rename2); - t_rmdir(rename3); - t_rmdir(dir2); - LEAVE(); -} - -int t11(char *name) -{ - char *base=lustre_path; - char path[MAX_PATH_LENGTH], path2[MAX_PATH_LENGTH]; - int i, j, level = 5, nreg = 5; - ENTER("deep tree"); - - safe_strncpy(path, base, MAX_PATH_LENGTH); - - for (i = 0; i < level; i++) { - for (j = 0; j < nreg; j++) { - sprintf(path2, "%s/file%d", path, j); - t_touch(path2); - } - - strcat(path, "/dir"); - t_mkdir(path); - } - - for (i = level; i > 0; i--) { - safe_strncpy(path, base, MAX_PATH_LENGTH); - for (j = 1; j < i; j++) - strcat(path, "/dir"); - - for (j = 0; j < nreg; j++) { - sprintf(path2, "%s/file%d", path, j); - t_unlink(path2); - } - - strcat(path, "/dir"); - t_rmdir(path); - } - - LEAVE(); -} - -int t12(char *name) -{ - char dir[MAX_PATH_LENGTH] = ""; - char buf[1024*128]; - int fd; - ENTER("empty directory readdir"); - snprintf(dir, MAX_PATH_LENGTH, "%s/test_t12_dir", lustre_path); - - t_mkdir(dir); - fd = t_opendir(dir); - t_ls(fd, buf, sizeof(buf)); - t_close(fd); - t_rmdir(dir); - LEAVE(); -} - -int t13(char *name) -{ - char dir[MAX_PATH_LENGTH] = ""; - char path[1024]; - char buf[1024]; - const int nfiles = 20; - char *prefix = "test13_filename_prefix_"; - int fd, i; - ENTER("multiple entries directory readdir"); - snprintf(dir, MAX_PATH_LENGTH, "%s/test_t13_dir/", lustre_path); - - t_mkdir(dir); - printf("Creating %d files...\n", nfiles); - for (i = 0; i < nfiles; i++) { - sprintf(path, "%s%s%05d", dir, prefix, i); - t_touch(path); - } - fd = t_opendir(dir); - t_ls(fd, buf, sizeof(buf)); - t_close(fd); - printf("Cleanup...\n"); - for (i = 0; i < nfiles; i++) { - sprintf(path, "%s%s%05d", dir, prefix, i); - t_unlink(path); - } - t_rmdir(dir); - LEAVE(); -} - -int t14(char *name) -{ - char dir[MAX_PATH_LENGTH] = ""; - char path[1024]; - char buf[1024]; - const int nfiles = 256; - char *prefix = "test14_filename_long_prefix_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA___"; - struct dirent64 *ent; - int fd, i, rc, pos, index; - loff_t base = 0; - ENTER(">1 block(4k) directory readdir"); - snprintf(dir, MAX_PATH_LENGTH, "%s/test_t14_dir/", lustre_path); - - rc = mkdir(dir, 0755); - if (rc < 0 && errno != EEXIST) { - printf("mkdir(%s) error: %s\n", dir, strerror(errno)); - exit(1); - } - printf("Creating %d files...\n", nfiles); - for (i = 0; i < nfiles; i++) { - sprintf(path, "%s%s%05d", dir, prefix, i); - t_touch(path); - } - fd = t_opendir(dir); - printf("Listing...\n"); - index = 0; - while ((rc = getdirentries64(fd, buf, 1024, &base)) > 0) { - pos = 0; - while (pos < rc) { - char *item; - - ent = (void *) buf + pos; - item = (char *) ent->d_name; - if (!strcmp(item, ".") || !strcmp(item, "..")) - goto iter; - if (strstr(item, prefix) != item) { - printf("found bad name %s\n", item); - return(-1); - } - printf("[%03d]: %s\t", - index++, item + strlen(prefix)); -iter: - pos += ent->d_reclen; - } - } - printf("\n"); - if (rc < 0) { - printf("getdents error %d\n", rc); - return(-1); - } - if (index != nfiles) { - printf("get %d files != %d\n", index, nfiles); - return(-1); - } - t_close(fd); - printf("Cleanup...\n"); - for (i = 0; i < nfiles; i++) { - sprintf(path, "%s%s%05d", dir, prefix, i); - t_unlink(path); - } - t_rmdir(dir); - LEAVE(); -} - -int t15(char *name) -{ - char file[MAX_PATH_LENGTH] = ""; - int fd; - ENTER("open-stat-close"); - snprintf(file, MAX_PATH_LENGTH, "%s/test_t15_file", lustre_path); - - t_touch(file); - fd = t_open(file); - t_check_stat(file, NULL); - t_close(fd); - t_unlink(file); - LEAVE(); -} - -int t16(char *name) -{ - char file[MAX_PATH_LENGTH] = ""; - ENTER("small-write-read"); - snprintf(file, MAX_PATH_LENGTH, "%s/test_t16_file", lustre_path); - - t_echo_create(file, "aaaaaaaaaaaaaaaaaaaaaa"); - t_grep(file, "aaaaaaaaaaaaaaaaaaaaaa"); - t_unlink(file); - LEAVE(); -} - -int t17(char *name) -{ - char file[MAX_PATH_LENGTH] = ""; - int fd; - ENTER("open-unlink without close"); - snprintf(file, MAX_PATH_LENGTH, "%s/test_t17_file", lustre_path); - - fd = open(file, O_WRONLY | O_CREAT, 0666); - if (fd < 0) { - printf("failed to create file: %s\n", strerror(errno)); - return(-1); - } - t_unlink(file); - LEAVE(); -} - -int t18(char *name) -{ - char file[MAX_PATH_LENGTH] = ""; - char buf[128]; - int fd, i; - struct stat statbuf[3]; - ENTER("write should change mtime/ctime"); - snprintf(file, MAX_PATH_LENGTH, "%s/test_t18_file", lustre_path); - - for (i = 0; i < 3; i++) { - fd = open(file, O_RDWR|O_CREAT|O_APPEND, (mode_t)0666); - if (fd < 0) { - printf("error open file: %s\n", strerror(errno)); - return(-1); - } - if (write(fd, buf, sizeof(buf)) != sizeof(buf)) { - printf("error write file\n"); - return(-1); - } - close(fd); - if(stat(file, &statbuf[i]) != 0) { - printf("Error stat\n"); - return(1); - } - printf("ctime %lu, mtime %lu\n", - statbuf[i].st_ctime, statbuf[i].st_mtime); - sleep(2); - } - - for (i = 1; i < 3; i++) { - if ((statbuf[i].st_ctime <= statbuf[i-1].st_ctime) || - (statbuf[i].st_mtime <= statbuf[i-1].st_mtime)) { - printf("time error\n"); - return(-1); - } - } - t_unlink(file); - LEAVE(); -} - -int t18b(char *name) -{ - char file[MAX_PATH_LENGTH] = ""; - int i; - struct stat statbuf[3]; - ENTER("utime should change mtime/atime/ctime"); - snprintf(file, MAX_PATH_LENGTH, "%s/test_t18b_file", lustre_path); - t_touch(file); - - for (i = 0; i < 3; i++) { - t_utime(file, NULL); - if(stat(file, &statbuf[i]) != 0) { - printf("Error stat\n"); - return(1); - } - printf("atime %lu, mtime %lu, ctime %lu\n", - statbuf[i].st_atime, statbuf[i].st_mtime, - statbuf[i].st_ctime); - sleep(2); - } - - for (i = 1; i < 3; i++) { - if ((statbuf[i].st_atime <= statbuf[i-1].st_atime) || - (statbuf[i].st_mtime <= statbuf[i-1].st_mtime) || - (statbuf[i].st_ctime <= statbuf[i-1].st_ctime)) { - printf("time error\n"); - return(-1); - } - } - t_unlink(file); - LEAVE(); -} - -static int check_file_size(char *file, long long size) -{ - struct stat statbuf; - - if (stat(file, &statbuf) != 0) { - printf("Error stat(%s)\n", file); - return(1); - } - if (statbuf.st_size != size) { - printf("size of %s: %lld != %lld\n", file, - (long long)statbuf.st_size, (long long )size); - return(-1); - } - return 0; -} - -int t19(char *name) -{ - char file[MAX_PATH_LENGTH] = ""; - int fd; - int result; - ENTER("open(O_TRUNC) should truncate file to 0-length"); - snprintf(file, MAX_PATH_LENGTH, "%s/test_t19_file", lustre_path); - - t_echo_create(file, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); - - fd = open(file, O_RDWR|O_CREAT|O_TRUNC, (mode_t)0666); - if (fd < 0) { - printf("error open file: %s\n", strerror(errno)); - return(-1); - } - close(fd); - result = check_file_size(file, 0); - if (result != 0) - return result; - t_unlink(file); - LEAVE(); -} - -int t20(char *name) -{ - char file[MAX_PATH_LENGTH] = ""; - int fd; - struct iovec iov[2]; - char buf[100]; - long ret; - ENTER("trap app's general bad pointer for file i/o"); - snprintf(file, MAX_PATH_LENGTH, "%s/test_t20_file", lustre_path); - - fd = open(file, O_RDWR|O_CREAT, (mode_t)0666); - if (fd < 0) { - printf("error open file: %s\n", strerror(errno)); - return(-1); - } - - ret = write(fd, NULL, 20); - if (ret != -1 || errno != EFAULT) { - printf("write 1: ret %lld, errno %d\n", (long long)ret, errno); - return(1); - } - ret = write(fd, (void *)-1, 20); - if (ret != -1 || errno != EFAULT) { - printf("write 2: ret %lld, errno %d\n", (long long)ret, errno); - return(1); - } - iov[0].iov_base = NULL; - iov[0].iov_len = 10; - iov[1].iov_base = (void *)-1; - iov[1].iov_len = 10; - ret = writev(fd, iov, 2); - if (ret != -1 || errno != EFAULT) { - printf("writev 1: ret %lld, errno %d\n", (long long)ret, errno); - return(1); - } - iov[0].iov_base = NULL; - iov[0].iov_len = 0; - iov[1].iov_base = buf; - iov[1].iov_len = sizeof(buf); - ret = writev(fd, iov, 2); - if (ret != sizeof(buf)) { - printf("writev 2: ret %lld, error %d\n", (long long)ret, errno); - return(1); - } - lseek(fd, 0, SEEK_SET); - - ret = read(fd, NULL, 20); - if (ret != -1 || errno != EFAULT) { - printf("read 1: ret %lld, errno %d\n", (long long)ret, errno); - return(1); - } - ret = read(fd, (void *)-1, 20); - if (ret != -1 || errno != EFAULT) { - printf("read 2: ret %lld, error %d\n", (long long)ret, errno); - return(1); - } - iov[0].iov_base = NULL; - iov[0].iov_len = 10; - iov[1].iov_base = (void *)-1; - iov[1].iov_len = 10; - ret = readv(fd, iov, 2); - if (ret != -1 || errno != EFAULT) { - printf("readv 1: ret %lld, error %d\n", (long long)ret, errno); - return(1); - } - iov[0].iov_base = NULL; - iov[0].iov_len = 0; - iov[1].iov_base = buf; - iov[1].iov_len = sizeof(buf); - ret = readv(fd, iov, 2); - if (ret != sizeof(buf)) { - printf("readv 2: ret %lld, error %d\n", (long long)ret, errno); - return(1); - } - - close(fd); - t_unlink(file); - LEAVE(); -} - -int t21(char *name) -{ - char file[MAX_PATH_LENGTH] = ""; - int fd, ret; - struct flock lock = { - .l_type = F_RDLCK, - .l_whence = SEEK_SET, - }; - - ENTER("basic fcntl support"); - snprintf(file, MAX_PATH_LENGTH, "%s/test_t21_file", lustre_path); - - fd = open(file, O_RDWR|O_CREAT, (mode_t)0666); - if (fd < 0) { - printf("error open file: %s\n", file); - return(-1); - } - - t_fcntl(fd, F_SETFL, O_APPEND); - ret = t_fcntl(fd, F_GETFL); - if ((ret & O_APPEND) == 0) { - printf("error get flag: ret %o\n", ret); - return(-1); - } - - t_fcntl(fd, F_SETLK, &lock); - t_fcntl(fd, F_GETLK, &lock); - lock.l_type = F_WRLCK; - t_fcntl(fd, F_SETLKW, &lock); - t_fcntl(fd, F_GETLK, &lock); - lock.l_type = F_UNLCK; - t_fcntl(fd, F_SETLK, &lock); - - close(fd); - t_unlink(file); - LEAVE(); -} - -int t22(char *name) -{ - char file[MAX_PATH_LENGTH] = ""; - int fd; - char *str = "1234567890"; - char buf[100]; - long ret; - ENTER("make sure O_APPEND take effect"); - snprintf(file, MAX_PATH_LENGTH, "%s/test_t22_file", lustre_path); - - fd = open(file, O_TRUNC|O_RDWR|O_CREAT|O_APPEND, (mode_t)0666); - if (fd < 0) { - printf("error open file: %s\n", strerror(errno)); - return(-1); - } - - lseek(fd, 100, SEEK_SET); - ret = write(fd, str, strlen(str)); - if (ret != strlen(str)) { - printf("write 1: ret %lld, errno %d\n", (long long)ret, errno); - return(1); - } - - lseek(fd, 0, SEEK_SET); - ret = read(fd, buf, sizeof(buf)); - if (ret != strlen(str)) { - printf("read 1: ret %lld\n", (long long)ret); - return(1); - } - - if (memcmp(buf, str, strlen(str))) { - printf("read 1 data err\n"); - return(1); - } - - if (fcntl(fd, F_SETFL, 0)) { - printf("fcntl err: %s\n", strerror(errno)); - return(1); - } - - lseek(fd, 100, SEEK_SET); - ret = write(fd, str, strlen(str)); - if (ret != strlen(str)) { - printf("write 2: ret %lld, errno %d\n", (long long)ret, errno); - return(1); - } - - lseek(fd, 100, SEEK_SET); - ret = read(fd, buf, sizeof(buf)); - if (ret != strlen(str)) { - printf("read 2: ret %lld\n", (long long)ret); - return(1); - } - - if (memcmp(buf, str, strlen(str))) { - printf("read 2 data err\n"); - return(1); - } - - close(fd); - t_unlink(file); - LEAVE(); -} - -int t23(char *name) -{ - char path[MAX_PATH_LENGTH]; - int fd; - long long ret; - loff_t off; - - ENTER("handle seek > 2GB"); - snprintf(path, MAX_PATH_LENGTH, "%s/f%s", lustre_path, name); - - fd = open(path, O_WRONLY | O_CREAT | O_LARGEFILE, 0666); - if (fd < 0) { - printf("failed to create file %s: %s\n", path, strerror(errno)); - return(-1); - } - - off = 2048ULL * 1024 * 1024 - buf_size / 2; - ret = lseek(fd, off, SEEK_SET); - if (ret != off) { - printf("seek error for initial %llu != %llu\n", - ret, (long long)off); - return -1; - } - - ret = write(fd, buf_alloc, buf_size); - if (ret != buf_size) { - printf("write error for %d != %llubytes @ %llu\n", - buf_size, ret, (long long)off); - if (ret == -1) - perror("write"); - return -1; - } - - ret = lseek(fd, off, SEEK_SET); - if (ret != off) { - printf("seek < 2GB error for %llu != %llu\n", - ret, (long long)off); - if (ret == -1) - perror("seek < 2GB"); - return -1; - } - - ret = lseek(fd, off + buf_size - 2, SEEK_SET); - if (ret != off + buf_size - 2) { - printf("seek > 2GB error for %llu != %llu\n", - ret, (long long)off); - if (ret == -1) - perror("seek > 2GB"); - return -1; - } - - ret = lseek(fd, -buf_size + 2, SEEK_CUR); - if (ret != off) { - printf("relative seek error for %d %llu != %llu\n", - -buf_size + 2, ret, (unsigned long long) off); - if (ret == -1) - perror("relative seek"); - return -1; - } - - ret = lseek(fd, 0, SEEK_END); - if (ret != off + buf_size) { - printf("end seek error for %llu != %llu\n", - ret, (long long)off + buf_size); - if (ret == -1) - perror("end seek"); - return -1; - } - - ret = lseek(fd, 0, SEEK_SET); - if (ret != 0) { - printf("seek 0 error for %llu != 0\n", ret); - if (ret == -1) - perror("seek 0"); - return -1; - } - - off = 2048ULL * 1024 * 1024, SEEK_SET; - ret = lseek(fd, off, SEEK_SET); - if (ret != off) { - printf("seek 2GB error for %llu != %llu\n", ret, (unsigned long long) off); - if (ret == -1) - perror("seek 2GB"); - return -1; - } - - close(fd); - t_unlink(path); - LEAVE(); -} - -/* pos: i/o start from - * xfer: npages per transfer - */ -static int pages_io(int xfer, loff_t pos) -{ - char path[MAX_PATH_LENGTH] = ""; - - int check_sum[_npages] = {0,}, *buf; - int fd, rc, i, j, data_error = 0; - struct timeval tw1, tw2, tr1, tr2; - double tw, tr; - loff_t ret; - - snprintf(path, MAX_PATH_LENGTH, "%s/test_t50", lustre_path); - - memset(buf_alloc, 0, buf_size); - - /* create sample data */ - for (i = 0, buf = buf_alloc; i < _npages; i++) { - for (j = 0; j < PAGE_CACHE_SIZE/sizeof(int); j++, buf++) { - *buf = rand(); - } - } - - /* compute checksum */ - for (i = 0, buf = buf_alloc; i < _npages; i++) { - for (j = 0; j < PAGE_CACHE_SIZE/sizeof(int); j++, buf++) { - check_sum[i] += *buf; - } - } - - unlink(path); - t_touch(path); - - fd = t_open(path); - - /* write */ - ret = lseek(fd, pos, SEEK_SET); - if (ret != pos) { - perror("write seek"); - return 1; - } - gettimeofday(&tw1, NULL); - for (i = 0, buf = buf_alloc; i < _npages; - i += xfer, buf += xfer * PAGE_CACHE_SIZE / sizeof(int)) { - rc = write(fd, buf, PAGE_CACHE_SIZE * xfer); - if (rc != PAGE_CACHE_SIZE * xfer) { - printf("write error (i %d, rc %d): %s\n", i, rc, - strerror(errno)); - return(1); - } - } - gettimeofday(&tw2, NULL); - - memset(buf_alloc, 0, buf_size); - - /* read */ - ret = lseek(fd, pos, SEEK_SET); - if (ret != pos) { - perror("read seek"); - return 1; - } - gettimeofday(&tr1, NULL); - for (i = 0, buf = buf_alloc; i < _npages; - i += xfer, buf += xfer * PAGE_CACHE_SIZE / sizeof(int)) { - rc = read(fd, buf, PAGE_CACHE_SIZE * xfer); - if (rc != PAGE_CACHE_SIZE * xfer) { - printf("read error (i %d, rc %d): %s\n", i, rc, - strerror(errno)); - return(1); - } - } - gettimeofday(&tr2, NULL); - - /* compute checksum */ - for (i = 0, buf = buf_alloc; i < _npages; i++) { - int sum = 0; - for (j = 0; j < PAGE_CACHE_SIZE/sizeof(int); j++, buf++) { - sum += *buf; - } - if (sum != check_sum[i]) { - data_error = 1; - printf("chunk %d checksum error expected %#x got %#x\n", - i, check_sum[i], sum); - } - } - - t_close(fd); - t_unlink(path); - tw = (tw2.tv_sec - tw1.tv_sec) * 1000000 + (tw2.tv_usec - tw1.tv_usec); - tr = (tr2.tv_sec - tr1.tv_sec) * 1000000 + (tr2.tv_usec - tr1.tv_usec); - printf(" (R:%.3fM/s, W:%.3fM/s)\n", - (_npages * PAGE_CACHE_SIZE) / (tw / 1000000.0) / (1024 * 1024), - (_npages * PAGE_CACHE_SIZE) / (tr / 1000000.0) / (1024 * 1024)); - - if (data_error) - return 1; - - return 0; -} - -int t50(char *name) -{ - int np = 1; - loff_t offset = 0; - - ENTER("4k aligned i/o sanity"); - while (np <= _npages) { - printf("%3d per xfer(total %d)...\t", np, _npages); - fflush(stdout); - if (pages_io(np, offset) != 0) - return 1; - np += np; - } - LEAVE(); -} - -int t50b(char *name) -{ - loff_t off_array[] = {1, 17, 255, 258, 4095, 4097, 8191, - 1024*1024*1024*1024ULL}; - int i; - long long offset; - - ENTER("4k un-aligned i/o sanity"); - for (i = 0; i < sizeof(off_array)/sizeof(loff_t); i++) { - offset = off_array[i]; - printf("16 per xfer(total %d), offset %10lld...\t", - _npages, offset); - if (pages_io(16, offset) != 0) - return 1; - } - - LEAVE(); -} - -enum { - T51_STEP = 42, - T51_NR = 1000 -}; - -/* - * truncate(2) checks. - */ -int t51(char *name) -{ - char file[MAX_PATH_LENGTH] = ""; - int fd; - long long size; - int result; - - ENTER("truncate() should truncate file to proper length"); - snprintf(file, MAX_PATH_LENGTH, "%s/test_t51_file", lustre_path); - - for (size = 0; size < T51_NR * T51_STEP; size += T51_STEP) { - t_echo_create(file, ""); - if (truncate(file, size) != 0) { - printf("\nerror truncating file: %s\n",strerror(errno)); - return(-1); - } - result = check_file_size(file, size); - if (result != 0) - return result; - t_unlink(file); - - t_echo_create(file, ""); - fd = open(file, O_RDWR|O_CREAT, (mode_t)0666); - if (fd < 0) { - printf("\nerror open file: %s\n", strerror(errno)); - return(-1); - } - if (ftruncate(fd, size) != 0) { - printf("\nerror ftruncating file:%s\n",strerror(errno)); - return(-1); - } - close(fd); - result = check_file_size(file, size); - if (result != 0) - return result; - t_unlink(file); - if (size % (T51_STEP * (T51_NR / 75)) == 0) { - printf("."); - fflush(stdout); - } - } - printf("\n"); - LEAVE(); -} -/* - * check atime update during read - */ -int t52(char *name) -{ - char file[MAX_PATH_LENGTH] = ""; - char buf[16]; - struct stat statbuf; - time_t atime; - time_t diff; - int fd, i; - - ENTER("atime should be updated during read"); - snprintf(file, MAX_PATH_LENGTH, "%s/test_t52_file", lustre_path); - - t_echo_create(file, "check atime update during read"); - fd = open(file, O_RDONLY); - if (fd < 0) { - printf("\nerror open file: %s\n", strerror(errno)); - return(-1); - } - stat(file, &statbuf); - printf("st_atime=%s", ctime(&statbuf.st_atime)); - atime = statbuf.st_atime; - for (i = 0; i < 3; i++) { - ssize_t num_read; - sleep(2); - /* should not ignore read(2)'s return value */ - num_read = read(fd, buf, sizeof(buf)); - if (num_read < 0 ) { - printf("read from %s: %s\n", file, strerror(errno)); - return -1; - } - stat(file, &statbuf); - printf("st_atime=%s", ctime(&statbuf.st_atime)); - diff = statbuf.st_atime - atime; - if (diff <= 0) { - printf("atime doesn't updated! failed!\n"); - close(fd); - t_unlink(file); - return -1; - } - atime = statbuf.st_atime; - } - close(fd); - t_unlink(file); - LEAVE(); -} - -#define NEW_TIME 10000 -int t53(char *name) -{ - char file[MAX_PATH_LENGTH] = ""; - struct utimbuf times; /* struct. buffer for utime() */ - struct stat stat_buf; /* struct buffer to hold file info. */ - time_t mtime, atime; - - ENTER("mtime/atime should be updated by utime() call"); - snprintf(file, MAX_PATH_LENGTH, "%s/test_t53_file", lustre_path); - - t_echo_create(file, "check mtime/atime update by utime() call"); - - /* Initialize the modification and access time in the times arg */ - times.actime = NEW_TIME+10; - times.modtime = NEW_TIME; - - /* file modification/access time */ - utime(file, ×); - - if (stat(file, &stat_buf) < 0) { - printf("stat(2) of %s failed, error:%d %s\n", - file, errno, strerror(errno)); - } - mtime = stat_buf.st_mtime; - atime = stat_buf.st_atime; - - if ((mtime == NEW_TIME) && (atime == NEW_TIME + 10)) { - t_unlink(file); - LEAVE(); - } - - printf("mod time %ld, expected %ld\n", mtime, (long)NEW_TIME); - printf("acc time %ld, expected %ld\n", atime, (long)NEW_TIME + 10); - - t_unlink(file); - return (-1); -} - -int t54(char *name) -{ - char file[MAX_PATH_LENGTH] = ""; - struct flock lock; - int fd, err; - - ENTER("fcntl should return 0 when succeed in getting flock"); - snprintf(file, MAX_PATH_LENGTH, "%s/test_t54_file", lustre_path); - - t_echo_create(file, "fcntl should return 0 when succeed"); - - fd = open(file, O_RDWR); - if (fd < 0) { - printf("\nerror open file: %s\n", strerror(errno)); - return(-1); - } - lock.l_type = F_WRLCK; - lock.l_start = 0; - lock.l_whence = 0; - lock.l_len = 1; - if ((err = t_fcntl(fd, F_SETLKW, &lock)) != 0) { - fprintf(stderr, "fcntl returned: %d (%s)\n", - err, strerror(err)); - close(fd); - t_unlink(file); - return (-1); - } - - lock.l_type = F_UNLCK; - t_fcntl(fd, F_SETLKW, &lock); - close(fd); - t_unlink(file); - LEAVE(); -} - -/* for O_DIRECTORY */ -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif - -#define STRIPE_SIZE (2048 * 2048) -#define STRIPE_OFFSET 0 -#define STRIPE_COUNT 1 -int t55(char *name) -{ - char path[MAX_PATH_LENGTH] = ""; - char file[MAX_PATH_LENGTH] = ""; - struct lov_user_md *lum = NULL; - struct lov_user_ost_data *lo = NULL; - int index, fd, buflen, rc; - - ENTER("setstripe/getstripe"); - snprintf(path, MAX_PATH_LENGTH, "%s/test_t55", lustre_path); - snprintf(file, MAX_PATH_LENGTH, "%s/test_t55/file_t55", lustre_path); - - buflen = sizeof(struct lov_user_md); - buflen += STRIPE_COUNT * sizeof(struct lov_user_ost_data); - lum = (struct lov_user_md *)malloc(buflen); - if (!lum) { - printf("out of memory!\n"); - return -1; - } - memset(lum, 0, buflen); - - t_mkdir(path); - rc = llapi_file_create(path, STRIPE_SIZE, STRIPE_OFFSET, - STRIPE_COUNT, LOV_PATTERN_RAID0); - if (rc) { - printf("llapi_file_create failed: rc = %d (%s) \n", - rc, strerror(-rc)); - t_rmdir(path); - free(lum); - return -1; - } - - fd = open(file, O_CREAT | O_RDWR, 0644); - if (fd < 0) { - printf("open file(%s) failed: rc = %d (%s) \n)", - file, fd, strerror(errno)); - t_rmdir(path); - free(lum); - return -1; - } - - lum->lmm_magic = LOV_USER_MAGIC; - lum->lmm_stripe_count = STRIPE_COUNT; - rc = ioctl(fd, LL_IOC_LOV_GETSTRIPE, lum); - if (rc) { - printf("dir:ioctl(LL_IOC_LOV_GETSTRIPE) failed: rc = %d(%s)\n", - rc, strerror(errno)); - close(fd); - t_unlink(file); - t_rmdir(path); - free(lum); - return -1; - } - - close(fd); - - if (opt_verbose) { - printf("lmm_magic: 0x%08X\n", lum->lmm_magic); - printf("lmm_object_id: "LPX64"\n", - lmm_oi_id(&lum->lmm_oi)); - printf("lmm_object_seq: "LPX64"\n", - lmm_oi_seq(&lum->lmm_oi)); - printf("lmm_stripe_count: %u\n", (int)lum->lmm_stripe_count); - printf("lmm_stripe_size: %u\n", lum->lmm_stripe_size); - printf("lmm_stripe_pattern: %x\n", lum->lmm_pattern); - - for (index = 0; index < lum->lmm_stripe_count; index++) { - lo = lum->lmm_objects + index; - printf("object %d:\n", index); - printf("\tobject_oid: "DOSTID"\n", - POSTID(&lo->l_ost_oi)); - printf("\tost_gen: %#x\n", lo->l_ost_gen); - printf("\tost_idx: %u\n", lo->l_ost_idx); - } - } - - if (lum->lmm_magic != LOV_USER_MAGIC || - lum->lmm_pattern != LOV_PATTERN_RAID0 || - lum->lmm_stripe_size != STRIPE_SIZE || - lum->lmm_objects[0].l_ost_idx != STRIPE_OFFSET || - lum->lmm_stripe_count != STRIPE_COUNT) { - printf("incorrect striping information!\n"); - t_unlink(file); - t_rmdir(path); - free(lum); - return -1; - } - t_unlink(file); - - /* setstripe on regular file */ - rc = llapi_file_create(file, STRIPE_SIZE, STRIPE_OFFSET, - STRIPE_COUNT, LOV_PATTERN_RAID0); - if (rc) { - printf("llapi_file_create failed: rc = %d (%s) \n", - rc, strerror(-rc)); - t_unlink(file); - t_rmdir(path); - free(lum); - return -1; - } - fd = open(file, O_RDWR, 0644); - if (fd < 0) { - printf("failed to open(%s): rc = %d (%s)\n", - file, fd, strerror(errno)); - t_unlink(file); - t_rmdir(path); - free(lum); - return -1; - } - - lum->lmm_magic = LOV_USER_MAGIC; - lum->lmm_stripe_count = STRIPE_COUNT; - rc = ioctl(fd, LL_IOC_LOV_GETSTRIPE, lum); - if (rc) { - printf("file:ioctl(LL_IOC_LOV_GETSTRIPE) failed: rc = %d(%s)\n", - rc, strerror(errno)); - close(fd); - t_unlink(file); - t_rmdir(path); - free(lum); - return -1; - } - close(fd); - - if (opt_verbose) { - printf("lmm_magic: 0x%08X\n", lum->lmm_magic); - printf("lmm_object_id: "LPX64"\n", - lmm_oi_id(&lum->lmm_oi)); - printf("lmm_object_seq: "LPX64"\n", - lmm_oi_seq(&lum->lmm_oi)); - printf("lmm_stripe_count: %u\n", (int)lum->lmm_stripe_count); - printf("lmm_stripe_size: %u\n", lum->lmm_stripe_size); - printf("lmm_stripe_pattern: %x\n", lum->lmm_pattern); - - for (index = 0; index < lum->lmm_stripe_count; index++) { - lo = lum->lmm_objects + index; - printf("object %d:\n", index); - printf("\tobject_oid: "DOSTID"\n", - POSTID(&lo->l_ost_oi)); - printf("\tost_gen: %#x\n", lo->l_ost_gen); - printf("\tost_idx: %u\n", lo->l_ost_idx); - } - } - - if (lum->lmm_magic != LOV_USER_MAGIC || - lum->lmm_pattern != LOV_PATTERN_RAID0 || - lum->lmm_stripe_size != STRIPE_SIZE || - lum->lmm_objects[0].l_ost_idx != STRIPE_OFFSET || - lum->lmm_stripe_count != STRIPE_COUNT) { - printf("incorrect striping information!\n"); - t_unlink(file); - t_rmdir(path); - free(lum); - return -1; - } - - t_unlink(file); - t_rmdir(path); - free(lum); - LEAVE(); -} - -/* - * getdirentries should return -1 and set errno to EINVAL when the size - * specified as an argument is too small to contain at least one entry - * (see bugzilla ticket 12229) - */ -int t56(char *name) -{ - int fd; - size_t nbytes; - off_t basep = 0; - long rc = 0; - struct dirent64 dir; - - ENTER("getdirentries should fail if nbytes is too small"); - - /* Set count to be very small. The result should be EINVAL */ - nbytes = 8; - - /* open the directory and call getdirentries */ - fd = t_opendir(lustre_path); - - rc = getdirentries(fd, (char *)&dir, nbytes, &basep); - - if (rc != -1) { - printf("Test failed: getdirentries returned %lld\n", - (long long)rc); - t_close(fd); - return -1; - } - if (errno != EINVAL) { - printf("Test failed: getdirentries returned %lld but errno is " - "set to %d (should be EINVAL)\n", (long long)rc, errno); - t_close(fd); - return -1; - } - t_close(fd); - - LEAVE(); -} - -extern void __liblustre_setup_(void); -extern void __liblustre_cleanup_(void); - - -void usage(char *cmd) -{ - printf("\n" - "usage: %s [-o test][-e test][-v] --target mgsnid:/fsname\n", - cmd); - printf(" %s --dumpfile dumpfile\n", cmd); - exit(-1); -} - -struct testlist { - int (*test)(char *name); - char *name; -} testlist[] = { - { t1, "1" }, - { t2, "2" }, - { t3, "3" }, - { t4, "4" }, - { t6, "6" }, - { t6b, "6b" }, - { t7, "7" }, - { t8, "8" }, - { t9, "9" }, - { t10, "10" }, - { t11, "11" }, - { t12, "12" }, - { t13, "13" }, - { t14, "14" }, - { t15, "15" }, - { t16, "16" }, - { t17, "17" }, - { t18, "18" }, - { t18b, "t8b" }, - { t19, "19" }, - { t20, "20" }, - { t21, "21" }, - { t22, "22" }, - { t23, "23" }, - { t50, "50" }, - { t50b, "50b" }, - { t51, "51" }, - { t53, "53" }, - { t54, "54" }, - { t55, "55" }, - { t56, "56" }, - { NULL, NULL } -}; - -int main(int argc, char * const argv[]) -{ - struct testlist *test; - int opt_index, c, rc = 0, numonly = 0, numexcept = 0; - char *only[100], *except[100]; - static struct option long_opts[] = { - {"dumpfile", 1, 0, 'd'}, - {"only", 1, 0, 'o'}, - {"except", 1, 0, 'e'}, - {"target", 1, 0, 't'}, - {"verbose", 1, 0, 'v'}, - {0, 0, 0, 0} - }; - - while ((c = getopt_long(argc, argv, "d:e:o:t:v", long_opts, &opt_index)) != -1) { - switch (c) { - case 'd': - setenv(ENV_LUSTRE_DUMPFILE, optarg, 1); - break; - case 'e': - if (numexcept == 0) - printf("Not running test(s): "); - printf("%s ", optarg); - except[numexcept++] = optarg; - break; - case 'o': - if (numonly == 0) - printf("Only running test(s): "); - printf("%s ", optarg); - only[numonly++] = optarg; - break; - case 't': - setenv(ENV_LUSTRE_MNTTGT, optarg, 1); - break; - case 'v': - opt_verbose++; - break; - default: - usage(argv[0]); - break; - } - } - - if (getenv(ENV_LUSTRE_MNTTGT) == NULL && - getenv(ENV_LUSTRE_DUMPFILE) == NULL) - usage(argv[0]); - - if (optind != argc) - usage(argv[0]); - - printf("\n"); - - __liblustre_setup_(); - - buf_size = _npages * PAGE_CACHE_SIZE; - if (opt_verbose) - printf("allocating %d bytes buffer\n", buf_size); - buf_alloc = calloc(1, buf_size); - if (buf_alloc == NULL) { - fprintf(stderr, "error allocating %d\n", buf_size); - exit(-ENOMEM); - } - - for (test = testlist; test->test != NULL; test++) { - int run = 1, i; - int len, olen; - - if (numexcept > 0) { - len = strlen(test->name); - for (i = 0; i < numexcept; i++) { - olen = strlen(except[i]); - - if (len < olen) - continue; - - if (strncmp(except[i], test->name, olen) == 0) { - switch(test->name[olen]) { - case '0': case '1': case '2': case '3': - case '4': case '5': case '6': case '7': - case '8': case '9': - break; - default: - run = 0; - break; - } - } - } - } - - if (numonly > 0) { - run = 0; - len = strlen(test->name); - for (i = 0; i < numonly; i++) { - olen = strlen(only[i]); - - if (len < olen) - continue; - - if (strncmp(only[i], test->name, olen) == 0) { - switch(test->name[olen]) { - case '0': case '1': case '2': case '3': - case '4': case '5': case '6': case '7': - case '8': case '9': - break; - default: - run = 1; - break; - } - } - } - } - if (run && (rc = (test->test)(test->name)) != 0) - break; - } - - free(buf_alloc); - - printf("liblustre is about to shutdown\n"); - __liblustre_cleanup_(); - - printf("complete successfully\n"); - return rc; -} diff --git a/lustre/liblustre/tests/test_common.c b/lustre/liblustre/tests/test_common.c deleted file mode 100644 index 1395df3..0000000 --- a/lustre/liblustre/tests/test_common.c +++ /dev/null @@ -1,470 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * 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 version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "test_common.h" - -int exit_on_err = 1; - -/****************************************************************** - * util functions - ******************************************************************/ - -#ifdef EXIT -#undef EXIT -#endif - -#define EXIT(err) \ - do { \ - if (exit_on_err) \ - exit(err); \ - } while (0) - -#define EXIT_RET(err) \ - do { \ - if (exit_on_err) \ - exit(err); \ - else \ - return (err); \ - } while (0) - - -void t_touch(const char *path) -{ - int fd, rc; - - fd = open(path, O_RDWR|O_CREAT, 0644); - if (fd < 0) { - printf("open(%s) error: %s\n", path, strerror(errno)); - EXIT(fd); - } - - rc = close(fd); - if (rc) { - printf("close(%s) error: %s\n", path, strerror(errno)); - EXIT(rc); - } -} - -/* XXX Now libsysio don't support mcreate */ -void t_create(const char *path) -{ - return t_touch(path); -#if 0 - int rc; - - rc = mknod(path, S_IFREG | 0644, 0); - if (rc) { - printf("mknod(%s) error: %s\n", path, strerror(errno)); - exit(-1); - } -#endif -} - -void t_link(const char *src, const char *dst) -{ - int rc; - - rc = link(src, dst); - if (rc) { - printf("link(%s -> %s) error: %s\n", src, dst, strerror(errno)); - EXIT(1); - } -} - -void t_unlink(const char *path) -{ - int rc; - - rc = unlink(path); - if (rc) { - printf("unlink(%s) error: %s\n", path, strerror(errno)); - EXIT(-1); - } -} - -void t_mkdir(const char *path) -{ - int rc; - - rc = mkdir(path, 00755); - if (rc < 0) { - printf("mkdir(%s) error: %s\n", path, strerror(errno)); - EXIT(1); - } -} - -void t_rmdir(const char *path) -{ - int rc; - - rc = rmdir(path); - if (rc) { - printf("rmdir(%s) error: %s\n", path, strerror(errno)); - EXIT(1); - } -} - -void t_symlink(const char *src, const char *new) -{ - int rc; - - rc = symlink(src, new); - if (rc) { - printf("symlink(%s<-%s) error: %s\n", src, new, strerror(errno)); - EXIT(1); - } -} - -#define MKDEV(a,b) (((a) << 8) | (b)) -void t_mknod(const char *path, mode_t mode, int major, int minor) -{ - int rc; - - rc = mknod(path, mode, MKDEV(5, 4)); - if (rc) { - printf("mknod(%s) error: %s\n", path, strerror(errno)); - EXIT(1); - } -} - -void t_chmod_raw(const char *path, mode_t mode) -{ - int rc; - - rc = chmod(path, mode); - if (rc) { - printf("chmod(%s) error: %s\n", path, strerror(errno)); - EXIT(1); - } -} - -void t_chmod(const char *path, const char *format, ...) -{ -} - -void t_rename(const char *oldpath, const char *newpath) -{ - int rc; - - rc = rename(oldpath, newpath); - if (rc) { - printf("rename(%s -> %s) error: %s\n", - oldpath, newpath, strerror(errno)); - EXIT(1); - } -} - -int t_open_readonly(const char *path) -{ - int fd; - - fd = open(path, O_RDONLY); - if (fd < 0) { - printf("open(%s) error: %s\n", path, strerror(errno)); - EXIT_RET(fd); - } - return fd; -} - -int t_open(const char *path) -{ - int fd; - - fd = open(path, O_RDWR | O_LARGEFILE); - if (fd < 0) { - printf("open(%s) error: %s\n", path, strerror(errno)); - EXIT_RET(fd); - } - return fd; -} - -int t_chdir(const char *path) -{ - int rc = chdir(path); - if (rc < 0) { - printf("chdir(%s) error: %s\n", path, strerror(errno)); - EXIT_RET(rc); - } - return rc; -} - -int t_utime(const char *path, const struct utimbuf *buf) -{ - int rc = utime(path, buf); - if (rc < 0) { - printf("utime(%s, %p) error: %s\n", path, buf, - strerror(errno)); - EXIT_RET(rc); - } - return rc; -} - -int t_opendir(const char *path) -{ - int fd; - - fd = open(path, O_RDONLY); - if (fd < 0) { - printf("opendir(%s) error: %s\n", path, strerror(errno)); - EXIT_RET(fd); - } - return fd; -} - -void t_close(int fd) -{ - int rc; - - rc = close(fd); - if (rc < 0) { - printf("close(%d) error: %s\n", fd, strerror(errno)); - EXIT(1); - } -} - -int t_check_stat(const char *name, struct stat *buf) -{ - struct stat stat; - int rc; - - memset(&stat, 0, sizeof(stat)); - - rc = lstat(name, &stat); - if (rc) { - printf("error %d stat %s\n", rc, name); - EXIT_RET(rc); - } - if (buf) - memcpy(buf, &stat, sizeof(*buf)); - if (stat.st_blksize == 0) { - printf("error: blksize is 0\n"); - EXIT_RET(-EINVAL); - } - - return 0; -} - -int t_check_stat_fail(const char *name) -{ - struct stat stat; - int rc; - - rc = lstat(name, &stat); - if (!rc) { - printf("%s still exists\n", name); - EXIT(-1); - } - - return 0; -} - -void t_echo_create(const char *path, const char *str) -{ - int fd, rc; - - fd = open(path, O_RDWR|O_CREAT, 0644); - if (fd < 0) { - printf("open(%s) error: %s\n", path, strerror(errno)); - EXIT(fd); - } - - if (write(fd, str, strlen(str)+1) != strlen(str)+1) { - printf("write(%s) error: %s\n", path, strerror(errno)); - EXIT(fd); - } - - rc = close(fd); - if (rc) { - printf("close(%s) error: %s\n", path, strerror(errno)); - EXIT(rc); - } -} - -static void _t_grep(const char *path, char *str, int should_contain) -{ - char buf[1024]; - int fd; - int rc; - - fd = t_open_readonly(path); - if (lseek(fd, 0, SEEK_SET) == -1) { - printf("pread_once: seek to 0 error: %s\n", strerror(errno)); - EXIT(fd); - } - - rc = read(fd, buf, 1023); - if (rc < 0) { - printf("grep: read error: %s\n", strerror(errno)); - EXIT(-1); - } - close(fd); - buf[rc] = 0; - - if ((strstr(buf, str) != 0) ^ should_contain) { - printf("grep: can't find string %s\n", str); - EXIT(-1); - } -} - -void t_grep(const char *path, char *str) -{ - _t_grep(path, str, 1); -} - -void t_grep_v(const char *path, char *str) -{ - _t_grep(path, str, 0); -} - -void t_ls(int fd, char *buf, int size) -{ - struct dirent64 *ent; - int rc, pos; - loff_t base = 0; - - printf("dir entries listing...\n"); - while ((rc = getdirentries64(fd, buf, size, &base)) > 0) { - pos = 0; - while (pos < rc) { - ent = (struct dirent64 *)((char *)buf + pos); - printf("%s\n", ent->d_name); - pos += ent->d_reclen; - } - } - - if (rc < 0) { - printf("getdents error %d\n", rc); - EXIT(-1); - } -} - -int t_fcntl(int fd, int cmd, ...) -{ - va_list ap; - long arg; - struct flock *lock; - int rc = -1; - - va_start(ap, cmd); - switch (cmd) { - case F_GETFL: - va_end(ap); - rc = fcntl(fd, cmd); - if (rc == -1) { - printf("fcntl GETFL failed: %s\n", - strerror(errno)); - EXIT(1); - } - break; - case F_SETFL: - arg = va_arg(ap, long); - va_end(ap); - rc = fcntl(fd, cmd, arg); - if (rc == -1) { - printf("fcntl SETFL %ld failed: %s\n", - arg, strerror(errno)); - EXIT(1); - } - break; - case F_GETLK: -#ifdef F_GETLK64 -#if F_GETLK64 != F_GETLK - case F_GETLK64: -#endif -#endif - case F_SETLK: -#ifdef F_SETLK64 -#if F_SETLK64 != F_SETLK - case F_SETLK64: -#endif -#endif - case F_SETLKW: -#ifdef F_SETLKW64 -#if F_SETLKW64 != F_SETLKW - case F_SETLKW64: -#endif -#endif - lock = va_arg(ap, struct flock *); - va_end(ap); - rc = fcntl(fd, cmd, lock); - if (rc == -1) { - printf("fcntl cmd %d failed: %s\n", - cmd, strerror(errno)); - EXIT(1); - } - break; - case F_DUPFD: - arg = va_arg(ap, long); - va_end(ap); - rc = fcntl(fd, cmd, arg); - if (rc == -1) { - printf("fcntl F_DUPFD %d failed: %s\n", - (int)arg, strerror(errno)); - EXIT(1); - } - break; - default: - va_end(ap); - printf("fcntl cmd %d not supported\n", cmd); - EXIT(1); - } - return rc; -} - -char *safe_strncpy(char *dst, char *src, int max_size) -{ - int src_size; - src_size=strlen(src); - if (src_size >= max_size) { - src_size=max_size-1; - } - memcpy(dst, src, src_size); - dst[src_size]=0; - - return(dst); -} diff --git a/lustre/liblustre/tests/test_common.h b/lustre/liblustre/tests/test_common.h deleted file mode 100644 index a4b0f4f..0000000 --- a/lustre/liblustre/tests/test_common.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * 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 version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - */ - -#ifndef __TEST_COMMON__H -#define __TEST_COMMON__H - -#define ENV_LUSTRE_MNTPNT "LIBLUSTRE_MOUNT_POINT" -#define ENV_LUSTRE_MNTTGT "LIBLUSTRE_MOUNT_TARGET" -#define ENV_LUSTRE_TIMEOUT "LIBLUSTRE_TIMEOUT" -#define ENV_LUSTRE_DUMPFILE "LIBLUSTRE_DUMPFILE" - -extern int exit_on_err; - -#include /* for utimbuf */ - -void t_touch(const char *path); -void t_create(const char *path); -void t_link(const char *src, const char *dst); -void t_unlink(const char *path); -void t_mkdir(const char *path); -void t_rmdir(const char *path); -void t_symlink(const char *src, const char *new); -void t_mknod(const char *path, mode_t mode, int major, int minor); -void t_chmod_raw(const char *path, mode_t mode); -void t_chmod(const char *path, const char *format, ...); -void t_rename(const char *oldpath, const char *newpath); -int t_open_readonly(const char *path); -int t_open(const char *path); -int t_chdir(const char *path); -int t_utime(const char *path, const struct utimbuf *buf); -int t_opendir(const char *path); -void t_close(int fd); -int t_check_stat(const char *name, struct stat *buf); -int t_check_stat_fail(const char *name); -void t_echo_create(const char *path, const char *str); -void t_grep(const char *path, char *str); -void t_grep_v(const char *path, char *str); -void t_ls(int fd, char *buf, int size); -int t_fcntl(int fd, int cmd, ...); - -char *safe_strncpy(char *dst, char *src, int max_size); - -#endif diff --git a/lustre/tests/Makefile.am b/lustre/tests/Makefile.am index fb1154d..7f6c3a4 100644 --- a/lustre/tests/Makefile.am +++ b/lustre/tests/Makefile.am @@ -29,7 +29,7 @@ noinst_SCRIPTS += sanity-krb5.sh krb5_login.sh setup_kerberos.sh noinst_SCRIPTS += recovery-mds-scale.sh run_dd.sh run_tar.sh run_iozone.sh noinst_SCRIPTS += run_dbench.sh run_IOR.sh recovery-double-scale.sh noinst_SCRIPTS += recovery-random-scale.sh parallel-scale.sh metadata-updates.sh -noinst_SCRIPTS += lustre-rsync-test.sh ost-pools.sh rpc.sh yaml.sh liblustre.sh +noinst_SCRIPTS += lustre-rsync-test.sh ost-pools.sh rpc.sh yaml.sh noinst_SCRIPTS += lnet-selftest.sh obdfilter-survey.sh mmp.sh mmp_mark.sh noinst_SCRIPTS += sgpdd-survey.sh maloo_upload.sh auster setup-nfs.sh noinst_SCRIPTS += mds-survey.sh parallel-scale-nfs.sh large-lun.sh diff --git a/lustre/tests/liblustre.sh b/lustre/tests/liblustre.sh deleted file mode 100644 index 0309b33..0000000 --- a/lustre/tests/liblustre.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash -# -#set -vx - -set -e - -LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)} -. $LUSTRE/tests/test-framework.sh -init_test_env $@ -. ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh} -init_logging - -LIBLUSTRETESTS=${LIBLUSTRETESTS:-$LUSTRE/liblustre/tests} - -assert_env MGSNID MOUNT2 -export LIBLUSTRE_MOUNT_POINT=$MOUNT2 -export LIBLUSTRE_MOUNT_RETRY=5 -export LIBLUSTRE_MOUNT_TARGET=$MGSNID:/$FSNAME -export LIBLUSTRE_TIMEOUT=`lctl get_param -n timeout` -#export LIBLUSTRE_DEBUG_MASK=`lctl get_param -n debug` - -test_1() { - if ! check_versions; then - skip "liblustre version mismatch: cli $(lustre_version_code client), \ - mds $(lustre_version_code $SINGLEMDS), ost $(lustre_version_code ost1)" - elif ! [ "$NETTYPE" = "tcp" -o "$NETTYPE" = "ptl" ]; then - skip "NETTYPE=$NETTYPE unsupported for liblustre" - elif [ ! -x $LIBLUSTRETESTS/sanity ]; then - skip "$LIBLUSTRETESTS/sanity: not found" - else - mkdir -p $MOUNT2 - echo $LIBLUSTRETESTS/sanity --target=$LIBLUSTRE_MOUNT_TARGET - $LIBLUSTRETESTS/sanity --target=$LIBLUSTRE_MOUNT_TARGET - if [ "$LIBLUSTRE_EXCEPT" ]; then - LIBLUSTRE_OPT="$LIBLUSTRE_OPT \ - $(echo ' '$LIBLUSTRE_EXCEPT | sed -re 's/\s+/ -e /g')" - fi - echo $LIBLUSTRETESTS/sanity --target=$LIBLUSTRE_MOUNT_TARGET $LIBLUSTRE_OPT - $LIBLUSTRETESTS/sanity --target=$LIBLUSTRE_MOUNT_TARGET $LIBLUSTRE_OPT - fi -} -run_test 1 "liblustre sanity" - -complete $SECONDS -check_and_cleanup_lustre -exit_status -- 1.8.3.1