Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions fboss/platform/showtech/Main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) 2004-present, Meta Platforms, Inc. and affiliates.
// All Rights Reserved.
#include <unistd.h>
#include <algorithm>
#include <ranges>
#include <set>
Expand Down Expand Up @@ -103,6 +104,11 @@ int main(int argc, char** argv) {
return app.exit(e);
}

if (geteuid() != 0) {
std::cerr << "Please run this program as root" << std::endl;
return 1;
}

try {
std::string showtechConfJson =
ConfigLib(configFilePath).getShowtechConfig();
Expand Down
6 changes: 4 additions & 2 deletions fboss/platform/showtech/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ void Utils::printGpio(const Gpio& gpio) {
struct gpiod_chip* chip = gpiod_chip_open(gpio.path()->c_str());
for (const auto& line : *gpio.lines()) {
std::cout << fmt::format(
"line {:>3}: {:<15} -> ", *line.lineIndex(), *line.name());
"line {:>2}: {:<15} -> ", *line.lineIndex(), *line.name());
try {
std::cout << GpiodLine(chip, *line.lineIndex(), *line.name()).getValue()
<< std::endl;
Expand All @@ -471,7 +471,9 @@ void Utils::printGpio(const Gpio& gpio) {
<< std::endl;
}
}
gpiod_chip_close(chip);
if (chip) {
gpiod_chip_close(chip);
}
std::cout << std::endl;
}

Expand Down
Loading