conga ricci/modules/storage/ExtendedFS.cpp ric ...
CVSROOT: /cvs/cluster
Module name: conga
Changes by: kupcevic at sourceware.org 2006-09-14 17:52:04
Modified files:
ricci/modules/storage: ExtendedFS.cpp Makefile SwapFS.cpp
. : conga.spec.in.in
Added files:
ricci/modules/storage: FileMagic.h FileMagic.cpp
Log message:
storage module: use libmagic instead of executing "file" command
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/FileMagic.h.diff?cvsroot=cluster&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/FileMagic.cpp.diff?cvsroot=cluster&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/ExtendedFS.cpp.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/Makefile.diff?cvsroot=cluster&r1=1.10&r2=1.11
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/SwapFS.cpp.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/conga.spec.in.in.diff?cvsroot=cluster&r1=1.40&r2=1.41
/cvs/cluster/conga/ricci/modules/storage/FileMagic.h,v --> standard output revision 1.1
- renamed from ricci/modules/storage/FileMagic.h +37 -0
@@ -0,0 +1,37 @@ +/* + Copyright Red Hat, Inc. 2006 + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 675 Mass Ave, Cambridge, + MA 02139, USA. +*/ +/* + * Author: Stanko Kupcevic <[email protected]> + */ + + +#ifndef FileMagic_h +#define FileMagic_h + +#include "String.h" + + +class FileMagic +{ + public: + static String get_description(const String& filename); +}; + + +#endif // GlobalFS_h
/cvs/cluster/conga/ricci/modules/storage/FileMagic.cpp,v --> standard output revision 1.1
- renamed from ricci/modules/storage/FileMagic.cpp +75 -0
75 lines not on this page · raw message
ricci/modules/storage/ExtendedFS.cpp +7 -14
@@ -26,6 +26,7 @@ #include "MountHandler.h" #include "defines.h" #include "UMountError.h" +#include "FileMagic.h" #include <iostream>
@@ -42,23 +43,15 @@ ContentFS("extended_fs", path), _journaled(false) { - vector<String> args; - args.push_back("-s"); - args.push_back("-L"); - args.push_back(path); + String magic(FileMagic::get_description(path)); + if (magic.find("ext3") == magic.npos && + magic.find("ext2") == magic.npos) + throw String(path + " not extended_fs"); + // dumpe2fs String out, err; int status; - if (utils::execute("/usr/bin/file", args, out, err, status)) - throw String("execute failed"); - if (status) - throw String("file failed"); - if (out.find("ext3") == out.npos && - out.find("ext2") == out.npos) - throw String("not extended_fs"); - - // dumpe2fs - args.clear(); + vector<String> args; args.push_back("-h"); args.push_back(path); if (utils::execute("/sbin/dumpe2fs", args, out, err, status))
ricci/modules/storage/Makefile +2 -1
@@ -17,6 +17,7 @@ TARGET = ricci-modstorage OBJECTS = main.o \ + FileMagic.o \ Props.o \ BD.o \ Content.o \
@@ -52,7 +53,7 @@ INCLUDE += CXXFLAGS += -LDFLAGS += +LDFLAGS += -lmagic all: ${TARGET}
ricci/modules/storage/SwapFS.cpp +4 -14
@@ -25,6 +25,7 @@ #include "utils.h" #include "MountHandler.h" #include "UMountError.h" +#include "FileMagic.h" using namespace std;
@@ -33,20 +34,9 @@ SwapFS::SwapFS(const String& path) : ContentFS("swap", path) { - vector<String> args; - args.push_back("-s"); - args.push_back("-L"); - args.push_back(path); - - String out, err; - int status; - if (utils::execute("/usr/bin/file", args, out, err, status)) - throw String("execute failed"); - if (status) - throw String("file failed"); - - if (out.find("swap") == out.npos) - throw String(path + "not swap"); + String magic(FileMagic::get_description(path)); + if (magic.find("swap") == magic.npos) + throw String(path + " not swap"); // swapon MountHandler mh;
conga.spec.in.in +1 -1
@@ -40,7 +40,7 @@ BuildRequires: python-devel >= 2.4.1 %endif BuildRequires: glibc-devel gcc-c++ libxml2-devel sed -BuildRequires: openssl-devel dbus-devel pam-devel pkgconfig +BuildRequires: openssl-devel dbus-devel pam-devel pkgconfig file %description Conga is a project developing management system for remote stations.