├── COPYING ├── ChangeLog ├── META ├── Makefile.am ├── Makefile.in ├── autogen.sh ├── config.h.in ├── config ├── config.guess ├── config.sub ├── deb.am ├── install-sh ├── ltmain.sh ├── lzfs-build.m4 ├── lzfs-meta.m4 ├── missing ├── rpm.am └── tgz.am ├── configure ├── configure.ac ├── debian ├── changelog ├── compat ├── control ├── copyright ├── dirs ├── docs ├── postinst ├── postrm ├── preinst ├── prerm └── rules ├── etc ├── Makefile.in ├── init.d │ ├── initd.debian │ └── initd.redhat └── zfs │ ├── zfs_config │ └── zfs_serial ├── include ├── Makefile.in ├── lzfs_exportfs.h ├── lzfs_inode.h ├── lzfs_snap.h └── lzfs_xattr.h ├── install-sh ├── ltmain.sh ├── lzfs.spec.in ├── lzfs_config.h ├── lzfs_config.h.in ├── module ├── Makefile.in ├── lzfs_exportfs.c ├── lzfs_snap.c ├── lzfs_super.c ├── lzfs_vnops.c ├── lzfs_xattr.c ├── lzfs_xattr_acl.c ├── lzfs_xattr_security.c └── lzfs_xattr_user.c └── usr ├── Makefile.in └── sbin ├── SystemReport.sh └── zfs_manage.py /COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | 2010-01-10 KQ Infotech 2 | - Downoad the source code from https://github.com/zfs-linux/lzfs. 3 | - Look at the META for the commit id 4 | - Do a checkout for that commit id. "git checkout " 5 | - Use the git commit logs for a full records of changes: 'git log' 6 | -------------------------------------------------------------------------------- /META: -------------------------------------------------------------------------------- 1 | Meta: 1 2 | Name: lzfs 3 | Branch: 1 4 | Version: 1.0 5 | Release: 1 6 | Release-Tags: relext 7 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | include $(top_srcdir)/config/rpm.am 2 | include ${top_srcdir}/config/deb.am 3 | include ${top_srcdir}/config/tgz.am 4 | 5 | USER_DIR = etc include usr 6 | KERNEL_DIR = module 7 | SUBDIRS = $(KERNEL_DIR) $(USER_DIR) 8 | 9 | AUTOMAKE_OPTIONS = foreign dist-zip 10 | EXTRA_DIST = autogen.sh lzfs.spec.in META ChangeLog COPYING 11 | EXTRA_DIST += config/rpm.am config/deb.am config/tgz.am 12 | noinst_HEADERS = lzfs_config.h 13 | 14 | distclean-local:: 15 | -$(RM) -R autom4te*.cache 16 | -find . \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS \ 17 | -o -name .pc -o -name .hg -o -name .git \) -prune -o \ 18 | \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ 19 | -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \ 20 | -o -name '.*.rej' -o -name 'aclocal.m4' -o -size 0 \ 21 | -o -name '*%' -o -name '.*.cmd' -o -name 'core' \ 22 | -o -name 'Makefile' -o -name '$(LINUX_SYMBOLS)' \ 23 | -o -name '*.order' -o -name '*.markers' \) \ 24 | -type f -print | xargs $(RM) 25 | 26 | install-data-local: 27 | destname=lzfs-$(LZFS_META_VERSION)/$(LINUX_VERSION); \ 28 | instdest=$(DESTDIR)/${prefix}/src/$$destname; \ 29 | echo "${LZFS_META_VERSION}" >$$instdest/lzfs.release; \ 30 | for instfile in $(noinst_HEADERS) module/$(LINUX_SYMBOLS); do \ 31 | $(INSTALL) -D $$instfile $$instdest/$$instfile; \ 32 | done 33 | 34 | ctags: 35 | $(RM) $(top_srcdir)/tags 36 | find $(top_srcdir) -name .git -prune -o -name '*.[hc]' | xargs ctags 37 | 38 | etags: 39 | $(RM) $(top_srcdir)/TAGS 40 | find $(top_srcdir) -name .pc -prune -o -name '*.[hc]' | xargs etags -a 41 | 42 | tags: ctags etags 43 | 44 | pkg: @DEFAULT_PACKAGE@ 45 | pkg-modules: @DEFAULT_PACKAGE@-modules 46 | pkg-utils: @DEFAULT_PACKAGE@-utils 47 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | aclocal -I config 4 | libtoolize --automake --copy 5 | autoheader 6 | automake --add-missing --include-deps --copy 7 | autoconf 8 | rm -rf autom4te.cache aclocal.m4 9 | -------------------------------------------------------------------------------- /config.h.in: -------------------------------------------------------------------------------- 1 | /* config.h.in. Generated from configure.ac by autoheader. */ 2 | 3 | /* Define to 1 if you have the `bzero' function. */ 4 | #undef HAVE_BZERO 5 | 6 | /* Define to 1 if you have the header file. */ 7 | #undef HAVE_INTTYPES_H 8 | 9 | /* Define to 1 if you have the header file. */ 10 | #undef HAVE_MEMORY_H 11 | 12 | /* Define to 1 if you have the `memset' function. */ 13 | #undef HAVE_MEMSET 14 | 15 | /* Define to 1 if you have the header file. */ 16 | #undef HAVE_STDINT_H 17 | 18 | /* Define to 1 if you have the header file. */ 19 | #undef HAVE_STDLIB_H 20 | 21 | /* Define to 1 if you have the `strchr' function. */ 22 | #undef HAVE_STRCHR 23 | 24 | /* Define to 1 if you have the header file. */ 25 | #undef HAVE_STRINGS_H 26 | 27 | /* Define to 1 if you have the header file. */ 28 | #undef HAVE_STRING_H 29 | 30 | /* Define to 1 if you have the header file. */ 31 | #undef HAVE_SYS_MNTENT_H 32 | 33 | /* Define to 1 if you have the header file. */ 34 | #undef HAVE_SYS_STAT_H 35 | 36 | /* Define to 1 if you have the header file. */ 37 | #undef HAVE_SYS_TYPES_H 38 | 39 | /* Define to 1 if you have the header file. */ 40 | #undef HAVE_SYS_VFS_H 41 | 42 | /* Define to 1 if you have the header file. */ 43 | #undef HAVE_UNISTD_H 44 | 45 | /* Define to the address where bug reports for this package should be sent. */ 46 | #undef PACKAGE_BUGREPORT 47 | 48 | /* Define to the full name of this package. */ 49 | #undef PACKAGE_NAME 50 | 51 | /* Define to the full name and version of this package. */ 52 | #undef PACKAGE_STRING 53 | 54 | /* Define to the one symbol short name of this package. */ 55 | #undef PACKAGE_TARNAME 56 | 57 | /* Define to the version of this package. */ 58 | #undef PACKAGE_VERSION 59 | 60 | /* Define to 1 if you have the ANSI C header files. */ 61 | #undef STDC_HEADERS 62 | 63 | /* Define for Solaris 2.5.1 so the uint32_t typedef from , 64 | , or is not used. If the typedef were allowed, the 65 | #define below would cause a syntax error. */ 66 | #undef _UINT32_T 67 | 68 | /* Define for Solaris 2.5.1 so the uint64_t typedef from , 69 | , or is not used. If the typedef were allowed, the 70 | #define below would cause a syntax error. */ 71 | #undef _UINT64_T 72 | 73 | /* Define to `__inline__' or `__inline' if that's what the C compiler 74 | calls it, or to nothing if 'inline' is not supported under any name. */ 75 | #ifndef __cplusplus 76 | #undef inline 77 | #endif 78 | 79 | /* Define to `unsigned int' if does not define. */ 80 | #undef size_t 81 | 82 | /* Define to `int' if does not define. */ 83 | #undef ssize_t 84 | 85 | /* Define to the type of an unsigned integer type of width exactly 32 bits if 86 | such a type exists and the standard includes do not define it. */ 87 | #undef uint32_t 88 | 89 | /* Define to the type of an unsigned integer type of width exactly 64 bits if 90 | such a type exists and the standard includes do not define it. */ 91 | #undef uint64_t 92 | -------------------------------------------------------------------------------- /config/deb.am: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (C) 2010 Lawrence Livermore National Security, LLC. 3 | # Written by Brian Behlendorf . 4 | ############################################################################### 5 | # Build targets for DEB packages. 6 | # 7 | # Long term native distro specific Debian style packaging should be added. 8 | # In the short term RPM packages are built and converted to DEB packages 9 | # using alien. If someone familiar with Debian style packaging were to 10 | # update the build system to correctly build Debian style packages I would 11 | # happily take it. Until then we will have to make due with alien. 12 | # 13 | ############################################################################### 14 | 15 | deb-local: 16 | @(if test "${HAVE_DPKGBUILD}" = "no"; then \ 17 | echo -e "\n" \ 18 | "*** Required util ${DPKGBUILD} missing. Please install the\n" \ 19 | "*** package for your distribution which provides ${DPKGBUILD},\n" \ 20 | "*** re-run configure, and try again.\n"; \ 21 | exit 1; \ 22 | fi; \ 23 | if test "${HAVE_ALIEN}" = "no"; then \ 24 | echo -e "\n" \ 25 | "*** Required util ${ALIEN} missing. Please install the\n" \ 26 | "*** package for your distribution which provides ${ALIEN},\n" \ 27 | "*** re-run configure, and try again.\n"; \ 28 | exit 1; \ 29 | fi) 30 | 31 | deb-utils: deb-local rpm-utils 32 | name=${PACKAGE}; \ 33 | version=${LZFS_META_VERSION}-${LZFS_META_RELEASE}; \ 34 | release=`echo ${LINUX_VERSION} | sed -e "s/-/_/g"`; \ 35 | arch=`$(RPM) -qp $${name}-$${version}.src.rpm --qf %{arch}`; \ 36 | pkg1=$${name}-$${version}_$${release}.$${arch}.rpm; \ 37 | fakeroot $(ALIEN) --scripts --to-deb $$pkg1; \ 38 | $(RM) $$pkg1 39 | 40 | deb: deb-utils 41 | -------------------------------------------------------------------------------- /config/install-sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # install - install a program, script, or datafile 3 | 4 | scriptversion=2009-04-28.21; # UTC 5 | 6 | # This originates from X11R5 (mit/util/scripts/install.sh), which was 7 | # later released in X11R6 (xc/config/util/install.sh) with the 8 | # following copyright and license. 9 | # 10 | # Copyright (C) 1994 X Consortium 11 | # 12 | # Permission is hereby granted, free of charge, to any person obtaining a copy 13 | # of this software and associated documentation files (the "Software"), to 14 | # deal in the Software without restriction, including without limitation the 15 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 16 | # sell copies of the Software, and to permit persons to whom the Software is 17 | # furnished to do so, subject to the following conditions: 18 | # 19 | # The above copyright notice and this permission notice shall be included in 20 | # all copies or substantial portions of the Software. 21 | # 22 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 26 | # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- 27 | # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | # 29 | # Except as contained in this notice, the name of the X Consortium shall not 30 | # be used in advertising or otherwise to promote the sale, use or other deal- 31 | # ings in this Software without prior written authorization from the X Consor- 32 | # tium. 33 | # 34 | # 35 | # FSF changes to this file are in the public domain. 36 | # 37 | # Calling this script install-sh is preferred over install.sh, to prevent 38 | # `make' implicit rules from creating a file called install from it 39 | # when there is no Makefile. 40 | # 41 | # This script is compatible with the BSD install script, but was written 42 | # from scratch. 43 | 44 | nl=' 45 | ' 46 | IFS=" "" $nl" 47 | 48 | # set DOITPROG to echo to test this script 49 | 50 | # Don't use :- since 4.3BSD and earlier shells don't like it. 51 | doit=${DOITPROG-} 52 | if test -z "$doit"; then 53 | doit_exec=exec 54 | else 55 | doit_exec=$doit 56 | fi 57 | 58 | # Put in absolute file names if you don't have them in your path; 59 | # or use environment vars. 60 | 61 | chgrpprog=${CHGRPPROG-chgrp} 62 | chmodprog=${CHMODPROG-chmod} 63 | chownprog=${CHOWNPROG-chown} 64 | cmpprog=${CMPPROG-cmp} 65 | cpprog=${CPPROG-cp} 66 | mkdirprog=${MKDIRPROG-mkdir} 67 | mvprog=${MVPROG-mv} 68 | rmprog=${RMPROG-rm} 69 | stripprog=${STRIPPROG-strip} 70 | 71 | posix_glob='?' 72 | initialize_posix_glob=' 73 | test "$posix_glob" != "?" || { 74 | if (set -f) 2>/dev/null; then 75 | posix_glob= 76 | else 77 | posix_glob=: 78 | fi 79 | } 80 | ' 81 | 82 | posix_mkdir= 83 | 84 | # Desired mode of installed file. 85 | mode=0755 86 | 87 | chgrpcmd= 88 | chmodcmd=$chmodprog 89 | chowncmd= 90 | mvcmd=$mvprog 91 | rmcmd="$rmprog -f" 92 | stripcmd= 93 | 94 | src= 95 | dst= 96 | dir_arg= 97 | dst_arg= 98 | 99 | copy_on_change=false 100 | no_target_directory= 101 | 102 | usage="\ 103 | Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE 104 | or: $0 [OPTION]... SRCFILES... DIRECTORY 105 | or: $0 [OPTION]... -t DIRECTORY SRCFILES... 106 | or: $0 [OPTION]... -d DIRECTORIES... 107 | 108 | In the 1st form, copy SRCFILE to DSTFILE. 109 | In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. 110 | In the 4th, create DIRECTORIES. 111 | 112 | Options: 113 | --help display this help and exit. 114 | --version display version info and exit. 115 | 116 | -c (ignored) 117 | -C install only if different (preserve the last data modification time) 118 | -d create directories instead of installing files. 119 | -g GROUP $chgrpprog installed files to GROUP. 120 | -m MODE $chmodprog installed files to MODE. 121 | -o USER $chownprog installed files to USER. 122 | -s $stripprog installed files. 123 | -t DIRECTORY install into DIRECTORY. 124 | -T report an error if DSTFILE is a directory. 125 | 126 | Environment variables override the default commands: 127 | CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG 128 | RMPROG STRIPPROG 129 | " 130 | 131 | while test $# -ne 0; do 132 | case $1 in 133 | -c) ;; 134 | 135 | -C) copy_on_change=true;; 136 | 137 | -d) dir_arg=true;; 138 | 139 | -g) chgrpcmd="$chgrpprog $2" 140 | shift;; 141 | 142 | --help) echo "$usage"; exit $?;; 143 | 144 | -m) mode=$2 145 | case $mode in 146 | *' '* | *' '* | *' 147 | '* | *'*'* | *'?'* | *'['*) 148 | echo "$0: invalid mode: $mode" >&2 149 | exit 1;; 150 | esac 151 | shift;; 152 | 153 | -o) chowncmd="$chownprog $2" 154 | shift;; 155 | 156 | -s) stripcmd=$stripprog;; 157 | 158 | -t) dst_arg=$2 159 | shift;; 160 | 161 | -T) no_target_directory=true;; 162 | 163 | --version) echo "$0 $scriptversion"; exit $?;; 164 | 165 | --) shift 166 | break;; 167 | 168 | -*) echo "$0: invalid option: $1" >&2 169 | exit 1;; 170 | 171 | *) break;; 172 | esac 173 | shift 174 | done 175 | 176 | if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then 177 | # When -d is used, all remaining arguments are directories to create. 178 | # When -t is used, the destination is already specified. 179 | # Otherwise, the last argument is the destination. Remove it from $@. 180 | for arg 181 | do 182 | if test -n "$dst_arg"; then 183 | # $@ is not empty: it contains at least $arg. 184 | set fnord "$@" "$dst_arg" 185 | shift # fnord 186 | fi 187 | shift # arg 188 | dst_arg=$arg 189 | done 190 | fi 191 | 192 | if test $# -eq 0; then 193 | if test -z "$dir_arg"; then 194 | echo "$0: no input file specified." >&2 195 | exit 1 196 | fi 197 | # It's OK to call `install-sh -d' without argument. 198 | # This can happen when creating conditional directories. 199 | exit 0 200 | fi 201 | 202 | if test -z "$dir_arg"; then 203 | trap '(exit $?); exit' 1 2 13 15 204 | 205 | # Set umask so as not to create temps with too-generous modes. 206 | # However, 'strip' requires both read and write access to temps. 207 | case $mode in 208 | # Optimize common cases. 209 | *644) cp_umask=133;; 210 | *755) cp_umask=22;; 211 | 212 | *[0-7]) 213 | if test -z "$stripcmd"; then 214 | u_plus_rw= 215 | else 216 | u_plus_rw='% 200' 217 | fi 218 | cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; 219 | *) 220 | if test -z "$stripcmd"; then 221 | u_plus_rw= 222 | else 223 | u_plus_rw=,u+rw 224 | fi 225 | cp_umask=$mode$u_plus_rw;; 226 | esac 227 | fi 228 | 229 | for src 230 | do 231 | # Protect names starting with `-'. 232 | case $src in 233 | -*) src=./$src;; 234 | esac 235 | 236 | if test -n "$dir_arg"; then 237 | dst=$src 238 | dstdir=$dst 239 | test -d "$dstdir" 240 | dstdir_status=$? 241 | else 242 | 243 | # Waiting for this to be detected by the "$cpprog $src $dsttmp" command 244 | # might cause directories to be created, which would be especially bad 245 | # if $src (and thus $dsttmp) contains '*'. 246 | if test ! -f "$src" && test ! -d "$src"; then 247 | echo "$0: $src does not exist." >&2 248 | exit 1 249 | fi 250 | 251 | if test -z "$dst_arg"; then 252 | echo "$0: no destination specified." >&2 253 | exit 1 254 | fi 255 | 256 | dst=$dst_arg 257 | # Protect names starting with `-'. 258 | case $dst in 259 | -*) dst=./$dst;; 260 | esac 261 | 262 | # If destination is a directory, append the input filename; won't work 263 | # if double slashes aren't ignored. 264 | if test -d "$dst"; then 265 | if test -n "$no_target_directory"; then 266 | echo "$0: $dst_arg: Is a directory" >&2 267 | exit 1 268 | fi 269 | dstdir=$dst 270 | dst=$dstdir/`basename "$src"` 271 | dstdir_status=0 272 | else 273 | # Prefer dirname, but fall back on a substitute if dirname fails. 274 | dstdir=` 275 | (dirname "$dst") 2>/dev/null || 276 | expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ 277 | X"$dst" : 'X\(//\)[^/]' \| \ 278 | X"$dst" : 'X\(//\)$' \| \ 279 | X"$dst" : 'X\(/\)' \| . 2>/dev/null || 280 | echo X"$dst" | 281 | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ 282 | s//\1/ 283 | q 284 | } 285 | /^X\(\/\/\)[^/].*/{ 286 | s//\1/ 287 | q 288 | } 289 | /^X\(\/\/\)$/{ 290 | s//\1/ 291 | q 292 | } 293 | /^X\(\/\).*/{ 294 | s//\1/ 295 | q 296 | } 297 | s/.*/./; q' 298 | ` 299 | 300 | test -d "$dstdir" 301 | dstdir_status=$? 302 | fi 303 | fi 304 | 305 | obsolete_mkdir_used=false 306 | 307 | if test $dstdir_status != 0; then 308 | case $posix_mkdir in 309 | '') 310 | # Create intermediate dirs using mode 755 as modified by the umask. 311 | # This is like FreeBSD 'install' as of 1997-10-28. 312 | umask=`umask` 313 | case $stripcmd.$umask in 314 | # Optimize common cases. 315 | *[2367][2367]) mkdir_umask=$umask;; 316 | .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; 317 | 318 | *[0-7]) 319 | mkdir_umask=`expr $umask + 22 \ 320 | - $umask % 100 % 40 + $umask % 20 \ 321 | - $umask % 10 % 4 + $umask % 2 322 | `;; 323 | *) mkdir_umask=$umask,go-w;; 324 | esac 325 | 326 | # With -d, create the new directory with the user-specified mode. 327 | # Otherwise, rely on $mkdir_umask. 328 | if test -n "$dir_arg"; then 329 | mkdir_mode=-m$mode 330 | else 331 | mkdir_mode= 332 | fi 333 | 334 | posix_mkdir=false 335 | case $umask in 336 | *[123567][0-7][0-7]) 337 | # POSIX mkdir -p sets u+wx bits regardless of umask, which 338 | # is incompatible with FreeBSD 'install' when (umask & 300) != 0. 339 | ;; 340 | *) 341 | tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ 342 | trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 343 | 344 | if (umask $mkdir_umask && 345 | exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 346 | then 347 | if test -z "$dir_arg" || { 348 | # Check for POSIX incompatibilities with -m. 349 | # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or 350 | # other-writeable bit of parent directory when it shouldn't. 351 | # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. 352 | ls_ld_tmpdir=`ls -ld "$tmpdir"` 353 | case $ls_ld_tmpdir in 354 | d????-?r-*) different_mode=700;; 355 | d????-?--*) different_mode=755;; 356 | *) false;; 357 | esac && 358 | $mkdirprog -m$different_mode -p -- "$tmpdir" && { 359 | ls_ld_tmpdir_1=`ls -ld "$tmpdir"` 360 | test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" 361 | } 362 | } 363 | then posix_mkdir=: 364 | fi 365 | rmdir "$tmpdir/d" "$tmpdir" 366 | else 367 | # Remove any dirs left behind by ancient mkdir implementations. 368 | rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null 369 | fi 370 | trap '' 0;; 371 | esac;; 372 | esac 373 | 374 | if 375 | $posix_mkdir && ( 376 | umask $mkdir_umask && 377 | $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" 378 | ) 379 | then : 380 | else 381 | 382 | # The umask is ridiculous, or mkdir does not conform to POSIX, 383 | # or it failed possibly due to a race condition. Create the 384 | # directory the slow way, step by step, checking for races as we go. 385 | 386 | case $dstdir in 387 | /*) prefix='/';; 388 | -*) prefix='./';; 389 | *) prefix='';; 390 | esac 391 | 392 | eval "$initialize_posix_glob" 393 | 394 | oIFS=$IFS 395 | IFS=/ 396 | $posix_glob set -f 397 | set fnord $dstdir 398 | shift 399 | $posix_glob set +f 400 | IFS=$oIFS 401 | 402 | prefixes= 403 | 404 | for d 405 | do 406 | test -z "$d" && continue 407 | 408 | prefix=$prefix$d 409 | if test -d "$prefix"; then 410 | prefixes= 411 | else 412 | if $posix_mkdir; then 413 | (umask=$mkdir_umask && 414 | $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break 415 | # Don't fail if two instances are running concurrently. 416 | test -d "$prefix" || exit 1 417 | else 418 | case $prefix in 419 | *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; 420 | *) qprefix=$prefix;; 421 | esac 422 | prefixes="$prefixes '$qprefix'" 423 | fi 424 | fi 425 | prefix=$prefix/ 426 | done 427 | 428 | if test -n "$prefixes"; then 429 | # Don't fail if two instances are running concurrently. 430 | (umask $mkdir_umask && 431 | eval "\$doit_exec \$mkdirprog $prefixes") || 432 | test -d "$dstdir" || exit 1 433 | obsolete_mkdir_used=true 434 | fi 435 | fi 436 | fi 437 | 438 | if test -n "$dir_arg"; then 439 | { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && 440 | { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && 441 | { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || 442 | test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 443 | else 444 | 445 | # Make a couple of temp file names in the proper directory. 446 | dsttmp=$dstdir/_inst.$$_ 447 | rmtmp=$dstdir/_rm.$$_ 448 | 449 | # Trap to clean up those temp files at exit. 450 | trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 451 | 452 | # Copy the file name to the temp name. 453 | (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && 454 | 455 | # and set any options; do chmod last to preserve setuid bits. 456 | # 457 | # If any of these fail, we abort the whole thing. If we want to 458 | # ignore errors from any of these, just make sure not to ignore 459 | # errors from the above "$doit $cpprog $src $dsttmp" command. 460 | # 461 | { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && 462 | { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && 463 | { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && 464 | { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && 465 | 466 | # If -C, don't bother to copy if it wouldn't change the file. 467 | if $copy_on_change && 468 | old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && 469 | new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && 470 | 471 | eval "$initialize_posix_glob" && 472 | $posix_glob set -f && 473 | set X $old && old=:$2:$4:$5:$6 && 474 | set X $new && new=:$2:$4:$5:$6 && 475 | $posix_glob set +f && 476 | 477 | test "$old" = "$new" && 478 | $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 479 | then 480 | rm -f "$dsttmp" 481 | else 482 | # Rename the file to the real destination. 483 | $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || 484 | 485 | # The rename failed, perhaps because mv can't rename something else 486 | # to itself, or perhaps because mv is so ancient that it does not 487 | # support -f. 488 | { 489 | # Now remove or move aside any old file at destination location. 490 | # We try this two ways since rm can't unlink itself on some 491 | # systems and the destination file might be busy for other 492 | # reasons. In this case, the final cleanup might fail but the new 493 | # file should still install successfully. 494 | { 495 | test ! -f "$dst" || 496 | $doit $rmcmd -f "$dst" 2>/dev/null || 497 | { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && 498 | { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } 499 | } || 500 | { echo "$0: cannot unlink or rename $dst" >&2 501 | (exit 1); exit 1 502 | } 503 | } && 504 | 505 | # Now rename the file to the real destination. 506 | $doit $mvcmd "$dsttmp" "$dst" 507 | } 508 | fi || exit 1 509 | 510 | trap '' 0 511 | fi 512 | done 513 | 514 | # Local variables: 515 | # eval: (add-hook 'write-file-hooks 'time-stamp) 516 | # time-stamp-start: "scriptversion=" 517 | # time-stamp-format: "%:y-%02m-%02d.%02H" 518 | # time-stamp-time-zone: "UTC" 519 | # time-stamp-end: "; # UTC" 520 | # End: 521 | -------------------------------------------------------------------------------- /config/lzfs-build.m4: -------------------------------------------------------------------------------- 1 | 2 | dnl # 3 | dnl # Default LZFS kernel configuration 4 | dnl # 5 | AC_DEFUN([LZFS_AC_CONFIG_KERNEL], [ 6 | LZFS_AC_KERNEL 7 | LZFS_AC_SPL 8 | LZFS_AC_ZFS 9 | dnl # Kernel build make options 10 | dnl # KERNELMAKE_PARAMS="V=1" # Enable verbose module build 11 | KERNELMAKE_PARAMS="V=1" 12 | 13 | dnl # -Wall -fno-strict-aliasing -Wstrict-prototypes and other 14 | dnl # compiler options are added by the kernel build system. 15 | KERNELCPPFLAGS="$KERNELCPPFLAGS -DHAVE_GPL_ONLY_SYMBOLS -Wstrict-prototypes -Werror" 16 | KERNELCPPFLAGS="$KERNELCPPFLAGS -I$SPL -I$SPL/include" 17 | 18 | if test "$LINUX_OBJ" != "$LINUX"; then 19 | KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ" 20 | fi 21 | 22 | AC_SUBST(KERNELMAKE_PARAMS) 23 | AC_SUBST(KERNELCPPFLAGS) 24 | ]) 25 | 26 | 27 | dnl # 28 | dnl # Detect name used for Module.symvers file in kernel 29 | dnl # 30 | AC_DEFUN([LZFS_AC_MODULE_SYMVERS], [ 31 | modpost=$LINUX/scripts/Makefile.modpost 32 | AC_MSG_CHECKING([kernel file name for module symbols]) 33 | if test -f "$modpost"; then 34 | if grep -q Modules.symvers $modpost; then 35 | LINUX_SYMBOLS=Modules.symvers 36 | else 37 | LINUX_SYMBOLS=Module.symvers 38 | fi 39 | else 40 | LINUX_SYMBOLS=NONE 41 | fi 42 | AC_MSG_RESULT($LINUX_SYMBOLS) 43 | AC_SUBST(LINUX_SYMBOLS) 44 | ]) 45 | 46 | dnl # 47 | dnl # Detect the kernel to be built against 48 | dnl # 49 | AC_DEFUN([LZFS_AC_KERNEL], [ 50 | AC_ARG_WITH([linux], 51 | AS_HELP_STRING([--with-linux=PATH], 52 | [Path to kernel source]), 53 | [kernelsrc="$withval"]) 54 | 55 | AC_ARG_WITH(linux-obj, 56 | AS_HELP_STRING([--with-linux-obj=PATH], 57 | [Path to kernel build objects]), 58 | [kernelbuild="$withval"]) 59 | 60 | AC_MSG_CHECKING([kernel source directory]) 61 | if test -z "$kernelsrc"; then 62 | headersdir="/lib/modules/$(uname -r)/build" 63 | if test -e "$headersdir"; then 64 | sourcelink=$(readlink -f "$headersdir") 65 | else 66 | sourcelink=$(ls -1d /usr/src/kernels/* \ 67 | /usr/src/linux-* \ 68 | 2>/dev/null | grep -v obj | tail -1) 69 | fi 70 | 71 | if test -n "$sourcelink" && test -e ${sourcelink}; then 72 | kernelsrc=`readlink -f ${sourcelink}` 73 | else 74 | AC_MSG_RESULT([Not found]) 75 | AC_MSG_ERROR([ 76 | *** Please make sure the kernel devel package for your distribution 77 | *** is installed then try again. If that fails you can specify the 78 | *** location of the kernel source with the '--with-linux=PATH' option.]) 79 | fi 80 | else 81 | if test "$kernelsrc" = "NONE"; then 82 | kernsrcver=NONE 83 | fi 84 | fi 85 | 86 | AC_MSG_RESULT([$kernelsrc]) 87 | AC_MSG_CHECKING([kernel build directory]) 88 | if test -z "$kernelbuild"; then 89 | if test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then 90 | kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu} 91 | elif test -d ${kernelsrc}-obj/${target_cpu}/default; then 92 | kernelbuild=${kernelsrc}-obj/${target_cpu}/default 93 | elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then 94 | kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu} 95 | else 96 | kernelbuild=${kernelsrc} 97 | fi 98 | fi 99 | AC_MSG_RESULT([$kernelbuild]) 100 | 101 | AC_MSG_CHECKING([kernel source version]) 102 | utsrelease1=$kernelbuild/include/linux/version.h 103 | utsrelease2=$kernelbuild/include/linux/utsrelease.h 104 | utsrelease3=$kernelbuild/include/generated/utsrelease.h 105 | if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then 106 | utsrelease=linux/version.h 107 | elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then 108 | utsrelease=linux/utsrelease.h 109 | elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then 110 | utsrelease=generated/utsrelease.h 111 | fi 112 | 113 | if test "$utsrelease"; then 114 | kernsrcver=`(echo "#include <$utsrelease>"; 115 | echo "kernsrcver=UTS_RELEASE") | 116 | cpp -I $kernelbuild/include | 117 | grep "^kernsrcver=" | cut -d \" -f 2` 118 | 119 | if test -z "$kernsrcver"; then 120 | AC_MSG_RESULT([Not found]) 121 | AC_MSG_ERROR([*** Cannot determine kernel version.]) 122 | fi 123 | else 124 | AC_MSG_RESULT([Not found]) 125 | AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.]) 126 | fi 127 | 128 | AC_MSG_RESULT([$kernsrcver]) 129 | 130 | LINUX=${kernelsrc} 131 | LINUX_OBJ=${kernelbuild} 132 | LINUX_VERSION=${kernsrcver} 133 | 134 | AC_SUBST(LINUX) 135 | AC_SUBST(LINUX_OBJ) 136 | AC_SUBST(LINUX_VERSION) 137 | 138 | LZFS_AC_MODULE_SYMVERS 139 | ]) 140 | 141 | 142 | dnl # 143 | dnl # Detect name used for the additional SPL Module.symvers file. If one 144 | dnl # does not exist this is likely because the SPL has been configured 145 | dnl # but not built. To allow recursive builds a good guess is made as to 146 | dnl # what this file will be named based on what it is named in the kernel 147 | dnl # build products. This file will first be used at link time so if 148 | dnl # the guess is wrong the build will fail then. This unfortunately 149 | dnl # means the ZFS package does not contain a reliable mechanism to 150 | dnl # detect symbols exported by the SPL at configure time. 151 | dnl # 152 | AC_DEFUN([LZFS_AC_SPL_MODULE_SYMVERS], [ 153 | AC_MSG_CHECKING([spl file name for module symbols]) 154 | if test -r $SPL_OBJ/Module.symvers; then 155 | SPL_SYMBOLS=Module.symvers 156 | elif test -r $SPL_OBJ/Modules.symvers; then 157 | SPL_SYMBOLS=Modules.symvers 158 | elif test -r $SPL_OBJ/module/Module.symvers; then 159 | SPL_SYMBOLS=Module.symvers 160 | elif test -r $SPL_OBJ/module/Modules.symvers; then 161 | SPL_SYMBOLS=Modules.symvers 162 | else 163 | SPL_SYMBOLS=$LINUX_SYMBOLS 164 | fi 165 | 166 | AC_MSG_RESULT([$SPL_SYMBOLS]) 167 | AC_SUBST(SPL_SYMBOLS) 168 | ]) 169 | 170 | dnl # 171 | dnl # Detect the SPL module to be built against 172 | dnl # 173 | AC_DEFUN([LZFS_AC_SPL], [ 174 | AC_ARG_WITH([spl], 175 | AS_HELP_STRING([--with-spl=PATH], 176 | [Path to spl source]), 177 | [splsrc="$withval"]) 178 | 179 | AC_ARG_WITH([spl-obj], 180 | AS_HELP_STRING([--with-spl-obj=PATH], 181 | [Path to spl build objects]), 182 | [splbuild="$withval"]) 183 | 184 | 185 | AC_MSG_CHECKING([spl source directory]) 186 | if test -z "$splsrc"; then 187 | sourcelink=`ls -1d /usr/src/spl-*/${LINUX_VERSION} \ 188 | 2>/dev/null | tail -1` 189 | 190 | if test -z "$sourcelink" || test ! -e $sourcelink; then 191 | sourcelink=../spl 192 | fi 193 | 194 | if test -e $sourcelink; then 195 | splsrc=`readlink -f ${sourcelink}` 196 | else 197 | AC_MSG_RESULT([Not found]) 198 | AC_MSG_ERROR([ 199 | *** Please make sure the spl devel package for your distribution 200 | *** is installed then try again. If that fails you can specify the 201 | *** location of the spl source with the '--with-spl=PATH' option.]) 202 | fi 203 | else 204 | if test "$splsrc" = "NONE"; then 205 | splbuild=NONE 206 | splsrcver=NONE 207 | fi 208 | fi 209 | 210 | AC_MSG_RESULT([$splsrc]) 211 | AC_MSG_CHECKING([spl build directory]) 212 | if test -z "$splbuild"; then 213 | splbuild=${splsrc} 214 | fi 215 | AC_MSG_RESULT([$splbuild]) 216 | 217 | AC_MSG_CHECKING([spl source version]) 218 | if test -r $splbuild/spl_config.h && 219 | fgrep -q SPL_META_VERSION $splbuild/spl_config.h; then 220 | 221 | splsrcver=`(echo "#include "; 222 | echo "splsrcver=SPL_META_VERSION") | 223 | cpp -I $splbuild | 224 | grep "^splsrcver=" | cut -d \" -f 2` 225 | fi 226 | 227 | if test -z "$splsrcver"; then 228 | AC_MSG_RESULT([Not found]) 229 | AC_MSG_ERROR([ 230 | *** Cannot determine the version of the spl source. 231 | *** Please prepare the spl source before running this script]) 232 | fi 233 | 234 | AC_MSG_RESULT([$splsrcver]) 235 | 236 | SPL=${splsrc} 237 | SPL_OBJ=${splbuild} 238 | SPL_VERSION=${splsrcver} 239 | 240 | AC_SUBST(SPL) 241 | AC_SUBST(SPL_OBJ) 242 | AC_SUBST(SPL_VERSION) 243 | 244 | LZFS_AC_SPL_MODULE_SYMVERS 245 | ]) 246 | 247 | dnl # 248 | dnl # Detect name used for the additional ZFS Module.symvers file. If one 249 | dnl # does not exist this is likely because the ZFS has been configured 250 | dnl # but not built. To allow recursive builds a good guess is made as to 251 | dnl # what this file will be named based on what it is named in the kernel 252 | dnl # build products. This file will first be used at link time so if 253 | dnl # the guess is wrong the build will fail then. This unfortunately 254 | dnl # means the LZFS package does not contain a reliable mechanism to 255 | dnl # detect symbols exported by the ZFS at configure time. 256 | dnl # 257 | AC_DEFUN([LZFS_AC_ZFS_MODULE_SYMVERS], [ 258 | AC_MSG_CHECKING([zfs file name for module symbols]) 259 | if test -r $ZFS_OBJ/Module.symvers; then 260 | ZFS_SYMBOLS=Module.symvers 261 | elif test -r $ZFS_OBJ/Modules.symvers; then 262 | ZFS_SYMBOLS=Modules.symvers 263 | elif test -r $ZFS_OBJ/module/Module.symvers; then 264 | ZFS_SYMBOLS=Module.symvers 265 | elif test -r $ZFS_OBJ/module/Modules.symvers; then 266 | ZFS_SYMBOLS=Modules.symvers 267 | else 268 | ZFS_SYMBOLS=$LINUX_SYMBOLS 269 | fi 270 | 271 | AC_MSG_RESULT([$ZFS_SYMBOLS]) 272 | AC_SUBST(ZFS_SYMBOLS) 273 | ]) 274 | 275 | dnl # 276 | dnl # Detect the ZFS module to be built against 277 | dnl # 278 | AC_DEFUN([LZFS_AC_ZFS], [ 279 | AC_ARG_WITH([zfs], 280 | AS_HELP_STRING([--with-zfs=PATH], 281 | [Path to zfs source]), 282 | [zfssrc="$withval"]) 283 | 284 | AC_ARG_WITH([zfs-obj], 285 | AS_HELP_STRING([--with-zfs-obj=PATH], 286 | [Path to zfs build objects]), 287 | [zfsbuild="$withval"]) 288 | 289 | 290 | AC_MSG_CHECKING([zfs source directory]) 291 | if test -z "$zfssrc"; then 292 | sourcelink=`ls -1d /usr/src/zfs-*/${LINUX_VERSION} \ 293 | 2>/dev/null | tail -1` 294 | 295 | if test -z "$sourcelink" || test ! -e $sourcelink; then 296 | sourcelink=../zfs 297 | fi 298 | 299 | if test -e $sourcelink; then 300 | zfssrc=`readlink -f ${sourcelink}` 301 | else 302 | AC_MSG_RESULT([Not found]) 303 | AC_MSG_ERROR([ 304 | *** Please make sure the zfs devel package for your distribution 305 | *** is installed then try again. If that fails you can specify the 306 | *** location of the zfs source with the '--with-zfs=PATH' option.]) 307 | fi 308 | else 309 | if test "$zfssrc" = "NONE"; then 310 | zfsbuild=NONE 311 | zfssrcver=NONE 312 | fi 313 | fi 314 | 315 | AC_MSG_RESULT([$zfssrc]) 316 | AC_MSG_CHECKING([zfs build directory]) 317 | if test -z "$zfsbuild"; then 318 | zfsbuild=${zfssrc} 319 | fi 320 | AC_MSG_RESULT([$zfsbuild]) 321 | 322 | AC_MSG_CHECKING([zfs source version]) 323 | if test -r $zfsbuild/zfs_config.h && 324 | fgrep -q ZFS_META_VERSION $zfsbuild/zfs_config.h; then 325 | 326 | zfssrcver=`(echo "#include "; 327 | echo "zfssrcver=ZFS_META_VERSION") | 328 | cpp -I $zfsbuild | 329 | grep "^zfssrcver=" | cut -d \" -f 2` 330 | fi 331 | 332 | if test -z "$zfssrcver"; then 333 | AC_MSG_RESULT([Not found]) 334 | AC_MSG_ERROR([ 335 | *** Cannot determine the version of the zfs source. 336 | *** Please prepare the zfs source before running this script]) 337 | fi 338 | 339 | AC_MSG_RESULT([$zfssrcver]) 340 | 341 | ZFS=${zfssrc} 342 | ZFS_OBJ=${zfsbuild} 343 | ZFS_VERSION=${zfssrcver} 344 | 345 | AC_SUBST(ZFS) 346 | AC_SUBST(ZFS_OBJ) 347 | AC_SUBST(ZFS_VERSION) 348 | 349 | LZFS_AC_ZFS_MODULE_SYMVERS 350 | ]) 351 | dnl # 352 | dnl # Check for rpm+rpmbuild to build RPM packages. If these tools 353 | dnl # are missing it is non-fatal but you will not be able to build 354 | dnl # RPM packages and will be warned if you try too. 355 | dnl # 356 | AC_DEFUN([LZFS_AC_RPM], [ 357 | RPM=rpm 358 | RPMBUILD=rpmbuild 359 | 360 | AC_MSG_CHECKING([whether $RPM is available]) 361 | AS_IF([tmp=$($RPM --version 2>/dev/null)], [ 362 | RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }') 363 | HAVE_RPM=yes 364 | AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)]) 365 | ],[ 366 | HAVE_RPM=no 367 | AC_MSG_RESULT([$HAVE_RPM]) 368 | ]) 369 | 370 | AC_MSG_CHECKING([whether $RPMBUILD is available]) 371 | AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [ 372 | RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }') 373 | HAVE_RPMBUILD=yes 374 | AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)]) 375 | ],[ 376 | HAVE_RPMBUILD=no 377 | AC_MSG_RESULT([$HAVE_RPMBUILD]) 378 | ]) 379 | 380 | AC_SUBST(HAVE_RPM) 381 | AC_SUBST(RPM) 382 | AC_SUBST(RPM_VERSION) 383 | 384 | AC_SUBST(HAVE_RPMBUILD) 385 | AC_SUBST(RPMBUILD) 386 | AC_SUBST(RPMBUILD_VERSION) 387 | ]) 388 | 389 | dnl # 390 | dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these 391 | dnl # tools are missing it is non-fatal but you will not be able to build 392 | dnl # DEB packages and will be warned if you try too. 393 | dnl # 394 | AC_DEFUN([LZFS_AC_DPKG], [ 395 | DPKG=dpkg 396 | DPKGBUILD=dpkg-buildpackage 397 | 398 | AC_MSG_CHECKING([whether $DPKG is available]) 399 | AS_IF([tmp=$($DPKG --version 2>/dev/null)], [ 400 | DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }') 401 | HAVE_DPKG=yes 402 | AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)]) 403 | ],[ 404 | HAVE_DPKG=no 405 | AC_MSG_RESULT([$HAVE_DPKG]) 406 | ]) 407 | 408 | AC_MSG_CHECKING([whether $DPKGBUILD is available]) 409 | AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [ 410 | DPKGBUILD_VERSION=$(echo $tmp | \ 411 | $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.') 412 | HAVE_DPKGBUILD=yes 413 | AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)]) 414 | ],[ 415 | HAVE_DPKGBUILD=no 416 | AC_MSG_RESULT([$HAVE_DPKGBUILD]) 417 | ]) 418 | 419 | AC_SUBST(HAVE_DPKG) 420 | AC_SUBST(DPKG) 421 | AC_SUBST(DPKG_VERSION) 422 | 423 | AC_SUBST(HAVE_DPKGBUILD) 424 | AC_SUBST(DPKGBUILD) 425 | AC_SUBST(DPKGBUILD_VERSION) 426 | ]) 427 | 428 | dnl # 429 | dnl # Until native packaging for various different packing systems 430 | dnl # can be added the least we can do is attempt to use alien to 431 | dnl # convert the RPM packages to the needed package type. This is 432 | dnl # a hack but so far it has worked reasonable well. 433 | dnl # 434 | AC_DEFUN([LZFS_AC_ALIEN], [ 435 | ALIEN=alien 436 | 437 | AC_MSG_CHECKING([whether $ALIEN is available]) 438 | AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [ 439 | ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }') 440 | HAVE_ALIEN=yes 441 | AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)]) 442 | ],[ 443 | HAVE_ALIEN=no 444 | AC_MSG_RESULT([$HAVE_ALIEN]) 445 | ]) 446 | 447 | AC_SUBST(HAVE_ALIEN) 448 | AC_SUBST(ALIEN) 449 | AC_SUBST(ALIEN_VERSION) 450 | ]) 451 | 452 | dnl # 453 | dnl # Using the VENDOR tag from config.guess set the default 454 | dnl # package type for 'make pkg': (rpm | deb | tgz) 455 | dnl # 456 | AC_DEFUN([LZFS_AC_DEFAULT_PACKAGE], [ 457 | VENDOR=$(echo $ac_build_alias | cut -f2 -d'-') 458 | 459 | AC_MSG_CHECKING([default package type]) 460 | case "$VENDOR" in 461 | fedora) DEFAULT_PACKAGE=rpm ;; 462 | redhat) DEFAULT_PACKAGE=rpm ;; 463 | sles) DEFAULT_PACKAGE=rpm ;; 464 | ubuntu) DEFAULT_PACKAGE=deb ;; 465 | debian) DEFAULT_PACKAGE=deb ;; 466 | slackware) DEFAULT_PACKAGE=tgz ;; 467 | *) DEFAULT_PACKAGE=rpm ;; 468 | esac 469 | 470 | AC_MSG_RESULT([$DEFAULT_PACKAGE]) 471 | AC_SUBST(DEFAULT_PACKAGE) 472 | ]) 473 | 474 | dnl # 475 | dnl # Default ZFS package configuration 476 | dnl # 477 | AC_DEFUN([LZFS_AC_PACKAGE], [ 478 | LZFS_AC_RPM 479 | LZFS_AC_DPKG 480 | LZFS_AC_ALIEN 481 | LZFS_AC_DEFAULT_PACKAGE 482 | ]) 483 | -------------------------------------------------------------------------------- /config/lzfs-meta.m4: -------------------------------------------------------------------------------- 1 | dnl # 2 | dnl # LZFS_AC_META 3 | dnl # Read metadata from the META file. 4 | dnl # 5 | dnl # 6 | AC_DEFUN([LZFS_AC_META], [ 7 | AC_MSG_CHECKING([metadata]) 8 | 9 | META="$srcdir/META" 10 | _spl_ac_meta_got_file=no 11 | if test -f "$META"; then 12 | _spl_ac_meta_got_file=yes 13 | 14 | LZFS_META_NAME=_LZFS_AC_META_GETVAL([(?:NAME|PROJECT|PACKAGE)]); 15 | if test -n "$LZFS_META_NAME"; then 16 | AC_DEFINE_UNQUOTED([LZFS_META_NAME], ["$LZFS_META_NAME"], 17 | [Define the project name.] 18 | ) 19 | AC_SUBST([LZFS_META_NAME]) 20 | fi 21 | 22 | LZFS_META_VERSION=_LZFS_AC_META_GETVAL([VERSION]); 23 | if test -n "$LZFS_META_VERSION"; then 24 | AC_DEFINE_UNQUOTED([LZFS_META_VERSION], ["$LZFS_META_VERSION"], 25 | [Define the project version.] 26 | ) 27 | AC_SUBST([LZFS_META_VERSION]) 28 | fi 29 | 30 | LZFS_META_RELEASE=_LZFS_AC_META_GETVAL([RELEASE]); 31 | if test -n "$LZFS_META_RELEASE"; then 32 | AC_DEFINE_UNQUOTED([LZFS_META_RELEASE], ["$LZFS_META_RELEASE"], 33 | [Define the project release.] 34 | ) 35 | AC_SUBST([LZFS_META_RELEASE]) 36 | fi 37 | 38 | if test -n "$LZFS_META_NAME" -a -n "$LZFS_META_VERSION"; then 39 | LZFS_META_ALIAS="$LZFS_META_NAME-$SPL_META_VERSION" 40 | test -n "$LZFS_META_RELEASE" && 41 | LZFS_META_ALIAS="$LZFS_META_ALIAS-$SPL_META_RELEASE" 42 | AC_DEFINE_UNQUOTED([LZFS_META_ALIAS], 43 | ["$LZFS_META_ALIAS"], 44 | [Define the project alias string.] 45 | ) 46 | AC_SUBST([LZFS_META_ALIAS]) 47 | fi 48 | 49 | LZFS_META_DATA=_LZFS_AC_META_GETVAL([DATE]); 50 | if test -n "$LZFS_META_DATA"; then 51 | AC_DEFINE_UNQUOTED([LZFS_META_DATA], ["$LZFS_META_DATA"], 52 | [Define the project release date.] 53 | ) 54 | AC_SUBST([LZFS_META_DATA]) 55 | fi 56 | 57 | LZFS_META_AUTHOR=_LZFS_AC_META_GETVAL([AUTHOR]); 58 | if test -n "$LZFS_META_AUTHOR"; then 59 | AC_DEFINE_UNQUOTED([LZFS_META_AUTHOR], ["$LZFS_META_AUTHOR"], 60 | [Define the project author.] 61 | ) 62 | AC_SUBST([LZFS_META_AUTHOR]) 63 | fi 64 | 65 | m4_pattern_allow([^LT_(CURRENT|REVISION|AGE)$]) 66 | LZFS_META_LT_CURRENT=_LZFS_AC_META_GETVAL([LT_CURRENT]); 67 | LZFS_META_LT_REVISION=_LZFS_AC_META_GETVAL([LT_REVISION]); 68 | LZFS_META_LT_AGE=_LZFS_AC_META_GETVAL([LT_AGE]); 69 | if test -n "$LZFS_META_LT_CURRENT" \ 70 | -o -n "$LZFS_META_LT_REVISION" \ 71 | -o -n "$LZFS_META_LT_AGE"; then 72 | test -n "$LZFS_META_LT_CURRENT" || LZFS_META_LT_CURRENT="0" 73 | test -n "$LZFS_META_LT_REVISION" || LZFS_META_LT_REVISION="0" 74 | test -n "$LZFS_META_LT_AGE" || LZFS_META_LT_AGE="0" 75 | AC_DEFINE_UNQUOTED([LZFS_META_LT_CURRENT], 76 | ["$LZFS_META_LT_CURRENT"], 77 | [Define the libtool library 'current' 78 | version information.] 79 | ) 80 | AC_DEFINE_UNQUOTED([LZFS_META_LT_REVISION], 81 | ["$LZFS_META_LT_REVISION"], 82 | [Define the libtool library 'revision' 83 | version information.] 84 | ) 85 | AC_DEFINE_UNQUOTED([LZFS_META_LT_AGE], ["$LZFS_META_LT_AGE"], 86 | [Define the libtool library 'age' 87 | version information.] 88 | ) 89 | AC_SUBST([LZFS_META_LT_CURRENT]) 90 | AC_SUBST([LZFS_META_LT_REVISION]) 91 | AC_SUBST([LZFS_META_LT_AGE]) 92 | fi 93 | fi 94 | 95 | AC_MSG_RESULT([$_spl_ac_meta_got_file]) 96 | ] 97 | ) 98 | 99 | AC_DEFUN([_LZFS_AC_META_GETVAL], 100 | [`perl -n\ 101 | -e "BEGIN { \\$key=shift @ARGV; }"\ 102 | -e "next unless s/^\s*\\$key@<:@:=@:>@//i;"\ 103 | -e "s/^((?:@<:@^'\"#@:>@*(?:(@<:@'\"@:>@)@<:@^\2@:>@*\2)*)*)#.*/\\@S|@1/;"\ 104 | -e "s/^\s+//;"\ 105 | -e "s/\s+$//;"\ 106 | -e "s/^(@<:@'\"@:>@)(.*)\1/\\@S|@2/;"\ 107 | -e "\\$val=\\$_;"\ 108 | -e "END { print \\$val if defined \\$val; }"\ 109 | '$1' $META`]dnl 110 | ) 111 | -------------------------------------------------------------------------------- /config/missing: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # Common stub for a few missing GNU programs while installing. 3 | 4 | scriptversion=2009-04-28.21; # UTC 5 | 6 | # Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006, 7 | # 2008, 2009 Free Software Foundation, Inc. 8 | # Originally by Fran,cois Pinard , 1996. 9 | 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2, or (at your option) 13 | # any later version. 14 | 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | 20 | # You should have received a copy of the GNU General Public License 21 | # along with this program. If not, see . 22 | 23 | # As a special exception to the GNU General Public License, if you 24 | # distribute this file as part of a program that contains a 25 | # configuration script generated by Autoconf, you may include it under 26 | # the same distribution terms that you use for the rest of that program. 27 | 28 | if test $# -eq 0; then 29 | echo 1>&2 "Try \`$0 --help' for more information" 30 | exit 1 31 | fi 32 | 33 | run=: 34 | sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' 35 | sed_minuso='s/.* -o \([^ ]*\).*/\1/p' 36 | 37 | # In the cases where this matters, `missing' is being run in the 38 | # srcdir already. 39 | if test -f configure.ac; then 40 | configure_ac=configure.ac 41 | else 42 | configure_ac=configure.in 43 | fi 44 | 45 | msg="missing on your system" 46 | 47 | case $1 in 48 | --run) 49 | # Try to run requested program, and just exit if it succeeds. 50 | run= 51 | shift 52 | "$@" && exit 0 53 | # Exit code 63 means version mismatch. This often happens 54 | # when the user try to use an ancient version of a tool on 55 | # a file that requires a minimum version. In this case we 56 | # we should proceed has if the program had been absent, or 57 | # if --run hadn't been passed. 58 | if test $? = 63; then 59 | run=: 60 | msg="probably too old" 61 | fi 62 | ;; 63 | 64 | -h|--h|--he|--hel|--help) 65 | echo "\ 66 | $0 [OPTION]... PROGRAM [ARGUMENT]... 67 | 68 | Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an 69 | error status if there is no known handling for PROGRAM. 70 | 71 | Options: 72 | -h, --help display this help and exit 73 | -v, --version output version information and exit 74 | --run try to run the given command, and emulate it if it fails 75 | 76 | Supported PROGRAM values: 77 | aclocal touch file \`aclocal.m4' 78 | autoconf touch file \`configure' 79 | autoheader touch file \`config.h.in' 80 | autom4te touch the output file, or create a stub one 81 | automake touch all \`Makefile.in' files 82 | bison create \`y.tab.[ch]', if possible, from existing .[ch] 83 | flex create \`lex.yy.c', if possible, from existing .c 84 | help2man touch the output file 85 | lex create \`lex.yy.c', if possible, from existing .c 86 | makeinfo touch the output file 87 | tar try tar, gnutar, gtar, then tar without non-portable flags 88 | yacc create \`y.tab.[ch]', if possible, from existing .[ch] 89 | 90 | Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and 91 | \`g' are ignored when checking the name. 92 | 93 | Send bug reports to ." 94 | exit $? 95 | ;; 96 | 97 | -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 98 | echo "missing $scriptversion (GNU Automake)" 99 | exit $? 100 | ;; 101 | 102 | -*) 103 | echo 1>&2 "$0: Unknown \`$1' option" 104 | echo 1>&2 "Try \`$0 --help' for more information" 105 | exit 1 106 | ;; 107 | 108 | esac 109 | 110 | # normalize program name to check for. 111 | program=`echo "$1" | sed ' 112 | s/^gnu-//; t 113 | s/^gnu//; t 114 | s/^g//; t'` 115 | 116 | # Now exit if we have it, but it failed. Also exit now if we 117 | # don't have it and --version was passed (most likely to detect 118 | # the program). This is about non-GNU programs, so use $1 not 119 | # $program. 120 | case $1 in 121 | lex*|yacc*) 122 | # Not GNU programs, they don't have --version. 123 | ;; 124 | 125 | tar*) 126 | if test -n "$run"; then 127 | echo 1>&2 "ERROR: \`tar' requires --run" 128 | exit 1 129 | elif test "x$2" = "x--version" || test "x$2" = "x--help"; then 130 | exit 1 131 | fi 132 | ;; 133 | 134 | *) 135 | if test -z "$run" && ($1 --version) > /dev/null 2>&1; then 136 | # We have it, but it failed. 137 | exit 1 138 | elif test "x$2" = "x--version" || test "x$2" = "x--help"; then 139 | # Could not run --version or --help. This is probably someone 140 | # running `$TOOL --version' or `$TOOL --help' to check whether 141 | # $TOOL exists and not knowing $TOOL uses missing. 142 | exit 1 143 | fi 144 | ;; 145 | esac 146 | 147 | # If it does not exist, or fails to run (possibly an outdated version), 148 | # try to emulate it. 149 | case $program in 150 | aclocal*) 151 | echo 1>&2 "\ 152 | WARNING: \`$1' is $msg. You should only need it if 153 | you modified \`acinclude.m4' or \`${configure_ac}'. You might want 154 | to install the \`Automake' and \`Perl' packages. Grab them from 155 | any GNU archive site." 156 | touch aclocal.m4 157 | ;; 158 | 159 | autoconf*) 160 | echo 1>&2 "\ 161 | WARNING: \`$1' is $msg. You should only need it if 162 | you modified \`${configure_ac}'. You might want to install the 163 | \`Autoconf' and \`GNU m4' packages. Grab them from any GNU 164 | archive site." 165 | touch configure 166 | ;; 167 | 168 | autoheader*) 169 | echo 1>&2 "\ 170 | WARNING: \`$1' is $msg. You should only need it if 171 | you modified \`acconfig.h' or \`${configure_ac}'. You might want 172 | to install the \`Autoconf' and \`GNU m4' packages. Grab them 173 | from any GNU archive site." 174 | files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` 175 | test -z "$files" && files="config.h" 176 | touch_files= 177 | for f in $files; do 178 | case $f in 179 | *:*) touch_files="$touch_files "`echo "$f" | 180 | sed -e 's/^[^:]*://' -e 's/:.*//'`;; 181 | *) touch_files="$touch_files $f.in";; 182 | esac 183 | done 184 | touch $touch_files 185 | ;; 186 | 187 | automake*) 188 | echo 1>&2 "\ 189 | WARNING: \`$1' is $msg. You should only need it if 190 | you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. 191 | You might want to install the \`Automake' and \`Perl' packages. 192 | Grab them from any GNU archive site." 193 | find . -type f -name Makefile.am -print | 194 | sed 's/\.am$/.in/' | 195 | while read f; do touch "$f"; done 196 | ;; 197 | 198 | autom4te*) 199 | echo 1>&2 "\ 200 | WARNING: \`$1' is needed, but is $msg. 201 | You might have modified some files without having the 202 | proper tools for further handling them. 203 | You can get \`$1' as part of \`Autoconf' from any GNU 204 | archive site." 205 | 206 | file=`echo "$*" | sed -n "$sed_output"` 207 | test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` 208 | if test -f "$file"; then 209 | touch $file 210 | else 211 | test -z "$file" || exec >$file 212 | echo "#! /bin/sh" 213 | echo "# Created by GNU Automake missing as a replacement of" 214 | echo "# $ $@" 215 | echo "exit 0" 216 | chmod +x $file 217 | exit 1 218 | fi 219 | ;; 220 | 221 | bison*|yacc*) 222 | echo 1>&2 "\ 223 | WARNING: \`$1' $msg. You should only need it if 224 | you modified a \`.y' file. You may need the \`Bison' package 225 | in order for those modifications to take effect. You can get 226 | \`Bison' from any GNU archive site." 227 | rm -f y.tab.c y.tab.h 228 | if test $# -ne 1; then 229 | eval LASTARG="\${$#}" 230 | case $LASTARG in 231 | *.y) 232 | SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` 233 | if test -f "$SRCFILE"; then 234 | cp "$SRCFILE" y.tab.c 235 | fi 236 | SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` 237 | if test -f "$SRCFILE"; then 238 | cp "$SRCFILE" y.tab.h 239 | fi 240 | ;; 241 | esac 242 | fi 243 | if test ! -f y.tab.h; then 244 | echo >y.tab.h 245 | fi 246 | if test ! -f y.tab.c; then 247 | echo 'main() { return 0; }' >y.tab.c 248 | fi 249 | ;; 250 | 251 | lex*|flex*) 252 | echo 1>&2 "\ 253 | WARNING: \`$1' is $msg. You should only need it if 254 | you modified a \`.l' file. You may need the \`Flex' package 255 | in order for those modifications to take effect. You can get 256 | \`Flex' from any GNU archive site." 257 | rm -f lex.yy.c 258 | if test $# -ne 1; then 259 | eval LASTARG="\${$#}" 260 | case $LASTARG in 261 | *.l) 262 | SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` 263 | if test -f "$SRCFILE"; then 264 | cp "$SRCFILE" lex.yy.c 265 | fi 266 | ;; 267 | esac 268 | fi 269 | if test ! -f lex.yy.c; then 270 | echo 'main() { return 0; }' >lex.yy.c 271 | fi 272 | ;; 273 | 274 | help2man*) 275 | echo 1>&2 "\ 276 | WARNING: \`$1' is $msg. You should only need it if 277 | you modified a dependency of a manual page. You may need the 278 | \`Help2man' package in order for those modifications to take 279 | effect. You can get \`Help2man' from any GNU archive site." 280 | 281 | file=`echo "$*" | sed -n "$sed_output"` 282 | test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` 283 | if test -f "$file"; then 284 | touch $file 285 | else 286 | test -z "$file" || exec >$file 287 | echo ".ab help2man is required to generate this page" 288 | exit $? 289 | fi 290 | ;; 291 | 292 | makeinfo*) 293 | echo 1>&2 "\ 294 | WARNING: \`$1' is $msg. You should only need it if 295 | you modified a \`.texi' or \`.texinfo' file, or any other file 296 | indirectly affecting the aspect of the manual. The spurious 297 | call might also be the consequence of using a buggy \`make' (AIX, 298 | DU, IRIX). You might want to install the \`Texinfo' package or 299 | the \`GNU make' package. Grab either from any GNU archive site." 300 | # The file to touch is that specified with -o ... 301 | file=`echo "$*" | sed -n "$sed_output"` 302 | test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` 303 | if test -z "$file"; then 304 | # ... or it is the one specified with @setfilename ... 305 | infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` 306 | file=`sed -n ' 307 | /^@setfilename/{ 308 | s/.* \([^ ]*\) *$/\1/ 309 | p 310 | q 311 | }' $infile` 312 | # ... or it is derived from the source name (dir/f.texi becomes f.info) 313 | test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info 314 | fi 315 | # If the file does not exist, the user really needs makeinfo; 316 | # let's fail without touching anything. 317 | test -f $file || exit 1 318 | touch $file 319 | ;; 320 | 321 | tar*) 322 | shift 323 | 324 | # We have already tried tar in the generic part. 325 | # Look for gnutar/gtar before invocation to avoid ugly error 326 | # messages. 327 | if (gnutar --version > /dev/null 2>&1); then 328 | gnutar "$@" && exit 0 329 | fi 330 | if (gtar --version > /dev/null 2>&1); then 331 | gtar "$@" && exit 0 332 | fi 333 | firstarg="$1" 334 | if shift; then 335 | case $firstarg in 336 | *o*) 337 | firstarg=`echo "$firstarg" | sed s/o//` 338 | tar "$firstarg" "$@" && exit 0 339 | ;; 340 | esac 341 | case $firstarg in 342 | *h*) 343 | firstarg=`echo "$firstarg" | sed s/h//` 344 | tar "$firstarg" "$@" && exit 0 345 | ;; 346 | esac 347 | fi 348 | 349 | echo 1>&2 "\ 350 | WARNING: I can't seem to be able to run \`tar' with the given arguments. 351 | You may want to install GNU tar or Free paxutils, or check the 352 | command line arguments." 353 | exit 1 354 | ;; 355 | 356 | *) 357 | echo 1>&2 "\ 358 | WARNING: \`$1' is needed, and is $msg. 359 | You might have modified some files without having the 360 | proper tools for further handling them. Check the \`README' file, 361 | it often tells you about the needed prerequisites for installing 362 | this package. You may also peek at any GNU archive site, in case 363 | some other package would contain this missing \`$1' program." 364 | exit 1 365 | ;; 366 | esac 367 | 368 | exit 0 369 | 370 | # Local variables: 371 | # eval: (add-hook 'write-file-hooks 'time-stamp) 372 | # time-stamp-start: "scriptversion=" 373 | # time-stamp-format: "%:y-%02m-%02d.%02H" 374 | # time-stamp-time-zone: "UTC" 375 | # time-stamp-end: "; # UTC" 376 | # End: 377 | -------------------------------------------------------------------------------- /config/rpm.am: -------------------------------------------------------------------------------- 1 | srpm-utils: 2 | $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}" srpm-common 3 | 4 | srpm: srpm-utils 5 | 6 | rpm-utils: srpm-utils 7 | $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}" rpm-common 8 | 9 | rpm: rpm-utils 10 | 11 | rpm-local: 12 | @(if test "${HAVE_RPMBUILD}" = "no"; then \ 13 | echo -e "\n" \ 14 | "*** Required util ${RPMBUILD} missing. Please install the\n" \ 15 | "*** package for your distribution which provides ${RPMBUILD},\n" \ 16 | "*** re-run configure, and try again.\n"; \ 17 | exit 1; \ 18 | fi; \ 19 | mkdir -p $(rpmbuild)/TMP && \ 20 | mkdir -p $(rpmbuild)/BUILD && \ 21 | mkdir -p $(rpmbuild)/RPMS && \ 22 | mkdir -p $(rpmbuild)/SRPMS && \ 23 | mkdir -p $(rpmbuild)/SPECS && \ 24 | cp $(rpmspec) $(rpmbuild)/SPECS && \ 25 | mkdir -p $(rpmbuild)/SOURCES && \ 26 | cp $(distdir).tar.gz $(rpmbuild)/SOURCES) 27 | 28 | srpm-common: dist 29 | rpmpkg=$(pkg)-$(LZFS_META_VERSION)-$(LZFS_META_RELEASE).src.rpm; \ 30 | rpmspec=$(pkg).spec; \ 31 | rpmbuild=`mktemp -t -d $(PACKAGE)-build-$$USER-XXXXXXXX`; \ 32 | $(MAKE) $(AM_MAKEFLAGS) \ 33 | rpmbuild="$$rpmbuild" \ 34 | rpmspec="$$rpmspec" \ 35 | rpm-local || exit 1; \ 36 | /usr/bin/rpmbuild \ 37 | --define "_tmppath $$rpmbuild/TMP" \ 38 | --define "_topdir $$rpmbuild" \ 39 | --define "build_src_rpm 1" \ 40 | --define "dist %{nil}" \ 41 | --nodeps -bs $$rpmbuild/SPECS/$$rpmspec || exit 1; \ 42 | cp $$rpmbuild/SRPMS/$$rpmpkg . || exit 1; \ 43 | $(RM) -R $$rpmbuild 44 | 45 | rpm-common: 46 | rpmpkg=$(pkg)-$(LZFS_META_VERSION)-$(LZFS_META_RELEASE).src.rpm; \ 47 | rpmspec=$(pkg).spec; \ 48 | rpmbuild=`mktemp -t -d $(PACKAGE)-build-$$USER-XXXXXXXX`; \ 49 | $(MAKE) $(AM_MAKEFLAGS) \ 50 | rpmbuild="$$rpmbuild" \ 51 | rpmspec="$$rpmspec" \ 52 | rpm-local || exit 1; \ 53 | /usr/bin/rpmbuild \ 54 | --define "_tmppath $$rpmbuild/TMP" \ 55 | --define "_topdir $$rpmbuild" \ 56 | --define "dist %{nil}" \ 57 | --define "require_spldir $(SPL)" \ 58 | --define "require_splobj $(SPL_OBJ)" \ 59 | --define "require_splver $(SPL_VERSION)" \ 60 | --define "require_zfsdir $(ZFS)" \ 61 | --define "require_zfsver $(ZFS_VERSION)" \ 62 | --define "require_kdir $(LINUX)" \ 63 | --define "require_kobj $(LINUX_OBJ)" \ 64 | --define "require_kver $(LINUX_VERSION)" \ 65 | --nodeps --rebuild $$rpmpkg || exit 1; \ 66 | cp $$rpmbuild/RPMS/*/* . || exit 1; \ 67 | $(RM) -R $$rpmbuild 68 | -------------------------------------------------------------------------------- /config/tgz.am: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (C) 2010 Lawrence Livermore National Security, LLC. 3 | # Written by Brian Behlendorf . 4 | ############################################################################### 5 | # Build targets for TGZ packages. 6 | # 7 | # Long term native distro specific Slackware style packaging should be added. 8 | # In the short term RPM packages are built and converted to TGZ packages 9 | # using alien. If someone familiar with Slackware style packaging were to 10 | # update the build system to correctly build Slackware style packages I would 11 | # happily take it. Until then we will have to make due with alien. 12 | # 13 | ############################################################################### 14 | 15 | tgz-local: 16 | @(if test "${HAVE_ALIEN}" = "no"; then \ 17 | echo -e "\n" \ 18 | "*** Required util ${ALIEN} missing. Please install the\n" \ 19 | "*** package for your distribution which provides ${ALIEN},\n" \ 20 | "*** re-run configure, and try again.\n"; \ 21 | exit 1; \ 22 | fi) 23 | 24 | tgz-utils: tgz-local rpm-utils 25 | name=${PACKAGE}; \ 26 | version=${LZFS_META_VERSION}-${LZFS_META_RELEASE}; \ 27 | arch=`$(RPM) -qp $${name}-$${version}.src.rpm --qf %{arch}`; \ 28 | pkg1=$${name}-$${version}.$${arch}.rpm; \ 29 | fakeroot $(ALIEN) --scripts --to-tgz $$pkg1; \ 30 | $(RM) $$pkg1 31 | 32 | tgz: tgz-utils 33 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | # -*- Autoconf -*- 2 | # Process this file with autoconf to produce a configure script. 3 | 4 | AC_PREREQ([2.63]) 5 | AC_INIT 6 | AC_LANG(C) 7 | LZFS_AC_META 8 | AC_CONFIG_AUX_DIR([config]) 9 | AC_CANONICAL_SYSTEM 10 | AM_INIT_AUTOMAKE([$LZFS_META_NAME], [$LZFS_META_VERSION]) 11 | AC_CONFIG_HEADERS([lzfs_config.h]) 12 | LZFS_AC_CONFIG_KERNEL 13 | LZFS_AC_PACKAGE 14 | AM_MAINTAINER_MODE 15 | 16 | # Checks for programs. 17 | AC_PROG_CC 18 | AC_PROG_INSTALL 19 | 20 | # Checks for libraries. 21 | 22 | # Checks for header files. 23 | AC_CHECK_HEADERS([sys/mntent.h sys/vfs.h]) 24 | 25 | # Checks for typedefs, structures, and compiler characteristics. 26 | AC_C_INLINE 27 | AC_TYPE_SIZE_T 28 | AC_TYPE_SSIZE_T 29 | AC_TYPE_UINT32_T 30 | AC_TYPE_UINT64_T 31 | 32 | # Checks for library functions. 33 | AC_CHECK_FUNCS([bzero memset strchr]) 34 | 35 | AC_CONFIG_FILES([ 36 | Makefile 37 | module/Makefile 38 | etc/Makefile 39 | include/Makefile 40 | usr/Makefile 41 | lzfs.spec 42 | ]) 43 | AC_OUTPUT 44 | -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | lzfs (1.0) unstable; urgency=low 2 | 3 | * Downoad the source code from https://github.com/zfs-linux/lzfs. 4 | * Look at the META for the commit id 5 | * Do a checkout for that commit id. "git checkout " 6 | * Use the git commit logs for a full records of changes: 'git log' 7 | 8 | -- kqinfo Mon, 10 Jan 2011 12:10:59 +0530 9 | -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 7 2 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: lzfs 2 | Section: kernel 3 | Priority: extra 4 | Maintainer: kqinfo 5 | Build-Depends: debhelper (>= 7), autotools-dev 6 | Standards-Version: 3.8.3 7 | Homepage: http://kqstor.com 8 | 9 | Package: lzfs 10 | Architecture: any 11 | Depends: ${shlibs:Depends}, ${misc:Depends}, spl, zfs, python-dmidecode, python-soappy, python-libxml2 12 | Description: The package contains POSIX porting layer to zfs file system. 13 | 14 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | This work was packaged for Debian by: 2 | 3 | KQ Infotech on Mon, 10 Jan 2011 11:16:05 +0530 4 | 5 | It was downloaded from git@github.com:zfs-linux/lzfs.git 6 | 7 | Upstream Author(s): 8 | 9 | KQ Infotech 10 | 11 | Copyright: 12 | Copyright (c) 2010 Knowledge Quest Infotech Pvt. Ltd. 13 | Produced at Knowledge Quest Infotech Pvt. Ltd. 14 | Written by: Knowledge Quest Infotech Pvt. Ltd. 15 | zfs@kqinfotech.com 16 | This is free software; you can redistribute it and/or modify it 17 | under the terms of the GNU General Public License as published by 18 | the Free Software Foundation; either version 2 of the License, or 19 | (at your option) any later version. 20 | 21 | This is distributed in the hope that it will be useful, but WITHOUT 22 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 23 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 24 | for more details. 25 | 26 | You should have received a copy of the GNU General Public License along 27 | with this program; if not, write to the Free Software Foundation, Inc., 28 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 29 | 30 | 31 | License: 32 | 33 | GPL 34 | 35 | The Debian packaging is: 36 | Copyright (c) 2010 Knowledge Quest Infotech Pvt. Ltd. 37 | Produced at Knowledge Quest Infotech Pvt. Ltd. 38 | Written by: Knowledge Quest Infotech Pvt. Ltd. 39 | zfs@kqinfotech.com 40 | 41 | -------------------------------------------------------------------------------- /debian/dirs: -------------------------------------------------------------------------------- 1 | /etc/ 2 | /etc/init.d 3 | -------------------------------------------------------------------------------- /debian/docs: -------------------------------------------------------------------------------- 1 | META 2 | COPYING 3 | -------------------------------------------------------------------------------- /debian/postinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # postinst script for lzfs 3 | # 4 | # see: dh_installdeb(1) 5 | /sbin/depmod 6 | /usr/sbin/update-rc.d zfsload defaults 7 | /etc/init.d/zfsload start 8 | -------------------------------------------------------------------------------- /debian/postrm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # postrm script for lzfs 3 | # 4 | # see: dh_installdeb(1) 5 | 6 | /usr/sbin/update-rc.d -f zfsload remove 7 | -------------------------------------------------------------------------------- /debian/preinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # preinst script for lzfs 3 | # 4 | # see: dh_installdeb(1) 5 | 6 | set -e 7 | 8 | # summary of how this script can be called: 9 | # * `install' 10 | # * `install' 11 | # * `upgrade' 12 | # * `abort-upgrade' 13 | # for details, see http://www.debian.org/doc/debian-policy/ or 14 | # the debian-policy package 15 | 16 | 17 | case "$1" in 18 | install|upgrade) 19 | ;; 20 | 21 | abort-upgrade) 22 | ;; 23 | 24 | *) 25 | echo "preinst called with unknown argument \`$1'" >&2 26 | exit 1 27 | ;; 28 | esac 29 | 30 | # dh_installdeb will replace this with shell code automatically 31 | # generated by other debhelper scripts. 32 | 33 | #DEBHELPER# 34 | 35 | exit 0 36 | -------------------------------------------------------------------------------- /debian/prerm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # prerm script for lzfs 3 | # 4 | # see: dh_installdeb(1) 5 | /etc/init.d/zfsload stop 6 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # -*- makefile -*- 3 | # Sample debian/rules that uses debhelper. 4 | # This file was originally written by Joey Hess and Craig Small. 5 | # As a special exception, when this file is copied by dh-make into a 6 | # dh-make output file, you may use that output file without restriction. 7 | # This special exception was added by Craig Small in version 0.37 of dh-make. 8 | 9 | # Uncomment this to turn on verbose mode. 10 | #export DH_VERBOSE=1 11 | 12 | %: 13 | dh $@ 14 | -------------------------------------------------------------------------------- /etc/Makefile.in: -------------------------------------------------------------------------------- 1 | 2 | etcdir = /etc 3 | initddir = $(etcdir)/init.d 4 | zfsdir = $(etcdir)/zfs 5 | INSTALL = /usr/bin/install -c 6 | 7 | all: 8 | install: install_initd install_zfs 9 | uninstall: uninstall_initd uninstall_zfs 10 | 11 | install_initd: 12 | if [ -f /etc/debian_version ]; then \ 13 | $(MAKE) install_initd_debian ; \ 14 | elif [ -f /etc/redhat-release ]; then \ 15 | $(MAKE) install_initd_redhat ; \ 16 | fi 17 | 18 | install_initd_redhat: 19 | test -z "$(initddir)" || /bin/mkdir -p "$(DESTDIR)$(initddir)" 20 | $(INSTALL) -m 755 init.d/initd.redhat \ 21 | $(DESTDIR)$(initddir)/zfsload 22 | if [ -z $(DESTDIR) ]; then \ 23 | /sbin/chkconfig --add $(DESTDIR)$(initddir)/zfsload; \ 24 | service zfsload start; \ 25 | fi 26 | 27 | install_initd_debian: 28 | test -z "$(initddir)" || /bin/mkdir -p "$(DESTDIR)$(initddir)" 29 | $(INSTALL) -m 755 init.d/initd.debian \ 30 | $(DESTDIR)$(initddir)/zfsload 31 | /usr/sbin/update-rc.d zfsload defaults 32 | service zfsload start 33 | 34 | uninstall_initd: 35 | if [ -f /etc/debian_version ]; then \ 36 | $(MAKE) uninstall_initd_debian ; \ 37 | elif [ -f /etc/redhat-release ]; then \ 38 | $(MAKE) uninstall_initd_redhat ; \ 39 | fi 40 | 41 | uninstall_initd_redhat: 42 | service zfsload stop 43 | /sbin/chkconfig --del zfsload 44 | 45 | uninstall_initd_debian: 46 | service zfsload stop 47 | /usr/sbin/update-rc.d -f zfsload remove 48 | 49 | install_zfs: 50 | test -z "$(zfsdir)" || /bin/mkdir -p "$(DESTDIR)$(zfsdir)" 51 | $(INSTALL) -m 755 zfs/zfs_config \ 52 | $(DESTDIR)$(zfsdir)/ 53 | $(INSTALL) -m 755 zfs/zfs_serial \ 54 | $(DESTDIR)$(zfsdir)/ 55 | 56 | uninstall_zfs: 57 | /bin/rm -f /etc/zfs/zfs_config 58 | /bin/rm -f /etc/zfs/zfs_serial 59 | 60 | clean: 61 | 62 | distclean: 63 | 64 | check: 65 | 66 | distdir: 67 | find ./ | xargs /bin/cp -rt $$distdir/$$subdir; 68 | -------------------------------------------------------------------------------- /etc/init.d/initd.debian: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # description:loads all modules required for zfs 4 | ### BEGIN INIT INFO 5 | # Provides: zfsload 6 | # Required-Start: $local_fs 7 | # Required-Stop: $local_fs 8 | # Default-Start: 2 3 4 5 9 | # Default-Stop: 0 1 6 10 | # Short-Description: Start daemon at boot time 11 | # Description: Enable service provided by zfs. 12 | ### END INIT INFO 13 | 14 | 15 | # Source function library. 16 | 17 | . /lib/lsb/init-functions 18 | 19 | PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/ 20 | RETVAL=0 21 | exec=/usr/sbin/zfsload 22 | prog=zfsload 23 | config=/etc/zfsload/zfsload.conf 24 | lockfile=/var/lock/subsys/$prog 25 | 26 | RES_COL=60 27 | # Command to move out to the configured column number 28 | MOVE_TO_COL="echo -n \\033[${RES_COL}G" 29 | # Command to set the color to SUCCESS (Green) 30 | SETCOLOR_SUCCESS="echo -n \\033[1;32m" 31 | # Command to set the color to FAILED (Red) 32 | SETCOLOR_FAILURE="echo -n \\033[1;31m" 33 | # Command to set the color back to normal 34 | SETCOLOR_NORMAL="echo -n \\033[0;39m" 35 | 36 | # Function to print the SUCCESS status 37 | echo_success() { 38 | $MOVE_TO_COL 39 | echo -n "[" 40 | $SETCOLOR_SUCCESS 41 | echo -n " OK " 42 | $SETCOLOR_NORMAL 43 | echo -n "]" 44 | echo -n "\r" 45 | return 0 46 | } 47 | 48 | # Function to print the FAILED status message 49 | echo_failure() { 50 | 51 | $MOVE_TO_COL 52 | echo -n "[" 53 | $SETCOLOR_FAILURE 54 | echo -n "FAILED" 55 | $SETCOLOR_NORMAL 56 | echo -n "]" 57 | echo -n "\r" 58 | return 1 59 | } 60 | 61 | start () { 62 | modprobe lzfs 63 | zfs mount -a 64 | 65 | RETVAL=$? 66 | if [ $RETVAL -eq 0 ] 67 | then 68 | echo -n "loading zfs modules " 69 | echo_success 70 | else 71 | echo -n "failed load zfs modules" 72 | echo_failure 73 | fi 74 | echo 75 | return $RETVAL 76 | } 77 | 78 | stop () { 79 | zfs umount -a 80 | modprobe -r lzfs 81 | modprobe -r zfs 82 | modprobe -r zcommon 83 | modprobe -r zunicode 84 | modprobe -r znvpair 85 | modprobe -r zavl 86 | modprobe -r spl 87 | 88 | RETVAL=$? 89 | if [ $RETVAL -eq 0 ] 90 | then 91 | echo -n "unloading zfs modules " 92 | echo_success 93 | else 94 | echo -n "failed to unload zfs modules" 95 | echo_failure 96 | fi 97 | echo 98 | [ $RETVAL = 0 ] && rm -f $lockfile 99 | return 0 100 | } 101 | 102 | restart() { 103 | stop 104 | start 105 | } 106 | 107 | case $1 in 108 | start) 109 | start 110 | ;; 111 | stop) 112 | stop 113 | ;; 114 | restart) 115 | restart 116 | ;; 117 | condrestart|try-restart) 118 | [ -f $lockfile ] && restart || : 119 | ;; 120 | reload) 121 | echo -n $"Reloading $prog: " 122 | killproc $prog -HUP 123 | RETVAL=$? 124 | echo 125 | ;; 126 | force-reload) 127 | echo -n $"Reloading $prog: " 128 | if ! killproc $prog -HUP; then 129 | restart 130 | fi 131 | echo 132 | ;; 133 | status) 134 | status=`lsmod | grep lzfs | cut -d ' ' -f1 | head -n 1 2> /dev/null` 135 | if [ "$status" = "lzfs" ] 136 | then 137 | echo "* zfs service is running" 138 | else 139 | echo "* zfs service is stopped" 140 | fi 141 | ;; 142 | restartlog) 143 | stop 144 | cat /dev/null >/var/log/zfsload/error_log 145 | start 146 | ;; 147 | *) 148 | 149 | echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|reload|force-reload|status}" 150 | exit 2 151 | esac 152 | 153 | exit $RETVAL 154 | -------------------------------------------------------------------------------- /etc/init.d/initd.redhat: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #chkconfig: 2345 20 80 3 | # description:loads all modules required for zfs 4 | # higher quality random number generation. 5 | 6 | ### BEGIN INIT INFO 7 | # Provides: zfsload 8 | # Required-Start: bar 9 | # Defalt-Start: 2 3 4 5 10 | # Default-Stop: 0 1 6 11 | # Description: zfsload init script 12 | ### END INIT INFO 13 | 14 | # Source function library. 15 | . /etc/rc.d/init.d/functions 16 | PATH=$PATH:/usr/local/sbin 17 | export PATH 18 | 19 | RETVAL=0 20 | exec=/usr/sbin/zfsload 21 | prog=zfsload 22 | config=/etc/zfsload/zfsload.conf 23 | lockfile=/var/lock/subsys/$prog 24 | 25 | RES_COL=60 26 | # Command to move out to the configured column number 27 | MOVE_TO_COL="echo -en \\033[${RES_COL}G" 28 | # Command to set the color to SUCCESS (Green) 29 | SETCOLOR_SUCCESS="echo -en \\033[1;32m" 30 | # Command to set the color to FAILED (Red) 31 | SETCOLOR_FAILURE="echo -en \\033[1;31m" 32 | # Command to set the color back to normal 33 | SETCOLOR_NORMAL="echo -en \\033[0;39m" 34 | 35 | 36 | # Function to print the SUCCESS status 37 | echo_success() { 38 | $MOVE_TO_COL 39 | echo -n "[" 40 | $SETCOLOR_SUCCESS 41 | echo -n $" OK " 42 | $SETCOLOR_NORMAL 43 | echo -n "]" 44 | echo -ne "\r" 45 | return 0 46 | } 47 | 48 | # Function to print the FAILED status message 49 | echo_failure() { 50 | 51 | $MOVE_TO_COL 52 | echo -n "[" 53 | $SETCOLOR_FAILURE 54 | echo -n $"FAILED" 55 | $SETCOLOR_NORMAL 56 | echo -n "]" 57 | echo -ne "\r" 58 | return 1 59 | } 60 | 61 | 62 | start () { 63 | modprobe lzfs 64 | zfs mount -a 65 | 66 | RETVAL=$? 67 | if [ $RETVAL -eq 0 ] 68 | then 69 | echo -n "loading zfs modules " 70 | echo_success 71 | else 72 | echo -n "failed load zfs modules" 73 | echo_failure 74 | fi 75 | echo 76 | return $RETVAL 77 | } 78 | 79 | stop () { 80 | zfs umount -a 81 | modprobe -r lzfs 82 | modprobe -r zfs 83 | modprobe -r zcommon 84 | modprobe -r zunicode 85 | modprobe -r znvpair 86 | modprobe -r zavl 87 | modprobe -r spl 88 | RETVAL=$? 89 | 90 | if [ $RETVAL -eq 0 ] 91 | then 92 | echo -n "unloading zfs modules " 93 | echo_success 94 | else 95 | echo -n "failed to unload zfs modules" 96 | echo_failure 97 | fi 98 | echo 99 | [ $RETVAL = 0 ] && rm -f $lockfile 100 | return 0 101 | } 102 | 103 | restart() { 104 | stop 105 | start 106 | } 107 | 108 | case $1 in 109 | start) 110 | start 111 | ;; 112 | stop) 113 | stop 114 | ;; 115 | restart) 116 | restart 117 | ;; 118 | condrestart|try-restart) 119 | [ -f $lockfile ] && restart || : 120 | ;; 121 | reload) 122 | echo -n $"Reloading $prog: " 123 | killproc $prog -HUP 124 | RETVAL=$? 125 | echo 126 | ;; 127 | force-reload) 128 | echo -n $"Reloading $prog: " 129 | if ! killproc $prog -HUP; then 130 | restart 131 | fi 132 | echo 133 | ;; 134 | status) 135 | status=`lsmod | grep lzfs | cut -d ' ' -f1 | head -n 1 2> /dev/null` 136 | if [ "$status" = "lzfs" ] 137 | then 138 | echo "* zfs service is running" 139 | else 140 | echo "* zfs service is stopped" 141 | fi 142 | ;; 143 | restartlog) 144 | stop 145 | cat /dev/null >/var/log/zfsload/error_log 146 | start 147 | ;; 148 | *) 149 | 150 | echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|reload|force-reload|status}" 151 | exit 2 152 | esac 153 | 154 | exit $RETVAL 155 | 156 | -------------------------------------------------------------------------------- /etc/zfs/zfs_config: -------------------------------------------------------------------------------- 1 | user= 2 | password= 3 | server= 4 | port= 5 | -------------------------------------------------------------------------------- /etc/zfs/zfs_serial: -------------------------------------------------------------------------------- 1 | asdfadsfpup8uyfauf8sdfj 2 | -------------------------------------------------------------------------------- /include/Makefile.in: -------------------------------------------------------------------------------- 1 | all: 2 | install: 3 | 4 | clean: 5 | 6 | distclean: 7 | 8 | check: 9 | 10 | distdir: 11 | /bin/cp -R * $$distdir/$$subdir 12 | 13 | -------------------------------------------------------------------------------- /include/lzfs_exportfs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the LZPL: Linux ZFS Posix Layer 3 | * 4 | * Copyright (c) 2010 Knowledge Quest Infotech Pvt. Ltd. 5 | * Produced at Knowledge Quest Infotech Pvt. Ltd. 6 | * Written by: Knowledge Quest Infotech Pvt. Ltd. 7 | * 8 | * This is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This is distributed in the hope that it will be useful, but WITHOUT 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | * for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | */ 22 | 23 | #ifndef _LZFS_EXPORTFS_H 24 | #define _LZFS_EXPORTFS_H 25 | 26 | #include 27 | #include 28 | 29 | #if 0 30 | struct lzfs_fid { 31 | u64 ino; 32 | u32 gen; 33 | 34 | u64 parent_ino; 35 | u32 parent_gen; 36 | } __attribute__((packed)); 37 | #else 38 | typedef fid_t lzfs_fid_t; 39 | #endif 40 | 41 | 42 | extern const struct export_operations zfs_export_ops; 43 | 44 | #define LZFS_FILEID_INO64_GEN 4 45 | #define LZFS_FILEID_INO64_GEN_PARENT 8 46 | #endif 47 | -------------------------------------------------------------------------------- /include/lzfs_inode.h: -------------------------------------------------------------------------------- 1 | #ifndef _LZFS_INODE_H 2 | #define _LZFS_INODE_H 3 | 4 | extern void 5 | lzfs_set_inode_ops(struct inode *inode); 6 | 7 | extern struct file_system_type lzfs_fs_type; 8 | #endif /* _LZFS_INODE_H */ 9 | -------------------------------------------------------------------------------- /include/lzfs_snap.h: -------------------------------------------------------------------------------- 1 | #ifndef _LZFS_SNAP_H 2 | #define _LZFS_SNAP_H 3 | 4 | #define LZFS_ZFSCTL_INO_ROOT 0xFFFFFFFFFFFFFFFF 5 | #define LZFS_ZFSCTL_INO_SNAPDIR 0xFFFFFFFFFFFFFFFE 6 | #define LZFS_ZFSCTL_INO_SHARES 0xFFFFFFFFFFFFFFFD 7 | 8 | #define ZFS_CTLDIR_NAME ".zfs" 9 | #define ZFS_SNAPDIR_NAME "snapshot" 10 | #define ZFS_SHAREDIR_NAME "shares" 11 | #endif /* _LZFS_SNAP_H */ 12 | -------------------------------------------------------------------------------- /include/lzfs_xattr.h: -------------------------------------------------------------------------------- 1 | #ifndef _LZFS_XATTR_H 2 | #define _LZFS_XATTR_H 3 | #include 4 | 5 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35) 6 | extern struct xattr_handler *lzfs_xattr_handlers[]; 7 | #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35) 8 | extern const struct xattr_handler *lzfs_xattr_handlers[]; 9 | #endif 10 | 11 | ssize_t 12 | lzfs_listxattr(struct dentry *dentry, char *buffer, size_t size); 13 | 14 | extern struct xattr_handler lzfs_xattr_user_handler; 15 | extern struct xattr_handler lzfs_xattr_security_handler; 16 | 17 | #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,31) 18 | extern struct xattr_handler lzfs_xattr_acl_access_handler; 19 | extern struct xattr_handler lzfs_xattr_acl_default_handler; 20 | #endif 21 | 22 | int 23 | lzfs_xattr_get(struct inode *inode, const char *name, 24 | void *buffer, size_t size, const char *xattr_name); 25 | 26 | int 27 | lzfs_xattr_set(struct inode *inode, const char *name, 28 | void *buffer, size_t size, const char *xattr_name); 29 | 30 | int 31 | lzfs_removexattr(struct dentry *dentry, const char *name); 32 | 33 | int 34 | lzfs_init_security(struct inode *inode, struct inode *dir); 35 | 36 | #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,31) 37 | extern int 38 | lzfs_acl_init(struct inode *inode, struct inode *dir); 39 | 40 | extern int 41 | lzfs_acl_chmod(struct inode *inode); 42 | 43 | extern int 44 | lzfs_check_acl(struct inode *inode, int mask); 45 | #endif 46 | 47 | extern int 48 | lzfs_vnop_setattr(struct dentry *dentry, struct iattr *iattr); 49 | 50 | #endif /* _LZFS_XATTR_H */ 51 | 52 | -------------------------------------------------------------------------------- /install-sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # install - install a program, script, or datafile 3 | 4 | scriptversion=2009-04-28.21; # UTC 5 | 6 | # This originates from X11R5 (mit/util/scripts/install.sh), which was 7 | # later released in X11R6 (xc/config/util/install.sh) with the 8 | # following copyright and license. 9 | # 10 | # Copyright (C) 1994 X Consortium 11 | # 12 | # Permission is hereby granted, free of charge, to any person obtaining a copy 13 | # of this software and associated documentation files (the "Software"), to 14 | # deal in the Software without restriction, including without limitation the 15 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 16 | # sell copies of the Software, and to permit persons to whom the Software is 17 | # furnished to do so, subject to the following conditions: 18 | # 19 | # The above copyright notice and this permission notice shall be included in 20 | # all copies or substantial portions of the Software. 21 | # 22 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 26 | # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- 27 | # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | # 29 | # Except as contained in this notice, the name of the X Consortium shall not 30 | # be used in advertising or otherwise to promote the sale, use or other deal- 31 | # ings in this Software without prior written authorization from the X Consor- 32 | # tium. 33 | # 34 | # 35 | # FSF changes to this file are in the public domain. 36 | # 37 | # Calling this script install-sh is preferred over install.sh, to prevent 38 | # `make' implicit rules from creating a file called install from it 39 | # when there is no Makefile. 40 | # 41 | # This script is compatible with the BSD install script, but was written 42 | # from scratch. 43 | 44 | nl=' 45 | ' 46 | IFS=" "" $nl" 47 | 48 | # set DOITPROG to echo to test this script 49 | 50 | # Don't use :- since 4.3BSD and earlier shells don't like it. 51 | doit=${DOITPROG-} 52 | if test -z "$doit"; then 53 | doit_exec=exec 54 | else 55 | doit_exec=$doit 56 | fi 57 | 58 | # Put in absolute file names if you don't have them in your path; 59 | # or use environment vars. 60 | 61 | chgrpprog=${CHGRPPROG-chgrp} 62 | chmodprog=${CHMODPROG-chmod} 63 | chownprog=${CHOWNPROG-chown} 64 | cmpprog=${CMPPROG-cmp} 65 | cpprog=${CPPROG-cp} 66 | mkdirprog=${MKDIRPROG-mkdir} 67 | mvprog=${MVPROG-mv} 68 | rmprog=${RMPROG-rm} 69 | stripprog=${STRIPPROG-strip} 70 | 71 | posix_glob='?' 72 | initialize_posix_glob=' 73 | test "$posix_glob" != "?" || { 74 | if (set -f) 2>/dev/null; then 75 | posix_glob= 76 | else 77 | posix_glob=: 78 | fi 79 | } 80 | ' 81 | 82 | posix_mkdir= 83 | 84 | # Desired mode of installed file. 85 | mode=0755 86 | 87 | chgrpcmd= 88 | chmodcmd=$chmodprog 89 | chowncmd= 90 | mvcmd=$mvprog 91 | rmcmd="$rmprog -f" 92 | stripcmd= 93 | 94 | src= 95 | dst= 96 | dir_arg= 97 | dst_arg= 98 | 99 | copy_on_change=false 100 | no_target_directory= 101 | 102 | usage="\ 103 | Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE 104 | or: $0 [OPTION]... SRCFILES... DIRECTORY 105 | or: $0 [OPTION]... -t DIRECTORY SRCFILES... 106 | or: $0 [OPTION]... -d DIRECTORIES... 107 | 108 | In the 1st form, copy SRCFILE to DSTFILE. 109 | In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. 110 | In the 4th, create DIRECTORIES. 111 | 112 | Options: 113 | --help display this help and exit. 114 | --version display version info and exit. 115 | 116 | -c (ignored) 117 | -C install only if different (preserve the last data modification time) 118 | -d create directories instead of installing files. 119 | -g GROUP $chgrpprog installed files to GROUP. 120 | -m MODE $chmodprog installed files to MODE. 121 | -o USER $chownprog installed files to USER. 122 | -s $stripprog installed files. 123 | -t DIRECTORY install into DIRECTORY. 124 | -T report an error if DSTFILE is a directory. 125 | 126 | Environment variables override the default commands: 127 | CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG 128 | RMPROG STRIPPROG 129 | " 130 | 131 | while test $# -ne 0; do 132 | case $1 in 133 | -c) ;; 134 | 135 | -C) copy_on_change=true;; 136 | 137 | -d) dir_arg=true;; 138 | 139 | -g) chgrpcmd="$chgrpprog $2" 140 | shift;; 141 | 142 | --help) echo "$usage"; exit $?;; 143 | 144 | -m) mode=$2 145 | case $mode in 146 | *' '* | *' '* | *' 147 | '* | *'*'* | *'?'* | *'['*) 148 | echo "$0: invalid mode: $mode" >&2 149 | exit 1;; 150 | esac 151 | shift;; 152 | 153 | -o) chowncmd="$chownprog $2" 154 | shift;; 155 | 156 | -s) stripcmd=$stripprog;; 157 | 158 | -t) dst_arg=$2 159 | shift;; 160 | 161 | -T) no_target_directory=true;; 162 | 163 | --version) echo "$0 $scriptversion"; exit $?;; 164 | 165 | --) shift 166 | break;; 167 | 168 | -*) echo "$0: invalid option: $1" >&2 169 | exit 1;; 170 | 171 | *) break;; 172 | esac 173 | shift 174 | done 175 | 176 | if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then 177 | # When -d is used, all remaining arguments are directories to create. 178 | # When -t is used, the destination is already specified. 179 | # Otherwise, the last argument is the destination. Remove it from $@. 180 | for arg 181 | do 182 | if test -n "$dst_arg"; then 183 | # $@ is not empty: it contains at least $arg. 184 | set fnord "$@" "$dst_arg" 185 | shift # fnord 186 | fi 187 | shift # arg 188 | dst_arg=$arg 189 | done 190 | fi 191 | 192 | if test $# -eq 0; then 193 | if test -z "$dir_arg"; then 194 | echo "$0: no input file specified." >&2 195 | exit 1 196 | fi 197 | # It's OK to call `install-sh -d' without argument. 198 | # This can happen when creating conditional directories. 199 | exit 0 200 | fi 201 | 202 | if test -z "$dir_arg"; then 203 | trap '(exit $?); exit' 1 2 13 15 204 | 205 | # Set umask so as not to create temps with too-generous modes. 206 | # However, 'strip' requires both read and write access to temps. 207 | case $mode in 208 | # Optimize common cases. 209 | *644) cp_umask=133;; 210 | *755) cp_umask=22;; 211 | 212 | *[0-7]) 213 | if test -z "$stripcmd"; then 214 | u_plus_rw= 215 | else 216 | u_plus_rw='% 200' 217 | fi 218 | cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; 219 | *) 220 | if test -z "$stripcmd"; then 221 | u_plus_rw= 222 | else 223 | u_plus_rw=,u+rw 224 | fi 225 | cp_umask=$mode$u_plus_rw;; 226 | esac 227 | fi 228 | 229 | for src 230 | do 231 | # Protect names starting with `-'. 232 | case $src in 233 | -*) src=./$src;; 234 | esac 235 | 236 | if test -n "$dir_arg"; then 237 | dst=$src 238 | dstdir=$dst 239 | test -d "$dstdir" 240 | dstdir_status=$? 241 | else 242 | 243 | # Waiting for this to be detected by the "$cpprog $src $dsttmp" command 244 | # might cause directories to be created, which would be especially bad 245 | # if $src (and thus $dsttmp) contains '*'. 246 | if test ! -f "$src" && test ! -d "$src"; then 247 | echo "$0: $src does not exist." >&2 248 | exit 1 249 | fi 250 | 251 | if test -z "$dst_arg"; then 252 | echo "$0: no destination specified." >&2 253 | exit 1 254 | fi 255 | 256 | dst=$dst_arg 257 | # Protect names starting with `-'. 258 | case $dst in 259 | -*) dst=./$dst;; 260 | esac 261 | 262 | # If destination is a directory, append the input filename; won't work 263 | # if double slashes aren't ignored. 264 | if test -d "$dst"; then 265 | if test -n "$no_target_directory"; then 266 | echo "$0: $dst_arg: Is a directory" >&2 267 | exit 1 268 | fi 269 | dstdir=$dst 270 | dst=$dstdir/`basename "$src"` 271 | dstdir_status=0 272 | else 273 | # Prefer dirname, but fall back on a substitute if dirname fails. 274 | dstdir=` 275 | (dirname "$dst") 2>/dev/null || 276 | expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ 277 | X"$dst" : 'X\(//\)[^/]' \| \ 278 | X"$dst" : 'X\(//\)$' \| \ 279 | X"$dst" : 'X\(/\)' \| . 2>/dev/null || 280 | echo X"$dst" | 281 | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ 282 | s//\1/ 283 | q 284 | } 285 | /^X\(\/\/\)[^/].*/{ 286 | s//\1/ 287 | q 288 | } 289 | /^X\(\/\/\)$/{ 290 | s//\1/ 291 | q 292 | } 293 | /^X\(\/\).*/{ 294 | s//\1/ 295 | q 296 | } 297 | s/.*/./; q' 298 | ` 299 | 300 | test -d "$dstdir" 301 | dstdir_status=$? 302 | fi 303 | fi 304 | 305 | obsolete_mkdir_used=false 306 | 307 | if test $dstdir_status != 0; then 308 | case $posix_mkdir in 309 | '') 310 | # Create intermediate dirs using mode 755 as modified by the umask. 311 | # This is like FreeBSD 'install' as of 1997-10-28. 312 | umask=`umask` 313 | case $stripcmd.$umask in 314 | # Optimize common cases. 315 | *[2367][2367]) mkdir_umask=$umask;; 316 | .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; 317 | 318 | *[0-7]) 319 | mkdir_umask=`expr $umask + 22 \ 320 | - $umask % 100 % 40 + $umask % 20 \ 321 | - $umask % 10 % 4 + $umask % 2 322 | `;; 323 | *) mkdir_umask=$umask,go-w;; 324 | esac 325 | 326 | # With -d, create the new directory with the user-specified mode. 327 | # Otherwise, rely on $mkdir_umask. 328 | if test -n "$dir_arg"; then 329 | mkdir_mode=-m$mode 330 | else 331 | mkdir_mode= 332 | fi 333 | 334 | posix_mkdir=false 335 | case $umask in 336 | *[123567][0-7][0-7]) 337 | # POSIX mkdir -p sets u+wx bits regardless of umask, which 338 | # is incompatible with FreeBSD 'install' when (umask & 300) != 0. 339 | ;; 340 | *) 341 | tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ 342 | trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 343 | 344 | if (umask $mkdir_umask && 345 | exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 346 | then 347 | if test -z "$dir_arg" || { 348 | # Check for POSIX incompatibilities with -m. 349 | # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or 350 | # other-writeable bit of parent directory when it shouldn't. 351 | # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. 352 | ls_ld_tmpdir=`ls -ld "$tmpdir"` 353 | case $ls_ld_tmpdir in 354 | d????-?r-*) different_mode=700;; 355 | d????-?--*) different_mode=755;; 356 | *) false;; 357 | esac && 358 | $mkdirprog -m$different_mode -p -- "$tmpdir" && { 359 | ls_ld_tmpdir_1=`ls -ld "$tmpdir"` 360 | test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" 361 | } 362 | } 363 | then posix_mkdir=: 364 | fi 365 | rmdir "$tmpdir/d" "$tmpdir" 366 | else 367 | # Remove any dirs left behind by ancient mkdir implementations. 368 | rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null 369 | fi 370 | trap '' 0;; 371 | esac;; 372 | esac 373 | 374 | if 375 | $posix_mkdir && ( 376 | umask $mkdir_umask && 377 | $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" 378 | ) 379 | then : 380 | else 381 | 382 | # The umask is ridiculous, or mkdir does not conform to POSIX, 383 | # or it failed possibly due to a race condition. Create the 384 | # directory the slow way, step by step, checking for races as we go. 385 | 386 | case $dstdir in 387 | /*) prefix='/';; 388 | -*) prefix='./';; 389 | *) prefix='';; 390 | esac 391 | 392 | eval "$initialize_posix_glob" 393 | 394 | oIFS=$IFS 395 | IFS=/ 396 | $posix_glob set -f 397 | set fnord $dstdir 398 | shift 399 | $posix_glob set +f 400 | IFS=$oIFS 401 | 402 | prefixes= 403 | 404 | for d 405 | do 406 | test -z "$d" && continue 407 | 408 | prefix=$prefix$d 409 | if test -d "$prefix"; then 410 | prefixes= 411 | else 412 | if $posix_mkdir; then 413 | (umask=$mkdir_umask && 414 | $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break 415 | # Don't fail if two instances are running concurrently. 416 | test -d "$prefix" || exit 1 417 | else 418 | case $prefix in 419 | *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; 420 | *) qprefix=$prefix;; 421 | esac 422 | prefixes="$prefixes '$qprefix'" 423 | fi 424 | fi 425 | prefix=$prefix/ 426 | done 427 | 428 | if test -n "$prefixes"; then 429 | # Don't fail if two instances are running concurrently. 430 | (umask $mkdir_umask && 431 | eval "\$doit_exec \$mkdirprog $prefixes") || 432 | test -d "$dstdir" || exit 1 433 | obsolete_mkdir_used=true 434 | fi 435 | fi 436 | fi 437 | 438 | if test -n "$dir_arg"; then 439 | { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && 440 | { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && 441 | { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || 442 | test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 443 | else 444 | 445 | # Make a couple of temp file names in the proper directory. 446 | dsttmp=$dstdir/_inst.$$_ 447 | rmtmp=$dstdir/_rm.$$_ 448 | 449 | # Trap to clean up those temp files at exit. 450 | trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 451 | 452 | # Copy the file name to the temp name. 453 | (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && 454 | 455 | # and set any options; do chmod last to preserve setuid bits. 456 | # 457 | # If any of these fail, we abort the whole thing. If we want to 458 | # ignore errors from any of these, just make sure not to ignore 459 | # errors from the above "$doit $cpprog $src $dsttmp" command. 460 | # 461 | { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && 462 | { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && 463 | { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && 464 | { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && 465 | 466 | # If -C, don't bother to copy if it wouldn't change the file. 467 | if $copy_on_change && 468 | old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && 469 | new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && 470 | 471 | eval "$initialize_posix_glob" && 472 | $posix_glob set -f && 473 | set X $old && old=:$2:$4:$5:$6 && 474 | set X $new && new=:$2:$4:$5:$6 && 475 | $posix_glob set +f && 476 | 477 | test "$old" = "$new" && 478 | $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 479 | then 480 | rm -f "$dsttmp" 481 | else 482 | # Rename the file to the real destination. 483 | $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || 484 | 485 | # The rename failed, perhaps because mv can't rename something else 486 | # to itself, or perhaps because mv is so ancient that it does not 487 | # support -f. 488 | { 489 | # Now remove or move aside any old file at destination location. 490 | # We try this two ways since rm can't unlink itself on some 491 | # systems and the destination file might be busy for other 492 | # reasons. In this case, the final cleanup might fail but the new 493 | # file should still install successfully. 494 | { 495 | test ! -f "$dst" || 496 | $doit $rmcmd -f "$dst" 2>/dev/null || 497 | { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && 498 | { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } 499 | } || 500 | { echo "$0: cannot unlink or rename $dst" >&2 501 | (exit 1); exit 1 502 | } 503 | } && 504 | 505 | # Now rename the file to the real destination. 506 | $doit $mvcmd "$dsttmp" "$dst" 507 | } 508 | fi || exit 1 509 | 510 | trap '' 0 511 | fi 512 | done 513 | 514 | # Local variables: 515 | # eval: (add-hook 'write-file-hooks 'time-stamp) 516 | # time-stamp-start: "scriptversion=" 517 | # time-stamp-format: "%:y-%02m-%02d.%02H" 518 | # time-stamp-time-zone: "UTC" 519 | # time-stamp-end: "; # UTC" 520 | # End: 521 | -------------------------------------------------------------------------------- /lzfs.spec.in: -------------------------------------------------------------------------------- 1 | # The following block is used to allow the source RPM to be rebuilt 2 | # against specific kernels. It is preferable that rpmbuild define the 3 | # require_kver, require_kdir, require_obj constants for us, but if it does not 4 | # not we attempt to determine the correct values based on your distro. 5 | 6 | # kdir: Full path to the kernel source headers 7 | # kobj: Full path to the kernel build objects 8 | # kver: Kernel version 9 | # kpkg: Kernel package name 10 | # kdevpkg: Kernel devel package name 11 | # kverpkg: Kernel package version 12 | 13 | %if %{defined require_kver} 14 | %define kver %{require_kver} 15 | %endif 16 | 17 | %if %{defined require_kdir} 18 | %define kdir %{require_kdir} 19 | %endif 20 | 21 | %if %{defined require_kobj} 22 | %define kobj %{require_kobj} 23 | %endif 24 | 25 | # SLES: 26 | %if %{defined suse_version} 27 | %if %{undefined kver} 28 | %ifarch ppc64 29 | %define kverextra ppc64 30 | %else 31 | %define kverextra default 32 | %endif 33 | 34 | %if %{suse_version} >= 1100 35 | %define klnk %{_usrsrc}/linux-obj/%{_target_cpu}/%{kverextra} 36 | %define krelease %{klnk}/include/config/kernel.release 37 | %else 38 | %define klnk %{_usrsrc}/linux-obj/%{_target_cpu}/%{kverextra} 39 | %define krelease %{klnk}/.kernelrelease 40 | %endif 41 | 42 | %define kver %((echo X; %{__cat} %{krelease} 2>/dev/null)|tail -1) 43 | %endif 44 | 45 | %if %{undefined kverextra} 46 | %define kverextra %(echo %{kver} | cut -f3 -d'-') 47 | %endif 48 | 49 | %define kpkg kernel-%{kverextra} 50 | %define kdevpkg kernel-source 51 | %define kverpkg %(echo %{kver} | %{__sed} -e 's/-%{kverextra}//g') 52 | 53 | # The kernel and rpm versions do not strictly match under SLES11 54 | # e.g. kernel version 2.6.27.19-5 != rpm version 2.6.27.19-5.1 55 | %if %{suse_version} >= 1100 56 | %define koppkg >= 57 | %else 58 | %define koppkg = 59 | %endif 60 | 61 | %if %{undefined kdir} 62 | %define kdir %{_usrsrc}/linux-%{kverpkg} 63 | %endif 64 | %if %{undefined kobj} 65 | %define kobj %{kdir}-obj/%{_target_cpu}/%{kverextra} 66 | %endif 67 | %else 68 | 69 | # CHAOS 4.x/5.x: 70 | %if %{defined ch4} || %{defined ch5} 71 | %if %{undefined kver} 72 | %define klnk %{_usrsrc}/kernels/*/include/config 73 | %define kver %((echo X; %{__cat} %{klnk}/kernel.release 74 | 2>/dev/null) | tail -1) 75 | %endif 76 | %define kpkg chaos-kernel 77 | %define kdevpkg chaos-kernel-devel 78 | %define kverpkg %{kver} 79 | %define koppkg = 80 | %if %{undefined kdir} 81 | %define kdir %{_usrsrc}/kernels/%{kver} 82 | %endif 83 | %if %{undefined kobj} 84 | %define kobj %{kdir} 85 | %endif 86 | %else 87 | 88 | # RHEL 5.x/6.x: 89 | %if %{defined el5} || %{defined el6} 90 | %if %{undefined kver} 91 | %define klnk %{_usrsrc}/kernels/*/include/config 92 | %define kver %((echo X; %{__cat} %{klnk}/kernel.release 93 | 2>/dev/null) | tail -1) 94 | %endif 95 | %define kpkg kernel 96 | %define kdevpkg kernel-devel 97 | %if %{defined el6} 98 | %define kverpkg %(echo %{kver} | %{__sed} -e 's/.%{_target_cpu}//g') 99 | %else 100 | %define kverpkg %{kver} 101 | %endif 102 | %define koppkg = 103 | %if %{undefined kdir} 104 | %define kdir %{_usrsrc}/kernels/%{kver}-%{_target_cpu} 105 | %endif 106 | %if %{undefined kobj} 107 | %define kobj %{kdir} 108 | %endif 109 | %else 110 | 111 | # Fedora: 112 | %if %{defined fedora} 113 | %if %{undefined kver} 114 | %define klnk %{_usrsrc}/kernels/*/include/config 115 | %define kver %((echo X; %{__cat} %{klnk}/kernel.release 116 | 2>/dev/null) | tail -1) 117 | %endif 118 | %define kpkg kernel 119 | %define kdevpkg kernel-devel 120 | %define kverpkg %(echo %{kver} | %{__sed} -e 's/.%{_target_cpu}//g') 121 | %define koppkg = 122 | %if %{undefined kdir} 123 | %define kdir %{_usrsrc}/kernels/%{kver} 124 | %endif 125 | %if %{undefined kobj} 126 | %define kobj %{kdir} 127 | %endif 128 | %else 129 | 130 | # Unsupported distro: 131 | %if %{undefined kver} 132 | %define kver %(uname -r) 133 | %endif 134 | %define kverpkg %{kver} 135 | %if %{undefined kdir} 136 | %define kdir /lib/modules/%{kver}/build 137 | %endif 138 | %if %{undefined kobj} 139 | %define kobj %{kdir} 140 | %endif 141 | 142 | %endif 143 | %endif 144 | %endif 145 | %endif 146 | 147 | %define name @PACKAGE@ 148 | %define version @VERSION@ 149 | %if %{defined build_src_rpm} 150 | %define release 1 151 | %define requires %{kpkg} 152 | %define devel_requires %{kdevpkg} 153 | %else 154 | %define relext %(echo %{kverpkg} | %{__sed} -e 's/-/_/g') 155 | %define release @LZFS_META_RELEASE@_%{relext} 156 | %define requires %{kpkg} %{koppkg} %{kverpkg} 157 | %define devel_requires %{kdevpkg} %{koppkg} %{kverpkg} 158 | %define debug_package %{nil} 159 | %endif 160 | 161 | 162 | %if %{defined require_spldir} 163 | %define spldir %{require_spldir} 164 | %endif 165 | 166 | %if %{defined require_zfsdir} 167 | %define zfsdir %{require_zfsdir} 168 | %endif 169 | 170 | 171 | Summary: LZFS 172 | Group: Utilities/System 173 | Name: %{name} 174 | Version: %{version} 175 | Release: %{release} 176 | License: GPL 177 | URL: KQ 178 | BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id} -un) 179 | Source: %{name}-%{version}.tar.gz 180 | Requires: %{requires} spl spl-modules zfs zfs-modules python-dmidecode SOAPpy 181 | 182 | 183 | %description 184 | The %{name} package contains POSIX porting layer to zfs file system. 185 | 186 | 187 | %prep 188 | %setup 189 | %build 190 | %configure --with-linux=%{kdir} --with-linux-obj=%{kobj} \ 191 | --with-spl=%{spldir} --with-zfs=%{zfsdir} 192 | make 193 | 194 | %install 195 | rm -rf $RPM_BUILD_ROOT 196 | make DESTDIR=$RPM_BUILD_ROOT install 197 | 198 | %clean 199 | rm -rf $RPM_BUILD_ROOT 200 | 201 | %files 202 | %defattr(-, root, root) 203 | /lib/modules/* 204 | %doc META ChangeLog COPYING 205 | %{_prefix}/src/* 206 | %attr(0755,root,root) %{_sysconfdir}/init.d/zfsload 207 | /usr/sbin/zfs_manage.py 208 | /usr/sbin/SystemReport.sh 209 | /etc/zfs/zfs_config 210 | /etc/zfs/zfs_serial 211 | 212 | %post 213 | if [ -f /boot/System.map-%{kver} ]; then 214 | depmod -ae -F /boot/System.map-%{kver} %{kver} || exit 0 215 | else 216 | depmod -ae %{kver} || exit 0 217 | fi 218 | /sbin/chkconfig --add zfsload 219 | /sbin/service zfsload start 220 | 221 | %preun 222 | /sbin/service zfsload stop 223 | 224 | %postun 225 | if [ -f /boot/System.map-%{kver} ]; then 226 | depmod -ae -F /boot/System.map-%{kver} %{kver} || exit 0 227 | else 228 | depmod -ae %{kver} || exit 0 229 | fi 230 | 231 | -------------------------------------------------------------------------------- /lzfs_config.h: -------------------------------------------------------------------------------- 1 | /* lzfs_config.h. Generated from lzfs_config.h.in by configure. */ 2 | /* lzfs_config.h.in. Generated from configure.ac by autoheader. */ 3 | 4 | /* Define to 1 if you have the `bzero' function. */ 5 | #define HAVE_BZERO 1 6 | 7 | /* Define to 1 if you have the header file. */ 8 | #define HAVE_INTTYPES_H 1 9 | 10 | /* Define to 1 if you have the header file. */ 11 | #define HAVE_MEMORY_H 1 12 | 13 | /* Define to 1 if you have the `memset' function. */ 14 | #define HAVE_MEMSET 1 15 | 16 | /* Define to 1 if you have the header file. */ 17 | #define HAVE_STDINT_H 1 18 | 19 | /* Define to 1 if you have the header file. */ 20 | #define HAVE_STDLIB_H 1 21 | 22 | /* Define to 1 if you have the `strchr' function. */ 23 | #define HAVE_STRCHR 1 24 | 25 | /* Define to 1 if you have the header file. */ 26 | #define HAVE_STRINGS_H 1 27 | 28 | /* Define to 1 if you have the header file. */ 29 | #define HAVE_STRING_H 1 30 | 31 | /* Define to 1 if you have the header file. */ 32 | /* #undef HAVE_SYS_MNTENT_H */ 33 | 34 | /* Define to 1 if you have the header file. */ 35 | #define HAVE_SYS_STAT_H 1 36 | 37 | /* Define to 1 if you have the header file. */ 38 | #define HAVE_SYS_TYPES_H 1 39 | 40 | /* Define to 1 if you have the header file. */ 41 | #define HAVE_SYS_VFS_H 1 42 | 43 | /* Define to 1 if you have the header file. */ 44 | #define HAVE_UNISTD_H 1 45 | 46 | /* Define the project alias string. */ 47 | #define LZFS_META_ALIAS "lzfs--" 48 | 49 | /* Define the project author. */ 50 | /* #undef LZFS_META_AUTHOR */ 51 | 52 | /* Define the project release date. */ 53 | /* #undef LZFS_META_DATA */ 54 | 55 | /* Define the libtool library 'age' version information. */ 56 | /* #undef LZFS_META_LT_AGE */ 57 | 58 | /* Define the libtool library 'current' version information. */ 59 | /* #undef LZFS_META_LT_CURRENT */ 60 | 61 | /* Define the libtool library 'revision' version information. */ 62 | /* #undef LZFS_META_LT_REVISION */ 63 | 64 | /* Define the project name. */ 65 | #define LZFS_META_NAME "lzfs" 66 | 67 | /* Define the project release. */ 68 | #define LZFS_META_RELEASE "1" 69 | 70 | /* Define the project version. */ 71 | #define LZFS_META_VERSION "0.2" 72 | 73 | /* Name of package */ 74 | #define PACKAGE "lzfs" 75 | 76 | /* Define to the address where bug reports for this package should be sent. */ 77 | #define PACKAGE_BUGREPORT "" 78 | 79 | /* Define to the full name of this package. */ 80 | #define PACKAGE_NAME "" 81 | 82 | /* Define to the full name and version of this package. */ 83 | #define PACKAGE_STRING "" 84 | 85 | /* Define to the one symbol short name of this package. */ 86 | #define PACKAGE_TARNAME "" 87 | 88 | /* Define to the version of this package. */ 89 | #define PACKAGE_VERSION "" 90 | 91 | /* Define to 1 if you have the ANSI C header files. */ 92 | #define STDC_HEADERS 1 93 | 94 | /* Version number of package */ 95 | #define VERSION "0.2" 96 | 97 | /* Define for Solaris 2.5.1 so the uint32_t typedef from , 98 | , or is not used. If the typedef were allowed, the 99 | #define below would cause a syntax error. */ 100 | /* #undef _UINT32_T */ 101 | 102 | /* Define for Solaris 2.5.1 so the uint64_t typedef from , 103 | , or is not used. If the typedef were allowed, the 104 | #define below would cause a syntax error. */ 105 | /* #undef _UINT64_T */ 106 | 107 | /* Define to `__inline__' or `__inline' if that's what the C compiler 108 | calls it, or to nothing if 'inline' is not supported under any name. */ 109 | #ifndef __cplusplus 110 | /* #undef inline */ 111 | #endif 112 | 113 | /* Define to `unsigned int' if does not define. */ 114 | /* #undef size_t */ 115 | 116 | /* Define to `int' if does not define. */ 117 | /* #undef ssize_t */ 118 | 119 | /* Define to the type of an unsigned integer type of width exactly 32 bits if 120 | such a type exists and the standard includes do not define it. */ 121 | /* #undef uint32_t */ 122 | 123 | /* Define to the type of an unsigned integer type of width exactly 64 bits if 124 | such a type exists and the standard includes do not define it. */ 125 | /* #undef uint64_t */ 126 | -------------------------------------------------------------------------------- /lzfs_config.h.in: -------------------------------------------------------------------------------- 1 | /* lzfs_config.h.in. Generated from configure.ac by autoheader. */ 2 | 3 | /* Define to 1 if you have the `bzero' function. */ 4 | #undef HAVE_BZERO 5 | 6 | /* Define to 1 if you have the header file. */ 7 | #undef HAVE_INTTYPES_H 8 | 9 | /* Define to 1 if you have the header file. */ 10 | #undef HAVE_MEMORY_H 11 | 12 | /* Define to 1 if you have the `memset' function. */ 13 | #undef HAVE_MEMSET 14 | 15 | /* Define to 1 if you have the header file. */ 16 | #undef HAVE_STDINT_H 17 | 18 | /* Define to 1 if you have the header file. */ 19 | #undef HAVE_STDLIB_H 20 | 21 | /* Define to 1 if you have the `strchr' function. */ 22 | #undef HAVE_STRCHR 23 | 24 | /* Define to 1 if you have the header file. */ 25 | #undef HAVE_STRINGS_H 26 | 27 | /* Define to 1 if you have the header file. */ 28 | #undef HAVE_STRING_H 29 | 30 | /* Define to 1 if you have the header file. */ 31 | #undef HAVE_SYS_MNTENT_H 32 | 33 | /* Define to 1 if you have the header file. */ 34 | #undef HAVE_SYS_STAT_H 35 | 36 | /* Define to 1 if you have the header file. */ 37 | #undef HAVE_SYS_TYPES_H 38 | 39 | /* Define to 1 if you have the header file. */ 40 | #undef HAVE_SYS_VFS_H 41 | 42 | /* Define to 1 if you have the header file. */ 43 | #undef HAVE_UNISTD_H 44 | 45 | /* Define the project alias string. */ 46 | #undef LZFS_META_ALIAS 47 | 48 | /* Define the project author. */ 49 | #undef LZFS_META_AUTHOR 50 | 51 | /* Define the project release date. */ 52 | #undef LZFS_META_DATA 53 | 54 | /* Define the libtool library 'age' version information. */ 55 | #undef LZFS_META_LT_AGE 56 | 57 | /* Define the libtool library 'current' version information. */ 58 | #undef LZFS_META_LT_CURRENT 59 | 60 | /* Define the libtool library 'revision' version information. */ 61 | #undef LZFS_META_LT_REVISION 62 | 63 | /* Define the project name. */ 64 | #undef LZFS_META_NAME 65 | 66 | /* Define the project release. */ 67 | #undef LZFS_META_RELEASE 68 | 69 | /* Define the project version. */ 70 | #undef LZFS_META_VERSION 71 | 72 | /* Name of package */ 73 | #undef PACKAGE 74 | 75 | /* Define to the address where bug reports for this package should be sent. */ 76 | #undef PACKAGE_BUGREPORT 77 | 78 | /* Define to the full name of this package. */ 79 | #undef PACKAGE_NAME 80 | 81 | /* Define to the full name and version of this package. */ 82 | #undef PACKAGE_STRING 83 | 84 | /* Define to the one symbol short name of this package. */ 85 | #undef PACKAGE_TARNAME 86 | 87 | /* Define to the home page for this package. */ 88 | #undef PACKAGE_URL 89 | 90 | /* Define to the version of this package. */ 91 | #undef PACKAGE_VERSION 92 | 93 | /* Define to 1 if you have the ANSI C header files. */ 94 | #undef STDC_HEADERS 95 | 96 | /* Version number of package */ 97 | #undef VERSION 98 | 99 | /* Define for Solaris 2.5.1 so the uint32_t typedef from , 100 | , or is not used. If the typedef were allowed, the 101 | #define below would cause a syntax error. */ 102 | #undef _UINT32_T 103 | 104 | /* Define for Solaris 2.5.1 so the uint64_t typedef from , 105 | , or is not used. If the typedef were allowed, the 106 | #define below would cause a syntax error. */ 107 | #undef _UINT64_T 108 | 109 | /* Define to `__inline__' or `__inline' if that's what the C compiler 110 | calls it, or to nothing if 'inline' is not supported under any name. */ 111 | #ifndef __cplusplus 112 | #undef inline 113 | #endif 114 | 115 | /* Define to `unsigned int' if does not define. */ 116 | #undef size_t 117 | 118 | /* Define to `int' if does not define. */ 119 | #undef ssize_t 120 | 121 | /* Define to the type of an unsigned integer type of width exactly 32 bits if 122 | such a type exists and the standard includes do not define it. */ 123 | #undef uint32_t 124 | 125 | /* Define to the type of an unsigned integer type of width exactly 64 bits if 126 | such a type exists and the standard includes do not define it. */ 127 | #undef uint64_t 128 | -------------------------------------------------------------------------------- /module/Makefile.in: -------------------------------------------------------------------------------- 1 | # Makefile.in for lzfs module 2 | 3 | MODULES := lzfs 4 | EXTRA_CFLAGS = @KERNELCPPFLAGS@ 5 | EXTRA_CFLAGS += -include @SPL_OBJ@/spl_config.h 6 | EXTRA_CFLAGS += -I@abs_top_srcdir@/include 7 | # lzfs module 8 | obj-m := lzfs.o 9 | 10 | lzfs-objs += lzfs_super.o 11 | lzfs-objs += lzfs_vnops.o 12 | lzfs-objs += lzfs_snap.o 13 | lzfs-objs += lzfs_exportfs.o 14 | lzfs-objs += lzfs_xattr.o 15 | lzfs-objs += lzfs_xattr_user.o 16 | lzfs-objs += lzfs_xattr_security.o 17 | lzfs-objs += lzfs_xattr_acl.o 18 | 19 | 20 | INSTALL=/usr/bin/install 21 | 22 | 23 | modules: 24 | @# Make the exported ZFS symbols available to these modules. 25 | @# They may be in the root of ZFS_OBJ when building against 26 | @# installed devel headers, or they may be in the module 27 | @# subdirectory when building against the spl source tree. 28 | @if [ -f @ZFS_OBJ@/@ZFS_SYMBOLS@ ]; then \ 29 | /bin/cp @ZFS_OBJ@/@ZFS_SYMBOLS@ .; \ 30 | elif [ -f @ZFS_OBJ@/module/@ZFS_SYMBOLS@ ]; then \ 31 | /bin/cp @ZFS_OBJ@/module/@ZFS_SYMBOLS@ .; \ 32 | else \ 33 | echo -e "\n" \ 34 | "*** Missing spl symbols ensure you have built the spl:\n" \ 35 | "*** - @ZFS_OBJ@/@ZFS_SYMBOLS@, or\n" \ 36 | "*** - @ZFS_OBJ@/module/@ZFS_SYMBOLS@\n"; \ 37 | exit 1; \ 38 | fi 39 | $(MAKE) -C @LINUX_OBJ@ SUBDIRS=`pwd` @KERNELMAKE_PARAMS@ $@ 40 | 41 | clean: 42 | $(MAKE) -C @LINUX_OBJ@ SUBDIRS=`pwd` @KERNELMAKE_PARAMS@ $@ 43 | if [ -f @ZFS_SYMBOLS@ ]; then $(RM) @ZFS_SYMBOLS@; fi 44 | if [ -f @LINUX_SYMBOLS@ ]; then $(RM) @LINUX_SYMBOLS@; fi 45 | if [ -f Module.markers ]; then $(RM) Module.markers; fi 46 | 47 | modules_install: 48 | $(MAKE) -C @LINUX_OBJ@ SUBDIRS=`pwd` \ 49 | INSTALL_MOD_PATH=$(DESTDIR) \ 50 | INSTALL_MOD_DIR=addon/lzfs $@ 51 | find ${DESTDIR}/lib/modules/ -name 'modules.*' | xargs ${RM} 52 | sysmap=${DESTDIR}/boot/System.map-@LINUX_VERSION@; \ 53 | if [ -f $$sysmap ]; then \ 54 | depmod -ae -F $$sysmap @LINUX_VERSION@; \ 55 | fi 56 | 57 | modules_uninstall: 58 | @# Uninstall the kernel modules 59 | $(RM) -R $(DESTDIR)/lib/modules/@LINUX_VERSION@/addon/lzfs 60 | 61 | distdir: 62 | (find ./ -name '*.c' -o -name '*.h' | \ 63 | xargs /bin/cp -t $$distdir/$$subdir); \ 64 | 65 | distclean maintainer-clean: clean 66 | install: modules_install 67 | uninstall: modules_uninstall 68 | all: modules 69 | check: 70 | -------------------------------------------------------------------------------- /module/lzfs_exportfs.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the LZPL: Linux ZFS Posix Layer 3 | * 4 | * Copyright (c) 2010 Knowledge Quest Infotech Pvt. Ltd. 5 | * Produced at Knowledge Quest Infotech Pvt. Ltd. 6 | * Written by: Knowledge Quest Infotech Pvt. Ltd. 7 | * zfs@kqinfotech.com 8 | * 9 | * This is free software; you can redistribute it and/or modify it 10 | * under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This is distributed in the hope that it will be useful, but WITHOUT 15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 17 | * for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License along 20 | * with this program; if not, write to the Free Software Foundation, Inc., 21 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 22 | */ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #ifdef SS_DEBUG_SUBSYS 32 | #undef SS_DEBUG_SUBSYS 33 | #endif 34 | 35 | /* 36 | * Log LZFS debug messages as the spl SS_USER2 subsystem. 37 | */ 38 | #define SS_DEBUG_SUBSYS SS_USER2 39 | 40 | extern int zfs_fid(vnode_t *vp, fid_t *fidp, caller_context_t *ct); 41 | extern int zfs_vget(vfs_t *vfsp, vnode_t **vpp, fid_t *fidp); 42 | extern int zfs_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, struct pathname *pnp, 43 | int flags, vnode_t *rdir, cred_t *cr, caller_context_t *ct, 44 | int *direntflags, pathname_t *realpnp); 45 | 46 | static int lzfs_encode_fh(struct dentry *dentry, u32 *fh, int *max_len, int connectable) 47 | { 48 | lzfs_fid_t *lzfid = (lzfs_fid_t *)fh; 49 | struct inode *inode = dentry->d_inode; 50 | int lfid_type = LZFS_FILEID_INO64_GEN; 51 | vnode_t *vp; 52 | int error = 0; 53 | 54 | SENTRY; 55 | lzfid->fid_len = *max_len; 56 | if (!(S_ISDIR(inode->i_mode) || !connectable)) { 57 | spin_lock(&dentry->d_lock); 58 | inode = dentry->d_parent->d_inode; 59 | spin_unlock(&dentry->d_lock); 60 | lfid_type = LZFS_FILEID_INO64_GEN_PARENT; 61 | } 62 | /* If inode number is -1 then we looking into .zfs(ZFS control 63 | * directory). Traversing .zfs from the NFS is not supported yet. 64 | */ 65 | if (inode->i_ino == -1) { 66 | return 255; 67 | } 68 | 69 | vp = LZFS_ITOV(inode); 70 | error = zfs_fid( vp, lzfid, 0); 71 | tsd_exit(); 72 | SEXIT; 73 | 74 | if (error) { 75 | printk(KERN_WARNING "Unable to get file handle \n"); 76 | return 255; 77 | } 78 | 79 | *max_len = lzfid->fid_len; 80 | 81 | return lfid_type; 82 | } 83 | 84 | struct dentry * lzfs_fh_to_dentry(struct super_block *sb, struct fid *fid, 85 | int fh_len, int fh_type) 86 | { 87 | lzfs_fid_t *lzfid = (lzfs_fid_t *)fid; 88 | vfs_t *vfsp = sb->s_fs_info; 89 | vnode_t *vp; 90 | int error = 0; 91 | struct dentry *dentry = NULL; 92 | 93 | SENTRY; 94 | if (fh_len < 2) { 95 | return NULL; 96 | } 97 | 98 | switch (fh_type) { 99 | case LZFS_FILEID_INO64_GEN : 100 | case LZFS_FILEID_INO64_GEN_PARENT : 101 | error = zfs_vget( vfsp, &vp, lzfid); 102 | break; 103 | } 104 | 105 | tsd_exit(); 106 | SEXIT; 107 | if (error) { 108 | printk(KERN_WARNING "Unable to get vnode \n"); 109 | return NULL; 110 | } 111 | 112 | if (LZFS_VTOI(vp)) { 113 | #ifdef HAVE_D_ALLOC_ANON /* for kernel version < 2.6.28 */ 114 | dentry = d_alloc_anon(LZFS_VTOI(vp)); 115 | #else 116 | dentry = d_obtain_alias(LZFS_VTOI(vp)); 117 | #endif 118 | } 119 | return dentry; 120 | } 121 | 122 | struct dentry *lzfs_get_parent(struct dentry *child) 123 | { 124 | vnode_t *vcp = LZFS_ITOV(child->d_inode); 125 | vnode_t *vp; 126 | int error = 0; 127 | struct dentry *dentry = NULL; 128 | const cred_t *cred = get_current_cred(); 129 | 130 | SENTRY; 131 | error = zfs_lookup(vcp, "..", &vp, NULL, 0 , NULL, 132 | (cred_t *) cred, NULL, NULL, NULL); 133 | 134 | (void)put_cred(cred); 135 | tsd_exit(); 136 | SEXIT; 137 | if (error) { 138 | if (error == ENOENT) { 139 | printk(KERN_WARNING "Try to get new dentry \n"); 140 | return d_splice_alias(NULL, dentry); 141 | } else { 142 | printk(KERN_WARNING "Unable to get dentry \n"); 143 | return ERR_PTR(-error); 144 | } 145 | } 146 | 147 | if (LZFS_VTOI(vp)) { 148 | #ifdef HAVE_D_ALLOC_ANON /* for kernel version < 2.6.28 */ 149 | dentry = d_alloc_anon(LZFS_VTOI(vp)); 150 | #else 151 | dentry = d_obtain_alias(LZFS_VTOI(vp)); 152 | #endif 153 | } 154 | return dentry; 155 | 156 | } 157 | 158 | const struct export_operations zfs_export_ops = { 159 | .encode_fh = lzfs_encode_fh, 160 | .fh_to_dentry = lzfs_fh_to_dentry, 161 | .fh_to_parent = lzfs_fh_to_dentry, 162 | .get_parent = lzfs_get_parent, 163 | }; 164 | -------------------------------------------------------------------------------- /module/lzfs_snap.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the LZPL: Linux ZFS Posix Layer 3 | * 4 | * Copyright (c) 2010 Knowledge Quest Infotech Pvt. Ltd. 5 | * Produced at Knowledge Quest Infotech Pvt. Ltd. 6 | * Written by: Knowledge Quest Infotech Pvt. Ltd. 7 | * zfs@kqinfotech.com 8 | * 9 | * This is free software; you can redistribute it and/or modify it 10 | * under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This is distributed in the hope that it will be useful, but WITHOUT 15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 17 | * for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License along 20 | * with this program; if not, write to the Free Software Foundation, Inc., 21 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 22 | */ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | #ifdef SS_DEBUG_SUBSYS 35 | #undef SS_DEBUG_SUBSYS 36 | #endif 37 | 38 | /* 39 | * Log LZFS debug messages as the spl SS_USER2 subsystem. 40 | */ 41 | #define SS_DEBUG_SUBSYS SS_USER2 42 | 43 | extern void zfs_fs_name_fn(void *, char *); 44 | extern int zfs_snapshot_list_next(void *, char *, uint64_t *, 45 | uint64_t *, boolean_t *); 46 | extern void set_zfsvfs_ctldir(void *, vnode_t *); 47 | extern void zfsctl_dir_destroy(void *); 48 | extern uint64_t zfs_snapname_to_id(void *void_ptr, const char *snapname); 49 | 50 | /* 51 | * Readdir implementation for the .zfs directory 52 | * which contains only two directories inside named 53 | * snapshot and shares. We are currently only done with 54 | * snapshot. 55 | */ 56 | 57 | static int 58 | zfsctl_readdir(struct file *filp, void *dirent, filldir_t filldir) 59 | { 60 | struct dentry *dentry = filp->f_path.dentry; 61 | u64 ino; 62 | int i = filp->f_pos; 63 | 64 | switch (i) { 65 | case 0: 66 | ino = dentry->d_inode->i_ino; 67 | if (filldir(dirent, ".", 1, i, ino, DT_DIR) < 0) 68 | break; 69 | filp->f_pos++; 70 | i++; 71 | case 1: 72 | ino = parent_ino(dentry); 73 | if (filldir(dirent, "..", 2, i, ino, DT_DIR) < 0) 74 | break; 75 | filp->f_pos++; 76 | i++; 77 | case 2: 78 | if (filldir(dirent, ZFS_SNAPDIR_NAME, strlen(ZFS_SNAPDIR_NAME), i, 79 | LZFS_ZFSCTL_INO_SNAPDIR, DT_DIR) < 0) 80 | break; 81 | filp->f_pos++; 82 | } 83 | return 0; 84 | } 85 | 86 | /* 87 | * Lookup defined for .zfs directory currently for dir name 88 | * snapshot only later need to do for shares dir 89 | */ 90 | 91 | static struct dentry * 92 | zfsctl_lookup(struct inode *dir,struct dentry *dentry, struct nameidata *nd) 93 | { 94 | struct inode *inode = NULL; 95 | 96 | if (dentry->d_name.len >= MAXNAMELEN) { 97 | return ERR_PTR(-ENAMETOOLONG); 98 | } 99 | if (strcmp(dentry->d_name.name, ZFS_SNAPDIR_NAME) == 0) { 100 | inode = ilookup(dir->i_sb, LZFS_ZFSCTL_INO_SNAPDIR); 101 | if(!inode) { 102 | return NULL; 103 | } 104 | return d_splice_alias(inode, dentry); 105 | } else { 106 | return d_splice_alias(NULL, dentry); 107 | } 108 | } 109 | 110 | /* 111 | * readdir for snapshot dir which contains directory entries 112 | * for all snapshots created gets it from dmu_snapshot_list_next 113 | */ 114 | 115 | static int 116 | snap_readdir(struct file *filp, void *dirent, filldir_t filldir) 117 | { 118 | vnode_t *dir_vp; 119 | struct inode *dir = filp->f_path.dentry->d_inode; 120 | char snapname[MAXNAMELEN]; 121 | uint64_t id, cookie; 122 | boolean_t case_conflict; 123 | int error, rc; 124 | vfs_t *vfsp = NULL; 125 | 126 | dir_vp = LZFS_ITOV(dir); 127 | vfsp = dir_vp->v_vfsp; 128 | cookie = filp->f_pos; 129 | rc = error = 0; 130 | if (!filp->f_pos) { 131 | rc = filldir(dirent, ".", 1, filp->f_pos, dir->i_ino, DT_DIR); 132 | if(rc) 133 | goto done; 134 | filp->f_pos++; 135 | } 136 | if (filp->f_pos == 1) { 137 | rc = filldir(dirent, "..", 2, filp->f_pos, 138 | parent_ino(filp->f_path.dentry), DT_DIR); 139 | if(rc) { 140 | goto done; 141 | } 142 | filp->f_pos++; 143 | } 144 | 145 | while (!(error = zfs_snapshot_list_next(vfsp->vfs_data, snapname, &id, 146 | &cookie, &case_conflict))) { 147 | ASSERT(id > 0); 148 | rc = filldir(dirent, snapname, strlen(snapname), filp->f_pos, 149 | LZFS_ZFSCTL_INO_SHARES - id, DT_DIR); 150 | filp->f_pos = cookie; // next position ptr 151 | } 152 | if (error) { 153 | if (error == ENOENT) { 154 | return (0); 155 | } 156 | return PTR_ERR(ERR_PTR(-error)); 157 | } 158 | 159 | done: 160 | return 0; 161 | } 162 | 163 | static void* 164 | snap_mountpoint_follow_link(struct dentry *dentry, struct nameidata *nd) 165 | { 166 | struct vfsmount *mnt = ERR_PTR(-ENOENT); 167 | vnode_t *dir_vp = NULL; 168 | char *snapname = NULL; 169 | char *zfs_fs_name = NULL; 170 | int rc = 0; 171 | vfs_t *vfsp = NULL; 172 | 173 | ASSERT(dentry->d_parent); 174 | dir_vp = LZFS_ITOV(dentry->d_parent->d_inode); 175 | vfsp = dir_vp->v_vfsp; 176 | ASSERT(vfsp); 177 | zfs_fs_name = kzalloc(MAXNAMELEN, KM_SLEEP); 178 | dput(nd->path.dentry); 179 | nd->path.dentry = dget(dentry); 180 | zfs_fs_name_fn(vfsp->vfs_data, zfs_fs_name); 181 | snapname = kzalloc(strlen(zfs_fs_name) + 182 | strlen(dentry->d_name.name) + 2, KM_SLEEP); 183 | snapname = strncpy(snapname, zfs_fs_name, strlen(zfs_fs_name) + 1); 184 | snapname = strcat(snapname, "@"); 185 | snapname = strcat(snapname, dentry->d_name.name); 186 | mnt = vfs_kern_mount(&lzfs_fs_type, 0, snapname, NULL); 187 | ((vfs_t *)mnt->mnt_sb->s_fs_info)->vfs_mntpt = dentry; 188 | mntget(mnt); 189 | rc = PTR_ERR(mnt); 190 | if (IS_ERR(mnt)) { 191 | goto out_err; 192 | } 193 | mnt->mnt_mountpoint = dentry; 194 | ASSERT(nd); 195 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) 196 | rc = do_add_mount(mnt, nd, 197 | nd->path.mnt->mnt_flags | MNT_READONLY, NULL); 198 | #else 199 | rc = do_add_mount(mnt, &nd->path, 200 | nd->path.mnt->mnt_flags | MNT_READONLY, NULL); 201 | #endif 202 | switch (rc) { 203 | case 0: 204 | path_put(&nd->path); 205 | nd->path.mnt = mnt; 206 | nd->path.dentry = dget(mnt->mnt_root); 207 | break; 208 | case -EBUSY: 209 | 210 | nd->path.dentry = dget(mnt->mnt_root); 211 | /* someone else made a mount here whilst we were busy */ 212 | 213 | #ifdef HAVE_2ARGS_FOLLOW_DOWN /* for kernel version < 2.6.31 */ 214 | while (d_mountpoint(nd->path.dentry) && 215 | follow_down(&mnt, &nd->path.dentry)) { 216 | ; 217 | } 218 | #else 219 | while (d_mountpoint(nd->path.dentry) && 220 | follow_down(&nd->path)) { 221 | ; 222 | } 223 | #endif 224 | rc = 0; 225 | default: 226 | mntput(mnt); 227 | break; 228 | } 229 | kfree(zfs_fs_name); 230 | kfree(snapname); 231 | return ERR_PTR(rc); 232 | out_err: 233 | path_put(&nd->path); 234 | kfree(zfs_fs_name); 235 | kfree(snapname); 236 | return ERR_PTR(rc); 237 | } 238 | 239 | const struct inode_operations snap_mount_dir_inode_operations = { 240 | .follow_link = snap_mountpoint_follow_link, 241 | }; 242 | 243 | /* 244 | * Inode allocation for the snapshots directories which are 245 | * present insided the snapshot directory 246 | */ 247 | 248 | struct inode * 249 | lzfs_snapshot_iget(struct super_block *sb, unsigned long ino) 250 | { 251 | vnode_t *vp = NULL; 252 | struct inode *inode; 253 | 254 | inode = iget_locked(sb, ino); 255 | if (!inode) 256 | return ERR_PTR(-ENOMEM); 257 | if (!(inode->i_state & I_NEW)) 258 | return inode; 259 | vp = LZFS_ITOV(inode); 260 | mutex_enter(&vp->v_lock); 261 | vp->v_count = 1; 262 | mutex_exit(&vp->v_lock); 263 | inode->i_mode |= (S_IFDIR | S_IRWXU); 264 | #ifdef HAVE_CRED_STRUCT 265 | inode->i_uid = current->cred->uid; 266 | inode->i_gid = current->cred->gid; 267 | #else 268 | inode->i_uid = current->uid; 269 | inode->i_gid = current->gid; 270 | #endif 271 | inode->i_version = 1; 272 | inode->i_op = &snap_mount_dir_inode_operations; 273 | inode->i_fop = &simple_dir_operations; 274 | inode->i_sb = sb; 275 | inode->i_private = inode; 276 | unlock_new_inode(inode); 277 | return inode; 278 | } 279 | 280 | /* 281 | * looks up for the snapshot directories inode and then mounts 282 | * the snapshot dataset on that pseudo - inode's dentry. 283 | */ 284 | 285 | static struct dentry * 286 | snap_lookup(struct inode *dir,struct dentry *dentry, struct nameidata *nd) 287 | { 288 | struct inode *inode = NULL; 289 | uint64_t id; 290 | vnode_t *dir_vp = NULL; 291 | vfs_t *vfsp = NULL; 292 | struct dentry *dentry_to_return = NULL; 293 | 294 | dir_vp = LZFS_ITOV(dir); 295 | vfsp = dir_vp->v_vfsp; 296 | if (dentry->d_name.len >= MAXNAMELEN) { 297 | return ERR_PTR(-ENAMETOOLONG); 298 | } 299 | if (!(id = zfs_snapname_to_id(vfsp->vfs_data, dentry->d_name.name))) { 300 | d_add(dentry, NULL); 301 | return NULL; 302 | } 303 | inode = lzfs_snapshot_iget(vfsp->vfs_super, 304 | LZFS_ZFSCTL_INO_SHARES - id); 305 | if (unlikely(IS_ERR(inode))) { 306 | return ERR_CAST(inode); 307 | } 308 | dentry_to_return = d_splice_alias(inode, dentry); 309 | return dentry_to_return; 310 | } 311 | 312 | /* 313 | * .zfs dir fops 314 | */ 315 | 316 | const struct file_operations zfsctl_dir_file_operations = { 317 | .read = generic_read_dir, 318 | .readdir = zfsctl_readdir, 319 | }; 320 | 321 | /* 322 | * .zfs dir iops 323 | */ 324 | 325 | const struct inode_operations zfsctl_dir_inode_operations = { 326 | .lookup = zfsctl_lookup, 327 | }; 328 | 329 | /* 330 | * snapshot dir fops 331 | */ 332 | 333 | const struct file_operations snap_dir_file_operations = { 334 | .read = generic_read_dir, 335 | .readdir = snap_readdir, 336 | }; 337 | 338 | /* 339 | * snapshot dir iops 340 | */ 341 | 342 | struct inode_operations snap_dir_inode_operations = { 343 | .lookup = snap_lookup, 344 | }; 345 | 346 | /* 347 | * called from lzfs_fill_super and creates .zfs and snapshot 348 | * dirs psuedo-inodes and vnodes if the dataset to be mounted 349 | * is not a snapshot and sets their iops and fops. 350 | */ 351 | 352 | void 353 | lzfs_zfsctl_create(vfs_t *vfsp) 354 | { 355 | vnode_t *vp_zfsctl_dir = NULL, *vp_snap_dir = NULL; 356 | struct dentry *zfsctl_dir_dentry = NULL, *snap_dir_dentry = NULL; 357 | struct inode *inode_ctldir = NULL, *inode_snapdir = NULL; 358 | timestruc_t now; 359 | 360 | inode_ctldir = iget_locked(vfsp->vfs_super, LZFS_ZFSCTL_INO_ROOT); 361 | ASSERT(inode_ctldir != NULL); 362 | vp_zfsctl_dir = LZFS_ITOV(inode_ctldir); 363 | gethrestime(&now); 364 | ASSERT(inode_ctldir->i_state & I_NEW); 365 | mutex_enter(&vp_zfsctl_dir->v_lock); 366 | vp_zfsctl_dir->v_count = 1; 367 | VN_SET_VFS_TYPE_DEV(vp_zfsctl_dir, vfsp, VDIR, 0); 368 | bcopy(&now, &(vp_zfsctl_dir->v_inode.i_ctime), 369 | sizeof (timestruc_t)); 370 | bcopy(&now, &(vp_zfsctl_dir->v_inode.i_atime), 371 | sizeof (timestruc_t)); 372 | bcopy(&now,&(vp_zfsctl_dir->v_inode.i_mtime),sizeof (timestruc_t)); 373 | #ifdef HAVE_CRED_STRUCT 374 | inode_ctldir->i_uid = current->cred->uid; 375 | inode_ctldir->i_gid = current->cred->gid; 376 | #else 377 | inode_ctldir->i_uid = current->uid; 378 | inode_ctldir->i_gid = current->gid; 379 | #endif 380 | inode_ctldir->i_version = 1; 381 | inode_ctldir->i_mode |= (S_IFDIR | S_IRWXU); 382 | inode_ctldir->i_op = &zfsctl_dir_inode_operations; 383 | inode_ctldir->i_fop = &zfsctl_dir_file_operations; 384 | ASSERT(vfsp); 385 | inode_ctldir->i_sb = vfsp->vfs_super; 386 | ASSERT(vfsp->vfs_super); 387 | ASSERT(vfsp->vfs_super->s_root); 388 | unlock_new_inode(inode_ctldir); 389 | zfsctl_dir_dentry = d_alloc_name(vfsp->vfs_super->s_root, 390 | ZFS_CTLDIR_NAME); 391 | if (zfsctl_dir_dentry) { 392 | d_add(zfsctl_dir_dentry, LZFS_VTOI(vp_zfsctl_dir)); 393 | vfsp->zfsctl_dir_dentry = zfsctl_dir_dentry; 394 | } else { 395 | goto dentry_out; 396 | } 397 | set_zfsvfs_ctldir(vfsp->vfs_data, vp_zfsctl_dir); 398 | mutex_exit(&vp_zfsctl_dir->v_lock); 399 | inode_snapdir = iget_locked(vfsp->vfs_super, LZFS_ZFSCTL_INO_SNAPDIR); 400 | ASSERT(inode_snapdir != NULL); 401 | ASSERT(inode_snapdir->i_state & I_NEW); 402 | vp_snap_dir = LZFS_ITOV(inode_snapdir); 403 | gethrestime(&now); 404 | vfsp->vfs_snap_dir = vp_snap_dir; 405 | mutex_enter(&vp_snap_dir->v_lock); 406 | vp_snap_dir->v_count = 1; 407 | VN_SET_VFS_TYPE_DEV(vp_snap_dir, vfsp, VDIR, 0); 408 | bcopy(&now,&(vp_snap_dir->v_inode.i_ctime),sizeof (timestruc_t)); 409 | bcopy(&now,&(vp_snap_dir->v_inode.i_atime),sizeof (timestruc_t)); 410 | bcopy(&now,&(vp_snap_dir->v_inode.i_mtime),sizeof (timestruc_t)); 411 | #ifdef HAVE_CRED_STRUCT 412 | inode_snapdir->i_uid = current->cred->uid; 413 | inode_snapdir->i_gid = current->cred->gid; 414 | #else 415 | inode_snapdir->i_uid = current->uid; 416 | inode_snapdir->i_gid = current->gid; 417 | #endif 418 | inode_snapdir->i_version = 1; 419 | inode_snapdir->i_mode |= (S_IFDIR | S_IRWXU); 420 | inode_snapdir->i_op = &snap_dir_inode_operations; 421 | inode_snapdir->i_fop = &snap_dir_file_operations; 422 | inode_snapdir->i_sb = vfsp->vfs_super; 423 | unlock_new_inode(inode_snapdir); 424 | ASSERT(zfsctl_dir_dentry); 425 | snap_dir_dentry = d_alloc_name(zfsctl_dir_dentry, ZFS_SNAPDIR_NAME); 426 | if (snap_dir_dentry) { 427 | d_add(snap_dir_dentry, LZFS_VTOI(vp_snap_dir)); 428 | vfsp->snap_dir_dentry = snap_dir_dentry; 429 | mutex_exit(&vp_snap_dir->v_lock); 430 | } else { 431 | goto dentry_out; 432 | } 433 | return; 434 | dentry_out: 435 | // free vnode 436 | vn_free(vp_zfsctl_dir); 437 | ASSERT(0 && "TODO"); 438 | } 439 | 440 | /* 441 | * used for cleanups of .zfs and snapshot dirs 442 | */ 443 | 444 | void 445 | lzfs_zfsctl_destroy(vfs_t *vfsp) 446 | { 447 | drop_nlink(LZFS_VTOI(vfsp->vfs_snap_dir)); 448 | mutex_destroy(&(vfsp->vfs_snap_dir->v_lock)); 449 | dput(vfsp->snap_dir_dentry); 450 | zfsctl_dir_destroy(vfsp->vfs_data); 451 | dput(vfsp->zfsctl_dir_dentry); 452 | } 453 | 454 | 455 | -------------------------------------------------------------------------------- /module/lzfs_super.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the LZPL: Linux ZFS Posix Layer 3 | * 4 | * Copyright (c) 2010 Knowledge Quest Infotech Pvt. Ltd. 5 | * Produced at Knowledge Quest Infotech Pvt. Ltd. 6 | * Written by: Knowledge Quest Infotech Pvt. Ltd. 7 | * zfs@kqinfotech.com 8 | * 9 | * This is free software; you can redistribute it and/or modify it 10 | * under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This is distributed in the hope that it will be useful, but WITHOUT 15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 17 | * for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License along 20 | * with this program; if not, write to the Free Software Foundation, Inc., 21 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 22 | */ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | 48 | #ifdef SS_DEBUG_SUBSYS 49 | #undef SS_DEBUG_SUBSYS 50 | #endif 51 | 52 | /* 53 | * Log LZFS debug messages as the spl SS_USER2 subsystem. 54 | */ 55 | #define SS_DEBUG_SUBSYS SS_USER2 56 | 57 | /* symbol exported by zfs module */ 58 | extern int zfs_domount(vfs_t *vfsp, char *data); 59 | extern int zfs_root(vfs_t *vfsp, vnode_t **vvp); 60 | extern int zfs_umount(vfs_t *vfsp, int fflags, cred_t *cr); 61 | extern int zfs_statvfs(vfs_t *vfsp, struct statvfs64 *statp); 62 | extern void lzfs_zfsctl_create(vfs_t *); 63 | extern void lzfs_zfsctl_destroy(vfs_t *); 64 | 65 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36) 66 | /* TODO 67 | * Following checking needs part of lzfs/spl configuration step. 68 | */ 69 | static void lzfs_delete_vnode(struct inode *inode) 70 | { 71 | #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,31) 72 | loff_t oldsize = i_size_read(inode); 73 | 74 | i_size_write(inode, 0); 75 | truncate_pagecache(inode, oldsize, 0); 76 | clear_inode(inode); 77 | #else 78 | struct address_space *mapping = inode->i_mapping; 79 | loff_t new = 0; 80 | 81 | i_size_write(inode, 0); 82 | unmap_mapping_range(mapping, new + PAGE_SIZE - 1, 0, 1); 83 | truncate_inode_pages(mapping, new); 84 | unmap_mapping_range(mapping, new + PAGE_SIZE - 1, 0, 1); 85 | clear_inode(inode); 86 | #endif 87 | } 88 | 89 | static void 90 | lzfs_clear_vnode(struct inode *inode) 91 | { 92 | vnode_t *vp; 93 | 94 | SENTRY; 95 | vp = LZFS_ITOV(inode); 96 | 97 | ASSERT(vp->v_count == 1); 98 | 99 | /* znode associated with this vnode is freed by zfs_inactive. 100 | * 101 | * each snapshot psuedo-inode does not contain corresponding 102 | * znode on-disk hence we need not call zfs_inactive for those 103 | * inodes i_private field of those inode is set to struct inode 104 | * and is not NULL to distinguish them with other inodes having 105 | * znode 106 | */ 107 | if(inode->i_ino != LZFS_ZFSCTL_INO_ROOT 108 | && inode->i_ino != LZFS_ZFSCTL_INO_SNAPDIR 109 | && inode->i_private == NULL ) { 110 | zfs_inactive(vp, NULL, NULL); 111 | } 112 | vp->v_data = NULL; 113 | SEXIT; 114 | } 115 | #else 116 | static void 117 | lzfs_evict_vnode(struct inode *inode) 118 | { 119 | loff_t oldsize = i_size_read(inode); 120 | vnode_t *vp; 121 | 122 | i_size_write(inode, 0); 123 | truncate_pagecache(inode, oldsize, 0); 124 | 125 | end_writeback(inode); 126 | 127 | if (inode->i_nlink) 128 | return; 129 | 130 | /* delete the inode */ 131 | vp = LZFS_ITOV(inode); 132 | 133 | ASSERT(vp->v_count == 1); 134 | if(inode->i_ino != LZFS_ZFSCTL_INO_ROOT 135 | && inode->i_ino != LZFS_ZFSCTL_INO_SNAPDIR 136 | && inode->i_private == NULL ) { 137 | zfs_inactive(vp, NULL, NULL); 138 | } 139 | vp->v_data = NULL; 140 | } 141 | #endif 142 | 143 | static void 144 | lzfs_put_super(struct super_block *sb) 145 | { 146 | struct dentry *mntpnt = ((vfs_t *)sb->s_fs_info)->vfs_mntpt; 147 | 148 | SENTRY; 149 | zfs_umount(sb->s_fs_info, 0, NULL); 150 | if(((vfs_t *)sb->s_fs_info)->is_snap) { 151 | d_invalidate(mntpnt); 152 | } 153 | kfree(sb->s_fs_info); 154 | SEXIT; 155 | } 156 | 157 | static struct inode * 158 | lzfs_alloc_vnode(struct super_block *sb) 159 | { 160 | vnode_t *vp = NULL; 161 | 162 | SENTRY; 163 | vp = vn_alloc(KM_SLEEP); 164 | bzero(vp, sizeof(vnode_t)); 165 | mutex_init(&vp->v_lock, NULL, MUTEX_DEFAULT, NULL); 166 | inode_init_once(LZFS_VTOI(vp)); 167 | LZFS_VTOI(vp)->i_version = 1; 168 | SEXIT; 169 | return LZFS_VTOI(vp); 170 | } 171 | 172 | static void 173 | lzfs_destroy_vnode(struct inode *inode) 174 | { 175 | mutex_destroy(&(LZFS_ITOV(inode))->v_lock); 176 | vn_free(LZFS_ITOV(inode)); 177 | } 178 | 179 | /* Structure to keep all the zfs related callback routines. 180 | */ 181 | 182 | static inline vfs_t* lzfs_super(struct super_block *sb) 183 | { 184 | return sb->s_fs_info; 185 | } 186 | 187 | static int lzfs_statfs(struct dentry *dentry, struct kstatfs *statfs) 188 | { 189 | struct super_block *sb = dentry->d_sb; 190 | vfs_t *vfsp = lzfs_super(sb); 191 | struct statvfs64 stat; 192 | 193 | BUG_ON(zfs_statvfs(vfsp, &stat)); 194 | 195 | statfs->f_type = vfsp->vfs_magic; 196 | statfs->f_bsize = stat.f_frsize; 197 | statfs->f_blocks = stat.f_blocks; 198 | statfs->f_bfree = stat.f_bfree; 199 | statfs->f_bavail = stat.f_bavail; 200 | statfs->f_files = stat.f_files; 201 | statfs->f_ffree = stat.f_ffree; 202 | statfs->f_namelen = stat.f_namemax; 203 | statfs->f_fsid.val[0] = (u32)stat.f_fsid; 204 | statfs->f_fsid.val[1] = (u32)(stat.f_fsid >> 32); 205 | 206 | return 0; 207 | } 208 | 209 | 210 | static int lzfs_show_options(struct seq_file *seq, struct vfsmount *vfsmnt) 211 | { 212 | vfs_t *vfsp = lzfs_super(vfsmnt->mnt_sb); 213 | /* 214 | if (vfs_isreadonly(vfsp)) 215 | seq_printf(seq, ",%s", MNTOPT_RO); 216 | else 217 | seq_printf(seq, ",%s", MNTOPT_RW); 218 | */ 219 | 220 | if (vfs_isatime(vfsp)) 221 | seq_printf(seq, ",%s", MNTOPT_ATIME); 222 | else { 223 | /* Linux Kernel Displays noatime when set, we need not do it */ 224 | // seq_printf(seq, ",%s", MNTOPT_NOATIME); 225 | } 226 | 227 | if (vfs_isxattr(vfsp)) 228 | seq_printf(seq, ",%s", MNTOPT_XATTR); 229 | else 230 | seq_printf(seq, ",%s", MNTOPT_NOXATTR); 231 | 232 | if (!vfs_issuid(vfsp)) { 233 | seq_printf(seq, ",%s", MNTOPT_NOSUID); 234 | // seq_printf(seq, ",%s", MNTOPT_NODEVICES); 235 | // seq_printf(seq, ",%s", MNTOPT_NOSETUID); 236 | } else { 237 | seq_printf(seq, ",%s", MNTOPT_SUID); 238 | if (vfs_isdevice(vfsp)) 239 | seq_printf(seq, ",%s", MNTOPT_DEVICES); 240 | else { 241 | /* Linux Kernel Displays nodev by default */ 242 | // seq_printf(seq, ",%s", MNTOPT_NODEVICES); 243 | } 244 | 245 | if (vfs_issetuid(vfsp)) 246 | seq_printf(seq, ",%s", MNTOPT_SETUID); 247 | else 248 | seq_printf(seq, ",%s", MNTOPT_NOSETUID); 249 | } 250 | 251 | if (vfs_isexec(vfsp)) 252 | seq_printf(seq, ",%s", MNTOPT_EXEC); 253 | else { 254 | /* Linux Kernel Displays noexec by default */ 255 | // seq_printf(seq, ",%s", MNTOPT_NOEXEC); 256 | } 257 | return 0; 258 | } 259 | 260 | static const struct super_operations lzfs_ops = { 261 | .alloc_inode = lzfs_alloc_vnode, 262 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36) 263 | .clear_inode = lzfs_clear_vnode, 264 | .delete_inode = lzfs_delete_vnode, 265 | #else 266 | .evict_inode = lzfs_evict_vnode, 267 | #endif 268 | .destroy_inode = lzfs_destroy_vnode, 269 | .put_super = lzfs_put_super, 270 | .statfs = lzfs_statfs, 271 | .show_options = lzfs_show_options, 272 | }; 273 | 274 | static int 275 | lzfs_fill_super(struct super_block *sb, void *data, int silent) 276 | { 277 | int error = 0; 278 | vfs_t *vfsp = NULL; 279 | vnode_t *root_vnode = NULL; 280 | struct inode *root_inode = NULL; 281 | struct dentry *root_dentry = NULL; 282 | long ret = -EINVAL; 283 | 284 | SENTRY; 285 | 286 | vfsp = (vfs_t *) kzalloc(sizeof(vfs_t), KM_SLEEP); 287 | vfsp->vfs_set_inode_ops = lzfs_set_inode_ops; 288 | vfsp->vfs_super = sb; 289 | sb->s_maxbytes = MAX_LFS_FILESIZE; 290 | sb->s_op = &lzfs_ops; 291 | sb->s_time_gran = 1; 292 | sb->s_flags = MS_ACTIVE; 293 | sb->s_flags |= MS_POSIXACL; 294 | sb->s_export_op = &zfs_export_ops; 295 | sb->s_xattr = lzfs_xattr_handlers; 296 | error = zfs_domount(vfsp, data); 297 | if (error) { 298 | printk(KERN_WARNING "mount failed to open the pool!!\n"); 299 | goto mount_failed; 300 | } 301 | 302 | vfsp->vfs_magic = (uint32_t) ZFS_MAGIC; 303 | sb->s_fs_info = vfsp; 304 | sb->s_magic = vfsp->vfs_magic; 305 | if (!strchr((char *) data, '@')) { 306 | vfsp->is_snap = 0; 307 | } else { 308 | vfsp->is_snap = 1; 309 | } 310 | 311 | sb->s_blocksize = vfsp->vfs_bsize; 312 | sb->s_blocksize_bits = ilog2(vfsp->vfs_bsize); 313 | sb->s_time_gran = 1; 314 | 315 | zfs_root(sb->s_fs_info, &root_vnode); 316 | if (!root_vnode) { 317 | printk(KERN_WARNING "root inode failed to allocate"); 318 | goto mount_failed; 319 | } 320 | // root_inode = &root_vnode->v_inode; 321 | root_inode = LZFS_VTOI(root_vnode); 322 | root_dentry = d_alloc_root(root_inode); 323 | if (!root_dentry) { 324 | printk(KERN_WARNING "chkneep4: %s\n", __FUNCTION__); 325 | goto mount_failed; 326 | } 327 | 328 | sb->s_root = root_dentry; 329 | 330 | if (!strchr((char *) data, '@')) { 331 | lzfs_zfsctl_create(vfsp); 332 | } 333 | SEXIT; 334 | return 0; 335 | 336 | mount_failed: 337 | sb->s_fs_info = NULL; 338 | kfree(vfsp); 339 | SEXIT; 340 | return (ret); 341 | } 342 | 343 | extern int zfs_register_callbacks(vfs_t *vfsp); 344 | 345 | static int 346 | lzfs_get_sb(struct file_system_type *fs_type, 347 | int flags, const char *dev_name, 348 | void *data, struct vfsmount *mnt) 349 | { 350 | int rc; 351 | vfs_t *vfsp = NULL; 352 | 353 | /* get the pool/file-system name in the dev_name 354 | * There is no need for a block device for this file system. 355 | * Let's call get_sb_nodev. 356 | */ 357 | SENTRY; 358 | rc = get_sb_nodev(fs_type, flags, (void *)dev_name, 359 | lzfs_fill_super, mnt); 360 | 361 | if (rc) 362 | return rc; 363 | 364 | vfsp = lzfs_super(mnt->mnt_sb); 365 | vfsp->vfsmnt = mnt; 366 | 367 | /* copy the mount flags information (from Linux Kernel) to 368 | * zfs file system 369 | * */ 370 | 371 | if (flags & MS_RDONLY) 372 | vfsp->vfs_flag |= VFS_RDONLY; 373 | else 374 | vfsp->vfs_flag &= ~VFS_RDONLY; 375 | 376 | if (flags & MS_NOSUID) 377 | vfsp->vfs_flag &= ~VFS_SUID; 378 | else 379 | vfsp->vfs_flag |= VFS_SUID; 380 | 381 | if (flags & MS_NODEV) 382 | vfsp->vfs_flag |= VFS_NODEVICES; 383 | else 384 | vfsp->vfs_flag &= ~VFS_NODEVICES; 385 | 386 | if (flags & MS_NOEXEC) 387 | vfsp->vfs_flag |= VFS_NOEXEC; 388 | else 389 | vfsp->vfs_flag &= ~VFS_NOEXEC; 390 | 391 | if (flags & MS_NOATIME) 392 | vfsp->vfs_flag &= ~VFS_ATIME; 393 | else 394 | vfsp->vfs_flag |= VFS_ATIME; 395 | 396 | if(!vfsp->is_snap) { 397 | if ((rc = zfs_register_callbacks(vfsp))) 398 | lzfs_zfsctl_destroy(vfsp->vfs_super->s_fs_info); 399 | } 400 | SEXIT; 401 | return rc; 402 | } 403 | 404 | static void 405 | lzfs_kill_sb(struct super_block *sb) 406 | { 407 | vfs_t *vfsp; 408 | 409 | SENTRY; 410 | if(sb->s_fs_info) { 411 | vfsp = (vfs_t *) sb->s_fs_info; 412 | if (!vfsp->is_snap) { 413 | lzfs_zfsctl_destroy(sb->s_fs_info); 414 | } 415 | } 416 | kill_anon_super(sb); 417 | SEXIT; 418 | } 419 | 420 | struct file_system_type lzfs_fs_type = { 421 | .owner = THIS_MODULE, 422 | .name = "zfs", 423 | .get_sb = lzfs_get_sb, 424 | .kill_sb = lzfs_kill_sb, 425 | }; 426 | 427 | static int 428 | init_lzfs_fs(void) 429 | { 430 | return register_filesystem(&lzfs_fs_type); 431 | } 432 | 433 | static void __exit 434 | exit_lzfs_fs(void) 435 | { 436 | unregister_filesystem(&lzfs_fs_type); 437 | } 438 | 439 | module_init(init_lzfs_fs) 440 | module_exit(exit_lzfs_fs) 441 | 442 | MODULE_LICENSE("GPL"); 443 | //MODULE_LICENSE("Proprietary"); 444 | 445 | -------------------------------------------------------------------------------- /module/lzfs_xattr.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #ifdef SS_DEBUG_SUBSYS 13 | #undef SS_DEBUG_SUBSYS 14 | #endif 15 | 16 | /* 17 | * Log LZFS debug messages as the spl SS_USER2 subsystem. 18 | */ 19 | #define SS_DEBUG_SUBSYS SS_USER2 20 | 21 | int 22 | lzfs_xattr_set(struct inode *inode, const char *name, 23 | void *buffer, size_t size, const char *xattr_name) 24 | { 25 | vnode_t *vp; 26 | vnode_t *dvp; 27 | vnode_t *xvp; 28 | vattr_t *vap; 29 | int err = 0; 30 | const cred_t *cred = get_current_cred(); 31 | struct iovec iov = { 32 | .iov_base = buffer, 33 | .iov_len = size, 34 | }; 35 | 36 | uio_t uio = { 37 | .uio_iov = &iov, 38 | .uio_resid = size, 39 | .uio_iovcnt = 1, 40 | .uio_loffset = (offset_t)0, 41 | .uio_limit = MAXOFFSET_T, 42 | .uio_segflg = UIO_SYSSPACE, 43 | }; 44 | struct inode *xinode; 45 | 46 | dvp = LZFS_ITOV(inode); 47 | 48 | err = zfs_lookup(dvp, NULL, &vp, NULL, LOOKUP_XATTR | CREATE_XATTR_DIR, 49 | NULL, (cred_t *) cred, NULL, NULL, NULL); 50 | if(err) 51 | return -err; 52 | 53 | if(!buffer) { 54 | err = zfs_remove(vp, (char *)name, (cred_t *)cred, NULL, 0); 55 | return -err; 56 | } 57 | 58 | vap = kmalloc(sizeof(vattr_t), GFP_KERNEL); 59 | ASSERT(vap != NULL); 60 | memset(vap, 0, sizeof(vap)); 61 | vap->va_type = VREG; 62 | vap->va_mode = 0644; 63 | vap->va_mask = AT_TYPE|AT_MODE; 64 | vap->va_uid = current_fsuid(); 65 | vap->va_gid = current_fsgid(); 66 | 67 | err = zfs_create(vp, (char *) xattr_name, vap, 0, 0644, 68 | &xvp, (cred_t *)cred, 0, NULL, NULL); 69 | kfree(vap); 70 | xinode = LZFS_VTOI(xvp); 71 | if(err) { 72 | unlock_new_inode(xinode); 73 | iput(xinode); 74 | return -err; 75 | } 76 | err = zfs_write(xvp, &uio, 0, (cred_t *)cred, NULL); 77 | (void)put_cred(cred); 78 | 79 | unlock_new_inode(xinode); 80 | return (err ? -err : 0); 81 | } 82 | 83 | int 84 | lzfs_xattr_get(struct inode *inode, const char *name, 85 | void *buffer, size_t size, const char *xattr_name) 86 | { 87 | struct inode *xinode = NULL; 88 | vnode_t *vp; 89 | vnode_t *dvp; 90 | vnode_t *xvp; 91 | int err = 0; 92 | const cred_t *cred = get_current_cred(); 93 | struct iovec iov; 94 | uio_t uio; 95 | 96 | dvp = LZFS_ITOV(inode); 97 | err = zfs_lookup(dvp, NULL, &vp, NULL, LOOKUP_XATTR, NULL, 98 | (cred_t *) cred, NULL, NULL, NULL); 99 | if(err) { 100 | if(err == ENOENT) { 101 | return -ENODATA; 102 | } 103 | return -err; 104 | } 105 | ASSERT(vp != NULL); 106 | err = zfs_lookup(vp, (char *) xattr_name, &xvp, NULL, 0, NULL, 107 | (cred_t *) cred, NULL, NULL, NULL); 108 | if(err) { 109 | if(err == ENOENT) { 110 | return -ENODATA; 111 | } 112 | return -err; 113 | } 114 | xinode = LZFS_VTOI(xvp); 115 | if(!size) { 116 | return ((int) xinode->i_size); 117 | } 118 | iov.iov_base = buffer; 119 | iov.iov_len = size; 120 | uio.uio_iov = &iov; 121 | uio.uio_resid = size; 122 | uio.uio_iovcnt = 1; 123 | uio.uio_loffset = (offset_t)0; 124 | uio.uio_segflg = UIO_SYSSPACE; 125 | 126 | err = zfs_read(xvp, &uio, 0, (cred_t *)cred, NULL); 127 | (void)put_cred(cred); 128 | if(err) { 129 | return -err; 130 | } 131 | 132 | return size - uio.uio_resid; 133 | } 134 | 135 | #define for_each_xattr_handler(handlers, handler) \ 136 | for ((handler) = *(handlers)++; \ 137 | (handler) != NULL; \ 138 | (handler) = *(handlers)++) 139 | 140 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35) 141 | static inline struct xattr_handler * 142 | find_xattr_handler_prefix(struct xattr_handler **handlers, 143 | const char *name) 144 | #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35) 145 | static inline const struct xattr_handler * 146 | find_xattr_handler_prefix(const struct xattr_handler **handlers, 147 | const char *name) 148 | #endif 149 | { 150 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35) 151 | struct xattr_handler *ea_handler; 152 | #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35) 153 | const struct xattr_handler *ea_handler; 154 | #endif 155 | 156 | if (!handlers) { 157 | return NULL; 158 | } 159 | for_each_xattr_handler(handlers, ea_handler) { 160 | if (strncmp(ea_handler->prefix, name, 161 | strlen(ea_handler->prefix)) == 0) 162 | break; 163 | } 164 | return ea_handler; 165 | } 166 | 167 | struct listxattr_buf { 168 | size_t size; 169 | size_t pos; 170 | char *buf; 171 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33) 172 | struct inode *inode; 173 | #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33) 174 | struct dentry *dentry; 175 | #endif 176 | }; 177 | 178 | static int listxattr_filler(void *buf, const char *name, int namelen, 179 | loff_t offset, u64 ino, unsigned int d_type) 180 | { 181 | struct listxattr_buf *b = (struct listxattr_buf *)buf; 182 | size_t size = 0; 183 | 184 | if (name[0] != '.' || 185 | (namelen != 1 && (name[1] != '.' || namelen != 2))) { 186 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35) 187 | struct xattr_handler *handler; 188 | #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35) 189 | const struct xattr_handler *handler; 190 | #endif 191 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33) 192 | handler = find_xattr_handler_prefix( 193 | b->inode->i_sb->s_xattr, 194 | name); 195 | #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33) 196 | handler = find_xattr_handler_prefix( 197 | b->dentry->d_sb->s_xattr, 198 | name); 199 | #endif 200 | if (!handler) 201 | return 0; 202 | if (b->buf) { 203 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33) 204 | size = handler->list(b->inode, b->buf + b->pos, 205 | b->size, name, namelen); 206 | #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33) 207 | size = handler->list(b->dentry, b->buf + b->pos, 208 | b->size, name, namelen, 209 | handler->flags); 210 | #endif 211 | if (size > b->size) 212 | return -ERANGE; 213 | } else { 214 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33) 215 | size = handler->list(b->inode, NULL, 216 | 0, name, namelen); 217 | #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33) 218 | size = handler->list(b->dentry, NULL, 219 | 0, name, namelen, handler->flags); 220 | #endif 221 | } 222 | } 223 | b->pos += size; 224 | return 0; 225 | } 226 | 227 | ssize_t 228 | lzfs_listxattr(struct dentry *dentry, char *buffer, size_t size) 229 | { 230 | vnode_t *dvp; 231 | vnode_t *vp; /* xattr dir vnode pointer */ 232 | int err = 0, eof; 233 | const cred_t *cred = get_current_cred(); 234 | loff_t pos = 0; 235 | 236 | struct listxattr_buf buf = { 237 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33) 238 | .inode = dentry->d_inode, 239 | #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33) 240 | .dentry = dentry, 241 | #endif 242 | .buf = buffer, 243 | .size = buffer ? size : 0, 244 | }; 245 | 246 | dvp = LZFS_ITOV(dentry->d_inode); 247 | err = zfs_lookup(dvp, NULL, &vp, NULL, LOOKUP_XATTR, NULL, 248 | (cred_t *) cred, NULL, NULL, NULL); 249 | if(err) { 250 | if(err == ENOENT) { 251 | err = 0; 252 | } 253 | return -err; 254 | } 255 | ASSERT(vp != NULL); 256 | 257 | if(!size) 258 | return (LZFS_VTOI(vp))->i_size; 259 | err = zfs_readdir(vp, (void *)&buf, NULL, &eof, NULL, 0, 260 | listxattr_filler, &pos); 261 | if(err) 262 | return -err; 263 | else 264 | err = buf.pos; 265 | return err; 266 | } 267 | 268 | int 269 | lzfs_removexattr(struct dentry *dentry, const char *name) 270 | { 271 | struct inode *inode = dentry->d_inode; 272 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35) 273 | struct xattr_handler *handler; 274 | #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35) 275 | const struct xattr_handler *handler; 276 | #endif 277 | handler = find_xattr_handler_prefix(inode->i_sb->s_xattr, name); 278 | 279 | if (!handler) 280 | return -EOPNOTSUPP; 281 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33) 282 | return handler->set(inode, name, NULL, 0, XATTR_REPLACE); 283 | #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33) 284 | return handler->set(dentry, name, NULL, 0, XATTR_REPLACE, 285 | handler->flags); 286 | #endif 287 | } 288 | 289 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35) 290 | struct xattr_handler *lzfs_xattr_handlers[] = { 291 | #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35) 292 | const struct xattr_handler *lzfs_xattr_handlers[] = { 293 | #endif 294 | &lzfs_xattr_user_handler, 295 | #ifdef HAVE_ZPL 296 | &lzfs_xattr_trusted_handler, // TODO 297 | #endif /* HAVE_ZPL */ 298 | #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,31) 299 | &lzfs_xattr_acl_access_handler, 300 | &lzfs_xattr_acl_default_handler, 301 | #endif 302 | &lzfs_xattr_security_handler, 303 | NULL 304 | }; 305 | -------------------------------------------------------------------------------- /module/lzfs_xattr_acl.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,31) 13 | static int lzfs_set_mode(struct inode *inode, mode_t mode) 14 | { 15 | struct iattr *att; 16 | struct dentry *fake_de = NULL; 17 | int err = -ENOMEM; 18 | 19 | att = kzalloc(sizeof(struct iattr), GFP_KERNEL); 20 | if(att == NULL) 21 | goto out; 22 | 23 | fake_de = kzalloc(sizeof(struct dentry), GFP_KERNEL); 24 | if(fake_de == NULL) 25 | goto out; 26 | 27 | fake_de->d_inode = inode; 28 | att->ia_valid = ATTR_MODE; 29 | att->ia_mode = mode; 30 | err = lzfs_vnop_setattr(fake_de, att); 31 | out: 32 | if (att) 33 | kfree(att); 34 | if (fake_de) 35 | kfree(fake_de); 36 | return err; 37 | 38 | } 39 | 40 | static int 41 | lzfs_set_acl(struct inode *inode,struct posix_acl *acl, int type) 42 | { 43 | int err = 0; 44 | size_t size=0; 45 | 46 | char *xattr_name = NULL; 47 | char * value = NULL; 48 | 49 | if (S_ISLNK(inode->i_mode)) 50 | return -EOPNOTSUPP; 51 | 52 | switch(type) { 53 | case ACL_TYPE_ACCESS: 54 | xattr_name = POSIX_ACL_XATTR_ACCESS; 55 | if (acl) { 56 | mode_t mode = inode->i_mode; 57 | err = posix_acl_equiv_mode(acl, &mode); 58 | if (err < 0) 59 | return err; 60 | else { 61 | if (inode->i_mode != mode) { 62 | int rc; 63 | rc = lzfs_set_mode(inode,mode); 64 | if (rc) { 65 | /* XXX error handling */ 66 | } 67 | } 68 | if (err == 0) { 69 | /* not extended attribute */ 70 | acl = NULL; 71 | } 72 | } 73 | } 74 | break; 75 | 76 | case ACL_TYPE_DEFAULT: 77 | xattr_name = POSIX_ACL_XATTR_DEFAULT; 78 | if (!S_ISDIR(inode->i_mode)) 79 | return acl ? -EACCES : 0; 80 | break; 81 | 82 | default: 83 | return -EINVAL; 84 | } 85 | 86 | if (acl) { 87 | size = posix_acl_xattr_size(acl->a_count); 88 | value = kmalloc(size, GFP_KERNEL); 89 | if (IS_ERR(value)) 90 | return (int)PTR_ERR(value); 91 | 92 | err = posix_acl_to_xattr(acl, value, size); 93 | if (err < 0) 94 | goto out; 95 | } 96 | 97 | err = lzfs_xattr_set(inode, xattr_name, value, size, xattr_name); 98 | 99 | if (err == -ENOENT && !acl) 100 | err = 0; 101 | if (!err) { 102 | if (acl) 103 | set_cached_acl(inode, type, acl); 104 | else 105 | forget_cached_acl(inode, type); 106 | } 107 | // posix_acl_release(acl); 108 | 109 | out: 110 | if (value) 111 | kfree(value); 112 | return err; 113 | 114 | } 115 | 116 | 117 | static struct posix_acl * 118 | lzfs_get_acl(struct inode *inode, int type) 119 | { 120 | char *name; 121 | char *xattr_name; 122 | char *value = NULL; 123 | struct posix_acl *acl; 124 | int retval; 125 | 126 | acl = get_cached_acl(inode, type); 127 | if (acl != ACL_NOT_CACHED) 128 | return acl; 129 | 130 | switch (type) { 131 | case ACL_TYPE_ACCESS: 132 | name = POSIX_ACL_XATTR_ACCESS; 133 | break; 134 | case ACL_TYPE_DEFAULT: 135 | name = POSIX_ACL_XATTR_DEFAULT; 136 | break; 137 | default: 138 | BUG(); 139 | } 140 | 141 | xattr_name = kmalloc(strlen(name), GFP_NOFS); 142 | if (!xattr_name) 143 | return ERR_PTR(-ENOMEM); 144 | xattr_name = strncpy(xattr_name, name,strlen(name)); 145 | 146 | retval = lzfs_xattr_get(inode, name, NULL, 0, xattr_name); 147 | if (retval > 0) { 148 | value = kmalloc(retval, GFP_NOFS); 149 | if (!value) { 150 | kfree(xattr_name); 151 | return ERR_PTR(-ENOMEM); 152 | } 153 | retval = lzfs_xattr_get(inode, name, value, retval, xattr_name); 154 | } 155 | kfree(xattr_name); 156 | 157 | if (retval > 0) 158 | acl = posix_acl_from_xattr(value, retval); 159 | 160 | else if (retval == -ENODATA || retval == -ENOSYS) 161 | acl = NULL; 162 | else 163 | acl = ERR_PTR(retval); 164 | 165 | if (value) 166 | kfree(value); 167 | 168 | if (!IS_ERR(acl)) 169 | set_cached_acl(inode, type, acl); 170 | 171 | return acl; 172 | } 173 | 174 | int 175 | lzfs_acl_init(struct inode *inode, struct inode *dir) 176 | { 177 | struct posix_acl *acl = NULL; 178 | int error = 0; 179 | 180 | if (!S_ISLNK(inode->i_mode)) { 181 | acl = lzfs_get_acl(dir, ACL_TYPE_DEFAULT); 182 | if (IS_ERR(acl)) 183 | return PTR_ERR(acl); 184 | if (!acl) { 185 | inode->i_mode &= ~current_umask(); 186 | error = lzfs_set_mode(inode,inode->i_mode); 187 | if (error) 188 | goto cleanup; 189 | } 190 | } 191 | 192 | if (acl) { 193 | struct posix_acl *clone; 194 | mode_t mode; 195 | 196 | if (S_ISDIR(inode->i_mode)) { 197 | error = lzfs_set_acl(inode, acl, ACL_TYPE_DEFAULT); 198 | if (error < 0) 199 | goto cleanup; 200 | } 201 | clone = posix_acl_clone(acl, GFP_NOFS); 202 | error = -ENOMEM; 203 | if (!clone) 204 | goto cleanup; 205 | 206 | mode = inode->i_mode; 207 | error = posix_acl_create_masq(clone, &mode); 208 | if (error >= 0) { 209 | int err; 210 | inode->i_mode = mode; 211 | err = lzfs_set_mode(inode, mode); 212 | if (error > 0) { 213 | /* This is an extended ACL */ 214 | error = lzfs_set_acl(inode, clone, ACL_TYPE_ACCESS); 215 | } 216 | error |= err; 217 | } 218 | posix_acl_release(clone); 219 | } 220 | cleanup: 221 | posix_acl_release(acl); 222 | return error; 223 | } 224 | 225 | int 226 | lzfs_check_acl(struct inode *inode, int mask) 227 | { 228 | struct posix_acl *acl = lzfs_get_acl(inode, ACL_TYPE_ACCESS); 229 | 230 | if (IS_ERR(acl)) 231 | return PTR_ERR(acl); 232 | if (acl) { 233 | int error = posix_acl_permission(inode, acl, mask); 234 | posix_acl_release(acl); 235 | return error; 236 | } 237 | return -EAGAIN; 238 | } 239 | 240 | int 241 | lzfs_acl_chmod(struct inode *inode) 242 | { 243 | struct posix_acl *acl, *clone; 244 | int error; 245 | 246 | if (S_ISLNK(inode->i_mode)) 247 | return -EOPNOTSUPP; 248 | 249 | acl = lzfs_get_acl(inode, ACL_TYPE_ACCESS); 250 | if (IS_ERR(acl) || !acl) 251 | return PTR_ERR(acl); 252 | clone = posix_acl_clone(acl, GFP_KERNEL); 253 | posix_acl_release(acl); 254 | if (!clone) 255 | return -ENOMEM; 256 | error = posix_acl_chmod_masq(clone, inode->i_mode); 257 | if (!error) 258 | error = lzfs_set_acl(inode, clone, ACL_TYPE_ACCESS); 259 | posix_acl_release(clone); 260 | return error; 261 | 262 | } 263 | 264 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33) 265 | static inline size_t 266 | lzfs_xattr_acl_list_access(struct inode *inode, char *list, 267 | size_t list_size,const char *name, size_t name_len) 268 | #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33) 269 | static inline size_t 270 | lzfs_xattr_acl_list_access(struct dentry *dentry, char *list, 271 | size_t list_size,const char *name, size_t name_len,int type) 272 | #endif 273 | { 274 | const size_t total_len = sizeof(POSIX_ACL_XATTR_ACCESS); 275 | 276 | if (list && total_len <= list_size) 277 | memcpy(list, POSIX_ACL_XATTR_ACCESS, total_len); 278 | return total_len; 279 | } 280 | 281 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33) 282 | static inline size_t 283 | lzfs_xattr_acl_list_default(struct inode *inode, char *list, size_t list_size, 284 | const char *name, size_t name_len) 285 | #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33) 286 | static inline size_t 287 | lzfs_xattr_acl_list_default(struct dentry *dentry, char *list, size_t list_size, 288 | const char *name, size_t name_len,int type) 289 | #endif 290 | { 291 | const size_t total_len = sizeof(POSIX_ACL_XATTR_DEFAULT); 292 | 293 | if (list && total_len <= list_size) 294 | memcpy(list, POSIX_ACL_XATTR_DEFAULT,total_len); 295 | return total_len; 296 | } 297 | 298 | 299 | static int 300 | lzfs_xattr_acl_get(struct dentry *dentry, const char *name, void *buffer, 301 | size_t size, int type) 302 | { 303 | struct posix_acl *acl; 304 | int error; 305 | 306 | if (strcmp(name, "") != 0) 307 | return -EINVAL; 308 | 309 | acl = lzfs_get_acl(dentry->d_inode, type); 310 | if (IS_ERR(acl)) 311 | return PTR_ERR(acl); 312 | if (acl == NULL) 313 | return -ENODATA; 314 | 315 | error = posix_acl_to_xattr(acl, buffer, size); 316 | posix_acl_release(acl); 317 | return error; 318 | } 319 | 320 | static int 321 | lzfs_xattr_acl_set(struct dentry *dentry, const char *name, const void *value, 322 | size_t size, int flags, int type) 323 | { 324 | struct posix_acl * acl = NULL; 325 | int err = 0; 326 | 327 | if ((strcmp(name, "") != 0) && 328 | ((type != ACL_TYPE_ACCESS) && (type != ACL_TYPE_DEFAULT))) 329 | return -EINVAL; 330 | 331 | if (!is_owner_or_cap(dentry->d_inode)) 332 | return -EPERM; 333 | 334 | if (value) { 335 | acl = posix_acl_from_xattr(value, size); 336 | if (IS_ERR(acl)) 337 | return PTR_ERR(acl); 338 | else if (acl) { 339 | err = posix_acl_valid(acl); 340 | if (err) 341 | goto release_and_out; 342 | } 343 | } 344 | 345 | err = lzfs_set_acl(dentry->d_inode, acl, type); 346 | release_and_out: 347 | posix_acl_release(acl); 348 | return err; 349 | } 350 | 351 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33) 352 | static inline int 353 | __lzfs_xattr_acl_get(struct inode *inode, const char *name, 354 | void *buffer, size_t size, int type) 355 | { 356 | struct dentry *fake_de = NULL; 357 | int error; 358 | 359 | fake_de = kzalloc(sizeof(struct dentry), GFP_KERNEL); 360 | if (!fake_de) 361 | return -ENOMEM; 362 | 363 | fake_de->d_inode = inode; 364 | error = lzfs_xattr_acl_get(fake_de, "", buffer, size, type); 365 | kfree(fake_de); 366 | 367 | return error; 368 | 369 | } 370 | 371 | static inline int 372 | lzfs_xattr_acl_get_access(struct inode *inode, const char *name, 373 | void *buffer, size_t size) 374 | { 375 | return __lzfs_xattr_acl_get(inode, name, buffer, size, ACL_TYPE_ACCESS); 376 | } 377 | 378 | static inline int 379 | __lzfs_xattr_acl_set(struct inode *inode, const char *name, 380 | const void *buffer, size_t size, int type, int flags) 381 | { 382 | struct dentry *fake_de = NULL; 383 | int error; 384 | 385 | fake_de = kzalloc(sizeof(struct dentry), GFP_KERNEL); 386 | if (!fake_de) 387 | return -ENOMEM; 388 | 389 | fake_de->d_inode = inode; 390 | error = lzfs_xattr_acl_set(fake_de, "", buffer, size, flags, type); 391 | kfree(fake_de); 392 | 393 | return error; 394 | 395 | } 396 | 397 | static inline int 398 | lzfs_xattr_acl_set_access(struct inode *inode, const char *name, 399 | const void *buffer, size_t size, int flags) 400 | { 401 | return __lzfs_xattr_acl_set(inode, name, buffer, size, ACL_TYPE_ACCESS, flags); 402 | } 403 | #endif 404 | 405 | struct xattr_handler lzfs_xattr_acl_access_handler = 406 | { 407 | .prefix = POSIX_ACL_XATTR_ACCESS, 408 | .list = lzfs_xattr_acl_list_access, 409 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33) 410 | .get = lzfs_xattr_acl_get_access, 411 | .set = lzfs_xattr_acl_set_access, 412 | #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33) 413 | .get = lzfs_xattr_acl_get, 414 | .set = lzfs_xattr_acl_set, 415 | .flags = ACL_TYPE_ACCESS, 416 | #endif 417 | }; 418 | 419 | 420 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33) 421 | static inline int 422 | lzfs_xattr_acl_get_default(struct inode *inode, const char *name, 423 | void *buffer, size_t size) 424 | { 425 | return __lzfs_xattr_acl_get(inode, name, buffer, size, ACL_TYPE_DEFAULT); 426 | } 427 | 428 | static inline int 429 | lzfs_xattr_acl_set_default(struct inode *inode, const char *name, 430 | const void *buffer, size_t size, int flags) 431 | { 432 | return __lzfs_xattr_acl_set(inode, name, buffer, size, ACL_TYPE_DEFAULT, flags); 433 | } 434 | #endif 435 | 436 | struct xattr_handler lzfs_xattr_acl_default_handler = 437 | { 438 | .prefix = POSIX_ACL_XATTR_DEFAULT, 439 | .list = lzfs_xattr_acl_list_default, 440 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33) 441 | .get = lzfs_xattr_acl_get_default, 442 | .set = lzfs_xattr_acl_set_default, 443 | #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33) 444 | .get = lzfs_xattr_acl_get, 445 | .set = lzfs_xattr_acl_set, 446 | .flags = ACL_TYPE_DEFAULT, 447 | #endif 448 | }; 449 | 450 | #endif 451 | -------------------------------------------------------------------------------- /module/lzfs_xattr_security.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #ifdef SS_DEBUG_SUBSYS 14 | #undef SS_DEBUG_SUBSYS 15 | #endif 16 | 17 | /* 18 | * Log LZFS debug messages as the spl SS_USER2 subsystem. 19 | */ 20 | #define SS_DEBUG_SUBSYS SS_USER2 21 | 22 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33) 23 | static int 24 | lzfs_xattr_security_get(struct inode *inode, const char *name, 25 | void *buffer, size_t size) 26 | #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33) 27 | static int 28 | lzfs_xattr_security_get(struct dentry *dentry, const char *name, 29 | void *buffer, size_t size, int type) 30 | #endif 31 | { 32 | char *xattr_name; 33 | int rc; 34 | 35 | if(strcmp(name,"") == 0) { 36 | return -EINVAL; 37 | } 38 | 39 | xattr_name = kzalloc(strlen(name) + 10, GFP_KERNEL); 40 | if (!xattr_name) 41 | return -ENOMEM; 42 | 43 | xattr_name = strncpy(xattr_name, "security.", 9); 44 | xattr_name = strncat(xattr_name, name, strlen(name)); 45 | 46 | 47 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33) 48 | rc = lzfs_xattr_get(inode, name, buffer, size, xattr_name); 49 | #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33) 50 | rc = lzfs_xattr_get(dentry->d_inode, name, buffer, size, xattr_name); 51 | #endif 52 | kfree(xattr_name); 53 | return rc; 54 | } 55 | 56 | int lzfs_xattr_security_set2(struct inode *inode, const char *name, 57 | const void *value, size_t size, int flags) 58 | { 59 | char *xattr_name; 60 | int rc; 61 | xattr_name = kzalloc(strlen(name) + 10, GFP_KERNEL); 62 | if (!xattr_name) 63 | return -ENOMEM; 64 | 65 | xattr_name = strncpy(xattr_name, "security.", 9); 66 | xattr_name = strncat(xattr_name, name, strlen(name)); 67 | 68 | rc = lzfs_xattr_set(inode, name, (void *) value, size, xattr_name); 69 | kfree(xattr_name); 70 | return rc; 71 | } 72 | 73 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33) 74 | static int 75 | lzfs_xattr_security_set(struct inode *inode, const char *name, 76 | const void *value, size_t size, int flags) 77 | #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33) 78 | static int 79 | lzfs_xattr_security_set(struct dentry *dentry, const char *name, 80 | const void *value, size_t size, int flags, int type) 81 | #endif 82 | { 83 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33) 84 | struct inode *inode = dentry->d_inode; 85 | #endif 86 | return lzfs_xattr_security_set2(inode, name, value, size, flags); 87 | } 88 | 89 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33) 90 | static size_t 91 | lzfs_xattr_security_list(struct inode *inode, char *list, size_t list_size, 92 | const char *name, size_t name_len) 93 | #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33) 94 | static size_t 95 | lzfs_xattr_security_list(struct dentry *dentry, char *list, size_t list_size, 96 | const char *name, size_t name_len, int type) 97 | #endif 98 | { 99 | 100 | const size_t total_len = name_len + 1; 101 | 102 | if (list && total_len <= list_size) { 103 | memcpy(list, name, name_len); 104 | list[name_len] = '\0'; 105 | } 106 | return total_len; 107 | } 108 | 109 | int 110 | lzfs_init_security(struct inode *inode, struct inode *dir) 111 | { 112 | int err; 113 | size_t len; 114 | void *value; 115 | char *name; 116 | 117 | err = security_inode_init_security(inode, dir, &name, &value, &len); 118 | if (err) { 119 | if (err == -EOPNOTSUPP) 120 | return 0; 121 | return err; 122 | } 123 | #if 0 124 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33) 125 | err = lzfs_xattr_security_set(dentry->d_inode, name, value, len, 0); 126 | #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33) 127 | err = lzfs_xattr_security_set(dentry, name, value, len, 0, 0); 128 | #endif 129 | #endif 130 | 131 | err = lzfs_xattr_security_set2(inode, name, value, len, 0); 132 | 133 | kfree(name); 134 | kfree(value); 135 | return err; 136 | } 137 | 138 | struct xattr_handler lzfs_xattr_security_handler = { 139 | .prefix = XATTR_SECURITY_PREFIX, 140 | .list = lzfs_xattr_security_list, 141 | .get = lzfs_xattr_security_get, 142 | .set = lzfs_xattr_security_set, 143 | }; 144 | -------------------------------------------------------------------------------- /module/lzfs_xattr_user.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #ifdef SS_DEBUG_SUBSYS 13 | #undef SS_DEBUG_SUBSYS 14 | #endif 15 | 16 | /* 17 | * Log LZFS debug messages as the spl SS_USER2 subsystem. 18 | */ 19 | #define SS_DEBUG_SUBSYS SS_USER2 20 | 21 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33) 22 | static int 23 | lzfs_xattr_user_get(struct inode *inode, const char *name, 24 | void *buffer, size_t size) 25 | #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33) 26 | static int 27 | lzfs_xattr_user_get(struct dentry *dentry, const char *name, 28 | void *buffer, size_t size, int type) 29 | #endif 30 | { 31 | char *xattr_name; 32 | int rc; 33 | 34 | if(strcmp(name,"") == 0) { 35 | return -EINVAL; 36 | } 37 | 38 | xattr_name = kzalloc(strlen(name) + 6, GFP_KERNEL); 39 | if (!xattr_name) 40 | return -ENOMEM; 41 | 42 | xattr_name = strncpy(xattr_name, "user.", 5); 43 | xattr_name = strncat(xattr_name, name, strlen(name)); 44 | 45 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33) 46 | rc = lzfs_xattr_get(inode, name, buffer, size, xattr_name); 47 | #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33) 48 | rc = lzfs_xattr_get(dentry->d_inode, name, buffer, size, xattr_name); 49 | #endif 50 | kfree(xattr_name); 51 | return rc; 52 | } 53 | 54 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33) 55 | static int 56 | lzfs_xattr_user_set(struct inode *inode, const char *name, 57 | const void *value, size_t size, int flags) 58 | #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33) 59 | static int 60 | lzfs_xattr_user_set(struct dentry *dentry, const char *name, 61 | const void *value, size_t size, int flags, int type) 62 | #endif 63 | { 64 | char *xattr_name; 65 | int rc; 66 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33) 67 | struct inode *inode = dentry->d_inode; 68 | #endif 69 | xattr_name = kzalloc(strlen(name) + 6, GFP_KERNEL); 70 | if (!xattr_name) 71 | return -ENOMEM; 72 | xattr_name = strncpy(xattr_name, "user.", 5); 73 | xattr_name = strncat(xattr_name, name, strlen(name)); 74 | rc = lzfs_xattr_set(inode, name, (void *) value, size, xattr_name); 75 | kfree(xattr_name); 76 | return rc; 77 | } 78 | 79 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33) 80 | static size_t 81 | lzfs_xattr_user_list(struct inode *inode, char *list, size_t list_size, 82 | const char *name, size_t name_len) 83 | #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33) 84 | static size_t 85 | lzfs_xattr_user_list(struct dentry *dentry, char *list, size_t list_size, 86 | const char *name, size_t name_len, int type) 87 | #endif 88 | { 89 | const size_t total_len = name_len + 1; 90 | 91 | if (list && total_len <= list_size) { 92 | memcpy(list, name, name_len); 93 | list[name_len] = '\0'; 94 | } 95 | return total_len; 96 | } 97 | 98 | 99 | struct xattr_handler lzfs_xattr_user_handler = { 100 | .prefix = XATTR_USER_PREFIX, 101 | .list = lzfs_xattr_user_list, 102 | .get = lzfs_xattr_user_get, 103 | .set = lzfs_xattr_user_set, 104 | }; 105 | -------------------------------------------------------------------------------- /usr/Makefile.in: -------------------------------------------------------------------------------- 1 | usrdir = /usr 2 | sbindir = $(usrdir)/sbin 3 | INSTALL = /usr/bin/install -c 4 | 5 | all: 6 | 7 | install: install_initd 8 | 9 | uninstall: uninstall_initd 10 | 11 | install_initd: 12 | test -z "$(usrdir)" || /bin/mkdir -p "$(DESTDIR)$(sbindir)" 13 | $(INSTALL) -m 755 sbin/zfs_manage.py \ 14 | $(DESTDIR)$(sbindir)/ 15 | $(INSTALL) -m 755 sbin/SystemReport.sh \ 16 | $(DESTDIR)$(sbindir)/ 17 | 18 | uninstall_initd: 19 | /bin/rm -f /usr/sbin/SystemReport.sh 20 | /bin/rm -f /usr/sbin/zfs_manage.py 21 | 22 | clean: 23 | 24 | distclean: 25 | 26 | check: 27 | 28 | distdir: 29 | find ./ | xargs /bin/cp -rt $$distdir/$$subdir; 30 | -------------------------------------------------------------------------------- /usr/sbin/zfs_manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | ''' ckeck package dependency ''' 4 | try: 5 | import os 6 | import sys 7 | import dbus 8 | import getopt 9 | import SOAPpy 10 | import string 11 | import gettext 12 | import commands 13 | import dmidecode 14 | import dmidecode 15 | from hashlib import md5 16 | from hashlib import md5 17 | _ = gettext.gettext 18 | from socket import gethostname 19 | import xml.etree.cElementTree as ElementTree 20 | except ImportError, e: 21 | print "Packages Dependency not resolved : %s" % e 22 | exit(-1) 23 | 24 | # test argument 25 | #args = '-u myasduser --user=masdyuser -p mypaadfss --password=mypaasdfss -k serasdasdialkey --key=serasdfialkey -s myservasdfer --server=masdfyserver --unregister --help'.split() 26 | 27 | ZFS_SERIAL = '/etc/zfs/zfs_serial' 28 | ZFS_CONFIG = '/etc/zfs/zfs_config' 29 | 30 | class XmlDictConfig(dict): 31 | def __init__(self, aDict): 32 | bDict = {} 33 | for element in aDict: 34 | if element: 35 | if len(element) == 1 or element[0].tag != element[1].tag: 36 | bDict = {element.tag: XmlDictConfig(element)} 37 | else: 38 | bDict = {element[0].tag : XmlDictConfig(element)} 39 | if element.items(): 40 | bDict.update(dict(element.items())) 41 | elif element.items(): 42 | bDict.update({element.tag: dict(element.items())}) 43 | else: 44 | bDict.update({element.tag: element.text}) 45 | self.update(bDict) 46 | 47 | 48 | class XmlParser(): 49 | def xmlToDict(self, parent_element): 50 | aDict = {} 51 | if parent_element.items(): 52 | aDict.update(dict(parent_element.items())) 53 | for element in parent_element: 54 | if element: 55 | if len(element) == 1 or element[0].tag != element[1].tag: 56 | bDict = XmlDictConfig(element) 57 | else: 58 | bDict = {element[0].tag: XmlDictConfig(element)} 59 | if element.items(): 60 | bDict.update(dict(element.items())) 61 | aDict.update({element.tag: bDict}) 62 | elif element.items(): 63 | aDict.update({element.tag: dict(element.items())}) 64 | else: 65 | aDict.update({element.tag: element.text}) 66 | return aDict 67 | 68 | def dictToXml(self, aDict): 69 | elem = ElementTree.Element("context") 70 | for key, value in aDict.items(): 71 | if isinstance(value, type(0)): 72 | ElementTree.SubElement(elem, key, type="int").text = str(value) 73 | elif isinstance(value, dict): 74 | test = self.dictToString(ElementTree.Element(key), value) 75 | ElementTree.SubElement(elem, key).text = test 76 | else: 77 | ElementTree.SubElement(elem, key).text = value 78 | dictAsXML = ElementTree.tostring(elem) 79 | dictAsXML = dictAsXML.replace("<", "<") 80 | dictAsXML = dictAsXML.replace(">",">") 81 | return dictAsXML 82 | 83 | def dictToString(self, elem, aDict): 84 | aList=[] 85 | for key, value in aDict.items(): 86 | if isinstance(value, type(0)): 87 | ElementTree.SubElement(elem, key, type="int").text = str(value) 88 | elif isinstance(value, dict): 89 | print "Element is a dict" 90 | ElementTree.SubElement(elem, key).text = self.dictToString(key, value) 91 | else: 92 | ElementTree.SubElement(elem, key).text = value 93 | aList.append("<" + key + ">" + value + "") 94 | return ''.join(aList) 95 | 96 | # this does not change, we can cache it 97 | _dmi_data = None 98 | _dmi_not_available = 0 99 | 100 | def dmi_warnings(): 101 | if not hasattr(dmidecode, 'get_warnings'): 102 | return None 103 | 104 | return dmidecode.get_warnings() 105 | 106 | def _initialize_dmi_data(): 107 | """ Initialize _dmi_data unless it already exist and returns it """ 108 | global _dmi_data, _dmi_not_available 109 | if _dmi_data is None: 110 | if _dmi_not_available: 111 | # do not try to initialize it again and again if not available 112 | return None 113 | else : 114 | dmixml = dmidecode.dmidecodeXML() 115 | dmixml.SetResultType(dmidecode.DMIXML_DOC) 116 | # Get all the DMI data and prepare a XPath context 117 | try: 118 | data = dmixml.QuerySection('all') 119 | dmi_warn = dmi_warnings() 120 | if dmi_warn: 121 | dmidecode.clear_warnings() 122 | log = up2dateLog.initLog() 123 | log.log_debug("dmidecode warnings: " % dmi_warn) 124 | except: 125 | # DMI decode FAIL, this can happend e.g in PV guest 126 | _dmi_not_available = 1 127 | dmi_warn = dmi_warnings() 128 | if dmi_warn: 129 | dmidecode.clear_warnings() 130 | return None 131 | _dmi_data = data.xpathNewContext(); 132 | return _dmi_data 133 | 134 | def get_dmi_data(path): 135 | """ Fetch DMI data from given section using given path. 136 | If data could not be retrieved, returns empty string. 137 | General method and should not be used outside of this module. 138 | """ 139 | dmi_data = _initialize_dmi_data() 140 | if dmi_data is None: 141 | return '' 142 | data = dmi_data.xpathEval(path) 143 | if data != []: 144 | return data[0].content 145 | else: 146 | # The path do not exist 147 | return '' 148 | 149 | def dmi_system_uuid(): 150 | """ Return UUID from dmidecode system information. 151 | If this value could not be fetch, returns empty string. 152 | """ 153 | # if guest was created manualy it can have empty UUID, in this 154 | # case dmidecode set attribute unavailable to 1 155 | uuid = get_dmi_data("/dmidecode/SystemInfo/SystemUUID[not(@unavailable='2')]") 156 | if not uuid: 157 | uuid = '' 158 | return uuid 159 | 160 | 161 | def get_smbios(): 162 | """ Returns dictionary with values we are interested for. 163 | For historical reason it is in format, which use HAL. 164 | Currently in dictionary are keys: 165 | smbios.system.uuid, smbios.bios.vendor, smbios.system.serial, 166 | smbios.system.manufacturer. 167 | """ 168 | _initialize_dmi_data() 169 | if _dmi_not_available: 170 | return {} 171 | else: 172 | return { 173 | 'smbios.system.uuid': dmi_system_uuid(), 174 | 'smbios.bios.vendor': get_dmi_data('/dmidecode/BIOSinfo/Vendor'), 175 | 'smbios.system.serial': get_dmi_data('/dmidecode/SystemInfo/SerialNumber'), 176 | 'smbios.system.manufacturer': get_dmi_data('/dmidecode/BaseBoardInfo/Manufacturer'), 177 | 'smbios.system.product': get_dmi_data('/dmidecode/SystemInfo/ProductName'), 178 | } 179 | 180 | def usage(): 181 | print "\nUsage is:\n " 182 | print sys.argv[0] + ' -u --user= -p --password= -k --key= -s --server= -o --operation= --help --dumpxml' 183 | print "\n => register , unregister, support (default is register)\n" 184 | print "Mandatory field(s)* (allways) : user, password" 185 | print "Mandatory field(s)* (first time registration) : key\n" 186 | return(-1) 187 | 188 | 189 | def main(): 190 | if len(sys.argv) == 1 : 191 | usage() 192 | 193 | index = -1 194 | try : 195 | index = sys.argv.index("--help") 196 | except: 197 | print 198 | if index != -1: 199 | usage() 200 | 201 | zfs_config = {"user":"", 202 | "password":"", 203 | "key":"", 204 | "server":"", 205 | "operation":"register", 206 | "help":"", 207 | "dumpxml":""} 208 | opt_zfs_config = {"-u":"user","--user":"user", 209 | "-p":"password", "--password":"password", 210 | "-k":"key", "--key":"key", 211 | "-s":"server","--server":"server", 212 | "-o":"operation","--operation":"operation", 213 | "--help":"help", 214 | "--dumpxml":"dumpxml"} 215 | 216 | # get default serial 217 | try: 218 | fd = open(ZFS_SERIAL) 219 | zfs_config['key'] = fd.read() 220 | fd.close() 221 | except: 222 | print 223 | 224 | try: 225 | optlist, args = getopt.gnu_getopt(sys.argv, 'dhu:p:k:s:o:n:',["user=", "password=", "key=", "server=", "operation=","unregister", "help","dumpxml"]) 226 | except getopt.GetoptError, err: 227 | print "Invalid arguments: " + str(err) 228 | return -1 229 | 230 | for ele in optlist: 231 | zfs_config[opt_zfs_config[ele[0]]] = ele[1] 232 | # set md5 checksum of password as password 233 | zfs_config['password'] = md5(zfs_config['password']).hexdigest() 234 | 235 | if zfs_config['user'] == '' or zfs_config['password'] == '' or zfs_config['key'] == '' : 236 | print "Mandatory fields are must. Please provide mendatory information." 237 | exit(-1) 238 | 239 | 240 | ns = 'http://tempuri.org/KQInfotech' 241 | # default web service url ( currently using test url) 242 | url = 'http://www.kqservice.com/UserMachineDetailsService.asmx' 243 | 244 | # chekc for web service url in configuration file 245 | confdict = {} 246 | try : 247 | fd = open(ZFS_CONFIG) 248 | data = fd.read() 249 | fd.close() 250 | sdata = data.split() 251 | for i in sdata: 252 | tmp = i.split('=') 253 | confdict[tmp[0]] = tmp[1] 254 | except : 255 | print 256 | # override dafault web service url if its available and is not empty 257 | if confdict.get('server') != None: 258 | if confdict['server'] != '': 259 | url = confdict['server'] 260 | 261 | server = SOAPpy.SOAPProxy( url, namespace=ns ) 262 | server.config.buildWithNamespacePrefix = 0 263 | 264 | # remove unnecessary option from zfs_config 265 | zfs_config.pop('dumpxml') 266 | zfs_config.pop('help') 267 | zfs_config.pop('server') 268 | zfs_config["machine"] = get_smbios() 269 | 270 | if zfs_config['operation'] == 'support' : 271 | try: 272 | # generate xml for zfs user registration info 273 | xmldata= XmlParser().dictToXml(zfs_config) 274 | dumpfile = "/tmp/" + gethostname() + ".zfs.xml" 275 | fd = open(dumpfile,"w") 276 | fd.write(xmldata) 277 | fd.close() 278 | ret = commands.getstatusoutput("SystemReport.sh") 279 | if ret[0] != 0 : 280 | print "sysreport generation failed" 281 | print "please send email to 'support@kqinfotech.com' with subject 'support' and attachment files %s and '/tmp/SysReport.tar.gz'" % (dumpfile) 282 | return 283 | except: 284 | print "error occured : support ops" 285 | return(-1) 286 | elif zfs_config['operation'] == 'unregister' : 287 | try: 288 | # generate xml for zfs user registration info 289 | xmldata= XmlParser().dictToXml(zfs_config) 290 | dumpfile = "/tmp/" + gethostname() + ".zfs.xml" 291 | fd = open(dumpfile,"w") 292 | fd.write(xmldata) 293 | fd.close() 294 | print "please send email to 'support@kqinfotech.com' with subject 'unregister' and attachment file '%s' " % (dumpfile) 295 | return 296 | except: 297 | print "No serial available(unregister)" 298 | return(-1) 299 | elif zfs_config['operation'] == 'register' : 300 | xmldata= XmlParser().dictToXml(zfs_config) 301 | ############################################## 302 | # dumpxml provided then only dump xml and quit 303 | index = -1 304 | try : 305 | index = sys.argv.index("--dumpxml") 306 | except: 307 | print 308 | if index != -1 : 309 | try: 310 | dumpfile = "/tmp/" + gethostname() + ".zfs.xml" 311 | fd = open(dumpfile,"w") 312 | fd.write(xmldata) 313 | print 'xml data available at %s ' % (dumpfile) 314 | fd.close() 315 | return(0) 316 | except: 317 | print 'can`t open %s for writing' % (dumpfile) 318 | return -1 319 | ################################### 320 | # register machine with web service 321 | ret = -1 322 | try: 323 | # web service to register user 324 | ret = server._sa( '%s/SendMachineDetails' %ns ).SendMachineDetails( inputxmlfile=xmldata ) 325 | except: 326 | print "could not connetct to service : " + url + "\n" 327 | return(-1) 328 | 329 | retEcho = {'0' : "Machine Restistation successful", 330 | '1' : "Machine Registeded Allready", 331 | '2' : "Key-user pair mismatch", 332 | '3' : "auhthentication fail", 333 | '4' : "Unsuffecient credentials", 334 | '5' : "Exeeding the installation limit6", 335 | '7' : "Database exception occured", 336 | '8' : "IO Exception", 337 | '9' : "Unknow error" } 338 | ####################################################### 339 | # seve product/serial key if registration is successful 340 | if ret == '0' : 341 | try: 342 | fd = open(ZFS_SERIAL,"w") 343 | fd.write(zfs_config['key']) 344 | fd.close() 345 | print "product/serial key saved at %s." %(ZFS_SERIAL) 346 | print "Got Response : " + retEcho[ret] 347 | return(0) 348 | except: 349 | print "Unable to save credentials (product key)" 350 | print "Please put you product key %s to file %s manually for future use" % (zfs_config['key'],ZFS_SERIAL) 351 | ############################ 352 | # echo return status message 353 | if retEcho.get(ret) == None: 354 | print "Got unknown response" 355 | return -1 356 | else: 357 | print "Got Response : " + retEcho[ret] 358 | return -1 359 | else : 360 | print "unknown operation" 361 | return -1 362 | 363 | 364 | if __name__ == '__main__': 365 | main() 366 | # return(0) 367 | --------------------------------------------------------------------------------