Skip to content

Commit

Permalink
Use a 0x{devnum} format for devices in lock screen, like files screen
Browse files Browse the repository at this point in the history
Also reflow it to not be absolutely bonkers
  • Loading branch information
nabijaczleweli authored and BenBE committed Jan 8, 2023
1 parent 8def4d6 commit 650cf0f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
11 changes: 6 additions & 5 deletions ProcessLocksScreen.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ ProcessLocksScreen* ProcessLocksScreen_new(const Process* process) {
this->pid = process->tgid;
else
this->pid = process->pid;
return (ProcessLocksScreen*) InfoScreen_init(&this->super, process, NULL, LINES - 2, " FD TYPE EXCLUSION READ/WRITE DEVICE:INODE START END FILENAME");

return (ProcessLocksScreen*) InfoScreen_init(&this->super, process, NULL, LINES - 2, " FD TYPE EXCLUSION READ/WRITE DEVICE NODE START END FILENAME");
}

void ProcessLocksScreen_delete(Object* this) {
Expand Down Expand Up @@ -64,18 +65,18 @@ static void ProcessLocksScreen_scan(InfoScreen* this) {

char entry[512];
if (ULLONG_MAX == data->end) {
xSnprintf(entry, sizeof(entry), "%5d %-10s %-10s %-10s %02x:%02x:%020"PRIu64" %20"PRIu64" %20s %s",
xSnprintf(entry, sizeof(entry), "%5d %-10s %-10s %-10s %#6"PRIx64" %10"PRIu64" %19"PRIu64" %19s %s",
data->fd,
data->locktype, data->exclusive, data->readwrite,
data->dev[0], data->dev[1], data->inode,
(uint64_t) data->dev, data->inode,
data->start, "<END OF FILE>",
data->filename ? data->filename : "<N/A>"
);
} else {
xSnprintf(entry, sizeof(entry), "%5d %-10s %-10s %-10s %02x:%02x:%020"PRIu64" %20"PRIu64" %20"PRIu64" %s",
xSnprintf(entry, sizeof(entry), "%5d %-10s %-10s %-10s %#6"PRIx64" %10"PRIu64" %19"PRIu64" %19"PRIu64" %s",
data->fd,
data->locktype, data->exclusive, data->readwrite,
data->dev[0], data->dev[1], data->inode,
(uint64_t) data->dev, data->inode,
data->start, data->end,
data->filename ? data->filename : "<N/A>"
);
Expand Down
2 changes: 1 addition & 1 deletion ProcessLocksScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ typedef struct FileLocks_Data_ {
char* readwrite;
char* filename;
int fd;
unsigned int dev[2];
dev_t dev;
uint64_t inode;
uint64_t start;
uint64_t end;
Expand Down
5 changes: 4 additions & 1 deletion linux/Platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ in the source distribution for its full text.
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <sys/sysmacros.h>

#include "BatteryMeter.h"
#include "ClockMeter.h"
Expand Down Expand Up @@ -478,16 +479,18 @@ FileLocks_ProcessData* Platform_getProcessLocks(pid_t pid) {

FileLocks_Data data = {.fd = file};
int _;
unsigned int maj, min;
char lock_end[25], locktype[32], exclusive[32], readwrite[32];
if (10 != sscanf(buffer + strlen("lock:\t"), "%d: %31s %31s %31s %d %x:%x:%"PRIu64" %"PRIu64" %24s",
&_, locktype, exclusive, readwrite, &_,
&data.dev[0], &data.dev[1], &data.inode,
&maj, &min, &data.inode,
&data.start, lock_end))
continue;

data.locktype = xStrdup(locktype);
data.exclusive = xStrdup(exclusive);
data.readwrite = xStrdup(readwrite);
data.dev = makedev(maj, min);

if (String_eq(lock_end, "EOF"))
data.end = ULLONG_MAX;
Expand Down

0 comments on commit 650cf0f

Please sign in to comment.