Skip to content

Commit

Permalink
Replace meaningless ID column with FD column in lock screen
Browse files Browse the repository at this point in the history
Doubly meaningless since the IDs are now per-FD
  • Loading branch information
nabijaczleweli authored and BenBE committed Jan 8, 2023
1 parent 67bc7fe commit 8def4d6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions ProcessLocksScreen.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ 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, " ID 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:INODE START END FILENAME");
}

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

char entry[512];
if (ULLONG_MAX == data->end) {
xSnprintf(entry, sizeof(entry), "%10d %-10s %-10s %-10s %02x:%02x:%020"PRIu64" %20"PRIu64" %20s %s",
data->id,
xSnprintf(entry, sizeof(entry), "%5d %-10s %-10s %-10s %02x:%02x:%020"PRIu64" %20"PRIu64" %20s %s",
data->fd,
data->locktype, data->exclusive, data->readwrite,
data->dev[0], data->dev[1], data->inode,
data->start, "<END OF FILE>",
data->filename ? data->filename : "<N/A>"
);
} else {
xSnprintf(entry, sizeof(entry), "%10d %-10s %-10s %-10s %02x:%02x:%020"PRIu64" %20"PRIu64" %20"PRIu64" %s",
data->id,
xSnprintf(entry, sizeof(entry), "%5d %-10s %-10s %-10s %02x:%02x:%020"PRIu64" %20"PRIu64" %20"PRIu64" %s",
data->fd,
data->locktype, data->exclusive, data->readwrite,
data->dev[0], data->dev[1], data->inode,
data->start, data->end,
Expand Down
2 changes: 1 addition & 1 deletion ProcessLocksScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ typedef struct FileLocks_Data_ {
char* exclusive;
char* readwrite;
char* filename;
int id;
int fd;
unsigned int dev[2];
uint64_t inode;
uint64_t start;
Expand Down
6 changes: 3 additions & 3 deletions linux/Platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ FileLocks_ProcessData* Platform_getProcessLocks(pid_t pid) {

errno = 0;
char *end = de->d_name;
strtoull(de->d_name, &end, 10);
int file = strtoull(de->d_name, &end, 10);
if (errno || *end)
continue;

Expand All @@ -476,11 +476,11 @@ FileLocks_ProcessData* Platform_getProcessLocks(pid_t pid) {
if (strncmp(buffer, "lock:\t", strlen("lock:\t")))
continue;

FileLocks_Data data = {0};
FileLocks_Data data = {.fd = file};
int _;
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",
&data.id, locktype, exclusive, readwrite, &_,
&_, locktype, exclusive, readwrite, &_,
&data.dev[0], &data.dev[1], &data.inode,
&data.start, lock_end))
continue;
Expand Down

0 comments on commit 8def4d6

Please sign in to comment.