mirror of
https://github.com/linux-msm/qbootctl.git
synced 2026-02-25 13:13:44 -08:00
drop test stub, fix licenses
This commit is contained in:
17
bootctrl.h
17
bootctrl.h
@@ -1,6 +1,20 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
* Copyright (C) 2022 Caleb Connolly <caleb@connolly.tech>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*
|
||||
* Copyright (C) 2023 Caleb Connolly <caleb@connolly.tech>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -99,6 +113,5 @@ struct boot_control_module {
|
||||
};
|
||||
|
||||
extern const struct boot_control_module bootctl;
|
||||
extern const struct boot_control_module bootctl_test;
|
||||
|
||||
#endif // __BOOTCTRL_H__
|
||||
|
||||
@@ -1,6 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2016, The Linux Foundation. All rights reserved.
|
||||
* Copyright (C) 2021-2022 Caleb Connolly <caleb@connolly.tech>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*
|
||||
* Copyright (C) 2021-2023 Caleb Connolly <caleb@connolly.tech>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
* Copyright (C) 2022 Caleb Connolly <caleb@connolly.tech>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "bootctrl.h"
|
||||
|
||||
struct test_state {
|
||||
struct slot_info slots[2];
|
||||
};
|
||||
|
||||
static struct test_state state = {
|
||||
.slots = {
|
||||
[0] = {
|
||||
.active = true,
|
||||
.bootable = true,
|
||||
.successful = false,
|
||||
},
|
||||
[1] = {
|
||||
.active = false,
|
||||
.bootable = true,
|
||||
.successful = false,
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
unsigned test_get_current_slot()
|
||||
{
|
||||
return (unsigned int)state.slots[1].active;
|
||||
}
|
||||
|
||||
int test_mark_boot_successful(unsigned slot)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_set_active_boot_slot(unsigned slot)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_set_slot_as_unbootable(unsigned slot)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_is_slot_bootable(unsigned slot)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char *test_get_suffix(unsigned slot)
|
||||
{
|
||||
switch (slot) {
|
||||
case 0:
|
||||
return "_x";
|
||||
case 1:
|
||||
return "_z";
|
||||
default:
|
||||
return "??";
|
||||
}
|
||||
}
|
||||
|
||||
int test_is_slot_marked_successful(unsigned slot)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
unsigned test_get_active_boot_slot()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
const struct boot_control_module bootctl_test = {
|
||||
.getCurrentSlot = test_get_current_slot,
|
||||
.markBootSuccessful = test_mark_boot_successful,
|
||||
.setActiveBootSlot = test_set_active_boot_slot,
|
||||
.setSlotAsUnbootable = test_set_slot_as_unbootable,
|
||||
.isSlotBootable = test_is_slot_bootable,
|
||||
.getSuffix = test_get_suffix,
|
||||
.isSlotMarkedSuccessful = test_is_slot_marked_successful,
|
||||
.getActiveBootSlot = test_get_active_boot_slot,
|
||||
};
|
||||
16
crc32.c
16
crc32.c
@@ -6,6 +6,22 @@
|
||||
* - changed crc32val to be a register
|
||||
* - License remains unchanged! It's still GPL-compatable!
|
||||
*/
|
||||
/*
|
||||
GPL-2 License
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copied from efibootmgr 2023-06-23
|
||||
|
||||
1
crc32.h
1
crc32.h
@@ -4,6 +4,7 @@
|
||||
|
||||
crc32.h
|
||||
|
||||
GPL-2 License
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
|
||||
@@ -9,7 +9,6 @@ endif
|
||||
src = [
|
||||
'qbootctl.c',
|
||||
'bootctrl_impl.c',
|
||||
'bootctrl_test.c',
|
||||
'gpt-utils.c',
|
||||
'ufs-bsg.c',
|
||||
'crc32.c',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Caleb Connolly <caleb@connolly.tech>
|
||||
* Copyright (C) 2023 Caleb Connolly <caleb@connolly.tech>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -140,11 +140,6 @@ int main(int argc, char **argv)
|
||||
int slot = -1;
|
||||
int rc;
|
||||
|
||||
const char* IS_TEST = getenv("QBOOTCTL_TEST");
|
||||
if (IS_TEST) {
|
||||
impl = &bootctl_test;
|
||||
}
|
||||
|
||||
if(geteuid() != 0) {
|
||||
fprintf(stderr, "This program must be run as root!\n");
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user