mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 21:52:45 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			33 lines
		
	
	
	
		
			765 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
	
		
			765 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #include <LibCore/File.h>
 | |
| #include <stdio.h>
 | |
| #include <unistd.h>
 | |
| 
 | |
| int main([[maybe_unused]] int argc, [[maybe_unused]] char** argv)
 | |
| {
 | |
|     if (pledge("stdio rpath", nullptr) < 0) {
 | |
|         perror("pledge");
 | |
|         return 1;
 | |
|     }
 | |
| 
 | |
|     if (unveil("/proc/dmesg", "r") < 0) {
 | |
|         perror("unveil");
 | |
|         return 1;
 | |
|     }
 | |
| 
 | |
|     unveil(nullptr, nullptr);
 | |
| 
 | |
|     auto file = Core::File::construct("/proc/dmesg");
 | |
|     if (!file->open(Core::OpenMode::ReadOnly)) {
 | |
|         warnln("Failed to open {}: {}", file->name(), file->error_string());
 | |
|         return 1;
 | |
|     }
 | |
|     auto buffer = file->read_all();
 | |
|     out("{}", String::copy(buffer));
 | |
|     return 0;
 | |
| }
 | 
