Mirror of git://git.busybox.net/busybox with our patches on top
Source
xxxxxxxxxx
blkid_set_tag(dev, "LABEL", (const char*)osb->s_label, sizeof(osb->s_label));
/* vi: set sw=4 ts=4: */
/*
* probe.c - identify a block device by its contents, and return a dev
* struct with the details
*
* Copyright (C) 1999 by Andries Brouwer
* Copyright (C) 1999, 2000, 2003 by Theodore Ts'o
* Copyright (C) 2001 by Andreas Dilger
*
* %Begin-Header%
* This file may be redistributed under the terms of the
* GNU Lesser General Public License.
* %End-Header%
*/
/*
* This is a special case code to check for an MDRAID device. We do
* this special since it requires checking for a superblock at the end
* of the device.
*/
static int check_mdraid(int fd, unsigned char *ret_uuid)
{
struct mdp_superblock_s *md;
blkid_loff_t offset;
char buf[4096];
if (fd < 0)
return -BLKID_ERR_PARAM;
offset = (blkid_get_dev_size(fd) & ~((blkid_loff_t)65535)) - 65536;
if (blkid_llseek(fd, offset, 0) < 0 ||
read(fd, buf, 4096) != 4096)
return -BLKID_ERR_IO;
/* Check for magic number */
if (memcmp("\251+N\374", buf, 4))
return -BLKID_ERR_PARAM;
if (!ret_uuid)
return 0;
*ret_uuid = 0;
/* The MD UUID is not contiguous in the superblock, make it so */
md = (struct mdp_superblock_s *)buf;
if (md->set_uuid0 || md->set_uuid1 || md->set_uuid2 || md->set_uuid3) {
memcpy(ret_uuid, &md->set_uuid0, 4);
memcpy(ret_uuid, &md->set_uuid1, 12);
}
return 0;
}
static void set_uuid(blkid_dev dev, uuid_t uuid)
{
char str[37];
if (!uuid_is_null(uuid)) {
uuid_unparse(uuid, str);
blkid_set_tag(dev, "UUID", str, sizeof(str));
}
}
static void get_ext2_info(blkid_dev dev, unsigned char *buf)
{
struct ext2_super_block *es = (struct ext2_super_block *) buf;
const char *label = NULL;
DBG(DEBUG_PROBE, printf("ext2_sb.compat = %08X:%08X:%08X\n",
blkid_le32(es->s_feature_compat),
blkid_le32(es->s_feature_incompat),
blkid_le32(es->s_feature_ro_compat)));
if (strlen(es->s_volume_name))