fix: 把内核恢复成 GitHub 原版
This commit is contained in:
@@ -1,92 +1,92 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/*
|
||||
* CPU <-> hardware queue mapping helpers
|
||||
*
|
||||
* Copyright (C) 2013-2014 Jens Axboe
|
||||
*/
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/threads.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/mm.h>
|
||||
#include <linux/smp.h>
|
||||
#include <linux/cpu.h>
|
||||
#include <linux/group_cpus.h>
|
||||
#include <linux/device/bus.h>
|
||||
|
||||
#include "blk.h"
|
||||
#include "blk-mq.h"
|
||||
|
||||
void blk_mq_map_queues(struct blk_mq_queue_map *qmap)
|
||||
{
|
||||
const struct cpumask *masks;
|
||||
unsigned int queue, cpu;
|
||||
|
||||
masks = group_cpus_evenly(qmap->nr_queues);
|
||||
if (!masks) {
|
||||
for_each_possible_cpu(cpu)
|
||||
qmap->mq_map[cpu] = qmap->queue_offset;
|
||||
return;
|
||||
}
|
||||
|
||||
for (queue = 0; queue < qmap->nr_queues; queue++) {
|
||||
for_each_cpu(cpu, &masks[queue])
|
||||
qmap->mq_map[cpu] = qmap->queue_offset + queue;
|
||||
}
|
||||
kfree(masks);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(blk_mq_map_queues);
|
||||
|
||||
/**
|
||||
* blk_mq_hw_queue_to_node - Look up the memory node for a hardware queue index
|
||||
* @qmap: CPU to hardware queue map.
|
||||
* @index: hardware queue index.
|
||||
*
|
||||
* We have no quick way of doing reverse lookups. This is only used at
|
||||
* queue init time, so runtime isn't important.
|
||||
*/
|
||||
int blk_mq_hw_queue_to_node(struct blk_mq_queue_map *qmap, unsigned int index)
|
||||
{
|
||||
int i;
|
||||
|
||||
for_each_possible_cpu(i) {
|
||||
if (index == qmap->mq_map[i])
|
||||
return cpu_to_node(i);
|
||||
}
|
||||
|
||||
return NUMA_NO_NODE;
|
||||
}
|
||||
|
||||
/**
|
||||
* blk_mq_map_hw_queues - Create CPU to hardware queue mapping
|
||||
* @qmap: CPU to hardware queue map
|
||||
* @dev: The device to map queues
|
||||
* @offset: Queue offset to use for the device
|
||||
*
|
||||
* Create a CPU to hardware queue mapping in @qmap. The struct bus_type
|
||||
* irq_get_affinity callback will be used to retrieve the affinity.
|
||||
*/
|
||||
void blk_mq_map_hw_queues(struct blk_mq_queue_map *qmap,
|
||||
struct device *dev, unsigned int offset)
|
||||
|
||||
{
|
||||
const struct cpumask *mask;
|
||||
unsigned int queue, cpu;
|
||||
|
||||
if (!dev->bus->irq_get_affinity)
|
||||
goto fallback;
|
||||
|
||||
for (queue = 0; queue < qmap->nr_queues; queue++) {
|
||||
mask = dev->bus->irq_get_affinity(dev, queue + offset);
|
||||
if (!mask)
|
||||
goto fallback;
|
||||
|
||||
for_each_cpu(cpu, mask)
|
||||
qmap->mq_map[cpu] = qmap->queue_offset + queue;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
fallback:
|
||||
blk_mq_map_queues(qmap);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(blk_mq_map_hw_queues);
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/*
|
||||
* CPU <-> hardware queue mapping helpers
|
||||
*
|
||||
* Copyright (C) 2013-2014 Jens Axboe
|
||||
*/
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/threads.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/mm.h>
|
||||
#include <linux/smp.h>
|
||||
#include <linux/cpu.h>
|
||||
#include <linux/group_cpus.h>
|
||||
#include <linux/device/bus.h>
|
||||
|
||||
#include "blk.h"
|
||||
#include "blk-mq.h"
|
||||
|
||||
void blk_mq_map_queues(struct blk_mq_queue_map *qmap)
|
||||
{
|
||||
const struct cpumask *masks;
|
||||
unsigned int queue, cpu;
|
||||
|
||||
masks = group_cpus_evenly(qmap->nr_queues);
|
||||
if (!masks) {
|
||||
for_each_possible_cpu(cpu)
|
||||
qmap->mq_map[cpu] = qmap->queue_offset;
|
||||
return;
|
||||
}
|
||||
|
||||
for (queue = 0; queue < qmap->nr_queues; queue++) {
|
||||
for_each_cpu(cpu, &masks[queue])
|
||||
qmap->mq_map[cpu] = qmap->queue_offset + queue;
|
||||
}
|
||||
kfree(masks);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(blk_mq_map_queues);
|
||||
|
||||
/**
|
||||
* blk_mq_hw_queue_to_node - Look up the memory node for a hardware queue index
|
||||
* @qmap: CPU to hardware queue map.
|
||||
* @index: hardware queue index.
|
||||
*
|
||||
* We have no quick way of doing reverse lookups. This is only used at
|
||||
* queue init time, so runtime isn't important.
|
||||
*/
|
||||
int blk_mq_hw_queue_to_node(struct blk_mq_queue_map *qmap, unsigned int index)
|
||||
{
|
||||
int i;
|
||||
|
||||
for_each_possible_cpu(i) {
|
||||
if (index == qmap->mq_map[i])
|
||||
return cpu_to_node(i);
|
||||
}
|
||||
|
||||
return NUMA_NO_NODE;
|
||||
}
|
||||
|
||||
/**
|
||||
* blk_mq_map_hw_queues - Create CPU to hardware queue mapping
|
||||
* @qmap: CPU to hardware queue map
|
||||
* @dev: The device to map queues
|
||||
* @offset: Queue offset to use for the device
|
||||
*
|
||||
* Create a CPU to hardware queue mapping in @qmap. The struct bus_type
|
||||
* irq_get_affinity callback will be used to retrieve the affinity.
|
||||
*/
|
||||
void blk_mq_map_hw_queues(struct blk_mq_queue_map *qmap,
|
||||
struct device *dev, unsigned int offset)
|
||||
|
||||
{
|
||||
const struct cpumask *mask;
|
||||
unsigned int queue, cpu;
|
||||
|
||||
if (!dev->bus->irq_get_affinity)
|
||||
goto fallback;
|
||||
|
||||
for (queue = 0; queue < qmap->nr_queues; queue++) {
|
||||
mask = dev->bus->irq_get_affinity(dev, queue + offset);
|
||||
if (!mask)
|
||||
goto fallback;
|
||||
|
||||
for_each_cpu(cpu, mask)
|
||||
qmap->mq_map[cpu] = qmap->queue_offset + queue;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
fallback:
|
||||
blk_mq_map_queues(qmap);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(blk_mq_map_hw_queues);
|
||||
|
||||
@@ -1,85 +1,85 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
#ifndef BLK_MQ_SCHED_H
|
||||
#define BLK_MQ_SCHED_H
|
||||
|
||||
#include "elevator.h"
|
||||
#include "blk-mq.h"
|
||||
|
||||
#define MAX_SCHED_RQ (16 * BLKDEV_DEFAULT_RQ)
|
||||
|
||||
bool blk_mq_sched_try_merge(struct request_queue *q, struct bio *bio,
|
||||
unsigned int nr_segs, struct request **merged_request);
|
||||
bool blk_mq_sched_bio_merge(struct request_queue *q, struct bio *bio,
|
||||
unsigned int nr_segs);
|
||||
bool blk_mq_sched_try_insert_merge(struct request_queue *q, struct request *rq,
|
||||
struct list_head *free);
|
||||
void blk_mq_sched_mark_restart_hctx(struct blk_mq_hw_ctx *hctx);
|
||||
void __blk_mq_sched_restart(struct blk_mq_hw_ctx *hctx);
|
||||
|
||||
void blk_mq_sched_dispatch_requests(struct blk_mq_hw_ctx *hctx);
|
||||
|
||||
int blk_mq_init_sched(struct request_queue *q, struct elevator_type *e);
|
||||
void blk_mq_exit_sched(struct request_queue *q, struct elevator_queue *e);
|
||||
void blk_mq_sched_free_rqs(struct request_queue *q);
|
||||
|
||||
static inline void blk_mq_sched_restart(struct blk_mq_hw_ctx *hctx)
|
||||
{
|
||||
if (test_bit(BLK_MQ_S_SCHED_RESTART, &hctx->state))
|
||||
__blk_mq_sched_restart(hctx);
|
||||
}
|
||||
|
||||
static inline bool bio_mergeable(struct bio *bio)
|
||||
{
|
||||
return !(bio->bi_opf & REQ_NOMERGE_FLAGS);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
blk_mq_sched_allow_merge(struct request_queue *q, struct request *rq,
|
||||
struct bio *bio)
|
||||
{
|
||||
if (rq->rq_flags & RQF_USE_SCHED) {
|
||||
struct elevator_queue *e = q->elevator;
|
||||
|
||||
if (e->type->ops.allow_merge)
|
||||
return e->type->ops.allow_merge(q, rq, bio);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline void blk_mq_sched_completed_request(struct request *rq, u64 now)
|
||||
{
|
||||
if (rq->rq_flags & RQF_USE_SCHED) {
|
||||
struct elevator_queue *e = rq->q->elevator;
|
||||
|
||||
if (e->type->ops.completed_request)
|
||||
e->type->ops.completed_request(rq, now);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void blk_mq_sched_requeue_request(struct request *rq)
|
||||
{
|
||||
if (rq->rq_flags & RQF_USE_SCHED) {
|
||||
struct request_queue *q = rq->q;
|
||||
struct elevator_queue *e = q->elevator;
|
||||
|
||||
if (e->type->ops.requeue_request)
|
||||
e->type->ops.requeue_request(rq);
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool blk_mq_sched_has_work(struct blk_mq_hw_ctx *hctx)
|
||||
{
|
||||
struct elevator_queue *e = hctx->queue->elevator;
|
||||
|
||||
if (e && e->type->ops.has_work)
|
||||
return e->type->ops.has_work(hctx);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline bool blk_mq_sched_needs_restart(struct blk_mq_hw_ctx *hctx)
|
||||
{
|
||||
return test_bit(BLK_MQ_S_SCHED_RESTART, &hctx->state);
|
||||
}
|
||||
|
||||
#endif
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
#ifndef BLK_MQ_SCHED_H
|
||||
#define BLK_MQ_SCHED_H
|
||||
|
||||
#include "elevator.h"
|
||||
#include "blk-mq.h"
|
||||
|
||||
#define MAX_SCHED_RQ (16 * BLKDEV_DEFAULT_RQ)
|
||||
|
||||
bool blk_mq_sched_try_merge(struct request_queue *q, struct bio *bio,
|
||||
unsigned int nr_segs, struct request **merged_request);
|
||||
bool blk_mq_sched_bio_merge(struct request_queue *q, struct bio *bio,
|
||||
unsigned int nr_segs);
|
||||
bool blk_mq_sched_try_insert_merge(struct request_queue *q, struct request *rq,
|
||||
struct list_head *free);
|
||||
void blk_mq_sched_mark_restart_hctx(struct blk_mq_hw_ctx *hctx);
|
||||
void __blk_mq_sched_restart(struct blk_mq_hw_ctx *hctx);
|
||||
|
||||
void blk_mq_sched_dispatch_requests(struct blk_mq_hw_ctx *hctx);
|
||||
|
||||
int blk_mq_init_sched(struct request_queue *q, struct elevator_type *e);
|
||||
void blk_mq_exit_sched(struct request_queue *q, struct elevator_queue *e);
|
||||
void blk_mq_sched_free_rqs(struct request_queue *q);
|
||||
|
||||
static inline void blk_mq_sched_restart(struct blk_mq_hw_ctx *hctx)
|
||||
{
|
||||
if (test_bit(BLK_MQ_S_SCHED_RESTART, &hctx->state))
|
||||
__blk_mq_sched_restart(hctx);
|
||||
}
|
||||
|
||||
static inline bool bio_mergeable(struct bio *bio)
|
||||
{
|
||||
return !(bio->bi_opf & REQ_NOMERGE_FLAGS);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
blk_mq_sched_allow_merge(struct request_queue *q, struct request *rq,
|
||||
struct bio *bio)
|
||||
{
|
||||
if (rq->rq_flags & RQF_USE_SCHED) {
|
||||
struct elevator_queue *e = q->elevator;
|
||||
|
||||
if (e->type->ops.allow_merge)
|
||||
return e->type->ops.allow_merge(q, rq, bio);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline void blk_mq_sched_completed_request(struct request *rq, u64 now)
|
||||
{
|
||||
if (rq->rq_flags & RQF_USE_SCHED) {
|
||||
struct elevator_queue *e = rq->q->elevator;
|
||||
|
||||
if (e->type->ops.completed_request)
|
||||
e->type->ops.completed_request(rq, now);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void blk_mq_sched_requeue_request(struct request *rq)
|
||||
{
|
||||
if (rq->rq_flags & RQF_USE_SCHED) {
|
||||
struct request_queue *q = rq->q;
|
||||
struct elevator_queue *e = q->elevator;
|
||||
|
||||
if (e->type->ops.requeue_request)
|
||||
e->type->ops.requeue_request(rq);
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool blk_mq_sched_has_work(struct blk_mq_hw_ctx *hctx)
|
||||
{
|
||||
struct elevator_queue *e = hctx->queue->elevator;
|
||||
|
||||
if (e && e->type->ops.has_work)
|
||||
return e->type->ops.has_work(hctx);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline bool blk_mq_sched_needs_restart(struct blk_mq_hw_ctx *hctx)
|
||||
{
|
||||
return test_bit(BLK_MQ_S_SCHED_RESTART, &hctx->state);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,69 +1,69 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
#include <linux/pagemap.h>
|
||||
#include <linux/blkdev.h>
|
||||
#include "../blk.h"
|
||||
|
||||
/*
|
||||
* add_gd_partition adds a partitions details to the devices partition
|
||||
* description.
|
||||
*/
|
||||
struct parsed_partitions {
|
||||
struct gendisk *disk;
|
||||
char name[BDEVNAME_SIZE];
|
||||
struct {
|
||||
sector_t from;
|
||||
sector_t size;
|
||||
int flags;
|
||||
bool has_info;
|
||||
struct partition_meta_info info;
|
||||
} *parts;
|
||||
int next;
|
||||
int limit;
|
||||
bool access_beyond_eod;
|
||||
char *pp_buf;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
struct folio *v;
|
||||
} Sector;
|
||||
|
||||
void *read_part_sector(struct parsed_partitions *state, sector_t n, Sector *p);
|
||||
static inline void put_dev_sector(Sector p)
|
||||
{
|
||||
folio_put(p.v);
|
||||
}
|
||||
|
||||
static inline void
|
||||
put_partition(struct parsed_partitions *p, int n, sector_t from, sector_t size)
|
||||
{
|
||||
if (n < p->limit) {
|
||||
char tmp[1 + BDEVNAME_SIZE + 10 + 1];
|
||||
|
||||
p->parts[n].from = from;
|
||||
p->parts[n].size = size;
|
||||
snprintf(tmp, sizeof(tmp), " %s%d", p->name, n);
|
||||
strlcat(p->pp_buf, tmp, PAGE_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
/* detection routines go here in alphabetical order: */
|
||||
int adfspart_check_ADFS(struct parsed_partitions *state);
|
||||
int adfspart_check_CUMANA(struct parsed_partitions *state);
|
||||
int adfspart_check_EESOX(struct parsed_partitions *state);
|
||||
int adfspart_check_ICS(struct parsed_partitions *state);
|
||||
int adfspart_check_POWERTEC(struct parsed_partitions *state);
|
||||
int aix_partition(struct parsed_partitions *state);
|
||||
int amiga_partition(struct parsed_partitions *state);
|
||||
int atari_partition(struct parsed_partitions *state);
|
||||
int cmdline_partition(struct parsed_partitions *state);
|
||||
int efi_partition(struct parsed_partitions *state);
|
||||
int ibm_partition(struct parsed_partitions *);
|
||||
int karma_partition(struct parsed_partitions *state);
|
||||
int ldm_partition(struct parsed_partitions *state);
|
||||
int mac_partition(struct parsed_partitions *state);
|
||||
int msdos_partition(struct parsed_partitions *state);
|
||||
int osf_partition(struct parsed_partitions *state);
|
||||
int sgi_partition(struct parsed_partitions *state);
|
||||
int sun_partition(struct parsed_partitions *state);
|
||||
int sysv68_partition(struct parsed_partitions *state);
|
||||
int ultrix_partition(struct parsed_partitions *state);
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
#include <linux/pagemap.h>
|
||||
#include <linux/blkdev.h>
|
||||
#include "../blk.h"
|
||||
|
||||
/*
|
||||
* add_gd_partition adds a partitions details to the devices partition
|
||||
* description.
|
||||
*/
|
||||
struct parsed_partitions {
|
||||
struct gendisk *disk;
|
||||
char name[BDEVNAME_SIZE];
|
||||
struct {
|
||||
sector_t from;
|
||||
sector_t size;
|
||||
int flags;
|
||||
bool has_info;
|
||||
struct partition_meta_info info;
|
||||
} *parts;
|
||||
int next;
|
||||
int limit;
|
||||
bool access_beyond_eod;
|
||||
char *pp_buf;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
struct folio *v;
|
||||
} Sector;
|
||||
|
||||
void *read_part_sector(struct parsed_partitions *state, sector_t n, Sector *p);
|
||||
static inline void put_dev_sector(Sector p)
|
||||
{
|
||||
folio_put(p.v);
|
||||
}
|
||||
|
||||
static inline void
|
||||
put_partition(struct parsed_partitions *p, int n, sector_t from, sector_t size)
|
||||
{
|
||||
if (n < p->limit) {
|
||||
char tmp[1 + BDEVNAME_SIZE + 10 + 1];
|
||||
|
||||
p->parts[n].from = from;
|
||||
p->parts[n].size = size;
|
||||
snprintf(tmp, sizeof(tmp), " %s%d", p->name, n);
|
||||
strlcat(p->pp_buf, tmp, PAGE_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
/* detection routines go here in alphabetical order: */
|
||||
int adfspart_check_ADFS(struct parsed_partitions *state);
|
||||
int adfspart_check_CUMANA(struct parsed_partitions *state);
|
||||
int adfspart_check_EESOX(struct parsed_partitions *state);
|
||||
int adfspart_check_ICS(struct parsed_partitions *state);
|
||||
int adfspart_check_POWERTEC(struct parsed_partitions *state);
|
||||
int aix_partition(struct parsed_partitions *state);
|
||||
int amiga_partition(struct parsed_partitions *state);
|
||||
int atari_partition(struct parsed_partitions *state);
|
||||
int cmdline_partition(struct parsed_partitions *state);
|
||||
int efi_partition(struct parsed_partitions *state);
|
||||
int ibm_partition(struct parsed_partitions *);
|
||||
int karma_partition(struct parsed_partitions *state);
|
||||
int ldm_partition(struct parsed_partitions *state);
|
||||
int mac_partition(struct parsed_partitions *state);
|
||||
int msdos_partition(struct parsed_partitions *state);
|
||||
int osf_partition(struct parsed_partitions *state);
|
||||
int sgi_partition(struct parsed_partitions *state);
|
||||
int sun_partition(struct parsed_partitions *state);
|
||||
int sysv68_partition(struct parsed_partitions *state);
|
||||
int ultrix_partition(struct parsed_partitions *state);
|
||||
|
||||
@@ -1,87 +1,87 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/*
|
||||
* fs/partitions/osf.c
|
||||
*
|
||||
* Code extracted from drivers/block/genhd.c
|
||||
*
|
||||
* Copyright (C) 1991-1998 Linus Torvalds
|
||||
* Re-organised Feb 1998 Russell King
|
||||
*/
|
||||
|
||||
#include "check.h"
|
||||
|
||||
#define MAX_OSF_PARTITIONS 18
|
||||
#define DISKLABELMAGIC (0x82564557UL)
|
||||
|
||||
int osf_partition(struct parsed_partitions *state)
|
||||
{
|
||||
int i;
|
||||
int slot = 1;
|
||||
unsigned int npartitions;
|
||||
Sector sect;
|
||||
unsigned char *data;
|
||||
struct disklabel {
|
||||
__le32 d_magic;
|
||||
__le16 d_type,d_subtype;
|
||||
u8 d_typename[16];
|
||||
u8 d_packname[16];
|
||||
__le32 d_secsize;
|
||||
__le32 d_nsectors;
|
||||
__le32 d_ntracks;
|
||||
__le32 d_ncylinders;
|
||||
__le32 d_secpercyl;
|
||||
__le32 d_secprtunit;
|
||||
__le16 d_sparespertrack;
|
||||
__le16 d_sparespercyl;
|
||||
__le32 d_acylinders;
|
||||
__le16 d_rpm, d_interleave, d_trackskew, d_cylskew;
|
||||
__le32 d_headswitch, d_trkseek, d_flags;
|
||||
__le32 d_drivedata[5];
|
||||
__le32 d_spare[5];
|
||||
__le32 d_magic2;
|
||||
__le16 d_checksum;
|
||||
__le16 d_npartitions;
|
||||
__le32 d_bbsize, d_sbsize;
|
||||
struct d_partition {
|
||||
__le32 p_size;
|
||||
__le32 p_offset;
|
||||
__le32 p_fsize;
|
||||
u8 p_fstype;
|
||||
u8 p_frag;
|
||||
__le16 p_cpg;
|
||||
} d_partitions[MAX_OSF_PARTITIONS];
|
||||
} * label;
|
||||
struct d_partition * partition;
|
||||
|
||||
data = read_part_sector(state, 0, §);
|
||||
if (!data)
|
||||
return -1;
|
||||
|
||||
label = (struct disklabel *) (data+64);
|
||||
partition = label->d_partitions;
|
||||
if (le32_to_cpu(label->d_magic) != DISKLABELMAGIC) {
|
||||
put_dev_sector(sect);
|
||||
return 0;
|
||||
}
|
||||
if (le32_to_cpu(label->d_magic2) != DISKLABELMAGIC) {
|
||||
put_dev_sector(sect);
|
||||
return 0;
|
||||
}
|
||||
npartitions = le16_to_cpu(label->d_npartitions);
|
||||
if (npartitions > MAX_OSF_PARTITIONS) {
|
||||
put_dev_sector(sect);
|
||||
return 0;
|
||||
}
|
||||
for (i = 0 ; i < npartitions; i++, partition++) {
|
||||
if (slot == state->limit)
|
||||
break;
|
||||
if (le32_to_cpu(partition->p_size))
|
||||
put_partition(state, slot,
|
||||
le32_to_cpu(partition->p_offset),
|
||||
le32_to_cpu(partition->p_size));
|
||||
slot++;
|
||||
}
|
||||
strlcat(state->pp_buf, "\n", PAGE_SIZE);
|
||||
put_dev_sector(sect);
|
||||
return 1;
|
||||
}
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/*
|
||||
* fs/partitions/osf.c
|
||||
*
|
||||
* Code extracted from drivers/block/genhd.c
|
||||
*
|
||||
* Copyright (C) 1991-1998 Linus Torvalds
|
||||
* Re-organised Feb 1998 Russell King
|
||||
*/
|
||||
|
||||
#include "check.h"
|
||||
|
||||
#define MAX_OSF_PARTITIONS 18
|
||||
#define DISKLABELMAGIC (0x82564557UL)
|
||||
|
||||
int osf_partition(struct parsed_partitions *state)
|
||||
{
|
||||
int i;
|
||||
int slot = 1;
|
||||
unsigned int npartitions;
|
||||
Sector sect;
|
||||
unsigned char *data;
|
||||
struct disklabel {
|
||||
__le32 d_magic;
|
||||
__le16 d_type,d_subtype;
|
||||
u8 d_typename[16];
|
||||
u8 d_packname[16];
|
||||
__le32 d_secsize;
|
||||
__le32 d_nsectors;
|
||||
__le32 d_ntracks;
|
||||
__le32 d_ncylinders;
|
||||
__le32 d_secpercyl;
|
||||
__le32 d_secprtunit;
|
||||
__le16 d_sparespertrack;
|
||||
__le16 d_sparespercyl;
|
||||
__le32 d_acylinders;
|
||||
__le16 d_rpm, d_interleave, d_trackskew, d_cylskew;
|
||||
__le32 d_headswitch, d_trkseek, d_flags;
|
||||
__le32 d_drivedata[5];
|
||||
__le32 d_spare[5];
|
||||
__le32 d_magic2;
|
||||
__le16 d_checksum;
|
||||
__le16 d_npartitions;
|
||||
__le32 d_bbsize, d_sbsize;
|
||||
struct d_partition {
|
||||
__le32 p_size;
|
||||
__le32 p_offset;
|
||||
__le32 p_fsize;
|
||||
u8 p_fstype;
|
||||
u8 p_frag;
|
||||
__le16 p_cpg;
|
||||
} d_partitions[MAX_OSF_PARTITIONS];
|
||||
} * label;
|
||||
struct d_partition * partition;
|
||||
|
||||
data = read_part_sector(state, 0, §);
|
||||
if (!data)
|
||||
return -1;
|
||||
|
||||
label = (struct disklabel *) (data+64);
|
||||
partition = label->d_partitions;
|
||||
if (le32_to_cpu(label->d_magic) != DISKLABELMAGIC) {
|
||||
put_dev_sector(sect);
|
||||
return 0;
|
||||
}
|
||||
if (le32_to_cpu(label->d_magic2) != DISKLABELMAGIC) {
|
||||
put_dev_sector(sect);
|
||||
return 0;
|
||||
}
|
||||
npartitions = le16_to_cpu(label->d_npartitions);
|
||||
if (npartitions > MAX_OSF_PARTITIONS) {
|
||||
put_dev_sector(sect);
|
||||
return 0;
|
||||
}
|
||||
for (i = 0 ; i < npartitions; i++, partition++) {
|
||||
if (slot == state->limit)
|
||||
break;
|
||||
if (le32_to_cpu(partition->p_size))
|
||||
put_partition(state, slot,
|
||||
le32_to_cpu(partition->p_offset),
|
||||
le32_to_cpu(partition->p_size));
|
||||
slot++;
|
||||
}
|
||||
strlcat(state->pp_buf, "\n", PAGE_SIZE);
|
||||
put_dev_sector(sect);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1,87 +1,87 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/*
|
||||
* fs/partitions/sgi.c
|
||||
*
|
||||
* Code extracted from drivers/block/genhd.c
|
||||
*/
|
||||
|
||||
#include "check.h"
|
||||
|
||||
#define SGI_LABEL_MAGIC 0x0be5a941
|
||||
|
||||
enum {
|
||||
LINUX_RAID_PARTITION = 0xfd, /* autodetect RAID partition */
|
||||
};
|
||||
|
||||
struct sgi_disklabel {
|
||||
__be32 magic_mushroom; /* Big fat spliff... */
|
||||
__be16 root_part_num; /* Root partition number */
|
||||
__be16 swap_part_num; /* Swap partition number */
|
||||
s8 boot_file[16]; /* Name of boot file for ARCS */
|
||||
u8 _unused0[48]; /* Device parameter useless crapola.. */
|
||||
struct sgi_volume {
|
||||
s8 name[8]; /* Name of volume */
|
||||
__be32 block_num; /* Logical block number */
|
||||
__be32 num_bytes; /* How big, in bytes */
|
||||
} volume[15];
|
||||
struct sgi_partition {
|
||||
__be32 num_blocks; /* Size in logical blocks */
|
||||
__be32 first_block; /* First logical block */
|
||||
__be32 type; /* Type of this partition */
|
||||
} partitions[16];
|
||||
__be32 csum; /* Disk label checksum */
|
||||
__be32 _unused1; /* Padding */
|
||||
};
|
||||
|
||||
int sgi_partition(struct parsed_partitions *state)
|
||||
{
|
||||
int i, csum;
|
||||
__be32 magic;
|
||||
int slot = 1;
|
||||
unsigned int start, blocks;
|
||||
__be32 *ui, cs;
|
||||
Sector sect;
|
||||
struct sgi_disklabel *label;
|
||||
struct sgi_partition *p;
|
||||
|
||||
label = read_part_sector(state, 0, §);
|
||||
if (!label)
|
||||
return -1;
|
||||
p = &label->partitions[0];
|
||||
magic = label->magic_mushroom;
|
||||
if(be32_to_cpu(magic) != SGI_LABEL_MAGIC) {
|
||||
/*printk("Dev %s SGI disklabel: bad magic %08x\n",
|
||||
state->disk->disk_name, be32_to_cpu(magic));*/
|
||||
put_dev_sector(sect);
|
||||
return 0;
|
||||
}
|
||||
ui = ((__be32 *) (label + 1)) - 1;
|
||||
for(csum = 0; ui >= ((__be32 *) label);) {
|
||||
cs = *ui--;
|
||||
csum += be32_to_cpu(cs);
|
||||
}
|
||||
if(csum) {
|
||||
printk(KERN_WARNING "Dev %s SGI disklabel: csum bad, label corrupted\n",
|
||||
state->disk->disk_name);
|
||||
put_dev_sector(sect);
|
||||
return 0;
|
||||
}
|
||||
/* All SGI disk labels have 16 partitions, disks under Linux only
|
||||
* have 15 minor's. Luckily there are always a few zero length
|
||||
* partitions which we don't care about so we never overflow the
|
||||
* current_minor.
|
||||
*/
|
||||
for(i = 0; i < 16; i++, p++) {
|
||||
blocks = be32_to_cpu(p->num_blocks);
|
||||
start = be32_to_cpu(p->first_block);
|
||||
if (blocks) {
|
||||
put_partition(state, slot, start, blocks);
|
||||
if (be32_to_cpu(p->type) == LINUX_RAID_PARTITION)
|
||||
state->parts[slot].flags = ADDPART_FLAG_RAID;
|
||||
}
|
||||
slot++;
|
||||
}
|
||||
strlcat(state->pp_buf, "\n", PAGE_SIZE);
|
||||
put_dev_sector(sect);
|
||||
return 1;
|
||||
}
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/*
|
||||
* fs/partitions/sgi.c
|
||||
*
|
||||
* Code extracted from drivers/block/genhd.c
|
||||
*/
|
||||
|
||||
#include "check.h"
|
||||
|
||||
#define SGI_LABEL_MAGIC 0x0be5a941
|
||||
|
||||
enum {
|
||||
LINUX_RAID_PARTITION = 0xfd, /* autodetect RAID partition */
|
||||
};
|
||||
|
||||
struct sgi_disklabel {
|
||||
__be32 magic_mushroom; /* Big fat spliff... */
|
||||
__be16 root_part_num; /* Root partition number */
|
||||
__be16 swap_part_num; /* Swap partition number */
|
||||
s8 boot_file[16]; /* Name of boot file for ARCS */
|
||||
u8 _unused0[48]; /* Device parameter useless crapola.. */
|
||||
struct sgi_volume {
|
||||
s8 name[8]; /* Name of volume */
|
||||
__be32 block_num; /* Logical block number */
|
||||
__be32 num_bytes; /* How big, in bytes */
|
||||
} volume[15];
|
||||
struct sgi_partition {
|
||||
__be32 num_blocks; /* Size in logical blocks */
|
||||
__be32 first_block; /* First logical block */
|
||||
__be32 type; /* Type of this partition */
|
||||
} partitions[16];
|
||||
__be32 csum; /* Disk label checksum */
|
||||
__be32 _unused1; /* Padding */
|
||||
};
|
||||
|
||||
int sgi_partition(struct parsed_partitions *state)
|
||||
{
|
||||
int i, csum;
|
||||
__be32 magic;
|
||||
int slot = 1;
|
||||
unsigned int start, blocks;
|
||||
__be32 *ui, cs;
|
||||
Sector sect;
|
||||
struct sgi_disklabel *label;
|
||||
struct sgi_partition *p;
|
||||
|
||||
label = read_part_sector(state, 0, §);
|
||||
if (!label)
|
||||
return -1;
|
||||
p = &label->partitions[0];
|
||||
magic = label->magic_mushroom;
|
||||
if(be32_to_cpu(magic) != SGI_LABEL_MAGIC) {
|
||||
/*printk("Dev %s SGI disklabel: bad magic %08x\n",
|
||||
state->disk->disk_name, be32_to_cpu(magic));*/
|
||||
put_dev_sector(sect);
|
||||
return 0;
|
||||
}
|
||||
ui = ((__be32 *) (label + 1)) - 1;
|
||||
for(csum = 0; ui >= ((__be32 *) label);) {
|
||||
cs = *ui--;
|
||||
csum += be32_to_cpu(cs);
|
||||
}
|
||||
if(csum) {
|
||||
printk(KERN_WARNING "Dev %s SGI disklabel: csum bad, label corrupted\n",
|
||||
state->disk->disk_name);
|
||||
put_dev_sector(sect);
|
||||
return 0;
|
||||
}
|
||||
/* All SGI disk labels have 16 partitions, disks under Linux only
|
||||
* have 15 minor's. Luckily there are always a few zero length
|
||||
* partitions which we don't care about so we never overflow the
|
||||
* current_minor.
|
||||
*/
|
||||
for(i = 0; i < 16; i++, p++) {
|
||||
blocks = be32_to_cpu(p->num_blocks);
|
||||
start = be32_to_cpu(p->first_block);
|
||||
if (blocks) {
|
||||
put_partition(state, slot, start, blocks);
|
||||
if (be32_to_cpu(p->type) == LINUX_RAID_PARTITION)
|
||||
state->parts[slot].flags = ADDPART_FLAG_RAID;
|
||||
}
|
||||
slot++;
|
||||
}
|
||||
strlcat(state->pp_buf, "\n", PAGE_SIZE);
|
||||
put_dev_sector(sect);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1,95 +1,95 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/*
|
||||
* fs/partitions/sysv68.c
|
||||
*
|
||||
* Copyright (C) 2007 Philippe De Muyter <phdm@macqel.be>
|
||||
*/
|
||||
|
||||
#include "check.h"
|
||||
|
||||
/*
|
||||
* Volume ID structure: on first 256-bytes sector of disk
|
||||
*/
|
||||
|
||||
struct volumeid {
|
||||
u8 vid_unused[248];
|
||||
u8 vid_mac[8]; /* ASCII string "MOTOROLA" */
|
||||
};
|
||||
|
||||
/*
|
||||
* config block: second 256-bytes sector on disk
|
||||
*/
|
||||
|
||||
struct dkconfig {
|
||||
u8 ios_unused0[128];
|
||||
__be32 ios_slcblk; /* Slice table block number */
|
||||
__be16 ios_slccnt; /* Number of entries in slice table */
|
||||
u8 ios_unused1[122];
|
||||
};
|
||||
|
||||
/*
|
||||
* combined volumeid and dkconfig block
|
||||
*/
|
||||
|
||||
struct dkblk0 {
|
||||
struct volumeid dk_vid;
|
||||
struct dkconfig dk_ios;
|
||||
};
|
||||
|
||||
/*
|
||||
* Slice Table Structure
|
||||
*/
|
||||
|
||||
struct slice {
|
||||
__be32 nblocks; /* slice size (in blocks) */
|
||||
__be32 blkoff; /* block offset of slice */
|
||||
};
|
||||
|
||||
|
||||
int sysv68_partition(struct parsed_partitions *state)
|
||||
{
|
||||
int i, slices;
|
||||
int slot = 1;
|
||||
Sector sect;
|
||||
unsigned char *data;
|
||||
struct dkblk0 *b;
|
||||
struct slice *slice;
|
||||
char tmp[64];
|
||||
|
||||
data = read_part_sector(state, 0, §);
|
||||
if (!data)
|
||||
return -1;
|
||||
|
||||
b = (struct dkblk0 *)data;
|
||||
if (memcmp(b->dk_vid.vid_mac, "MOTOROLA", sizeof(b->dk_vid.vid_mac))) {
|
||||
put_dev_sector(sect);
|
||||
return 0;
|
||||
}
|
||||
slices = be16_to_cpu(b->dk_ios.ios_slccnt);
|
||||
i = be32_to_cpu(b->dk_ios.ios_slcblk);
|
||||
put_dev_sector(sect);
|
||||
|
||||
data = read_part_sector(state, i, §);
|
||||
if (!data)
|
||||
return -1;
|
||||
|
||||
slices -= 1; /* last slice is the whole disk */
|
||||
snprintf(tmp, sizeof(tmp), "sysV68: %s(s%u)", state->name, slices);
|
||||
strlcat(state->pp_buf, tmp, PAGE_SIZE);
|
||||
slice = (struct slice *)data;
|
||||
for (i = 0; i < slices; i++, slice++) {
|
||||
if (slot == state->limit)
|
||||
break;
|
||||
if (be32_to_cpu(slice->nblocks)) {
|
||||
put_partition(state, slot,
|
||||
be32_to_cpu(slice->blkoff),
|
||||
be32_to_cpu(slice->nblocks));
|
||||
snprintf(tmp, sizeof(tmp), "(s%u)", i);
|
||||
strlcat(state->pp_buf, tmp, PAGE_SIZE);
|
||||
}
|
||||
slot++;
|
||||
}
|
||||
strlcat(state->pp_buf, "\n", PAGE_SIZE);
|
||||
put_dev_sector(sect);
|
||||
return 1;
|
||||
}
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/*
|
||||
* fs/partitions/sysv68.c
|
||||
*
|
||||
* Copyright (C) 2007 Philippe De Muyter <phdm@macqel.be>
|
||||
*/
|
||||
|
||||
#include "check.h"
|
||||
|
||||
/*
|
||||
* Volume ID structure: on first 256-bytes sector of disk
|
||||
*/
|
||||
|
||||
struct volumeid {
|
||||
u8 vid_unused[248];
|
||||
u8 vid_mac[8]; /* ASCII string "MOTOROLA" */
|
||||
};
|
||||
|
||||
/*
|
||||
* config block: second 256-bytes sector on disk
|
||||
*/
|
||||
|
||||
struct dkconfig {
|
||||
u8 ios_unused0[128];
|
||||
__be32 ios_slcblk; /* Slice table block number */
|
||||
__be16 ios_slccnt; /* Number of entries in slice table */
|
||||
u8 ios_unused1[122];
|
||||
};
|
||||
|
||||
/*
|
||||
* combined volumeid and dkconfig block
|
||||
*/
|
||||
|
||||
struct dkblk0 {
|
||||
struct volumeid dk_vid;
|
||||
struct dkconfig dk_ios;
|
||||
};
|
||||
|
||||
/*
|
||||
* Slice Table Structure
|
||||
*/
|
||||
|
||||
struct slice {
|
||||
__be32 nblocks; /* slice size (in blocks) */
|
||||
__be32 blkoff; /* block offset of slice */
|
||||
};
|
||||
|
||||
|
||||
int sysv68_partition(struct parsed_partitions *state)
|
||||
{
|
||||
int i, slices;
|
||||
int slot = 1;
|
||||
Sector sect;
|
||||
unsigned char *data;
|
||||
struct dkblk0 *b;
|
||||
struct slice *slice;
|
||||
char tmp[64];
|
||||
|
||||
data = read_part_sector(state, 0, §);
|
||||
if (!data)
|
||||
return -1;
|
||||
|
||||
b = (struct dkblk0 *)data;
|
||||
if (memcmp(b->dk_vid.vid_mac, "MOTOROLA", sizeof(b->dk_vid.vid_mac))) {
|
||||
put_dev_sector(sect);
|
||||
return 0;
|
||||
}
|
||||
slices = be16_to_cpu(b->dk_ios.ios_slccnt);
|
||||
i = be32_to_cpu(b->dk_ios.ios_slcblk);
|
||||
put_dev_sector(sect);
|
||||
|
||||
data = read_part_sector(state, i, §);
|
||||
if (!data)
|
||||
return -1;
|
||||
|
||||
slices -= 1; /* last slice is the whole disk */
|
||||
snprintf(tmp, sizeof(tmp), "sysV68: %s(s%u)", state->name, slices);
|
||||
strlcat(state->pp_buf, tmp, PAGE_SIZE);
|
||||
slice = (struct slice *)data;
|
||||
for (i = 0; i < slices; i++, slice++) {
|
||||
if (slot == state->limit)
|
||||
break;
|
||||
if (be32_to_cpu(slice->nblocks)) {
|
||||
put_partition(state, slot,
|
||||
be32_to_cpu(slice->blkoff),
|
||||
be32_to_cpu(slice->nblocks));
|
||||
snprintf(tmp, sizeof(tmp), "(s%u)", i);
|
||||
strlcat(state->pp_buf, tmp, PAGE_SIZE);
|
||||
}
|
||||
slot++;
|
||||
}
|
||||
strlcat(state->pp_buf, "\n", PAGE_SIZE);
|
||||
put_dev_sector(sect);
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user