yast2-storage

Parted.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) [2004-2010] Novell, Inc.
00003  *
00004  * All Rights Reserved.
00005  *
00006  * This program is free software; you can redistribute it and/or modify it
00007  * under the terms of version 2 of the GNU General Public License as published
00008  * by the Free Software Foundation.
00009  *
00010  * This program is distributed in the hope that it will be useful, but WITHOUT
00011  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
00013  * more details.
00014  *
00015  * You should have received a copy of the GNU General Public License along
00016  * with this program; if not, contact Novell, Inc.
00017  *
00018  * To contact Novell about this file by physical or electronic mail, you may
00019  * find current contact information at www.novell.com.
00020  */
00021 
00022 
00023 #ifndef PARTED_H
00024 #define PARTED_H
00025 
00026 #include "storage/StorageInterface.h"
00027 #include "storage/Geometry.h"
00028 #include "storage/Region.h"
00029 
00030 
00031 namespace storage
00032 {
00033 
00034     class Parted
00035     {
00036 
00037     public:
00038 
00039         Parted(const string& device);
00040 
00041         struct Entry
00042         {
00043             Entry() : num(0), type(PRIMARY), id(0), boot(false) {}
00044 
00045             unsigned num;
00046             Region cylRegion;
00047             Region secRegion;
00048             PartitionType type;
00049             unsigned id;
00050             bool boot;
00051 
00052             friend std::ostream& operator<<(std::ostream& s, const Entry& e);
00053         };
00054 
00055         const string& getLabel() const { return label; }
00056         const Geometry& getGeometry() const { return geometry; }
00057         bool getGptEnlarge() const { return gpt_enlarge; }
00058 
00059         typedef vector<Entry>::const_iterator const_iterator;
00060 
00061         const vector<Entry>& getEntries() const { return entries; }
00062 
00063         bool getEntry(unsigned num, Entry& entry) const;
00064 
00065     private:
00066 
00067         typedef vector<Entry>::iterator iterator;
00068 
00069         string label;
00070         Geometry geometry;
00071         bool gpt_enlarge;
00072         vector<Entry> entries;
00073 
00074         void scanSectorSizeLine(const string& line);
00075         void scanGeometryLine(const string& line);
00076         void scanCylEntryLine(const string& line);
00077         void scanSecEntryLine(const string& line);
00078 
00079     };
00080 
00081 }
00082 
00083 
00084 #endif