Task 379: .MCF File Format
Task 379: .MCF File Format
File Format Specifications for the .MCF File Format
The .MCF file format is the Master Configuration File (MCF) used in Oracle/Sun QFS (Quick File System) and SAM-QFS (Storage and Archive Manager for QFS) file systems. It is a plain text file that defines the configuration of file systems and associated devices. The file consists of lines of specification code divided into six columns or fields, separated by spaces or tabs. Comment lines start with '#'. Optional fields can be indicated with a dash ('-'). The format is used to configure file systems, metadata devices, data devices, striped groups, and storage hardware like tape libraries.
- List of all the properties of this file format intrinsic to its file system:
- Equipment Identifier: The device path or name (e.g., /dev/dsk/c2t1d0s7 or file system name).
- Equipment Number: A unique ordinal number assigned to the equipment (e.g., 10, 11).
- Equipment Type: The type code for the equipment (e.g., ma for file system, mm for metadata device, g0 for striped group, md for data device, rb for robot, tp for tape drive).
- Family Set: The family set name that groups related devices (e.g., qfs1).
- Device State: The state of the device (e.g., -, on, off).
- Additional Parameters: Any additional parameters (e.g., shared for shared file systems, or - for none).
- Find two direct download links for files of format .MCF.
- https://www.yaskawa.com/downloads/attachment/264_SGLGW-90A200CP.mcf (Yaskawa motor constant file, .mcf extension)
- https://www.yaskawa.com/downloads/attachment/629_SGLFW2-30A120AS_1.mcf (Yaskawa motor constant file, .mcf extension)
(Note: These are Yaskawa motor constant files using the .mcf extension, though they may have a different internal structure from the QFS MCF. They are publicly referenced as downloadable .mcf files. Access may require site registration.)
- Write a ghost blog embedded html javascript that allows a user to drag n drop a file of format .MCF and it will dump to screen all these properties.
- Write a python class that can open any file of format .MCF and decode read and write and print to console all the properties from the above list.
import os
class MCFParser:
def __init__(self, filename):
self.filename = filename
self.entries = []
self.read()
def read(self):
self.entries = []
with open(self.filename, 'r') as f:
for line in f:
line = line.strip()
if line and not line.startswith('#'):
fields = line.split()
if len(fields) >= 5:
entry = {
'Equipment Identifier': fields[0],
'Equipment Number': fields[1],
'Equipment Type': fields[2],
'Family Set': fields[3],
'Device State': fields[4],
'Additional Parameters': ' '.join(fields[5:]) if len(fields) > 5 else '-'
}
self.entries.append(entry)
def print_properties(self):
for entry in self.entries:
for key, value in entry.items():
print(f"{key}: {value}")
print('---')
def write(self, new_filename):
with open(new_filename, 'w') as f:
f.write('# Equipment Identifier Equipment Number Equipment Type Family Set Device State Additional Parameters\n')
for entry in self.entries:
f.write(f"{entry['Equipment Identifier']} {entry['Equipment Number']} {entry['Equipment Type']} {entry['Family Set']} {entry['Device State']} {entry['Additional Parameters']}\n")
# Example usage:
# parser = MCFParser('example.mcf')
# parser.print_properties()
# parser.write('new.mcf')
- Write a java class that can open any file of format .MCF and decode read and write and print to console all the properties from the above list.
import java.io.*;
import java.util.*;
public class MCFParser {
private String filename;
private List<Map<String, String>> entries = new ArrayList<>();
public MCFParser(String filename) {
this.filename = filename;
read();
}
public void read() {
entries.clear();
try (BufferedReader br = new BufferedReader(new FileReader(filename))) {
String line;
while ((line = br.readLine()) != null) {
line = line.trim();
if (!line.isEmpty() && !line.startsWith("#")) {
String[] fields = line.split("\\s+");
if (fields.length >= 5) {
Map<String, String> entry = new LinkedHashMap<>();
entry.put("Equipment Identifier", fields[0]);
entry.put("Equipment Number", fields[1]);
entry.put("Equipment Type", fields[2]);
entry.put("Family Set", fields[3]);
entry.put("Device State", fields[4]);
String additional = (fields.length > 5) ? String.join(" ", Arrays.copyOfRange(fields, 5, fields.length)) : "-";
entry.put("Additional Parameters", additional);
entries.add(entry);
}
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
public void printProperties() {
for (Map<String, String> entry : entries) {
for (Map.Entry<String, String> kv : entry.entrySet()) {
System.out.println(kv.getKey() + ": " + kv.getValue());
}
System.out.println("---");
}
}
public void write(String newFilename) {
try (PrintWriter pw = new PrintWriter(new File(newFilename))) {
pw.println("# Equipment Identifier Equipment Number Equipment Type Family Set Device State Additional Parameters");
for (Map<String, String> entry : entries) {
pw.printf("%s %s %s %s %s %s%n",
entry.get("Equipment Identifier"),
entry.get("Equipment Number"),
entry.get("Equipment Type"),
entry.get("Family Set"),
entry.get("Device State"),
entry.get("Additional Parameters"));
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
// Example usage:
// public static void main(String[] args) {
// MCFParser parser = new MCFParser("example.mcf");
// parser.printProperties();
// parser.write("new.mcf");
// }
}
- Write a javascript class that can open any file of format .MCF and decode read and write and print to console all the properties from the above list.
(Note: This is for Node.js, as browser JS cannot directly open files from disk without user input.)
const fs = require('fs');
class MCFParser {
constructor(filename) {
this.filename = filename;
this.entries = [];
this.read();
}
read() {
this.entries = [];
const text = fs.readFileSync(this.filename, 'utf8');
const lines = text.split('\n');
lines.forEach(line => {
line = line.trim();
if (line && !line.startsWith('#')) {
const fields = line.split(/\s+/);
if (fields.length >= 5) {
const entry = {
'Equipment Identifier': fields[0],
'Equipment Number': fields[1],
'Equipment Type': fields[2],
'Family Set': fields[3],
'Device State': fields[4],
'Additional Parameters': fields.slice(5).join(' ') || '-'
};
this.entries.push(entry);
}
}
});
}
printProperties() {
this.entries.forEach(entry => {
Object.entries(entry).forEach(([key, value]) => {
console.log(`${key}: ${value}`);
});
console.log('---');
});
}
write(newFilename) {
let content = '# Equipment Identifier Equipment Number Equipment Type Family Set Device State Additional Parameters\n';
this.entries.forEach(entry => {
content += `${entry['Equipment Identifier']} ${entry['Equipment Number']} ${entry['Equipment Type']} ${entry['Family Set']} ${entry['Device State']} ${entry['Additional Parameters']}\n`;
});
fs.writeFileSync(newFilename, content);
}
}
// Example usage:
// const parser = new MCFParser('example.mcf');
// parser.printProperties();
// parser.write('new.mcf');
- Write a c class that can open any file of format .MCF and decode read and write and print to console all the properties from the above list.
(Note: C does not have built-in "classes," so this is implemented in C++ for class structure.)
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <sstream>
#include <string>
class MCFParser {
private:
std::string filename;
std::vector<std::map<std::string, std::string>> entries;
public:
MCFParser(const std::string& fn) : filename(fn) {
read();
}
void read() {
entries.clear();
std::ifstream file(filename);
if (!file.is_open()) {
std::cerr << "Error opening file: " << filename << std::endl;
return;
}
std::string line;
while (std::getline(file, line)) {
line.erase(0, line.find_first_not_of(" \t"));
line.erase(line.find_last_not_of(" \t") + 1);
if (!line.empty() && line[0] != '#') {
std::istringstream iss(line);
std::vector<std::string> fields;
std::string field;
while (iss >> field) {
fields.push_back(field);
}
if (fields.size() >= 5) {
std::map<std::string, std::string> entry;
entry["Equipment Identifier"] = fields[0];
entry["Equipment Number"] = fields[1];
entry["Equipment Type"] = fields[2];
entry["Family Set"] = fields[3];
entry["Device State"] = fields[4];
std::string additional = "-";
if (fields.size() > 5) {
additional = "";
for (size_t i = 5; i < fields.size(); ++i) {
additional += fields[i] + " ";
}
additional.pop_back(); // Remove trailing space
}
entry["Additional Parameters"] = additional;
entries.push_back(entry);
}
}
}
file.close();
}
void printProperties() const {
for (const auto& entry : entries) {
for (const auto& kv : entry) {
std::cout << kv.first << ": " << kv.second << std::endl;
}
std::cout << "---" << std::endl;
}
}
void write(const std::string& newFilename) const {
std::ofstream file(newFilename);
if (!file.is_open()) {
std::cerr << "Error opening file for writing: " << newFilename << std::endl;
return;
}
file << "# Equipment Identifier Equipment Number Equipment Type Family Set Device State Additional Parameters" << std::endl;
for (const auto& entry : entries) {
file << entry.at("Equipment Identifier") << " "
<< entry.at("Equipment Number") << " "
<< entry.at("Equipment Type") << " "
<< entry.at("Family Set") << " "
<< entry.at("Device State") << " "
<< entry.at("Additional Parameters") << std::endl;
}
file.close();
}
};
// Example usage:
// int main() {
// MCFParser parser("example.mcf");
// parser.printProperties();
// parser.write("new.mcf");
// return 0;
// }