Page Menu
Home
ClusterLabs Projects
Search
Configure Global Search
Log In
Files
F4511855
api_nozzle_get_fd.c
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
api_nozzle_get_fd.c
View Options
/*
* Copyright (C) 2018-2025 Red Hat, Inc. All rights reserved.
*
* Author: Fabio M. Di Nitto <fabbione@kronosnet.org>
*
* This software licensed under GPL-2.0+
*/
#include "config.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <stdint.h>
#include <limits.h>
#include <fcntl.h>
#include "test-common.h"
static int test(void)
{
char device_name[IFNAMSIZ];
size_t size = IFNAMSIZ;
int err=0;
nozzle_t nozzle;
int fd;
printf("Testing get fd\n");
memset(device_name, 0, size);
nozzle = nozzle_open(device_name, size, NULL);
if (!nozzle) {
printf("Unable to init %s\n", device_name);
return -1;
}
fd = nozzle_get_fd(nozzle);
if (fd < 0) {
printf("Unable to get fd\n");
err = -1;
goto out_clean;
}
if (fcntl(fd, F_GETFD) < 0) {
printf("Unable to get valid fd\n");
err = -1;
goto out_clean;
}
printf("Testing ERROR conditions\n");
printf("Passing empty struct to get_fd\n");
if (nozzle_get_fd(NULL) > 0) {
printf("Something is wrong in nozzle_get_fd sanity checks\n");
err = -1;
goto out_clean;
}
out_clean:
if (nozzle) {
nozzle_close(nozzle);
}
return err;
}
int main(void)
{
need_root();
need_tun();
if (test() < 0)
return FAIL;
return PASS;
}
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Wed, Jun 25, 3:00 AM (15 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1951932
Default Alt Text
api_nozzle_get_fd.c (1 KB)
Attached To
Mode
rK kronosnet
Attached
Detach File
Event Timeline
Log In to Comment