diff --git a/unix/ioctl_signed.go b/unix/ioctl_signed.go
index 5b0759b..be0f3fb 100644
--- a/unix/ioctl_signed.go
+++ b/unix/ioctl_signed.go
@@ -6,9 +6,7 @@
package unix
-import (
- "unsafe"
-)
+import "unsafe"
// ioctl itself should not be exposed directly, but additional get/set
// functions for specific types are permissible.
@@ -28,6 +26,13 @@
return ioctlPtr(fd, req, unsafe.Pointer(&v))
}
+// IoctlSetString performs an ioctl operation which sets a string value
+// on fd, using the specified request number.
+func IoctlSetString(fd int, req int, value string) error {
+ bs := append([]byte(value), 0)
+ return ioctlPtr(fd, req, unsafe.Pointer(&bs[0]))
+}
+
// IoctlSetWinsize performs an ioctl on fd with a *Winsize argument.
//
// To change fd's window size, the req argument should be TIOCSWINSZ.
diff --git a/unix/ioctl_unsigned.go b/unix/ioctl_unsigned.go
index 20f470b..f0c2821 100644
--- a/unix/ioctl_unsigned.go
+++ b/unix/ioctl_unsigned.go
@@ -6,9 +6,7 @@
package unix
-import (
- "unsafe"
-)
+import "unsafe"
// ioctl itself should not be exposed directly, but additional get/set
// functions for specific types are permissible.
@@ -28,6 +26,13 @@
return ioctlPtr(fd, req, unsafe.Pointer(&v))
}
+// IoctlSetString performs an ioctl operation which sets a string value
+// on fd, using the specified request number.
+func IoctlSetString(fd int, req uint, value string) error {
+ bs := append([]byte(value), 0)
+ return ioctlPtr(fd, req, unsafe.Pointer(&bs[0]))
+}
+
// IoctlSetWinsize performs an ioctl on fd with a *Winsize argument.
//
// To change fd's window size, the req argument should be TIOCSWINSZ.
diff --git a/unix/syscall_solaris.go b/unix/syscall_solaris.go
index 18a3d9b..a6a2ea0 100644
--- a/unix/syscall_solaris.go
+++ b/unix/syscall_solaris.go
@@ -1052,14 +1052,6 @@
return ioctlRet(fd, req, uintptr(arg))
}
-func IoctlSetString(fd int, req int, val string) error {
- bs := make([]byte, len(val)+1)
- copy(bs[:len(bs)-1], val)
- err := ioctlPtr(fd, req, unsafe.Pointer(&bs[0]))
- runtime.KeepAlive(&bs[0])
- return err
-}
-
// Lifreq Helpers
func (l *Lifreq) SetName(name string) error {