├── .hgignore ├── AUTHORS ├── COPYING ├── ChangeLog ├── INSTALL ├── Makefile.am ├── Makefile.in ├── NEWS ├── README ├── RELEASE ├── configure ├── configure.ac ├── debian ├── changelog ├── compat ├── control ├── copyright ├── dirs ├── docs └── rules ├── depcomp ├── install-sh ├── linux-fadvise.c ├── linux-fallocate.c ├── linux-fincore.c ├── linux-ftools.h ├── missing ├── showrlimit.c └── waste_memory.c /.hgignore: -------------------------------------------------------------------------------- 1 | 2 | Makefile 3 | config.log 4 | config.status 5 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yazgoo/linux-ftools/5f05f69474d6cefb5a1156f774328539a44e3075/AUTHORS -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yazgoo/linux-ftools/5f05f69474d6cefb5a1156f774328539a44e3075/COPYING -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yazgoo/linux-ftools/5f05f69474d6cefb5a1156f774328539a44e3075/ChangeLog -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | Installation Instructions 2 | ************************* 3 | 4 | Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, 5 | 2006 Free Software Foundation, Inc. 6 | 7 | This file is free documentation; the Free Software Foundation gives 8 | unlimited permission to copy, distribute and modify it. 9 | 10 | Basic Installation 11 | ================== 12 | 13 | Briefly, the shell commands `./configure; make; make install' should 14 | configure, build, and install this package. The following 15 | more-detailed instructions are generic; see the `README' file for 16 | instructions specific to this package. 17 | 18 | The `configure' shell script attempts to guess correct values for 19 | various system-dependent variables used during compilation. It uses 20 | those values to create a `Makefile' in each directory of the package. 21 | It may also create one or more `.h' files containing system-dependent 22 | definitions. Finally, it creates a shell script `config.status' that 23 | you can run in the future to recreate the current configuration, and a 24 | file `config.log' containing compiler output (useful mainly for 25 | debugging `configure'). 26 | 27 | It can also use an optional file (typically called `config.cache' 28 | and enabled with `--cache-file=config.cache' or simply `-C') that saves 29 | the results of its tests to speed up reconfiguring. Caching is 30 | disabled by default to prevent problems with accidental use of stale 31 | cache files. 32 | 33 | If you need to do unusual things to compile the package, please try 34 | to figure out how `configure' could check whether to do them, and mail 35 | diffs or instructions to the address given in the `README' so they can 36 | be considered for the next release. If you are using the cache, and at 37 | some point `config.cache' contains results you don't want to keep, you 38 | may remove or edit it. 39 | 40 | The file `configure.ac' (or `configure.in') is used to create 41 | `configure' by a program called `autoconf'. You need `configure.ac' if 42 | you want to change it or regenerate `configure' using a newer version 43 | of `autoconf'. 44 | 45 | The simplest way to compile this package is: 46 | 47 | 1. `cd' to the directory containing the package's source code and type 48 | `./configure' to configure the package for your system. 49 | 50 | Running `configure' might take a while. While running, it prints 51 | some messages telling which features it is checking for. 52 | 53 | 2. Type `make' to compile the package. 54 | 55 | 3. Optionally, type `make check' to run any self-tests that come with 56 | the package. 57 | 58 | 4. Type `make install' to install the programs and any data files and 59 | documentation. 60 | 61 | 5. You can remove the program binaries and object files from the 62 | source code directory by typing `make clean'. To also remove the 63 | files that `configure' created (so you can compile the package for 64 | a different kind of computer), type `make distclean'. There is 65 | also a `make maintainer-clean' target, but that is intended mainly 66 | for the package's developers. If you use it, you may have to get 67 | all sorts of other programs in order to regenerate files that came 68 | with the distribution. 69 | 70 | Compilers and Options 71 | ===================== 72 | 73 | Some systems require unusual options for compilation or linking that the 74 | `configure' script does not know about. Run `./configure --help' for 75 | details on some of the pertinent environment variables. 76 | 77 | You can give `configure' initial values for configuration parameters 78 | by setting variables in the command line or in the environment. Here 79 | is an example: 80 | 81 | ./configure CC=c99 CFLAGS=-g LIBS=-lposix 82 | 83 | *Note Defining Variables::, for more details. 84 | 85 | Compiling For Multiple Architectures 86 | ==================================== 87 | 88 | You can compile the package for more than one kind of computer at the 89 | same time, by placing the object files for each architecture in their 90 | own directory. To do this, you can use GNU `make'. `cd' to the 91 | directory where you want the object files and executables to go and run 92 | the `configure' script. `configure' automatically checks for the 93 | source code in the directory that `configure' is in and in `..'. 94 | 95 | With a non-GNU `make', it is safer to compile the package for one 96 | architecture at a time in the source code directory. After you have 97 | installed the package for one architecture, use `make distclean' before 98 | reconfiguring for another architecture. 99 | 100 | Installation Names 101 | ================== 102 | 103 | By default, `make install' installs the package's commands under 104 | `/usr/local/bin', include files under `/usr/local/include', etc. You 105 | can specify an installation prefix other than `/usr/local' by giving 106 | `configure' the option `--prefix=PREFIX'. 107 | 108 | You can specify separate installation prefixes for 109 | architecture-specific files and architecture-independent files. If you 110 | pass the option `--exec-prefix=PREFIX' to `configure', the package uses 111 | PREFIX as the prefix for installing programs and libraries. 112 | Documentation and other data files still use the regular prefix. 113 | 114 | In addition, if you use an unusual directory layout you can give 115 | options like `--bindir=DIR' to specify different values for particular 116 | kinds of files. Run `configure --help' for a list of the directories 117 | you can set and what kinds of files go in them. 118 | 119 | If the package supports it, you can cause programs to be installed 120 | with an extra prefix or suffix on their names by giving `configure' the 121 | option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. 122 | 123 | Optional Features 124 | ================= 125 | 126 | Some packages pay attention to `--enable-FEATURE' options to 127 | `configure', where FEATURE indicates an optional part of the package. 128 | They may also pay attention to `--with-PACKAGE' options, where PACKAGE 129 | is something like `gnu-as' or `x' (for the X Window System). The 130 | `README' should mention any `--enable-' and `--with-' options that the 131 | package recognizes. 132 | 133 | For packages that use the X Window System, `configure' can usually 134 | find the X include and library files automatically, but if it doesn't, 135 | you can use the `configure' options `--x-includes=DIR' and 136 | `--x-libraries=DIR' to specify their locations. 137 | 138 | Specifying the System Type 139 | ========================== 140 | 141 | There may be some features `configure' cannot figure out automatically, 142 | but needs to determine by the type of machine the package will run on. 143 | Usually, assuming the package is built to be run on the _same_ 144 | architectures, `configure' can figure that out, but if it prints a 145 | message saying it cannot guess the machine type, give it the 146 | `--build=TYPE' option. TYPE can either be a short name for the system 147 | type, such as `sun4', or a canonical name which has the form: 148 | 149 | CPU-COMPANY-SYSTEM 150 | 151 | where SYSTEM can have one of these forms: 152 | 153 | OS KERNEL-OS 154 | 155 | See the file `config.sub' for the possible values of each field. If 156 | `config.sub' isn't included in this package, then this package doesn't 157 | need to know the machine type. 158 | 159 | If you are _building_ compiler tools for cross-compiling, you should 160 | use the option `--target=TYPE' to select the type of system they will 161 | produce code for. 162 | 163 | If you want to _use_ a cross compiler, that generates code for a 164 | platform different from the build platform, you should specify the 165 | "host" platform (i.e., that on which the generated programs will 166 | eventually be run) with `--host=TYPE'. 167 | 168 | Sharing Defaults 169 | ================ 170 | 171 | If you want to set default values for `configure' scripts to share, you 172 | can create a site shell script called `config.site' that gives default 173 | values for variables like `CC', `cache_file', and `prefix'. 174 | `configure' looks for `PREFIX/share/config.site' if it exists, then 175 | `PREFIX/etc/config.site' if it exists. Or, you can set the 176 | `CONFIG_SITE' environment variable to the location of the site script. 177 | A warning: not all `configure' scripts look for a site script. 178 | 179 | Defining Variables 180 | ================== 181 | 182 | Variables not defined in a site shell script can be set in the 183 | environment passed to `configure'. However, some packages may run 184 | configure again during the build, and the customized values of these 185 | variables may be lost. In order to avoid this problem, you should set 186 | them in the `configure' command line, using `VAR=value'. For example: 187 | 188 | ./configure CC=/usr/local2/bin/gcc 189 | 190 | causes the specified `gcc' to be used as the C compiler (unless it is 191 | overridden in the site shell script). 192 | 193 | Unfortunately, this technique does not work for `CONFIG_SHELL' due to 194 | an Autoconf bug. Until the bug is fixed you can use this workaround: 195 | 196 | CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash 197 | 198 | `configure' Invocation 199 | ====================== 200 | 201 | `configure' recognizes the following options to control how it operates. 202 | 203 | `--help' 204 | `-h' 205 | Print a summary of the options to `configure', and exit. 206 | 207 | `--version' 208 | `-V' 209 | Print the version of Autoconf used to generate the `configure' 210 | script, and exit. 211 | 212 | `--cache-file=FILE' 213 | Enable the cache: use and save the results of the tests in FILE, 214 | traditionally `config.cache'. FILE defaults to `/dev/null' to 215 | disable caching. 216 | 217 | `--config-cache' 218 | `-C' 219 | Alias for `--cache-file=config.cache'. 220 | 221 | `--quiet' 222 | `--silent' 223 | `-q' 224 | Do not print messages saying which checks are being made. To 225 | suppress all normal output, redirect it to `/dev/null' (any error 226 | messages will still be shown). 227 | 228 | `--srcdir=DIR' 229 | Look for the package's source code in directory DIR. Usually 230 | `configure' can determine that directory automatically. 231 | 232 | `configure' also accepts some other, not widely useful, options. Run 233 | `configure --help' for more details. 234 | 235 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = linux-fincore linux-fadvise linux-fallocate 2 | linux_fincore_SOURCES = linux-fincore.c 3 | linux_fincore_LDADD = -lm 4 | linux_fadvise_SOURCES = linux-fadvise.c 5 | linux_fallocate_SOURCES = linux-fallocate.c 6 | -------------------------------------------------------------------------------- /Makefile.in: -------------------------------------------------------------------------------- 1 | # Makefile.in generated by automake 1.11.1 from Makefile.am. 2 | # @configure_input@ 3 | 4 | # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 5 | # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, 6 | # Inc. 7 | # This Makefile.in is free software; the Free Software Foundation 8 | # gives unlimited permission to copy and/or distribute it, 9 | # with or without modifications, as long as this notice is preserved. 10 | 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY, to the extent permitted by law; without 13 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A 14 | # PARTICULAR PURPOSE. 15 | 16 | @SET_MAKE@ 17 | 18 | VPATH = @srcdir@ 19 | pkgdatadir = $(datadir)/@PACKAGE@ 20 | pkgincludedir = $(includedir)/@PACKAGE@ 21 | pkglibdir = $(libdir)/@PACKAGE@ 22 | pkglibexecdir = $(libexecdir)/@PACKAGE@ 23 | am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd 24 | install_sh_DATA = $(install_sh) -c -m 644 25 | install_sh_PROGRAM = $(install_sh) -c 26 | install_sh_SCRIPT = $(install_sh) -c 27 | INSTALL_HEADER = $(INSTALL_DATA) 28 | transform = $(program_transform_name) 29 | NORMAL_INSTALL = : 30 | PRE_INSTALL = : 31 | POST_INSTALL = : 32 | NORMAL_UNINSTALL = : 33 | PRE_UNINSTALL = : 34 | POST_UNINSTALL = : 35 | bin_PROGRAMS = linux-fincore$(EXEEXT) linux-fadvise$(EXEEXT) \ 36 | linux-fallocate$(EXEEXT) 37 | subdir = . 38 | DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ 39 | $(srcdir)/Makefile.in $(top_srcdir)/configure AUTHORS COPYING \ 40 | ChangeLog INSTALL NEWS config.guess config.sub depcomp \ 41 | install-sh missing 42 | ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 43 | am__aclocal_m4_deps = $(top_srcdir)/configure.ac 44 | am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ 45 | $(ACLOCAL_M4) 46 | am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ 47 | configure.lineno config.status.lineno 48 | mkinstalldirs = $(install_sh) -d 49 | CONFIG_CLEAN_FILES = 50 | CONFIG_CLEAN_VPATH_FILES = 51 | am__installdirs = "$(DESTDIR)$(bindir)" 52 | PROGRAMS = $(bin_PROGRAMS) 53 | am_linux_fadvise_OBJECTS = linux-fadvise.$(OBJEXT) 54 | linux_fadvise_OBJECTS = $(am_linux_fadvise_OBJECTS) 55 | linux_fadvise_LDADD = $(LDADD) 56 | am_linux_fallocate_OBJECTS = linux-fallocate.$(OBJEXT) 57 | linux_fallocate_OBJECTS = $(am_linux_fallocate_OBJECTS) 58 | linux_fallocate_LDADD = $(LDADD) 59 | am_linux_fincore_OBJECTS = linux-fincore.$(OBJEXT) 60 | linux_fincore_OBJECTS = $(am_linux_fincore_OBJECTS) 61 | linux_fincore_DEPENDENCIES = 62 | DEFAULT_INCLUDES = -I.@am__isrc@ 63 | depcomp = $(SHELL) $(top_srcdir)/depcomp 64 | am__depfiles_maybe = depfiles 65 | am__mv = mv -f 66 | COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ 67 | $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) 68 | CCLD = $(CC) 69 | LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ 70 | SOURCES = $(linux_fadvise_SOURCES) $(linux_fallocate_SOURCES) \ 71 | $(linux_fincore_SOURCES) 72 | DIST_SOURCES = $(linux_fadvise_SOURCES) $(linux_fallocate_SOURCES) \ 73 | $(linux_fincore_SOURCES) 74 | ETAGS = etags 75 | CTAGS = ctags 76 | DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) 77 | distdir = $(PACKAGE)-$(VERSION) 78 | top_distdir = $(distdir) 79 | am__remove_distdir = \ 80 | { test ! -d "$(distdir)" \ 81 | || { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ 82 | && rm -fr "$(distdir)"; }; } 83 | DIST_ARCHIVES = $(distdir).tar.gz 84 | GZIP_ENV = --best 85 | distuninstallcheck_listfiles = find . -type f -print 86 | distcleancheck_listfiles = find . -type f -print 87 | ACLOCAL = @ACLOCAL@ 88 | AMTAR = @AMTAR@ 89 | AUTOCONF = @AUTOCONF@ 90 | AUTOHEADER = @AUTOHEADER@ 91 | AUTOMAKE = @AUTOMAKE@ 92 | AWK = @AWK@ 93 | CC = @CC@ 94 | CCDEPMODE = @CCDEPMODE@ 95 | CFLAGS = @CFLAGS@ 96 | CPP = @CPP@ 97 | CPPFLAGS = @CPPFLAGS@ 98 | CYGPATH_W = @CYGPATH_W@ 99 | DEFS = @DEFS@ 100 | DEPDIR = @DEPDIR@ 101 | ECHO_C = @ECHO_C@ 102 | ECHO_N = @ECHO_N@ 103 | ECHO_T = @ECHO_T@ 104 | EGREP = @EGREP@ 105 | EXEEXT = @EXEEXT@ 106 | GREP = @GREP@ 107 | INSTALL = @INSTALL@ 108 | INSTALL_DATA = @INSTALL_DATA@ 109 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 110 | INSTALL_SCRIPT = @INSTALL_SCRIPT@ 111 | INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ 112 | LDFLAGS = @LDFLAGS@ 113 | LIBOBJS = @LIBOBJS@ 114 | LIBS = @LIBS@ 115 | LTLIBOBJS = @LTLIBOBJS@ 116 | MAKEINFO = @MAKEINFO@ 117 | MKDIR_P = @MKDIR_P@ 118 | OBJEXT = @OBJEXT@ 119 | PACKAGE = @PACKAGE@ 120 | PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ 121 | PACKAGE_NAME = @PACKAGE_NAME@ 122 | PACKAGE_STRING = @PACKAGE_STRING@ 123 | PACKAGE_TARNAME = @PACKAGE_TARNAME@ 124 | PACKAGE_URL = @PACKAGE_URL@ 125 | PACKAGE_VERSION = @PACKAGE_VERSION@ 126 | PATH_SEPARATOR = @PATH_SEPARATOR@ 127 | SET_MAKE = @SET_MAKE@ 128 | SHELL = @SHELL@ 129 | STRIP = @STRIP@ 130 | VERSION = @VERSION@ 131 | abs_builddir = @abs_builddir@ 132 | abs_srcdir = @abs_srcdir@ 133 | abs_top_builddir = @abs_top_builddir@ 134 | abs_top_srcdir = @abs_top_srcdir@ 135 | ac_ct_CC = @ac_ct_CC@ 136 | am__include = @am__include@ 137 | am__leading_dot = @am__leading_dot@ 138 | am__quote = @am__quote@ 139 | am__tar = @am__tar@ 140 | am__untar = @am__untar@ 141 | bindir = @bindir@ 142 | build_alias = @build_alias@ 143 | builddir = @builddir@ 144 | datadir = @datadir@ 145 | datarootdir = @datarootdir@ 146 | docdir = @docdir@ 147 | dvidir = @dvidir@ 148 | exec_prefix = @exec_prefix@ 149 | host_alias = @host_alias@ 150 | htmldir = @htmldir@ 151 | includedir = @includedir@ 152 | infodir = @infodir@ 153 | install_sh = @install_sh@ 154 | libdir = @libdir@ 155 | libexecdir = @libexecdir@ 156 | localedir = @localedir@ 157 | localstatedir = @localstatedir@ 158 | mandir = @mandir@ 159 | mkdir_p = @mkdir_p@ 160 | oldincludedir = @oldincludedir@ 161 | pdfdir = @pdfdir@ 162 | prefix = @prefix@ 163 | program_transform_name = @program_transform_name@ 164 | psdir = @psdir@ 165 | sbindir = @sbindir@ 166 | sharedstatedir = @sharedstatedir@ 167 | srcdir = @srcdir@ 168 | sysconfdir = @sysconfdir@ 169 | target_alias = @target_alias@ 170 | top_build_prefix = @top_build_prefix@ 171 | top_builddir = @top_builddir@ 172 | top_srcdir = @top_srcdir@ 173 | linux_fincore_SOURCES = linux-fincore.c 174 | linux_fincore_LDADD = -lm 175 | linux_fadvise_SOURCES = linux-fadvise.c 176 | linux_fallocate_SOURCES = linux-fallocate.c 177 | all: all-am 178 | 179 | .SUFFIXES: 180 | .SUFFIXES: .c .o .obj 181 | am--refresh: 182 | @: 183 | $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) 184 | @for dep in $?; do \ 185 | case '$(am__configure_deps)' in \ 186 | *$$dep*) \ 187 | echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \ 188 | $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \ 189 | && exit 0; \ 190 | exit 1;; \ 191 | esac; \ 192 | done; \ 193 | echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ 194 | $(am__cd) $(top_srcdir) && \ 195 | $(AUTOMAKE) --gnu Makefile 196 | .PRECIOUS: Makefile 197 | Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status 198 | @case '$?' in \ 199 | *config.status*) \ 200 | echo ' $(SHELL) ./config.status'; \ 201 | $(SHELL) ./config.status;; \ 202 | *) \ 203 | echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ 204 | cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ 205 | esac; 206 | 207 | $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) 208 | $(SHELL) ./config.status --recheck 209 | 210 | $(top_srcdir)/configure: $(am__configure_deps) 211 | $(am__cd) $(srcdir) && $(AUTOCONF) 212 | $(ACLOCAL_M4): $(am__aclocal_m4_deps) 213 | $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) 214 | $(am__aclocal_m4_deps): 215 | install-binPROGRAMS: $(bin_PROGRAMS) 216 | @$(NORMAL_INSTALL) 217 | test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" 218 | @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ 219 | for p in $$list; do echo "$$p $$p"; done | \ 220 | sed 's/$(EXEEXT)$$//' | \ 221 | while read p p1; do if test -f $$p; \ 222 | then echo "$$p"; echo "$$p"; else :; fi; \ 223 | done | \ 224 | sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ 225 | -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ 226 | sed 'N;N;N;s,\n, ,g' | \ 227 | $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ 228 | { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ 229 | if ($$2 == $$4) files[d] = files[d] " " $$1; \ 230 | else { print "f", $$3 "/" $$4, $$1; } } \ 231 | END { for (d in files) print "f", d, files[d] }' | \ 232 | while read type dir files; do \ 233 | if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ 234 | test -z "$$files" || { \ 235 | echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ 236 | $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ 237 | } \ 238 | ; done 239 | 240 | uninstall-binPROGRAMS: 241 | @$(NORMAL_UNINSTALL) 242 | @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ 243 | files=`for p in $$list; do echo "$$p"; done | \ 244 | sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ 245 | -e 's/$$/$(EXEEXT)/' `; \ 246 | test -n "$$list" || exit 0; \ 247 | echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ 248 | cd "$(DESTDIR)$(bindir)" && rm -f $$files 249 | 250 | clean-binPROGRAMS: 251 | -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) 252 | linux-fadvise$(EXEEXT): $(linux_fadvise_OBJECTS) $(linux_fadvise_DEPENDENCIES) 253 | @rm -f linux-fadvise$(EXEEXT) 254 | $(LINK) $(linux_fadvise_OBJECTS) $(linux_fadvise_LDADD) $(LIBS) 255 | linux-fallocate$(EXEEXT): $(linux_fallocate_OBJECTS) $(linux_fallocate_DEPENDENCIES) 256 | @rm -f linux-fallocate$(EXEEXT) 257 | $(LINK) $(linux_fallocate_OBJECTS) $(linux_fallocate_LDADD) $(LIBS) 258 | linux-fincore$(EXEEXT): $(linux_fincore_OBJECTS) $(linux_fincore_DEPENDENCIES) 259 | @rm -f linux-fincore$(EXEEXT) 260 | $(LINK) $(linux_fincore_OBJECTS) $(linux_fincore_LDADD) $(LIBS) 261 | 262 | mostlyclean-compile: 263 | -rm -f *.$(OBJEXT) 264 | 265 | distclean-compile: 266 | -rm -f *.tab.c 267 | 268 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/linux-fadvise.Po@am__quote@ 269 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/linux-fallocate.Po@am__quote@ 270 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/linux-fincore.Po@am__quote@ 271 | 272 | .c.o: 273 | @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< 274 | @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po 275 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ 276 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 277 | @am__fastdepCC_FALSE@ $(COMPILE) -c $< 278 | 279 | .c.obj: 280 | @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` 281 | @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po 282 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ 283 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 284 | @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` 285 | 286 | ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) 287 | list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ 288 | unique=`for i in $$list; do \ 289 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 290 | done | \ 291 | $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ 292 | END { if (nonempty) { for (i in files) print i; }; }'`; \ 293 | mkid -fID $$unique 294 | tags: TAGS 295 | 296 | TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ 297 | $(TAGS_FILES) $(LISP) 298 | set x; \ 299 | here=`pwd`; \ 300 | list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ 301 | unique=`for i in $$list; do \ 302 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 303 | done | \ 304 | $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ 305 | END { if (nonempty) { for (i in files) print i; }; }'`; \ 306 | shift; \ 307 | if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ 308 | test -n "$$unique" || unique=$$empty_fix; \ 309 | if test $$# -gt 0; then \ 310 | $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 311 | "$$@" $$unique; \ 312 | else \ 313 | $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 314 | $$unique; \ 315 | fi; \ 316 | fi 317 | ctags: CTAGS 318 | CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ 319 | $(TAGS_FILES) $(LISP) 320 | list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ 321 | unique=`for i in $$list; do \ 322 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 323 | done | \ 324 | $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ 325 | END { if (nonempty) { for (i in files) print i; }; }'`; \ 326 | test -z "$(CTAGS_ARGS)$$unique" \ 327 | || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ 328 | $$unique 329 | 330 | GTAGS: 331 | here=`$(am__cd) $(top_builddir) && pwd` \ 332 | && $(am__cd) $(top_srcdir) \ 333 | && gtags -i $(GTAGS_ARGS) "$$here" 334 | 335 | distclean-tags: 336 | -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags 337 | 338 | distdir: $(DISTFILES) 339 | $(am__remove_distdir) 340 | test -d "$(distdir)" || mkdir "$(distdir)" 341 | @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 342 | topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 343 | list='$(DISTFILES)'; \ 344 | dist_files=`for file in $$list; do echo $$file; done | \ 345 | sed -e "s|^$$srcdirstrip/||;t" \ 346 | -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ 347 | case $$dist_files in \ 348 | */*) $(MKDIR_P) `echo "$$dist_files" | \ 349 | sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ 350 | sort -u` ;; \ 351 | esac; \ 352 | for file in $$dist_files; do \ 353 | if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ 354 | if test -d $$d/$$file; then \ 355 | dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ 356 | if test -d "$(distdir)/$$file"; then \ 357 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 358 | fi; \ 359 | if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ 360 | cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ 361 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 362 | fi; \ 363 | cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ 364 | else \ 365 | test -f "$(distdir)/$$file" \ 366 | || cp -p $$d/$$file "$(distdir)/$$file" \ 367 | || exit 1; \ 368 | fi; \ 369 | done 370 | -test -n "$(am__skip_mode_fix)" \ 371 | || find "$(distdir)" -type d ! -perm -755 \ 372 | -exec chmod u+rwx,go+rx {} \; -o \ 373 | ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ 374 | ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ 375 | ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ 376 | || chmod -R a+r "$(distdir)" 377 | dist-gzip: distdir 378 | tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz 379 | $(am__remove_distdir) 380 | 381 | dist-bzip2: distdir 382 | tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 383 | $(am__remove_distdir) 384 | 385 | dist-lzma: distdir 386 | tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma 387 | $(am__remove_distdir) 388 | 389 | dist-xz: distdir 390 | tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz 391 | $(am__remove_distdir) 392 | 393 | dist-tarZ: distdir 394 | tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z 395 | $(am__remove_distdir) 396 | 397 | dist-shar: distdir 398 | shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz 399 | $(am__remove_distdir) 400 | 401 | dist-zip: distdir 402 | -rm -f $(distdir).zip 403 | zip -rq $(distdir).zip $(distdir) 404 | $(am__remove_distdir) 405 | 406 | dist dist-all: distdir 407 | tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz 408 | $(am__remove_distdir) 409 | 410 | # This target untars the dist file and tries a VPATH configuration. Then 411 | # it guarantees that the distribution is self-contained by making another 412 | # tarfile. 413 | distcheck: dist 414 | case '$(DIST_ARCHIVES)' in \ 415 | *.tar.gz*) \ 416 | GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ 417 | *.tar.bz2*) \ 418 | bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ 419 | *.tar.lzma*) \ 420 | lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\ 421 | *.tar.xz*) \ 422 | xz -dc $(distdir).tar.xz | $(am__untar) ;;\ 423 | *.tar.Z*) \ 424 | uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ 425 | *.shar.gz*) \ 426 | GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ 427 | *.zip*) \ 428 | unzip $(distdir).zip ;;\ 429 | esac 430 | chmod -R a-w $(distdir); chmod a+w $(distdir) 431 | mkdir $(distdir)/_build 432 | mkdir $(distdir)/_inst 433 | chmod a-w $(distdir) 434 | test -d $(distdir)/_build || exit 0; \ 435 | dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ 436 | && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ 437 | && am__cwd=`pwd` \ 438 | && $(am__cd) $(distdir)/_build \ 439 | && ../configure --srcdir=.. --prefix="$$dc_install_base" \ 440 | $(DISTCHECK_CONFIGURE_FLAGS) \ 441 | && $(MAKE) $(AM_MAKEFLAGS) \ 442 | && $(MAKE) $(AM_MAKEFLAGS) dvi \ 443 | && $(MAKE) $(AM_MAKEFLAGS) check \ 444 | && $(MAKE) $(AM_MAKEFLAGS) install \ 445 | && $(MAKE) $(AM_MAKEFLAGS) installcheck \ 446 | && $(MAKE) $(AM_MAKEFLAGS) uninstall \ 447 | && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ 448 | distuninstallcheck \ 449 | && chmod -R a-w "$$dc_install_base" \ 450 | && ({ \ 451 | (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ 452 | && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ 453 | && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ 454 | && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ 455 | distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ 456 | } || { rm -rf "$$dc_destdir"; exit 1; }) \ 457 | && rm -rf "$$dc_destdir" \ 458 | && $(MAKE) $(AM_MAKEFLAGS) dist \ 459 | && rm -rf $(DIST_ARCHIVES) \ 460 | && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ 461 | && cd "$$am__cwd" \ 462 | || exit 1 463 | $(am__remove_distdir) 464 | @(echo "$(distdir) archives ready for distribution: "; \ 465 | list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ 466 | sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' 467 | distuninstallcheck: 468 | @$(am__cd) '$(distuninstallcheck_dir)' \ 469 | && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ 470 | || { echo "ERROR: files left after uninstall:" ; \ 471 | if test -n "$(DESTDIR)"; then \ 472 | echo " (check DESTDIR support)"; \ 473 | fi ; \ 474 | $(distuninstallcheck_listfiles) ; \ 475 | exit 1; } >&2 476 | distcleancheck: distclean 477 | @if test '$(srcdir)' = . ; then \ 478 | echo "ERROR: distcleancheck can only run from a VPATH build" ; \ 479 | exit 1 ; \ 480 | fi 481 | @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ 482 | || { echo "ERROR: files left in build directory after distclean:" ; \ 483 | $(distcleancheck_listfiles) ; \ 484 | exit 1; } >&2 485 | check-am: all-am 486 | check: check-am 487 | all-am: Makefile $(PROGRAMS) 488 | installdirs: 489 | for dir in "$(DESTDIR)$(bindir)"; do \ 490 | test -z "$$dir" || $(MKDIR_P) "$$dir"; \ 491 | done 492 | install: install-am 493 | install-exec: install-exec-am 494 | install-data: install-data-am 495 | uninstall: uninstall-am 496 | 497 | install-am: all-am 498 | @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am 499 | 500 | installcheck: installcheck-am 501 | install-strip: 502 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 503 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 504 | `test -z '$(STRIP)' || \ 505 | echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install 506 | mostlyclean-generic: 507 | 508 | clean-generic: 509 | 510 | distclean-generic: 511 | -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) 512 | -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) 513 | 514 | maintainer-clean-generic: 515 | @echo "This command is intended for maintainers to use" 516 | @echo "it deletes files that may require special tools to rebuild." 517 | clean: clean-am 518 | 519 | clean-am: clean-binPROGRAMS clean-generic mostlyclean-am 520 | 521 | distclean: distclean-am 522 | -rm -f $(am__CONFIG_DISTCLEAN_FILES) 523 | -rm -rf ./$(DEPDIR) 524 | -rm -f Makefile 525 | distclean-am: clean-am distclean-compile distclean-generic \ 526 | distclean-tags 527 | 528 | dvi: dvi-am 529 | 530 | dvi-am: 531 | 532 | html: html-am 533 | 534 | html-am: 535 | 536 | info: info-am 537 | 538 | info-am: 539 | 540 | install-data-am: 541 | 542 | install-dvi: install-dvi-am 543 | 544 | install-dvi-am: 545 | 546 | install-exec-am: install-binPROGRAMS 547 | 548 | install-html: install-html-am 549 | 550 | install-html-am: 551 | 552 | install-info: install-info-am 553 | 554 | install-info-am: 555 | 556 | install-man: 557 | 558 | install-pdf: install-pdf-am 559 | 560 | install-pdf-am: 561 | 562 | install-ps: install-ps-am 563 | 564 | install-ps-am: 565 | 566 | installcheck-am: 567 | 568 | maintainer-clean: maintainer-clean-am 569 | -rm -f $(am__CONFIG_DISTCLEAN_FILES) 570 | -rm -rf $(top_srcdir)/autom4te.cache 571 | -rm -rf ./$(DEPDIR) 572 | -rm -f Makefile 573 | maintainer-clean-am: distclean-am maintainer-clean-generic 574 | 575 | mostlyclean: mostlyclean-am 576 | 577 | mostlyclean-am: mostlyclean-compile mostlyclean-generic 578 | 579 | pdf: pdf-am 580 | 581 | pdf-am: 582 | 583 | ps: ps-am 584 | 585 | ps-am: 586 | 587 | uninstall-am: uninstall-binPROGRAMS 588 | 589 | .MAKE: install-am install-strip 590 | 591 | .PHONY: CTAGS GTAGS all all-am am--refresh check check-am clean \ 592 | clean-binPROGRAMS clean-generic ctags dist dist-all dist-bzip2 \ 593 | dist-gzip dist-lzma dist-shar dist-tarZ dist-xz dist-zip \ 594 | distcheck distclean distclean-compile distclean-generic \ 595 | distclean-tags distcleancheck distdir distuninstallcheck dvi \ 596 | dvi-am html html-am info info-am install install-am \ 597 | install-binPROGRAMS install-data install-data-am install-dvi \ 598 | install-dvi-am install-exec install-exec-am install-html \ 599 | install-html-am install-info install-info-am install-man \ 600 | install-pdf install-pdf-am install-ps install-ps-am \ 601 | install-strip installcheck installcheck-am installdirs \ 602 | maintainer-clean maintainer-clean-generic mostlyclean \ 603 | mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ 604 | tags uninstall uninstall-am uninstall-binPROGRAMS 605 | 606 | 607 | # Tell versions [3.59,3.63) of GNU make to not export all variables. 608 | # Otherwise a system limit (for SysV at least) may be exceeded. 609 | .NOEXPORT: 610 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | - Sun Jun 06 2010 06:07 PM (burton@tailrank.com): first release. 2 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | These are tools designed for working with modern linux system calls including, mincore, fallocate, fadvise, etc. 2 | 3 | We designed these primarily to work in high performance environments to determine information about the running kernel, improve system performance, and debug performance problems. 4 | 5 | = fincore = 6 | 7 | {{{ 8 | fincore [options] files... 9 | 10 | --pages=false Do not print pages 11 | --summarize When comparing multiple files, print a summary report 12 | --only-cached Only print stats for files that are actually in cache. 13 | 14 | root@xxxxxx:/var/lib/mysql/blogindex# fincore --pages=false --summarize --only-cached * 15 | stats for CLUSTER_LOG_2010_05_21.MYI: file size=93840384 , total pages=22910 , cached pages=1 , cached size=4096, cached perc=0.004365 16 | stats for CLUSTER_LOG_2010_05_22.MYI: file size=417792 , total pages=102 , cached pages=1 , cached size=4096, cached perc=0.980392 17 | stats for CLUSTER_LOG_2010_05_23.MYI: file size=826368 , total pages=201 , cached pages=1 , cached size=4096, cached perc=0.497512 18 | stats for CLUSTER_LOG_2010_05_24.MYI: file size=192512 , total pages=47 , cached pages=1 , cached size=4096, cached perc=2.127660 19 | stats for CLUSTER_LOG_2010_06_03.MYI: file size=345088 , total pages=84 , cached pages=43 , cached size=176128, cached perc=51.190476 20 | stats for CLUSTER_LOG_2010_06_04.MYD: file size=1478552 , total pages=360 , cached pages=97 , cached size=397312, cached perc=26.944444 21 | stats for CLUSTER_LOG_2010_06_04.MYI: file size=205824 , total pages=50 , cached pages=29 , cached size=118784, cached perc=58.000000 22 | stats for COMMENT_CONTENT_2010_06_03.MYI: file size=100051968 , total pages=24426 , cached pages=10253 , cached size=41996288, cached perc=41.975764 23 | stats for COMMENT_CONTENT_2010_06_04.MYD: file size=716369644 , total pages=174894 , cached pages=79821 , cached size=326946816, cached perc=45.639645 24 | stats for COMMENT_CONTENT_2010_06_04.MYI: file size=56832000 , total pages=13875 , cached pages=5365 , cached size=21975040, cached perc=38.666667 25 | stats for FEED_CONTENT_2010_06_03.MYI: file size=1001518080 , total pages=244511 , cached pages=98975 , cached size=405401600, cached perc=40.478751 26 | stats for FEED_CONTENT_2010_06_04.MYD: file size=9206385684 , total pages=2247652 , cached pages=1018661 , cached size=4172435456, cached perc=45.321117 27 | stats for FEED_CONTENT_2010_06_04.MYI: file size=638005248 , total pages=155763 , cached pages=52912 , cached size=216727552, cached perc=33.969556 28 | stats for FEED_CONTENT_2010_06_04.frm: file size=9840 , total pages=2 , cached pages=3 , cached size=12288, cached perc=150.000000 29 | stats for PERMALINK_CONTENT_2010_06_03.MYI: file size=1035290624 , total pages=252756 , cached pages=108563 , cached size=444674048, cached perc=42.951700 30 | stats for PERMALINK_CONTENT_2010_06_04.MYD: file size=55619712720 , total pages=13579031 , cached pages=6590322 , cached size=26993958912, cached perc=48.533080 31 | stats for PERMALINK_CONTENT_2010_06_04.MYI: file size=659397632 , total pages=160985 , cached pages=54304 , cached size=222429184, cached perc=33.732335 32 | stats for PERMALINK_CONTENT_2010_06_04.frm: file size=10156 , total pages=2 , cached pages=3 , cached size=12288, cached perc=150.000000 33 | --- 34 | total cached size: 32847278080 35 | }}} 36 | 37 | = fadvise = 38 | 39 | {{{ 40 | 41 | SYNTAX: filename mode [offset] [,length] 42 | Where mode can be: 43 | 44 | POSIX_FADV_NORMAL No further special treatment. 45 | POSIX_FADV_RANDOM Expect random page references. 46 | POSIX_FADV_SEQUENTIAL Expect sequential page references. 47 | POSIX_FADV_WILLNEED Will need these pages. 48 | POSIX_FADV_DONTNEED Dont need these pages. 49 | POSIX_FADV_NOREUSE Data will be accessed once. 50 | 51 | Allows an application to to tell the kernel how it expects to use a file handle, 52 | so that the kernel can choose appropriate read-ahead and caching techniques for 53 | access to the corresponding file. This is similar to the POSIX version of the 54 | madvise system call, but for file access instead of memory access. The 55 | sys_fadvise64() function is obsolete and corresponds to a broken glibc API, 56 | sys_fadvise64_64() is the fixed version. The following are the values for the 57 | advice parameter: 58 | 59 | FADV_NORMAL 60 | 61 | No special treatment. 62 | 63 | FADV_RANDOM 64 | 65 | Expect page references in random order. 66 | 67 | FADV_SEQUENTIAL 68 | 69 | Expect page references in sequential order. 70 | 71 | FADV_WILLNEED 72 | 73 | Expect access in the near future. 74 | 75 | FADV_DONTNEED 76 | 77 | Do not expect access in the near future. Subsequent access of pages in this 78 | range will succeed, but will result either in reloading of the memory contents 79 | from the underlying mapped file or zero-fill-in-demand pages for mappings 80 | without an underlying file. 81 | 82 | FADV_NOREUSE 83 | 84 | Access data only once. 85 | }}} 86 | 87 | = fallocate = 88 | 89 | {{{ 90 | SYNTAX: fallocate file length 91 | 92 | fallocate() allows the caller to directly manipulate the allocated disk space 93 | for the file referred to by fd for the byte range starting at offset and 94 | continuing for len bytes. 95 | 96 | The mode argument determines the operation to be performed on the given 97 | range. Currently only one flag is supported for mode: 98 | 99 | FALLOC_FL_KEEP_SIZE 100 | 101 | This flag allocates and initializes to zero the disk space within the range 102 | specified by offset and len. After a successful call, subsequent writes into 103 | this range are guaranteed not to fail because of lack of disk 104 | space. Preallocating zeroed blocks beyond the end of the file is useful for 105 | optimizing append workloads. Preallocating blocks does not change the file size 106 | (as reported by stat(2)) even if it is less than offset+len. 107 | 108 | If FALLOC_FL_KEEP_SIZE flag is not specified in mode, the default behavior is 109 | almost same as when this flag is specified. The only difference is that on 110 | success, the file size will be changed if offset + len is greater than the file 111 | size. This default behavior closely resembles the behavior of the 112 | posix_fallocate(3) library function, and is intended as a method of optimally 113 | implementing that function. 114 | 115 | Because allocation is done in block size chunks, fallocate() may allocate a 116 | larger range than that which was specified. 117 | }}} 118 | -------------------------------------------------------------------------------- /RELEASE: -------------------------------------------------------------------------------- 1 | ===== 2 | = Release instructions for developers doing releases = 3 | 4 | # regen configure 5 | 6 | aclocal && automake && autoconf 7 | 8 | automake might need --add-missing the first time. 9 | 10 | # make and install it 11 | 12 | make clean && make && make install 13 | 14 | ==== 15 | = Making Debian packages 16 | 17 | apt-get install autoconf automake fakeroot debhelper 18 | 19 | fakeroot debian/rules clean 20 | fakeroot debian/rules binary 21 | 22 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | # -*- Autoconf -*- 2 | # Process this file with autoconf to produce a configure script. 3 | 4 | AC_PREREQ(2.61) 5 | AC_INIT([linux-ftools], [1.3.0], BUG-REPORT-ADDRESS) 6 | AC_CONFIG_SRCDIR([linux-fincore.c]) 7 | AM_INIT_AUTOMAKE([linux-ftools], [1.3.0]) 8 | #AC_CONFIG_HEADER([config.h]) 9 | 10 | # Checks for programs. 11 | AC_PROG_CC 12 | 13 | # Checks for header files. 14 | AC_HEADER_STDC 15 | AC_CHECK_HEADERS([fcntl.h stdlib.h string.h sys/time.h unistd.h]) 16 | 17 | # Checks for typedefs, structures, and compiler characteristics. 18 | AC_HEADER_STDBOOL 19 | AC_TYPE_SIZE_T 20 | AC_CHECK_MEMBERS([struct stat.st_blksize]) 21 | AC_STRUCT_ST_BLOCKS 22 | 23 | # Checks for library functions. 24 | AC_FUNC_MALLOC 25 | AC_FUNC_MMAP 26 | AC_CHECK_FUNCS([getpagesize memset munmap strtol]) 27 | 28 | # Checks for typedefs, structures, and compiler characteristics. 29 | 30 | # Checks for library functions. 31 | 32 | AC_CONFIG_FILES([Makefile]) 33 | AC_OUTPUT 34 | -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | linux-ftools (1.3.0) stable; urgency=high 2 | * added linux-prefix to everything 3 | 4 | linux-ftools (1.2.0) stable; urgency=high 5 | * added linux-prefix 6 | 7 | linux-ftools (1.1.0) stable; urgency=high 8 | * Fixed a number of bugs and package is now stable 9 | 10 | linux-ftools (1.0.0) unstable; urgency=low 11 | 12 | * Initial Release. 13 | 14 | -- root Mon, 07 Jun 2010 18:39:20 +0000 15 | -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 7 2 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: linux-ftools 2 | Section: unknown 3 | Priority: extra 4 | Maintainer: Kevin Burton 5 | Build-Depends: debhelper (>= 7), autotools-dev 6 | Standards-Version: 3.7.3 7 | Homepage: http://code.google.com/p/linux-ftools/ 8 | 9 | Package: linux-ftools 10 | Architecture: any 11 | Depends: ${shlibs:Depends}, ${misc:Depends} 12 | Description: These are tools designed for working with modern linux system calls including, mincore, fallocate, fadvise, etc. 13 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | This package was debianized by root on 2 | Mon, 07 Jun 2010 18:39:20 +0000. 3 | 4 | It was downloaded from 5 | 6 | Upstream Author(s): 7 | 8 | 9 | 10 | 11 | Copyright: 12 | 13 | 14 | 15 | 16 | License: 17 | 18 | This package is free software; you can redistribute it and/or modify 19 | it under the terms of the GNU General Public License as published by 20 | the Free Software Foundation; either version 2 of the License, or 21 | (at your option) any later version. 22 | 23 | This package is distributed in the hope that it will be useful, 24 | but WITHOUT ANY WARRANTY; without even the implied warranty of 25 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 26 | GNU General Public License for more details. 27 | 28 | You should have received a copy of the GNU General Public License 29 | along with this package; if not, write to the Free Software 30 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 31 | 32 | On Debian systems, the complete text of the GNU General 33 | Public License can be found in `/usr/share/common-licenses/GPL'. 34 | 35 | The Debian packaging is (C) 2010, root and 36 | is licensed under the GPL, see above. 37 | 38 | 39 | # Please also look if there are files or directories which have a 40 | # different copyright/license attached and list them here. 41 | -------------------------------------------------------------------------------- /debian/dirs: -------------------------------------------------------------------------------- 1 | usr/bin 2 | usr/sbin 3 | -------------------------------------------------------------------------------- /debian/docs: -------------------------------------------------------------------------------- 1 | NEWS 2 | README 3 | -------------------------------------------------------------------------------- /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 | # These are used for cross-compiling and for saving the configure script 14 | # from having to guess our platform (since we know it already) 15 | DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) 16 | DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) 17 | ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE)) 18 | CROSS= --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE) 19 | else 20 | CROSS= --build $(DEB_BUILD_GNU_TYPE) 21 | endif 22 | 23 | 24 | 25 | config.status: configure 26 | dh_testdir 27 | # Add here commands to configure the package. 28 | ifneq "$(wildcard /usr/share/misc/config.sub)" "" 29 | cp -f /usr/share/misc/config.sub config.sub 30 | endif 31 | ifneq "$(wildcard /usr/share/misc/config.guess)" "" 32 | cp -f /usr/share/misc/config.guess config.guess 33 | endif 34 | ./configure $(CROSS) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info CFLAGS="$(CFLAGS)" LDFLAGS="-Wl,-z,defs" 35 | 36 | 37 | build: build-stamp 38 | 39 | build-stamp: config.status 40 | dh_testdir 41 | 42 | # Add here commands to compile the package. 43 | $(MAKE) 44 | #docbook-to-man debian/linux-ftools.sgml > linux-ftools.1 45 | 46 | touch $@ 47 | 48 | clean: 49 | dh_testdir 50 | dh_testroot 51 | rm -f build-stamp 52 | 53 | # Add here commands to clean up after the build process. 54 | [ ! -f Makefile ] || $(MAKE) distclean 55 | rm -f config.sub config.guess 56 | 57 | dh_clean 58 | 59 | install: build 60 | dh_testdir 61 | dh_testroot 62 | dh_clean -k 63 | dh_installdirs 64 | 65 | # Add here commands to install the package into debian/linux-ftools. 66 | $(MAKE) DESTDIR=$(CURDIR)/debian/linux-ftools install 67 | 68 | 69 | # Build architecture-independent files here. 70 | binary-indep: build install 71 | # We have nothing to do by default. 72 | 73 | # Build architecture-dependent files here. 74 | binary-arch: build install 75 | dh_testdir 76 | dh_testroot 77 | dh_installchangelogs ChangeLog 78 | dh_installdocs 79 | dh_installexamples 80 | # dh_install 81 | # dh_installmenu 82 | # dh_installdebconf 83 | # dh_installlogrotate 84 | # dh_installemacsen 85 | # dh_installpam 86 | # dh_installmime 87 | # dh_python 88 | # dh_installinit 89 | # dh_installcron 90 | # dh_installinfo 91 | dh_installman 92 | dh_link 93 | dh_strip 94 | dh_compress 95 | dh_fixperms 96 | # dh_perl 97 | # dh_makeshlibs 98 | dh_installdeb 99 | dh_shlibdeps 100 | dh_gencontrol 101 | dh_md5sums 102 | dh_builddeb 103 | 104 | binary: binary-indep binary-arch 105 | .PHONY: build clean binary-indep binary-arch binary install 106 | -------------------------------------------------------------------------------- /depcomp: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # depcomp - compile a program generating dependencies as side-effects 3 | 4 | scriptversion=2006-10-15.18 5 | 6 | # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006 Free Software 7 | # Foundation, Inc. 8 | 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2, or (at your option) 12 | # any later version. 13 | 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program; if not, write to the Free Software 21 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 22 | # 02110-1301, USA. 23 | 24 | # As a special exception to the GNU General Public License, if you 25 | # distribute this file as part of a program that contains a 26 | # configuration script generated by Autoconf, you may include it under 27 | # the same distribution terms that you use for the rest of that program. 28 | 29 | # Originally written by Alexandre Oliva . 30 | 31 | case $1 in 32 | '') 33 | echo "$0: No command. Try \`$0 --help' for more information." 1>&2 34 | exit 1; 35 | ;; 36 | -h | --h*) 37 | cat <<\EOF 38 | Usage: depcomp [--help] [--version] PROGRAM [ARGS] 39 | 40 | Run PROGRAMS ARGS to compile a file, generating dependencies 41 | as side-effects. 42 | 43 | Environment variables: 44 | depmode Dependency tracking mode. 45 | source Source file read by `PROGRAMS ARGS'. 46 | object Object file output by `PROGRAMS ARGS'. 47 | DEPDIR directory where to store dependencies. 48 | depfile Dependency file to output. 49 | tmpdepfile Temporary file to use when outputing dependencies. 50 | libtool Whether libtool is used (yes/no). 51 | 52 | Report bugs to . 53 | EOF 54 | exit $? 55 | ;; 56 | -v | --v*) 57 | echo "depcomp $scriptversion" 58 | exit $? 59 | ;; 60 | esac 61 | 62 | if test -z "$depmode" || test -z "$source" || test -z "$object"; then 63 | echo "depcomp: Variables source, object and depmode must be set" 1>&2 64 | exit 1 65 | fi 66 | 67 | # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 68 | depfile=${depfile-`echo "$object" | 69 | sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 70 | tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 71 | 72 | rm -f "$tmpdepfile" 73 | 74 | # Some modes work just like other modes, but use different flags. We 75 | # parameterize here, but still list the modes in the big case below, 76 | # to make depend.m4 easier to write. Note that we *cannot* use a case 77 | # here, because this file can only contain one case statement. 78 | if test "$depmode" = hp; then 79 | # HP compiler uses -M and no extra arg. 80 | gccflag=-M 81 | depmode=gcc 82 | fi 83 | 84 | if test "$depmode" = dashXmstdout; then 85 | # This is just like dashmstdout with a different argument. 86 | dashmflag=-xM 87 | depmode=dashmstdout 88 | fi 89 | 90 | case "$depmode" in 91 | gcc3) 92 | ## gcc 3 implements dependency tracking that does exactly what 93 | ## we want. Yay! Note: for some reason libtool 1.4 doesn't like 94 | ## it if -MD -MP comes after the -MF stuff. Hmm. 95 | ## Unfortunately, FreeBSD c89 acceptance of flags depends upon 96 | ## the command line argument order; so add the flags where they 97 | ## appear in depend2.am. Note that the slowdown incurred here 98 | ## affects only configure: in makefiles, %FASTDEP% shortcuts this. 99 | for arg 100 | do 101 | case $arg in 102 | -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 103 | *) set fnord "$@" "$arg" ;; 104 | esac 105 | shift # fnord 106 | shift # $arg 107 | done 108 | "$@" 109 | stat=$? 110 | if test $stat -eq 0; then : 111 | else 112 | rm -f "$tmpdepfile" 113 | exit $stat 114 | fi 115 | mv "$tmpdepfile" "$depfile" 116 | ;; 117 | 118 | gcc) 119 | ## There are various ways to get dependency output from gcc. Here's 120 | ## why we pick this rather obscure method: 121 | ## - Don't want to use -MD because we'd like the dependencies to end 122 | ## up in a subdir. Having to rename by hand is ugly. 123 | ## (We might end up doing this anyway to support other compilers.) 124 | ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 125 | ## -MM, not -M (despite what the docs say). 126 | ## - Using -M directly means running the compiler twice (even worse 127 | ## than renaming). 128 | if test -z "$gccflag"; then 129 | gccflag=-MD, 130 | fi 131 | "$@" -Wp,"$gccflag$tmpdepfile" 132 | stat=$? 133 | if test $stat -eq 0; then : 134 | else 135 | rm -f "$tmpdepfile" 136 | exit $stat 137 | fi 138 | rm -f "$depfile" 139 | echo "$object : \\" > "$depfile" 140 | alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 141 | ## The second -e expression handles DOS-style file names with drive letters. 142 | sed -e 's/^[^:]*: / /' \ 143 | -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 144 | ## This next piece of magic avoids the `deleted header file' problem. 145 | ## The problem is that when a header file which appears in a .P file 146 | ## is deleted, the dependency causes make to die (because there is 147 | ## typically no way to rebuild the header). We avoid this by adding 148 | ## dummy dependencies for each header file. Too bad gcc doesn't do 149 | ## this for us directly. 150 | tr ' ' ' 151 | ' < "$tmpdepfile" | 152 | ## Some versions of gcc put a space before the `:'. On the theory 153 | ## that the space means something, we add a space to the output as 154 | ## well. 155 | ## Some versions of the HPUX 10.20 sed can't process this invocation 156 | ## correctly. Breaking it into two sed invocations is a workaround. 157 | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 158 | rm -f "$tmpdepfile" 159 | ;; 160 | 161 | hp) 162 | # This case exists only to let depend.m4 do its work. It works by 163 | # looking at the text of this script. This case will never be run, 164 | # since it is checked for above. 165 | exit 1 166 | ;; 167 | 168 | sgi) 169 | if test "$libtool" = yes; then 170 | "$@" "-Wp,-MDupdate,$tmpdepfile" 171 | else 172 | "$@" -MDupdate "$tmpdepfile" 173 | fi 174 | stat=$? 175 | if test $stat -eq 0; then : 176 | else 177 | rm -f "$tmpdepfile" 178 | exit $stat 179 | fi 180 | rm -f "$depfile" 181 | 182 | if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 183 | echo "$object : \\" > "$depfile" 184 | 185 | # Clip off the initial element (the dependent). Don't try to be 186 | # clever and replace this with sed code, as IRIX sed won't handle 187 | # lines with more than a fixed number of characters (4096 in 188 | # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 189 | # the IRIX cc adds comments like `#:fec' to the end of the 190 | # dependency line. 191 | tr ' ' ' 192 | ' < "$tmpdepfile" \ 193 | | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 194 | tr ' 195 | ' ' ' >> $depfile 196 | echo >> $depfile 197 | 198 | # The second pass generates a dummy entry for each header file. 199 | tr ' ' ' 200 | ' < "$tmpdepfile" \ 201 | | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 202 | >> $depfile 203 | else 204 | # The sourcefile does not contain any dependencies, so just 205 | # store a dummy comment line, to avoid errors with the Makefile 206 | # "include basename.Plo" scheme. 207 | echo "#dummy" > "$depfile" 208 | fi 209 | rm -f "$tmpdepfile" 210 | ;; 211 | 212 | aix) 213 | # The C for AIX Compiler uses -M and outputs the dependencies 214 | # in a .u file. In older versions, this file always lives in the 215 | # current directory. Also, the AIX compiler puts `$object:' at the 216 | # start of each line; $object doesn't have directory information. 217 | # Version 6 uses the directory in both cases. 218 | stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'` 219 | tmpdepfile="$stripped.u" 220 | if test "$libtool" = yes; then 221 | "$@" -Wc,-M 222 | else 223 | "$@" -M 224 | fi 225 | stat=$? 226 | 227 | if test -f "$tmpdepfile"; then : 228 | else 229 | stripped=`echo "$stripped" | sed 's,^.*/,,'` 230 | tmpdepfile="$stripped.u" 231 | fi 232 | 233 | if test $stat -eq 0; then : 234 | else 235 | rm -f "$tmpdepfile" 236 | exit $stat 237 | fi 238 | 239 | if test -f "$tmpdepfile"; then 240 | outname="$stripped.o" 241 | # Each line is of the form `foo.o: dependent.h'. 242 | # Do two passes, one to just change these to 243 | # `$object: dependent.h' and one to simply `dependent.h:'. 244 | sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" 245 | sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" 246 | else 247 | # The sourcefile does not contain any dependencies, so just 248 | # store a dummy comment line, to avoid errors with the Makefile 249 | # "include basename.Plo" scheme. 250 | echo "#dummy" > "$depfile" 251 | fi 252 | rm -f "$tmpdepfile" 253 | ;; 254 | 255 | icc) 256 | # Intel's C compiler understands `-MD -MF file'. However on 257 | # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 258 | # ICC 7.0 will fill foo.d with something like 259 | # foo.o: sub/foo.c 260 | # foo.o: sub/foo.h 261 | # which is wrong. We want: 262 | # sub/foo.o: sub/foo.c 263 | # sub/foo.o: sub/foo.h 264 | # sub/foo.c: 265 | # sub/foo.h: 266 | # ICC 7.1 will output 267 | # foo.o: sub/foo.c sub/foo.h 268 | # and will wrap long lines using \ : 269 | # foo.o: sub/foo.c ... \ 270 | # sub/foo.h ... \ 271 | # ... 272 | 273 | "$@" -MD -MF "$tmpdepfile" 274 | stat=$? 275 | if test $stat -eq 0; then : 276 | else 277 | rm -f "$tmpdepfile" 278 | exit $stat 279 | fi 280 | rm -f "$depfile" 281 | # Each line is of the form `foo.o: dependent.h', 282 | # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 283 | # Do two passes, one to just change these to 284 | # `$object: dependent.h' and one to simply `dependent.h:'. 285 | sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 286 | # Some versions of the HPUX 10.20 sed can't process this invocation 287 | # correctly. Breaking it into two sed invocations is a workaround. 288 | sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 289 | sed -e 's/$/ :/' >> "$depfile" 290 | rm -f "$tmpdepfile" 291 | ;; 292 | 293 | hp2) 294 | # The "hp" stanza above does not work with aCC (C++) and HP's ia64 295 | # compilers, which have integrated preprocessors. The correct option 296 | # to use with these is +Maked; it writes dependencies to a file named 297 | # 'foo.d', which lands next to the object file, wherever that 298 | # happens to be. 299 | # Much of this is similar to the tru64 case; see comments there. 300 | dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 301 | test "x$dir" = "x$object" && dir= 302 | base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 303 | if test "$libtool" = yes; then 304 | tmpdepfile1=$dir$base.d 305 | tmpdepfile2=$dir.libs/$base.d 306 | "$@" -Wc,+Maked 307 | else 308 | tmpdepfile1=$dir$base.d 309 | tmpdepfile2=$dir$base.d 310 | "$@" +Maked 311 | fi 312 | stat=$? 313 | if test $stat -eq 0; then : 314 | else 315 | rm -f "$tmpdepfile1" "$tmpdepfile2" 316 | exit $stat 317 | fi 318 | 319 | for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 320 | do 321 | test -f "$tmpdepfile" && break 322 | done 323 | if test -f "$tmpdepfile"; then 324 | sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 325 | # Add `dependent.h:' lines. 326 | sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile" 327 | else 328 | echo "#dummy" > "$depfile" 329 | fi 330 | rm -f "$tmpdepfile" "$tmpdepfile2" 331 | ;; 332 | 333 | tru64) 334 | # The Tru64 compiler uses -MD to generate dependencies as a side 335 | # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 336 | # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 337 | # dependencies in `foo.d' instead, so we check for that too. 338 | # Subdirectories are respected. 339 | dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 340 | test "x$dir" = "x$object" && dir= 341 | base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 342 | 343 | if test "$libtool" = yes; then 344 | # With Tru64 cc, shared objects can also be used to make a 345 | # static library. This mechanism is used in libtool 1.4 series to 346 | # handle both shared and static libraries in a single compilation. 347 | # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 348 | # 349 | # With libtool 1.5 this exception was removed, and libtool now 350 | # generates 2 separate objects for the 2 libraries. These two 351 | # compilations output dependencies in $dir.libs/$base.o.d and 352 | # in $dir$base.o.d. We have to check for both files, because 353 | # one of the two compilations can be disabled. We should prefer 354 | # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 355 | # automatically cleaned when .libs/ is deleted, while ignoring 356 | # the former would cause a distcleancheck panic. 357 | tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 358 | tmpdepfile2=$dir$base.o.d # libtool 1.5 359 | tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 360 | tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 361 | "$@" -Wc,-MD 362 | else 363 | tmpdepfile1=$dir$base.o.d 364 | tmpdepfile2=$dir$base.d 365 | tmpdepfile3=$dir$base.d 366 | tmpdepfile4=$dir$base.d 367 | "$@" -MD 368 | fi 369 | 370 | stat=$? 371 | if test $stat -eq 0; then : 372 | else 373 | rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 374 | exit $stat 375 | fi 376 | 377 | for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 378 | do 379 | test -f "$tmpdepfile" && break 380 | done 381 | if test -f "$tmpdepfile"; then 382 | sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 383 | # That's a tab and a space in the []. 384 | sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 385 | else 386 | echo "#dummy" > "$depfile" 387 | fi 388 | rm -f "$tmpdepfile" 389 | ;; 390 | 391 | #nosideeffect) 392 | # This comment above is used by automake to tell side-effect 393 | # dependency tracking mechanisms from slower ones. 394 | 395 | dashmstdout) 396 | # Important note: in order to support this mode, a compiler *must* 397 | # always write the preprocessed file to stdout, regardless of -o. 398 | "$@" || exit $? 399 | 400 | # Remove the call to Libtool. 401 | if test "$libtool" = yes; then 402 | while test $1 != '--mode=compile'; do 403 | shift 404 | done 405 | shift 406 | fi 407 | 408 | # Remove `-o $object'. 409 | IFS=" " 410 | for arg 411 | do 412 | case $arg in 413 | -o) 414 | shift 415 | ;; 416 | $object) 417 | shift 418 | ;; 419 | *) 420 | set fnord "$@" "$arg" 421 | shift # fnord 422 | shift # $arg 423 | ;; 424 | esac 425 | done 426 | 427 | test -z "$dashmflag" && dashmflag=-M 428 | # Require at least two characters before searching for `:' 429 | # in the target name. This is to cope with DOS-style filenames: 430 | # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 431 | "$@" $dashmflag | 432 | sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 433 | rm -f "$depfile" 434 | cat < "$tmpdepfile" > "$depfile" 435 | tr ' ' ' 436 | ' < "$tmpdepfile" | \ 437 | ## Some versions of the HPUX 10.20 sed can't process this invocation 438 | ## correctly. Breaking it into two sed invocations is a workaround. 439 | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 440 | rm -f "$tmpdepfile" 441 | ;; 442 | 443 | dashXmstdout) 444 | # This case only exists to satisfy depend.m4. It is never actually 445 | # run, as this mode is specially recognized in the preamble. 446 | exit 1 447 | ;; 448 | 449 | makedepend) 450 | "$@" || exit $? 451 | # Remove any Libtool call 452 | if test "$libtool" = yes; then 453 | while test $1 != '--mode=compile'; do 454 | shift 455 | done 456 | shift 457 | fi 458 | # X makedepend 459 | shift 460 | cleared=no 461 | for arg in "$@"; do 462 | case $cleared in 463 | no) 464 | set ""; shift 465 | cleared=yes ;; 466 | esac 467 | case "$arg" in 468 | -D*|-I*) 469 | set fnord "$@" "$arg"; shift ;; 470 | # Strip any option that makedepend may not understand. Remove 471 | # the object too, otherwise makedepend will parse it as a source file. 472 | -*|$object) 473 | ;; 474 | *) 475 | set fnord "$@" "$arg"; shift ;; 476 | esac 477 | done 478 | obj_suffix="`echo $object | sed 's/^.*\././'`" 479 | touch "$tmpdepfile" 480 | ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 481 | rm -f "$depfile" 482 | cat < "$tmpdepfile" > "$depfile" 483 | sed '1,2d' "$tmpdepfile" | tr ' ' ' 484 | ' | \ 485 | ## Some versions of the HPUX 10.20 sed can't process this invocation 486 | ## correctly. Breaking it into two sed invocations is a workaround. 487 | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 488 | rm -f "$tmpdepfile" "$tmpdepfile".bak 489 | ;; 490 | 491 | cpp) 492 | # Important note: in order to support this mode, a compiler *must* 493 | # always write the preprocessed file to stdout. 494 | "$@" || exit $? 495 | 496 | # Remove the call to Libtool. 497 | if test "$libtool" = yes; then 498 | while test $1 != '--mode=compile'; do 499 | shift 500 | done 501 | shift 502 | fi 503 | 504 | # Remove `-o $object'. 505 | IFS=" " 506 | for arg 507 | do 508 | case $arg in 509 | -o) 510 | shift 511 | ;; 512 | $object) 513 | shift 514 | ;; 515 | *) 516 | set fnord "$@" "$arg" 517 | shift # fnord 518 | shift # $arg 519 | ;; 520 | esac 521 | done 522 | 523 | "$@" -E | 524 | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 525 | -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 526 | sed '$ s: \\$::' > "$tmpdepfile" 527 | rm -f "$depfile" 528 | echo "$object : \\" > "$depfile" 529 | cat < "$tmpdepfile" >> "$depfile" 530 | sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 531 | rm -f "$tmpdepfile" 532 | ;; 533 | 534 | msvisualcpp) 535 | # Important note: in order to support this mode, a compiler *must* 536 | # always write the preprocessed file to stdout, regardless of -o, 537 | # because we must use -o when running libtool. 538 | "$@" || exit $? 539 | IFS=" " 540 | for arg 541 | do 542 | case "$arg" in 543 | "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 544 | set fnord "$@" 545 | shift 546 | shift 547 | ;; 548 | *) 549 | set fnord "$@" "$arg" 550 | shift 551 | shift 552 | ;; 553 | esac 554 | done 555 | "$@" -E | 556 | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" 557 | rm -f "$depfile" 558 | echo "$object : \\" > "$depfile" 559 | . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 560 | echo " " >> "$depfile" 561 | . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" 562 | rm -f "$tmpdepfile" 563 | ;; 564 | 565 | none) 566 | exec "$@" 567 | ;; 568 | 569 | *) 570 | echo "Unknown depmode $depmode" 1>&2 571 | exit 1 572 | ;; 573 | esac 574 | 575 | exit 0 576 | 577 | # Local Variables: 578 | # mode: shell-script 579 | # sh-indentation: 2 580 | # eval: (add-hook 'write-file-hooks 'time-stamp) 581 | # time-stamp-start: "scriptversion=" 582 | # time-stamp-format: "%:y-%02m-%02d.%02H" 583 | # time-stamp-end: "$" 584 | # End: 585 | -------------------------------------------------------------------------------- /install-sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # install - install a program, script, or datafile 3 | 4 | scriptversion=2006-10-14.15 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 | mvprog="${MVPROG-mv}" 62 | cpprog="${CPPROG-cp}" 63 | chmodprog="${CHMODPROG-chmod}" 64 | chownprog="${CHOWNPROG-chown}" 65 | chgrpprog="${CHGRPPROG-chgrp}" 66 | stripprog="${STRIPPROG-strip}" 67 | rmprog="${RMPROG-rm}" 68 | mkdirprog="${MKDIRPROG-mkdir}" 69 | 70 | posix_glob= 71 | posix_mkdir= 72 | 73 | # Desired mode of installed file. 74 | mode=0755 75 | 76 | chmodcmd=$chmodprog 77 | chowncmd= 78 | chgrpcmd= 79 | stripcmd= 80 | rmcmd="$rmprog -f" 81 | mvcmd="$mvprog" 82 | src= 83 | dst= 84 | dir_arg= 85 | dstarg= 86 | no_target_directory= 87 | 88 | usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE 89 | or: $0 [OPTION]... SRCFILES... DIRECTORY 90 | or: $0 [OPTION]... -t DIRECTORY SRCFILES... 91 | or: $0 [OPTION]... -d DIRECTORIES... 92 | 93 | In the 1st form, copy SRCFILE to DSTFILE. 94 | In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. 95 | In the 4th, create DIRECTORIES. 96 | 97 | Options: 98 | -c (ignored) 99 | -d create directories instead of installing files. 100 | -g GROUP $chgrpprog installed files to GROUP. 101 | -m MODE $chmodprog installed files to MODE. 102 | -o USER $chownprog installed files to USER. 103 | -s $stripprog installed files. 104 | -t DIRECTORY install into DIRECTORY. 105 | -T report an error if DSTFILE is a directory. 106 | --help display this help and exit. 107 | --version display version info and exit. 108 | 109 | Environment variables override the default commands: 110 | CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG 111 | " 112 | 113 | while test $# -ne 0; do 114 | case $1 in 115 | -c) shift 116 | continue;; 117 | 118 | -d) dir_arg=true 119 | shift 120 | continue;; 121 | 122 | -g) chgrpcmd="$chgrpprog $2" 123 | shift 124 | shift 125 | continue;; 126 | 127 | --help) echo "$usage"; exit $?;; 128 | 129 | -m) mode=$2 130 | shift 131 | shift 132 | case $mode in 133 | *' '* | *' '* | *' 134 | '* | *'*'* | *'?'* | *'['*) 135 | echo "$0: invalid mode: $mode" >&2 136 | exit 1;; 137 | esac 138 | continue;; 139 | 140 | -o) chowncmd="$chownprog $2" 141 | shift 142 | shift 143 | continue;; 144 | 145 | -s) stripcmd=$stripprog 146 | shift 147 | continue;; 148 | 149 | -t) dstarg=$2 150 | shift 151 | shift 152 | continue;; 153 | 154 | -T) no_target_directory=true 155 | shift 156 | continue;; 157 | 158 | --version) echo "$0 $scriptversion"; exit $?;; 159 | 160 | --) shift 161 | break;; 162 | 163 | -*) echo "$0: invalid option: $1" >&2 164 | exit 1;; 165 | 166 | *) break;; 167 | esac 168 | done 169 | 170 | if test $# -ne 0 && test -z "$dir_arg$dstarg"; then 171 | # When -d is used, all remaining arguments are directories to create. 172 | # When -t is used, the destination is already specified. 173 | # Otherwise, the last argument is the destination. Remove it from $@. 174 | for arg 175 | do 176 | if test -n "$dstarg"; then 177 | # $@ is not empty: it contains at least $arg. 178 | set fnord "$@" "$dstarg" 179 | shift # fnord 180 | fi 181 | shift # arg 182 | dstarg=$arg 183 | done 184 | fi 185 | 186 | if test $# -eq 0; then 187 | if test -z "$dir_arg"; then 188 | echo "$0: no input file specified." >&2 189 | exit 1 190 | fi 191 | # It's OK to call `install-sh -d' without argument. 192 | # This can happen when creating conditional directories. 193 | exit 0 194 | fi 195 | 196 | if test -z "$dir_arg"; then 197 | trap '(exit $?); exit' 1 2 13 15 198 | 199 | # Set umask so as not to create temps with too-generous modes. 200 | # However, 'strip' requires both read and write access to temps. 201 | case $mode in 202 | # Optimize common cases. 203 | *644) cp_umask=133;; 204 | *755) cp_umask=22;; 205 | 206 | *[0-7]) 207 | if test -z "$stripcmd"; then 208 | u_plus_rw= 209 | else 210 | u_plus_rw='% 200' 211 | fi 212 | cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; 213 | *) 214 | if test -z "$stripcmd"; then 215 | u_plus_rw= 216 | else 217 | u_plus_rw=,u+rw 218 | fi 219 | cp_umask=$mode$u_plus_rw;; 220 | esac 221 | fi 222 | 223 | for src 224 | do 225 | # Protect names starting with `-'. 226 | case $src in 227 | -*) src=./$src ;; 228 | esac 229 | 230 | if test -n "$dir_arg"; then 231 | dst=$src 232 | dstdir=$dst 233 | test -d "$dstdir" 234 | dstdir_status=$? 235 | else 236 | 237 | # Waiting for this to be detected by the "$cpprog $src $dsttmp" command 238 | # might cause directories to be created, which would be especially bad 239 | # if $src (and thus $dsttmp) contains '*'. 240 | if test ! -f "$src" && test ! -d "$src"; then 241 | echo "$0: $src does not exist." >&2 242 | exit 1 243 | fi 244 | 245 | if test -z "$dstarg"; then 246 | echo "$0: no destination specified." >&2 247 | exit 1 248 | fi 249 | 250 | dst=$dstarg 251 | # Protect names starting with `-'. 252 | case $dst in 253 | -*) dst=./$dst ;; 254 | esac 255 | 256 | # If destination is a directory, append the input filename; won't work 257 | # if double slashes aren't ignored. 258 | if test -d "$dst"; then 259 | if test -n "$no_target_directory"; then 260 | echo "$0: $dstarg: Is a directory" >&2 261 | exit 1 262 | fi 263 | dstdir=$dst 264 | dst=$dstdir/`basename "$src"` 265 | dstdir_status=0 266 | else 267 | # Prefer dirname, but fall back on a substitute if dirname fails. 268 | dstdir=` 269 | (dirname "$dst") 2>/dev/null || 270 | expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ 271 | X"$dst" : 'X\(//\)[^/]' \| \ 272 | X"$dst" : 'X\(//\)$' \| \ 273 | X"$dst" : 'X\(/\)' \| . 2>/dev/null || 274 | echo X"$dst" | 275 | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ 276 | s//\1/ 277 | q 278 | } 279 | /^X\(\/\/\)[^/].*/{ 280 | s//\1/ 281 | q 282 | } 283 | /^X\(\/\/\)$/{ 284 | s//\1/ 285 | q 286 | } 287 | /^X\(\/\).*/{ 288 | s//\1/ 289 | q 290 | } 291 | s/.*/./; q' 292 | ` 293 | 294 | test -d "$dstdir" 295 | dstdir_status=$? 296 | fi 297 | fi 298 | 299 | obsolete_mkdir_used=false 300 | 301 | if test $dstdir_status != 0; then 302 | case $posix_mkdir in 303 | '') 304 | # Create intermediate dirs using mode 755 as modified by the umask. 305 | # This is like FreeBSD 'install' as of 1997-10-28. 306 | umask=`umask` 307 | case $stripcmd.$umask in 308 | # Optimize common cases. 309 | *[2367][2367]) mkdir_umask=$umask;; 310 | .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; 311 | 312 | *[0-7]) 313 | mkdir_umask=`expr $umask + 22 \ 314 | - $umask % 100 % 40 + $umask % 20 \ 315 | - $umask % 10 % 4 + $umask % 2 316 | `;; 317 | *) mkdir_umask=$umask,go-w;; 318 | esac 319 | 320 | # With -d, create the new directory with the user-specified mode. 321 | # Otherwise, rely on $mkdir_umask. 322 | if test -n "$dir_arg"; then 323 | mkdir_mode=-m$mode 324 | else 325 | mkdir_mode= 326 | fi 327 | 328 | posix_mkdir=false 329 | case $umask in 330 | *[123567][0-7][0-7]) 331 | # POSIX mkdir -p sets u+wx bits regardless of umask, which 332 | # is incompatible with FreeBSD 'install' when (umask & 300) != 0. 333 | ;; 334 | *) 335 | tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ 336 | trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 337 | 338 | if (umask $mkdir_umask && 339 | exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 340 | then 341 | if test -z "$dir_arg" || { 342 | # Check for POSIX incompatibilities with -m. 343 | # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or 344 | # other-writeable bit of parent directory when it shouldn't. 345 | # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. 346 | ls_ld_tmpdir=`ls -ld "$tmpdir"` 347 | case $ls_ld_tmpdir in 348 | d????-?r-*) different_mode=700;; 349 | d????-?--*) different_mode=755;; 350 | *) false;; 351 | esac && 352 | $mkdirprog -m$different_mode -p -- "$tmpdir" && { 353 | ls_ld_tmpdir_1=`ls -ld "$tmpdir"` 354 | test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" 355 | } 356 | } 357 | then posix_mkdir=: 358 | fi 359 | rmdir "$tmpdir/d" "$tmpdir" 360 | else 361 | # Remove any dirs left behind by ancient mkdir implementations. 362 | rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null 363 | fi 364 | trap '' 0;; 365 | esac;; 366 | esac 367 | 368 | if 369 | $posix_mkdir && ( 370 | umask $mkdir_umask && 371 | $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" 372 | ) 373 | then : 374 | else 375 | 376 | # The umask is ridiculous, or mkdir does not conform to POSIX, 377 | # or it failed possibly due to a race condition. Create the 378 | # directory the slow way, step by step, checking for races as we go. 379 | 380 | case $dstdir in 381 | /*) prefix=/ ;; 382 | -*) prefix=./ ;; 383 | *) prefix= ;; 384 | esac 385 | 386 | case $posix_glob in 387 | '') 388 | if (set -f) 2>/dev/null; then 389 | posix_glob=true 390 | else 391 | posix_glob=false 392 | fi ;; 393 | esac 394 | 395 | oIFS=$IFS 396 | IFS=/ 397 | $posix_glob && set -f 398 | set fnord $dstdir 399 | shift 400 | $posix_glob && set +f 401 | IFS=$oIFS 402 | 403 | prefixes= 404 | 405 | for d 406 | do 407 | test -z "$d" && continue 408 | 409 | prefix=$prefix$d 410 | if test -d "$prefix"; then 411 | prefixes= 412 | else 413 | if $posix_mkdir; then 414 | (umask=$mkdir_umask && 415 | $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break 416 | # Don't fail if two instances are running concurrently. 417 | test -d "$prefix" || exit 1 418 | else 419 | case $prefix in 420 | *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; 421 | *) qprefix=$prefix;; 422 | esac 423 | prefixes="$prefixes '$qprefix'" 424 | fi 425 | fi 426 | prefix=$prefix/ 427 | done 428 | 429 | if test -n "$prefixes"; then 430 | # Don't fail if two instances are running concurrently. 431 | (umask $mkdir_umask && 432 | eval "\$doit_exec \$mkdirprog $prefixes") || 433 | test -d "$dstdir" || exit 1 434 | obsolete_mkdir_used=true 435 | fi 436 | fi 437 | fi 438 | 439 | if test -n "$dir_arg"; then 440 | { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && 441 | { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && 442 | { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || 443 | test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 444 | else 445 | 446 | # Make a couple of temp file names in the proper directory. 447 | dsttmp=$dstdir/_inst.$$_ 448 | rmtmp=$dstdir/_rm.$$_ 449 | 450 | # Trap to clean up those temp files at exit. 451 | trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 452 | 453 | # Copy the file name to the temp name. 454 | (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && 455 | 456 | # and set any options; do chmod last to preserve setuid bits. 457 | # 458 | # If any of these fail, we abort the whole thing. If we want to 459 | # ignore errors from any of these, just make sure not to ignore 460 | # errors from the above "$doit $cpprog $src $dsttmp" command. 461 | # 462 | { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \ 463 | && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \ 464 | && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \ 465 | && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && 466 | 467 | # Now rename the file to the real destination. 468 | { $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null \ 469 | || { 470 | # The rename failed, perhaps because mv can't rename something else 471 | # to itself, or perhaps because mv is so ancient that it does not 472 | # support -f. 473 | 474 | # Now remove or move aside any old file at destination location. 475 | # We try this two ways since rm can't unlink itself on some 476 | # systems and the destination file might be busy for other 477 | # reasons. In this case, the final cleanup might fail but the new 478 | # file should still install successfully. 479 | { 480 | if test -f "$dst"; then 481 | $doit $rmcmd -f "$dst" 2>/dev/null \ 482 | || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null \ 483 | && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }; }\ 484 | || { 485 | echo "$0: cannot unlink or rename $dst" >&2 486 | (exit 1); exit 1 487 | } 488 | else 489 | : 490 | fi 491 | } && 492 | 493 | # Now rename the file to the real destination. 494 | $doit $mvcmd "$dsttmp" "$dst" 495 | } 496 | } || exit 1 497 | 498 | trap '' 0 499 | fi 500 | done 501 | 502 | # Local variables: 503 | # eval: (add-hook 'write-file-hooks 'time-stamp) 504 | # time-stamp-start: "scriptversion=" 505 | # time-stamp-format: "%:y-%02m-%02d.%02H" 506 | # time-stamp-end: "$" 507 | # End: 508 | -------------------------------------------------------------------------------- /linux-fadvise.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | //convert the given string to uppercase. 16 | void strtoupper( char* str ) { 17 | 18 | int i; 19 | 20 | for( i = 0; i < strlen( str ); ++i ) { 21 | str[i] = toupper( str[i] ); 22 | } 23 | 24 | } 25 | 26 | /** 27 | 28 | SYNTAX: filename mode [offset] [,length] 29 | Where mode can be: 30 | 31 | POSIX_FADV_NORMAL No further special treatment. 32 | POSIX_FADV_RANDOM Expect random page references. 33 | POSIX_FADV_SEQUENTIAL Expect sequential page references. 34 | POSIX_FADV_WILLNEED Will need these pages. 35 | POSIX_FADV_DONTNEED Don't need these pages. 36 | POSIX_FADV_NOREUSE Data will be accessed once. 37 | 38 | Allows an application to to tell the kernel how it expects to use a file handle, 39 | so that the kernel can choose appropriate read-ahead and caching techniques for 40 | access to the corresponding file. This is similar to the POSIX version of the 41 | madvise system call, but for file access instead of memory access. The 42 | sys_fadvise64() function is obsolete and corresponds to a broken glibc API, 43 | sys_fadvise64_64() is the fixed version. The following are the values for the 44 | advice parameter: 45 | 46 | FADV_NORMAL 47 | 48 | No special treatment. 49 | 50 | FADV_RANDOM 51 | 52 | Expect page references in random order. 53 | 54 | FADV_SEQUENTIAL 55 | 56 | Expect page references in sequential order. 57 | 58 | FADV_WILLNEED 59 | 60 | Expect access in the near future. 61 | 62 | FADV_DONTNEED 63 | 64 | Do not expect access in the near future. Subsequent access of pages in this 65 | range will succeed, but will result either in reloading of the memory contents 66 | from the underlying mapped file or zero-fill-in-demand pages for mappings 67 | without an underlying file. 68 | 69 | FADV_NOREUSE 70 | 71 | Access data only once. 72 | 73 | */ 74 | int main(int argc, char *argv[]) { 75 | 76 | if ( argc < 3 ) { 77 | fprintf( stderr, "%s version %s\n", argv[0], LINUX_FTOOLS_VERSION ); 78 | printf( "SYNTAX: fadvise filename mode [offset] [,length]\n" ); 79 | 80 | printf( "Where mode can be:\n\n" ); 81 | 82 | printf( " POSIX_FADV_NORMAL | NORMAL No further special treatment. \n" ); 83 | printf( " POSIX_FADV_RANDOM | RANDOM Expect random page references. \n" ); 84 | printf( " POSIX_FADV_SEQUENTIAL | SEQUENTIAL Expect sequential page references. \n" ); 85 | printf( " POSIX_FADV_WILLNEED | WILLNEED Will need these pages. \n" ); 86 | printf( " POSIX_FADV_DONTNEED | DONTNEED Don't need these pages. \n" ); 87 | printf( " POSIX_FADV_NOREUSE | NOREUSE Data will be accessed once. \n" ); 88 | 89 | exit( 1 ); 90 | } 91 | 92 | char* path = argv[1]; 93 | char* param_mode = argv[2]; 94 | 95 | strtoupper( param_mode ); 96 | 97 | if ( strcmp( param_mode, "DO_NOT_WANT" ) == 0 ) { 98 | param_mode = "POSIX_FADV_DONTNEED"; 99 | } 100 | 101 | char new_mode[40]; 102 | 103 | if ( strstr( "POSIX_FADV_" , param_mode ) != 0 ) { 104 | strcat( new_mode, "POSIX_FADV_" ); 105 | strcat( new_mode, param_mode ); 106 | param_mode = new_mode; 107 | } 108 | 109 | printf( "Going to fadvise %s as mode %s\n", path , param_mode ); 110 | 111 | int flags = O_RDWR; 112 | int fd = open( path, flags ); 113 | 114 | if ( fd == -1 ) { 115 | perror( NULL ); 116 | return 1; 117 | } 118 | 119 | struct stat fd_stat ; 120 | 121 | if ( fstat( fd, &fd_stat ) < 0 ) { 122 | perror( "Could not stat file: " ); 123 | return 1; 124 | } 125 | 126 | loff_t offset = 0; 127 | loff_t length = fd_stat.st_size; 128 | 129 | if ( argc >= 4 ) { 130 | offset = strtol( argv[3], NULL, 10 ); 131 | } 132 | 133 | if ( argc >= 5 ) { 134 | length = strtol( argv[4], NULL, 10 ); 135 | } 136 | 137 | printf( "offset: %ld\n", offset ); 138 | printf( "length: %ld\n", length ); 139 | 140 | int mode = -1; 141 | 142 | if ( strcmp( param_mode , "POSIX_FADV_NORMAL" ) == 0 ) { 143 | mode = POSIX_FADV_NORMAL; 144 | } else if ( strcmp( param_mode , "POSIX_FADV_RANDOM" ) == 0 ) { 145 | mode = POSIX_FADV_RANDOM; 146 | } else if ( strcmp( param_mode , "POSIX_FADV_SEQUENTIAL" ) == 0 ) { 147 | mode = POSIX_FADV_SEQUENTIAL; 148 | } else if ( strcmp( param_mode , "POSIX_FADV_WILLNEED" ) == 0 ) { 149 | mode = POSIX_FADV_WILLNEED; 150 | } else if ( strcmp( param_mode , "POSIX_FADV_DONTNEED" ) == 0 ) { 151 | mode = POSIX_FADV_DONTNEED; 152 | } else if ( strcmp( param_mode , "POSIX_FADV_NOREUSE" ) == 0 ) { 153 | mode = POSIX_FADV_NOREUSE; 154 | } else { 155 | printf( "Invalid mode %s\n", param_mode ); 156 | exit( 1 ); 157 | } 158 | 159 | printf( "mode: %s\n", param_mode ); 160 | 161 | long result = syscall( SYS_fadvise64, fd, offset, length , mode ); 162 | 163 | if ( result != 0 ) { 164 | 165 | if ( result != -1 ) { 166 | errno=result; 167 | perror( "Unable to fadvise" ); 168 | } else { 169 | printf( "Unable to fadvise: %ld\n" , result ); 170 | } 171 | 172 | return 1; 173 | } 174 | 175 | printf( "WIN\n" ); 176 | 177 | close( fd ); 178 | return 0; 179 | 180 | } 181 | -------------------------------------------------------------------------------- /linux-fallocate.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 | /* 14 | - 15 | 16 | */ 17 | 18 | /** 19 | 20 | SYNTAX: fallocate file length 21 | 22 | fallocate() allows the caller to directly manipulate the allocated disk space 23 | for the file referred to by fd for the byte range starting at offset and 24 | continuing for len bytes. 25 | 26 | The mode argument determines the operation to be performed on the given 27 | range. Currently only one flag is supported for mode: 28 | 29 | FALLOC_FL_KEEP_SIZE 30 | 31 | This flag allocates and initializes to zero the disk space within the range 32 | specified by offset and len. After a successful call, subsequent writes into 33 | this range are guaranteed not to fail because of lack of disk 34 | space. Preallocating zeroed blocks beyond the end of the file is useful for 35 | optimizing append workloads. Preallocating blocks does not change the file size 36 | (as reported by stat(2)) even if it is less than offset+len. 37 | 38 | If FALLOC_FL_KEEP_SIZE flag is not specified in mode, the default behavior is 39 | almost same as when this flag is specified. The only difference is that on 40 | success, the file size will be changed if offset + len is greater than the file 41 | size. This default behavior closely resembles the behavior of the 42 | posix_fallocate(3) library function, and is intended as a method of optimally 43 | implementing that function. 44 | 45 | Because allocation is done in block size chunks, fallocate() may allocate a 46 | larger range than that which was specified. 47 | 48 | */ 49 | 50 | void logstats(int fd) { 51 | 52 | struct stat fd_stat ; 53 | 54 | if ( fstat( fd, &fd_stat ) < 0 ) { 55 | perror( "Could not stat file" ); 56 | exit(1); 57 | } 58 | 59 | printf( "File stats: \n" ); 60 | printf( " Length: %ld\n", fd_stat.st_size ); 61 | printf( " Block size: %ld\n", fd_stat.st_blksize ); 62 | printf( " Blocks allocated: %ld\n" , fd_stat.st_blocks ); 63 | 64 | } 65 | 66 | int main(int argc, char *argv[]) { 67 | 68 | if ( argc != 3 ) { 69 | fprintf( stderr, "%s version %s\n", argv[0], LINUX_FTOOLS_VERSION ); 70 | fprintf( stderr, "SYNTAX: fallocate file length\n" ); 71 | exit(1); 72 | } 73 | 74 | char* path = argv[1]; 75 | 76 | printf( "Going to fallocate %s\n", path ); 77 | 78 | int flags = O_RDWR; 79 | int fd = open( path, flags ); 80 | 81 | if ( fd == -1 ) { 82 | perror( "Unable to open file" ); 83 | exit(1); 84 | } 85 | 86 | logstats(fd); 87 | 88 | loff_t len = atol( argv[2] ); 89 | 90 | printf( "Increasing file to: %ld\n", len ); 91 | 92 | if ( len <= 0 ) { 93 | fprintf( stderr, "Unable to allocate size %ld\n", len ); 94 | exit( 1 ); 95 | } 96 | 97 | loff_t offset = 0; 98 | 99 | //TODO: make this a command line option. 100 | int mode = FALLOC_FL_KEEP_SIZE; 101 | 102 | long result = syscall( SYS_fallocate, fd, mode, offset, len ); 103 | 104 | if ( result != 0 ) { 105 | 106 | //TODO: rework this error handling 107 | if ( result != -1 ) { 108 | errno=result; 109 | perror( "Unable to fallocate" ); 110 | exit( 1 ); 111 | } else { 112 | char buff[100]; 113 | sprintf( buff, "Unable to fallocate: %ld" , result ); 114 | perror( buff ); 115 | exit( 1 ); 116 | } 117 | 118 | return 1; 119 | } 120 | 121 | logstats(fd); 122 | 123 | close( fd ); 124 | return 0; 125 | 126 | } 127 | -------------------------------------------------------------------------------- /linux-fincore.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | char STR_FORMAT[] = "%-80s %18s %18s %18s %18s %18s %18s\n"; 18 | char DATA_FORMAT[] = "%-80s %'18ld %'18d %'18ld %'18ld %'18ld %18.2f\n"; 19 | 20 | long DEFAULT_NR_REGIONS = 160; // default number of regions 21 | 22 | // program options 23 | int arg_pages = 0; // display/print pages we've found. Used for external programs. 24 | int arg_summarize = 1; // print a summary at the end. 25 | int arg_only_cached = 0; // only show cached files 26 | int arg_graph = 0; // graph the page distribution of files. 27 | int arg_verbose = 0; // level of verbosity. 28 | int arg_vertical = 0; // print variables vertical 29 | 30 | long arg_min_size = -1; // required minimum size for files or we ignore them. 31 | long arg_min_cached_size = -1; // required minimum percent cached for files or we ignore them. 32 | long arg_min_cached_perc = -1; // required minimum percent of a file in cache. 33 | 34 | long nr_regions = 0; 35 | 36 | // Array of longs of the NR of blocks per region (used for graphing) 37 | static long *regions = NULL; 38 | 39 | // Array of doubles of the percentages of blocks per region. 40 | static double *region_percs = NULL; 41 | 42 | //TODO: 43 | // 44 | // - ability to adjust print graph width and height width from the command line. 45 | // 46 | // - convert ALL the variables used to store stats to longs. 47 | // 48 | // - option to print symbols in human readable form (1GB, 2.1GB , 300KB 49 | // 50 | // - only call setlocale() if it's not currently set. 51 | // 52 | // - print new headers every N rows. 53 | 54 | struct fincore_result 55 | { 56 | long cached_size; 57 | }; 58 | 59 | int _argtobool( char* str ) { 60 | 61 | int result = 0; 62 | 63 | if ( optarg != NULL ) { 64 | 65 | if ( strcmp( "true", optarg ) == 0 ) { 66 | result = 1; 67 | } 68 | 69 | if ( strcmp( "1", optarg ) == 0 ) { 70 | result = 1; 71 | } 72 | 73 | } else { 74 | result = 1; 75 | } 76 | 77 | return result; 78 | } 79 | 80 | int _argtoint( char* str, int _default ) { 81 | 82 | int result = _default; 83 | 84 | if ( optarg != NULL ) { 85 | result = atoi( str ); 86 | } 87 | 88 | return result; 89 | } 90 | 91 | char *_itoa(int n) { 92 | static char retbuf[100]; 93 | sprintf(retbuf, "%d", n); 94 | return retbuf; 95 | } 96 | 97 | char *_ltoa( long value ) { 98 | 99 | static char buff[100]; 100 | 101 | sprintf( buff, "%ld", value ); 102 | 103 | return buff; 104 | 105 | } 106 | 107 | char *_dtoa( double value ) { 108 | 109 | static char buff[100]; 110 | 111 | sprintf( buff, "%f", value ); 112 | 113 | return buff; 114 | 115 | } 116 | 117 | double perc( long val, int range ) { 118 | 119 | if ( range == 0 ) 120 | return 0; 121 | 122 | double result = ( val / (double)range ) * 100; 123 | 124 | return result; 125 | 126 | } 127 | 128 | void graph_header( long nr_regions ) { 129 | 130 | int j; 131 | 132 | printf( " ------" ); 133 | for( j = 0; j < nr_regions; ++j ) { 134 | printf( "-" ); 135 | } 136 | 137 | printf( "\n" ); 138 | 139 | } 140 | 141 | void graph(double regions[], long nr_regions ) { 142 | 143 | printf( "\n" ); 144 | 145 | graph_header(nr_regions); 146 | 147 | int *ptr; 148 | 149 | int i, j; 150 | 151 | int perc_width = 10; 152 | 153 | for( i = 0 ; i < perc_width; ++ i ) { 154 | 155 | double perc_index = 100 - ((i+1) * perc_width ); 156 | 157 | // show where we are. 158 | printf( "%4.0f %% ", perc_index + perc_width ); 159 | 160 | for( j = 0; j < nr_regions; ++j ) { 161 | 162 | double val = regions[j]; 163 | 164 | if ( val < 1 ) { 165 | printf( " " ); 166 | } else if ( val >= perc_index ) { 167 | printf( "*" ); 168 | } else { 169 | printf( " " ); 170 | } 171 | 172 | } 173 | 174 | printf( " | \n" ); 175 | 176 | } 177 | 178 | graph_header(nr_regions); 179 | 180 | printf( "\n" ); 181 | 182 | } 183 | 184 | void fincore(char* path, 185 | struct fincore_result *result ) { 186 | 187 | int fd; 188 | struct stat file_stat; 189 | void *file_mmap; 190 | 191 | // vector result from mincore 192 | unsigned char *mincore_vec; 193 | 194 | // default page size of this OS 195 | size_t page_size = getpagesize(); 196 | size_t page_index; 197 | 198 | int i; 199 | 200 | // the number of pages that we have detected that are cached 201 | size_t cached = 0; 202 | 203 | // the number of pages that we have printed 204 | size_t printed = 0; 205 | 206 | //the total number of pages we're working with 207 | size_t total_pages; 208 | 209 | //the oldest page in the cache or -1 if it isn't in the cache. 210 | off_t min_cached_page = -1 ; 211 | 212 | // by default the cached size is zero so initialize this member. 213 | result->cached_size = 0; 214 | 215 | //FIXME: make this sizeof(regions) 216 | if ( regions == NULL ) 217 | regions = calloc( nr_regions , sizeof(long) ) ; 218 | 219 | if ( region_percs == NULL ) 220 | region_percs = calloc( nr_regions , sizeof(double) ) ; 221 | 222 | if ( regions == NULL || region_percs == NULL ) { 223 | perror( "Could not allocate memory" ); 224 | goto cleanup; 225 | } 226 | 227 | for( i = 0; i < nr_regions; ++i ) { 228 | regions[i] = (long)0; 229 | region_percs[i] = (double)0; 230 | } 231 | 232 | fd = open( path, O_RDONLY ); 233 | 234 | if ( fd == -1 ) { 235 | 236 | //FIXME: migrate this code to a decated function for dealing with errors. 237 | char buff[1024]; 238 | sprintf( buff, "Could not open file: %s", path ); 239 | perror( buff ); 240 | 241 | return; 242 | } 243 | 244 | if ( fstat( fd, &file_stat ) < 0 ) { 245 | 246 | char buff[1024]; 247 | sprintf( buff, "Could not stat file: %s", path ); 248 | perror( buff ); 249 | 250 | goto cleanup; 251 | 252 | } 253 | 254 | if ( file_stat.st_size == 0 ) { 255 | // this file could not have been cached as it's empty so anything we 256 | //would do is pointless. 257 | goto cleanup; 258 | } 259 | 260 | file_mmap = mmap((void *)0, file_stat.st_size, PROT_NONE, MAP_SHARED, fd, 0 ); 261 | 262 | if ( file_mmap == MAP_FAILED ) { 263 | 264 | char buff[1024]; 265 | sprintf( buff, "Could not mmap file: %s", path ); 266 | perror( buff ); 267 | goto cleanup; 268 | } 269 | 270 | size_t calloc_size = (file_stat.st_size+page_size-1)/page_size; 271 | 272 | mincore_vec = calloc(1, calloc_size); 273 | 274 | if ( mincore_vec == NULL ) { 275 | perror( "Could not calloc" ); 276 | exit( 1 ); 277 | } 278 | 279 | if ( mincore(file_mmap, file_stat.st_size, mincore_vec) != 0 ) { 280 | char buff[1024]; 281 | sprintf( buff, "%s: Could not call mincore on file", path ); 282 | perror( buff ); 283 | exit( 1 ); 284 | } 285 | 286 | total_pages = (int)ceil( (double)file_stat.st_size / (double)page_size ); 287 | 288 | int region_ptr = (int)((total_pages - 1) / nr_regions); 289 | 290 | for (page_index = 0; page_index <= file_stat.st_size/page_size; page_index++) { 291 | 292 | if (mincore_vec[page_index]&1) { 293 | 294 | ++cached; 295 | 296 | if ( min_cached_page == -1 || page_index < min_cached_page ) { 297 | min_cached_page = page_index; 298 | } 299 | 300 | if ( arg_pages ) { 301 | printf("%lu ", (unsigned long)page_index); 302 | ++printed; 303 | } 304 | 305 | if ( region_ptr > 0 ) { 306 | int region = (int)(page_index / region_ptr ); 307 | ++regions[region]; 308 | } 309 | 310 | } 311 | 312 | } 313 | 314 | if ( printed ) printf("\n"); 315 | 316 | double cached_perc = 100 * (cached / (double)total_pages); 317 | 318 | size_t cached_size = (long)cached * (long)page_size; 319 | 320 | if ( arg_min_cached_size > 0 && cached_size <= arg_min_cached_size ) { 321 | goto cleanup; 322 | } 323 | 324 | if ( arg_min_cached_perc > 0 && cached_perc <= arg_min_cached_perc ) { 325 | goto cleanup; 326 | } 327 | 328 | if ( arg_min_size > 0 && file_stat.st_size <= arg_min_size ) { 329 | goto cleanup; 330 | } 331 | 332 | if ( arg_only_cached == 0 || cached > 0 ) { 333 | 334 | if ( arg_graph ) { 335 | _show_headers(); 336 | } 337 | 338 | if ( arg_vertical ) { 339 | 340 | printf( "%s\n", path ); 341 | printf( "size: %'ld\n", file_stat.st_size ); 342 | printf( "total_pages: %'ld\n", total_pages ); 343 | printf( "min_cached_page: %'ld\n", min_cached_page ); 344 | printf( "cached: %'ld\n", cached ); 345 | printf( "cached_size: %'ld\n", cached_size ); 346 | printf( "cached_perc: %.2f\n", cached_perc ); 347 | 348 | } else { 349 | 350 | printf( DATA_FORMAT, 351 | path, 352 | file_stat.st_size , 353 | total_pages , 354 | min_cached_page, 355 | cached , 356 | cached_size , 357 | cached_perc ); 358 | 359 | } 360 | 361 | for( i = 0 ; i < nr_regions; ++i ) { 362 | region_percs[i] = perc(regions[i], region_ptr ); 363 | } 364 | 365 | if ( arg_graph && total_pages > nr_regions ) { 366 | graph( region_percs, nr_regions ); 367 | } 368 | 369 | } 370 | 371 | // update structure members when done. 372 | result->cached_size = cached_size; 373 | 374 | cleanup: 375 | 376 | if ( mincore_vec != NULL ) { 377 | free(mincore_vec); 378 | mincore_vec = NULL; 379 | } 380 | 381 | if ( file_mmap != MAP_FAILED ) 382 | munmap(file_mmap, file_stat.st_size); 383 | 384 | if ( fd != -1 ) 385 | close(fd); 386 | 387 | return; 388 | 389 | } 390 | 391 | // print help / usage 392 | void help() { 393 | 394 | fprintf( stderr, "%s version %s\n", "fincore", LINUX_FTOOLS_VERSION ); 395 | fprintf( stderr, "fincore [options] files...\n" ); 396 | fprintf( stderr, "\n" ); 397 | 398 | fprintf( stderr, " -s --summarize When comparing multiple files, print a summary report\n" ); 399 | fprintf( stderr, " -p --pages Print pages that are cached\n" ); 400 | fprintf( stderr, " -o --only-cached Only print stats for files that are actually in cache.\n" ); 401 | fprintf( stderr, " -g --graph Print a visual graph of each file's cached page distribution.\n" ); 402 | fprintf( stderr, " -S --min-size Require that each files size be larger than N bytes.\n" ); 403 | fprintf( stderr, " -C --min-cached-size Require that each files cached size be larger than N bytes.\n" ); 404 | fprintf( stderr, " -P --min-perc-cached Require percentage of a file that must be cached.\n" ); 405 | fprintf( stderr, " -h --help Print this message.\n" ); 406 | fprintf( stderr, " -L --vertical Print the output of this script vertically.\n" ); 407 | fprintf( stderr, "\n" ); 408 | 409 | } 410 | 411 | void _show_headers() { 412 | 413 | printf( STR_FORMAT, "filename", "size", "total_pages", "min_cached page", "cached_pages", "cached_size", "cached_perc" ); 414 | printf( STR_FORMAT, "--------", "----", "-----------", "---------------", "------------", "-----------", "-----------" ); 415 | 416 | return; 417 | 418 | } 419 | 420 | /** 421 | * see README 422 | */ 423 | int main(int argc, char *argv[]) { 424 | 425 | int c; 426 | 427 | static struct option long_options[] = 428 | { 429 | /* These options don't set a flag. 430 | We distinguish them by their indices. */ 431 | {"summarize", optional_argument, 0, 's'}, 432 | {"pages", optional_argument, 0, 'p'}, 433 | {"only-cached", optional_argument, 0, 'c'}, 434 | {"graph", optional_argument, 0, 'g'}, 435 | {"verbose", optional_argument, 0, 'v'}, 436 | {"min-size", required_argument, 0, 'S'}, 437 | {"min-cached-size", required_argument, 0, 'C'}, 438 | {"min-cached-perc", required_argument, 0, 'P'}, 439 | {"help", no_argument, 0, 'h'}, 440 | {"vertical", no_argument, 0, 'L'}, 441 | {0, 0, 0, 0} 442 | }; 443 | 444 | while (1) { 445 | 446 | /* getopt_long stores the option index here. */ 447 | int option_index = 0; 448 | 449 | c = getopt_long (argc, argv, "s::p::c::g::v::L::S:C:P:h",long_options, &option_index); 450 | 451 | /* Detect the end of the options. */ 452 | if (c == -1) 453 | break; 454 | 455 | //bool foo = 1; 456 | 457 | switch (c) 458 | { 459 | case 0: 460 | /* If this option set a flag, do nothing else now. */ 461 | if (long_options[option_index].flag != 0) 462 | break; 463 | if (optarg) 464 | printf (" with arg %s", optarg); 465 | printf ("\n"); 466 | break; 467 | 468 | case 'p': 469 | arg_pages = _argtobool( optarg ); 470 | break; 471 | 472 | case 's': 473 | arg_summarize = _argtobool( optarg ); 474 | break; 475 | 476 | case 'c': 477 | arg_only_cached = _argtobool( optarg ); 478 | break; 479 | 480 | case 'g': 481 | arg_graph = _argtobool( optarg ); 482 | break; 483 | 484 | case 'v': 485 | arg_verbose = _argtoint( optarg, 1 ); 486 | break; 487 | 488 | case 'S': 489 | arg_min_size = _argtoint( optarg, 0 ); 490 | break; 491 | 492 | case 'C': 493 | arg_min_cached_size = _argtoint( optarg, 0 ); 494 | break; 495 | 496 | case 'P': 497 | arg_min_cached_perc = _argtoint( optarg, 0 ); 498 | break; 499 | 500 | case 'L': 501 | arg_vertical = _argtoint( optarg, 1 ); 502 | break; 503 | 504 | case 'h': 505 | help(); 506 | exit(1); 507 | 508 | case '?': 509 | /* getopt_long already printed an error message. */ 510 | break; 511 | 512 | default: 513 | 514 | fprintf( stderr, "Invalid command line item: %s\n" , argv[ optind ] ); 515 | help(); 516 | 517 | exit(1); 518 | } 519 | } // done processing arguments. 520 | 521 | if ( arg_verbose >= 1 ) { 522 | 523 | printf( "Running with arguments: \n" ); 524 | printf( " pages: %d\n", arg_pages ); 525 | printf( " summarize: %d\n", arg_summarize ); 526 | printf( " only cached: %d\n", arg_only_cached ); 527 | printf( " graph: %d\n", arg_graph ); 528 | printf( " min size: %ld\n", arg_min_size ); 529 | printf( " min cached size: %ld\n", arg_min_cached_size ); 530 | printf( " min cached perc: %ld\n", arg_min_cached_perc ); 531 | printf( " vertical: %ld\n", arg_vertical ); 532 | 533 | } 534 | 535 | setlocale( LC_NUMERIC, "en_US" ); 536 | 537 | nr_regions = DEFAULT_NR_REGIONS; 538 | 539 | struct winsize ws; 540 | 541 | if (ioctl(stdout,TIOCGWINSZ,&ws) == 0) { 542 | 543 | if ( ws.ws_col > nr_regions ) { 544 | nr_regions = ((ws.ws_col/2)*2) - 10; 545 | } 546 | 547 | //printf( "Using graph width: %d\n" , nr_regions ); 548 | 549 | } 550 | 551 | if ( optind == argc ) { 552 | help(); 553 | exit(1); 554 | } 555 | 556 | if ( ! arg_graph ) 557 | _show_headers(); 558 | 559 | long total_cached_size = 0; 560 | 561 | /* Print any remaining command line arguments (not options). */ 562 | 563 | if (optind < argc) { 564 | 565 | while (optind < argc) { 566 | 567 | char* path = argv[optind++]; 568 | 569 | struct fincore_result result; 570 | 571 | fincore( path, &result ); 572 | 573 | total_cached_size += result.cached_size; 574 | 575 | //printf ("%s ", ); 576 | //putchar ('\n'); 577 | } 578 | 579 | } 580 | 581 | if ( arg_summarize ) { 582 | 583 | printf( "---\n" ); 584 | 585 | //TODO: add more metrics including total size... 586 | printf( "total cached size: %'ld\n", total_cached_size ); 587 | 588 | } 589 | 590 | } 591 | -------------------------------------------------------------------------------- /linux-ftools.h: -------------------------------------------------------------------------------- 1 | // TODO: READ the @VERSION from configure.ac 2 | #define LINUX_FTOOLS_VERSION "1.3.0" 3 | -------------------------------------------------------------------------------- /missing: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # Common stub for a few missing GNU programs while installing. 3 | 4 | scriptversion=2006-05-10.23 5 | 6 | # Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006 7 | # 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, write to the Free Software 22 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 23 | # 02110-1301, USA. 24 | 25 | # As a special exception to the GNU General Public License, if you 26 | # distribute this file as part of a program that contains a 27 | # configuration script generated by Autoconf, you may include it under 28 | # the same distribution terms that you use for the rest of that program. 29 | 30 | if test $# -eq 0; then 31 | echo 1>&2 "Try \`$0 --help' for more information" 32 | exit 1 33 | fi 34 | 35 | run=: 36 | sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' 37 | sed_minuso='s/.* -o \([^ ]*\).*/\1/p' 38 | 39 | # In the cases where this matters, `missing' is being run in the 40 | # srcdir already. 41 | if test -f configure.ac; then 42 | configure_ac=configure.ac 43 | else 44 | configure_ac=configure.in 45 | fi 46 | 47 | msg="missing on your system" 48 | 49 | case $1 in 50 | --run) 51 | # Try to run requested program, and just exit if it succeeds. 52 | run= 53 | shift 54 | "$@" && exit 0 55 | # Exit code 63 means version mismatch. This often happens 56 | # when the user try to use an ancient version of a tool on 57 | # a file that requires a minimum version. In this case we 58 | # we should proceed has if the program had been absent, or 59 | # if --run hadn't been passed. 60 | if test $? = 63; then 61 | run=: 62 | msg="probably too old" 63 | fi 64 | ;; 65 | 66 | -h|--h|--he|--hel|--help) 67 | echo "\ 68 | $0 [OPTION]... PROGRAM [ARGUMENT]... 69 | 70 | Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an 71 | error status if there is no known handling for PROGRAM. 72 | 73 | Options: 74 | -h, --help display this help and exit 75 | -v, --version output version information and exit 76 | --run try to run the given command, and emulate it if it fails 77 | 78 | Supported PROGRAM values: 79 | aclocal touch file \`aclocal.m4' 80 | autoconf touch file \`configure' 81 | autoheader touch file \`config.h.in' 82 | autom4te touch the output file, or create a stub one 83 | automake touch all \`Makefile.in' files 84 | bison create \`y.tab.[ch]', if possible, from existing .[ch] 85 | flex create \`lex.yy.c', if possible, from existing .c 86 | help2man touch the output file 87 | lex create \`lex.yy.c', if possible, from existing .c 88 | makeinfo touch the output file 89 | tar try tar, gnutar, gtar, then tar without non-portable flags 90 | yacc create \`y.tab.[ch]', if possible, from existing .[ch] 91 | 92 | Send bug reports to ." 93 | exit $? 94 | ;; 95 | 96 | -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 97 | echo "missing $scriptversion (GNU Automake)" 98 | exit $? 99 | ;; 100 | 101 | -*) 102 | echo 1>&2 "$0: Unknown \`$1' option" 103 | echo 1>&2 "Try \`$0 --help' for more information" 104 | exit 1 105 | ;; 106 | 107 | esac 108 | 109 | # Now exit if we have it, but it failed. Also exit now if we 110 | # don't have it and --version was passed (most likely to detect 111 | # the program). 112 | case $1 in 113 | lex|yacc) 114 | # Not GNU programs, they don't have --version. 115 | ;; 116 | 117 | tar) 118 | if test -n "$run"; then 119 | echo 1>&2 "ERROR: \`tar' requires --run" 120 | exit 1 121 | elif test "x$2" = "x--version" || test "x$2" = "x--help"; then 122 | exit 1 123 | fi 124 | ;; 125 | 126 | *) 127 | if test -z "$run" && ($1 --version) > /dev/null 2>&1; then 128 | # We have it, but it failed. 129 | exit 1 130 | elif test "x$2" = "x--version" || test "x$2" = "x--help"; then 131 | # Could not run --version or --help. This is probably someone 132 | # running `$TOOL --version' or `$TOOL --help' to check whether 133 | # $TOOL exists and not knowing $TOOL uses missing. 134 | exit 1 135 | fi 136 | ;; 137 | esac 138 | 139 | # If it does not exist, or fails to run (possibly an outdated version), 140 | # try to emulate it. 141 | case $1 in 142 | aclocal*) 143 | echo 1>&2 "\ 144 | WARNING: \`$1' is $msg. You should only need it if 145 | you modified \`acinclude.m4' or \`${configure_ac}'. You might want 146 | to install the \`Automake' and \`Perl' packages. Grab them from 147 | any GNU archive site." 148 | touch aclocal.m4 149 | ;; 150 | 151 | autoconf) 152 | echo 1>&2 "\ 153 | WARNING: \`$1' is $msg. You should only need it if 154 | you modified \`${configure_ac}'. You might want to install the 155 | \`Autoconf' and \`GNU m4' packages. Grab them from any GNU 156 | archive site." 157 | touch configure 158 | ;; 159 | 160 | autoheader) 161 | echo 1>&2 "\ 162 | WARNING: \`$1' is $msg. You should only need it if 163 | you modified \`acconfig.h' or \`${configure_ac}'. You might want 164 | to install the \`Autoconf' and \`GNU m4' packages. Grab them 165 | from any GNU archive site." 166 | files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` 167 | test -z "$files" && files="config.h" 168 | touch_files= 169 | for f in $files; do 170 | case $f in 171 | *:*) touch_files="$touch_files "`echo "$f" | 172 | sed -e 's/^[^:]*://' -e 's/:.*//'`;; 173 | *) touch_files="$touch_files $f.in";; 174 | esac 175 | done 176 | touch $touch_files 177 | ;; 178 | 179 | automake*) 180 | echo 1>&2 "\ 181 | WARNING: \`$1' is $msg. You should only need it if 182 | you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. 183 | You might want to install the \`Automake' and \`Perl' packages. 184 | Grab them from any GNU archive site." 185 | find . -type f -name Makefile.am -print | 186 | sed 's/\.am$/.in/' | 187 | while read f; do touch "$f"; done 188 | ;; 189 | 190 | autom4te) 191 | echo 1>&2 "\ 192 | WARNING: \`$1' is needed, but is $msg. 193 | You might have modified some files without having the 194 | proper tools for further handling them. 195 | You can get \`$1' as part of \`Autoconf' from any GNU 196 | archive site." 197 | 198 | file=`echo "$*" | sed -n "$sed_output"` 199 | test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` 200 | if test -f "$file"; then 201 | touch $file 202 | else 203 | test -z "$file" || exec >$file 204 | echo "#! /bin/sh" 205 | echo "# Created by GNU Automake missing as a replacement of" 206 | echo "# $ $@" 207 | echo "exit 0" 208 | chmod +x $file 209 | exit 1 210 | fi 211 | ;; 212 | 213 | bison|yacc) 214 | echo 1>&2 "\ 215 | WARNING: \`$1' $msg. You should only need it if 216 | you modified a \`.y' file. You may need the \`Bison' package 217 | in order for those modifications to take effect. You can get 218 | \`Bison' from any GNU archive site." 219 | rm -f y.tab.c y.tab.h 220 | if test $# -ne 1; then 221 | eval LASTARG="\${$#}" 222 | case $LASTARG in 223 | *.y) 224 | SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` 225 | if test -f "$SRCFILE"; then 226 | cp "$SRCFILE" y.tab.c 227 | fi 228 | SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` 229 | if test -f "$SRCFILE"; then 230 | cp "$SRCFILE" y.tab.h 231 | fi 232 | ;; 233 | esac 234 | fi 235 | if test ! -f y.tab.h; then 236 | echo >y.tab.h 237 | fi 238 | if test ! -f y.tab.c; then 239 | echo 'main() { return 0; }' >y.tab.c 240 | fi 241 | ;; 242 | 243 | lex|flex) 244 | echo 1>&2 "\ 245 | WARNING: \`$1' is $msg. You should only need it if 246 | you modified a \`.l' file. You may need the \`Flex' package 247 | in order for those modifications to take effect. You can get 248 | \`Flex' from any GNU archive site." 249 | rm -f lex.yy.c 250 | if test $# -ne 1; then 251 | eval LASTARG="\${$#}" 252 | case $LASTARG in 253 | *.l) 254 | SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` 255 | if test -f "$SRCFILE"; then 256 | cp "$SRCFILE" lex.yy.c 257 | fi 258 | ;; 259 | esac 260 | fi 261 | if test ! -f lex.yy.c; then 262 | echo 'main() { return 0; }' >lex.yy.c 263 | fi 264 | ;; 265 | 266 | help2man) 267 | echo 1>&2 "\ 268 | WARNING: \`$1' is $msg. You should only need it if 269 | you modified a dependency of a manual page. You may need the 270 | \`Help2man' package in order for those modifications to take 271 | effect. You can get \`Help2man' from any GNU archive site." 272 | 273 | file=`echo "$*" | sed -n "$sed_output"` 274 | test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` 275 | if test -f "$file"; then 276 | touch $file 277 | else 278 | test -z "$file" || exec >$file 279 | echo ".ab help2man is required to generate this page" 280 | exit 1 281 | fi 282 | ;; 283 | 284 | makeinfo) 285 | echo 1>&2 "\ 286 | WARNING: \`$1' is $msg. You should only need it if 287 | you modified a \`.texi' or \`.texinfo' file, or any other file 288 | indirectly affecting the aspect of the manual. The spurious 289 | call might also be the consequence of using a buggy \`make' (AIX, 290 | DU, IRIX). You might want to install the \`Texinfo' package or 291 | the \`GNU make' package. Grab either from any GNU archive site." 292 | # The file to touch is that specified with -o ... 293 | file=`echo "$*" | sed -n "$sed_output"` 294 | test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` 295 | if test -z "$file"; then 296 | # ... or it is the one specified with @setfilename ... 297 | infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` 298 | file=`sed -n ' 299 | /^@setfilename/{ 300 | s/.* \([^ ]*\) *$/\1/ 301 | p 302 | q 303 | }' $infile` 304 | # ... or it is derived from the source name (dir/f.texi becomes f.info) 305 | test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info 306 | fi 307 | # If the file does not exist, the user really needs makeinfo; 308 | # let's fail without touching anything. 309 | test -f $file || exit 1 310 | touch $file 311 | ;; 312 | 313 | tar) 314 | shift 315 | 316 | # We have already tried tar in the generic part. 317 | # Look for gnutar/gtar before invocation to avoid ugly error 318 | # messages. 319 | if (gnutar --version > /dev/null 2>&1); then 320 | gnutar "$@" && exit 0 321 | fi 322 | if (gtar --version > /dev/null 2>&1); then 323 | gtar "$@" && exit 0 324 | fi 325 | firstarg="$1" 326 | if shift; then 327 | case $firstarg in 328 | *o*) 329 | firstarg=`echo "$firstarg" | sed s/o//` 330 | tar "$firstarg" "$@" && exit 0 331 | ;; 332 | esac 333 | case $firstarg in 334 | *h*) 335 | firstarg=`echo "$firstarg" | sed s/h//` 336 | tar "$firstarg" "$@" && exit 0 337 | ;; 338 | esac 339 | fi 340 | 341 | echo 1>&2 "\ 342 | WARNING: I can't seem to be able to run \`tar' with the given arguments. 343 | You may want to install GNU tar or Free paxutils, or check the 344 | command line arguments." 345 | exit 1 346 | ;; 347 | 348 | *) 349 | echo 1>&2 "\ 350 | WARNING: \`$1' is needed, and is $msg. 351 | You might have modified some files without having the 352 | proper tools for further handling them. Check the \`README' file, 353 | it often tells you about the needed prerequisites for installing 354 | this package. You may also peek at any GNU archive site, in case 355 | some other package would contain this missing \`$1' program." 356 | exit 1 357 | ;; 358 | esac 359 | 360 | exit 0 361 | 362 | # Local variables: 363 | # eval: (add-hook 'write-file-hooks 'time-stamp) 364 | # time-stamp-start: "scriptversion=" 365 | # time-stamp-format: "%:y-%02m-%02d.%02H" 366 | # time-stamp-end: "$" 367 | # End: 368 | -------------------------------------------------------------------------------- /showrlimit.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | void padd( int val ) { 9 | 10 | char p[20]; 11 | 12 | int len = sprintf( p, "%i", val ); 13 | 14 | printf( "%i", val ); 15 | 16 | if ( val > 1000000000 ) 17 | printf( " " ); 18 | else if ( val > 100000000 ) 19 | printf( " " ); 20 | else if ( val > 10000000 ) 21 | printf( " " ); 22 | else if ( val > 1000000 ) 23 | printf( " " ); 24 | else if ( val > 100000 ) 25 | printf( " " ); 26 | else if ( val > 10000 ) 27 | printf( " " ); 28 | else if ( val > 1000 ) 29 | printf( " " ); 30 | else if ( val > 100 ) 31 | printf( " " ); 32 | else if ( val > 10 ) 33 | printf( " " ); 34 | else if ( val >= 0 ) 35 | printf( " " ); 36 | else if ( val == -1 ) 37 | printf( " " ); 38 | 39 | } 40 | 41 | void dump( char *header, int resource ) { 42 | 43 | struct rlimit limit; 44 | 45 | getrlimit( resource, &limit ); 46 | 47 | printf( header ); 48 | padd( limit.rlim_cur ); 49 | padd( limit.rlim_max ); 50 | printf( "\n" ); 51 | 52 | } 53 | 54 | /* 55 | * print rlimit variables 56 | * 57 | * http://linux.die.net/man/2/getrlimit 58 | */ 59 | int main() { 60 | 61 | dump( "RLIMIT_AS: ", RLIMIT_AS ); 62 | dump( "RLIMIT_CORE: ", RLIMIT_CORE ); 63 | dump( "RLIMIT_CPU: ", RLIMIT_CPU ); 64 | dump( "RLIMIT_DATA: ", RLIMIT_DATA ); 65 | dump( "RLIMIT_FSIZE: ", RLIMIT_FSIZE ); 66 | dump( "RLIMIT_LOCKS: ", RLIMIT_LOCKS ); 67 | dump( "RLIMIT_MEMLOCK: ", RLIMIT_MEMLOCK ); 68 | dump( "RLIMIT_MSGQUEUE: ", RLIMIT_MSGQUEUE ); 69 | dump( "RLIMIT_NICE: ", RLIMIT_NICE ); 70 | dump( "RLIMIT_NOFILE: ", RLIMIT_NOFILE ); 71 | dump( "RLIMIT_NPROC: ", RLIMIT_NPROC ); 72 | dump( "RLIMIT_RSS: ", RLIMIT_RSS ); 73 | dump( "RLIMIT_RTPRIO: ", RLIMIT_RTPRIO ); 74 | dump( "RLIMIT_SIGPENDING: ", RLIMIT_SIGPENDING ); 75 | dump( "RLIMIT_STACK: ", RLIMIT_STACK ); 76 | dump( "RLIMIT_OFILE: ", RLIMIT_OFILE ); 77 | 78 | } 79 | 80 | -------------------------------------------------------------------------------- /waste_memory.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | /* 11 | */ 12 | int main(int argc, char *argv[]) { 13 | 14 | //number of bytes we should attempt to allocate. 15 | size_t len = 1 * 1024 * 1024 * 1024; 16 | 17 | if ( argc == 2 ) 18 | len = atol( argv[1] ); 19 | 20 | printf( "Allocating %ld bytes ...", len ); 21 | 22 | void *buff = malloc( len ); 23 | 24 | if ( buff == NULL ) { 25 | printf( "\nFailed to malloc.\n" ); 26 | exit( EXIT_FAILURE ); 27 | } 28 | 29 | memset( buff, 1, len ); 30 | 31 | printf( "done\n" ); 32 | 33 | fflush( stdout ); 34 | 35 | printf( "Sleeping to hold memory...\n" ); 36 | sleep( 2147483648 ); 37 | 38 | } 39 | --------------------------------------------------------------------------------