Ignore:
Timestamp:
2025-06-29T23:21:19Z (9 months ago)
Author:
Miroslav Cimerman <mc@…>
Children:
640250b
Parents:
b81ae12
Message:

hr: encoding and saving MD metadata support

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/bd/hr/metadata/foreign/md/md_p.h

    rb81ae12 r7ef5ea2  
    3333
    3434#define MD_MAGIC 0xa92b4efc
     35
     36#define MD_DISK_SYNC 2
    3537
    3638/*
     
    130132};
    131133
    132 /* from mdadm.h */
     134/*
     135 * mdadm - manage Linux "md" devices aka RAID arrays.
     136 *
     137 * Copyright (C) 2001-2016 Neil Brown <neilb@suse.com>
     138 *
     139 *
     140 *    This program is free software; you can redistribute it and/or modify
     141 *    it under the terms of the GNU General Public License as published by
     142 *    the Free Software Foundation; either version 2 of the License, or
     143 *    (at your option) any later version.
     144 *
     145 *    This program is distributed in the hope that it will be useful,
     146 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
     147 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     148 *    GNU General Public License for more details.
     149 *
     150 *    You should have received a copy of the GNU General Public License
     151 *    along with this program; if not, write to the Free Software
     152 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     153 *
     154 *    Author: Neil Brown
     155 *    Email: <neilb@suse.de>
     156 */
     157
     158/* from mdadm - mdadm.h*/
    133159#define ALGORITHM_LEFT_ASYMMETRIC       0
    134160#define ALGORITHM_RIGHT_ASYMMETRIC      1
    135161#define ALGORITHM_LEFT_SYMMETRIC        2
     162
     163/* from mdadm - super1.c */
     164static inline unsigned int calc_sb_1_csum(struct mdp_superblock_1 * sb)
     165{
     166        unsigned int disk_csum, csum;
     167        unsigned long long newcsum;
     168        int size = sizeof(*sb) + uint32_t_le2host(sb->max_dev)*2;
     169        unsigned int *isuper = (unsigned int *)sb;
     170
     171/* make sure I can count... */
     172        if (offsetof(struct mdp_superblock_1,data_offset) != 128 ||
     173            offsetof(struct mdp_superblock_1, utime) != 192 ||
     174            sizeof(struct mdp_superblock_1) != 256) {
     175                fprintf(stderr, "WARNING - superblock isn't sized correctly\n");
     176        }
     177
     178        disk_csum = sb->sb_csum;
     179        sb->sb_csum = 0;
     180        newcsum = 0;
     181        for (; size >= 4; size -= 4) {
     182                newcsum += uint32_t_le2host(*isuper);
     183                isuper++;
     184        }
     185
     186        if (size == 2)
     187                newcsum += uint32_t_le2host(*(unsigned short*) isuper);
     188
     189        csum = (newcsum & 0xffffffff) + (newcsum >> 32);
     190        sb->sb_csum = disk_csum;
     191        return host2uint32_t_le(csum);
     192}
    136193
    137194#endif
Note: See TracChangeset for help on using the changeset viewer.