mhddfs-0.1.39+nmu1ubuntu1/0000775000000000000000000000000012145007556012146 5ustar mhddfs-0.1.39+nmu1ubuntu1/README0000664000000000000000000001032712145007405013022 0ustar The driver combines a several mount points into the single one. Using ~~~~~ mhddfs /path/to/dir1,/path/to/dir2[,/path/to/dir3] /path/to/mount fusermount -u /path/to/mount with an "-o option" you can specify some additional options: -o logfile=/path/to/file.log specify a file that will contain debug information. -o loglevel=x 0 - debug messages 1 - info messages 2 - standart (default) messages -o mlimit=size[m|k|g] a free space size threshold If a drive has the free space less than the threshold specifed then another drive will be choosen while creating a new file. If all the drives have free space less than the threshold specified then a drive containing most free space will be choosen. Default value is 25%, minimum value is 100M. This option accepts suffixes: [mM] - megabytes [gG] - gigabytes [kK] - kilobytes [%] - percent If mlimit is equal 100% or contain a number which is more than the largest of mount directories, mhddfs will try to allocate files regularly. For an information about the additional options see output of 'mhddfs -h'. It's necessary to get installed fuse-utils, libfuse for driver working. Working ~~~~~~~ Consider we have two hard drives with the content below: /hdd1 /hdd2 | | +-- /dir1 +-- /dir1 | | | | | +- file2 | +- file4 | | +- file2 +-- file1 | | +-- file5 +-- /dir2 | | +-- /dir3 +- file3 | +- file6 mounting this tree with the command: mhddfs /hdd1,/hdd2 /hdd_common into the specified file system point we will see a combined tree. In the united tree we can see all the directories and files. Note file2 of 2nd hdd is not visible (because 1st hdd has the file2 already). /hdd_common | +-- /dir1 | | | +-- file2 -> /hdd1/dir1/file2 | +-- file4 | |-- /dir2 | | | + file3 | +-- /dir3 | | | +-- file6 | +-- file1 +-- file5 While writing files they are written to a 1st hdd until the hdd has the free space (see mlimit option), then they are written on a 2nd hdd, then to 3rd etc. df will show a total statistics of all filesystems like there is a big one hdd. If an overflow arises while writing to the hdd1 then a file content already written will be transferred to a hdd containing enough of free space for a file. The transferring is processed on-the-fly, fully transparent for the application that is writing. So this behaviour simulates a big file system. WARNING: The filesystems are combined must provide a possibility to get their parameters correctly (e.g. size of free space). Otherwise the writing failure can occur (but data consistency will be ok anyway). For example it is a bad idea to combine a several sshfs systems together. File system's functions ~~~~~~~~~~~~~~~~~~~~~~~ Most of the functions are supported. Functions are supported: - get/set attributes of file system objects; - get/set file system information (total size, size of free space is calculated as summary size of file systems); - read/remove/create directories; - read/remove/create/write files; - symbolic links; - device files, sockets and fifo; - file locks; - hardlinks (only on a single device; no moving support for hardlinked files) - extended file attributes (xattr); Install ~~~~~~~ It's neccessary for install to have: 1. FUSE header files 2. GCC 3. libc6 header files 4. uthash header files 5. libattr1 header files (optional) Run 'make' in the source directory produces mhddfs binary. Put the binary into /usr/bin or /usr/local/bin and now you can use it. Please read FUSE documentation for a further conception. GET IT ~~~~~~ Last version of the mhddfs drivers you can get at http://mhddfs.uvw.ru/downloads. SVN version is located at: http://svn.uvw.ru/mhddfs/trunk To checkout SVN files run: svn co http://svn.uvw.ru/mhddfs/trunk mhddfs BUGS ~~~~ Please use Debian-BTS as the bugtracking system. Feel free to submit a bug information to the Debian bugtracker for mhddfs project. See the additional information here: http://www.debian.org/Bugs COPYRIGHT ~~~~~~~~~ Distributed under GPLv3 and higher Copyright (C) 2008 Dmitry E. Oboukhov mhddfs-0.1.39+nmu1ubuntu1/README.ru.UTF-80000664000000000000000000001473712145007405014262 0ustar Драйвер для объединения нескольких точек монтирования в одну. Использование ~~~~~~~~~~~~~ mhddfs /path/to/dir1,/path/to/dir2[,/path/to/dir3] /path/to/mount fusermount -u /path/to/mount используя опцию -o можно задать некоторые дополнительные опции: -o logfile=/path/to/file.log - имя файла куда будет сохраняться отладочная информация о процессе работы. -o loglevel=x - уровень сообщений в log-файл 0 - debug messages 1 - info messages 2 - standart (default) messages -o mlimit=size[m|k|g] - пороговый размер свободного места. если на диске места меньше чем это значение, то для создания нового файла будет выбран другой диск. Если на всех дисках свободного места меньше чем это значение, то будет выбран диск на котором самое большое количество свободного места. Значение по умолчанию - 4G, минимальное значение - 100M. Данная опция понимает суффиксы [mM] - мегабайты [gG] - гигабайты [kK] - килобайты информацию о дополнительных опциях смотри в помощи 'mhddfs -h' для работы необходимо иметь установленные fuse-utils, libfuse Работа ~~~~~~ Допустим у нас есть два hdd со следующим содержимым. /hdd1 /hdd2 | | +-- /dir1 +-- /dir1 | | | | | +- file2 | +- file4 | | +- file2 +-- file1 | | +-- file5 +-- /dir2 | | +-- /dir3 +- file3 | +- file6 смонтировав это дерево командой mhddfs /hdd1,/hdd2 /hdd_common в определенную точку файловой системы мы будем видеть объединенное дерево. в суммарном дереве мы увидим все каталоги и файлы. Обратите внимание что file2 со второго винчестера виден не будет (так как уже есть такой файл на первом винчестере): /hdd_common | +-- /dir1 | | | +-- file2 -> /hdd1/dir1/file2 | +-- file4 | |-- /dir2 | | | + file3 | +-- /dir3 | | | +-- file6 | +-- file1 +-- file5 При записи файлов в файловую систему файлы пишутся на первый hdd до тех пор пока там есть место (см опцию mlimit), затем они пишутся на второй hdd, третий итп. df покажет суммарную статистику по всем файлсистемам как будто это один большой винчестер. если при записи файла на hdd1 получится переполнение винчестера, то уже записанное содержимое будет перенесено на винчестер на котором достаточно места для данного файла. Перенос осуществляется прозрачно для записывающего приложения, этим достигается иммитация файловой системы большого размера. ЗАМЕЧАНИЕ: объединяемые файловые системы должны обеспечивать корректное определение своих параметров (размеров доступного пространства итп). иначе функциональность записи будет нарушена (однако это не будет опасно для данных). например не стоит объединять воедино несколько sshfs систем. Функциональность файловой системы ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Поддерживается большинство функций. Поддерживаются функции: * Получение/установка атрибутов об объектах файловой системы; * Получение информации о файловой системе (общий объем, объем свободного места вычисляются как сумма объемов составляющих файловых систем); * Чтение/удаление/создание каталогов; * Чтение/удаление/создание/запись файлов; * Символьные ссылки (symlinks); * Файлы устройств, сокеты и fifo; * Блокировки файлов; * частичная поддержка жёстких ссылок: работает создание, не работает перемещение файлов на другой диск если ссылок больше одной; * Расширенные атрибуты файлов (xattr); Установка ~~~~~~~~~ Для сборки необходимо иметь 1. заголовочные файлы FUSE 2. компилятор gcc 3. заголовочные файлы libc6 введите в каталоге с исходными текстами команду make и будет собран модуль mhddfs. Поместите его в /usr/bin или /usr/local/bin и можете пользоваться. Для более подробного понимания работы читайте документацию на FUSE. Получение ~~~~~~~~~ Последнюю версию драйвера mhddfs Вы можете получить на страничке http://mhddfs.uvw.ru. SVN-версия находится по адресу: http://svn.uvw.ru/mhddfs/trunk. Для получения файлов из svn введите команду: svn co http://svn.uvw.ru/mhddfs/trunk mhddfs COPYRIGHT ~~~~~~~~~ Copyright (C) 2008, Dmitry E. Oboukhov распространяется под лицензией GPLv3 и выше. mhddfs-0.1.39+nmu1ubuntu1/mhddfs.spec0000664000000000000000000000727512145007405014273 0ustar # mhddfs - Multi HDD [FUSE] File System # Copyright (C) 2008 Dmitry E. Oboukhov # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . #------------------------------------------------------------------------------- # The all-important N-V-R, Name-Version-Release. #------------------------------------------------------------------------------- Name: mhddfs Version: %version Release: %{release} #------------------------------------------------------------------------------- # Additional header information. #------------------------------------------------------------------------------- Summary: A fuse-based file system for unifying several mount points into one. License: GPLv3 Group: File tools URL: http://mhddfs.uvw.ru Packager: MHDDFS Team Source: %{name}_%version.tar.gz Requires: fuse, fuse-libs BuildRoot: %{_tmppath}/%{name}-buildroot %description This FUSE-based file system allows mount points (or directories) to be combined, simulating a single big volume which can merge several hard drives or remote file systems. It is like unionfs, but can choose the drive with the most free space to create new files on, and can move data transparently between drives. #=============================================================================== %prep %setup -q %build make %install rm -rf $RPM_BUILD_ROOT mkdir -p $RPM_BUILD_ROOT/usr/bin cp %{name} $RPM_BUILD_ROOT/usr/bin/%{name} mkdir -p $RPM_BUILD_ROOT/usr/share/man/man1 cp %{name}.1 $RPM_BUILD_ROOT/usr/share/man/man1 %clean rm -rf $RPM_BUILD_ROOT #make clean #=============================================================================== #------------------------------------------------------------------------------- # The following sections control the uninstallation process. Since we never # uninstall this package, these sections are empty. #------------------------------------------------------------------------------- %preun exit 0 %postun exit 0 #=============================================================================== #------------------------------------------------------------------------------- # The script in this section gains control just before installation. #------------------------------------------------------------------------------- %pre exit 0 #=============================================================================== #------------------------------------------------------------------------------- # The script in this section gains control just after installation. #------------------------------------------------------------------------------- %post exit 0 #=============================================================================== #------------------------------------------------------------------------------- # This section describes the files in this package. #------------------------------------------------------------------------------- %files %defattr(-,root,root) %doc README* ChangeLog LICENSE COPYING mhddfs.1 /usr/bin/mhddfs /usr/share/man/man1/mhddfs.1.gz # emacs is your friend # local variables: # mode: rpm-spec # end: mhddfs-0.1.39+nmu1ubuntu1/mhddfs.10000664000000000000000000000511312145007405013466 0ustar .TH mhddfs "1" "February 2008" .SH NAME mhddfs \- The driver combines a several mount points into the single one. .SH SYNOPSIS mhddfs /dir1,/dir2[,/path/to/dir3] /path/to/mount [-o options] mhddfs /dir1 dir2,dir3 /mount/point [-o options] ... fusermount \-u /path/to/mount .SS fstab record example: mhddfs#/path/to/dir1,/path/to/dir2 /mnt/point fuse defaults 0 0 mhddfs#/dir1,/dir2,/dir3 /mnt fuse logfile=/var/log/mhddfs.log 0 0 .SH OPTIONS with an .B "\-o option1,option2..." you can specify some additional options: .SS logfile=/path/to/file.log specify a file that will contain debug information. .SS loglevel=x 0 \- debug messages 1 \- info messages 2 \- standard (default) messages .SS mlimit=size[m|k|g] a free space size threshold If a drive has the free space less than the threshold specifed then another drive will be choosen while creating a new file. If all the drives have free space less than the threshold specified then a drive containing most free space will be choosen. Default value is 4G, minimum value is 100M. This option accepts suffixes: .RS [mM] \- megabytes [gG] \- gigabytes [kK] \- kilobytes .RE .PP For an information about the additional options see output of: .RS .B mhddfs \-h .RE .SH DESCRIPTION .PP The file system allows to unite a several mount points (or directories) to the single one. So a one big filesystem is simulated and this makes it possible to combine a several hard drives or network file systems. This system is like .B unionfs but it can choose a drive with the most of free space, and move the data between drives transparently for the applications. .PP While writing files they are written to a 1st hdd until the hdd has the free space (see mlimit option), then they are written on a 2nd hdd, then to 3rd etc. .PP .B df will show a total statistics of all filesystems like there is a big one hdd. .PP If an overflow arises while writing to the hdd1 then a file content already written will be transferred to a hdd containing enough of free space for a file. The transferring is processed on\-the\-fly, fully transparent for the application that is writing. So this behaviour simulates a big file system. .PP .SS WARNINGS The filesystems are combined must provide a possibility to get their parameters correctly (e.g. size of free space). Otherwise the writing failure can occur (but data consistency will be ok anyway). For example it is a bad idea to combine a several .B sshfs systems together. Please read FUSE documentation for a further conception. .SH COPYRIGHT Distributed under .B GPLv3 Copyright (C) 2008 Dmitry E. Oboukhov .I mhddfs-0.1.39+nmu1ubuntu1/Makefile0000664000000000000000000001252012145007405013577 0ustar # mhddfs - Multi HDD [FUSE] File System # Copyright (C) 2008 Dmitry E. Oboukhov # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . SRC = $(wildcard src/*.c) OBJ = $(SRC:src/%.c=obj/%.o) DEPS = $(OBJ:obj/%.o=obj/%.d) TARGET = mhddfs CFLAGS = -Wall $(shell pkg-config fuse --cflags) \ -DFUSE_USE_VERSION=26 -MMD ifdef WITHOUT_XATTR CFLAGS += -DWITHOUT_XATTR endif LDFLAGS = $(shell pkg-config fuse --libs) -pthread FORTAR = src COPYING LICENSE README Makefile \ README.ru.UTF-8 ChangeLog mhddfs.1 \ debian VERSION = $(shell cat src/version.h \ |grep '^.define'|grep '[[:space:]]VERSION[[:space:]]' \ |awk '{print $$3}'|sed 's/\"//g' ) DEBVERSION = $(shell \ head -n 1 debian/changelog \ | awk '{print $$2}' \ | sed 's/^.//' | sed 's/.$$//' \ | sed 's/-[[:digit:]]\+$$//' \ ) RELEASE = 0 SRCDIR = $(shell rpm --eval '%_sourcedir') ifeq ($(DEBVERSION), $(VERSION)) all: $(TARGET) else all: update_version $(TARGET) endif update_version: @echo Updating upstream version from $(VERSION) to $(DEBVERSION)... @sleep 5 perl -pi -e 's/^(#define\s+VERSION\s+).*/$$1 "$(DEBVERSION)"/' \ src/version.h help: @echo usage: make - to build program @echo make WITHOUT_XATTR=1 - to build program without xattr functional tarball: mhddfs_$(VERSION).tar.gz @echo '>>>> mhddfs_$(VERSION).tar.gz created' mhddfs_$(VERSION).tar.gz: $(FORTAR) $(wildcard src/*) mkdir mhddfs-$(VERSION) cp -r $(FORTAR) mhddfs-$(VERSION) tar --exclude=.svn -czvf $@ mhddfs-$(VERSION) rm -fr mhddfs-$(VERSION) rpm: tarball mkdir -p $(SRCDIR) mv -f mhddfs_$(VERSION).tar.gz $(SRCDIR) rpmbuild -ba mhddfs.spec --define 'version $(VERSION)' --define 'release $(RELEASE)' cp $(shell rpm --eval '%_srcrpmdir')/mhddfs-$(VERSION)-$(RELEASE)* \ $(shell rpm --eval '%_rpmdir')/*/mhddfs-*$(VERSION)-$(RELEASE)* . $(TARGET): obj/obj-stamp $(OBJ) gcc $(CFLAGS) $(OBJ) -o $@ $(LDFLAGS) obj/obj-stamp: mkdir -p obj touch $@ obj/%.o: src/%.c gcc $(CFLAGS) -c $< -o $@ clean: rm -fr obj $(TARGET) pwrite_test statvfs rename fusermount -u rename-test || true rm -fr rename-test/mnt rename: tests/rename.c gcc -o $@ $< release_svn_thread: @echo current version $(VERSION) if ! svn ls http://svn.uvw.ru/mhddfs/tags| \ grep -q release_$(VERSION); then \ svn copy -m release-$(VERSION) \ http://svn.uvw.ru/mhddfs/trunk \ http://svn.uvw.ru/mhddfs/tags/release_$(VERSION); \ fi open_project: screen -t vim vim Makefile src/*.[ch] README* ChangeLog mhddfs.1 pwrite_test: src/test/pwrite.c gcc -o $@ $< statvfs: src/test/statvfs.c gcc -o $@ $< images-mount: test1.img test2.img mount|grep -q `pwd`/test1 || sudo mount -o loop test1.img test1 mount|grep -q `pwd`/test2 || sudo mount -o loop test2.img test2 sudo chown -R `whoami` test1 test2 test-mount: rm -f logfile.log mount|grep -q `pwd`/mnt && make test-umount || true ./$(TARGET) test1 test2 mnt -o \ logfile=logfile.log,mlimit=50m,nonempty,loglevel=0 df -h test1 test2 ls mnt test-umount: -fusermount -u mnt test1.img: dd if=/dev/zero of=$@ bs=1M count=100 echo y|/sbin/mkfs.ext3 $@ test2.img: dd if=/dev/zero of=$@ bs=1M count=200 echo y|/sbin/mkfs.ext3 $@ test: file_name=`mktemp -p mnt file_XXXXXXXXXX`; \ echo $$file_name; \ dd if=/dev/urandom of=$$file_name bs=1M count=1 2> /dev/null btest: file_name=`mktemp -p mnt file_XXXXXXXXXX`; \ echo $$file_name; \ dd if=/dev/urandom bs=1M count=65 2> /dev/null \ |tee $$file_name \ |md5sum; \ md5sum $$file_name tests: while make test; do echo ok; echo; done ptest: gcc -o $@ tests/plocks.c -l pthread -./$@ rm -f $@ symlinks_test: $(TARGET) bash tests/utimes.sh test-images: test1.img test2.img rename-test: $(TARGET) fusermount -u $@/mnt || true rm -f logfile.log rm -fr $@ mkdir $@ $@/1 $@/2 $@/mnt ./$(TARGET) $@/1 $@/2 $@/mnt -o logfile=logfile.log,loglevel=0 touch $@/mnt/test-file mv $@/mnt/test-file $@/mnt/test-file.1 mkdir $@/mnt/test-dir mv $@/mnt/test-dir $@/mnt/test-dir.1 mkdir $@/2/test-dir.2 touch $@/2/test-dir.2/123 mkdir $@/mnt/test-dir.3 mv $@/mnt/test-dir.2/123 $@/mnt/test-dir.3 fusermount -u $@/mnt rm -fr $@ @echo '******************** PASSED ***********************' dirtree-test: $(TARGET) fusermount -u $@/mnt || true rm -f logfile.log rm -fr $@ mkdir $@ $@/1 $@/2 $@/mnt ./$(TARGET) $@/1 $@/2 $@/mnt -o logfile=logfile.log,loglevel=0 bash -c 'touch $@/1/{1,2,3,4} $@/2/{3,4,5,6}' test `find $@/mnt -type f | sort -u |wc -l` -eq 6 test -e $@/mnt/1 test -e $@/mnt/2 test -e $@/mnt/3 test -e $@/mnt/4 test -e $@/mnt/5 test -e $@/mnt/6 fusermount -u $@/mnt rm -fr $@ @echo '******************** PASSED ***********************' .PHONY: all clean open_project tarball \ release_svn_thread test-mount test-umount \ images-mount test tests rename-test \ help update_version include $(wildcard obj/*.d) mhddfs-0.1.39+nmu1ubuntu1/LICENSE0000664000000000000000000010451312145007405013150 0ustar GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . mhddfs-0.1.39+nmu1ubuntu1/src/0000775000000000000000000000000012145007556012735 5ustar mhddfs-0.1.39+nmu1ubuntu1/src/main.c0000664000000000000000000005300212145007405014016 0ustar /* mhddfs - Multi HDD [FUSE] File System Copyright (C) 2008 Dmitry E. Oboukhov This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Modified by Glenn Washburn (added support for extended attributes.) */ #define _XOPEN_SOURCE 500 #define _BSD_SOURCE 1 #include #include #include #include #include #include #include #include #include #include #include #include #ifndef WITHOUT_XATTR #include #endif #include "parse_options.h" #include "tools.h" #include "debug.h" #include // getattr static int mhdd_stat(const char *file_name, struct stat *buf) { mhdd_debug(MHDD_MSG, "mhdd_stat: %s\n", file_name); char *path = find_path(file_name); if (path) { int ret = lstat(path, buf); free(path); if (ret == -1) return -errno; return 0; } errno = ENOENT; return -errno; } //statvfs static int mhdd_statfs(const char *path, struct statvfs *buf) { int i, j; struct statvfs * stats; struct stat st; dev_t * devices; mhdd_debug(MHDD_MSG, "mhdd_statfs: %s\n", path); stats = calloc(mhdd.cdirs, sizeof(struct statvfs)); devices = calloc(mhdd.cdirs, sizeof(dev_t)); for (i = 0; i < mhdd.cdirs; i++) { int ret = statvfs(mhdd.dirs[i], stats+i); if (ret != 0) { free(stats); free(devices); return -errno; } ret = stat(mhdd.dirs[i], &st); if (ret != 0) { free(stats); free(devices); return -errno; } devices[i] = st.st_dev; } unsigned long min_block = stats[0].f_bsize, min_frame = stats[0].f_frsize; for (i = 1; istats[i].f_bsize) min_block = stats[i].f_bsize; if (min_frame>stats[i].f_frsize) min_frame = stats[i].f_frsize; } if (!min_block) min_block = 512; if (!min_frame) min_frame = 512; for (i = 0; i < mhdd.cdirs; i++) { if (stats[i].f_bsize>min_block) { stats[i].f_bfree *= stats[i].f_bsize/min_block; stats[i].f_bavail *= stats[i].f_bsize/min_block; stats[i].f_bsize = min_block; } if (stats[i].f_frsize>min_frame) { stats[i].f_blocks *= stats[i].f_frsize/min_frame; stats[i].f_frsize = min_frame; } } memcpy(buf, stats, sizeof(struct statvfs)); for (i = 1; if_namemaxf_namemax = stats[i].f_namemax; } buf->f_ffree += stats[i].f_ffree; buf->f_files += stats[i].f_files; buf->f_favail += stats[i].f_favail; buf->f_bavail += stats[i].f_bavail; buf->f_bfree += stats[i].f_bfree; buf->f_blocks += stats[i].f_blocks; } free(stats); free(devices); return 0; } static int mhdd_readdir( const char *dirname, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info * fi) { int i, j, found; mhdd_debug(MHDD_MSG, "mhdd_readdir: %s\n", dirname); char **dirs = (char **) calloc(mhdd.cdirs+1, sizeof(char *)); typedef struct dir_item { char *name; struct stat *st; UT_hash_handle hh; } dir_item; dir_item * items_ht = NULL; struct stat st; // find all dirs for(i = j = found = 0; id_name, prev); if (prev) { continue; } // add item char *object_name = create_path(dirs[i], de->d_name); struct dir_item *new_item = calloc(1, sizeof(struct dir_item)); new_item->name = strdup(de->d_name); new_item->st = calloc(1, sizeof(struct stat)); lstat(object_name, new_item->st); HASH_ADD_KEYPTR( hh, items_ht, new_item->name, strlen(new_item->name), new_item ); free(object_name); } closedir(dh); } dir_item *item, *tmp; // fill list HASH_ITER(hh, items_ht, item, tmp) { if (filler(buf, item->name, item->st, 0)) break; } // free memory HASH_ITER(hh, items_ht, item, tmp) { free(item->name); free(item->st); free(item); } HASH_CLEAR(hh, items_ht); for (i = 0; dirs[i]; i++) free(dirs[i]); free(dirs); return 0; } // readlink static int mhdd_readlink(const char *path, char *buf, size_t size) { mhdd_debug(MHDD_MSG, "mhdd_readlink: %s, size = %d\n", path, size); char *link = find_path(path); if (link) { memset(buf, 0, size); int res = readlink(link, buf, size); free(link); if (res >= 0) return 0; } return -1; } #define CREATE_FUNCTION 0 #define OPEN_FUNCION 1 // create or open static int mhdd_internal_open(const char *file, mode_t mode, struct fuse_file_info *fi, int what) { mhdd_debug(MHDD_INFO, "mhdd_internal_open: %s, flags = 0x%X\n", file, fi->flags); int dir_id, fd; char *path = find_path(file); if (path) { if (what == CREATE_FUNCTION) fd = open(path, fi->flags, mode); else fd = open(path, fi->flags); if (fd == -1) { free(path); return -errno; } struct flist *add = flist_create(file, path, fi->flags, fd); fi->fh = add->id; flist_unlock(); free(path); return 0; } mhdd_debug(MHDD_INFO, "mhdd_internal_open: new file %s\n", file); if ((dir_id = get_free_dir()) < 0) { errno = ENOSPC; return -errno; } create_parent_dirs(dir_id, file); path = create_path(mhdd.dirs[dir_id], file); if (what == CREATE_FUNCTION) fd = open(path, fi->flags, mode); else fd = open(path, fi->flags); if (fd == -1) { free(path); return -errno; } if (getuid() == 0) { struct stat st; gid_t gid = fuse_get_context()->gid; if (fstat(fd, &st) == 0) { /* parent directory is SGID'ed */ if (st.st_gid != getgid()) gid = st.st_gid; } fchown(fd, fuse_get_context()->uid, gid); } struct flist *add = flist_create(file, path, fi->flags, fd); fi->fh = add->id; flist_unlock(); free(path); return 0; } // create static int mhdd_create(const char *file, mode_t mode, struct fuse_file_info *fi) { mhdd_debug(MHDD_MSG, "mhdd_create: %s, mode = %X\n", file, fi->flags); int res = mhdd_internal_open(file, mode, fi, CREATE_FUNCTION); if (res != 0) mhdd_debug(MHDD_INFO, "mhdd_create: error: %s\n", strerror(-res)); return res; } // open static int mhdd_fileopen(const char *file, struct fuse_file_info *fi) { mhdd_debug(MHDD_MSG, "mhdd_fileopen: %s, flags = %04X\n", file, fi->flags); int res = mhdd_internal_open(file, 0, fi, OPEN_FUNCION); if (res != 0) mhdd_debug(MHDD_INFO, "mhdd_fileopen: error: %s\n", strerror(-res)); return res; } // close static int mhdd_release(const char *path, struct fuse_file_info *fi) { struct flist *del; int fh; mhdd_debug(MHDD_MSG, "mhdd_release: %s, handle = %lld\n", path, fi->fh); del = flist_item_by_id_wrlock(fi->fh); if (!del) { mhdd_debug(MHDD_INFO, "mhdd_release: unknown file number: %llu\n", fi->fh); errno = EBADF; return -errno; } fh = del->fh; flist_delete_wrlocked(del); close(fh); return 0; } // read static int mhdd_read(const char *path, char *buf, size_t count, off_t offset, struct fuse_file_info *fi) { ssize_t res; struct flist * info; mhdd_debug(MHDD_INFO, "mhdd_read: %s, offset = %lld, count = %lld\n", path, (long long)offset, (long long)count ); info = flist_item_by_id(fi->fh); if (!info) { errno = EBADF; return -errno; } res = pread(info->fh, buf, count, offset); flist_unlock(); if (res == -1) return -errno; return res; } // write static int mhdd_write(const char *path, const char *buf, size_t count, off_t offset, struct fuse_file_info *fi) { ssize_t res; struct flist *info; mhdd_debug(MHDD_INFO, "mhdd_write: %s, handle = %lld\n", path, fi->fh); info = flist_item_by_id(fi->fh); if (!info) { errno = EBADF; return -errno; } res = pwrite(info->fh, buf, count, offset); if ((res == count) || (res == -1 && errno != ENOSPC)) { flist_unlock(); if (res == -1) { mhdd_debug(MHDD_DEBUG, "mhdd_write: error write %s: %s\n", info->real_name, strerror(errno)); return -errno; } return res; } // end free space if (move_file(info, offset + count) == 0) { res = pwrite(info->fh, buf, count, offset); flist_unlock(); if (res == -1) { mhdd_debug(MHDD_DEBUG, "mhdd_write: error restart write: %s\n", strerror(errno)); return -errno; } if (res < count) { mhdd_debug(MHDD_DEBUG, "mhdd_write: error (re)write file %s %s\n", info->real_name, strerror(ENOSPC)); } return res; } errno = ENOSPC; flist_unlock(); return -errno; } // truncate static int mhdd_truncate(const char *path, off_t size) { char *file = find_path(path); mhdd_debug(MHDD_MSG, "mhdd_truncate: %s\n", path); if (file) { int res = truncate(file, size); free(file); if (res == -1) return -errno; return 0; } errno = ENOENT; return -errno; } // ftrucate static int mhdd_ftruncate(const char *path, off_t size, struct fuse_file_info *fi) { int res; struct flist *info; mhdd_debug(MHDD_MSG, "mhdd_ftruncate: %s, handle = %lld\n", path, fi->fh); info = flist_item_by_id(fi->fh); if (!info) { errno = EBADF; return -errno; } int fh = info->fh; res = ftruncate(fh, size); flist_unlock(); if (res == -1) return -errno; return 0; } // access static int mhdd_access(const char *path, int mask) { mhdd_debug(MHDD_MSG, "mhdd_access: %s mode = %04X\n", path, mask); char *file = find_path(path); if (file) { int res = access(file, mask); free(file); if (res == -1) return -errno; return 0; } errno = ENOENT; return -errno; } // mkdir static int mhdd_mkdir(const char * path, mode_t mode) { mhdd_debug(MHDD_MSG, "mhdd_mkdir: %s mode = %04X\n", path, mode); if (find_path_id(path) != -1) { errno = EEXIST; return -errno; } char *parent = get_parent_path(path); if (!parent) { errno = EFAULT; return -errno; } if (find_path_id(parent) == -1) { free(parent); errno = EFAULT; return -errno; } free(parent); int dir_id = get_free_dir(); if (dir_id<0) { errno = ENOSPC; return -errno; } create_parent_dirs(dir_id, path); char *name = create_path(mhdd.dirs[dir_id], path); if (mkdir(name, mode) == 0) { if (getuid() == 0) { struct stat st; gid_t gid = fuse_get_context()->gid; if (lstat(name, &st) == 0) { /* parent directory is SGID'ed */ if (st.st_gid != getgid()) gid = st.st_gid; } chown(name, fuse_get_context()->uid, gid); } free(name); return 0; } free(name); return -errno; } // rmdir static int mhdd_rmdir(const char * path) { mhdd_debug(MHDD_MSG, "mhdd_rmdir: %s\n", path); char *dir; while((dir = find_path(path))) { int res = rmdir(dir); free(dir); if (res == -1) return -errno; } return 0; } // unlink static int mhdd_unlink(const char *path) { mhdd_debug(MHDD_MSG, "mhdd_unlink: %s\n", path); char *file = find_path(path); if (!file) { errno = ENOENT; return -errno; } int res = unlink(file); free(file); if (res == -1) return -errno; return 0; } // rename static int mhdd_rename(const char *from, const char *to) { mhdd_debug(MHDD_MSG, "mhdd_rename: from = %s to = %s\n", from, to); int i, res; struct stat sto, sfrom; char *obj_from, *obj_to; int from_is_dir = 0, to_is_dir = 0, from_is_file = 0, to_is_file = 0; int to_dir_is_empty = 1; if (strcmp(from, to) == 0) return 0; /* seek for possible errors */ for (i = 0; i < mhdd.cdirs; i++) { obj_to = create_path(mhdd.dirs[i], to); obj_from = create_path(mhdd.dirs[i], from); if (stat(obj_to, &sto) == 0) { if (S_ISDIR(sto.st_mode)) { to_is_dir++; if (!dir_is_empty(obj_to)) to_dir_is_empty = 0; } else to_is_file++; } if (stat(obj_from, &sfrom) == 0) { if (S_ISDIR (sfrom.st_mode)) from_is_dir++; else from_is_file++; } free(obj_from); free(obj_to); if (to_is_file && from_is_dir) return -ENOTDIR; if (to_is_file && to_is_dir) return -ENOTEMPTY; if (from_is_dir && !to_dir_is_empty) return -ENOTEMPTY; } /* parent 'to' path doesn't exists */ char *pto = get_parent_path (to); if (find_path_id(pto) == -1) { free (pto); return -ENOENT; } free (pto); /* rename cycle */ for (i = 0; i < mhdd.cdirs; i++) { obj_to = create_path(mhdd.dirs[i], to); obj_from = create_path(mhdd.dirs[i], from); if (stat(obj_from, &sfrom) == 0) { /* if from is dir and at the same time file, we only rename dir */ if (from_is_dir && from_is_file) { if (!S_ISDIR(sfrom.st_mode)) { free(obj_from); free(obj_to); continue; } } create_parent_dirs(i, to); mhdd_debug(MHDD_MSG, "mhdd_rename: rename %s -> %s\n", obj_from, obj_to); res = rename(obj_from, obj_to); if (res == -1) { free(obj_from); free(obj_to); return -errno; } } else { /* from and to are files, so we must remove to files */ if (from_is_file && to_is_file && !from_is_dir) { if (stat(obj_to, &sto) == 0) { mhdd_debug(MHDD_MSG, "mhdd_rename: unlink %s\n", obj_to); if (unlink(obj_to) == -1) { free(obj_from); free(obj_to); return -errno; } } } } free(obj_from); free(obj_to); } return 0; } // .utimens static int mhdd_utimens(const char *path, const struct timespec ts[2]) { mhdd_debug(MHDD_MSG, "mhdd_utimens: %s\n", path); int i, res, flag_found; for (i = flag_found = 0; i= 0) res = close(res); } else if (S_ISFIFO(mode)) res = mkfifo(nod, mode); else res = mknod(nod, mode, rdev); if (res != -1) { if (getuid() == 0) { struct fuse_context * fcontext = fuse_get_context(); chown(nod, fcontext->uid, fcontext->gid); } free(nod); return 0; } free(nod); if (errno != ENOSPC) return -errno; } return -errno; } #if _POSIX_SYNCHRONIZED_IO + 0 > 0 || defined(__FreeBSD__) #undef HAVE_FDATASYNC #else #define HAVE_FDATASYNC 1 #endif //fsync static int mhdd_fsync(const char *path, int isdatasync, struct fuse_file_info *fi) { struct flist *info; mhdd_debug(MHDD_MSG, "mhdd_fsync: path = %s handle = %llu\n", path, fi->fh); info = flist_item_by_id(fi->fh); int res; if (!info) { errno = EBADF; return -errno; } int fh = info->fh; #ifdef HAVE_FDATASYNC if (isdatasync) res = fdatasync(fh); else #endif res = fsync(fh); flist_unlock(); if (res == -1) return -errno; return 0; } // Define extended attribute support #ifndef WITHOUT_XATTR static int mhdd_setxattr(const char *path, const char *attrname, const char *attrval, size_t attrvalsize, int flags) { char * real_path = find_path(path); if (!real_path) return -ENOENT; mhdd_debug(MHDD_MSG, "mhdd_setxattr: path = %s name = %s value = %s size = %d\n", real_path, attrname, attrval, attrvalsize); int res = setxattr(real_path, attrname, attrval, attrvalsize, flags); free(real_path); if (res == -1) return -errno; return 0; } #endif #ifndef WITHOUT_XATTR static int mhdd_getxattr(const char *path, const char *attrname, char *buf, size_t count) { int size = 0; char * real_path = find_path(path); if (!real_path) return -ENOENT; mhdd_debug(MHDD_MSG, "mhdd_getxattr: path = %s name = %s bufsize = %d\n", real_path, attrname, count); size = getxattr(real_path, attrname, buf, count); free(real_path); if (size == -1) return -errno; return size; } #endif #ifndef WITHOUT_XATTR static int mhdd_listxattr(const char *path, char *buf, size_t count) { int ret = 0; char * real_path = find_path(path); if (!real_path) return -ENOENT; mhdd_debug(MHDD_MSG, "mhdd_listxattr: path = %s bufsize = %d\n", real_path, count); ret=listxattr(real_path, buf, count); free(real_path); if (ret == -1) return -errno; return ret; } #endif #ifndef WITHOUT_XATTR static int mhdd_removexattr(const char *path, const char *attrname) { char * real_path = find_path(path); if (!real_path) return -ENOENT; mhdd_debug(MHDD_MSG, "mhdd_removexattr: path = %s name = %s\n", real_path, attrname); int res = removexattr(real_path, attrname); free(real_path); if (res == -1) return -errno; return 0; } #endif // functions links static struct fuse_operations mhdd_oper = { .getattr = mhdd_stat, .statfs = mhdd_statfs, .readdir = mhdd_readdir, .readlink = mhdd_readlink, .open = mhdd_fileopen, .release = mhdd_release, .read = mhdd_read, .write = mhdd_write, .create = mhdd_create, .truncate = mhdd_truncate, .ftruncate = mhdd_ftruncate, .access = mhdd_access, .mkdir = mhdd_mkdir, .rmdir = mhdd_rmdir, .unlink = mhdd_unlink, .rename = mhdd_rename, .utimens = mhdd_utimens, .chmod = mhdd_chmod, .chown = mhdd_chown, .symlink = mhdd_symlink, .mknod = mhdd_mknod, .fsync = mhdd_fsync, .link = mhdd_link, #ifndef WITHOUT_XATTR .setxattr = mhdd_setxattr, .getxattr = mhdd_getxattr, .listxattr = mhdd_listxattr, .removexattr = mhdd_removexattr, #endif }; // start int main(int argc, char *argv[]) { mhdd_debug_init(); struct fuse_args *args = parse_options(argc, argv); flist_init(); return fuse_main(args->argc, args->argv, &mhdd_oper, 0); } mhddfs-0.1.39+nmu1ubuntu1/src/flist.h0000664000000000000000000000173412145007405014225 0ustar #include #include // opened file list struct flist { char *name; char *real_name; int flags; int fh; union { uint64_t id; struct flist *aid; }; struct flist *next, *prev; }; // init list system void flist_init(void); // create item and rdlock struct flist* flist_create(const char *name, const char *real_name, int flags, int fh); // return item by id and rdlock struct flist * flist_item_by_id(uint64_t id); // return item by id and wrlock struct flist * flist_item_by_id_wrlock(uint64_t id); // return all items by item struct flist ** flist_items_by_eq_name(struct flist * info); // delete item from locked list void flist_delete_locked(struct flist * item); // delete item from wrlocked list void flist_delete_wrlocked(struct flist * item); // lock for read void flist_rdlock(void); // lock for write void flist_wrlock(void); // unlock void flist_unlock(void); // wrlock void flist_wrlock_locked(void); mhddfs-0.1.39+nmu1ubuntu1/src/debug.h0000664000000000000000000000036012145007405014164 0ustar #ifndef __MHDD_DEBUG_H__ #define __MHDD_DEBUG_H__ #define MHDD_DEFAULT_DEBUG_LEVEL 2 #define MHDD_DEBUG 0 #define MHDD_INFO 1 #define MHDD_MSG 2 int mhdd_debug(int level, const char *fmt, ...); void mhdd_debug_init(void); #endif mhddfs-0.1.39+nmu1ubuntu1/src/flist.c0000664000000000000000000000652412145007405014222 0ustar #include #include #include #include #include #include #include #include #include #include #include "flist.h" #include "debug.h" static struct flist *files = 0; #define flist_foreach(__next) \ for(__next = files; __next; __next = __next->next) enum { UNLOCKED, RDLOCKED, WRLOCKED }; static pthread_rwlock_t files_lock; // init void flist_init(void) { pthread_rwlock_init(&files_lock, 0); } // unlock semaphore void flist_unlock(void) { if (pthread_rwlock_unlock(&files_lock) != 0) { mhdd_debug(MHDD_DEBUG, "E error unlock flist\n"); } mhdd_debug(MHDD_DEBUG, "< unlock flist\n"); } // lock for read void flist_rdlock(void) { pthread_rwlock_rdlock(&files_lock); } // lock for write void flist_wrlock(void) { pthread_rwlock_wrlock(&files_lock); } // lock for write for locked void flist_wrlock_locked(void) { pthread_rwlock_unlock(&files_lock); pthread_rwlock_wrlock(&files_lock); } // add file to list struct flist * flist_create(const char *name, const char *real_name, int flags, int fh) { struct flist * add = calloc(1, sizeof(struct flist)); add->flags = flags; add->id = 0; add->aid = add; add->name = strdup(name); add->real_name = strdup(real_name); add->fh = fh; flist_wrlock(); add->next = files; if (files) files->prev = add; files = add; return add; } /* return (malloced) array for list files with name == name */ struct flist ** flist_items_by_eq_name(struct flist * info) { struct flist * next; struct flist ** result; int i = 0, count = 0; mhdd_debug(MHDD_INFO, "flist_items_by_eq_name: %s\n", info->name); flist_foreach(next) count++; if (!count) return 0; result=calloc(count+1, sizeof(struct flist *)); flist_foreach(next) { if (strcmp(info->name, next->name) == 0) result[i++] = next; } if (!result[0]) { free(result); return 0; } return result; } /* return (wr- or rdlocked) item by id */ static struct flist * item_by_id(uint64_t id, int wrlock) { struct flist * next; if (wrlock) flist_wrlock(); else flist_rdlock(); flist_foreach(next) { if (next->id == id) return next; } flist_unlock(); return 0; } /* return (rdlocked) item from flist */ struct flist * flist_item_by_id(uint64_t id) { return item_by_id(id, 0); } /* return (wrlocked) item from flist */ struct flist * flist_item_by_id_wrlock(uint64_t id) { return item_by_id(id, 1); } /* internal function */ static void delete_item(struct flist *item, int locked) { struct flist *next; switch(locked) { case UNLOCKED: flist_wrlock(); case RDLOCKED: flist_wrlock_locked(); case WRLOCKED: break; } flist_foreach(next) { if (next == item) { if (item->next) item->next->prev = item->prev; if (item->prev) item->prev->next = item->next; if (files==item) files = item->next; mhdd_debug(MHDD_DEBUG, "delete_item: %s (%s)\n", item->name, item->real_name); free(item->name); free(item->real_name); free(item); break; } } flist_unlock(); } // delete from file list void flist_delete(struct flist *item) { delete_item(item, UNLOCKED); } // delete locked file from list void flist_delete_locked(struct flist *item) { delete_item(item, RDLOCKED); } // delete item from wrlocked list void flist_delete_wrlocked(struct flist * item) { delete_item(item, WRLOCKED); } mhddfs-0.1.39+nmu1ubuntu1/src/version.h0000664000000000000000000000146412145007405014571 0ustar /* mhddfs - Multi HDD [FUSE] File System Copyright (C) 2008 Dmitry E. Oboukhov This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #ifndef __MHDDFS__VERSION__H__ #define __MHDDFS__VERSION__H__ #define VERSION "0.1.39" #endif mhddfs-0.1.39+nmu1ubuntu1/src/tools.h0000664000000000000000000000266112145007405014244 0ustar /* mhddfs - Multi HDD [FUSE] File System Copyright (C) 2008 Dmitry E. Oboukhov This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Modified by Glenn Washburn (added support for extended attributes.) */ #ifndef __TOOLS__H__ #define __TOOLS__H__ #include #include #include "flist.h" int get_free_dir(void); char * create_path(const char *dir, const char * file); char * find_path(const char *file); int find_path_id(const char *file); int create_parent_dirs(int dir_id, const char *path); int copy_xattrs(const char *from, const char *to); // true if success int move_file(struct flist * file, off_t size); // paths char * get_parent_path(const char *path); char * get_base_name(const char *path); // others int dir_is_empty(const char *path); #define MOVE_BLOCK_SIZE 32768 #endif mhddfs-0.1.39+nmu1ubuntu1/src/tools.c0000664000000000000000000003116512145007405014240 0ustar /* mhddfs - Multi HDD [FUSE] File System Copyright (C) 2008 Dmitry E. Oboukhov This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Modified by Glenn Washburn (added support for extended attributes.) */ #include #include #include #include #include #include #include #include #include #include #include #include #ifndef WITHOUT_XATTR #include #endif #include "tools.h" #include "debug.h" #include "parse_options.h" // get diridx for maximum free space int get_free_dir(void) { int i, max, max_perc, max_perc_space = 0; struct statvfs stf; fsblkcnt_t max_space = 0; for (max = i = 0; i < mhdd.cdirs; i++) { if (statvfs(mhdd.dirs[i], &stf) != 0) continue; fsblkcnt_t space = stf.f_bsize; space *= stf.f_bavail; if (mhdd.move_limit <= 100) { int perc; if (mhdd.move_limit != 100) { fsblkcnt_t perclimit = stf.f_blocks; if (mhdd.move_limit != 99) { perclimit *= mhdd.move_limit + 1; perclimit /= 100; } if (stf.f_bavail >= perclimit) return i; } perc = 100 * stf.f_bavail / stf.f_blocks; if (perc > max_perc_space) { max_perc_space = perc; max_perc = i; } } else { if (space >= mhdd.move_limit) return i; } if(space > max_space) { max_space = space; max = i; } } if (!max_space && !max_perc_space) { mhdd_debug(MHDD_INFO, "get_free_dir: Can't find freespace\n"); return -1; } if (max_perc_space) return max_perc; return max; } // find mount point with free space > size // -1 if not found static int find_free_space(off_t size) { int i, max; struct statvfs stf; fsblkcnt_t max_space=0; for (max=-1,i=0; isize+mhdd.move_limit) return i; if (space>size && (max<0 || max_space %s\n", file->real_name, new_name); rlist = flist_items_by_eq_name(file); if (!rlist) return 0; for (i = 0; rlist[i]; i++) { struct flist * next = rlist[i]; off_t seek = lseek(next->fh, 0, SEEK_CUR); int flags = next->flags; int fh; flags &= ~(O_EXCL|O_TRUNC); // open if ((fh = open(new_name, flags)) == -1) { mhdd_debug(MHDD_INFO, "reopen_files: error reopen: %s\n", strerror(errno)); if (!i) { error = errno; break; } close(next->fh); } else { // seek if (seek != lseek(fh, seek, SEEK_SET)) { mhdd_debug(MHDD_INFO, "reopen_files: error seek %s\n", strerror(errno)); close(fh); if (!i) { error = errno; break; } } // filehandle if (dup2(fh, next->fh) != next->fh) { mhdd_debug(MHDD_INFO, "reopen_files: error dup2 %s\n", strerror(errno)); close(fh); if (!i) { error = errno; break; } } // close temporary filehandle mhdd_debug(MHDD_MSG, "reopen_files: reopened %s (to %s) old h=%x " "new h=%x seek=%lld\n", next->real_name, new_name, next->fh, fh, seek); close(fh); } } if (error) { free(rlist); return -error; } /* change real_name */ for (i = 0; rlist[i]; i++) { free(rlist[i]->real_name); rlist[i]->real_name = strdup(new_name); } free(rlist); return 0; } int move_file(struct flist * file, off_t wsize) { char *from, *to, *buf; off_t size; FILE *input, *output; int ret, dir_id; struct utimbuf ftime = {0}; struct statvfs svf; fsblkcnt_t space; struct stat st; mhdd_debug(MHDD_MSG, "move_file: %s\n", file->real_name); /* TODO: it would be nice to contrive something alter */ flist_wrlock_locked(); from=file->real_name; /* We need to check if already moved */ if (statvfs(from, &svf) != 0) return -errno; space = svf.f_bsize; space *= svf.f_bavail; /* get file size */ if (fstat(file->fh, &st) != 0) { mhdd_debug(MHDD_MSG, "move_file: error stat %s: %s\n", from, strerror(errno)); return -errno; } /* Hard link support is limited to a single device, and files with >1 hardlinks cannot be moved between devices since this would (a) result in partial files on the source device (b) not free the space from the source device during unlink. */ if (st.st_nlink > 1) { mhdd_debug(MHDD_MSG, "move_file: cannot move " "files with >1 hardlinks\n"); return -ENOTSUP; } size = st.st_size; if (size < wsize) size=wsize; if (space > size) { mhdd_debug(MHDD_MSG, "move_file: we have enough space\n"); return 0; } if ((dir_id=find_free_space(size)) == -1) { mhdd_debug(MHDD_MSG, "move_file: can not find space\n"); return -1; } if (!(input = fopen(from, "r"))) return -errno; create_parent_dirs(dir_id, file->name); to = create_path(mhdd.dirs[dir_id], file->name); if (!(output = fopen(to, "w+"))) { ret = -errno; mhdd_debug(MHDD_MSG, "move_file: error create %s: %s\n", to, strerror(errno)); free(to); fclose(input); return(ret); } mhdd_debug(MHDD_MSG, "move_file: move %s to %s\n", from, to); // move data buf=(char *)calloc(sizeof(char), MOVE_BLOCK_SIZE); while((size = fread(buf, sizeof(char), MOVE_BLOCK_SIZE, input))) { if (size != fwrite(buf, sizeof(char), size, output)) { mhdd_debug(MHDD_MSG, "move_file: error move data to %s: %s\n", to, strerror(errno)); fclose(output); fclose(input); free(buf); unlink(to); free(to); return -1; } } free(buf); mhdd_debug(MHDD_MSG, "move_file: done move data\n"); fclose(input); // owner/group/permissions fchmod(fileno(output), st.st_mode); fchown(fileno(output), st.st_uid, st.st_gid); fclose(output); // time ftime.actime = st.st_atime; ftime.modtime = st.st_mtime; utime(to, &ftime); #ifndef WITHOUT_XATTR // extended attributes if (copy_xattrs(from, to) == -1) mhdd_debug(MHDD_MSG, "copy_xattrs: error copying xattrs from %s to %s\n", from, to); #endif from = strdup(from); if ((ret = reopen_files(file, to)) == 0) unlink(from); else unlink(to); mhdd_debug(MHDD_MSG, "move_file: %s -> %s: done, code=%d\n", from, to, ret); free(to); free(from); return ret; } #ifndef WITHOUT_XATTR int copy_xattrs(const char *from, const char *to) { int listsize=0, attrvalsize=0; char *listbuf=NULL, *attrvalbuf=NULL, *name_begin=NULL, *name_end=NULL; // if not xattrs on source, then do nothing if ((listsize=listxattr(from, NULL, 0)) == 0) return 0; // get all extended attributes listbuf=(char *)calloc(sizeof(char), listsize); if (listxattr(from, listbuf, listsize) == -1) { mhdd_debug(MHDD_MSG, "listxattr: error listing xattrs on %s : %s\n", from, strerror(errno)); return -1; } // loop through each xattr for(name_begin=listbuf, name_end=listbuf+1; name_end < (listbuf + listsize); name_end++) { // skip the loop if we're not at the end of an attribute name if (*name_end != '\0') continue; // get the size of the extended attribute attrvalsize = getxattr(from, name_begin, NULL, 0); if (attrvalsize < 0) { mhdd_debug(MHDD_MSG, "getxattr: error getting xattr size on %s name %s : %s\n", from, name_begin, strerror(errno)); return -1; } // get the value of the extended attribute attrvalbuf=(char *)calloc(sizeof(char), attrvalsize); if (getxattr(from, name_begin, attrvalbuf, attrvalsize) < 0) { mhdd_debug(MHDD_MSG, "getxattr: error getting xattr value on %s name %s : %s\n", from, name_begin, strerror(errno)); return -1; } // set the value of the extended attribute on dest file if (setxattr(to, name_begin, attrvalbuf, attrvalsize, 0) < 0) { mhdd_debug(MHDD_MSG, "setxattr: error setting xattr value on %s name %s : %s\n", from, name_begin, strerror(errno)); return -1; } free(attrvalbuf); // point the pointer to the start of the attr name to the start // of the next attr name_begin=name_end+1; name_end++; } free(listbuf); return 0; } #endif char * create_path(const char *dir, const char * file) { if (file[0]=='/') file++; int plen=strlen(dir); int flen=strlen(file); char *path=(char *)calloc(plen+flen+2, sizeof(char)); if (dir[plen-1]=='/') { sprintf(path, "%s%s", dir, file); } else { sprintf(path, "%s/%s", dir, file); } plen=strlen(path); if (plen>1 && path[plen-1]=='/') path[plen-1]=0; /* mhdd_debug(MHDD_DEBUG, "create_path: %s\n", path); */ return(path); } char * find_path(const char *file) { int i; struct stat st; for (i=0; i1 && dir[len-1]=='/') dir[--len]=0; if (len) return dir; free(dir); return 0; } char * get_base_name(const char *path) { char *dir=strdup(path); int len=strlen(dir); if (len && dir[len-1]=='/') dir[--len]=0; char *file=strrchr(dir, '/'); if (file) { file++; strcpy(dir, file); } return dir; } /* return true if directory is empty */ int dir_is_empty(const char *path) { DIR * dir = opendir(path); struct dirent *de; if (!dir) return -1; while((de = readdir(dir))) { if (strcmp(de->d_name, ".") == 0) continue; if (strcmp(de->d_name, "..") == 0) continue; closedir(dir); return 0; } closedir(dir); return 1; } mhddfs-0.1.39+nmu1ubuntu1/src/test/0000775000000000000000000000000012145007556013714 5ustar mhddfs-0.1.39+nmu1ubuntu1/src/test/stat.pl0000664000000000000000000000224112145007405015214 0ustar #!/usr/bin/perl use warnings; use strict; use utf8; use open qw(:std :utf8); for (@ARGV) { my ( $dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks ) = stat $_; print "\n$_\n"; unless (defined $dev) { print "$!\n"; last; } printf < #include #include #include int main(int argc, char **argv) { if (argc<2) { printf("Usage: %s directory\n", argv[0]); _exit(-1); } struct statvfs stv; int ret=statvfs(argv[1], &stv); printf( " Path:%s\n" " statvfs returned:%d\n\n" " f_bsize=%12llu /* file system block size */\n" " f_frsize=%12llu /* fragment size */\n" " f_blocks=%12llu /* size of fs in f_frsize units */\n" " f_bfree=%12llu /* # free blocks */\n" " f_bavail=%12llu /* # free blocks for non-root */\n" " f_files=%12llu /* # inodes */\n" " f_ffree=%12llu /* # free inodes */\n" " f_favail=%12llu /* # free inodes for non-root */\n" " f_fsid=%12llu /* file system ID */\n" " f_flag=%12llu /* mount flags */\n" " f_namemax=%12llu /* maximum filename length */\n", argv[1], ret, (unsigned long long)stv.f_bsize, (unsigned long long)stv.f_frsize, (unsigned long long)stv.f_blocks, (unsigned long long)stv.f_bfree, (unsigned long long)stv.f_bavail, (unsigned long long)stv.f_files, (unsigned long long)stv.f_ffree, (unsigned long long)stv.f_favail, (unsigned long long)stv.f_fsid, (unsigned long long)stv.f_flag, (unsigned long long)stv.f_namemax); return 0; } mhddfs-0.1.39+nmu1ubuntu1/src/test/pwrite.c0000664000000000000000000000201512145007405015361 0ustar #define _XOPEN_SOURCE 500 #include #include #include #include #include #include #include #include void usage(void) { printf("usage: pwrite_test file_name\n"); _exit(0); } #define COUNT_WRITE (50*1024*1024) int main(int argc, char **argv) { if (argc < 2) usage(); int hfile=open(argv[1], O_CREAT|O_EXCL|O_RDWR); if (hfile == -1) { fprintf(stderr, "Can not create file %s: %s\n", argv[1], strerror(errno)); _exit(-1); } fchmod(hfile, 0644); printf("file %s has been created\n", argv[1]); printf("writing %d + %d bytes ... ", COUNT_WRITE, COUNT_WRITE); char * buf=malloc(COUNT_WRITE); ssize_t write = pwrite(hfile, buf, COUNT_WRITE, COUNT_WRITE); if (write == -1 || write #include #include #include #include "debug.h" #include "parse_options.h" static pthread_mutex_t debug_lock; void mhdd_debug_init(void) { pthread_mutex_init(&debug_lock, 0); } int mhdd_debug(int level, const char *fmt, ...) { if (level This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include #include "usage.h" void usage(FILE * to) { const char *usage= "\n" "Multi-hdd FUSE filesystem\n" " Copyright (C) 2008, Dmitry E. Oboukhov \n" "\n" "Usage:\n" " mhddfs dir1,dir2.. mountpoint [ -o OPTIONS ]\n" "\n" "OPTIONS:\n" " mlimit=xxx - limit of the disk free space (if the disk\n" " has the free space more than specified - it is\n" " considered as the empty one). Default is 4Gb,\n" " but 100Mb at least.\n" " logfile=/path/to/file - path to a file where the logs\n" " will be stored.\n" " loglevel=x - level for log-messages:\n" " 0 - debug\n" " 1 - info\n" " 2 - default messages\n" "\n" " see fusermount(1) for information about other options\n" ""; fprintf(to, usage); if (to==stdout) exit(0); exit(-1); } mhddfs-0.1.39+nmu1ubuntu1/src/usage.h0000664000000000000000000000145412145007405014207 0ustar /* mhddfs - Multi HDD [FUSE] File System Copyright (C) 2008 Dmitry E. Oboukhov This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #ifndef __USAGE__H__ #define __USAGE__H__ #include void usage(FILE * to); #endif mhddfs-0.1.39+nmu1ubuntu1/src/parse_options.h0000664000000000000000000000225412145007405015767 0ustar /* mhddfs - Multi HDD [FUSE] File System Copyright (C) 2008 Dmitry E. Oboukhov This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #ifndef __PARSE__OPTIONS__H__ #define __PARSE__OPTIONS__H__ #include #include #include struct mhdd_config { char * mount; // mount point char ** dirs; // dir list int cdirs; // count dirs in dirs off_t move_limit; // no limits FILE *debug; char *debug_file; char *mlimit_str; // mlimit string int loglevel; }; extern struct mhdd_config mhdd; struct fuse_args * parse_options(int argc, char *argv[]); #endif mhddfs-0.1.39+nmu1ubuntu1/src/parse_options.c0000664000000000000000000001520112145007405015756 0ustar /* mhddfs - Multi HDD [FUSE] File System Copyright (C) 2008 Dmitry E. Oboukhov This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include #include #include #include #include #include #include #include #include #include #include "parse_options.h" #include "usage.h" #include "version.h" #include "debug.h" #include "tools.h" struct mhdd_config mhdd={0}; #define MHDDFS_OPT(t, p, v) { t, offsetof(struct mhdd_config, p), v } #define MHDD_VERSION_OPT 15121974 #if FUSE_VERSION >= 27 #define FUSE_MP_OPT_STR "-osubtype=mhddfs,fsname=" #else #define FUSE_MP_OPT_STR "-ofsname=mhddfs#" #endif /* the number less (or equal) than 100 is in percent, more than 100 is in bytes */ #define DEFAULT_MLIMIT ( 4l * 1024 * 1024 * 1024 ) #define MINIMUM_MLIMIT ( 50l * 1024 * 1024 ) static struct fuse_opt mhddfs_opts[]={ MHDDFS_OPT("mlimit=%s", mlimit_str, 0), MHDDFS_OPT("logfile=%s", debug_file, 0), MHDDFS_OPT("loglevel=%d", loglevel, 0), FUSE_OPT_KEY("-V", MHDD_VERSION_OPT), FUSE_OPT_KEY("--version", MHDD_VERSION_OPT), FUSE_OPT_END }; static void add_mhdd_dirs(const char * dir) { int i; char ** newdirs; char *add_dir; if (*dir=='/') { add_dir=strdup(dir); } else { char cpwd[PATH_MAX]; getcwd(cpwd, PATH_MAX); add_dir = create_path(cpwd, dir); } if (!mhdd.dirs) { mhdd.dirs=calloc(2, sizeof(char *)); mhdd.dirs[0]=add_dir; mhdd.cdirs=1; return; } newdirs=calloc(mhdd.cdirs+2, sizeof(char *)); for (i=0; i 100) mhdd.move_limit = MINIMUM_MLIMIT; } } } if (mhdd.move_limit <= 100) fprintf(stderr, "mhddfs: move size limit %lld%%\n", (long long)mhdd.move_limit); else fprintf(stderr, "mhddfs: move size limit %lld bytes\n", (long long)mhdd.move_limit); mhdd_debug(MHDD_MSG, " >>>>> mhdd " VERSION " started <<<<<\n"); return args; } mhddfs-0.1.39+nmu1ubuntu1/tests/0000775000000000000000000000000012145007556013310 5ustar mhddfs-0.1.39+nmu1ubuntu1/tests/seek.pl0000664000000000000000000000161312145007405014566 0ustar #!/usr/bin/perl use warnings; use strict; sub usage() { print <', $file_name) { print "Can not create file `$file_name': $!\n"; return; } else { print "Save data...\n"; unless (syswrite $file, "test\n") { print "error syswrite: $!\n"; } print "Seek...\n"; unless (sysseek $file, 300, 0) { print "error sysseek: $!\n"; } print "Save data...\n"; unless (syswrite $file, "test\n") { print "error syswrite: $!\n"; } } system md5sum => $file_name; unlink $file_name; } use Getopt::Std qw(getopts); getopts('h', \my %opts) or usage; $opts{h} and usage; @ARGV or usage; test_seek $_ for (@ARGV); mhddfs-0.1.39+nmu1ubuntu1/tests/xattrs.sh0000664000000000000000000000644712145007405015175 0ustar #!/bin/bash PATH=/sbin:$PATH set -x TMP_PATH="${1:-/tmp}" image1="test1.xfs.img" image2="test2.xfs.img" mount="mnt.xfs" mount1="test1.xfs" mount2="test2.xfs" logfile="logfile.xfs.log" CWD=`pwd` MHDDFS="$CWD/mhddfs" if ! which attr 1>/dev/null 2>&1; then echo "Need attr command to test extended attributes" exit 1 fi if ! sudo which mkfs.xfs 1>/dev/null 2>&1; then echo "Need mkfs.xfs command to test extended attributes" exit 1 fi function run_test () { TESTNAME=$1 { $TESTNAME && echo "Passed $TESTNAME ..." || { echo "Failed $TESTNAME ..." return 1 } } return 0 } function setup() { test -r $image1 || dd if=/dev/zero of=$image1 bs=1M count=50 test -r $image2 || dd if=/dev/zero of=$image2 bs=1M count=100 # make xfs filesystems sudo mkfs.xfs -f $image1 1>/dev/null sudo mkfs.xfs -f $image2 1>/dev/null test -d $mount1 || mkdir $mount1 test -d $mount2 || mkdir $mount2 test -d $mount || mkdir $mount # mount loop back xfs filesystems sudo mount -o loop $image1 $mount1 sudo mount -o loop $image2 $mount2 sudo chown -R `whoami` $mount1 $mount2 $MHDDFS -o allow_other,logfile=$logfile -o loglevel=0 $mount1 $mount2 $mount } function teardown () { fusermount -u $mount sudo umount $mount1 sudo umount $mount2 rm -rf $image1 $image2 $mount1 $mount2 $mount } function test_xattr () { touch $mount1/testfile ATTRNAME="X&E^REsd436" ATTRVAL="More random garbage UFI(fh99fHwhgp932wcP*(@*TGPew." attr -qs "$ATTRNAME" -V "$ATTRVAL" $mount1/testfile || return 1; _ATTRNAME=$(attr -ql $mount/testfile | { read A; echo -n "$A"; }) [ "$_ATTRNAME" != "$ATTRNAME" ] && { echo "Found attribute name $_ATTRNAME, but looking for $ATTRNAME" return 1 } _ATTRVAL=$(attr -qg "$ATTRNAME" $mount/testfile) [ "$_ATTRVAL" != "$ATTRVAL" ] && { echo "Found attribute value mismatch: $_ATTRVAL != $ATTRVAL" return 1 } attr -qr "$ATTRNAME" $mount/testfile || return 1 _ATTRNAME=$(attr -ql $mount/testfile | { read A; echo -n "$A"; }) [ "$_ATTRNAME" != "" ] && { echo "Found attribute name \"$_ATTRNAME\", but looking for \"\"" return 1 } return 0 } function test_preserve_xattr_across_move () { mkdir $mount1/testdir touch $mount1/testdir/testfile attr -qs "testdirattr" -V "a test value for this dir attribute" $mount1/testdir && sudo attr -qs "testfileattr" -V "a test value for this file attribute" $mount1/testdir/testfile # cause the file to be moved to another partition dd if=/dev/zero of=$mount/testdir/testfile bs=1M count=51 # verify that attributes were copied to new location _ATTRVAL=$(attr -qg testdirattr $mount/testdir) if [ "$_ATTRVAL" != "a test value for this dir attribute" ]; then echo "Directory xattr test failed: got \"$_ATTRVAL\" but expected \"a test value for this dir attribute\"" return 1 fi _ATTRVAL=$(attr -qg testfileattr $mount/testdir/testfile) if [ "$_ATTRVAL" != "a test value for this file attribute" ]; then echo "File xattr test failed: got \"$_ATTRVAL\" but expected \"a test value for this file attribute\"" return 1 fi return 0 } setup # Run tests { run_test "test_xattr" && run_test "test_preserve_xattr_across_move" } || RC=$? read -p "Press Enter to teardown..." teardown exit $RC mhddfs-0.1.39+nmu1ubuntu1/tests/access.pl0000664000000000000000000000125212145007405015077 0ustar #!/usr/bin/perl use warnings; use strict; use utf8; use open qw(:std :utf8); use POSIX; use Encode qw(decode); unless (@ARGV) { print "Usage $0 object1 object2\n"; } for (@ARGV) { $_ = decode(utf8 => $_) unless utf8::is_utf8($_); print "Test $_ R_OK..."; if (POSIX::access($_, &POSIX::R_OK)) { print " ok\n"; } else { print " fail\n"; } print "Test $_ W_OK..."; if (POSIX::access($_, &POSIX::W_OK)) { print " ok\n"; } else { print " fail\n"; } print "Test $_ X_OK..."; if (POSIX::access($_, &POSIX::X_OK)) { print " ok\n"; } else { print " fail\n"; } print "\n"; } mhddfs-0.1.39+nmu1ubuntu1/tests/rename.c0000664000000000000000000000320012145007405014707 0ustar /************************************************************************* * * * Copyright (C) 2009 Dmitry E. Oboukhov * * * * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 3 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * * * *************************************************************************/ #include #include #include #include int main (int argc, char **argv) { if (argc < 3) { printf("usage %s object_from object_to\n", argv[0]); return 0; } int res = rename(argv[1], argv[2]); if (res == -1) { printf ("%s\n", strerror (errno)); } return res; } mhddfs-0.1.39+nmu1ubuntu1/tests/utimes.sh0000664000000000000000000000101612145007405015141 0ustar #!/bin/bash dir1=`mktemp -d` dir2=`mktemp -d` mnt=`mktemp -d` log=`mktemp` ret=0 cleantemp() { rm -fr $dir1 $dir2 $mnt $log } mkdir -p $dir1/1/{2,3,4}/{5,6,7} cwd=`pwd` cd $dir1/1 find -type d -exec ln -s '{}' '{}link' ';' cd $cwd sleep 1 ./mhddfs $dir1 $dir2 $mnt rsync -a $mnt/1 $mnt/2 2> $log logrsync=`cat $log` fusermount -u $mnt if test -z "$logrsync"; then echo "**************** PASSED ******************" cleantemp exit 0 else echo "FAILED:" cat $log cleantemp exit -1 fi mhddfs-0.1.39+nmu1ubuntu1/tests/plocks.c0000664000000000000000000000462412145007405014746 0ustar /************************************************************************* * * * Copyright (C) 2009 Dmitry E. Oboukhov * * * * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 3 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * * * *************************************************************************/ #include #include #include pthread_rwlock_t rwlock; pthread_mutex_t mutex; void * thread(void *data) { fprintf(stderr, "Started thread %u\n", pthread_self()); for(;;) { int res; fprintf(stderr, "%u get rdlock...\n", pthread_self()); /* pthread_mutex_lock(&mutex); */ res = pthread_rwlock_rdlock(&rwlock); /* pthread_mutex_unlock(&mutex); */ fprintf(stderr, "%u got rdlock: %d\n", pthread_self(), res); fprintf(stderr, "%u get wrlock...\n", pthread_self()); /* pthread_mutex_lock(&mutex); */ pthread_rwlock_unlock(&rwlock); res = pthread_rwlock_wrlock(&rwlock); /* pthread_mutex_unlock(&mutex); */ fprintf(stderr, "%u got wrlock...: %d\n", pthread_self(), res); pthread_rwlock_unlock(&rwlock); fprintf(stderr, "%u unlocked\n", pthread_self()); } } int main(void) { pthread_t t1, t2; pthread_rwlock_init(&rwlock, 0); pthread_mutex_init(&mutex, 0); pthread_create(&t1, 0, thread, 0); pthread_create(&t2, 0, thread, 0); pthread_join(t1, NULL); pthread_join(t2, NULL); } mhddfs-0.1.39+nmu1ubuntu1/tests/statvfs.pl0000664000000000000000000000211012145007405015322 0ustar #!/usr/bin/perl use warnings; use strict; use utf8; use open qw(:std :utf8); use Getopt::Std qw(getopts); use Filesys::Statvfs; sub usage() { print <) { my @f = split /\s+/, $_; next unless @f > 3; next unless $f[1] eq 'on'; push @paths, $f[2]; } } for (@paths) { my @stat = statvfs $_; my @hi = ( 'File system block size', 'Fragment size', 'Size of fs in "Fragment size" units', 'Free blocks', 'Free blocks for unprivileged users', 'Inodes', 'Free inodes', 'Free inodes for unprivileged users', 'Mount flags', 'Maximum filename length' ); printf "%s\n\t%s\n\n", $_, join "\n\t", map { sprintf "%40s: %s", $hi[$_], $stat[$_] } 0 .. $#stat; } mhddfs-0.1.39+nmu1ubuntu1/ChangeLog0000664000000000000000000000351012145007405013710 0ustar 0.1.1 * Added changelog; * Using pthread_mutex for multithread; * Added -s (single thread) option; 0.1.2 * Added English README * Optimized open/create * removed lock (not needed) 0.1.3 * Added option ' -o loglevel=dd': 0 - debug level 1 - info level 2 - default level 0.1.4 * Added man page 0.1.5 * created objects belong creates (was mount-user) (if mount-user ==root) 0.1.6 * fix permissions after move files. 0.1.7 * fix readlink function. 0.1.8 * Parse the command line using the fuse-lib. 0.1.9 * New files are created only on a partition with enough space 0.1.10 * call chown only if uid==0 * New directories are created only on a partition with enough space 0.1.11 * fix detect filesystem overflow. Thanks lordikc . 0.1.12 * SGID-attribute works correctly * option -V shows version of mhddfs 0.1.13 * Fix flags in Makefile (fixed build with --as-needed), thanks for Vladimir V. Kamarzin * Added lock for debug-stream when writing debug messages thanks for Andrew McGill 0.1.14 * Fix segfault on mhdd_internal_open (locks added), thanks to Konstantin Zavialov 0.1.16 * Revert to old locks scheme. 0.1.17 * Added standard variant for list of directories. Now it works: mhddfs /dir1 /dir2 /mount and old variant works too: mhddfs /dir1,/dir2 /mount * Reformatted sources. 0.1.21 * Fixed possible deadlocks 0.1.24 * Applied extended attribute patch, thanks for Glenn Washburn . 0.1.26 * Fixed memory leak in extended attribute patch 0.1.27 * Fixed renaming directory bug, thanks for Nathan Grennan 0.1.31 * Fixed statvfs if a few shares are placed onto one device. 0.1.32 * Added startup check to remove duplicaties of mount directories. 0.1.33 * Symlinks are processed properly (set date/time). mhddfs-0.1.39+nmu1ubuntu1/debian/0000775000000000000000000000000012145007556013370 5ustar mhddfs-0.1.39+nmu1ubuntu1/debian/rules0000775000000000000000000000161012145007405014437 0ustar #!/usr/bin/make -f # -*- makefile -*- # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 MHDDFS_BUILDFLAGS = FREEBSD_FLAGS = $(shell \ if `dpkg-architecture -qDEB_BUILD_ARCH|grep -q 'kfreebsd'`; then \ echo WITHOUT_XATTR=1; \ fi \ ) MHDDFS_BUILDFLAGS += $(FREEBSD_FLAGS) build: build-stamp build-stamp: dh_testdir make $(MHDDFS_BUILDFLAGS) touch $@ clean: dh_testdir dh_testroot make clean rm -f build-stamp dh_clean # Build architecture-independent files here. binary-indep: build install # Build architecture-dependent files here. binary-arch: build install dh_testdir dh_testroot dh_installchangelogs ChangeLog dh_installdocs dh_install dh_installman dh_strip dh_compress dh_fixperms dh_installdeb dh_shlibdeps dh_gencontrol dh_md5sums dh_builddeb binary: binary-indep binary-arch .PHONY: build clean binary-indep binary-arch binary install configure mhddfs-0.1.39+nmu1ubuntu1/debian/changelog0000664000000000000000000002030412145007536015237 0ustar mhddfs (0.1.39+nmu1ubuntu1) saucy; urgency=low * Merge from Debian unstable. Remaining changes: - Makefile: Add -pthread to LDFLAGS to fix underlinking FTBFS. -- Logan Rosen Wed, 15 May 2013 18:42:09 -0400 mhddfs (0.1.39+nmu1) unstable; urgency=low * Non-maintainer upload. * Depend on fuse instead of fuse-utils. (Closes: #698128) -- Ansgar Burchardt Sun, 12 May 2013 15:35:08 +0200 mhddfs (0.1.39ubuntu1) raring; urgency=low * Makefile: Add -pthread to LDFLAGS to fix underlinking FTBFS. -- Logan Rosen Fri, 19 Apr 2013 15:50:03 -0400 mhddfs (0.1.39) unstable; urgency=low * Kalyanov Dmitry optimized readdir function: now we use HASH-tables to deduplicate directories. -- Dmitry E. Oboukhov Sun, 17 Jun 2012 17:46:43 +0400 mhddfs (0.1.38) unstable; urgency=low * Apply hardlinks patch, big thanks for patch to Dermot Duffy . -- Dmitry E. Oboukhov Wed, 04 May 2011 12:23:01 +0400 mhddfs (0.1.37) unstable; urgency=low * Old default mlimit is used. * mlimit=100% is a reasonable request. -- Dmitry E. Oboukhov Tue, 13 Jul 2010 17:05:40 +0400 mhddfs (0.1.36) experimental; urgency=low * Since now mhddfs uses 'mlimit' option in percent, thanks for Robert de Bath , closes: #588892. -- Dmitry E. Oboukhov Tue, 13 Jul 2010 15:18:37 +0400 mhddfs (0.1.35) unstable; urgency=low * Debian/kfreebsd architectures are built using WITHOUT_XATTR=1 build flag, fixes a few build warnings. -- Dmitry E. Oboukhov Tue, 15 Jun 2010 09:44:23 +0400 mhddfs (0.1.34) unstable; urgency=low * Fixed dependencies on freebsd. -- Dmitry E. Oboukhov Thu, 03 Jun 2010 21:51:48 +0400 mhddfs (0.1.33) unstable; urgency=low * Symlinks are processed properly (set date/time), closes: #575847, thanks for Jools Wills for bugreport. -- Dmitry E. Oboukhov Tue, 01 Jun 2010 16:31:20 +0400 mhddfs (0.1.32) unstable; urgency=low * Switch to dpkg-source 3.0 (native) format. * Added startup check to remove duplicaties of mount directories, closes: #582888. * Debian is upstream linux variant, so we will use debian native package format. -- Dmitry E. Oboukhov Tue, 01 Jun 2010 15:09:37 +0400 mhddfs (0.1.31-1) unstable; urgency=low * Fixed statvfs if a few shares are placed onto one device, closes: #580785. * Added libattr1-dev in B-D, fixed FTBFS, closes: #565037. * Closes unreproducible bugreport (a few months passed), closes: #512649. -- Dmitry E. Oboukhov Tue, 01 Jun 2010 12:07:00 +0400 mhddfs (0.1.30-1) UNRELEASE; urgency=low * Another BSD build problem. -- Dmitry E. Oboukhov Mon, 11 Jan 2010 23:07:30 +0300 mhddfs (0.1.29-1) UNRELEASE; urgency=low * Building under FreeBSD is fixed. -- Dmitry E. Oboukhov Mon, 11 Jan 2010 11:49:17 +0300 mhddfs (0.1.28-1) unstable; urgency=high * Fixed creating parent directories when item is moved between shares. -- Dmitry E. Oboukhov Fri, 18 Dec 2009 22:59:15 +0300 mhddfs (0.1.27-1) unstable; urgency=high * Fixed renaming a directory bug, thanks for Nathan Grennan . -- Dmitry E. Oboukhov Sat, 12 Dec 2009 14:24:22 +0300 mhddfs (0.1.26-1) unstable; urgency=low * Fixed memory leak in extended attribute patch. -- Dmitry E. Oboukhov Thu, 26 Nov 2009 00:37:42 +0300 mhddfs (0.1.25-1) unstable; urgency=low * Rewite rename mechanizm to properly rename directories which are present in many hdds. -- Dmitry E. Oboukhov Mon, 16 Nov 2009 00:25:36 +0300 mhddfs (0.1.24-1) unstable; urgency=low * Applied extended attribute patch, thanks for Glenn Washburn . -- Dmitry E. Oboukhov Fri, 30 Oct 2009 09:52:00 +0300 mhddfs (0.1.23-1) unstable; urgency=low * Fixed rename mechanizm if files are in different hdds, closes: #547172, tanks to Pozsar Balazs for bugreport. -- Dmitry E. Oboukhov Tue, 29 Sep 2009 12:51:02 +0400 mhddfs (0.1.22-1) unstable; urgency=low * Finally fixed deadlock when it moves file between sources. * Bumped Standards-Version to 3.8.2. -- Dmitry E. Oboukhov Thu, 02 Jul 2009 18:04:18 +0400 mhddfs (0.1.21-1) unstable; urgency=low * Fixed deadlock when it closes bad file descrioption. -- Dmitry E. Oboukhov Thu, 02 Jul 2009 12:09:17 +0400 mhddfs (0.1.20-1) unstable; urgency=low * New upstream version. * Fixed possible deadlock when it moves file between sources. -- Dmitry E. Oboukhov Wed, 01 Jul 2009 09:28:29 +0400 mhddfs (0.1.19-1) unstable; urgency=low * Check free space is better than before: code will return the error if it does not find free space. -- Dmitry E. Oboukhov Wed, 11 Mar 2009 12:55:19 +0300 mhddfs (0.1.18-1) unstable; urgency=low * New upstream release. Fixed deadlocks. -- Dmitry E. Oboukhov Mon, 29 Dec 2008 12:06:57 +0300 mhddfs (0.1.17-1) unstable; urgency=low * New upstream release. Now the mount's directories can be input with the help of spaces. closes: #508330. -- Dmitry E. Oboukhov Fri, 12 Dec 2008 22:53:44 +0300 mhddfs (0.1.17~debug-1) norelease; urgency=low * Test version for find segfault. -- Dmitry E. Oboukhov Fri, 24 Oct 2008 12:16:17 +0400 mhddfs (0.1.16-1) unstable; urgency=low * Revert to old lock-scheme. -- Dmitry E. Oboukhov Mon, 20 Oct 2008 15:20:10 +0400 mhddfs (0.1.15-1) unstable; urgency=low * New upstream release (fixed segfault on mhdd_fileopen). -- Dmitry E. Oboukhov Mon, 20 Oct 2008 14:44:47 +0400 mhddfs (0.1.13-1) unstable; urgency=low * New release. * Fix few linker options, closes: #499380. * Added lock for debug-stream when writing debug messages. -- Dmitry E. Oboukhov Mon, 13 Oct 2008 15:32:01 +0400 mhddfs (0.1.12-1) unstable; urgency=low * New release (Now SGID-bit works fine). * Added Vcs-Browser: to debian/control. -- Dmitry E. Oboukhov Fri, 11 Jul 2008 23:38:18 +0400 mhddfs (0.1.11-1) unstable; urgency=medium * New release (fix detect filesystem overflow. Thanks lordikc .) * Standards-Version bumped to 3.8.0. -- Dmitry E. Oboukhov Mon, 16 Jun 2008 23:47:54 +0400 mhddfs (0.1.10-2) unstable; urgency=low * My email address has been changed. -- Dmitry E. Oboukhov Fri, 30 May 2008 07:56:05 +0400 mhddfs (0.1.10-1) unstable; urgency=low * New release. * Upload sponsored by Al Nikolov -- Dmitry E. Oboukhov Sun, 4 May 2008 18:28:15 +0400 mhddfs (0.1.8-2) unstable; urgency=low * Changed description, closes: #477796. * Added homepage url to debian/control. * Upload sponsored by Al Nikolov -- Dmitry E. Oboukhov Fri, 25 Apr 2008 14:50:09 +0400 mhddfs (0.1.8-1) unstable; urgency=low * New release. * Upload sponsored by Al Nikolov -- Dmitry E. Oboukhov Fri, 11 Apr 2008 01:02:34 +0400 mhddfs (0.1.7-1) unstable; urgency=low * New release. * Upload sponsored by Al Nikolov -- Dmitry E. Oboukhov Thu, 03 Apr 2008 18:18:36 +0400 mhddfs (0.1.6-1) unstable; urgency=low * New version. * Added debian/watch file. * Upload sponsored by Al Nikolov -- Dmitry E. Oboukhov Sat, 22 Mar 2008 13:06:18 +0300 mhddfs (0.1.5-1) unstable; urgency=low * New version. -- Dmitry E. Oboukhov Sat, 22 Mar 2008 00:55:18 +0300 mhddfs (0.1.4-1) unstable; urgency=low * New release (manpage added). -- Dmitry E. Oboukhov Thu, 20 Mar 2008 23:59:57 +0300 mhddfs (0.1.3-1) unstable; urgency=low * Initial release (Closes: #471880). -- Dmitry E. Oboukhov Thu, 20 Mar 2008 22:23:19 +0300 mhddfs-0.1.39+nmu1ubuntu1/debian/compat0000664000000000000000000000000212145007405014557 0ustar 5 mhddfs-0.1.39+nmu1ubuntu1/debian/copyright0000664000000000000000000000173112145007405015316 0ustar This package was debianized by Dmitry E. Oboukhov on Thu, 20 Mar 2008 22:23:19 +0300. It was downloaded from http://mhddfs.uvw.ru/ Upstream Author: Dmitry E. Oboukhov Copyright: Copyright (C) 2008 Dmitry E. Oboukhov License: This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. On Debian systems, the complete text of the GNU General Public License can be found in `/usr/share/common-licenses/GPL'. The Debian packaging is (C) 2008, Dmitry E. Oboukhov and is licensed under the GPL, see above. mhddfs-0.1.39+nmu1ubuntu1/debian/source/0000775000000000000000000000000012145007556014670 5ustar mhddfs-0.1.39+nmu1ubuntu1/debian/source/format0000664000000000000000000000001512145007405016070 0ustar 3.0 (native) mhddfs-0.1.39+nmu1ubuntu1/debian/manpages0000664000000000000000000000001112145007405015067 0ustar mhddfs.1 mhddfs-0.1.39+nmu1ubuntu1/debian/install0000664000000000000000000000002012145007405014742 0ustar mhddfs /usr/bin mhddfs-0.1.39+nmu1ubuntu1/debian/control0000664000000000000000000000155112145007435014771 0ustar Source: mhddfs Section: utils Priority: extra Maintainer: Ubuntu Developers XSBC-Original-Maintainer: Dmitry E. Oboukhov Build-Depends: debhelper (>= 5), libfuse-dev, pkg-config, libattr1-dev, uthash-dev Standards-Version: 3.8.4 Homepage: http://mhddfs.uvw.ru Vcs-Browser: http://svn.uvw.ru/mhddfs/trunk Package: mhddfs Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, fuse [!kfreebsd-amd64 !kfreebsd-i386] Description: file system for unifying several mount points into one This FUSE-based file system allows mount points (or directories) to be combined, simulating a single big volume which can merge several hard drives or remote file systems. It is like unionfs, but can choose the drive with the most free space to create new files on, and can move data transparently between drives. mhddfs-0.1.39+nmu1ubuntu1/debian/docs0000664000000000000000000000002712145007405014233 0ustar README README.ru.UTF-8 mhddfs-0.1.39+nmu1ubuntu1/COPYING0000664000000000000000000000130612145007405013172 0ustar mhddfs - Multi HDD [FUSE] File System Copyright (C) 2008 Dmitry E. Oboukhov This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see .