Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 922917 Details for
Bug 1125273
bcache device registration may temporarily fail (device busy)
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
C program to register a bcache device, trying again when appropriate
bcreg.c (text/plain), 1.63 KB, created by
Ian Pilcher
on 2014-07-31 13:20:50 UTC
(
hide
)
Description:
C program to register a bcache device, trying again when appropriate
Filename:
MIME Type:
Creator:
Ian Pilcher
Created:
2014-07-31 13:20:50 UTC
Size:
1.63 KB
patch
obsolete
>#include <stdlib.h> >#include <string.h> >#include <unistd.h> >#include <stdio.h> >#include <fcntl.h> >#include <errno.h> >#include <time.h> > >/* How often to wake up and check when waiting for something; 1/10 second */ >#define WAKEUP_NSEC 100000000L > >/* Timeouts are in multiples of WAKEUP_NSEC */ >#define SYSFS_TIMEOUT 50 /* 5 seconds */ >#define DEVICE_TIMEOUT 50 /* 5 seconds */ > >static const char sysfs_reg[] = "/sys/fs/bcache/register"; > >int main(int argc, char *argv[]) >{ > struct timespec timeout; > size_t len; > int i, fd; > > if (argc != 2) { > fprintf(stderr, "USAGE: %s <BLOCK_DEVICE>\n", argv[0]); > exit(EXIT_FAILURE); > } > > i = SYSFS_TIMEOUT; > > while (1) { > > fd = open(sysfs_reg, O_WRONLY); > if (fd != -1) > break; > > if (errno != ENOENT) { > perror(sysfs_reg); > exit(EXIT_FAILURE); > } > > if (i-- == 0) { > fprintf(stderr, "Timed out waiting for %s\n", sysfs_reg); > exit(EXIT_FAILURE); > } > > timeout.tv_sec = 0; > timeout.tv_nsec = WAKEUP_NSEC; > > if (nanosleep(&timeout, NULL) == -1) { > perror("nanosleep"); > exit(EXIT_FAILURE); > } > } > > len = strlen(argv[1]); > i = DEVICE_TIMEOUT; > > while (1) { > > if (lseek(fd, 0, SEEK_SET) == -1) { > perror(sysfs_reg); > close(fd); > exit(EXIT_FAILURE); > } > > if (write(fd, argv[1], len) == (ssize_t)len) > break; > > if (errno != EBUSY) { > perror(argv[1]); > close(fd); > exit(EXIT_FAILURE); > } > > if (i-- == 0) { > fprintf(stderr, "Timed out waiting for %s\n", argv[1]); > close(fd); > exit(EXIT_FAILURE); > } > > timeout.tv_sec = 0; > timeout.tv_nsec = WAKEUP_NSEC; > > if (nanosleep(&timeout, NULL) == -1) { > perror("nanosleep"); > close(fd); > exit(EXIT_FAILURE); > } > } > > close(fd); > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 1125273
:
922915
| 922917 |
922929