You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: mlock_unix.go
    path of file: ./repos/sealer/vendor/go.etcd.io/bbolt
    
    the code of the file until where you have to start completion: // +build !windows

package bbolt

import "golang.org/x/sys/unix"

// mlock locks memory of db file
func mlock(db *DB, fileSize int) error {
	sizeToLock := fi
    
func mlock(db *DB, fileSize int) error {
	sizeToLock := fileSize
	if sizeToLock > db.datasz {
		// Can't lock more than mmaped slice
		sizeToLock = db.datasz
	}
	if err := unix.Mlock(db.dataref[:sizeToLock]); err != nil {
		return err
	}
	return nil
}