open-cas-linux/configure.d/1_bdev_lookup.conf
Rafal Stefanowski 91f5d497ef copyright/license: Add missing file extensions
Proper file extensions help 'copyright header checker' find files
that should contain copyright info. Extensions also clearly indicate
file type, and help to fit in with the file naming convention.

Signed-off-by: Rafal Stefanowski <rafal.stefanowski@intel.com>
2022-09-07 15:23:11 +02:00

106 lines
2.4 KiB
Bash

#!/bin/bash
#
# Copyright(c) 2012-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
. $(dirname $3)/conf_framework.sh
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "dev_t dev; lookup_bdev(\"some_path\", &dev);" "linux/blkdev.h"
then
echo $cur_name "1" >> $config_file_path
elif compile_module $cur_name "lookup_bdev(\"some_path\");" "linux/fs.h" "linux/blkdev.h"
then
echo $cur_name "2" >> $config_file_path
elif compile_module $cur_name "lookup_bdev(\"some_path\", 0);" "linux/fs.h" "linux/blkdev.h"
then
echo $cur_name "3" >> $config_file_path
else
echo $cur_name "X" >> $config_file_path
fi
}
apply() {
case "$1" in
"1")
add_function "
static inline bool cas_bdev_exist(const char *path)
{
dev_t dev;
int result;
result = lookup_bdev(path, &dev);
return !result;
}"
add_function "
static inline bool cas_bdev_match(const char *path, struct block_device *bd)
{
dev_t dev;
int result;
result = lookup_bdev(path, &dev);
if (result)
return false;
return (bd->bd_dev == dev);
}" ;;
"2")
add_function "
static inline bool cas_bdev_exist(const char *path)
{
struct block_device *bdev;
bdev = lookup_bdev(path);
if (IS_ERR(bdev))
return false;
bdput(bdev);
return true;
}"
add_function "
static inline bool cas_bdev_match(const char *path, struct block_device *bd)
{
struct block_device *bdev;
bool match = false;
bdev = lookup_bdev(path);
if (IS_ERR(bdev))
return false;
match = (bdev == bd);
bdput(bdev);
return match;
}" ;;
"3")
add_function "
static inline bool cas_bdev_exist(const char *path)
{
struct block_device *bdev;
bdev = lookup_bdev(path, 0);
if (IS_ERR(bdev))
return false;
bdput(bdev);
return true;
}"
add_function "
static inline bool cas_bdev_match(const char *path, struct block_device *bd)
{
struct block_device *bdev;
bool match = false;
bdev = lookup_bdev(path, 0);
if (IS_ERR(bdev))
return false;
match = (bdev == bd);
bdput(bdev);
return match;
}" ;;
*)
exit 1
esac
}
conf_run $@