vxfs.c revision 2603474ff9be2418900581da1af5cccc9f13cae1
fb0951b02ebf51a93acf12721d8857d31ce57ba3Lennart Poettering/*
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering * volume_id - reads filesystem label and uuid
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering *
3e2147858f21943d5f4a781c60f33ac22c6096edKay Sievers * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
3e2147858f21943d5f4a781c60f33ac22c6096edKay Sievers *
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering * This program is free software; you can redistribute it and/or modify it
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering * under the terms of the GNU General Public License as published by the
5430f7f2bc7330f3088b894166bf3524a067e3d8Lennart Poettering * Free Software Foundation version 2 of the License.
5430f7f2bc7330f3088b894166bf3524a067e3d8Lennart Poettering */
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering#ifndef _GNU_SOURCE
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering#define _GNU_SOURCE 1
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering#endif
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering
5430f7f2bc7330f3088b894166bf3524a067e3d8Lennart Poettering#ifdef HAVE_CONFIG_H
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering# include <config.h>
5430f7f2bc7330f3088b894166bf3524a067e3d8Lennart Poettering#endif
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering#include <stdio.h>
4e949c11a1df4547d5f102e4131e07b026369cd7Javier Jardón#include <stdlib.h>
4e949c11a1df4547d5f102e4131e07b026369cd7Javier Jardón#include <unistd.h>
4e949c11a1df4547d5f102e4131e07b026369cd7Javier Jardón#include <string.h>
139ee8cc316a861bcc8a8ebdf4a8449dffe16f79Lennart Poettering#include <errno.h>
4e949c11a1df4547d5f102e4131e07b026369cd7Javier Jardón#include <ctype.h>
4e949c11a1df4547d5f102e4131e07b026369cd7Javier Jardón
4e949c11a1df4547d5f102e4131e07b026369cd7Javier Jardón#include "libvolume_id.h"
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering#include "libvolume_id-private.h"
78a825f216d39ee0295b00647b059d45467e1d02Kay Sievers#include "util.h"
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering#define VXFS_SUPER_MAGIC 0xa501FCF5
a80db8bd5f7f15859e8891aab9fc3694ce4cd0bdJavier Jardón
a80db8bd5f7f15859e8891aab9fc3694ce4cd0bdJavier Jardónstruct vxfs_super {
4db6d587c37c0357d20c79bf1a7c9afd4c7ced61Kay Sievers uint32_t vs_magic;
907dd1953b7517534d646f5b2777780020c896e2Kay Sievers int32_t vs_version;
eb7bbee6cd182d5c4eb1e1180631c35158f59379Kay Sievers} PACKED;
bbd9b8c2139a70005e4e83d198575e2a10fe1db2Lennart Poettering
3e2147858f21943d5f4a781c60f33ac22c6096edKay Sieversint volume_id_probe_vxfs(struct volume_id *id, uint64_t off, uint64_t size)
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering{
22be093ffb403a1c474037939ca9b88b1ee39f77Lennart Poettering struct vxfs_super *vxs;
d59d0a2b4b41a75eaf618b26b8f8bd1e17de7e2bcee
d59d0a2b4b41a75eaf618b26b8f8bd1e17de7e2bcee info("probing at offset 0x%llx\n", (unsigned long long) off);
d59d0a2b4b41a75eaf618b26b8f8bd1e17de7e2bcee
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering vxs = (struct vxfs_super *) volume_id_get_buffer(id, off + 0x200, 0x200);
3e2147858f21943d5f4a781c60f33ac22c6096edKay Sievers if (vxs == NULL)
3e2147858f21943d5f4a781c60f33ac22c6096edKay Sievers return -1;
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering
1c7dde3e475978c569a982d65fd86d4b4e3caad8Bastien Nocera if (vxs->vs_magic == cpu_to_le32(VXFS_SUPER_MAGIC)) {
1c7dde3e475978c569a982d65fd86d4b4e3caad8Bastien Nocera snprintf(id->type_version, sizeof(id->type_version)-1, "%u", (unsigned int) vxs->vs_version);
1c7dde3e475978c569a982d65fd86d4b4e3caad8Bastien Nocera volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
1c7dde3e475978c569a982d65fd86d4b4e3caad8Bastien Nocera id->type = "vxfs";
1c7dde3e475978c569a982d65fd86d4b4e3caad8Bastien Nocera return 0;
1c7dde3e475978c569a982d65fd86d4b4e3caad8Bastien Nocera }
e9da3678fcfc774b325dc1eaa054d0e00028a1fcLennart Poettering
e9da3678fcfc774b325dc1eaa054d0e00028a1fcLennart Poettering return -1;
e9da3678fcfc774b325dc1eaa054d0e00028a1fcLennart Poettering}
3ce4fad8f548db9edb19869ea540e3192d2123f4Kay Sievers