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: losetup_linux.go
    path of file: ./repos/moby/vendor/github.com/containerd/containerd/mount
    
    the code of the file until where you have to start completion: /*
   Copyright The containerd Authors.

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless require
    
func setupLoop(backingFile string, param LoopParams) (*os.File, error) {
	for retry := 1; retry < 100; retry++ {
		num, err := getFreeLoopDev()
		if err != nil {
			return nil, err
		}

		loopDev := fmt.Sprintf(loopDevFormat, num)
		file, err := setupLoopDev(backingFile, loopDev, param)
		if err != nil {
			// Per util-linux/sys-utils/losetup.c:create_loop(),
			// free loop device can race and we end up failing
			// with EBUSY when trying to set it up.
			if strings.Contains(err.Error(), ebusyString) {
				// Fallback a bit to avoid live lock
				time.Sleep(time.Millisecond * time.Duration(randutil.Intn(retry*10)))
				continue
			}
			return nil, err
		}

		return file, nil
	}

	return nil, errors.New("timeout creating new loopback device")
}